Socksifying a Java ServerSocket - how to approach

I would like to have a Java program running on network A have a ServerSocket living on another network B through a proxy. I have played with a SOCKS5 proxy (which works) but it appears that all the proxy facilities in Java only work with client connections, not with ServerSockets (no constructor taking a Proxy argument). Asking Google gives much hay and few needles.

What is the approach I should take to get this running?

If a specific client is better than a generic SOCKS or web proxy then fine, but it needs to be Java (that leaves sshd out).

Target JVM is preferrably Java 5, and then Java 6.

Upvotes: 3

Views: 721

Answers (2)

Adamski
Adamski

Reputation: 54695

Why not just set up an stunnel to deal with forwarding the traffic from one network to the other? As ZZ Coder mentions this isn't a server issue and so the solution should live outside your Java application codebase IMHO.

Upvotes: 1

ZZ Coder
ZZ Coder

Reputation: 75456

Proxying is a client issue and server shouldn't care. For example, the server on network B is no different from any other servers. The client and proxy are responsible to make connection to it from other networks.

On server side, the only thing you might care is to find out the original IP address of the client. To server, the connection is from proxy.

Upvotes: 0

Related Questions