diff --git a/app/Http/Controllers/Server/PoseidonController.php b/app/Http/Controllers/Server/PoseidonController.php index dcd736b3..ee6e678d 100644 --- a/app/Http/Controllers/Server/PoseidonController.php +++ b/app/Http/Controllers/Server/PoseidonController.php @@ -17,6 +17,13 @@ class PoseidonController extends Controller { 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}}}}'; + public $poseidonVersion; + + public function __construct(Request $request) + { + $this->poseidonVersion = $request->input('poseidon_version'); + } + // 后端获取用户 public function user(Request $request) { @@ -100,6 +107,20 @@ class PoseidonController extends Controller $json->poseidon = [ 'license_key' => (string)config('v2board.server_license'), ]; + if ($this->poseidonVersion >= 'v1.5.0') { + // don't need it after v1.5.0 + unset($json->inboundDetour); + unset($json->stats); + unset($json->api); + array_shift($json->routing->rules); + } + + foreach($json->policy->levels as &$level) { + $level->handshake = 2; + $level->uplinkOnly = 2; + $level->downlinkOnly = 2; + $level->connIdle = 60; + } return $this->success($json); } catch (\Exception $e) {