rofl0r / microsocks

tiny, portable SOCKS5 server with very moderate resource usage
Other
1.59k stars 277 forks source link

Allow binding to another (non-default) interface #29

Open tahajahangir opened 4 years ago

rofl0r commented 4 years ago

SO_BINDTODEVICE seems to be a linux-specific API. what prevents you from using the ip address of the specified interface with the existing -b option?

tahajahangir commented 4 years ago

The existing -b option only works when the specified IP is on the same interface as the default route interface. When machine have multiple interfaces and the bind-ip is not on the default interface, this options solves the problem.

soffchen commented 3 years ago

Nice feature, but works only under linux.

mimi89999 commented 3 years ago

what prevents you from using the ip address of the specified interface with the existing -b option?

It would be nice to listen on a different interface that the outgoing connections.

mimi89999 commented 3 years ago

The problem is that if the IP address set by the -b option is on the default route, the default route will be used and not the specified interface.

zopieux commented 2 years ago

I've patched this PR against master and it works and does exactly what I needed. Would you consider accepting it, please?

rofl0r commented 2 years ago

i can't merge this PR as-is, because it would break build on solaris, *BSD, and OSX

zopieux commented 2 years ago

It is a matter of surrounding the Linux-specific code with #if[def] fences?

rofl0r commented 2 years ago

i dont want to litter the code with ugly ifdefs, they need to be in a single spot, if at all

alexandervlpl commented 7 months ago

For anyone else looking for this functionality. Dante doesn't have it either, their external option lets you "bind" to an interface by name but in practice works the same way using the default route. :cry: But this PR works perfectly, thanks @tahajahangir !

I do appreciate that @rofl0r doesn't want to clutter such a clean minimalist project.