{"id":13826108,"url":"https://github.com/bubuflystudio/bbtunnel","last_synced_at":"2025-07-08T23:31:05.672Z","repository":{"id":143852894,"uuid":"114059902","full_name":"BubuflyStudio/bbtunnel","owner":"BubuflyStudio","description":"基于 socksv5 的内网穿透工具","archived":false,"fork":false,"pushed_at":"2017-12-15T08:57:37.000Z","size":31,"stargazers_count":4,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-12T15:51:29.695Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/BubuflyStudio.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}},"created_at":"2017-12-13T01:49:33.000Z","updated_at":"2019-11-12T17:16:19.000Z","dependencies_parsed_at":null,"dependency_job_id":"fbd4115a-cdd8-4847-aa61-21c1a26cc25f","html_url":"https://github.com/BubuflyStudio/bbtunnel","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/BubuflyStudio/bbtunnel","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BubuflyStudio%2Fbbtunnel","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BubuflyStudio%2Fbbtunnel/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BubuflyStudio%2Fbbtunnel/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BubuflyStudio%2Fbbtunnel/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BubuflyStudio","download_url":"https://codeload.github.com/BubuflyStudio/bbtunnel/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BubuflyStudio%2Fbbtunnel/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264365446,"owners_count":23596834,"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":[],"created_at":"2024-08-04T09:01:32.212Z","updated_at":"2025-07-08T23:31:05.397Z","avatar_url":"https://github.com/BubuflyStudio.png","language":"JavaScript","funding_links":[],"categories":["\u003ca id=\"01e6651181d405ecdcd92a452989e7e0\"\u003e\u003c/a\u003e工具"],"sub_categories":["\u003ca id=\"9d6789f22a280f5bb6491d1353b02384\"\u003e\u003c/a\u003e隧道\u0026\u0026穿透"],"readme":"# bbtunnel 内网穿透\n\n## 使用\n执行 `npm install -g bbtunnel` 安装 `bbtunnel` 内网穿透工具。\n\n### 服务端\n服务端需要在公网的服务器上安装（服务端执行 `npm install -g bbtunnel` 安装 `bbtunnel`）\n\n安装完成后，执行 `bbt-server -f \u003c服务端配置文件路径\u003e` 即可启动服务端，其中配置文件\n路径默认为执行该命令时所在目录下的 `bbt_config.js` 文件，使用 `-f` 参数可以指定自定\n义的文件路径。\n\n需要注意的是配置文件为 `.js` 文件，格式如下：\n```js\nmodule.exports = {\n    // 客户端连接配置，格式为 \u003chost\u003e: \u003cpassword\u003e（客户端连接时需要指定监听的域与对应的密码）\n    connMap: {\n        'aaa.test.com': '123456',\n        'bbb.test.com': '123456'\n    },\n    httpPort: 80,       // 监听来自外网的 http 服务，默认80端口\n    socksPort: 8000     // 监听来自内网的 socksv5 连接服务，默认8000端口\n};\n```\n\n启动后即会启动监听 `80` 端口的 `http` 服务，与监听 `8000` 端口的 `socksv5` 连接。\n\n### 客户端\n客户端在为本地安装（本地执行 `npm install -g bbtunnel` 安装 `bbtunnel`）\n\n安装完成后，执行 `bbt-client -f \u003c客户端配置文件路径\u003e` 即可启动客户端。需要注意的是在\n启动 `bbt-client` 之前，需要先启动本地计划暴露到公网的 `http` 服务，否则客户端会启动\n失败（会有相应提示）。\n\n客户端默认的配置文件路径为执行该命令时所在目录下的 `bbt_config.js` 文件，使用 `-f` 参\n数可以指定自定义的文件路径。\n\n需要注意的是配置文件为 `.js` 文件，格式如下：\n```js\nmodule.exports = {\n    // 连接配置，可以同时连接多个域（服务端的 connMap 需要包含这些域）\n    connMap: {\n        'aaa.test.com': '123456'\n    },\n    socksHost: 'aaa.test.com',  // bbt-server 所在的地址\n    socksPort: 8000,            // bbt-server 监听的 socksv5 服务端口，默认为 8000\n    localHttpPort: 3000,        // 本地 http 服务所监听的端口，默认为 3000\n    connLimit: 20               // 最大并发连接数，默认为 20\n};\n```\n\n位于公网的服务端与位于内网的本地 http 服务、客户端启动后，内网的 http 服务即暴露到了公\n网，可以直接从公网访问内网的 http 服务。\n\n## 原理说明\n如图：\n![desc.png](https://raw.githubusercontent.com/BubuflyStudio/bbtunnel/master/desc.png)\n\n1. `bbt-client` 会主动通过 `socksv5` 的方式与公网的 `bbt-server` 建立连接通道  \n2. 当 `bbt-server` 收到相应的 `http` 请求时，它会将该 `http` 请求通过建立的 `socksv5` 通\n道发给 `bbt-client`  \n3. `bbt-client` 会将该请求进一步转发给本地的 `http` 服务，得到请求结果后将结果通过 `socksv5`\n通道返回给 `bbt-server`  \n4. `bbt-server` 将请求结果返回给访问的浏览器\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbubuflystudio%2Fbbtunnel","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbubuflystudio%2Fbbtunnel","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbubuflystudio%2Fbbtunnel/lists"}