Browse Source

update: remove origin subscribe method

tokumeikoi 3 years ago
parent
commit
dfef6d2d94

+ 3 - 47
app/Http/Controllers/Client/ClientController.php

@@ -7,12 +7,10 @@ use App\Services\ServerService;
 use App\Utils\Clash;
 use App\Utils\QuantumultX;
 use App\Utils\Shadowrocket;
+use App\Utils\Shadowsocks;
 use App\Utils\Surge;
 use App\Utils\Surfboard;
-use App\Utils\URLSchemes;
 use Illuminate\Http\Request;
-use App\Models\Server;
-use App\Utils\Helper;
 use Symfony\Component\Yaml\Yaml;
 use App\Services\UserService;
 
@@ -35,9 +33,6 @@ class ClientController extends Controller
                 if (strpos($flag, 'quantumult%20x') !== false) {
                     die($this->quantumultX($user, $servers));
                 }
-                if (strpos($flag, 'quantumult') !== false) {
-                    die($this->quantumult($user, $servers));
-                }
                 if (strpos($flag, 'clash') !== false) {
                     die($this->clash($user, $servers));
                 }
@@ -54,30 +49,8 @@ class ClientController extends Controller
                     die($this->shaodowsocksSIP008($user, $servers));
                 }
             }
-            die($this->origin($user, $servers));
-        }
-    }
-    // TODO: Ready to stop support
-    private function quantumult($user, $servers = [])
-    {
-        $uri = '';
-        header('subscription-userinfo: upload=' . $user['u'] . '; download=' . $user['d'] . ';total=' . $user['transfer_enable']);
-        foreach ($servers as $item) {
-            if ($item['type'] === 'v2ray') {
-                $str = '';
-                $str .= $item['name'] . '= vmess, ' . $item['host'] . ', ' . $item['port'] . ', chacha20-ietf-poly1305, "' . $user['uuid'] . '", over-tls=' . ($item['tls'] ? "true" : "false") . ', certificate=0, group=' . config('v2board.app_name', 'V2Board');
-                if ($item['network'] === 'ws') {
-                    $str .= ', obfs=ws';
-                    if ($item['networkSettings']) {
-                        $wsSettings = json_decode($item['networkSettings'], true);
-                        if (isset($wsSettings['path'])) $str .= ', obfs-path="' . $wsSettings['path'] . '"';
-                        if (isset($wsSettings['headers']['Host'])) $str .= ', obfs-header="Host:' . $wsSettings['headers']['Host'] . '"';
-                    }
-                }
-                $uri .= "vmess://" . base64_encode($str) . "\r\n";
-            }
+            die('当前客户端不支持获取配置');
         }
-        return base64_encode($uri);
     }
 
     private function shadowrocket($user, $servers = [])
@@ -121,23 +94,6 @@ class ClientController extends Controller
         return base64_encode($uri);
     }
 
-    private function origin($user, $servers = [])
-    {
-        $uri = '';
-        foreach ($servers as $item) {
-            if ($item['type'] === 'shadowsocks') {
-                $uri .= URLSchemes::buildShadowsocks($item, $user);
-            }
-            if ($item['type'] === 'v2ray') {
-                $uri .= URLSchemes::buildVmess($item, $user);
-            }
-            if ($item['type'] === 'trojan') {
-                $uri .= URLSchemes::buildTrojan($item, $user);
-            }
-        }
-        return base64_encode($uri);
-    }
-
     private function shaodowsocksSIP008($user, $servers = [])
     {
         $configs = [];
@@ -151,7 +107,7 @@ class ClientController extends Controller
 
         foreach ($servers as $item) {
             if ($item['type'] === 'shadowsocks') {
-                array_push($configs, URLSchemes::buildShadowsocksSIP008($item, $user));
+                array_push($configs, Shadowsocks::SIP008($item, $user));
             }
         }
 

+ 0 - 5
app/Services/ServerService.php

@@ -8,8 +8,6 @@ use App\Models\User;
 use App\Models\Server;
 use App\Models\ServerTrojan;
 use App\Utils\CacheKey;
-use App\Utils\Helper;
-use App\Utils\URLSchemes;
 use Illuminate\Support\Facades\Cache;
 
 class ServerService
@@ -29,7 +27,6 @@ class ServerService
             $v2ray[$i]['type'] = 'v2ray';
             $groupId = json_decode($v2ray[$i]['group_id']);
             if (in_array($user->group_id, $groupId)) {
-                $v2ray[$i]['link'] = URLSchemes::buildVmess($v2ray[$i], $user);
                 if ($v2ray[$i]['parent_id']) {
                     $v2ray[$i]['last_check_at'] = Cache::get(CacheKey::get('SERVER_V2RAY_LAST_CHECK_AT', $v2ray[$i]['parent_id']));
                 } else {
@@ -54,7 +51,6 @@ class ServerService
         for ($i = 0; $i < count($trojan); $i++) {
             $trojan[$i]['type'] = 'trojan';
             $groupId = json_decode($trojan[$i]['group_id']);
-            $trojan[$i]['link'] = URLSchemes::buildTrojan($trojan[$i], $user);
             if (in_array($user->group_id, $groupId)) {
                 if ($trojan[$i]['parent_id']) {
                     $trojan[$i]['last_check_at'] = Cache::get(CacheKey::get('SERVER_TROJAN_LAST_CHECK_AT', $trojan[$i]['parent_id']));
@@ -78,7 +74,6 @@ class ServerService
         for ($i = 0; $i < count($shadowsocks); $i++) {
             $shadowsocks[$i]['type'] = 'shadowsocks';
             $groupId = json_decode($shadowsocks[$i]['group_id']);
-            $shadowsocks[$i]['link'] = URLSchemes::buildShadowsocks($shadowsocks[$i], $user);
             if (in_array($user->group_id, $groupId)) {
                 if ($shadowsocks[$i]['parent_id']) {
                     $shadowsocks[$i]['last_check_at'] = Cache::get(CacheKey::get('SERVER_SHADOWSOCKS_LAST_CHECK_AT', $shadowsocks[$i]['parent_id']));

+ 20 - 0
app/Utils/Shadowsocks.php

@@ -0,0 +1,20 @@
+<?php
+namespace App\Utils;
+
+use App\Models\User;
+
+class Shadowsocks
+{
+    public static function SIP008($server, User $user)
+    {
+        $config = [
+            "id" => $server['id'],
+            "remarks" => $server['name'],
+            "server" => $server['host'],
+            "server_port" => $server['port'],
+            "password" => $user['uuid'],
+            "method" => $server['cipher']
+        ];
+        return $config;
+    }
+}

+ 0 - 68
app/Utils/URLSchemes.php

@@ -1,68 +0,0 @@
-<?php
-namespace App\Utils;
-
-use App\Models\Server;
-use App\Models\User;
-
-class URLSchemes
-{
-    public static function buildShadowsocks($server, User $user)
-    {
-        $name = rawurlencode($server['name']);
-        $str = str_replace(
-            ['+', '/', '='],
-            ['-', '_', ''],
-            base64_encode("{$server['cipher']}:{$user['uuid']}")
-        );
-        return "ss://{$str}@{$server['host']}:{$server['port']}#{$name}\r\n";
-    }
-
-    public static function buildShadowsocksSIP008($server, User $user)
-    {
-        $config = [
-            "id" => $server['id'],
-            "remarks" => $server['name'],
-            "server" => $server['host'],
-            "server_port" => $server['port'],
-            "password" => $user['uuid'],
-            "method" => $server['cipher']
-        ];
-        return $config;
-    }
-
-    public static function buildVmess($server, User $user)
-    {
-        $config = [
-            "v" => "2",
-            "ps" => $server['name'],
-            "add" => $server['host'],
-            "port" => (string)$server['port'],
-            "id" => $user['uuid'],
-            "aid" => (string)$server['alter_id'],
-            "net" => $server['network'],
-            "type" => "none",
-            "host" => "",
-            "path" => "",
-            "tls" => $server['tls'] ? "tls" : ""
-        ];
-        if ((string)$server['network'] === 'ws') {
-            $wsSettings = json_decode($server['networkSettings'], true);
-            if (isset($wsSettings['path'])) $config['path'] = $wsSettings['path'];
-            if (isset($wsSettings['headers']['Host'])) $config['host'] = $wsSettings['headers']['Host'];
-        }
-        return "vmess://" . base64_encode(json_encode($config)) . "\r\n";
-    }
-
-    public static function buildTrojan($server, User $user)
-    {
-        $name = rawurlencode($server['name']);
-        $query = http_build_query([
-            'allowInsecure' => $server['allow_insecure'],
-            'peer' => $server['server_name'],
-            'sni' => $server['server_name']
-        ]);
-        $uri = "trojan://{$user['uuid']}@{$server['host']}:{$server['port']}?{$query}#{$name}";
-        $uri .= "\r\n";
-        return $uri;
-    }
-}

File diff suppressed because it is too large
+ 0 - 0
public/assets/user/umi.js


Some files were not shown because too many files changed in this diff