rapiz1 / rathole

A lightweight and high-performance reverse proxy for NAT traversal, written in Rust. An alternative to frp and ngrok.
Apache License 2.0
9.44k stars 475 forks source link

Bind on multiple addresses. #267

Open fernvenue opened 1 year ago

fernvenue commented 1 year ago

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.

rapiz1 commented 1 year ago

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.

fernvenue commented 1 year ago

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.

rapiz1 commented 1 year ago

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

soundslocke commented 8 months ago

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...