Saturday, January 17, 2009

Transparent proxy in Ubuntu

I have a socks5 proxy on my machine (actually on my Android phone, but port-forwarded through adb), and want non-socks5 aware applications to be able to use it. I tried tsocks, but couldn't get it to work with wget - it wouldn't proxy the DNS resolution, even if I set the compile time flags. I then switched to proxychains, which works great with wget and other commandline utils. The only issue is that proxychains does not seem to work with stand-alone java applications, failing in the connection library like:


Caused by: java.net.SocketException: Network is unreachable
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
at java.net.Socket.connect(Socket.java:519)
at java.net.Socket.connect(Socket.java:469)
at sun.net.NetworkClient.doConnect(NetworkClient.java:163)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:394)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:529)
at sun.net.www.http.HttpClient.(HttpClient.java:233)
at sun.net.www.http.HttpClient.New(HttpClient.java:306)
at sun.net.www.http.HttpClient.New(HttpClient.java:323)
at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:837)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:816)
at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:703)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1026)
at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:373)


Update: got this working with shell-wrapped jar files. See next post

No comments:

Post a Comment