Tokumeikoi 5 years ago
parent
commit
dfdf995ddb

+ 6 - 0
app/Http/Controllers/Admin/ServerController.php

@@ -42,6 +42,12 @@ class ServerController extends Controller
             $params['tags'] = json_encode($params['tags']);
         }
 
+        if (isset($params['dnsSettings'])) {
+            if (!is_object(json_decode($params['dnsSettings']))) {
+                abort(500, 'DNS规则配置格式不正确');
+            }
+        }
+
         if (isset($params['ruleSettings'])) {
             if (!is_object(json_decode($params['ruleSettings']))) {
                 abort(500, '审计规则配置格式不正确');

+ 2 - 1
app/Http/Requests/Admin/ServerSave.php

@@ -20,7 +20,8 @@ class ServerSave extends FormRequest
         'network' => 'required|in:tcp,kcp,ws,http,domainsocket,quic',
         'networkSettings' => '',
         'ruleSettings' => '',
-        'tlsSettings' => ''
+        'tlsSettings' => '',
+        'dnsSettings' => ''
     ];
     /**
      * Get the validation rules that apply to the request.

+ 2 - 1
app/Services/ServerService.php

@@ -8,7 +8,7 @@ use App\Models\Server;
 class ServerService
 {
 
-    CONST SERVER_CONFIG = '{"api":{"services":["HandlerService","StatsService"],"tag":"api"},"stats":{},"inbound":{"port":443,"protocol":"vmess","settings":{"clients":[]},"sniffing":{"enabled": true,"destOverride": ["http","tls"]},"streamSettings":{"network":"tcp"},"tag":"proxy"},"inboundDetour":[{"listen":"0.0.0.0","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 SERVER_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":"0.0.0.0","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}}}}';
 
     public function getAvailableUsers($groupId)
     {
@@ -53,6 +53,7 @@ class ServerService
     private function setDns(Server $server, object $json)
     {
         if ($server->dnsSettings) {
+            $dns = json_decode($server->dnsSettings);
 
         }
     }