3 unstable releases
0.2.1 | Apr 5, 2024 |
---|---|
0.2.0 | Apr 5, 2024 |
0.1.0 | Mar 31, 2024 |
#1462 in Network programming
417 downloads per month
29KB
578 lines
English • 中文
stab
This is a modern, simple, high-performance TCP tunneling tool implemented by rust to easily expose local ports to remote servers.
1.Installation
cargo install stab
2.Server
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 0.0.0.0:5746
09:39:49 [INFO] src\web\mod.rs:31 => web server:http://localhost:3000
Where 0.0.0.0:5746
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:
3.Local
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 127.0.0.1:8000=server.com:0
This command will link your local 127.0.0.1:8000
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 127.0.0.1:8000=server.com:7878
If your server changed the default control port, it should be changed here as well:
stab local -c 7777 --link 8000=server.com
4.Example
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
.
5.Secret
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
6.Option
The complete optional parameters are listed below:
a simple CLI tool for making tunnels to localhost
Usage: stab.exe [OPTIONS] <MODE>
Arguments:
<MODE> run mode [possible values: local, server]
Options:
-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: 127.0.0.1:8080=127.0.0.1:0]
-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.
Dependencies
~8–17MB
~189K SLoC