首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >连接到TOR Java

连接到TOR Java
EN

Stack Overflow用户
提问于 2013-02-11 23:02:38
回答 1查看 8.5K关注 0票数 3

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

代码语言:javascript
复制
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;
}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-02-12 21:15:28

问题很简单,当你使用silvertunnel API时,你不需要在url中指定协议,所以只需删除http://就可以修复你的错误。

请尝试以下操作

代码语言:javascript
复制
                        //remove http://   
String remoteHostname = "test.silvertunnel.com";
票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/14814749

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档