@@ -3949,7 +3949,8 @@ function getConnectionLink($server_id, $uniqid, $protocol, $remark, $port, $netT
39493949 if ($ netType == 'grpc ' ) {
39503950 if ($ tlsStatus == 'tls ' ){
39513951 $ alpn = $ tlsSetting ->certificates ->alpn ;
3952- if (isset ($ tlsSetting ->settings ->serverName )) $ sni = $ tlsSetting ->settings ->serverName ;
3952+ if (isset ($ tlsSetting ->serverName )) $ sni = $ tlsSetting ->serverName ;
3953+ if (isset ($ tlsSetting ->settings ->serverName )) $ sni = $ tlsSetting ->settings ->serverName ;
39533954 }
39543955 elseif ($ tlsStatus == "reality " ){
39553956 $ realitySettings = json_decode ($ row ->streamSettings )->realitySettings ;
@@ -3965,11 +3966,13 @@ function getConnectionLink($server_id, $uniqid, $protocol, $remark, $port, $netT
39653966 }
39663967 if ($ tlsStatus == 'tls ' ){
39673968 $ serverName = $ tlsSetting ->serverName ;
3969+ if (isset ($ tlsSetting ->serverName )) $ sni = $ tlsSetting ->serverName ;
39683970 if (isset ($ tlsSetting ->settings ->serverName )) $ sni = $ tlsSetting ->settings ->serverName ;
39693971 }
39703972 if ($ tlsStatus == "xtls " ){
39713973 $ serverName = $ xtlsSetting ->serverName ;
39723974 $ alpn = $ xtlsSetting ->alpn ;
3975+ if (isset ($ xtlsSetting ->serverName )) $ sni = $ xtlsSetting ->serverName ;
39733976 if (isset ($ xtlsSetting ->settings ->serverName )) $ sni = $ xtlsSetting ->settings ->serverName ;
39743977 }
39753978 if ($ netType == 'kcp ' ){
@@ -4020,6 +4023,7 @@ function getConnectionLink($server_id, $uniqid, $protocol, $remark, $port, $netT
40204023 }elseif ($ netType == 'grpc ' ) {
40214024 if ($ tlsStatus == 'tls ' ){
40224025 $ alpn = $ tlsSetting ->alpn ;
4026+ if (isset ($ tlsSetting ->serverName )) $ sni = $ tlsSetting ->serverName ;
40234027 if (isset ($ tlsSetting ->settings ->serverName )) $ sni = $ tlsSetting ->settings ->serverName ;
40244028 }
40254029 elseif ($ tlsStatus == "reality " ){
@@ -4039,11 +4043,13 @@ function getConnectionLink($server_id, $uniqid, $protocol, $remark, $port, $netT
40394043 }
40404044 if ($ tlsStatus == 'tls ' ){
40414045 $ serverName = $ tlsSetting ->serverName ;
4046+ if (isset ($ tlsSetting ->serverName )) $ sni = $ tlsSetting ->serverName ;
40424047 if (isset ($ tlsSetting ->settings ->serverName )) $ sni = $ tlsSetting ->settings ->serverName ;
40434048 }
40444049 if ($ tlsStatus == "xtls " ){
40454050 $ serverName = $ xtlsSetting ->serverName ;
40464051 $ alpn = $ xtlsSetting ->alpn ;
4052+ if (isset ($ xtlsSetting ->serverName )) $ sni = $ xtlsSetting ->serverName ;
40474053 if (isset ($ xtlsSetting ->settings ->serverName )) $ sni = $ xtlsSetting ->settings ->serverName ;
40484054 }
40494055
@@ -4192,7 +4198,7 @@ function getConnectionLink($server_id, $uniqid, $protocol, $remark, $port, $netT
41924198 $ outputlink = "$ protocol:// $ uniqid@ $ server_ip: $ port?type= $ netType&security= $ tlsStatus&headerType= $ kcpType&seed= $ kcpSeed# $ remark " ;
41934199 elseif ($ netType == 'grpc ' ){
41944200 if ($ tlsStatus == 'tls ' ){
4195- $ outputlink = "$ protocol:// $ uniqid@ $ server_ip: $ port?type= $ netType&security= $ tlsStatus&serviceName= $ serviceName&sni= $ serverName # $ remark " ;
4201+ $ outputlink = "$ protocol:// $ uniqid@ $ server_ip: $ port?type= $ netType&security= $ tlsStatus&serviceName= $ serviceName&sni= $ sni # $ remark " ;
41964202 }
41974203 elseif ($ tlsStatus =="reality " ){
41984204 $ outputlink = "$ protocol:// $ uniqid@ $ server_ip: $ port?type= $ netType&security= $ tlsStatus&serviceName= $ serviceName&fp= $ fp&pbk= $ pbk&sni= $ sni " . ($ flow != "" ?"&flow= $ flow " :"" ) . "&sid= $ sid&spx= $ spiderX# $ remark " ;
@@ -4287,7 +4293,7 @@ function updateConfig($server_id, $inboundId, $protocol, $netType = 'tcp', $secu
42874293 $ sni = $ server_info ['sni ' ];
42884294 if (!empty ($ sni ) && ($ serverType == "sanaei " || $ serverType == "alireza " )){
42894295 $ tlsSettings = json_decode ($ tlsSettings ,true );
4290- $ tlsSettings ['settings ' ][ ' serverName ' ] = $ sni ;
4296+ $ tlsSettings ['serverName ' ] = $ sni ;
42914297 $ tlsSettings = json_encode ($ tlsSettings ,488 |JSON_UNESCAPED_UNICODE );
42924298 }
42934299
@@ -4383,19 +4389,16 @@ function updateConfig($server_id, $inboundId, $protocol, $netType = 'tcp', $secu
43834389 "network": "grpc",
43844390 "security": "tls",
43854391 "tlsSettings": {
4386- "serverName": " ' . parse_url ($ panel_url , PHP_URL_HOST ) . '",
4392+ "serverName": " ' .
4393+ (!empty ($ sni ) && ($ serverType == "sanaei " || $ serverType == "alireza " ) ? $ sni : parse_url ($ panel_url , PHP_URL_HOST ))
4394+ . '",
43874395 "certificates": [
43884396 {
43894397 "certificateFile": " ' . $ certificateFile . '",
43904398 "keyFile": " ' . $ keyFile . '"
43914399 }
43924400 ],
43934401 "alpn": [] '
4394- .
4395- (!empty ($ sni ) && ($ serverType == "sanaei " || $ serverType == "alireza " ) ? ',
4396- "settings": {
4397- "serverName": " ' . $ sni . '"
4398- } ' :'' )
43994402 .'
44004403 },
44014404 "grpcSettings": {
@@ -4578,7 +4581,7 @@ function editInbound($server_id, $uniqid, $uuid, $protocol, $netType = 'tcp', $s
45784581 $ sni = $ server_info ['sni ' ];
45794582 if (!empty ($ sni ) && ($ serverType == "sanaei " || $ serverType == "alireza " )){
45804583 $ tlsSettings = json_decode ($ tlsSettings ,true );
4581- $ tlsSettings ['settings ' ][ ' serverName ' ] = $ sni ;
4584+ $ tlsSettings ['serverName ' ] = $ sni ;
45824585 $ tlsSettings = json_encode ($ tlsSettings );
45834586 }
45844587
@@ -4745,19 +4748,16 @@ function editInbound($server_id, $uniqid, $uuid, $protocol, $netType = 'tcp', $s
47454748 "network": "grpc",
47464749 "security": "tls",
47474750 "tlsSettings": {
4748- "serverName": " ' . parse_url ($ panel_url , PHP_URL_HOST ) . '",
4751+ "serverName": " ' .
4752+ (!empty ($ sni ) && ($ serverType == "sanaei " || $ serverType == "alireza " ) ? $ sni : parse_url ($ panel_url , PHP_URL_HOST ))
4753+ . '",
47494754 "certificates": [
47504755 {
47514756 "certificateFile": " ' . $ certificateFile . '",
47524757 "keyFile": " ' . $ keyFile . '"
47534758 }
47544759 ],
47554760 "alpn": [] '
4756- .
4757- (!empty ($ sni ) && ($ serverType == "sanaei " || $ serverType == "alireza " ) ? ',
4758- "settings": {
4759- "serverName": " ' . $ sni . '"
4760- } ' :'' )
47614761 .'
47624762 },
47634763 "grpcSettings": {
@@ -5206,7 +5206,7 @@ function addUser($server_id, $client_id, $protocol, $port, $expiryTime, $remark,
52065206
52075207 if (!empty ($ sni ) && ($ serverType == "sanaei " || $ serverType == "alireza " )){
52085208 $ tlsSettings = json_decode ($ tlsSettings ,true );
5209- $ tlsSettings ['settings ' ][ ' serverName ' ] = $ sni ;
5209+ $ tlsSettings ['serverName ' ] = $ sni ;
52105210 $ tlsSettings = json_encode ($ tlsSettings );
52115211 }
52125212
@@ -5360,19 +5360,16 @@ function addUser($server_id, $client_id, $protocol, $port, $expiryTime, $remark,
53605360 "network": "grpc",
53615361 "security": "tls",
53625362 "tlsSettings": {
5363- "serverName": " ' . parse_url ($ panel_url , PHP_URL_HOST ) . '",
5363+ "serverName": " ' .
5364+ (!empty ($ sni ) && ($ serverType == "sanaei " || $ serverType == "alireza " ) ? $ sni : parse_url ($ panel_url , PHP_URL_HOST ))
5365+ . '",
53645366 "certificates": [
53655367 {
53665368 "certificateFile": " ' . $ certificateFile . '",
53675369 "keyFile": " ' . $ keyFile . '"
53685370 }
53695371 ],
53705372 "alpn": [] '
5371- .
5372- (!empty ($ sni ) && ($ serverType == "sanaei " || $ serverType == "alireza " ) ? ',
5373- "settings": {
5374- "serverName": " ' . $ sni . '"
5375- } ' :'' )
53765373 .'
53775374 },
53785375 "grpcSettings": {
0 commit comments