{"id":25692379,"url":"https://github.com/ys928/stab","last_synced_at":"2025-04-24T05:14:53.193Z","repository":{"id":230634064,"uuid":"779864894","full_name":"ys928/stab","owner":"ys928","description":"一个简单、小巧、用户友好、高性能的TCP隧道工具，可轻松将本地端口暴露给远程服务器。A simple, compact, user-friendly, high-performance TCP tunneling tool that easily exposes local ports to remote servers 。","archived":false,"fork":false,"pushed_at":"2025-02-06T09:07:33.000Z","size":119,"stargazers_count":9,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-24T05:14:28.646Z","etag":null,"topics":["cli","localhost","network","proxy","rust","tcp","tunnel"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ys928.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-03-31T01:55:05.000Z","updated_at":"2025-02-22T10:10:06.000Z","dependencies_parsed_at":"2024-04-13T03:33:18.233Z","dependency_job_id":"1b51b9cc-951d-45cd-b0c9-70b3c340757a","html_url":"https://github.com/ys928/stab","commit_stats":null,"previous_names":["ys928/stab"],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ys928%2Fstab","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ys928%2Fstab/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ys928%2Fstab/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ys928%2Fstab/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ys928","download_url":"https://codeload.github.com/ys928/stab/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250566510,"owners_count":21451233,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cli","localhost","network","proxy","rust","tcp","tunnel"],"created_at":"2025-02-24T23:09:02.798Z","updated_at":"2025-04-24T05:14:53.166Z","avatar_url":"https://github.com/ys928.png","language":"Rust","readme":"\u003cp align=\"left\"\u003e\n    \u003cspan\u003e中文\u003c/span\u003e\n    \u003cspan\u003e • \u003c/span\u003e\n    \u003ca href=\"readme_en.md\"\u003eEnglish\u003c/a\u003e\n\u003c/p\u003e\n\n# stab\n\n这是一个现代、简单、小巧的高性能 TCP 隧道工具，可轻松将本地端口暴露给远程服务器。\n\n主要特点：\n\n- 人性化\n- 性能极高\n- 心跳检测\n- 流量统计\n- 允许手动断开链接\n- 允许暴露多个本地端口\n\n下图为stab与[bore](https://github.com/ekzhang/bore)之间的性能对比：\n\n![image](https://github.com/user-attachments/assets/47ada59e-1203-4dba-b309-7a034fc641d2)\n\n环境为wsl ubuntu 24.04，压测命令为：\n\n```bash\n ab -n 100000 -c 5000 http://127.0.0.1:2000/\n```\n\n### 1.安装\n\n如果你安装了 rust 开发环境，那么使用 cargo 命令是最简单的方式：\n\n```bash\ncargo install stab\n```\n\n如果没有 cargo，那么你可以直接去[release](https://github.com/ys928/stab/releases)下载已经编译好的程序使用。\n\n### 2.服务器\n\n你可以在你的服务器上运行下面这个命令：\n\n```bash\nstab server\n```\n\n这将启动 stab 的服务器模式，其默认的控制端口为 5746，但您可以修改：\n\n```bash\nstab server -c 7777\n```\n\n运行成功后，你将看到下面这样的输出：\n\n```bash\n15:52:21 [INFO] stab::server:62 =\u003e server listening 0.0.0.0:5656\n15:52:21 [INFO] stab::web:29 =\u003e web server:http://localhost:3400\n```\n\n其中`0.0.0.0:5656`代表控制端口，而`http://localhost:3400`则代表 web 服务，你可以打开该链接查看当前所有连接到本服务器的客户端信息，并可以主动手动断开该链接：\n\n![image](https://github.com/user-attachments/assets/24cc756a-6e59-424d-bf99-344ef4d4dc4c)\n\n\n### 3.本地\n\n然后你可以在本地运行下面这条命令：\n\n```bash\nstab local -l 8000=server.com\n```\n\n上面命令为简写形式，其完整的格式为：\n\n```bash\nstab local --link 127.0.0.1:8000=server.com:0\n```\n\n该命令会把你的本地`127.0.0.1:8000`端口与你的`server.com:0`进行链接，这是默认行为，此时端口将由服务器自动分配。\n\n当然你也可以指定服务器需要暴露端口：\n\n```bash\nstab local --link 127.0.0.1:8000=server.com:7878\n```\n\n如果你的服务器更改了默认的控制端口，那么这里也应该更改：\n\n```bash\nstab local -c 7777 --link 8000=server.com\n```\n\n### 4.示例\n\n假设你在`server.com`中启动了 stab 服务器模式：\n\n```bash\nstab server\n```\n\n并且你在本地端口 8000 启动了一个 web 服务器，之后你就可以通过`stab`连接到服务器来暴露本地的 web 服务：\n\n```bash\nstab local -l 8000=server.com\n```\n\n当你成功连接到服务器后，你将得到类似下面这样的日志输出：\n\n```bash\n15:54:59 [INFO] stab::client:101 =\u003e 127.0.0.1:8000 link to server.com:1024\n```\n\n此时，你就能通过 `server.com:1024` 访问到你的本地 web 服务。\n\n### 5.密钥\n\n为了防止被别人滥用，你可以添加一个密钥：\n\n```bash\nstab server -s test\n```\n\n此时客户端就必须填入密钥才能连接到服务器：\n\n```bash\nstab local -l 8000=your.server.com -s test\n```\n\n### 6.Toml 配置（推荐）\n\n除了使用命令行参数外，你可以通过 toml 配置文件的方式配置所有选项。\n\n服务器配置文件实例`server.toml`：\n\n```toml\nmode = \"Server\"        # 选择服务器模式\nport = 5959            # 设置控制端口\nsecret = \"test secret\" # 设置密钥\nlog = 5                # 设置日志等级：1-5，默认为5\nlog_path = \"logs\"      # 设置日志保存位置，默认为当前目录下的logs目录\n\n[server]\nweb_port = 80            # 设置web端口\nport_range = \"2000-3000\" # 设置允许使用的端口范围\npool_size = 8            # 设置连接池大小，默认8个\n```\n\n应用该配置文件：\n\n```bash\nstab -f server.toml\n```\n\n本地配置文件实例`local.toml`：\n\n```toml\nmode = \"Local\"         # 选择本地模式\nport = 5959            # 设置控制端口\nsecret = \"test secret\" # 设置密钥\nlog = 5                # 设置日志等级：1-5，默认为5\nlog_path = \"logs\"      # 设置日志保存位置，默认为当前目录下的logs目录\n\n[local]\nto = \"server.com\"       # 设置默认服务器\nlinks = [\n    \"127.0.0.1:8080=server.com:2000\",  # 完整写法\n    \"8080=server.com:1900\",            # 等价于：127.0.0.1:8080=server.com:1900\n    \"8081=server.com\",                 # 等价于：127.0.0.1:8081=server.com:0\n    \"8082=2001\",                       # 等价于：127.0.0.1:8082={to}:2001\n    \"8083\",                            # 等价于：127.0.0.1:8083={to}:0\n] # 设置将要与服务器建立的链接，支持同时建立多个链接\n```\n\n应用该配置文件：\n\n```bash\nstab -f local.toml\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fys928%2Fstab","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fys928%2Fstab","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fys928%2Fstab/lists"}