|
-
Jan 4th, 2010, 02:32 PM
#1
Thread Starter
Frenzied Member
[RESOLVED] Getting WAN IP address without connecting to whatismyip.com
Hi, this question has been asked before, but I can't find the solution I'm looking for.
I'm creating an app to upload text messages to a server. I'd like to add the IP address of the user (encrypted) to the header of the message, so action can be taken when the user does something inappropriate.
Many people are behind a router and Winsock1.LocalIP will then show the LAN IP address, like 192.168.1.100 and not the WAN address.
Code:
Private Sub Command1_Click()
MsgBox Winsock1.LocalIP
End Sub
Then I thought, I might get the IP address when connecting to the server first, but then Winsock1.LocalIP returns 127.0.0.1 (local host).
Code:
Private Sub Command1_Click()
Winsock1.Connect "123.123.123.123", 80
End Sub
Private Sub Winsock1_Connect()
MsgBox Winsock1.LocalIP
End Sub
The only solution I know, is to connect to whatismyip.com or a similar site and read the IP address. Generally it works fine, but it might seem a little bit suspicious when people have a firewall installed and a message pops up that the app is trying to connect to whatismyip.com.
Is there any way to get the WAN address without getting it from an external source.
-
Jan 4th, 2010, 03:17 PM
#2
Re: Getting WAN IP address without connecting to whatismyip.com
Surely the server knows the IP that it is receiving data from, so why not store the IP in the server code?
-
Jan 4th, 2010, 03:18 PM
#3
Re: Getting WAN IP address without connecting to whatismyip.com
you can read the appropriate page from their router /gateway
or possibly use a php script on the server to upload the file and append the ip address
this php script would echo the wan ip back to a webbrowser
Code:
<?php
echo $_SERVER['REMOTE_ADDR']
?>
at least if it is on the same server as the file is being uploaded to it should not arouse suspicion
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Jan 4th, 2010, 07:26 PM
#4
Thread Starter
Frenzied Member
Re: Getting WAN IP address without connecting to whatismyip.com
The problem is that I don't have any control over the server, it are Usenet newsservers.
Members from a Usenet community use my app to post messages, but many of them use a premium newsserver. Premium newsservers never put the IP address of the user in the header (ISP newsservers usually do) and those people can do whatever they want anonymously. Certain parts of the header can be filled in by the client and by manually adding the users IP address to the header, they can be dealt with if they don't behave.
I guess it's not possible then 
Thank you for your replies.
-
Jan 4th, 2010, 07:36 PM
#5
PowerPoster
Re: Getting WAN IP address without connecting to whatismyip.com
Anything's possible, but rather than IP why don't you do some other uniquely identifiable and easily available information from the user's PC...if you give each user a custom key for their PC (search for security on the site, or under the deployment section) you could store an encrypted version of the key in the outgoing data and you'd instantly know who it was and could disable access to that person :-)
See, the more information people give is, the more we can do with it...we only go on what we get told :-P
Well, everyone else has been doing it :-)
Loading a file into memory QUICKLY - Using SendKeys - HyperLabel - A highly customisable label replacement - Using resource files/DLLs with VB - Adding GZip to your projects
Expect more to come in future
If I have helped you, RATE ME! :-)
I love helping noobs with their VB problems (probably because, as an amateur programmer, I am only slightly better at VB than them :-)) but if you SERIOUSLY want to get help for free from a community such as VBForums, you have to first have a grounding (basic knowledge) in VB6, otherwise you're way too much work to help...You've got to give a little if you want to get help from us, in other words!
And we DON'T do your homework. If your tutor doesn't teach you enough to help you make the project without his or her help, FIND A BETTER TUTOR or try reading books on programming! We are happy to help with minor things regarding the project, but you have to understand the rest of it if you want our help to be useful.
-
Jan 5th, 2010, 10:02 AM
#6
Thread Starter
Frenzied Member
Re: Getting WAN IP address without connecting to whatismyip.com
Thanks smUX, that's a possible solution.
The reason I don't give all that information at first, is that many people can't be bothered to read large posts. If you ask a simple question, then people tend to help you quicker. Large posts often stay unanswered.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|