I wrote the beginnings of a SocketImplFactory that would allow transparent
access from inside Sun's firewall to machines both inside
and outside that firewall. By installing a SocketImplFactory that intercepts
the hostnames, checks to see if they are local (within the Sun firewall) or
remote, I can either make a socket to the local machine or connect to the
firewall and perform some handshaking with
it to get it to give me a socket to a remote machine.
Unfortunately, there is a "bug" in Socket(String hostname, int port) that
will prevent this from working. The first thing that Socket(String, int)
does with the hostname is convert it into an InetAddress and then tell the
SocketImpl to connect to the given InetAddress. So my SocketImpl will
never get the remote hostname and a chance to parse it and redirect the
connect outside the firewall; the constructor for Socket will have already
failed with an UnknownHostException because hostnames outside of the
firewall cannot be mapped to InetAddresses.
Instead: Socket(String, int) should call SocketImpl.connect(String, int)
otherwise, this renders SocketImplFactories useless for going through firewalls to machines whose IP address is not known within the firewall. It is ironic, since the comments in SocketImpl.java state that the "impl" way of doing things was done to make it possible to do things like tunnel through firewalls.
access from inside Sun's firewall to machines both inside
and outside that firewall. By installing a SocketImplFactory that intercepts
the hostnames, checks to see if they are local (within the Sun firewall) or
remote, I can either make a socket to the local machine or connect to the
firewall and perform some handshaking with
it to get it to give me a socket to a remote machine.
Unfortunately, there is a "bug" in Socket(String hostname, int port) that
will prevent this from working. The first thing that Socket(String, int)
does with the hostname is convert it into an InetAddress and then tell the
SocketImpl to connect to the given InetAddress. So my SocketImpl will
never get the remote hostname and a chance to parse it and redirect the
connect outside the firewall; the constructor for Socket will have already
failed with an UnknownHostException because hostnames outside of the
firewall cannot be mapped to InetAddresses.
Instead: Socket(String, int) should call SocketImpl.connect(String, int)
otherwise, this renders SocketImplFactories useless for going through firewalls to machines whose IP address is not known within the firewall. It is ironic, since the comments in SocketImpl.java state that the "impl" way of doing things was done to make it possible to do things like tunnel through firewalls.
- relates to
-
JDK-4145724 protected classes and extending the Java Class Library
-
- Closed
-