diff --git a/app/Controllers/LinkController.php b/app/Controllers/LinkController.php index 4367dbda..5086f13b 100644 --- a/app/Controllers/LinkController.php +++ b/app/Controllers/LinkController.php @@ -960,6 +960,76 @@ class LinkController extends BaseController return base64_encode($return); } + public static function getSSRPcConf($user) + { + $proxy = []; + $items = array_merge( + URL::getAllItems($user, 0, 0, 0), + URL::getAllItems($user, 1, 0, 0) + ); + foreach ($items as $item) { + $proxy[] = [ + "remarks" => $item['remark'], + "server" => $item['address'], + "server_port" => $item['port'], + "method" => $item['method'], + "obfs" => $item['obfs'], + "obfsparam" => $item['obfs_param'], + "remarks_base64" => base64_encode($item['remark']), + "password" => $item['passwd'], + "tcp_over_udp" => false, + "udp_over_tcp" => false, + "group" => Config::get('appName'), + "protocol" => $item['protocol'], + "protoparam" => $item['protocol_param'], + "obfs_udp" => false, + "enable" => true + ]; + } + $config = [ + 'configs' => $proxy, + 'index' => 0, + 'random' => true, + 'sysProxyMode' => 1, + 'shareOverLan' => false, + 'localPort' => 1080, + 'localAuthPassword' => Tools::genRandomChar(26), + 'dnsServer' => '', + 'reconnectTimes' => 2, + 'balanceAlgorithm' => 'LowException', + 'randomInGroup' => false, + 'TTL' => 0, + 'connectTimeout' => 5, + 'proxyRuleMode' => 2, + 'proxyEnable' => false, + 'pacDirectGoProxy' => false, + 'proxyType' => 0, + 'proxyHost' => '', + 'proxyPort' => 0, + 'proxyAuthUser' => '', + 'proxyAuthPass' => '', + 'proxyUserAgent' => '', + 'authUser' => '', + 'authPass' => '', + 'autoBan' => false, + 'sameHostForSameTarget' => false, + 'keepVisitTime' => 180, + 'isHideTips' => false, + 'nodeFeedAutoUpdate' => true, + 'serverSubscribes' => [ + [ + 'URL' => self::getSubinfo($user, 0)['ssr'], + 'Group' => Config::get('appName'), + 'LastUpdateTime' => 0 + ] + ], + 'token' => [], + 'portMap' => [] + ]; + + return json_encode($config, JSON_PRETTY_PRINT); + } + /** * 通用订阅,ssr & v2rayn * diff --git a/app/Controllers/UserController.php b/app/Controllers/UserController.php index 6c8dc756..0f8ade62 100644 --- a/app/Controllers/UserController.php +++ b/app/Controllers/UserController.php @@ -1918,4 +1918,24 @@ class UserController extends BaseController return $this->view()->assign('logs', $logs)->assign('iplocation', $iplocation)->display('user/subscribe_log.tpl'); } + public function getPcClient($request, $response, $args) + { + $zipArc = new \ZipArchive(); + $user_token = LinkController::GenerateSSRSubCode($this->user->id, 0); + if ($request->getQueryParams()['type'] == 'ssr-win') { + $file = '../storage/ssr_client_' . $user_token . '.zip'; + $zipArc->open($file, \ZipArchive::CREATE); + $zipArc->addFromString ('gui-config.json', LinkController::getSSRPcConf($this->user)); + $zipArc->addGlob('../resources/clients/ssr-win/*', GLOB_BRACE, ['add_path' => '/', 'remove_all_path' => true]); + $zipArc->close(); + $newResponse = $response->withHeader('Content-type', ' application/octet-stream')->withHeader('Content-Disposition', ' attachment; filename=ssr-win.zip'); + $newResponse->getBody()->write(file_get_contents($file)); + unlink($file); + } else { + return 'gg'; + } + + return $newResponse; + } + } diff --git a/config/routes.php b/config/routes.php index 22997cb4..eeedec33 100644 --- a/config/routes.php +++ b/config/routes.php @@ -147,6 +147,9 @@ $app->group('/user', function () { // getUserAllURL $this->get('/getUserAllURL', App\Controllers\UserController::class . ':getUserAllURL'); + // getPcClient + $this->get('/getPcClient', App\Controllers\UserController::class . ':getPcClient'); + //Reconstructed Payment System $this->post('/payment/purchase', App\Services\Payment::class . ':purchase'); $this->get('/payment/return', App\Services\Payment::class . ':returnHTML');