简体   繁体   English

Java隧道和TCP代理

[英]Java tunnel and tcp proxy

I need to tunnel through a tcp proxy. 我需要通过TCP代理隧道。 Within Java, the proxy types are only socks, direct or HTTP. 在Java中,代理类型只有袜子,直接或HTTP。 So in the example below a socket is being created then the proxy object is being created from the socketAddress and the type is socks. 因此,在下面的示例中,创建了一个套接字,然后从socketAddress创建了代理对象,类型是袜子。
How can I specify the proxy is TCP? 如何指定代理为TCP?

    SocketAddress addr = new InetSocketAddress("socks.example.com", 1080);
    Proxy proxy = new Proxy(Proxy.Type.SOCKS, addr);
    Socket socket = new Socket(proxy);
    InetSocketAddress dest = new InetSocketAddress("server.example.org", 1234);
    try {
        socket.connect(dest);
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    return isValidated;

You want a DIRECT proxy to Localhost on the port you set up to tunnel to the destination. 您希望在设置为隧道连接到目标的端口上有一个到Localhost的DIRECT代理。 For example if your tunnel is set up to go from 4000 (Local) to 3389 (on the host you really want to connect to) the destination is Localhost, 1000, proxy type Direct. 例如,如果您的隧道设置为从4000(本地)到3389(在您真正要连接的主机上),则目的地是Localhost,1000,代理类型为Direct。 See SSH tunneling via JSch 请参阅通过JSch进行SSH隧道

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM