我正在查看silvertunnel库,但努力建立成功的连接。我遇到的问题是连接需要 10 多分钟才能提供输出。我正在查看他们的一项测试,这是我的代码:
public boolean tryConnOLD() throws IOException {
try {
// define remote address
String remoteHostname = "http://test.silvertunnel.com";
int remotePort = 80;
TcpipNetAddress remoteAddress = new TcpipNetAddress(remoteHostname, remotePort);
// get TorNetLayer instance and wait until it is ready
NetLayer netLayer = NetFactory.getInstance().getNetLayerById(NetLayerIDs.TOR);
netLayer.waitUntilReady();
// open connection to remote address - this connection is tunneled through the TOR anonymity network
netSocket = netLayer.createNetSocket(null, null, remoteAddress);
InputStream is = netSocket.getInputStream();
String content = CharStreams.toString(new InputStreamReader(is, Charsets.UTF_8));
Closeables.closeQuietly(is);
is.close();
System.out.println(is.read());
java.util.Scanner s = new java.util.Scanner(is).useDelimiter("\\A");
if(s.hasNext()) {
System.out.println(s.next());
System.out.println();
}
return true;
} catch (IOException ex) {
} finally {
netSocket.close();
}
return false;
}