android SOCKS proxy -


i have following code in (test) android project:

        url u = new url("http://www.google.com");          inetsocketaddress sa = inetsocketaddress.createunresolved("127.0.0.1", 1080);         proxy proxy = new proxy(proxy.type.socks, sa);         httpurlconnection conn = (httpurlconnection) u.openconnection(proxy); 

then have implemented socks server listening on port 1080.

the problem have in socks4 connection request, destination address , port not "ip google":80 rather 127.0.0.1:1080, i.e. proxy address.

if return ok, start getting http data.

am doing wrong or there bug in socks-client?

i have solution little lower level might useful you:

this works me on android 4.3 on rooted nexus 4 sshtunnel running:

    socketaddress proxyaddr = new inetsocketaddress("127.0.0.1", 1984);       socketaddress hostaddr = new inetsocketaddress(address, port);     java.net.proxy proxy = new java.net.proxy(java.net.proxy.type.socks, proxyaddr);     socket = new socket(proxy);     socket.connect(hostaddr); 

note: installed iptables beta i'm not sure if it's required.

for work emulator change ip 10.0.2.2 android's alias host machine. have run local socks proxy on machine of course.


Comments

Popular posts from this blog

django - How can I change user group without delete record -

java - Need to add SOAP security token -

java - EclipseLink JPA Object is not a known entity type -