diff --git a/app/Command/Job.php b/app/Command/Job.php index b83a6d2a..bd16eb92 100644 --- a/app/Command/Job.php +++ b/app/Command/Job.php @@ -32,6 +32,7 @@ use App\Utils\Telegram; use ArrayObject; use App\Models\Disconnect; use App\Models\GConfig; +use App\Models\Token; use App\Models\UnblockIp; use Exception; use RuntimeException; @@ -154,6 +155,8 @@ class Job // 清理订阅记录 UserSubscribeLog::where('request_time', '<', date('Y-m-d H:i:s', time() - 86400 * (int) Config::get('subscribeLog_keep_days')))->delete(); + Token::where('expire_time', '<', time())->delete(); + NodeInfoLog::where('log_time', '<', time() - 86400 * 3)->delete(); NodeOnlineLog::where('log_time', '<', time() - 86400 * 3)->delete(); TrafficLog::where('log_time', '<', time() - 86400 * 3)->delete(); diff --git a/app/Controllers/LinkController.php b/app/Controllers/LinkController.php index d253bd63..d59a56bd 100644 --- a/app/Controllers/LinkController.php +++ b/app/Controllers/LinkController.php @@ -1331,6 +1331,112 @@ class LinkController extends BaseController return json_encode($config, JSON_PRETTY_PRINT); } + public static function getV2RayPcNConf($user) + { + $subUrl = self::getSubinfo($user, 0)['v2ray']; + $subId = Uuid::uuid3(Uuid::NAMESPACE_DNS, $subUrl)->toString(); + $config = [ + 'inbound' => [ + [ + 'localPort' => 10808, + 'protocol' => 'socks', + 'udpEnabled' => true, + 'sniffingEnabled' => true, + ], + ], + 'logEnabled' => false, + 'loglevel' => 'warning', + 'index' => 0, + 'vmess' => [], + 'muxEnabled' => false, + 'domainStrategy' => 'IPIfNonMatch', + 'routingMode' => '3', + 'useragent' => [], + 'userdirect' => [], + 'userblock' => [], + 'kcpItem' => [ + 'mtu' => 1350, + 'tti' => 50, + 'uplinkCapacity' => 12, + 'downlinkCapacity' => 100, + 'congestion' => false, + 'readBufferSize' => 2, + 'writeBufferSize' => 2, + ], + 'listenerType' => 0, + 'urlGFWList' => 'https://raw.githubusercontent.com/gfwlist/gfwlist/master/gfwlist.txt', + 'allowLANConn' => false, + 'enableStatistics' => true, + 'statisticsFreshRate' => 2000, + 'remoteDNS' => '114.114.114.114,1.2.4.8,223.5.5.5,8,8,8,8', + 'subItem' => [ + [ + 'id' => $subId, + 'remarks' => $_ENV['appName'], + 'url' => $subUrl, + 'enabled' => true, + ], + ], + 'uiItem' => [ + 'mainQRCodeWidth' => 600, + ], + 'userPacRule' => [] + ]; + $Rule = [ + 'type' => 'vmess', + 'is_mu' => ($_ENV['mergeSub'] === true ? 1 : 0), + 'emoji' => $_ENV['add_emoji_to_node_name'], + 'extend' => $_ENV['enable_sub_extend'], + ]; + $proxys = []; + $items = URL::getNew_AllItems($user, $Rule); + foreach ($items as $item) { + if (!in_array($item['net'], ['tcp', 'ws', 'kcp', 'h2'])) { + continue; + } + $proxy = [ + 'configVersion' => 2, + 'address' => $item['add'], + 'port' => $item['port'], + 'id' => $item['id'], + 'alterId' => $item['aid'], + 'security' => 'auto', + 'network' => $item['net'], + 'remarks' => $item['remark'], + 'headerType' => 'none', + 'requestHost' => '', + 'path' => '', + 'streamSecurity' => '', + 'allowInsecure' => '', + 'configType' => 1, + 'testResult' => '', + 'subid' => $subId, + ]; + switch ($item['net']) { + case 'h2': + $proxy['requestHost'] = ($item['host'] != '' ? $item['host'] : $item['add']); + $proxy['path'] = $item['path']; + break; + case 'ws': + $proxy['requestHost'] = ($item['host'] != '' ? $item['host'] : $item['add']); + $proxy['path'] = $item['path']; + break; + case 'kcp': + $proxy['headerType'] = $item['type']; + break; + } + if ($item['tls'] == 'tls') { + $proxy['streamSecurity'] = $item['tls']; + if ($item['verify_cert'] == false){ + $proxy['allowInsecure'] = 'true'; + } + } + $proxys[] = $proxy; + } + $config['vmess'] = $proxys; + return json_encode($config, JSON_PRETTY_PRINT); + } + /** * 通用订阅,ssr & v2rayn * diff --git a/app/Controllers/UserController.php b/app/Controllers/UserController.php index 997af7a1..431dca96 100644 --- a/app/Controllers/UserController.php +++ b/app/Controllers/UserController.php @@ -37,6 +37,7 @@ use App\Models\BlockIp; use App\Models\UnblockIp; use App\Models\Payback; use App\Models\Relay; +use App\Models\Token; use App\Models\UserSubscribeLog; use App\Utils\QQWry; use App\Utils\GA; @@ -73,9 +74,28 @@ class UserController extends BaseController $Ann = Ann::orderBy('date', 'desc')->first(); + if ($_ENV['subscribe_client_url'] != '') { + $getClient = new Token(); + for ($i = 0; $i < 10; $i++) { + $token = $this->user->id . Tools::genRandomChar(16); + $Elink = Token::where('token', '=', $token)->first(); + if ($Elink == null) { + $getClient->token = $token; + break; + } + } + $getClient->user_id = $this->user->id; + $getClient->create_time = time(); + $getClient->expire_time = time() + 10 * 60; + $getClient->save(); + } else { + $token = ''; + } + return $this->view() ->assign('subInfo', LinkController::getSubinfo($this->user, 0)) ->assign('ssr_sub_token', $ssr_sub_token) + ->assign('getClient', $token) ->assign('display_ios_class', Config::get('display_ios_class')) ->assign('display_ios_topup', Config::get('display_ios_topup')) ->assign('ios_account', Config::get('ios_account')) @@ -1886,6 +1906,12 @@ class UserController extends BaseController $content = LinkController::getSSRPcConf($this->user); $client_path .= $type . '/'; break; + case 'v2rayn-win': + $temp_file_path .= $type . '_' . $user_token . '.zip'; + $user_config_file_name = 'guiNConfig.json'; + $content = LinkController::getV2RayPcNConf($this->user); + $client_path .= $type . '/'; + break; default: return 'gg'; } @@ -1909,6 +1935,21 @@ class UserController extends BaseController return $newResponse; } + public function getClientfromToken($request, $response, $args) + { + $token = $args['token']; + $Etoken = Token::where('token', '=', $token)->where('create_time', '>', time() - 60 * 10)->first(); + if ($Etoken == null) { + return '下载链接已失效,请刷新页面后重新点击.'; + } + $user = User::find($Etoken->user_id); + if ($user == null) { + return null; + } + $this->user = $user; + return self::getPcClient($request, $response, $args); + } + /** * 清理订阅缓存 * diff --git a/app/Services/Config.php b/app/Services/Config.php index cc2a0b57..6ea36d4d 100644 --- a/app/Services/Config.php +++ b/app/Services/Config.php @@ -67,6 +67,7 @@ class Config 'subscribe_client' => self::get('subscribe_client'), 'enable_sub_cache' => self::get('enable_sub_cache'), 'use_new_telegram_bot' => self::get('use_new_telegram_bot'), + 'subscribe_client_url' => self::get('subscribe_client_url'), ]; } diff --git a/config/.config.example.php b/config/.config.example.php index 8115479e..d557312d 100644 --- a/config/.config.example.php +++ b/config/.config.example.php @@ -378,6 +378,7 @@ $_ENV['db_collation'] = 'utf8_general_ci'; $_ENV['db_prefix'] = ''; $_ENV['muKeyList'] = []; //多 key 列表 $_ENV['subscribe_client'] = false; //下载协议客户端时附带节点和订阅信息 +$_ENV['subscribe_client_url'] = ''; //使用独立的服务器提供附带节点和订阅信息的协议客户端下载,为空表示不使用 $_ENV['mu_port_migration'] = false; //为后端直接下发偏移后的端口 $_ENV['relay_port_migration'] = false; //为中转规则下发偏移后的端口,此项未经测试 diff --git a/config/routes.php b/config/routes.php index 299a066f..87bea3de 100644 --- a/config/routes.php +++ b/config/routes.php @@ -369,6 +369,9 @@ $app->group('/res', function () { $this->get('/captcha/{id}', App\Controllers\ResController::class . ':captcha'); }); +$app->group('/getClient', function () { + $this->get('/{token}', App\Controllers\UserController::class . ':getClientfromToken'); +}); $app->group('/link', function () { $this->get('/{token}', App\Controllers\LinkController::class . ':GetContent'); diff --git a/resources/clients/v2rayn-win/使用注意.txt b/resources/clients/v2rayn-win/使用注意.txt new file mode 100644 index 00000000..8574e0ed --- /dev/null +++ b/resources/clients/v2rayn-win/使用注意.txt @@ -0,0 +1,3 @@ +尊敬的用户您好: + + 如您在使用上遇到问题,请注意在我们的网站上查询相关的教程或联系我们。 diff --git a/resources/views/material/user/index.tpl b/resources/views/material/user/index.tpl index 98a609dc..10a70374 100644 --- a/resources/views/material/user/index.tpl +++ b/resources/views/material/user/index.tpl @@ -411,23 +411,27 @@ table tr td:first-child {
-

filter_1 save_alt 下载 SS - [ SS ]:

+

filter_1 save_alt 下载 SS - [ SS ]:

教程文档:how_to_vote点击查看

使用方式:how_to_vote全部 URL


-

filter_2 save_alt 下载 SSD - [ SS ]:

+

filter_2 save_alt 下载 SSD - [ SS ]:

教程文档:how_to_vote点击查看

使用方式:how_to_vote拷贝链接.how_to_vote全部 URL


-

filter_3 save_alt 下载 SSR(R) - [ SS/SSR ]:

+

filter_3 save_alt 下载 SSR(R) - [ SS/SSR ]:

教程文档:how_to_vote点击查看

使用方式:how_to_vote订阅链接.how_to_vote全部 URL


-

filter_4 save_alt 下载 Clash for Windows - [ SS/VMess ]:

+

filter_4 save_alt 下载 V2RayN - [ SS/VMess ]:

+

教程文档:how_to_vote点击查看

+

使用方式:how_to_vote订阅链接.how_to_vote全部 URL

+
+

filter_5 save_alt 下载 Clash for Windows - [ SS/VMess ]:

教程文档:how_to_vote点击查看

使用方式:how_to_vote配置下载.how_to_voteClash for Windows 一键导入


-

filter_5 save_alt 下载 ClashR for Windows - [ SS/SSR/VMess ]:

+

filter_6 save_alt 下载 ClashR for Windows - [ SS/SSR/VMess ]:

教程文档:自行摸索

使用方式:how_to_vote配置下载.how_to_voteClashR for Windows 一键导入