欢迎访问 生活随笔!

生活随笔

当前位置: 首页 > 运维知识 > Android >内容正文

Android

orbot android教程,Android Orbot malformed reply from SOCKS server

发布时间:2023/12/3 Android 60 豆豆
生活随笔 收集整理的这篇文章主要介绍了 orbot android教程,Android Orbot malformed reply from SOCKS server 小编觉得挺不错的,现在分享给大家,帮大家做个参考.

问题

I am trying to enable TOR support on my own XMPP app in android. I am using orbot as TOR proxy and I have the following code to connect app socket:

socket = new Socket(new Proxy(Proxy.Type.SOCKS, new InetSocketAddress("127.0.0.1", 9050)));

socket.connect(addr, Config.SOCKET_TIMEOUT * 1000);

but I am getting Malformed reply from SOCKS server even that my Orbot is up and running. I believe that this error is thrown when app cant access proxy server or mentioned server is not SOCKS proxy.

I have also tried to use jsocks:

Socks5Proxy sProxy = new Socks5Proxy("127.0.0.1", 9050);

sProxy.resolveAddrLocally(false);

String host = account.getServer().toString();

int port = 5222;

System.out.println(host + ":" + port);

try {

socket = new SocksSocket(sProxy, host, port);

}catch(SocksException sock_ex){

System.err.println("SocksException:"+sock_ex);

}

System.out.println("here we are");

where host is "jabbim.com"

But I never get to "here we are" println so it looks like my app hangs somewhere on creating SocksSocket but I am not getting any errors either. When I debug it it hangs on impl.getInputStream somewhere in jsocks (PlainSocketImpl I believe)

Any idea how to fix this?

Thanks in forward

回答1:

I solved this using

compile "org.igniterealtime.smack:smack-android-extensions:4.1.4"

compile "org.igniterealtime.smack:smack-tcp:4.1.4"

and then connecting using this code:

final Random rndForTorCircuits = new Random();

String user = rndForTorCircuits.nextInt(100000) + "";

String pass = rndForTorCircuits.nextInt(100000) + "";

ProxyInfo proxyInfo = new ProxyInfo(ProxyInfo.ProxyType.SOCKS5, "127.0.0.1", 9050, user, pass);

socket = proxyInfo.getSocketFactory().createSocket(addr.getHostName(), addr.getPort());

by using this you get socket that is already connected to proxy.

来源:https://stackoverflow.com/questions/33829730/android-orbot-malformed-reply-from-socks-server

总结

以上是生活随笔为你收集整理的orbot android教程,Android Orbot malformed reply from SOCKS server的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得生活随笔网站内容还不错,欢迎将生活随笔推荐给好友。