rathole icon indicating copy to clipboard operation
rathole copied to clipboard

Bind on multiple addresses.

Open fernvenue opened this issue 2 years ago • 4 comments

Feature Proposed As mentioned above, does rathole allow binding on multiple addresses? If so, could anyone please let me know how to utilize this feature? Thanks!

Use Case When we wanna bind on both IPv4 and IPv6, or when we have multiple adapters, this feature will be very useful.

fernvenue avatar Jul 02 '23 19:07 fernvenue

I assume you want to listen to v4 and v6 0.0.0.0 at the same time, not with different IP addresses. Actually, I'm not sure what's the code change needed to achieve this. On some platforms(IIRC, linux), binding a listen socket at 0.0.0.0 automatically listens to both v4 and v6. It's called dualstack or something.

yujqiao avatar Oct 01 '23 10:10 yujqiao

Hi @rapiz1, I have reviewed the code and attempted to assess the implementation difficulty of this feature. The conclusion is that it may require significant modifications and will be somewhat challenging. However, fortunately, we can achieve listening to both IPv4 and IPv6 addresses simultaneously by listening to ::. I have successfully tested this on Debian. However, if we wanna specify addresses, currently it still requires manually writing separate services for each address.

fernvenue avatar Oct 01 '23 10:10 fernvenue

The conclusion is that it may require significant modifications and will be somewhat challenging.

Yeah, it's not trivial.

However, if we wanna specify addresses, currently it still requires manually writing separate services for each address.

That's true but I'm not sure if ppl really need it. :: should satisfy most users

yujqiao avatar Oct 01 '23 10:10 yujqiao

I wanted to bind both IPv4 and IPv6 in Ubuntu and came across this issue and it works for me.

Example config on the server:

[server]
bind_addr = "[::]:2333"

# Then services...

soundslocke avatar Jan 11 '24 00:01 soundslocke