#tunnel #tcp #local-server #cli #networking #cli-tool

app stab

a simple CLI tool for making tunnels to localhost

3 unstable releases

0.2.1 Apr 5, 2024
0.2.0 Apr 5, 2024
0.1.0 Mar 31, 2024

#231 in Network programming

Download history 196/week @ 2024-03-29 216/week @ 2024-04-05 5/week @ 2024-04-12

224 downloads per month

MIT license

578 lines

English 中文


This is a modern, simple, high-performance TCP tunneling tool implemented by rust to easily expose local ports to remote servers.


cargo install stab


You can run this command below on your server:

stab server

This will start stab in server mode with a default control port of 5746, but you can change this:

stab server -c 7777

After a successful run, you will see output like the following:

09:39:49 [INFO] src\server.rs:39 => server listening
09:39:49 [INFO] src\web\mod.rs:31 => web server:http://localhost:3000

Where stands for the control port and http://localhost:3000 stands for the web service, you can view information about all clients connected to this server through this link, and you can proactively disconnect the link manually:



You can then run the following command locally:

stab local -l 8000=server.com

The above command is in short form and its full format is:

stab local --link

This command will link your local port with your server.com:0, which is the default behaviour, at which point the port will be automatically assigned by the server.

Of course you can also specify the server to expose the port:

stab local --link

If your server changed the default control port, it should be changed here as well:

stab local -c 7777 --link 8000=server.com


Let's say you start stab server mode in server.com:

stab server

And you start a web server on local port 8000, after which you can connect to the server via stab to expose the local web service:

stab local -l 8000=server.com

When you successfully connect to the server, you will get log output similar to the following:

09:46:42 [INFO] src\client.rs:72 => listening at server.com:1024

At this point, you will be able to access your local web service via server.com:1024.


To prevent abuse by others, you can add a key:

stab server -s test

At this point the client will have to fill in the key to connect to the server:

stab local -l 8000=your.server.com -s test


The complete optional parameters are listed below:

a simple CLI tool for making tunnels to localhost

Usage: stab.exe [OPTIONS] <MODE>

  <MODE>  run mode [possible values: local, server]

  -c, --contrl-port <control port>  the control port [default: 5746]
  -s, --secret <secret>             an optional secret for authentication
  -l, --link <local mode>           create a link from the local to the server [default:]
  -p, --port-range <server mode>    accepted TCP port number range [default: 1024-65535]
  -w, --web-port <server mode>      web manage server port [default: 3000]
  -h, --help                        Print help (see more with '--help')
  -V, --version                     Print version

Note that -p is used to specify a range of ports available to the server, which is ignored by the client.


~190K SLoC