Browse Source

update: v2ray config

tokumeikoi 3 years ago
parent
commit
9b21cca314

+ 0 - 4
app/Http/Controllers/Client/AppController.php

@@ -13,10 +13,6 @@ use Symfony\Component\Yaml\Yaml;
 
 class AppController extends Controller
 {
-    CONST CLIENT_CONFIG = '{"policy":{"levels":{"0":{"uplinkOnly":0}}},"dns":{"servers":["114.114.114.114","8.8.8.8"]},"outboundDetour":[{"protocol":"freedom","tag":"direct","settings":{}}],"inbound":{"listen":"0.0.0.0","port":31211,"protocol":"socks","settings":{"auth":"noauth","udp":true,"ip":"127.0.0.1"}},"inboundDetour":[{"listen":"0.0.0.0","allocate":{"strategy":"always","refresh":5,"concurrency":3},"port":31210,"protocol":"http","tag":"httpDetour","domainOverride":["http","tls"],"streamSettings":{},"settings":{"timeout":0}}],"routing":{"strategy":"rules","settings":{"domainStrategy":"IPIfNonMatch","rules":[{"type":"field","ip":["geoip:cn"],"outboundTag":"direct"},{"type":"field","ip":["0.0.0.0/8","10.0.0.0/8","100.64.0.0/10","127.0.0.0/8","169.254.0.0/16","172.16.0.0/12","192.0.0.0/24","192.0.2.0/24","192.168.0.0/16","198.18.0.0/15","198.51.100.0/24","203.0.113.0/24","::1/128","fc00::/7","fe80::/10"],"outboundTag":"direct"}]}},"outbound":{"tag":"proxy","sendThrough":"0.0.0.0","mux":{"enabled":false,"concurrency":8},"protocol":"vmess","settings":{"vnext":[{"address":"server","port":443,"users":[{"id":"uuid","alterId":2,"security":"auto","level":0}],"remark":"remark"}]},"streamSettings":{"network":"tcp","tcpSettings":{"header":{"type":"none"}},"security":"none","tlsSettings":{"allowInsecure":true,"allowInsecureCiphers":true},"kcpSettings":{"header":{"type":"none"},"mtu":1350,"congestion":false,"tti":20,"uplinkCapacity":5,"writeBufferSize":1,"readBufferSize":1,"downlinkCapacity":20},"wsSettings":{"path":"","headers":{"Host":"server.cc"}}}}}';
-    CONST SOCKS_PORT = 10010;
-    CONST HTTP_PORT = 10011;
-
     public function getConfig(Request $request)
     {
         $servers = [];

+ 18 - 18
app/Services/ServerService.php

@@ -13,7 +13,7 @@ use Illuminate\Support\Facades\Cache;
 class ServerService
 {
 
-    CONST V2RAY_CONFIG = '{"api":{"services":["HandlerService","StatsService"],"tag":"api"},"dns":{},"stats":{},"inbound":{"port":443,"protocol":"vmess","settings":{"clients":[]},"sniffing":{"enabled":true,"destOverride":["http","tls"]},"streamSettings":{"network":"tcp"},"tag":"proxy"},"inboundDetour":[{"listen":"127.0.0.1","port":23333,"protocol":"dokodemo-door","settings":{"address":"0.0.0.0"},"tag":"api"}],"log":{"loglevel":"debug","access":"access.log","error":"error.log"},"outbound":{"protocol":"freedom","settings":{}},"outboundDetour":[{"protocol":"blackhole","settings":{},"tag":"block"}],"routing":{"rules":[{"inboundTag":"api","outboundTag":"api","type":"field"}]},"policy":{"levels":{"0":{"handshake":4,"connIdle":300,"uplinkOnly":5,"downlinkOnly":30,"statsUserUplink":true,"statsUserDownlink":true}}}}';
+    CONST V2RAY_CONFIG = '{"api":{"services":["HandlerService","StatsService"],"tag":"api"},"dns":{},"stats":{},"inbounds":[{"port":443,"protocol":"vmess","settings":{"clients":[]},"sniffing":{"enabled":true,"destOverride":["http","tls"]},"streamSettings":{"network":"tcp"},"tag":"proxy"},{"listen":"127.0.0.1","port":23333,"protocol":"dokodemo-door","settings":{"address":"0.0.0.0"},"tag":"api"}],"log":{"loglevel":"debug","access":"access.log","error":"error.log"},"outbounds":[{"protocol":"freedom","settings":{}},{"protocol":"blackhole","settings":{},"tag":"block"}],"routing":{"rules":[{"inboundTag":"api","outboundTag":"api","type":"field"}]},"policy":{"levels":{"0":{"handshake":4,"connIdle":300,"uplinkOnly":5,"downlinkOnly":30,"statsUserUplink":true,"statsUserDownlink":true}}}}';
     CONST TROJAN_CONFIG = '{"run_type":"server","local_addr":"0.0.0.0","local_port":443,"remote_addr":"www.taobao.com","remote_port":80,"password":[],"ssl":{"cert":"server.crt","key":"server.key","sni":"domain.com"},"api":{"enabled":true,"api_addr":"127.0.0.1","api_port":10000}}';
     public function getV2ray(User $user, $all = false):array
     {
@@ -129,9 +129,9 @@ class ServerService
         }
         $json = json_decode(self::V2RAY_CONFIG);
         $json->log->loglevel = (int)config('v2board.server_log_enable') ? 'debug' : 'none';
-        $json->inboundDetour[0]->port = (int)$localPort;
-        $json->inbound->port = (int)$server->server_port;
-        $json->inbound->streamSettings->network = $server->network;
+        $json->inbounds[1]->port = (int)$localPort;
+        $json->inbounds[0]->port = (int)$server->server_port;
+        $json->inbounds[0]->streamSettings->network = $server->network;
         $this->setDns($server, $json);
         $this->setNetwork($server, $json);
         $this->setRule($server, $json);
@@ -165,7 +165,7 @@ class ServerService
                 array_push($dns->servers, 'localhost');
             }
             $json->dns = $dns;
-            $json->outbound->settings->domainStrategy = 'UseIP';
+            $json->outbound[0]->settings->domainStrategy = 'UseIP';
         }
     }
 
@@ -174,25 +174,25 @@ class ServerService
         if ($server->networkSettings) {
             switch ($server->network) {
                 case 'tcp':
-                    $json->inbound->streamSettings->tcpSettings = $server->networkSettings;
+                    $json->inbound[0]->streamSettings->tcpSettings = $server->networkSettings;
                     break;
                 case 'kcp':
-                    $json->inbound->streamSettings->kcpSettings = $server->networkSettings;
+                    $json->inbound[0]->streamSettings->kcpSettings = $server->networkSettings;
                     break;
                 case 'ws':
-                    $json->inbound->streamSettings->wsSettings = $server->networkSettings;
+                    $json->inbound[0]->streamSettings->wsSettings = $server->networkSettings;
                     break;
                 case 'http':
-                    $json->inbound->streamSettings->httpSettings = $server->networkSettings;
+                    $json->inbound[0]->streamSettings->httpSettings = $server->networkSettings;
                     break;
                 case 'domainsocket':
-                    $json->inbound->streamSettings->dsSettings = $server->networkSettings;
+                    $json->inbound[0]->streamSettings->dsSettings = $server->networkSettings;
                     break;
                 case 'quic':
-                    $json->inbound->streamSettings->quicSettings = $server->networkSettings;
+                    $json->inbound[0]->streamSettings->quicSettings = $server->networkSettings;
                     break;
                 case 'grpc':
-                    $json->inbound->streamSettings->grpcSettings = $server->networkSettings;
+                    $json->inbound[0]->streamSettings->grpcSettings = $server->networkSettings;
                     break;
             }
         }
@@ -234,7 +234,7 @@ class ServerService
             array_push($json->routing->rules, $protocolObj);
         }
         if (empty($domainRules) && empty($protocolRules)) {
-            $json->inbound->sniffing->enabled = false;
+            $json->inbounds[0]->sniffing->enabled = false;
         }
     }
 
@@ -242,19 +242,19 @@ class ServerService
     {
         if ((int)$server->tls) {
             $tlsSettings = $server->tlsSettings;
-            $json->inbound->streamSettings->security = 'tls';
+            $json->inbound[0]->streamSettings->security = 'tls';
             $tls = (object)[
                 'certificateFile' => '/root/.cert/server.crt',
                 'keyFile' => '/root/.cert/server.key'
             ];
-            $json->inbound->streamSettings->tlsSettings = new \StdClass();
+            $json->inbound[0]->streamSettings->tlsSettings = new \StdClass();
             if (isset($tlsSettings->serverName)) {
-                $json->inbound->streamSettings->tlsSettings->serverName = (string)$tlsSettings->serverName;
+                $json->inbound[0]->streamSettings->tlsSettings->serverName = (string)$tlsSettings->serverName;
             }
             if (isset($tlsSettings->allowInsecure)) {
-                $json->inbound->streamSettings->tlsSettings->allowInsecure = (int)$tlsSettings->allowInsecure ? true : false;
+                $json->inbound[0]->streamSettings->tlsSettings->allowInsecure = (int)$tlsSettings->allowInsecure ? true : false;
             }
-            $json->inbound->streamSettings->tlsSettings->certificates[0] = $tls;
+            $json->inbound[0]->streamSettings->tlsSettings->certificates[0] = $tls;
         }
     }
 

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


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