├── .github └── workflows │ └── ci.yml ├── .gitignore ├── LICENSE ├── README.md ├── README_CN.md ├── build.sh ├── node ├── index.js └── package.json ├── output_temp └── .build_date.txt ├── start.sh └── variables.yml /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | # This is a basic workflow to help you get started with Actions 2 | 3 | name: CI 4 | 5 | on: 6 | push: 7 | branches: [ main ] 8 | pull_request: 9 | branches: [ main ] 10 | 11 | jobs: 12 | build: 13 | runs-on: ubuntu-latest 14 | container: pandoc/latex 15 | steps: 16 | - uses: actions/checkout@v2 17 | - name: Install mustache (to update the date) 18 | run: apk add ruby && gem install mustache 19 | - name: creates output 20 | run: sh ./build.sh 21 | - name: Pushes to another repository 22 | id: push_directory 23 | uses: cpina/github-action-push-to-another-repository@target-branch 24 | env: 25 | SSH_DEPLOY_KEY: ${{ secrets.SSH_DEPLOY_KEY }} 26 | with: 27 | source-directory: . 28 | destination-github-username: 'amclubs' 29 | destination-repository-name: 'am-nodejs-proxy' 30 | user-email: action@ci.github 31 | commit-message: See ORIGIN_COMMIT from $GITHUB_REF 32 | target-branch: main 33 | - name: Test get variable exported by push-to-another-repository 34 | run: echo $DESTINATION_CLONED_DIRECTORY 35 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules 3 | /dist 4 | 5 | 6 | # local env files 7 | .env.local 8 | .env.*.local 9 | 10 | # Log files 11 | npm-debug.log* 12 | yarn-debug.log* 13 | yarn-error.log* 14 | pnpm-debug.log* 15 | 16 | # Editor directories and files 17 | .idea 18 | .vscode 19 | *.suo 20 | *.ntvs* 21 | *.njsproj 22 | *.sln 23 | *.sw? 24 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # [am-nodejs-proxy](https://github.com/amclubs/am-nodejs-proxy) 2 | 基于 Node.js 的 vless 实现包。它在各种 Node.js 环境中都能运行,包括但不限于:Windows、Linux、MacOS、Android、iOS、树莓派等。同时,它也适用于各种 PaaS 平台,如:replit、heroku 等。 3 | 4 | # 5 | ▶️ **新人[YouTube](https://youtube.com/@am_clubs?sub_confirmation=1)** 需要您的支持,请务必帮我**点赞**、**关注**、**打开小铃铛**,***十分感谢!!!*** ✅ 6 |
🎁请 **follow** 我的[GitHub](https://github.com/amclubs)、给我所有项目一个 **Star** 星星(拜托了)!你的支持是我不断前进的动力! 💖 7 |
✅**解锁更多技能** [加入TG群【am_clubs】](https://t.me/am_clubs)、[YouTube频道【@am_clubs】](https://youtube.com/@am_clubs?sub_confirmation=1)、[【博客(国内)】](https://amclubss.com)、[【博客(国际)】](https://amclubs.blogspot.com) 8 |
✅点击观看教程[CLoudflare免费节点](https://www.youtube.com/playlist?list=PLGVQi7TjHKXbrY0Pk8gm3T7m8MZ-InquF) | [VPS搭建节点](https://www.youtube.com/playlist?list=PLGVQi7TjHKXaVlrHP9Du61CaEThYCQaiY) | [获取免费域名](https://www.youtube.com/playlist?list=PLGVQi7TjHKXZGODTvB8DEervrmHANQ1AR) | [免费VPN](https://www.youtube.com/playlist?list=PLGVQi7TjHKXY7V2JF-ShRSVwGANlZULdk) | [IPTV源](https://www.youtube.com/playlist?list=PLGVQi7TjHKXbkozDYVsDRJhbnNaEOC76w) | [Mac和Win工具](https://www.youtube.com/playlist?list=PLGVQi7TjHKXYBWu65yP8E08HxAu9LbCWm) | [AI分享](https://www.youtube.com/playlist?list=PLGVQi7TjHKXaodkM-mS-2Nwggwc5wRjqY) 9 | 10 | - [中文文档](./README_CN.md) 11 | - [视频教程](https://youtu.be/tj9uD575R80) 12 | 13 | This README explains how to set up and use the `start.sh` script to manage the project components. 14 | 15 | ## Initial Setup 16 | 17 | 1. Connect to your host using SSH: 18 | 19 | ``` 20 | ssh @.serv00.com 21 | ``` 22 | 23 | Use the information emailed to you by serv00. 24 | 25 | 2. Enable management permissions: 26 | 27 | ``` 28 | devil binexec on 29 | ``` 30 | 31 | ***AFTER THIS STEP, EXIT FROM SSH AND LOG IN AGAIN.*** 32 | 33 | 3. Clone the repository: 34 | 35 | ``` 36 | cd domains/${USER}.serv00.net 37 | ``` 38 | ``` 39 | git clone https://github.com/amclubs/am-nodejs-proxy.git 40 | ``` 41 | ``` 42 | cd am-nodejs-proxy 43 | ``` 44 | 45 | ## Usage 46 | 47 | To use the script, run: 48 | 49 | ``` 50 | ./start.sh 51 | ``` 52 | 53 | | Action | Sub-Action | Command | Description | 54 | | :----: | :-----------: | :---------------------: | :--------------------------------------------: | 55 | | setup | node/xray/cf | `./start.sh setup node` | Setup services in a single command | 56 | | check | node/xray/cf | `./start.sh check node` | Checks Cloudflared and other services | 57 | | show | node/xray/all | `./start.sh show node` | Displays VLESS connection links from node/.env | 58 | 59 | View all node information 60 | ``` 61 | cat domains/${USER}.serv00.net/am-nodejs-proxy/node/.env 62 | ``` 63 | 64 | ***NODE.JS AND XRAY CANNOT BE ACTIVE SIMULTANEOUSLY. ONLY ONE OF THEM SHOULD BE RUNNING AT A TIME.*** 65 | 66 | ## Checking Sessions 67 | 68 | To check the status of a specific component, you can attach to its tmux session: 69 | 70 | ``` 71 | tmux attach -t 72 | ``` 73 | 74 | Replace `` with: 75 | 76 | - `cf` for Cloudflared 77 | - `node` for Node.js 78 | - `xray` for Xray 79 | 80 | For example, to check the Cloudflared session: 81 | 82 | ``` 83 | tmux attach -t cf 84 | ``` 85 | 86 | To detach from a tmux session without closing it, press: 87 | 88 | ``` 89 | Ctrl + b, then d 90 | ``` 91 | 92 | This key combination allows you to exit the session while leaving it running in the background. 93 | 94 | ## Notes 95 | 96 | - The script uses tmux to manage sessions for each component. 97 | - Cron jobs are set up for periodic maintenance of Node.js and Xray. 98 | - Cloudflared, Node.js, and Xray configurations are generated automatically. 99 | - The script includes functions for port management and cleanup. 100 | 101 | # 102 |
103 |
[点击展开] 赞赏支持 ~🧧 104 | *我非常感谢您的赞赏和支持,它们将极大地激励我继续创新,持续产生有价值的工作。* 105 | 106 | - **USDT-TRC20:** `TWTxUyay6QJN3K4fs4kvJTT8Zfa2mWTwDD` 107 | - **TRX-TRC20:** `TWTxUyay6QJN3K4fs4kvJTT8Zfa2mWTwDD` 108 | 109 |
110 |
111 | TRC10/TRC20扫码支付 112 |
113 |
114 |
115 | 116 | # 117 | 免责声明: 118 | - 1、该项目设计和开发仅供学习、研究和安全测试目的。请于下载后 24 小时内删除, 不得用作任何商业用途, 文字、数据及图片均有所属版权, 如转载须注明来源。 119 | - 2、使用本程序必循遵守部署服务器所在地区的法律、所在国家和用户所在国家的法律法规。对任何人或团体使用该项目时产生的任何后果由使用者承担。 120 | - 3、作者不对使用该项目可能引起的任何直接或间接损害负责。作者保留随时更新免责声明的权利,且不另行通知。 121 | 122 | -------------------------------------------------------------------------------- /README_CN.md: -------------------------------------------------------------------------------- 1 | # [am-nodejs-proxy](https://github.com/amclubs/am-nodejs-proxy) 2 | 基于 Node.js 的 vless 实现包。它在各种 Node.js 环境中都能运行,包括但不限于:Windows、Linux、MacOS、Android、iOS、树莓派等。同时,它也适用于各种 PaaS 平台,如:replit、heroku 等。 3 | 4 | # 5 | ▶️ **新人[YouTube](https://youtube.com/@am_clubs?sub_confirmation=1)** 需要您的支持,请务必帮我**点赞**、**关注**、**打开小铃铛**,***十分感谢!!!*** ✅ 6 |
🎁请 **follow** 我的[GitHub](https://github.com/amclubs)、给我所有项目一个 **Star** 星星(拜托了)!你的支持是我不断前进的动力! 💖 7 |
✅**解锁更多技能** [加入TG群【am_clubs】](https://t.me/am_clubs)、[YouTube频道【@am_clubs】](https://youtube.com/@am_clubs?sub_confirmation=1)、[【博客(国内)】](https://amclubss.com)、[【博客(国际)】](https://amclubs.blogspot.com) 8 |
✅点击观看教程[CLoudflare免费节点](https://www.youtube.com/playlist?list=PLGVQi7TjHKXbrY0Pk8gm3T7m8MZ-InquF) | [VPS搭建节点](https://www.youtube.com/playlist?list=PLGVQi7TjHKXaVlrHP9Du61CaEThYCQaiY) | [获取免费域名](https://www.youtube.com/playlist?list=PLGVQi7TjHKXZGODTvB8DEervrmHANQ1AR) | [免费VPN](https://www.youtube.com/playlist?list=PLGVQi7TjHKXY7V2JF-ShRSVwGANlZULdk) | [IPTV源](https://www.youtube.com/playlist?list=PLGVQi7TjHKXbkozDYVsDRJhbnNaEOC76w) | [Mac和Win工具](https://www.youtube.com/playlist?list=PLGVQi7TjHKXYBWu65yP8E08HxAu9LbCWm) | [AI分享](https://www.youtube.com/playlist?list=PLGVQi7TjHKXaodkM-mS-2Nwggwc5wRjqY) 9 | 10 | - [中文文档](./README_CN.md) 11 | - [视频教程](https://youtu.be/tj9uD575R80) 12 | 13 | 本自述文件解释了如何设置和使用“start.sh”脚本来管理项目组件。 14 | 15 | ## 初始设置 16 | 17 | 1. 使用 SSH 连接到您的主机: 18 | 19 | ``` 20 | ssh @.serv00.com 21 | ``` 22 | 23 | 使用 serv00 通过电子邮件发送给您的信息,上面的username、panel换成你接收的信息。 24 | 25 | 2. 启用管理权限: 26 | 27 | ``` 28 | devil binexec on 29 | ``` 30 | 31 | ***完成此步骤后,退出 SSH 并再次登录。*** 32 | 33 | 3. 克隆仓库代码: 34 | 35 | ``` 36 | cd domains/${USER}.serv00.net 37 | ``` 38 | ``` 39 | git clone https://github.com/amclubs/am-nodejs-proxy.git 40 | ``` 41 | ``` 42 | cd am-nodejs-proxy 43 | ``` 44 | 45 | ## 使用 46 | 47 | 要使用该脚本,请运行: 48 | 49 | ``` 50 | ./start.sh 51 | ``` 52 | 53 | | Action | Sub-Action | Command | Description | 54 | | :----: | :-----------: | :---------------------: | :--------------------------------------------: | 55 | | setup | node/xray/cf | `./start.sh setup node` | 通过单个命令设置服务 | 56 | | check | node/xray/cf | `./start.sh check node` | 检查 Cloudflared 和其他服务 | 57 | | show | node/xray/all | `./start.sh show node` | 显示来自 node/.env 的 VLESS 连接链接 | 58 | 59 | 查看所有节点信息 60 | ``` 61 | cat domains/${USER}.serv00.net/am-nodejs-proxy/node/.env 62 | ``` 63 | 64 | ***NODE.JS 和 XRAY 不能同时处于活动状态。一次只能运行其中一个。*** 65 | 66 | ## 检查会话 67 | 68 | 要检查特定组件的状态,您可以附加到其 tmux 会话: 69 | 70 | ``` 71 | tmux attach -t 72 | ``` 73 | 74 | 将 `` 替换为: 75 | 76 | - `cf` for Cloudflared 77 | - `node` for Node.js 78 | - `xray` for Xray 79 | 80 | 例如,要检查 Cloudflared 会话: 81 | 82 | ``` 83 | tmux attach -t cf 84 | ``` 85 | 86 | 要从 tmux 会话分离而不关闭它,请按: 87 | 88 | ``` 89 | Ctrl + b, 然后是 d 90 | ``` 91 | 92 | 此组合键允许您退出会话,同时使其在后台运行。 93 | 94 | ## Notes 95 | 96 | - 该脚本使用 tmux 来管理每个组件的会话。 97 | - 设置 Cron 作业用于定期维护 Node.js 和 Xray。 98 | - Cloudflared、Node.js 和 Xray 配置自动生成。 99 | - 该脚本包括端口管理和清理功能。 100 | 101 | # 102 |
103 |
[点击展开] 赞赏支持 ~🧧 104 | *我非常感谢您的赞赏和支持,它们将极大地激励我继续创新,持续产生有价值的工作。* 105 | 106 | - **USDT-TRC20:** `TWTxUyay6QJN3K4fs4kvJTT8Zfa2mWTwDD` 107 | - **TRX-TRC20:** `TWTxUyay6QJN3K4fs4kvJTT8Zfa2mWTwDD` 108 | 109 |
110 |
111 | TRC10/TRC20扫码支付 112 |
113 |
114 |
115 | 116 | # 117 | 免责声明: 118 | - 1、该项目设计和开发仅供学习、研究和安全测试目的。请于下载后 24 小时内删除, 不得用作任何商业用途, 文字、数据及图片均有所属版权, 如转载须注明来源。 119 | - 2、使用本程序必循遵守部署服务器所在地区的法律、所在国家和用户所在国家的法律法规。对任何人或团体使用该项目时产生的任何后果由使用者承担。 120 | - 3、作者不对使用该项目可能引起的任何直接或间接损害负责。作者保留随时更新免责声明的权利,且不另行通知。 121 | 122 | -------------------------------------------------------------------------------- /build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # build.sh 4 | # This is an example of some "process". Here it uses 5 | # pandoc to convert from MarkDown to different formats 6 | # and saves the output into "output_temp" 7 | 8 | OUTPUT_DIR="output_temp" 9 | 10 | mkdir "$OUTPUT_DIR" 11 | 12 | 13 | date > "$OUTPUT_DIR"/.build_date.txt 14 | 15 | echo "generated_at: $(date)" > variables.yml 16 | 17 | #mustache variables.yml index.output.html > "$OUTPUT_DIR"/index.html 18 | #mustache variables.yml README.output.md > "$OUTPUT_DIR"/README.md 19 | -------------------------------------------------------------------------------- /node/index.js: -------------------------------------------------------------------------------- 1 | /** 2 | *- Telegram交流群:https://t.me/AM_CLUBS 3 | *- YouTube频道:https://youtube.com/@AM_CLUB 4 | *- VLESS订阅地址:https://worker.amcloud.filegear-sg.me/866853eb-5293-4f09-bf00-e13eb237c655 5 | *- Github仓库地址:https://github.com/ansoncloud8 6 | **/ 7 | 8 | // Required modules 9 | require('dotenv').config() 10 | const net = require('net') 11 | const { TextDecoder } = require('util') 12 | const { WebSocket, createWebSocketStream } = require('ws') 13 | 14 | // Constants 15 | const serverID = process.env.ID 16 | const serverPort = process.env.PORT 17 | 18 | // Define logging and error callback function 19 | const log = (type, ...args) => console[type](`[${new Date().toISOString()}] ${type.toUpperCase()}:`, ...args) 20 | 21 | // Define WebSocket server 22 | const wss = new WebSocket.Server({ port: serverPort }, () => log('info', 'listen:', serverPort)) 23 | wss.on('connection', (ws) => { 24 | ws.once('message', (msg) => handleMessage(msg, ws)) 25 | }) 26 | 27 | // Function to handle incoming messages 28 | const handleMessage = (msg, ws) => { 29 | const id = msg.slice(1, 17).toString('hex') 30 | if (id !== serverID) return 31 | const [version] = msg 32 | let offset = msg.slice(17, 18).readUInt8() + 19 33 | const targetPort = msg.slice(offset, (offset += 2)).readUInt16BE(0) 34 | const addressType = msg.slice(offset, (offset += 1)).readUInt8() 35 | const hosts = { 36 | 1: () => msg.slice(offset, (offset += 4)).join('.'), // IPV4 37 | 2: () => new TextDecoder().decode(msg.slice(offset + 1, (offset += 1 + msg.slice(offset, offset + 1).readUInt8()))), // Domain 38 | 3: () => msg.slice(offset, (offset += 16)).reduce((s, b, i, a) => (i % 2 ? s.concat(a.slice(i - 1, i + 1)) : s), []).map((b) => b.readUInt16BE(0).toString(16)).join(':') // IPV6 39 | } 40 | const targetHost = hosts[addressType] ? hosts[addressType]() : '' 41 | log('info', `Incoming connection from ${targetHost}:${targetPort}`) 42 | ws.send(new Uint8Array([version, 0])) 43 | const duplexStream = createWebSocketStream(ws) 44 | establishConnection(targetHost, targetPort, msg.slice(offset), duplexStream) 45 | } 46 | 47 | // Function to establish connection with the host 48 | const establishConnection = (host, port, data, duplex) => { 49 | const clientSocket = net.connect({ host, port }, function () { 50 | log('info', `Connected to ${host}:${port}`) 51 | this.write(data) 52 | duplex.on('error', () => log('error', `Error in WebSocket stream to ${host}:${port}`)).pipe(this).on('error', () => log('error', `Error piping data to/from ${host}:${port}`)).pipe(duplex) 53 | }).on('error', () => log('error', `Error connecting to ${host}:${port}`)) 54 | } 55 | -------------------------------------------------------------------------------- /node/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "am-nodejs-proxy-ws", 3 | "version": "1.0.0", 4 | "description": "Deploy vless nodes on Serv00 free hosting website,YouTube频道:https://youtube.com/@AM_CLUB ,GitHub频道:https://github.com/ansoncloud8 ,交流频道:https://t.me/AM_CLUBS", 5 | "author": "AM科技", 6 | "main": "index.js", 7 | "license": "GPL-3.0-only", 8 | "scripts": { 9 | "start": "node index.js", 10 | "test": "echo \"Error: no test specified\" && exit 1" 11 | }, 12 | "dependencies": { 13 | "dotenv": "latest", 14 | "ws": "latest" 15 | }, 16 | "engines": { 17 | "node": ">=14" 18 | } 19 | } -------------------------------------------------------------------------------- /output_temp/.build_date.txt: -------------------------------------------------------------------------------- 1 | Mon Aug 12 09:47:27 UTC 2024 2 | -------------------------------------------------------------------------------- /start.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | function cleanup() { 4 | echo "Script interrupted." 5 | exit 1 6 | } 7 | 8 | trap cleanup INT 9 | trap '' SIGTERM 10 | 11 | base_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 12 | 13 | function setup_services() { 14 | local action="${1:-xray}" 15 | init 16 | run_cloudflared 17 | run_app $action 18 | } 19 | 20 | function show_services() { 21 | local action="${1:-xray}" 22 | case $action in 23 | all) 24 | extract_vars '^VLESS_' 25 | ;; 26 | xray) 27 | extract_vars '^VLESS_XRAY' 28 | ;; 29 | node) 30 | extract_vars '^VLESS_NODE' 31 | ;; 32 | esac 33 | } 34 | 35 | function check_services() { 36 | local action="${1:-xray}" 37 | local cf_session=$(tmux list-sessions | grep -q "cf" && echo "1" || echo "0") 38 | local action_session=$(tmux list-sessions | grep -q "$action" && echo "1" || echo "0") 39 | if [ "$cf_session" -eq 0 ]; then 40 | setup_services $action 41 | exit 1 42 | fi 43 | if [ "$action_session" -eq 0 ]; then 44 | run_app $action 45 | exit 1 46 | fi 47 | } 48 | 49 | function init() { 50 | devil binexec on 51 | reset 52 | prepare_cloudflared 53 | prepare_node 54 | prepare_xray 55 | } 56 | 57 | function run_cloudflared() { 58 | local uuid=$(uuidgen) 59 | local port=$(reserve_port) 60 | local id=$(echo $uuid | tr -d '-') 61 | local session="cf" 62 | tmux kill-session -t $session 63 | tmux new-session -s $session -d "cd $base_dir/cloudflared && ./cloudflared tunnel --url localhost:$port --edge-ip-version auto --no-autoupdate -protocol http2 2>&1 | tee $base_dir/cloudflared/session_$session.log" 64 | sleep 10 65 | local log=$(<"$base_dir/cloudflared/session_$session.log") 66 | local cloudflared_address=$(echo "$log" | pcregrep -o1 'https://([^ ]+\.trycloudflare\.com)' | sed 's/https:\/\///') 67 | generate_configs $port $uuid $id $cloudflared_address 68 | } 69 | 70 | function run_node() { 71 | local session="node" 72 | tmux kill-session -t $session 73 | tmux new-session -s $session -d "cd $base_dir/node && node index.js 2>&1 | tee $base_dir/node/session_$session.log" 74 | set_cronjob $session 75 | } 76 | 77 | function run_xray() { 78 | local session="xray" 79 | tmux kill-session -t $session 80 | tmux new-session -s $session -d "cd $base_dir/xray && ./xray 2>&1 | tee $base_dir/xray/session_$session.log" 81 | set_cronjob $session 82 | } 83 | 84 | function reset() { 85 | tmux kill-session -a 86 | local ports=$(devil port list | awk '/[0-9]+/ {print $1}' | sort -u) 87 | for port in $ports; do 88 | devil port del tcp $port 89 | devil port del udp $port 90 | done 91 | } 92 | 93 | function prepare_cloudflared() { 94 | mkdir -p $base_dir/cloudflared 95 | cd $base_dir/cloudflared 96 | curl -Lo cloudflared.7z https://cloudflared.bowring.uk/binaries/cloudflared-freebsd-latest.7z 97 | 7z x cloudflared.7z 98 | rm cloudflared.7z 99 | mv $(find . -name 'cloudflared*') cloudflared 100 | rm -rf temp 101 | chmod +x cloudflared 102 | } 103 | 104 | function prepare_node() { 105 | mkdir -p $base_dir/node 106 | cd $base_dir/node 107 | npm install 108 | } 109 | 110 | function prepare_xray() { 111 | mkdir -p $base_dir/xray 112 | cd $base_dir/xray 113 | curl -Lo xray.zip https://github.com/xtls/xray-core/releases/latest/download/xray-freebsd-64.zip 114 | unzip -o xray.zip 115 | rm xray.zip 116 | chmod +x xray 117 | } 118 | 119 | function reserve_port() { 120 | local port 121 | while true; do 122 | port=$(jot -r 1 1024 64000) 123 | tcp_output=$(devil port add tcp $port 2>&1) 124 | udp_output=$(devil port add udp $port 2>&1) 125 | if ! echo "$tcp_output" | grep -q "\[Error\]" && ! echo "$udp_output" | grep -q "\[Error\]"; then 126 | echo $port 127 | break 128 | else 129 | devil port del tcp $port 130 | devil port del udp $port 131 | fi 132 | done 133 | } 134 | 135 | function generate_configs() { 136 | local port="$1" 137 | local uuid="$2" 138 | local id="$3" 139 | local cloudflared_address="$4" 140 | local vless_node="vless://${id}@icook.tw:443?security=tls&sni=${cloudflared_address}&alpn=h2,http/1.1&fp=chrome&type=ws&path=/&host=${cloudflared_address}&encryption=none#[pl]%20[vl-tl-ws]%20[at-ar-no]" 141 | local vless_xray="vless://${uuid}@visa.com:443?security=tls&sni=${cloudflared_address}&alpn=h2,http/1.1&fp=chrome&type=ws&path=/ws?ed%3D2048&host=${cloudflared_address}&encryption=none#[pl]%20[vl-tl-ws]%20[at-ar]" 142 | 143 | cat > $base_dir/node/.env << EOF 144 | PORT=$port 145 | UUID=$uuid 146 | ID=$id 147 | VLESS_NODE=$vless_node 148 | VLESS_XRAY=$vless_xray 149 | EOF 150 | 151 | cat > $base_dir/../public_html/sub.txt << EOF 152 | $vless_node 153 | $vless_xray 154 | EOF 155 | 156 | cat > $base_dir/xray/config.json << EOF 157 | { 158 | "log": { 159 | "loglevel": "none" 160 | }, 161 | "inbounds": [ 162 | { 163 | "port": ${port}, 164 | "listen": "127.0.0.1", 165 | "protocol": "vless", 166 | "settings": { 167 | "clients": [ 168 | { 169 | "id": "${uuid}", 170 | "level": 0, 171 | "email": "ansoncloud8@gmail.com" 172 | } 173 | ], 174 | "decryption": "none" 175 | }, 176 | "streamSettings": { 177 | "network": "ws", 178 | "security": "none", 179 | "wsSettings": { 180 | "path": "/ws?ed=2048" 181 | } 182 | } 183 | } 184 | ], 185 | "outbounds": [ 186 | { 187 | "protocol": "freedom" 188 | } 189 | ] 190 | } 191 | EOF 192 | } 193 | 194 | function run_app() { 195 | local action="$1" 196 | case $action in 197 | xray) 198 | run_xray 199 | ;; 200 | node) 201 | run_node 202 | ;; 203 | esac 204 | } 205 | 206 | function set_cronjob() { 207 | local action=$1 208 | local cron_job="*/1 * * * * $base_dir/start.sh check $action" 209 | crontab -rf 210 | echo "$cron_job" > temp_crontab 211 | crontab temp_crontab 212 | rm temp_crontab 213 | } 214 | 215 | function extract_vars() { 216 | local pattern="$1" 217 | local env_file="$base_dir/node/.env" 218 | 219 | if [ -f "$env_file" ]; then 220 | grep "$pattern" "$env_file" | sed 's/^[^=]*=//' 221 | else 222 | echo "Error: .env file not found in $base_dir/node/" 223 | return 1 224 | fi 225 | } 226 | 227 | function main() { 228 | local action="$1" 229 | local sub_action="$2" 230 | case $action in 231 | setup) 232 | setup_services $sub_action >/dev/null 2>&1 233 | ;; 234 | check) 235 | check_services $sub_action >/dev/null 2>&1 236 | ;; 237 | show) 238 | show_services $sub_action 239 | ;; 240 | *) 241 | echo "Usage: $0 {setup|check|show}" 242 | exit 1 243 | ;; 244 | esac 245 | } 246 | 247 | main "$@" 248 | -------------------------------------------------------------------------------- /variables.yml: -------------------------------------------------------------------------------- 1 | generated_at: Mon Aug 12 09:47:27 UTC 2024 2 | --------------------------------------------------------------------------------