kongjianweili / connectbot

Automatically exported from code.google.com/p/connectbot
Apache License 2.0
0 stars 0 forks source link

can't bind forwarded ports to INADDR_ANY (with patch) #609

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Set up a local port forward such as 9000 -> remotehost:9000.
2. From another nearby machine, try to connect to port 9000 on the tunneling 
device.
3. Have a sad.

What is the expected output? What do you see instead?

Would be nice to be able to bind forwarded ports to INADDR_ANY so that other 
machines on the local network can connect via the tunnel.  I realize why it's 
not the default behavior, but it is useful sometimes.  (in this case, for 
making a remote squeezebox server available.)

Attached patch works well enough for me, but, several things to beware of:

+ whitespace is probably screwed up by my emacs
+ the "bind remote listen socket to INADDR_ANY" function is untested
+ the horrible implementation of "bind local listen socket to INADDR_ANY" 
doesn't really do that, because the stupid JVM behavior of INADDR_ANY is "only 
bind to IPv6 no matter what you say."   Instead it searches through the local 
interfaces until it finds an IPv4 address that isn't localhost, and binds to 
that by name.  Nothing else worked.
+ when you check "bind to INADDR_ANY" the resulting socket will *not* be 
available on 127.0.0.1 or ::, which will be surprising to some

So, best to think of it as "proof of concept," but it compiles and works for me.

Original issue reported on code.google.com by pomonami...@gmail.com on 23 Sep 2012 at 6:23

Attachments: