2016-03-31 8 views
0

Haben Sie dieses Programm:JAVA: Falsche ip als Antwort über Proxy

public static void main(String[] args) { 
    System.setProperty("http.proxyHost", "177.40.136.238"); 
    System.setProperty("http.proxyPort", "8080"); 

    // Next connection will be through proxy. 
    try { 
     URL oracle = new URL("http://ip.jsontest.com/"); 
     while (true) { 
      URLConnection yc = oracle.openConnection(); 
      BufferedReader in = new BufferedReader(new InputStreamReader(
        yc.getInputStream())); 
      String inputLine; 
      while ((inputLine = in.readLine()) != null) 
       System.out.println(inputLine); 
      in.close(); 
     } 
    } catch (IOException e) { 
     e.printStackTrace(); 
    } 

    // Now, let's 'unset' the proxy. 
    System.clearProperty("http.proxyHost"); 
} 

Wenn ich ip in der Konsole zu bekommen, ist es nicht ip von gefassten Proxy wie ist (es ist ip meiner lokalen Station). Was habe ich falsch gemacht?

+0

Was meinen Sie mit "Get ip in der Konsole"? – f1sh

+0

Was ist das Ergebnis, wenn Sie auf diese URL im Browser zugreifen? –

+0

"get ip in console" bedeutet, dass ich Respons aussieht wie {"ip": "my.local.ip.address"} das gleiche wie im Browser – Dimka

Antwort

0

So war das Problem mit öffentlichen Proxy, die Ihre Anfrage Informationen nicht versteckt. Alles, was wir tun müssen - senden Sie unsere Anfrage durch anonyme Proxies.