erebe / wstunnel

Tunnel all your traffic over Websocket or HTTP2 - Bypass firewalls/DPI - Static binary available
BSD 3-Clause "New" or "Revised" License
4.36k stars 372 forks source link

Add hard fileno #366

Closed Ongy closed 2 weeks ago

Ongy commented 1 month ago

This allows wstunnel to use fds>1024. Otherwise heavy use can easily run out of file descriptors on connection attempts. While there will still be a limit, it is significantly higher (~500 times on my system) which provides enough headroom for connections to be torn down and fds to be closed.

erebe commented 1 month ago

Hello,

Thank you for the PR, it is appreciated. But ultimately, I would prefer to let this setting outside of wstunnel. For me it is up to the system to configure the file descriptor limit. Either with systemd, ulimit, netconfig,...

In addition, this crate only works on linux/macos, so it should be gated by a conditonnal compilation cfg.

Or maybe make it the default without any flag for those os.

Ongy commented 1 month ago

Hi, sorry for the late reply

While I fully agree that the hard limit should be set by the environment, the soft limit is mostly a historical issue with the 1024 FDs support by select(2). IMO it makes sense to up it in process when the application acknowledges that it can handle it. Might even make sense without the flag :thinking:

Yea, gating to the OS makes sense. I'll have to figure out the syntax if that's the only issue.

erebe commented 1 month ago

I think we can make it the default without any flags and merge the PR. I checked the crate, and it does already nothing if it is a platform it does not support.

So calling everytime fdlimit::raise_fd_limit() is fine for me as long as we dont exit if the call fails, and just log a warning.

Ongy commented 2 weeks ago

Done.

Do you have a preference about squashing?

erebe commented 2 weeks ago

That's perfect, thank you. I am going to squash into 1 commit