diff --git a/app/Http/Controllers/Admin/ServerController.php b/app/Http/Controllers/Admin/ServerController.php index ce40cc11..44cc01a8 100755 --- a/app/Http/Controllers/Admin/ServerController.php +++ b/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, '审计规则配置格式不正确'); diff --git a/app/Http/Requests/Admin/ServerSave.php b/app/Http/Requests/Admin/ServerSave.php index ff472c28..364b5693 100755 --- a/app/Http/Requests/Admin/ServerSave.php +++ b/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. diff --git a/app/Services/ServerService.php b/app/Services/ServerService.php index bcad9710..1a2df554 100644 --- a/app/Services/ServerService.php +++ b/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); } }