wsl2-auto-portproxy icon indicating copy to clipboard operation
wsl2-auto-portproxy copied to clipboard

A TCP workaround tool for proxy port from wsl2 linux to windows

wsl2-auto-portProxy

wsl2-auto-portProxy(wslpp) is a simple tool for proxying port of linux running in wsl2 (which now use a hyper-v nat network), it automatically scans the port in wls and setup a port proxy in windows host.

Note: only port listening at [::] or 0.0.0.0 works, and will only works to your default wsl distribution

Feature

  • [x] TCP port support
  • [x] custom port proxy config, support live edit
  • [ ] web interface
  • [ ] UDP port support

Requirement

your wsl linux must install the net-tools by

sudo apt-get install net-tools

Build and install

you can download the bin file(wslpp.exe) in release.

or build wslpp.exe from source

make build

the bin file will be store in dist/wslpp.exe

or install with go get

go get https://github.com/HobaiRiku/wsl2-auto-portproxy

and use wsl2-auto-portproxy.exe to start proxy

How it works

wslpp start an interval to get IP address of the nat interface and scan all ports listening at all network in the subsystem, then use golang's net to start proxy direct to ports.

Configuration

Support custom configuration by a json file, which must be placed in %HOMEPATH%/.wslpp/config.json, the .wslpp dir will be created automatically by wslpp when it runs, but the json file should be created by yourself.
Example:

{
  "onlyPredefined": true,
  "predefined": {
    "tcp": [
      "666:22"
    ]
  },
  "ignore": {
    "tcp": [
      445
    ]
  }
}
  • onlyPredefined: If true, will only start port defined in predefined field.
  • predefined: Define the custom port to proxy, "666:22" means windows(666)->linux(22), if undefined, port in windows will follow the same of linux. Must be a string array in the sub field name tcp.
  • ignore: If defined, will ignore the port in linux. Must be a number array in the sub field name tcp.

Note: If port is already use by another program in windows, the port will be omitted

License

MIT