Mega Code Archive

 
Categories / Delphi / LAN Web TCP
 

Get the ip-address bhind a router-proxy

{ Wenn man hinter einem Router oder Proxy seine richtige Internet-IP herausfinden möchte, dann brauch man die Hilfe von einem externen Internetserver, der einem die IP „verrät“. Realisierbar ist dies mit einer Kombination von PERL und DELPHI. Das folgende Perlscript muss auf einen Webspace, der CGI/Perl unterstützt geladen werden: If you are behind a router or proxy and want to get your real Internet-IP-Address then you need the help of a extern Internet Server. That extern Internet server have to tell you your real Ip-Address. You can make this with a combination of PERL and DELPHI. The following PERL-SCRIPT you have to upload to an Webspace witch allows Perl/CGI-access: } -------------------------------------------------------- #!/usr/local/bin/perl use CGI qw/:standard/; print "Content-type: text/html\n\n"; print "BEGINIP".$ENV{REMOTE_ADDR}."ENDIP"; -------------------------------------------------------- { Wenn die Adresse des Script’s http://www.my-server.de/cgi-bin/GiveMeMyIp.pl ist, dann ist der Delphi Quelltext, um die IP rauszufinden: If the address of the Script is "http://www.my-server.de/cgi-bin/GiveMeMyIp.pl" then the Delphi-Code to get your real IP is: } procedure TForm1.Button1Click(Sender: TObject); var IPSTR, IP, HP: string; BeginIP, EndIP, i: integer; begin Button1.Enabled := False; HP := ‘http://www.my-server.de/cgi-bin/GiveMeMyIp.pl’; NMHTTP1.Get(HP); IPSTR := (NMHTTP1.Body); BeginIP := Pos('BEGINIP', IPSTR) + Length('BEGINIP'); EndIP := Pos('ENDIP', IPSTR); IP := ''; for i := BeginIP to ENDip - 1 do begin IP := IP + IPstr[i]; end; label1.Caption := IP; Button1.Enabled := True; end;