1

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;
nyi
  • 3,123
  • 4
  • 22
  • 45
user1158745
  • 2,402
  • 9
  • 41
  • 60

1 Answers1

0

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

Duston
  • 1,601
  • 5
  • 13
  • 24
  • Can this be done without SSH? Do you have a simple sample you could provide? – user1158745 May 24 '18 at 15:19
  • I don't know, I haven't tried. My larger point was that what you're doing is tunneling and what you were trying was a proxy which are different things. If it's a tunnel, then your application is blissfully unaware of how the data gets from one machine to the other, it just needs to be told where to connect. – Duston May 24 '18 at 16:35
  • Perhaps my word of tunneling was misused. Why doesn't java support tcp proxys, why only socks and http? I need to connect to a tcp proxy server. I guess that's my issue, but java doesn't allow that method. Any ideas? – user1158745 Jun 20 '18 at 15:13