问题
I need to tunnel through a tcp proxy. Within Java, the proxy types are only socks, direct or 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.
How can I specify the proxy is 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;
回答1:
You want a DIRECT proxy to Localhost on the port you set up to tunnel to the destination. 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. See SSH tunneling via JSch
来源:https://stackoverflow.com/questions/50473633/java-tunnel-and-tcp-proxy