gpt4 book ai didi

java - 连接到 TOR Java

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:53:40 24 4
gpt4 key购买 nike

我正在查看 silvertunnel图书馆,但努力建立成功的联系。我遇到的问题是连接需要超过 10 分钟才能提供输出。我正在浏览他们的一个 tests ,这是我的代码:

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;
}

最佳答案

问题很简单,当您使用 silvertunnel API 时,您不需要在 url 中指定协议(protocol),因此只需删除 http:// 即可修复您的错误。

尝试以下操作

                        //remove http://   
String remoteHostname = "test.silvertunnel.com";

关于java - 连接到 TOR Java,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14814749/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com