问题描述
我试图启用在Android中我自己的XMPP应用TOR的支持。我使用orbot作为TOR代理,我有以下的code连接的应用程序接口:
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);
但我正在逐渐从SOCKS服务器畸形回复
连我Orbot是启动和运行。我相信,当应用程序访问斜面代理服务器或提及服务器不是SOCKS代理引发此错误。
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.
我也试过用jsocks:
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");
其中host是jabbim.com
但我从来没有得到我们在这里调用println所以它看起来像我的应用程序的某个地方挂在创建SocksSocket但我没有得到任何错误,无论是。当我调试它它jsocks某处挂在impl.getInputStream(PlainSocketImpl我相信)
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?
由于在前进
推荐答案
我解决了这个用
compile "org.igniterealtime.smack:smack-android-extensions:4.1.4"
compile "org.igniterealtime.smack:smack-tcp:4.1.4"
,然后使用这个code连接:
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.
这篇关于从SOCKS服务器的Android Orbot畸形回复的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!