├── LICENSE ├── README.md ├── XrayR.service ├── XrayR.sh ├── config ├── config.yml ├── custom_inbound.json ├── custom_outbound.json ├── dns.json ├── geoip.dat ├── geosite.dat ├── route.json └── rulelist ├── docker-compose.yml ├── gost.sh └── install.sh /LICENSE: -------------------------------------------------------------------------------- 1 | Mozilla Public License Version 2.0 2 | ================================== 3 | 4 | 1. Definitions 5 | -------------- 6 | 7 | 1.1. "Contributor" 8 | means each individual or legal entity that creates, contributes to 9 | the creation of, or owns Covered Software. 10 | 11 | 1.2. "Contributor Version" 12 | means the combination of the Contributions of others (if any) used 13 | by a Contributor and that particular Contributor's Contribution. 14 | 15 | 1.3. "Contribution" 16 | means Covered Software of a particular Contributor. 17 | 18 | 1.4. "Covered Software" 19 | means Source Code Form to which the initial Contributor has attached 20 | the notice in Exhibit A, the Executable Form of such Source Code 21 | Form, and Modifications of such Source Code Form, in each case 22 | including portions thereof. 23 | 24 | 1.5. "Incompatible With Secondary Licenses" 25 | means 26 | 27 | (a) that the initial Contributor has attached the notice described 28 | in Exhibit B to the Covered Software; or 29 | 30 | (b) that the Covered Software was made available under the terms of 31 | version 1.1 or earlier of the License, but not also under the 32 | terms of a Secondary License. 33 | 34 | 1.6. "Executable Form" 35 | means any form of the work other than Source Code Form. 36 | 37 | 1.7. "Larger Work" 38 | means a work that combines Covered Software with other material, in 39 | a separate file or files, that is not Covered Software. 40 | 41 | 1.8. "License" 42 | means this document. 43 | 44 | 1.9. "Licensable" 45 | means having the right to grant, to the maximum extent possible, 46 | whether at the time of the initial grant or subsequently, any and 47 | all of the rights conveyed by this License. 48 | 49 | 1.10. "Modifications" 50 | means any of the following: 51 | 52 | (a) any file in Source Code Form that results from an addition to, 53 | deletion from, or modification of the contents of Covered 54 | Software; or 55 | 56 | (b) any new file in Source Code Form that contains any Covered 57 | Software. 58 | 59 | 1.11. "Patent Claims" of a Contributor 60 | means any patent claim(s), including without limitation, method, 61 | process, and apparatus claims, in any patent Licensable by such 62 | Contributor that would be infringed, but for the grant of the 63 | License, by the making, using, selling, offering for sale, having 64 | made, import, or transfer of either its Contributions or its 65 | Contributor Version. 66 | 67 | 1.12. "Secondary License" 68 | means either the GNU General Public License, Version 2.0, the GNU 69 | Lesser General Public License, Version 2.1, the GNU Affero General 70 | Public License, Version 3.0, or any later versions of those 71 | licenses. 72 | 73 | 1.13. "Source Code Form" 74 | means the form of the work preferred for making modifications. 75 | 76 | 1.14. "You" (or "Your") 77 | means an individual or a legal entity exercising rights under this 78 | License. For legal entities, "You" includes any entity that 79 | controls, is controlled by, or is under common control with You. For 80 | purposes of this definition, "control" means (a) the power, direct 81 | or indirect, to cause the direction or management of such entity, 82 | whether by contract or otherwise, or (b) ownership of more than 83 | fifty percent (50%) of the outstanding shares or beneficial 84 | ownership of such entity. 85 | 86 | 2. License Grants and Conditions 87 | -------------------------------- 88 | 89 | 2.1. Grants 90 | 91 | Each Contributor hereby grants You a world-wide, royalty-free, 92 | non-exclusive license: 93 | 94 | (a) under intellectual property rights (other than patent or trademark) 95 | Licensable by such Contributor to use, reproduce, make available, 96 | modify, display, perform, distribute, and otherwise exploit its 97 | Contributions, either on an unmodified basis, with Modifications, or 98 | as part of a Larger Work; and 99 | 100 | (b) under Patent Claims of such Contributor to make, use, sell, offer 101 | for sale, have made, import, and otherwise transfer either its 102 | Contributions or its Contributor Version. 103 | 104 | 2.2. Effective Date 105 | 106 | The licenses granted in Section 2.1 with respect to any Contribution 107 | become effective for each Contribution on the date the Contributor first 108 | distributes such Contribution. 109 | 110 | 2.3. Limitations on Grant Scope 111 | 112 | The licenses granted in this Section 2 are the only rights granted under 113 | this License. No additional rights or licenses will be implied from the 114 | distribution or licensing of Covered Software under this License. 115 | Notwithstanding Section 2.1(b) above, no patent license is granted by a 116 | Contributor: 117 | 118 | (a) for any code that a Contributor has removed from Covered Software; 119 | or 120 | 121 | (b) for infringements caused by: (i) Your and any other third party's 122 | modifications of Covered Software, or (ii) the combination of its 123 | Contributions with other software (except as part of its Contributor 124 | Version); or 125 | 126 | (c) under Patent Claims infringed by Covered Software in the absence of 127 | its Contributions. 128 | 129 | This License does not grant any rights in the trademarks, service marks, 130 | or logos of any Contributor (except as may be necessary to comply with 131 | the notice requirements in Section 3.4). 132 | 133 | 2.4. Subsequent Licenses 134 | 135 | No Contributor makes additional grants as a result of Your choice to 136 | distribute the Covered Software under a subsequent version of this 137 | License (see Section 10.2) or under the terms of a Secondary License (if 138 | permitted under the terms of Section 3.3). 139 | 140 | 2.5. Representation 141 | 142 | Each Contributor represents that the Contributor believes its 143 | Contributions are its original creation(s) or it has sufficient rights 144 | to grant the rights to its Contributions conveyed by this License. 145 | 146 | 2.6. Fair Use 147 | 148 | This License is not intended to limit any rights You have under 149 | applicable copyright doctrines of fair use, fair dealing, or other 150 | equivalents. 151 | 152 | 2.7. Conditions 153 | 154 | Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted 155 | in Section 2.1. 156 | 157 | 3. Responsibilities 158 | ------------------- 159 | 160 | 3.1. Distribution of Source Form 161 | 162 | All distribution of Covered Software in Source Code Form, including any 163 | Modifications that You create or to which You contribute, must be under 164 | the terms of this License. You must inform recipients that the Source 165 | Code Form of the Covered Software is governed by the terms of this 166 | License, and how they can obtain a copy of this License. You may not 167 | attempt to alter or restrict the recipients' rights in the Source Code 168 | Form. 169 | 170 | 3.2. Distribution of Executable Form 171 | 172 | If You distribute Covered Software in Executable Form then: 173 | 174 | (a) such Covered Software must also be made available in Source Code 175 | Form, as described in Section 3.1, and You must inform recipients of 176 | the Executable Form how they can obtain a copy of such Source Code 177 | Form by reasonable means in a timely manner, at a charge no more 178 | than the cost of distribution to the recipient; and 179 | 180 | (b) You may distribute such Executable Form under the terms of this 181 | License, or sublicense it under different terms, provided that the 182 | license for the Executable Form does not attempt to limit or alter 183 | the recipients' rights in the Source Code Form under this License. 184 | 185 | 3.3. Distribution of a Larger Work 186 | 187 | You may create and distribute a Larger Work under terms of Your choice, 188 | provided that You also comply with the requirements of this License for 189 | the Covered Software. If the Larger Work is a combination of Covered 190 | Software with a work governed by one or more Secondary Licenses, and the 191 | Covered Software is not Incompatible With Secondary Licenses, this 192 | License permits You to additionally distribute such Covered Software 193 | under the terms of such Secondary License(s), so that the recipient of 194 | the Larger Work may, at their option, further distribute the Covered 195 | Software under the terms of either this License or such Secondary 196 | License(s). 197 | 198 | 3.4. Notices 199 | 200 | You may not remove or alter the substance of any license notices 201 | (including copyright notices, patent notices, disclaimers of warranty, 202 | or limitations of liability) contained within the Source Code Form of 203 | the Covered Software, except that You may alter any license notices to 204 | the extent required to remedy known factual inaccuracies. 205 | 206 | 3.5. Application of Additional Terms 207 | 208 | You may choose to offer, and to charge a fee for, warranty, support, 209 | indemnity or liability obligations to one or more recipients of Covered 210 | Software. However, You may do so only on Your own behalf, and not on 211 | behalf of any Contributor. You must make it absolutely clear that any 212 | such warranty, support, indemnity, or liability obligation is offered by 213 | You alone, and You hereby agree to indemnify every Contributor for any 214 | liability incurred by such Contributor as a result of warranty, support, 215 | indemnity or liability terms You offer. You may include additional 216 | disclaimers of warranty and limitations of liability specific to any 217 | jurisdiction. 218 | 219 | 4. Inability to Comply Due to Statute or Regulation 220 | --------------------------------------------------- 221 | 222 | If it is impossible for You to comply with any of the terms of this 223 | License with respect to some or all of the Covered Software due to 224 | statute, judicial order, or regulation then You must: (a) comply with 225 | the terms of this License to the maximum extent possible; and (b) 226 | describe the limitations and the code they affect. Such description must 227 | be placed in a text file included with all distributions of the Covered 228 | Software under this License. Except to the extent prohibited by statute 229 | or regulation, such description must be sufficiently detailed for a 230 | recipient of ordinary skill to be able to understand it. 231 | 232 | 5. Termination 233 | -------------- 234 | 235 | 5.1. The rights granted under this License will terminate automatically 236 | if You fail to comply with any of its terms. However, if You become 237 | compliant, then the rights granted under this License from a particular 238 | Contributor are reinstated (a) provisionally, unless and until such 239 | Contributor explicitly and finally terminates Your grants, and (b) on an 240 | ongoing basis, if such Contributor fails to notify You of the 241 | non-compliance by some reasonable means prior to 60 days after You have 242 | come back into compliance. Moreover, Your grants from a particular 243 | Contributor are reinstated on an ongoing basis if such Contributor 244 | notifies You of the non-compliance by some reasonable means, this is the 245 | first time You have received notice of non-compliance with this License 246 | from such Contributor, and You become compliant prior to 30 days after 247 | Your receipt of the notice. 248 | 249 | 5.2. If You initiate litigation against any entity by asserting a patent 250 | infringement claim (excluding declaratory judgment actions, 251 | counter-claims, and cross-claims) alleging that a Contributor Version 252 | directly or indirectly infringes any patent, then the rights granted to 253 | You by any and all Contributors for the Covered Software under Section 254 | 2.1 of this License shall terminate. 255 | 256 | 5.3. In the event of termination under Sections 5.1 or 5.2 above, all 257 | end user license agreements (excluding distributors and resellers) which 258 | have been validly granted by You or Your distributors under this License 259 | prior to termination shall survive termination. 260 | 261 | ************************************************************************ 262 | * * 263 | * 6. Disclaimer of Warranty * 264 | * ------------------------- * 265 | * * 266 | * Covered Software is provided under this License on an "as is" * 267 | * basis, without warranty of any kind, either expressed, implied, or * 268 | * statutory, including, without limitation, warranties that the * 269 | * Covered Software is free of defects, merchantable, fit for a * 270 | * particular purpose or non-infringing. The entire risk as to the * 271 | * quality and performance of the Covered Software is with You. * 272 | * Should any Covered Software prove defective in any respect, You * 273 | * (not any Contributor) assume the cost of any necessary servicing, * 274 | * repair, or correction. This disclaimer of warranty constitutes an * 275 | * essential part of this License. No use of any Covered Software is * 276 | * authorized under this License except under this disclaimer. * 277 | * * 278 | ************************************************************************ 279 | 280 | ************************************************************************ 281 | * * 282 | * 7. Limitation of Liability * 283 | * -------------------------- * 284 | * * 285 | * Under no circumstances and under no legal theory, whether tort * 286 | * (including negligence), contract, or otherwise, shall any * 287 | * Contributor, or anyone who distributes Covered Software as * 288 | * permitted above, be liable to You for any direct, indirect, * 289 | * special, incidental, or consequential damages of any character * 290 | * including, without limitation, damages for lost profits, loss of * 291 | * goodwill, work stoppage, computer failure or malfunction, or any * 292 | * and all other commercial damages or losses, even if such party * 293 | * shall have been informed of the possibility of such damages. This * 294 | * limitation of liability shall not apply to liability for death or * 295 | * personal injury resulting from such party's negligence to the * 296 | * extent applicable law prohibits such limitation. Some * 297 | * jurisdictions do not allow the exclusion or limitation of * 298 | * incidental or consequential damages, so this exclusion and * 299 | * limitation may not apply to You. * 300 | * * 301 | ************************************************************************ 302 | 303 | 8. Litigation 304 | ------------- 305 | 306 | Any litigation relating to this License may be brought only in the 307 | courts of a jurisdiction where the defendant maintains its principal 308 | place of business and such litigation shall be governed by laws of that 309 | jurisdiction, without reference to its conflict-of-law provisions. 310 | Nothing in this Section shall prevent a party's ability to bring 311 | cross-claims or counter-claims. 312 | 313 | 9. Miscellaneous 314 | ---------------- 315 | 316 | This License represents the complete agreement concerning the subject 317 | matter hereof. If any provision of this License is held to be 318 | unenforceable, such provision shall be reformed only to the extent 319 | necessary to make it enforceable. Any law or regulation which provides 320 | that the language of a contract shall be construed against the drafter 321 | shall not be used to construe this License against a Contributor. 322 | 323 | 10. Versions of the License 324 | --------------------------- 325 | 326 | 10.1. New Versions 327 | 328 | Mozilla Foundation is the license steward. Except as provided in Section 329 | 10.3, no one other than the license steward has the right to modify or 330 | publish new versions of this License. Each version will be given a 331 | distinguishing version number. 332 | 333 | 10.2. Effect of New Versions 334 | 335 | You may distribute the Covered Software under the terms of the version 336 | of the License under which You originally received the Covered Software, 337 | or under the terms of any subsequent version published by the license 338 | steward. 339 | 340 | 10.3. Modified Versions 341 | 342 | If you create software not governed by this License, and you want to 343 | create a new license for such software, you may create and use a 344 | modified version of this License if you rename the license and remove 345 | any references to the name of the license steward (except to note that 346 | such modified license differs from this License). 347 | 348 | 10.4. Distributing Source Code Form that is Incompatible With Secondary 349 | Licenses 350 | 351 | If You choose to distribute Source Code Form that is Incompatible With 352 | Secondary Licenses under the terms of this version of the License, the 353 | notice described in Exhibit B of this License must be attached. 354 | 355 | Exhibit A - Source Code Form License Notice 356 | ------------------------------------------- 357 | 358 | This Source Code Form is subject to the terms of the Mozilla Public 359 | License, v. 2.0. If a copy of the MPL was not distributed with this 360 | file, You can obtain one at http://mozilla.org/MPL/2.0/. 361 | 362 | If it is not possible or desirable to put the notice in a particular 363 | file, then You may include the notice in a location (such as a LICENSE 364 | file in a relevant directory) where a recipient would be likely to look 365 | for such a notice. 366 | 367 | You may add additional accurate notices of copyright ownership. 368 | 369 | Exhibit B - "Incompatible With Secondary Licenses" Notice 370 | --------------------------------------------------------- 371 | 372 | This Source Code Form is "Incompatible With Secondary Licenses", as 373 | defined by the Mozilla Public License, v. 2.0. 374 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # XRayR 2 | A Xray backend framework that can easily support many panels. 3 | 4 | 一个基于Xray的后端框架,支持V2ay,Trojan,Shadowsocks协议,极易扩展,支持多面板对接 5 | 6 | Find the source code here: [XrayR-project/XrayR](https://github.com/XrayR-project/XrayR) 7 | 8 | XrayR已于2022年4月27日删库,此库留作备份使用 9 | 10 | XrayR已于7.28回归 11 | 12 | # 详细使用教程 13 | 14 | [教程](https://crackair.gitbook.io/xrayr-project/) 15 | 16 | # 一键安装 17 | 18 | ``` 19 | bash <(curl -Ls https://raw.githubusercontent.com/longyi8/XrayR/master/install.sh) 20 | ``` 21 | # Docker 安装 22 | 23 | ``` 24 | docker pull crackair/xrayr:latest && docker run --restart=always --name xrayr -d -v ${PATH_TO_CONFIG}/config.yml:/etc/XrayR/config.yml --network=host crackair/xrayr:latest 25 | ``` 26 | 27 | # Docker compose 安装 28 | 0. 安装docker-compose: 29 | ``` 30 | curl -fsSL https://get.docker.com | bash -s docker 31 | curl -L "https://github.com/docker/compose/releases/download/1.26.1/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose 32 | chmod +x /usr/local/bin/docker-compose 33 | ``` 34 | 1. `git clone https://github.com/longyi8/XrayR` 35 | 2. `cd XrayR` 36 | 3. 编辑config。 37 | 配置文件基本格式如下,Nodes下可以同时添加多个面板,多个节点配置信息,只需添加相同格式的Nodes item即可。 38 | 4. 启动docker:`docker-compose up -d` 39 | ``` 40 | Log: 41 | Level: none # Log level: none, error, warning, info, debug 42 | AccessPath: # /etc/XrayR/access.Log 43 | ErrorPath: # /etc/XrayR/error.log 44 | DnsConfigPath: # /etc/XrayR/dns.json Path to dns config 45 | ConnetionConfig: 46 | Handshake: 4 # Handshake time limit, Second 47 | ConnIdle: 10 # Connection idle time limit, Second 48 | UplinkOnly: 2 # Time limit when the connection downstream is closed, Second 49 | DownlinkOnly: 4 # Time limit when the connection is closed after the uplink is closed, Second 50 | BufferSize: 64 # The internal cache size of each connection, kB 51 | Nodes: 52 | - 53 | PanelType: "SSpanel" # Panel type: SSpanel, V2board, PMpanel 54 | ApiConfig: 55 | ApiHost: "http://127.0.0.1:667" 56 | ApiKey: "123" 57 | NodeID: 41 58 | NodeType: V2ray # Node type: V2ray, Shadowsocks, Trojan 59 | Timeout: 30 # Timeout for the api request 60 | EnableVless: false # Enable Vless for V2ray Type 61 | EnableXTLS: false # Enable XTLS for V2ray and Trojan 62 | SpeedLimit: 0 # Mbps, Local settings will replace remote settings, 0 means disable 63 | DeviceLimit: 0 # Local settings will replace remote settings, 0 means disable 64 | RuleListPath: # /etc/XrayR/rulelist Path to local rulelist file 65 | ControllerConfig: 66 | ListenIP: 0.0.0.0 # IP address you want to listen 67 | SendIP: 0.0.0.0 # IP address you want to send pacakage 68 | UpdatePeriodic: 60 # Time to update the nodeinfo, how many sec. 69 | EnableDNS: false # Use custom DNS config, Please ensure that you set the dns.json well 70 | DNSType: AsIs # AsIs, UseIP, UseIPv4, UseIPv6, DNS strategy 71 | EnableProxyProtocol: false # Only works for WebSocket and TCP 72 | EnableFallback: false # Only support for Trojan and Vless 73 | FallBackConfigs: # Support multiple fallbacks 74 | - 75 | SNI: # TLS SNI(Server Name Indication), Empty for any 76 | Path: # HTTP PATH, Empty for any 77 | Dest: 80 # Required, Destination of fallback, check https://xtls.github.io/config/fallback/ for details. 78 | ProxyProtocolVer: 0 # Send PROXY protocol version, 0 for dsable 79 | CertConfig: 80 | CertMode: dns # Option about how to get certificate: none, file, http, dns. Choose "none" will forcedly disable the tls config. 81 | CertDomain: "node1.test.com" # Domain to cert 82 | CertFile: /etc/XrayR/cert/node1.test.com.cert # Provided if the CertMode is file 83 | KeyFile: /etc/XrayR/cert/node1.test.com.key 84 | Provider: alidns # DNS cert provider, Get the full support list here: https://go-acme.github.io/lego/dns/ 85 | Email: test@me.com 86 | DNSEnv: # DNS ENV option used by DNS provider 87 | ALICLOUD_ACCESS_KEY: aaa 88 | ALICLOUD_SECRET_KEY: bbb 89 | # - 90 | # PanelType: "V2board" # Panel type: SSpanel, V2board 91 | # ApiConfig: 92 | # ApiHost: "http://127.0.0.1:668" 93 | # ApiKey: "123" 94 | # NodeID: 4 95 | # NodeType: Shadowsocks # Node type: V2ray, Shadowsocks, Trojan 96 | # Timeout: 30 # Timeout for the api request 97 | # EnableVless: false # Enable Vless for V2ray Type 98 | # EnableXTLS: false # Enable XTLS for V2ray and Trojan 99 | # SpeedLimit: 0 # Mbps, Local settings will replace remote settings 100 | # DeviceLimit: 0 # Local settings will replace remote settings 101 | # ControllerConfig: 102 | # ListenIP: 0.0.0.0 # IP address you want to listen 103 | # UpdatePeriodic: 10 # Time to update the nodeinfo, how many sec. 104 | # EnableDNS: false # Use custom DNS config, Please ensure that you set the dns.json well 105 | # CertConfig: 106 | # CertMode: dns # Option about how to get certificate: none, file, http, dns 107 | # CertDomain: "node1.test.com" # Domain to cert 108 | # CertFile: /etc/XrayR/cert/node1.test.com.cert # Provided if the CertMode is file 109 | # KeyFile: /etc/XrayR/cert/node1.test.com.pem 110 | # Provider: alidns # DNS cert provider, Get the full support list here: https://go-acme.github.io/lego/dns/ 111 | # Email: test@me.com 112 | # DNSEnv: # DNS ENV option used by DNS provider 113 | # ALICLOUD_ACCESS_KEY: aaa 114 | # ALICLOUD_SECRET_KEY: bbb 115 | ``` 116 | 117 | ## Docker compose升级 118 | 在docker-compose.yml目录下执行: 119 | ``` 120 | docker-compose pull 121 | docker-compose up -d 122 | ``` 123 | -------------------------------------------------------------------------------- /XrayR.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=XrayR Service 3 | After=network.target nss-lookup.target 4 | Wants=network.target 5 | 6 | [Service] 7 | User=root 8 | Group=root 9 | Type=simple 10 | LimitAS=infinity 11 | LimitRSS=infinity 12 | LimitCORE=infinity 13 | LimitNOFILE=999999 14 | WorkingDirectory=/usr/local/XrayR/ 15 | ExecStart=/usr/local/XrayR/XrayR -config /etc/XrayR/config.yml 16 | Restart=on-failure 17 | RestartSec=10 18 | 19 | [Install] 20 | WantedBy=multi-user.target 21 | -------------------------------------------------------------------------------- /XrayR.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | red='\033[0;31m' 4 | green='\033[0;32m' 5 | yellow='\033[0;33m' 6 | plain='\033[0m' 7 | 8 | version="v1.0.0" 9 | 10 | # check root 11 | [[ $EUID -ne 0 ]] && echo -e "${red}错误: ${plain} 必须使用root用户运行此脚本!\n" && exit 1 12 | 13 | # check os 14 | if [[ -f /etc/redhat-release ]]; then 15 | release="centos" 16 | elif cat /etc/issue | grep -Eqi "debian"; then 17 | release="debian" 18 | elif cat /etc/issue | grep -Eqi "ubuntu"; then 19 | release="ubuntu" 20 | elif cat /etc/issue | grep -Eqi "centos|red hat|redhat"; then 21 | release="centos" 22 | elif cat /proc/version | grep -Eqi "debian"; then 23 | release="debian" 24 | elif cat /proc/version | grep -Eqi "ubuntu"; then 25 | release="ubuntu" 26 | elif cat /proc/version | grep -Eqi "centos|red hat|redhat"; then 27 | release="centos" 28 | else 29 | echo -e "${red}未检测到系统版本,请联系脚本作者!${plain}\n" && exit 1 30 | fi 31 | 32 | os_version="" 33 | 34 | # os version 35 | if [[ -f /etc/os-release ]]; then 36 | os_version=$(awk -F'[= ."]' '/VERSION_ID/{print $3}' /etc/os-release) 37 | fi 38 | if [[ -z "$os_version" && -f /etc/lsb-release ]]; then 39 | os_version=$(awk -F'[= ."]+' '/DISTRIB_RELEASE/{print $2}' /etc/lsb-release) 40 | fi 41 | 42 | if [[ x"${release}" == x"centos" ]]; then 43 | if [[ ${os_version} -le 6 ]]; then 44 | echo -e "${red}请使用 CentOS 7 或更高版本的系统!${plain}\n" && exit 1 45 | fi 46 | elif [[ x"${release}" == x"ubuntu" ]]; then 47 | if [[ ${os_version} -lt 16 ]]; then 48 | echo -e "${red}请使用 Ubuntu 16 或更高版本的系统!${plain}\n" && exit 1 49 | fi 50 | elif [[ x"${release}" == x"debian" ]]; then 51 | if [[ ${os_version} -lt 8 ]]; then 52 | echo -e "${red}请使用 Debian 8 或更高版本的系统!${plain}\n" && exit 1 53 | fi 54 | fi 55 | 56 | confirm() { 57 | if [[ $# > 1 ]]; then 58 | echo && read -p "$1 [默认$2]: " temp 59 | if [[ x"${temp}" == x"" ]]; then 60 | temp=$2 61 | fi 62 | else 63 | read -p "$1 [y/n]: " temp 64 | fi 65 | if [[ x"${temp}" == x"y" || x"${temp}" == x"Y" ]]; then 66 | return 0 67 | else 68 | return 1 69 | fi 70 | } 71 | 72 | confirm_restart() { 73 | confirm "是否重启XrayR" "y" 74 | if [[ $? == 0 ]]; then 75 | restart 76 | else 77 | show_menu 78 | fi 79 | } 80 | 81 | before_show_menu() { 82 | echo && echo -n -e "${yellow}按回车返回主菜单: ${plain}" && read temp 83 | show_menu 84 | } 85 | 86 | install() { 87 | bash <(curl -Ls https://raw.githubusercontent.com/261818813/XrayR/master/install.sh) 88 | if [[ $? == 0 ]]; then 89 | if [[ $# == 0 ]]; then 90 | start 91 | else 92 | start 0 93 | fi 94 | fi 95 | } 96 | 97 | update() { 98 | if [[ $# == 0 ]]; then 99 | echo && echo -n -e "输入指定版本(默认最新版): " && read version 100 | else 101 | version=$2 102 | fi 103 | # confirm "本功能会强制重装当前最新版,数据不会丢失,是否继续?" "n" 104 | # if [[ $? != 0 ]]; then 105 | # echo -e "${red}已取消${plain}" 106 | # if [[ $1 != 0 ]]; then 107 | # before_show_menu 108 | # fi 109 | # return 0 110 | # fi 111 | bash <(curl -Ls https://raw.githubusercontent.com/longyi8/XrayR/master/install.sh) $version 112 | if [[ $? == 0 ]]; then 113 | echo -e "${green}更新完成,已自动重启 XrayR,请使用 XrayR log 查看运行日志${plain}" 114 | exit 115 | fi 116 | 117 | if [[ $# == 0 ]]; then 118 | before_show_menu 119 | fi 120 | } 121 | 122 | config() { 123 | echo "XrayR在修改配置后会自动尝试重启" 124 | vi /etc/XrayR/config.yml 125 | sleep 2 126 | check_status 127 | case $? in 128 | 0) 129 | echo -e "XrayR状态: ${green}已运行${plain}" 130 | ;; 131 | 1) 132 | echo -e "检测到您未启动XrayR或XrayR自动重启失败,是否查看日志?[Y/n]" && echo 133 | read -e -p "(默认: y):" yn 134 | [[ -z ${yn} ]] && yn="y" 135 | if [[ ${yn} == [Yy] ]]; then 136 | show_log 137 | fi 138 | ;; 139 | 2) 140 | echo -e "XrayR状态: ${red}未安装${plain}" 141 | esac 142 | } 143 | 144 | uninstall() { 145 | confirm "确定要卸载 XrayR 吗?" "n" 146 | if [[ $? != 0 ]]; then 147 | if [[ $# == 0 ]]; then 148 | show_menu 149 | fi 150 | return 0 151 | fi 152 | systemctl stop XrayR 153 | systemctl disable XrayR 154 | rm /etc/systemd/system/XrayR.service -f 155 | systemctl daemon-reload 156 | systemctl reset-failed 157 | rm /etc/XrayR/ -rf 158 | rm /usr/local/XrayR/ -rf 159 | 160 | echo "" 161 | echo -e "卸载成功,如果你想删除此脚本,则退出脚本后运行 ${green}rm /usr/bin/XrayR -f${plain} 进行删除" 162 | echo "" 163 | 164 | if [[ $# == 0 ]]; then 165 | before_show_menu 166 | fi 167 | } 168 | 169 | start() { 170 | check_status 171 | if [[ $? == 0 ]]; then 172 | echo "" 173 | echo -e "${green}XrayR已运行,无需再次启动,如需重启请选择重启${plain}" 174 | else 175 | systemctl start XrayR 176 | sleep 2 177 | check_status 178 | if [[ $? == 0 ]]; then 179 | echo -e "${green}XrayR 启动成功,请使用 XrayR log 查看运行日志${plain}" 180 | else 181 | echo -e "${red}XrayR可能启动失败,请稍后使用 XrayR log 查看日志信息${plain}" 182 | fi 183 | fi 184 | 185 | if [[ $# == 0 ]]; then 186 | before_show_menu 187 | fi 188 | } 189 | 190 | stop() { 191 | systemctl stop XrayR 192 | sleep 2 193 | check_status 194 | if [[ $? == 1 ]]; then 195 | echo -e "${green}XrayR 停止成功${plain}" 196 | else 197 | echo -e "${red}XrayR停止失败,可能是因为停止时间超过了两秒,请稍后查看日志信息${plain}" 198 | fi 199 | 200 | if [[ $# == 0 ]]; then 201 | before_show_menu 202 | fi 203 | } 204 | 205 | restart() { 206 | systemctl restart XrayR 207 | sleep 2 208 | check_status 209 | if [[ $? == 0 ]]; then 210 | echo -e "${green}XrayR 重启成功,请使用 XrayR log 查看运行日志${plain}" 211 | else 212 | echo -e "${red}XrayR可能启动失败,请稍后使用 XrayR log 查看日志信息${plain}" 213 | fi 214 | if [[ $# == 0 ]]; then 215 | before_show_menu 216 | fi 217 | } 218 | 219 | status() { 220 | systemctl status XrayR --no-pager -l 221 | if [[ $# == 0 ]]; then 222 | before_show_menu 223 | fi 224 | } 225 | 226 | enable() { 227 | systemctl enable XrayR 228 | if [[ $? == 0 ]]; then 229 | echo -e "${green}XrayR 设置开机自启成功${plain}" 230 | else 231 | echo -e "${red}XrayR 设置开机自启失败${plain}" 232 | fi 233 | 234 | if [[ $# == 0 ]]; then 235 | before_show_menu 236 | fi 237 | } 238 | 239 | disable() { 240 | systemctl disable XrayR 241 | if [[ $? == 0 ]]; then 242 | echo -e "${green}XrayR 取消开机自启成功${plain}" 243 | else 244 | echo -e "${red}XrayR 取消开机自启失败${plain}" 245 | fi 246 | 247 | if [[ $# == 0 ]]; then 248 | before_show_menu 249 | fi 250 | } 251 | 252 | show_log() { 253 | journalctl -u XrayR.service -e --no-pager -f 254 | if [[ $# == 0 ]]; then 255 | before_show_menu 256 | fi 257 | } 258 | 259 | install_bbr() { 260 | bash <(curl -L -s https://raw.githubusercontent.com/chiakge/Linux-NetSpeed/master/tcp.sh) 261 | #if [[ $? == 0 ]]; then 262 | # echo "" 263 | # echo -e "${green}安装 bbr 成功,请重启服务器${plain}" 264 | #else 265 | # echo "" 266 | # echo -e "${red}下载 bbr 安装脚本失败,请检查本机能否连接 Github${plain}" 267 | #fi 268 | 269 | #before_show_menu 270 | } 271 | 272 | update_shell() { 273 | wget -O /usr/bin/XrayR -N --no-check-certificate https://raw.githubusercontent.com/longyi8/XrayR/master/XrayR.sh 274 | if [[ $? != 0 ]]; then 275 | echo "" 276 | echo -e "${red}下载脚本失败,请检查本机能否连接 Github${plain}" 277 | before_show_menu 278 | else 279 | chmod +x /usr/bin/XrayR 280 | echo -e "${green}升级脚本成功,请重新运行脚本${plain}" && exit 0 281 | fi 282 | } 283 | 284 | # 0: running, 1: not running, 2: not installed 285 | check_status() { 286 | if [[ ! -f /etc/systemd/system/XrayR.service ]]; then 287 | return 2 288 | fi 289 | temp=$(systemctl status XrayR | grep Active | awk '{print $3}' | cut -d "(" -f2 | cut -d ")" -f1) 290 | if [[ x"${temp}" == x"running" ]]; then 291 | return 0 292 | else 293 | return 1 294 | fi 295 | } 296 | 297 | check_enabled() { 298 | temp=$(systemctl is-enabled XrayR) 299 | if [[ x"${temp}" == x"enabled" ]]; then 300 | return 0 301 | else 302 | return 1; 303 | fi 304 | } 305 | 306 | check_uninstall() { 307 | check_status 308 | if [[ $? != 2 ]]; then 309 | echo "" 310 | echo -e "${red}XrayR已安装,请不要重复安装${plain}" 311 | if [[ $# == 0 ]]; then 312 | before_show_menu 313 | fi 314 | return 1 315 | else 316 | return 0 317 | fi 318 | } 319 | 320 | check_install() { 321 | check_status 322 | if [[ $? == 2 ]]; then 323 | echo "" 324 | echo -e "${red}请先安装XrayR${plain}" 325 | if [[ $# == 0 ]]; then 326 | before_show_menu 327 | fi 328 | return 1 329 | else 330 | return 0 331 | fi 332 | } 333 | 334 | show_status() { 335 | check_status 336 | case $? in 337 | 0) 338 | echo -e "XrayR状态: ${green}已运行${plain}" 339 | show_enable_status 340 | ;; 341 | 1) 342 | echo -e "XrayR状态: ${yellow}未运行${plain}" 343 | show_enable_status 344 | ;; 345 | 2) 346 | echo -e "XrayR状态: ${red}未安装${plain}" 347 | esac 348 | } 349 | 350 | show_enable_status() { 351 | check_enabled 352 | if [[ $? == 0 ]]; then 353 | echo -e "是否开机自启: ${green}是${plain}" 354 | else 355 | echo -e "是否开机自启: ${red}否${plain}" 356 | fi 357 | } 358 | 359 | show_XrayR_version() { 360 | echo -n "XrayR 版本:" 361 | /usr/local/XrayR/XrayR -version 362 | echo "" 363 | if [[ $# == 0 ]]; then 364 | before_show_menu 365 | fi 366 | } 367 | 368 | show_usage() { 369 | echo "XrayR 管理脚本使用方法: " 370 | echo "------------------------------------------" 371 | echo "XrayR - 显示管理菜单 (功能更多)" 372 | echo "XrayR start - 启动 XrayR" 373 | echo "XrayR stop - 停止 XrayR" 374 | echo "XrayR restart - 重启 XrayR" 375 | echo "XrayR status - 查看 XrayR 状态" 376 | echo "XrayR enable - 设置 XrayR 开机自启" 377 | echo "XrayR disable - 取消 XrayR 开机自启" 378 | echo "XrayR log - 查看 XrayR 日志" 379 | echo "XrayR update - 更新 XrayR" 380 | echo "XrayR update x.x.x - 更新 XrayR 指定版本" 381 | echo "XrayR install - 安装 XrayR" 382 | echo "XrayR uninstall - 卸载 XrayR" 383 | echo "XrayR version - 查看 XrayR 版本" 384 | echo "------------------------------------------" 385 | } 386 | 387 | show_menu() { 388 | echo -e " 389 | ${green}XrayR 后端管理脚本,${plain}${red}不适用于docker${plain} 390 | --- https://github.com/Misaka-blog/XrayR --- 391 | ${green}0.${plain} 修改配置 392 | ———————————————— 393 | ${green}1.${plain} 安装 XrayR 394 | ${green}2.${plain} 更新 XrayR 395 | ${green}3.${plain} 卸载 XrayR 396 | ———————————————— 397 | ${green}4.${plain} 启动 XrayR 398 | ${green}5.${plain} 停止 XrayR 399 | ${green}6.${plain} 重启 XrayR 400 | ${green}7.${plain} 查看 XrayR 状态 401 | ${green}8.${plain} 查看 XrayR 日志 402 | ———————————————— 403 | ${green}9.${plain} 设置 XrayR 开机自启 404 | ${green}10.${plain} 取消 XrayR 开机自启 405 | ———————————————— 406 | ${green}11.${plain} 一键安装 bbr (最新内核) 407 | ${green}12.${plain} 查看 XrayR 版本 408 | ${green}13.${plain} 升级维护脚本 409 | ${green}14.${plain} 关闭VMESS AEAD 410 | " 411 | #后续更新可加入上方字符串中 412 | show_status 413 | echo && read -p "请输入选择 [0-13]: " num 414 | 415 | case "${num}" in 416 | 0) config 417 | ;; 418 | 1) check_uninstall && install 419 | ;; 420 | 2) check_install && update 421 | ;; 422 | 3) check_install && uninstall 423 | ;; 424 | 4) check_install && start 425 | ;; 426 | 5) check_install && stop 427 | ;; 428 | 6) check_install && restart 429 | ;; 430 | 7) check_install && status 431 | ;; 432 | 8) check_install && show_log 433 | ;; 434 | 9) check_install && enable 435 | ;; 436 | 10) check_install && disable 437 | ;; 438 | 11) install_bbr 439 | ;; 440 | 12) check_install && show_XrayR_version 441 | ;; 442 | 13) update_shell 443 | ;; 444 | 14) echo "正在关闭AEAD强制加密..."&& sed -i 'N;18 i Environment="XRAY_VMESS_AEAD_FORCED=false"' /etc/systemd/system/XrayR.service && systemctl daemon-reload && check_install && restart 445 | ;; 446 | *) echo -e "${red}请输入正确的数字 [0-14]${plain}" 447 | ;; 448 | esac 449 | } 450 | 451 | 452 | if [[ $# > 0 ]]; then 453 | case $1 in 454 | "start") check_install 0 && start 0 455 | ;; 456 | "stop") check_install 0 && stop 0 457 | ;; 458 | "restart") check_install 0 && restart 0 459 | ;; 460 | "status") check_install 0 && status 0 461 | ;; 462 | "enable") check_install 0 && enable 0 463 | ;; 464 | "disable") check_install 0 && disable 0 465 | ;; 466 | "log") check_install 0 && show_log 0 467 | ;; 468 | "update") check_install 0 && update 0 $2 469 | ;; 470 | "config") config $* 471 | ;; 472 | "install") check_uninstall 0 && install 0 473 | ;; 474 | "uninstall") check_install 0 && uninstall 0 475 | ;; 476 | "version") check_install 0 && show_XrayR_version 0 477 | ;; 478 | "update_shell") update_shell 479 | ;; 480 | *) show_usage 481 | esac 482 | else 483 | show_menu 484 | fi 485 | -------------------------------------------------------------------------------- /config/config.yml: -------------------------------------------------------------------------------- 1 | Log: 2 | Level: warning # Log level: none, error, warning, info, debug 3 | AccessPath: # /etc/XrayR/access.Log 4 | ErrorPath: # /etc/XrayR/error.log 5 | DnsConfigPath: # /etc/XrayR/dns.json # Path to dns config, check https://xtls.github.io/config/base/dns/ for help 6 | InboundConfigPath: # /etc/XrayR/custom_inbound.json # Path to custom inbound config, check https://xtls.github.io/config/inbound.html for help 7 | RouteConfigPath: # /etc/XrayR/route.json # Path to route config, check https://xtls.github.io/config/base/route/ for help 8 | OutboundConfigPath: # /etc/XrayR/custom_outbound.json # Path to custom outbound config, check https://xtls.github.io/config/base/outbound/ for help 9 | ConnetionConfig: 10 | Handshake: 4 # Handshake time limit, Second 11 | ConnIdle: 30 # Connection idle time limit, Second 12 | UplinkOnly: 2 # Time limit when the connection downstream is closed, Second 13 | DownlinkOnly: 4 # Time limit when the connection is closed after the uplink is closed, Second 14 | BufferSize: 64 # The internal cache size of each connection, kB 15 | Nodes: 16 | - 17 | PanelType: "SSpanel" # Panel type: SSpanel, V2board, PMpanel, , Proxypanel 18 | ApiConfig: 19 | ApiHost: "http://127.0.0.1:667" 20 | ApiKey: "123" 21 | NodeID: 41 22 | NodeType: V2ray # Node type: V2ray, Shadowsocks, Trojan, Shadowsocks-Plugin 23 | Timeout: 30 # Timeout for the api request 24 | EnableVless: false # Enable Vless for V2ray Type 25 | EnableXTLS: false # Enable XTLS for V2ray and Trojan 26 | SpeedLimit: 0 # Mbps, Local settings will replace remote settings, 0 means disable 27 | DeviceLimit: 0 # Local settings will replace remote settings, 0 means disable 28 | RuleListPath: # /etc/XrayR/rulelist Path to local rulelist file 29 | ControllerConfig: 30 | ListenIP: 0.0.0.0 # IP address you want to listen 31 | SendIP: 0.0.0.0 # IP address you want to send pacakage 32 | UpdatePeriodic: 60 # Time to update the nodeinfo, how many sec. 33 | EnableDNS: false # Use custom DNS config, Please ensure that you set the dns.json well 34 | DNSType: AsIs # AsIs, UseIP, UseIPv4, UseIPv6, DNS strategy 35 | EnableProxyProtocol: false # Only works for WebSocket and TCP 36 | EnableFallback: false # Only support for Trojan and Vless 37 | FallBackConfigs: # Support multiple fallbacks 38 | - 39 | SNI: # TLS SNI(Server Name Indication), Empty for any 40 | Path: # HTTP PATH, Empty for any 41 | Dest: 80 # Required, Destination of fallback, check https://xtls.github.io/config/fallback/ for details. 42 | ProxyProtocolVer: 0 # Send PROXY protocol version, 0 for dsable 43 | CertConfig: 44 | CertMode: dns # Option about how to get certificate: none, file, http, dns. Choose "none" will forcedly disable the tls config. 45 | CertDomain: "node1.test.com" # Domain to cert 46 | CertFile: /etc/XrayR/cert/node1.test.com.cert # Provided if the CertMode is file 47 | KeyFile: /etc/XrayR/cert/node1.test.com.key 48 | Provider: alidns # DNS cert provider, Get the full support list here: https://go-acme.github.io/lego/dns/ 49 | Email: test@me.com 50 | DNSEnv: # DNS ENV option used by DNS provider 51 | ALICLOUD_ACCESS_KEY: aaa 52 | ALICLOUD_SECRET_KEY: bbb 53 | # - 54 | # PanelType: "V2board" # Panel type: SSpanel, V2board 55 | # ApiConfig: 56 | # ApiHost: "http://127.0.0.1:668" 57 | # ApiKey: "123" 58 | # NodeID: 4 59 | # NodeType: Shadowsocks # Node type: V2ray, Shadowsocks, Trojan 60 | # Timeout: 30 # Timeout for the api request 61 | # EnableVless: false # Enable Vless for V2ray Type 62 | # EnableXTLS: false # Enable XTLS for V2ray and Trojan 63 | # SpeedLimit: 0 # Mbps, Local settings will replace remote settings 64 | # DeviceLimit: 0 # Local settings will replace remote settings 65 | # ControllerConfig: 66 | # ListenIP: 0.0.0.0 # IP address you want to listen 67 | # UpdatePeriodic: 10 # Time to update the nodeinfo, how many sec. 68 | # EnableDNS: false # Use custom DNS config, Please ensure that you set the dns.json well 69 | # CertConfig: 70 | # CertMode: dns # Option about how to get certificate: none, file, http, dns 71 | # CertDomain: "node1.test.com" # Domain to cert 72 | # CertFile: /etc/XrayR/cert/node1.test.com.cert # Provided if the CertMode is file 73 | # KeyFile: /etc/XrayR/cert/node1.test.com.pem 74 | # Provider: alidns # DNS cert provider, Get the full support list here: https://go-acme.github.io/lego/dns/ 75 | # Email: test@me.com 76 | # DNSEnv: # DNS ENV option used by DNS provider 77 | # ALICLOUD_ACCESS_KEY: aaa 78 | # ALICLOUD_SECRET_KEY: bbb 79 | -------------------------------------------------------------------------------- /config/custom_inbound.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "listen": "0.0.0.0", 4 | "port": 1234, 5 | "protocol": "socks", 6 | "settings": { 7 | "auth": "noauth", 8 | "accounts": [ 9 | { 10 | "user": "my-username", 11 | "pass": "my-password" 12 | } 13 | ], 14 | "udp": false, 15 | "ip": "127.0.0.1", 16 | "userLevel": 0 17 | } 18 | } 19 | ] -------------------------------------------------------------------------------- /config/custom_outbound.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "tag": "IPv4_out", 4 | "protocol": "freedom" 5 | }, 6 | { 7 | "tag": "IPv6_out", 8 | "protocol": "freedom", 9 | "settings": { 10 | "domainStrategy": "UseIPv6" 11 | } 12 | }, 13 | { 14 | "protocol": "blackhole", 15 | "tag": "block" 16 | } 17 | ] 18 | -------------------------------------------------------------------------------- /config/dns.json: -------------------------------------------------------------------------------- 1 | { 2 | "servers": [ 3 | "1.1.1.1", 4 | "8.8.8.8", 5 | "localhost" 6 | ], 7 | "tag": "dns_inbound" 8 | } 9 | -------------------------------------------------------------------------------- /config/geoip.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/longyi8/XrayR/caebff5182136372b54ea91a4c1a3280c5541cdc/config/geoip.dat -------------------------------------------------------------------------------- /config/geosite.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/longyi8/XrayR/caebff5182136372b54ea91a4c1a3280c5541cdc/config/geosite.dat -------------------------------------------------------------------------------- /config/route.json: -------------------------------------------------------------------------------- 1 | { 2 | "domainStrategy": "IPOnDemand", 3 | "rules": [ 4 | { 5 | "type": "field", 6 | "outboundTag": "block", 7 | "ip": [ 8 | "geoip:private" 9 | ] 10 | }, 11 | { 12 | "type": "field", 13 | "outboundTag": "block", 14 | "protocol": [ 15 | "bittorrent" 16 | ] 17 | }, 18 | { 19 | "type": "field", 20 | "outboundTag": "IPv6_out", 21 | "domain": [ 22 | "geosite:netflix" 23 | ] 24 | } 25 | ] 26 | } 27 | -------------------------------------------------------------------------------- /config/rulelist: -------------------------------------------------------------------------------- 1 | (.+\.|^)(360|so)\.(cn|com) 2 | baidu.com 3 | google.com -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3' 2 | services: 3 | xrayr: 4 | image: crackair/xrayr:latest 5 | volumes: 6 | - ./config:/etc/XrayR/ # 映射配置文件夹 7 | restart: always 8 | network_mode: host 9 | -------------------------------------------------------------------------------- /gost.sh: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | Green_font_prefix="\033[32m" && Red_font_prefix="\033[31m" && Green_background_prefix="\033[42;37m" && Font_color_suffix="\033[0m" 3 | Info="${Green_font_prefix}[信息]${Font_color_suffix}" 4 | Error="${Red_font_prefix}[错误]${Font_color_suffix}" 5 | shell_version="1.0.8" 6 | gost_conf_path="/etc/gost/config.json" 7 | raw_conf_path="/etc/gost/rawconf" 8 | function checknew() { 9 | checknew=$(gost -V 2>&1 | awk '{print $2}') 10 | check_new_ver 11 | echo "你的gost版本为:""$checknew""" 12 | echo -n 是否更新\(y/n\)\: 13 | read checknewnum 14 | if test $checknewnum = "y"; then 15 | cp -r /etc/gost /tmp/ 16 | Install_ct 17 | rm -rf /etc/gost 18 | mv /tmp/gost /etc/ 19 | systemctl restart gost 20 | else 21 | exit 0 22 | fi 23 | } 24 | function check_sys() { 25 | if [[ -f /etc/redhat-release ]]; then 26 | release="centos" 27 | elif cat /etc/issue | grep -q -E -i "debian"; then 28 | release="debian" 29 | elif cat /etc/issue | grep -q -E -i "ubuntu"; then 30 | release="ubuntu" 31 | elif cat /etc/issue | grep -q -E -i "centos|red hat|redhat"; then 32 | release="centos" 33 | elif cat /proc/version | grep -q -E -i "debian"; then 34 | release="debian" 35 | elif cat /proc/version | grep -q -E -i "ubuntu"; then 36 | release="ubuntu" 37 | elif cat /proc/version | grep -q -E -i "centos|red hat|redhat"; then 38 | release="centos" 39 | fi 40 | bit=$(uname -m) 41 | if test "$bit" != "x86_64"; then 42 | echo "请输入你的芯片架构,/386/armv5/armv6/armv7/armv8" 43 | read bit 44 | else 45 | bit="amd64" 46 | fi 47 | } 48 | function Installation_dependency() { 49 | gzip_ver=$(gzip -V) 50 | if [[ -z ${gzip_ver} ]]; then 51 | if [[ ${release} == "centos" ]]; then 52 | yum update 53 | yum install -y gzip wget 54 | else 55 | apt-get update 56 | apt-get install -y gzip wget 57 | fi 58 | fi 59 | } 60 | function check_root() { 61 | [[ $EUID != 0 ]] && echo -e "${Error} 当前非ROOT账号(或没有ROOT权限),无法继续操作,请更换ROOT账号或使用 ${Green_background_prefix}sudo su${Font_color_suffix} 命令获取临时ROOT权限(执行后可能会提示输入当前账号的密码)。" && exit 1 62 | } 63 | function check_new_ver() { 64 | ct_new_ver=$(wget --no-check-certificate -qO- -t2 -T3 https://api.github.com/repos/ginuerzh/gost/releases/latest | grep "tag_name" | head -n 1 | awk -F ":" '{print $2}' | sed 's/\"//g;s/,//g;s/ //g;s/v//g') 65 | if [[ -z ${ct_new_ver} ]]; then 66 | ct_new_ver="2.11.1" 67 | echo -e "${Error} gost 最新版本获取失败,正在下载v${ct_new_ver}版" 68 | else 69 | echo -e "${Info} gost 目前最新版本为 ${ct_new_ver}" 70 | fi 71 | } 72 | function check_file() { 73 | if test ! -d "/usr/lib/systemd/system/"; then 74 | mkdir /usr/lib/systemd/system 75 | chmod -R 777 /usr/lib/systemd/system 76 | fi 77 | } 78 | function check_nor_file() { 79 | rm -rf "$(pwd)"/gost 80 | rm -rf "$(pwd)"/gost.service 81 | rm -rf "$(pwd)"/config.json 82 | rm -rf /etc/gost 83 | rm -rf /usr/lib/systemd/system/gost.service 84 | rm -rf /usr/bin/gost 85 | } 86 | function Install_ct() { 87 | check_root 88 | check_nor_file 89 | Installation_dependency 90 | check_file 91 | check_sys 92 | check_new_ver 93 | echo -e "若为国内机器建议使用大陆镜像加速下载" 94 | read -e -p "是否使用?[y/n]:" addyn 95 | [[ -z ${addyn} ]] && addyn="n" 96 | if [[ ${addyn} == [Yy] ]]; then 97 | rm -rf gost-linux-"$bit"-"$ct_new_ver".gz 98 | wget --no-check-certificate https://gotunnel.oss-cn-shenzhen.aliyuncs.com/gost-linux-amd64-2.11.1.gz 99 | gunzip gost-linux-"$bit"-"$ct_new_ver".gz 100 | mv gost-linux-"$bit"-"$ct_new_ver" gost 101 | mv gost /usr/bin/gost 102 | chmod -R 777 /usr/bin/gost 103 | wget --no-check-certificate https://gotunnel.oss-cn-shenzhen.aliyuncs.com/gost.service && chmod -R 777 gost.service && mv gost.service /usr/lib/systemd/system 104 | mkdir /etc/gost && wget --no-check-certificate https://gotunnel.oss-cn-shenzhen.aliyuncs.com/config.json && mv config.json /etc/gost && chmod -R 777 /etc/gost 105 | else 106 | rm -rf gost-linux-"$bit"-"$ct_new_ver".gz 107 | wget --no-check-certificate https://github.com/ginuerzh/gost/releases/download/v"$ct_new_ver"/gost-linux-"$bit"-"$ct_new_ver".gz 108 | gunzip gost-linux-"$bit"-"$ct_new_ver".gz 109 | mv gost-linux-"$bit"-"$ct_new_ver" gost 110 | mv gost /usr/bin/gost 111 | chmod -R 777 /usr/bin/gost 112 | wget --no-check-certificate https://raw.githubusercontent.com/KANIKIG/Multi-EasyGost/master/gost.service && chmod -R 777 gost.service && mv gost.service /usr/lib/systemd/system 113 | mkdir /etc/gost && wget --no-check-certificate https://raw.githubusercontent.com/KANIKIG/Multi-EasyGost/master/config.json && mv config.json /etc/gost && chmod -R 777 /etc/gost 114 | fi 115 | 116 | systemctl enable gost && systemctl restart gost 117 | echo "------------------------------" 118 | if test -a /usr/bin/gost -a /usr/lib/systemctl/gost.service -a /etc/gost/config.json; then 119 | echo "gost安装成功" 120 | rm -rf "$(pwd)"/gost 121 | rm -rf "$(pwd)"/gost.service 122 | rm -rf "$(pwd)"/config.json 123 | else 124 | echo "gost没有安装成功" 125 | rm -rf "$(pwd)"/gost 126 | rm -rf "$(pwd)"/gost.service 127 | rm -rf "$(pwd)"/config.json 128 | rm -rf "$(pwd)"/gost.sh 129 | fi 130 | } 131 | function Uninstall_ct() { 132 | rm -rf /usr/bin/gost 133 | rm -rf /usr/lib/systemd/system/gost.service 134 | rm -rf /etc/gost 135 | rm -rf "$(pwd)"/gost.sh 136 | echo "gost已经成功删除" 137 | } 138 | function Start_ct() { 139 | systemctl start gost 140 | echo "已启动" 141 | } 142 | function Stop_ct() { 143 | systemctl stop gost 144 | echo "已停止" 145 | } 146 | function Restart_ct() { 147 | rm -rf /etc/gost/config.json 148 | confstart 149 | writeconf 150 | conflast 151 | systemctl restart gost 152 | echo "已重读配置并重启" 153 | } 154 | function read_protocol() { 155 | echo -e "请问您要设置哪种功能: " 156 | echo -e "-----------------------------------" 157 | echo -e "[1] tcp+udp流量转发, 不加密" 158 | echo -e "说明: 一般设置在国内中转机上" 159 | echo -e "-----------------------------------" 160 | echo -e "[2] 加密隧道流量转发" 161 | echo -e "说明: 用于转发原本加密等级较低的流量, 一般设置在国内中转机上" 162 | echo -e " 选择此协议意味着你还有一台机器用于接收此加密流量, 之后须在那台机器上配置协议[3]进行对接" 163 | echo -e "-----------------------------------" 164 | echo -e "[3] 解密由gost传输而来的流量并转发" 165 | echo -e "说明: 对于经由gost加密中转的流量, 通过此选项进行解密并转发给本机的代理服务端口或转发给其他远程机器" 166 | echo -e " 一般设置在用于接收中转流量的国外机器上" 167 | echo -e "-----------------------------------" 168 | echo -e "[4] 一键安装ss/socks5代理" 169 | echo -e "说明: 使用gost内置的代理协议,轻量且易于管理" 170 | echo -e "-----------------------------------" 171 | echo -e "[5] 进阶:多落地均衡负载" 172 | echo -e "说明: 支持各种加密方式的简单均衡负载" 173 | echo -e "-----------------------------------" 174 | echo -e "[6] 进阶:转发CDN自选节点" 175 | echo -e "说明: 只需在中转机设置" 176 | echo -e "-----------------------------------" 177 | read -p "请选择: " numprotocol 178 | 179 | if [ "$numprotocol" == "1" ]; then 180 | flag_a="nonencrypt" 181 | elif [ "$numprotocol" == "2" ]; then 182 | encrypt 183 | elif [ "$numprotocol" == "3" ]; then 184 | decrypt 185 | elif [ "$numprotocol" == "4" ]; then 186 | proxy 187 | elif [ "$numprotocol" == "5" ]; then 188 | enpeer 189 | elif [ "$numprotocol" == "6" ]; then 190 | cdn 191 | else 192 | echo "type error, please try again" 193 | exit 194 | fi 195 | } 196 | function read_s_port() { 197 | if [ "$flag_a" == "ss" ]; then 198 | echo -e "-----------------------------------" 199 | read -p "请输入ss密码: " flag_b 200 | elif [ "$flag_a" == "socks" ]; then 201 | echo -e "-----------------------------------" 202 | read -p "请输入socks密码: " flag_b 203 | else 204 | echo -e "------------------------------------------------------------------" 205 | echo -e "请问你要将本机哪个端口接收到的流量进行转发?" 206 | read -p "请输入: " flag_b 207 | fi 208 | } 209 | function read_d_ip() { 210 | if [ "$flag_a" == "ss" ]; then 211 | echo -e "------------------------------------------------------------------" 212 | echo -e "请问您要设置的ss加密(仅提供常用的几种): " 213 | echo -e "-----------------------------------" 214 | echo -e "[1] aes-256-gcm" 215 | echo -e "[2] aes-256-cfb" 216 | echo -e "[3] chacha20-ietf-poly1305" 217 | echo -e "[4] chacha20" 218 | echo -e "[5] rc4-md5" 219 | echo -e "[6] AEAD_CHACHA20_POLY1305" 220 | echo -e "-----------------------------------" 221 | read -p "请选择ss加密方式: " ssencrypt 222 | 223 | if [ "$ssencrypt" == "1" ]; then 224 | flag_c="aes-256-gcm" 225 | elif [ "$ssencrypt" == "2" ]; then 226 | flag_c="aes-256-cfb" 227 | elif [ "$ssencrypt" == "3" ]; then 228 | flag_c="chacha20-ietf-poly1305" 229 | elif [ "$ssencrypt" == "4" ]; then 230 | flag_c="chacha20" 231 | elif [ "$ssencrypt" == "5" ]; then 232 | flag_c="rc4-md5" 233 | elif [ "$ssencrypt" == "6" ]; then 234 | flag_c="AEAD_CHACHA20_POLY1305" 235 | else 236 | echo "type error, please try again" 237 | exit 238 | fi 239 | elif [ "$flag_a" == "socks" ]; then 240 | echo -e "-----------------------------------" 241 | read -p "请输入socks用户名: " flag_c 242 | elif [[ "$flag_a" == "peer"* ]]; then 243 | echo -e "------------------------------------------------------------------" 244 | echo -e "请输入落地列表文件名" 245 | read -e -p "自定义但不同配置应不重复,不用输入后缀,例如ips1、iplist2: " flag_c 246 | touch $flag_c.txt 247 | echo -e "------------------------------------------------------------------" 248 | echo -e "请依次输入你要均衡负载的落地ip与端口" 249 | while true; do 250 | echo -e "请问你要将本机从${flag_b}接收到的流量转发向的IP或域名?" 251 | read -p "请输入: " peer_ip 252 | echo -e "请问你要将本机从${flag_b}接收到的流量转发向${peer_ip}的哪个端口?" 253 | read -p "请输入: " peer_port 254 | echo -e "$peer_ip:$peer_port" >>$flag_c.txt 255 | read -e -p "是否继续添加落地?[Y/n]:" addyn 256 | [[ -z ${addyn} ]] && addyn="y" 257 | if [[ ${addyn} == [Nn] ]]; then 258 | echo -e "------------------------------------------------------------------" 259 | echo -e "已在root目录创建$flag_c.txt,您可以随时编辑该文件修改落地信息,重启gost即可生效" 260 | echo -e "------------------------------------------------------------------" 261 | break 262 | else 263 | echo -e "------------------------------------------------------------------" 264 | echo -e "继续添加均衡负载落地配置" 265 | fi 266 | done 267 | elif [[ "$flag_a" == "cdn"* ]]; then 268 | echo -e "------------------------------------------------------------------" 269 | echo -e "将本机从${flag_b}接收到的流量转发向的自选ip:" 270 | read -p "请输入: " flag_c 271 | echo -e "请问你要将本机从${flag_b}接收到的流量转发向${flag_c}的哪个端口?" 272 | echo -e "[1] 80" 273 | echo -e "[2] 443" 274 | echo -e "[3] 自定义端口(如8080等)" 275 | read -p "请选择端口: " cdnport 276 | if [ "$cdnport" == "1" ]; then 277 | flag_c="$flag_c:80" 278 | elif [ "$cdnport" == "2" ]; then 279 | flag_c="$flag_c:443" 280 | elif [ "$cdnport" == "3" ]; then 281 | read -p "请输入自定义端口: " customport 282 | flag_c="$flag_c:$customport" 283 | else 284 | echo "type error, please try again" 285 | exit 286 | fi 287 | else 288 | echo -e "------------------------------------------------------------------" 289 | echo -e "请问你要将本机从${flag_b}接收到的流量转发向哪个IP或域名?" 290 | echo -e "注: IP既可以是[远程机器/当前机器]的公网IP, 也可是以本机本地回环IP(即127.0.0.1)" 291 | echo -e "具体IP地址的填写, 取决于接收该流量的服务正在监听的IP(详见: https://github.com/KANIKIG/Multi-EasyGost)" 292 | if [[ ${is_cert} == [Yy] ]]; then 293 | echo -e "注意: 落地机开启自定义tls证书,务必填写${Red_font_prefix}域名${Font_color_suffix}" 294 | fi 295 | read -p "请输入: " flag_c 296 | fi 297 | } 298 | function read_d_port() { 299 | if [ "$flag_a" == "ss" ]; then 300 | echo -e "------------------------------------------------------------------" 301 | echo -e "请问你要设置ss代理服务的端口?" 302 | read -p "请输入: " flag_d 303 | elif [ "$flag_a" == "socks" ]; then 304 | echo -e "------------------------------------------------------------------" 305 | echo -e "请问你要设置socks代理服务的端口?" 306 | read -p "请输入: " flag_d 307 | elif [[ "$flag_a" == "peer"* ]]; then 308 | echo -e "------------------------------------------------------------------" 309 | echo -e "您要设置的均衡负载策略: " 310 | echo -e "-----------------------------------" 311 | echo -e "[1] round - 轮询" 312 | echo -e "[2] random - 随机" 313 | echo -e "[3] fifo - 自上而下" 314 | echo -e "-----------------------------------" 315 | read -p "请选择均衡负载类型: " numstra 316 | 317 | if [ "$numstra" == "1" ]; then 318 | flag_d="round" 319 | elif [ "$numstra" == "2" ]; then 320 | flag_d="random" 321 | elif [ "$numstra" == "3" ]; then 322 | flag_d="fifo" 323 | else 324 | echo "type error, please try again" 325 | exit 326 | fi 327 | elif [[ "$flag_a" == "cdn"* ]]; then 328 | echo -e "------------------------------------------------------------------" 329 | read -p "请输入host:" flag_d 330 | else 331 | echo -e "------------------------------------------------------------------" 332 | echo -e "请问你要将本机从${flag_b}接收到的流量转发向${flag_c}的哪个端口?" 333 | read -p "请输入: " flag_d 334 | if [[ ${is_cert} == [Yy] ]]; then 335 | flag_d="$flag_d?secure=true" 336 | fi 337 | fi 338 | } 339 | function writerawconf() { 340 | echo $flag_a"/""$flag_b""#""$flag_c""#""$flag_d" >>$raw_conf_path 341 | } 342 | function rawconf() { 343 | read_protocol 344 | read_s_port 345 | read_d_ip 346 | read_d_port 347 | writerawconf 348 | } 349 | function eachconf_retrieve() { 350 | d_server=${trans_conf#*#} 351 | d_port=${d_server#*#} 352 | d_ip=${d_server%#*} 353 | flag_s_port=${trans_conf%%#*} 354 | s_port=${flag_s_port#*/} 355 | is_encrypt=${flag_s_port%/*} 356 | } 357 | function confstart() { 358 | echo "{ 359 | \"Debug\": true, 360 | \"Retries\": 0, 361 | \"ServeNodes\": [" >>$gost_conf_path 362 | } 363 | function multiconfstart() { 364 | echo " { 365 | \"Retries\": 0, 366 | \"ServeNodes\": [" >>$gost_conf_path 367 | } 368 | function conflast() { 369 | echo " ] 370 | }" >>$gost_conf_path 371 | } 372 | function multiconflast() { 373 | if [ $i -eq $count_line ]; then 374 | echo " ] 375 | }" >>$gost_conf_path 376 | else 377 | echo " ] 378 | }," >>$gost_conf_path 379 | fi 380 | } 381 | function encrypt() { 382 | echo -e "请问您要设置的转发传输类型: " 383 | echo -e "-----------------------------------" 384 | echo -e "[1] tls隧道" 385 | echo -e "[2] ws隧道" 386 | echo -e "[3] wss隧道" 387 | echo -e "注意: 同一则转发,中转与落地传输类型必须对应!本脚本默认开启tcp+udp" 388 | echo -e "-----------------------------------" 389 | read -p "请选择转发传输类型: " numencrypt 390 | 391 | if [ "$numencrypt" == "1" ]; then 392 | flag_a="encrypttls" 393 | echo -e "注意: 选择 是 将针对落地的自定义证书开启证书校验保证安全性,稍后落地机务必填写${Red_font_prefix}域名${Font_color_suffix}" 394 | read -e -p "落地机是否开启了自定义tls证书?[y/n]:" is_cert 395 | elif [ "$numencrypt" == "2" ]; then 396 | flag_a="encryptws" 397 | elif [ "$numencrypt" == "3" ]; then 398 | flag_a="encryptwss" 399 | echo -e "注意: 选择 是 将针对落地的自定义证书开启证书校验保证安全性,稍后落地机务必填写${Red_font_prefix}域名${Font_color_suffix}" 400 | read -e -p "落地机是否开启了自定义tls证书?[y/n]:" is_cert 401 | else 402 | echo "type error, please try again" 403 | exit 404 | fi 405 | } 406 | function enpeer() { 407 | echo -e "请问您要设置的均衡负载传输类型: " 408 | echo -e "-----------------------------------" 409 | echo -e "[1] 不加密转发" 410 | echo -e "[2] tls隧道" 411 | echo -e "[3] ws隧道" 412 | echo -e "[4] wss隧道" 413 | echo -e "注意: 同一则转发,中转与落地传输类型必须对应!本脚本默认同一配置的传输类型相同" 414 | echo -e "此脚本仅支持简单型均衡负载,具体可参考官方文档" 415 | echo -e "gost均衡负载官方文档:https://docs.ginuerzh.xyz/gost/load-balancing" 416 | echo -e "-----------------------------------" 417 | read -p "请选择转发传输类型: " numpeer 418 | 419 | if [ "$numpeer" == "1" ]; then 420 | flag_a="peerno" 421 | elif [ "$numpeer" == "2" ]; then 422 | flag_a="peertls" 423 | elif [ "$numpeer" == "3" ]; then 424 | flag_a="peerws" 425 | elif [ "$numpeer" == "4" ]; then 426 | flag_a="peerwss" 427 | 428 | else 429 | echo "type error, please try again" 430 | exit 431 | fi 432 | } 433 | function cdn() { 434 | echo -e "请问您要设置的CDN传输类型: " 435 | echo -e "-----------------------------------" 436 | echo -e "[1] 不加密转发" 437 | echo -e "[2] ws隧道-80" 438 | echo -e "[3] wss隧道-443" 439 | echo -e "注意: 同一则转发,中转与落地传输类型必须对应!" 440 | echo -e "此功能只需在中转机设置,落地机若用隧道,流量入口必须是80/443,之后套cdn即可" 441 | echo -e "-----------------------------------" 442 | read -p "请选择CDN转发传输类型: " numcdn 443 | 444 | if [ "$numcdn" == "1" ]; then 445 | flag_a="cdnno" 446 | elif [ "$numcdn" == "2" ]; then 447 | flag_a="cdnws" 448 | elif [ "$numcdn" == "3" ]; then 449 | flag_a="cdnwss" 450 | else 451 | echo "type error, please try again" 452 | exit 453 | fi 454 | } 455 | function cert() { 456 | echo -e "-----------------------------------" 457 | echo -e "[1] ACME一键申请证书" 458 | echo -e "[2] 手动上传证书" 459 | echo -e "-----------------------------------" 460 | echo -e "说明: 仅用于落地机配置,默认使用的gost内置的证书可能带来安全问题,使用自定义证书提高安全性" 461 | echo -e " 配置后对本机所有tls/wss解密生效,无需再次设置" 462 | read -p "请选择证书生成方式: " numcert 463 | 464 | if [ "$numcert" == "1" ]; then 465 | echo -e "-----------------------------------" 466 | echo -e "请确认本机${Red_font_prefix}80端口${Font_color_suffix}未被占用,且已安装${Red_font_prefix}socat${Font_color_suffix},否则会申请失败" 467 | echo -e "socat安装命令 Ubuntu/Debian:apt-get install -y socat ;Centos: yum install -y socat" 468 | read -p "请输入解析到本机的域名:" domain 469 | curl https://get.acme.sh | sh 470 | echo -e "ACME证书申请程序安装成功" 471 | if "$HOME"/.acme.sh/acme.sh --issue -d "${domain}" --standalone -k ec-256 --force; then 472 | echo -e "SSL 证书生成成功,默认申请高安全性的ECC证书" 473 | if [ ! -d "$HOME/gost_cert" ]; then 474 | mkdir $HOME/gost_cert 475 | fi 476 | if "$HOME"/.acme.sh/acme.sh --installcert -d "${domain}" --fullchainpath $HOME/gost_cert/cert.pem --keypath $HOME/gost_cert/key.pem --ecc --force; then 477 | echo -e "SSL 证书配置成功,且会自动续签,证书及秘钥位于用户目录下的 ${Red_font_prefix}gost_cert${Font_color_suffix} 目录" 478 | echo -e "证书目录名与证书文件名请勿更改; 删除 gost_cert 目录后用脚本重启,即自动启用gost内置证书" 479 | echo -e "-----------------------------------" 480 | fi 481 | else 482 | echo -e "SSL 证书生成失败" 483 | exit 1 484 | fi 485 | elif [ "$numcert" == "2" ]; then 486 | if [ ! -d "$HOME/gost_cert" ]; then 487 | mkdir $HOME/gost_cert 488 | fi 489 | echo -e "-----------------------------------" 490 | echo -e "已在用户目录建立 ${Red_font_prefix}gost_cert${Font_color_suffix} 目录,请将证书文件 cert.pem 与秘钥文件 key.pem 上传到该目录" 491 | echo -e "证书与秘钥文件名必须与上述一致,目录名也请勿更改" 492 | echo -e "上传成功后,用脚本重启gost会自动启用,无需再设置; 删除 gost_cert 目录后用脚本重启,即重新启用gost内置证书" 493 | echo -e "-----------------------------------" 494 | else 495 | echo "type error, please try again" 496 | exit 497 | fi 498 | } 499 | function decrypt() { 500 | echo -e "请问您要设置的解密传输类型: " 501 | echo -e "-----------------------------------" 502 | echo -e "[1] tls" 503 | echo -e "[2] ws" 504 | echo -e "[3] wss" 505 | echo -e "注意: 同一则转发,中转与落地传输类型必须对应!本脚本默认开启tcp+udp" 506 | echo -e "-----------------------------------" 507 | read -p "请选择解密传输类型: " numdecrypt 508 | 509 | if [ "$numdecrypt" == "1" ]; then 510 | flag_a="decrypttls" 511 | elif [ "$numdecrypt" == "2" ]; then 512 | flag_a="decryptws" 513 | elif [ "$numdecrypt" == "3" ]; then 514 | flag_a="decryptwss" 515 | else 516 | echo "type error, please try again" 517 | exit 518 | fi 519 | } 520 | function proxy() { 521 | echo -e "------------------------------------------------------------------" 522 | echo -e "请问您要设置的代理类型: " 523 | echo -e "-----------------------------------" 524 | echo -e "[1] shadowsocks" 525 | echo -e "[2] socks5(强烈建议加隧道用于Telegram代理)" 526 | echo -e "-----------------------------------" 527 | read -p "请选择代理类型: " numproxy 528 | if [ "$numproxy" == "1" ]; then 529 | flag_a="ss" 530 | elif [ "$numproxy" == "2" ]; then 531 | flag_a="socks" 532 | else 533 | echo "type error, please try again" 534 | exit 535 | fi 536 | } 537 | function method() { 538 | if [ $i -eq 1 ]; then 539 | if [ "$is_encrypt" == "nonencrypt" ]; then 540 | echo " \"tcp://:$s_port/$d_ip:$d_port\", 541 | \"udp://:$s_port/$d_ip:$d_port\"" >>$gost_conf_path 542 | elif [ "$is_encrypt" == "cdnno" ]; then 543 | echo " \"tcp://:$s_port/$d_ip?host=$d_port\", 544 | \"udp://:$s_port/$d_ip?host=$d_port\"" >>$gost_conf_path 545 | elif [ "$is_encrypt" == "peerno" ]; then 546 | echo " \"tcp://:$s_port?ip=/root/$d_ip.txt&strategy=$d_port\", 547 | \"udp://:$s_port?ip=/root/$d_ip.txt&strategy=$d_port\"" >>$gost_conf_path 548 | elif [ "$is_encrypt" == "encrypttls" ]; then 549 | echo " \"tcp://:$s_port\", 550 | \"udp://:$s_port\" 551 | ], 552 | \"ChainNodes\": [ 553 | \"relay+tls://$d_ip:$d_port\"" >>$gost_conf_path 554 | elif [ "$is_encrypt" == "encryptws" ]; then 555 | echo " \"tcp://:$s_port\", 556 | \"udp://:$s_port\" 557 | ], 558 | \"ChainNodes\": [ 559 | \"relay+ws://$d_ip:$d_port\"" >>$gost_conf_path 560 | elif [ "$is_encrypt" == "encryptwss" ]; then 561 | echo " \"tcp://:$s_port\", 562 | \"udp://:$s_port\" 563 | ], 564 | \"ChainNodes\": [ 565 | \"relay+wss://$d_ip:$d_port\"" >>$gost_conf_path 566 | elif [ "$is_encrypt" == "peertls" ]; then 567 | echo " \"tcp://:$s_port\", 568 | \"udp://:$s_port\" 569 | ], 570 | \"ChainNodes\": [ 571 | \"relay+tls://:?ip=/root/$d_ip.txt&strategy=$d_port\"" >>$gost_conf_path 572 | elif [ "$is_encrypt" == "peerws" ]; then 573 | echo " \"tcp://:$s_port\", 574 | \"udp://:$s_port\" 575 | ], 576 | \"ChainNodes\": [ 577 | \"relay+ws://:?ip=/root/$d_ip.txt&strategy=$d_port\"" >>$gost_conf_path 578 | elif [ "$is_encrypt" == "peerwss" ]; then 579 | echo " \"tcp://:$s_port\", 580 | \"udp://:$s_port\" 581 | ], 582 | \"ChainNodes\": [ 583 | \"relay+wss://:?ip=/root/$d_ip.txt&strategy=$d_port\"" >>$gost_conf_path 584 | elif [ "$is_encrypt" == "cdnws" ]; then 585 | echo " \"tcp://:$s_port\", 586 | \"udp://:$s_port\" 587 | ], 588 | \"ChainNodes\": [ 589 | \"relay+ws://$d_ip?host=$d_port\"" >>$gost_conf_path 590 | elif [ "$is_encrypt" == "cdnwss" ]; then 591 | echo " \"tcp://:$s_port\", 592 | \"udp://:$s_port\" 593 | ], 594 | \"ChainNodes\": [ 595 | \"relay+wss://$d_ip?host=$d_port\"" >>$gost_conf_path 596 | elif [ "$is_encrypt" == "decrypttls" ]; then 597 | if [ -d "$HOME/gost_cert" ]; then 598 | echo " \"relay+tls://:$s_port/$d_ip:$d_port?cert=/root/gost_cert/cert.pem&key=/root/gost_cert/key.pem\"" >>$gost_conf_path 599 | else 600 | echo " \"relay+tls://:$s_port/$d_ip:$d_port\"" >>$gost_conf_path 601 | fi 602 | elif [ "$is_encrypt" == "decryptws" ]; then 603 | echo " \"relay+ws://:$s_port/$d_ip:$d_port\"" >>$gost_conf_path 604 | elif [ "$is_encrypt" == "decryptwss" ]; then 605 | if [ -d "$HOME/gost_cert" ]; then 606 | echo " \"relay+wss://:$s_port/$d_ip:$d_port?cert=/root/gost_cert/cert.pem&key=/root/gost_cert/key.pem\"" >>$gost_conf_path 607 | else 608 | echo " \"relay+wss://:$s_port/$d_ip:$d_port\"" >>$gost_conf_path 609 | fi 610 | elif [ "$is_encrypt" == "ss" ]; then 611 | echo " \"ss://$d_ip:$s_port@:$d_port\"" >>$gost_conf_path 612 | elif [ "$is_encrypt" == "socks" ]; then 613 | echo " \"socks5://$d_ip:$s_port@:$d_port\"" >>$gost_conf_path 614 | else 615 | echo "config error" 616 | fi 617 | elif [ $i -gt 1 ]; then 618 | if [ "$is_encrypt" == "nonencrypt" ]; then 619 | echo " \"tcp://:$s_port/$d_ip:$d_port\", 620 | \"udp://:$s_port/$d_ip:$d_port\"" >>$gost_conf_path 621 | elif [ "$is_encrypt" == "peerno" ]; then 622 | echo " \"tcp://:$s_port?ip=/root/$d_ip.txt&strategy=$d_port\", 623 | \"udp://:$s_port?ip=/root/$d_ip.txt&strategy=$d_port\"" >>$gost_conf_path 624 | elif [ "$is_encrypt" == "cdnno" ]; then 625 | echo " \"tcp://:$s_port/$d_ip?host=$d_port\", 626 | \"udp://:$s_port/$d_ip?host=$d_port\"" >>$gost_conf_path 627 | elif [ "$is_encrypt" == "encrypttls" ]; then 628 | echo " \"tcp://:$s_port\", 629 | \"udp://:$s_port\" 630 | ], 631 | \"ChainNodes\": [ 632 | \"relay+tls://$d_ip:$d_port\"" >>$gost_conf_path 633 | elif [ "$is_encrypt" == "encryptws" ]; then 634 | echo " \"tcp://:$s_port\", 635 | \"udp://:$s_port\" 636 | ], 637 | \"ChainNodes\": [ 638 | \"relay+ws://$d_ip:$d_port\"" >>$gost_conf_path 639 | elif [ "$is_encrypt" == "encryptwss" ]; then 640 | echo " \"tcp://:$s_port\", 641 | \"udp://:$s_port\" 642 | ], 643 | \"ChainNodes\": [ 644 | \"relay+wss://$d_ip:$d_port\"" >>$gost_conf_path 645 | elif [ "$is_encrypt" == "peertls" ]; then 646 | echo " \"tcp://:$s_port\", 647 | \"udp://:$s_port\" 648 | ], 649 | \"ChainNodes\": [ 650 | \"relay+tls://:?ip=/root/$d_ip.txt&strategy=$d_port\"" >>$gost_conf_path 651 | elif [ "$is_encrypt" == "peerws" ]; then 652 | echo " \"tcp://:$s_port\", 653 | \"udp://:$s_port\" 654 | ], 655 | \"ChainNodes\": [ 656 | \"relay+ws://:?ip=/root/$d_ip.txt&strategy=$d_port\"" >>$gost_conf_path 657 | elif [ "$is_encrypt" == "peerwss" ]; then 658 | echo " \"tcp://:$s_port\", 659 | \"udp://:$s_port\" 660 | ], 661 | \"ChainNodes\": [ 662 | \"relay+wss://:?ip=/root/$d_ip.txt&strategy=$d_port\"" >>$gost_conf_path 663 | elif [ "$is_encrypt" == "cdnws" ]; then 664 | echo " \"tcp://:$s_port\", 665 | \"udp://:$s_port\" 666 | ], 667 | \"ChainNodes\": [ 668 | \"relay+ws://$d_ip?host=$d_port\"" >>$gost_conf_path 669 | elif [ "$is_encrypt" == "cdnwss" ]; then 670 | echo " \"tcp://:$s_port\", 671 | \"udp://:$s_port\" 672 | ], 673 | \"ChainNodes\": [ 674 | \"relay+wss://$d_ip?host=$d_port\"" >>$gost_conf_path 675 | elif [ "$is_encrypt" == "decrypttls" ]; then 676 | if [ -d "$HOME/gost_cert" ]; then 677 | echo " \"relay+tls://:$s_port/$d_ip:$d_port?cert=/root/gost_cert/cert.pem&key=/root/gost_cert/key.pem\"" >>$gost_conf_path 678 | else 679 | echo " \"relay+tls://:$s_port/$d_ip:$d_port\"" >>$gost_conf_path 680 | fi 681 | elif [ "$is_encrypt" == "decryptws" ]; then 682 | echo " \"relay+ws://:$s_port/$d_ip:$d_port\"" >>$gost_conf_path 683 | elif [ "$is_encrypt" == "decryptwss" ]; then 684 | if [ -d "$HOME/gost_cert" ]; then 685 | echo " \"relay+wss://:$s_port/$d_ip:$d_port?cert=/root/gost_cert/cert.pem&key=/root/gost_cert/key.pem\"" >>$gost_conf_path 686 | else 687 | echo " \"relay+wss://:$s_port/$d_ip:$d_port\"" >>$gost_conf_path 688 | fi 689 | elif [ "$is_encrypt" == "ss" ]; then 690 | echo " \"ss://$d_ip:$s_port@:$d_port\"" >>$gost_conf_path 691 | elif [ "$is_encrypt" == "socks" ]; then 692 | echo " \"socks5://$d_ip:$s_port@:$d_port\"" >>$gost_conf_path 693 | else 694 | echo "config error" 695 | fi 696 | else 697 | echo "config error" 698 | exit 699 | fi 700 | } 701 | 702 | function writeconf() { 703 | count_line=$(awk 'END{print NR}' $raw_conf_path) 704 | for ((i = 1; i <= $count_line; i++)); do 705 | if [ $i -eq 1 ]; then 706 | trans_conf=$(sed -n "${i}p" $raw_conf_path) 707 | eachconf_retrieve 708 | method 709 | elif [ $i -gt 1 ]; then 710 | if [ $i -eq 2 ]; then 711 | echo " ], 712 | \"Routes\": [" >>$gost_conf_path 713 | trans_conf=$(sed -n "${i}p" $raw_conf_path) 714 | eachconf_retrieve 715 | multiconfstart 716 | method 717 | multiconflast 718 | else 719 | trans_conf=$(sed -n "${i}p" $raw_conf_path) 720 | eachconf_retrieve 721 | multiconfstart 722 | method 723 | multiconflast 724 | fi 725 | fi 726 | done 727 | } 728 | function show_all_conf() { 729 | echo -e " GOST 配置 " 730 | echo -e "--------------------------------------------------------" 731 | echo -e "序号|方法\t |本地端口\t|目的地地址:目的地端口" 732 | echo -e "--------------------------------------------------------" 733 | 734 | count_line=$(awk 'END{print NR}' $raw_conf_path) 735 | for ((i = 1; i <= $count_line; i++)); do 736 | trans_conf=$(sed -n "${i}p" $raw_conf_path) 737 | eachconf_retrieve 738 | 739 | if [ "$is_encrypt" == "nonencrypt" ]; then 740 | str="不加密中转" 741 | elif [ "$is_encrypt" == "encrypttls" ]; then 742 | str=" tls隧道 " 743 | elif [ "$is_encrypt" == "encryptws" ]; then 744 | str=" ws隧道 " 745 | elif [ "$is_encrypt" == "encryptwss" ]; then 746 | str=" wss隧道 " 747 | elif [ "$is_encrypt" == "peerno" ]; then 748 | str=" 不加密均衡负载 " 749 | elif [ "$is_encrypt" == "peertls" ]; then 750 | str=" tls隧道均衡负载 " 751 | elif [ "$is_encrypt" == "peerws" ]; then 752 | str=" ws隧道均衡负载 " 753 | elif [ "$is_encrypt" == "peerwss" ]; then 754 | str=" wss隧道均衡负载 " 755 | elif [ "$is_encrypt" == "decrypttls" ]; then 756 | str=" tls解密 " 757 | elif [ "$is_encrypt" == "decryptws" ]; then 758 | str=" ws解密 " 759 | elif [ "$is_encrypt" == "decryptwss" ]; then 760 | str=" wss解密 " 761 | elif [ "$is_encrypt" == "ss" ]; then 762 | str=" ss " 763 | elif [ "$is_encrypt" == "socks" ]; then 764 | str=" socks5 " 765 | elif [ "$is_encrypt" == "cdnno" ]; then 766 | str="不加密转发CDN" 767 | elif [ "$is_encrypt" == "cdnws" ]; then 768 | str="ws隧道转发CDN" 769 | elif [ "$is_encrypt" == "cdnwss" ]; then 770 | str="wss隧道转发CDN" 771 | else 772 | str="" 773 | fi 774 | 775 | echo -e " $i |$str |$s_port\t|$d_ip:$d_port" 776 | echo -e "--------------------------------------------------------" 777 | done 778 | } 779 | 780 | cron_restart() { 781 | echo -e "------------------------------------------------------------------" 782 | echo -e "gost定时重启任务: " 783 | echo -e "-----------------------------------" 784 | echo -e "[1] 配置gost定时重启任务" 785 | echo -e "[2] 删除gost定时重启任务" 786 | echo -e "-----------------------------------" 787 | read -p "请选择: " numcron 788 | if [ "$numcron" == "1" ]; then 789 | echo -e "------------------------------------------------------------------" 790 | echo -e "gost定时重启任务类型: " 791 | echo -e "-----------------------------------" 792 | echo -e "[1] 每?小时重启" 793 | echo -e "[2] 每日?点重启" 794 | echo -e "-----------------------------------" 795 | read -p "请选择: " numcrontype 796 | if [ "$numcrontype" == "1" ]; then 797 | echo -e "-----------------------------------" 798 | read -p "每?小时重启: " cronhr 799 | echo "0 0 */$cronhr * * ? * systemctl restart gost" >>/etc/crontab 800 | echo -e "定时重启设置成功!" 801 | elif [ "$numcrontype" == "2" ]; then 802 | echo -e "-----------------------------------" 803 | read -p "每日?点重启: " cronhr 804 | echo "0 0 $cronhr * * ? systemctl restart gost" >>/etc/crontab 805 | echo -e "定时重启设置成功!" 806 | else 807 | echo "type error, please try again" 808 | exit 809 | fi 810 | elif [ "$numcron" == "2" ]; then 811 | sed -i "/gost/d" /etc/crontab 812 | echo -e "定时重启任务删除完成!" 813 | else 814 | echo "type error, please try again" 815 | exit 816 | fi 817 | } 818 | 819 | update_sh() { 820 | ol_version=$(curl -L -s --connect-timeout 5 https://raw.githubusercontent.com/KANIKIG/Multi-EasyGost/master/gost.sh | grep "shell_version=" | head -1 | awk -F '=|"' '{print $3}') 821 | if [ -n "$ol_version" ]; then 822 | if [[ "$shell_version" != "$ol_version" ]]; then 823 | echo -e "存在新版本,是否更新 [Y/N]?" 824 | read -r update_confirm 825 | case $update_confirm in 826 | [yY][eE][sS] | [yY]) 827 | wget -N --no-check-certificate https://raw.githubusercontent.com/KANIKIG/Multi-EasyGost/master/gost.sh 828 | echo -e "更新完成" 829 | exit 0 830 | ;; 831 | *) ;; 832 | 833 | esac 834 | else 835 | echo -e " ${Green_font_prefix}当前版本为最新版本!${Font_color_suffix}" 836 | fi 837 | else 838 | echo -e " ${Red_font_prefix}脚本最新版本获取失败,请检查与github的连接!${Font_color_suffix}" 839 | fi 840 | } 841 | 842 | update_sh 843 | echo && echo -e " gost 一键安装配置脚本"${Red_font_prefix}[${shell_version}]${Font_color_suffix}" 844 | ----------- KANIKIG ----------- 845 | 特性: (1)本脚本采用systemd及gost配置文件对gost进行管理 846 | (2)能够在不借助其他工具(如screen)的情况下实现多条转发规则同时生效 847 | (3)机器reboot后转发不失效 848 | 功能: (1)tcp+udp不加密转发, (2)中转机加密转发, (3)落地机解密对接转发 849 | 帮助文档:https://github.com/KANIKIG/Multi-EasyGost 850 | 851 | ${Green_font_prefix}1.${Font_color_suffix} 安装 gost 852 | ${Green_font_prefix}2.${Font_color_suffix} 更新 gost 853 | ${Green_font_prefix}3.${Font_color_suffix} 卸载 gost 854 | ———————————— 855 | ${Green_font_prefix}4.${Font_color_suffix} 启动 gost 856 | ${Green_font_prefix}5.${Font_color_suffix} 停止 gost 857 | ${Green_font_prefix}6.${Font_color_suffix} 重启 gost 858 | ———————————— 859 | ${Green_font_prefix}7.${Font_color_suffix} 新增gost转发配置 860 | ${Green_font_prefix}8.${Font_color_suffix} 查看现有gost配置 861 | ${Green_font_prefix}9.${Font_color_suffix} 删除一则gost配置 862 | ———————————— 863 | ${Green_font_prefix}10.${Font_color_suffix} gost定时重启配置 864 | ${Green_font_prefix}11.${Font_color_suffix} 自定义TLS证书配置 865 | ————————————" && echo 866 | read -e -p " 请输入数字 [1-9]:" num 867 | case "$num" in 868 | 1) 869 | Install_ct 870 | ;; 871 | 2) 872 | checknew 873 | ;; 874 | 3) 875 | Uninstall_ct 876 | ;; 877 | 4) 878 | Start_ct 879 | ;; 880 | 5) 881 | Stop_ct 882 | ;; 883 | 6) 884 | Restart_ct 885 | ;; 886 | 7) 887 | rawconf 888 | rm -rf /etc/gost/config.json 889 | confstart 890 | writeconf 891 | conflast 892 | systemctl restart gost 893 | echo -e "配置已生效,当前配置如下" 894 | echo -e "--------------------------------------------------------" 895 | show_all_conf 896 | ;; 897 | 8) 898 | show_all_conf 899 | ;; 900 | 9) 901 | show_all_conf 902 | read -p "请输入你要删除的配置编号:" numdelete 903 | if echo $numdelete | grep -q '[0-9]'; then 904 | sed -i "${numdelete}d" $raw_conf_path 905 | rm -rf /etc/gost/config.json 906 | confstart 907 | writeconf 908 | conflast 909 | systemctl restart gost 910 | echo -e "配置已删除,服务已重启" 911 | else 912 | echo "请输入正确数字" 913 | fi 914 | ;; 915 | 10) 916 | cron_restart 917 | ;; 918 | 11) 919 | cert 920 | ;; 921 | *) 922 | echo "请输入正确数字 [1-9]" 923 | ;; 924 | esac 925 | -------------------------------------------------------------------------------- /install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | red='\033[0;31m' 4 | green='\033[0;32m' 5 | yellow='\033[0;33m' 6 | plain='\033[0m' 7 | 8 | cur_dir=$(pwd) 9 | 10 | # check root 11 | [[ $EUID -ne 0 ]] && echo -e "${red}错误:${plain} 必须使用root用户运行此脚本!\n" && exit 1 12 | 13 | # check os 14 | if [[ -f /etc/redhat-release ]]; then 15 | release="centos" 16 | elif cat /etc/issue | grep -Eqi "debian"; then 17 | release="debian" 18 | elif cat /etc/issue | grep -Eqi "ubuntu"; then 19 | release="ubuntu" 20 | elif cat /etc/issue | grep -Eqi "centos|red hat|redhat"; then 21 | release="centos" 22 | elif cat /proc/version | grep -Eqi "debian"; then 23 | release="debian" 24 | elif cat /proc/version | grep -Eqi "ubuntu"; then 25 | release="ubuntu" 26 | elif cat /proc/version | grep -Eqi "centos|red hat|redhat"; then 27 | release="centos" 28 | else 29 | echo -e "${red}未检测到系统版本,请联系脚本作者!${plain}\n" && exit 1 30 | fi 31 | 32 | arch=$(arch) 33 | 34 | if [[ $arch == "x86_64" || $arch == "x64" || $arch == "amd64" ]]; then 35 | arch="64" 36 | elif [[ $arch == "aarch64" || $arch == "arm64" ]]; then 37 | arch="arm64-v8a" 38 | elif [[ $arch == "s390x" ]]; then 39 | arch="s390x" 40 | else 41 | arch="64" 42 | echo -e "${red}检测架构失败,使用默认架构: ${arch}${plain}" 43 | fi 44 | 45 | echo "架构: ${arch}" 46 | 47 | if [ "$(getconf WORD_BIT)" != '32' ] && [ "$(getconf LONG_BIT)" != '64' ] ; then 48 | echo "本软件不支持 32 位系统(x86),请使用 64 位系统(x86_64),如果检测有误,请联系作者" 49 | exit 2 50 | fi 51 | 52 | os_version="" 53 | 54 | # os version 55 | if [[ -f /etc/os-release ]]; then 56 | os_version=$(awk -F'[= ."]' '/VERSION_ID/{print $3}' /etc/os-release) 57 | fi 58 | if [[ -z "$os_version" && -f /etc/lsb-release ]]; then 59 | os_version=$(awk -F'[= ."]+' '/DISTRIB_RELEASE/{print $2}' /etc/lsb-release) 60 | fi 61 | 62 | if [[ x"${release}" == x"centos" ]]; then 63 | if [[ ${os_version} -le 6 ]]; then 64 | echo -e "${red}请使用 CentOS 7 或更高版本的系统!${plain}\n" && exit 1 65 | fi 66 | elif [[ x"${release}" == x"ubuntu" ]]; then 67 | if [[ ${os_version} -lt 16 ]]; then 68 | echo -e "${red}请使用 Ubuntu 16 或更高版本的系统!${plain}\n" && exit 1 69 | fi 70 | elif [[ x"${release}" == x"debian" ]]; then 71 | if [[ ${os_version} -lt 8 ]]; then 72 | echo -e "${red}请使用 Debian 8 或更高版本的系统!${plain}\n" && exit 1 73 | fi 74 | fi 75 | 76 | install_base() { 77 | if [[ x"${release}" == x"centos" ]]; then 78 | yum install epel-release -y 79 | yum install wget curl unzip tar crontabs socat -y 80 | else 81 | apt update -y 82 | apt install wget curl unzip tar cron socat -y 83 | fi 84 | } 85 | 86 | # 0: running, 1: not running, 2: not installed 87 | check_status() { 88 | if [[ ! -f /etc/systemd/system/XrayR.service ]]; then 89 | return 2 90 | fi 91 | temp=$(systemctl status XrayR | grep Active | awk '{print $3}' | cut -d "(" -f2 | cut -d ")" -f1) 92 | if [[ x"${temp}" == x"running" ]]; then 93 | return 0 94 | else 95 | return 1 96 | fi 97 | } 98 | 99 | install_acme() { 100 | curl https://get.acme.sh | sh 101 | } 102 | 103 | install_XrayR() { 104 | if [[ -e /usr/local/XrayR/ ]]; then 105 | rm /usr/local/XrayR/ -rf 106 | fi 107 | 108 | mkdir /usr/local/XrayR/ -p 109 | cd /usr/local/XrayR/ 110 | 111 | if [ $# == 0 ] ;then 112 | last_version=$(curl -Ls "https://api.github.com/repos/longyi8/XrayR-/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/') 113 | if [[ ! -n "$last_version" ]]; then 114 | echo -e "${red}检测 XrayR 版本失败,可能是超出 Github API 限制,请稍后再试,或手动指定 XrayR 版本安装${plain}" 115 | exit 1 116 | fi 117 | echo -e "检测到 XrayR 最新版本:${last_version},开始安装" 118 | wget -q -N --no-check-certificate -O /usr/local/XrayR/XrayR-linux.zip https://github.com/longyi8/XrayR-/releases/download/${last_version}/XrayR-linux-${arch}.zip 119 | if [[ $? -ne 0 ]]; then 120 | echo -e "${red}下载 XrayR 失败,请确保你的服务器能够下载 Github 的文件${plain}" 121 | exit 1 122 | fi 123 | else 124 | last_version=$1 125 | url="https://github.com/longyi8/XrayR-/releases/download/${last_version}/XrayR-linux-${arch}.zip" 126 | echo -e "开始安装 XrayR v$1" 127 | wget -q -N --no-check-certificate -O /usr/local/XrayR/XrayR-linux.zip ${url} 128 | if [[ $? -ne 0 ]]; then 129 | echo -e "${red}下载 XrayR v$1 失败,请确保此版本存在${plain}" 130 | exit 1 131 | fi 132 | fi 133 | 134 | unzip XrayR-linux.zip 135 | rm XrayR-linux.zip -f 136 | chmod +x XrayR 137 | mkdir /etc/XrayR/ -p 138 | rm /etc/systemd/system/XrayR.service -f 139 | file="https://raw.githubusercontent.com/longyi8/XrayR/master/XrayR.service" 140 | wget -q -N --no-check-certificate -O /etc/systemd/system/XrayR.service ${file} 141 | #cp -f XrayR.service /etc/systemd/system/ 142 | systemctl daemon-reload 143 | systemctl stop XrayR 144 | systemctl enable XrayR 145 | echo -e "${green}XrayR ${last_version}${plain} 安装完成,已设置开机自启" 146 | cp geoip.dat /etc/XrayR/ 147 | cp geosite.dat /etc/XrayR/ 148 | 149 | if [[ ! -f /etc/XrayR/config.yml ]]; then 150 | cp config.yml /etc/XrayR/ 151 | echo -e "" 152 | echo -e "全新安装,请先参看教程:https://github.com/XrayR-project/XrayR,配置必要的内容" 153 | else 154 | systemctl start XrayR 155 | sleep 2 156 | check_status 157 | echo -e "" 158 | if [[ $? == 0 ]]; then 159 | echo -e "${green}XrayR 重启成功${plain}" 160 | else 161 | echo -e "${red}XrayR 可能启动失败,请稍后使用 XrayR log 查看日志信息,若无法启动,则可能更改了配置格式,请前往 wiki 查看:https://github.com/XrayR-project/XrayR/wiki${plain}" 162 | fi 163 | fi 164 | 165 | if [[ ! -f /etc/XrayR/dns.json ]]; then 166 | cp dns.json /etc/XrayR/ 167 | fi 168 | if [[ ! -f /etc/XrayR/route.json ]]; then 169 | cp route.json /etc/XrayR/ 170 | fi 171 | if [[ ! -f /etc/XrayR/custom_outbound.json ]]; then 172 | cp custom_outbound.json /etc/XrayR/ 173 | fi 174 | if [[ ! -f /etc/XrayR/custom_inbound.json ]]; then 175 | cp custom_inbound.json /etc/XrayR/ 176 | fi 177 | if [[ ! -f /etc/XrayR/ruelist ]]; then 178 | cp ruelist /etc/XrayR/ 179 | fi 180 | curl -o /usr/bin/XrayR -Ls https://raw.githubusercontent.com/longyi8/XrayR/master/XrayR.sh 181 | chmod +x /usr/bin/XrayR 182 | ln -s /usr/bin/XrayR /usr/bin/xrayr # 小写兼容 183 | chmod +x /usr/bin/xrayr 184 | echo -e "" 185 | echo "XrayR 管理脚本使用方法 (兼容使用xrayr执行,大小写不敏感): " 186 | echo "------------------------------------------" 187 | echo "XrayR - 显示管理菜单 (功能更多)" 188 | echo "XrayR start - 启动 XrayR" 189 | echo "XrayR stop - 停止 XrayR" 190 | echo "XrayR restart - 重启 XrayR" 191 | echo "XrayR status - 查看 XrayR 状态" 192 | echo "XrayR enable - 设置 XrayR 开机自启" 193 | echo "XrayR disable - 取消 XrayR 开机自启" 194 | echo "XrayR log - 查看 XrayR 日志" 195 | echo "XrayR update - 更新 XrayR" 196 | echo "XrayR update x.x.x - 更新 XrayR 指定版本" 197 | echo "XrayR config - 显示配置文件内容" 198 | echo "XrayR install - 安装 XrayR" 199 | echo "XrayR uninstall - 卸载 XrayR" 200 | echo "XrayR version - 查看 XrayR 版本" 201 | echo "------------------------------------------" 202 | } 203 | 204 | echo -e "${green}开始安装${plain}" 205 | install_base 206 | install_acme 207 | install_XrayR $1 208 | --------------------------------------------------------------------------------