├── .gitignore ├── LICENSE ├── README.md ├── config.sample.php ├── index.php └── parse.php /.gitignore: -------------------------------------------------------------------------------- 1 | config.php 2 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 郭宇翔 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Surge配置生成器 2 | 3 | 每次更新 Surge 配置文件,都需要从网上下载网上已有的配置,再手动填写自己对应服务器的配置信息,改了配置有时候还要想办法传回手机,这样非常麻烦,现在有了 Surge 配置生成器,帮你从繁琐的改配置中释放出来。 4 | 5 | 因为涉及到你个人的代理服务(Shadowsock的用户信息)所以最好是部署在你自己的 PHP 空间上。 6 | 7 | 经过测试,在新浪的 SAE 上也可以正常使用(稍后更新更多部署教程)。 8 | 9 | ## 原理 10 | 11 | 使用 PHP 远程下载网上 自动更新的 `surge.conf` 再根据配置文件 `config.php` 中的配置替换相关字段,并返回已经更改好相应字段的配置文件。 12 | 13 | 直接使用 Surge 的 `Download Configuration from URL` 填入部署在你服务器的生成器地址即可方便的更新配置。 14 | 15 | ## 配置 16 | 17 | 复制 `config.sample.php` 到 `config.php`,并根据你实际情况进行修改。 18 | 19 | ```php 20 | $config = array( 21 | // Surge 在线配置文件地址 22 | 'surge' => array( 23 | 'Abclite_ADB' => 'http://abclite.cn/Abclite_ADB.conf', 24 | 'Abclite' => 'http://abclite.cn/Abclite.conf' 25 | ), 26 | // 你的服务器内容 27 | 'server' => array( 28 | 'Abclite1' => array( 29 | // 代理服务器列表 30 | 'proxy' => array( 31 | '🇭🇰HK = custom,abclite.cn,10000,rc4-md5,abclite.cn,http://abclite.cn/SSEncrypt.module', 32 | '🇸🇬SG = custom,abclite.cn,10000,rc4-md5,abclite.cn,http://abclite.cn/SSEncrypt.module', 33 | '🇯🇵JP = custom,abclite.cn,10000,rc4-md5,abclite.cn,http://abclite.cn/SSEncrypt.module', 34 | '🇺🇸US = custom,abclite.cn,10000,rc4-md5,abclite.cn,http://abclite.cn/SSEncrypt.module', 35 | '🇰🇷KR = custom,abclite.cn,10000,rc4-md5,abclite.cn,http://abclite.cn/SSEncrypt.module' 36 | ), 37 | // 请求时的验证密码(防止服务器信息泄露) 38 | 'passwd' => 'myPassword' 39 | ), 40 | ), 41 | ); 42 | ``` 43 | 44 | 其中 `surge` 和 `server` 可以配置多组,根据请求的 GET 参数确定返回哪个配置。 45 | 46 | ## 部署 47 | 48 | 把下载目录中的文件(`index.php`、`parse.php`)以及你修改好的 `config.php` 一起上传到一个支持 PHP 的空间,部署就完成了。 49 | 50 | ## 使用 51 | 52 | 假设你上传到服务器 `server.com` 的 `surge` 目录,配置文件如上所示,那么获取对应配置(`Abclite_ADB`)服务器(`Abclite1`)文件的网址就是: 53 | 54 | http://server.com/surge/?config=Abclite_ADB&account=Abclite1&passwd=myPassword 55 | 56 | 将该网址填入 Surge 的 `Download Configuration from URL` 就完成了。 57 | 58 | > 如果不填写 `config` 和 `account` 会默认加载第一个配置,URL 可以简单写成:http://server.com/surge/?passwd=myPassword 59 | -------------------------------------------------------------------------------- /config.sample.php: -------------------------------------------------------------------------------- 1 | array( 5 | 'Abclite_ADB' => 'http://abclite.cn/Abclite_ADB.conf', 6 | 'Abclite' => 'http://abclite.cn/Abclite.conf' 7 | ), 8 | // 你的服务器内容 9 | 'server' => array( 10 | 'Abclite1' => array( 11 | // 代理服务器列表 12 | 'proxy' => array( 13 | '🇭🇰HK = custom,abclite.cn,10000,rc4-md5,abclite.cn,http://abclite.cn/SSEncrypt.module', 14 | '🇸🇬SG = custom,abclite.cn,10000,rc4-md5,abclite.cn,http://abclite.cn/SSEncrypt.module', 15 | '🇯🇵JP = custom,abclite.cn,10000,rc4-md5,abclite.cn,http://abclite.cn/SSEncrypt.module', 16 | '🇺🇸US = custom,abclite.cn,10000,rc4-md5,abclite.cn,http://abclite.cn/SSEncrypt.module', 17 | '🇰🇷KR = custom,abclite.cn,10000,rc4-md5,abclite.cn,http://abclite.cn/SSEncrypt.module' 18 | ), 19 | // 请求时的验证密码(防止服务器泄露) 20 | 'passwd' => 'myPassword' 21 | ), 22 | ), 23 | ); 24 | ?> -------------------------------------------------------------------------------- /index.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /parse.php: -------------------------------------------------------------------------------- 1 | --------------------------------------------------------------------------------