erebe / wstunnel

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

Allow specifying tunnels with a config file #350

Closed jsonmona closed 2 months ago

jsonmona commented 2 months ago

Describe the feature

From client side, all tunnels must be specified on command line. This feature request is to enable users to specify tunnels in a separate config file.

As far as I can tell, from server side, restrictions already can be specified on separate file, so this is not an issue.

Describe the reason for such feature

  1. Ease of maintenance
  2. Apparantly the PC I'm using blocks batch files or cmd or PowerShell. Therefore, the only way to specify command line is to use a shortcut file, which has length limit of whopping 260. I can barely specify one tunnel alongside full path to the executable and other flags.

Describe alternatives you've considered

I don't see any existing options would enable this. All I need is to shorten the command line, so using a separate config file for all settings could be a solution. But I think that would be significantly harder to implement.

Also, I'm willing to write a PR for this issue. I'm considering file format of:

# Lines starting with # is comment
# Each tunnel goes to one line
-L tcp://8080:127.0.0.1:8080
-R tcp://1212:google.com:443

I'll start implementing if you're ok with this format. Please let me know your thoughts.

erebe commented 2 months ago

Hello, Feel free to fork and modify it for your needs, but for accepting a PR regarding adding a config file. It would need to:

jsonmona commented 2 months ago

I think it is better to have tunnel definitions to be separated from other config file because that would allow reloading the file. This way, tunnels can be added or removed without interrupting already connected ones.

But on the second thought, since current code simply spawns tasks, making tunnels dynamically adjustable seems quite infeasible.