mirror of
https://github.com/lkddi/Xboard.git
synced 2026-04-03 18:40:52 +08:00
Merge pull request #832 from Dlphine/fix/raw-array-access-data-get
fix: replace raw array access with data_get() to prevent Undefined array key
This commit is contained in:
@@ -61,7 +61,7 @@ class General extends AbstractProtocol
|
|||||||
$str = str_replace(
|
$str = str_replace(
|
||||||
['+', '/', '='],
|
['+', '/', '='],
|
||||||
['-', '_', ''],
|
['-', '_', ''],
|
||||||
base64_encode("{$protocol_settings['cipher']}:{$password}")
|
base64_encode(data_get($protocol_settings, 'cipher') . ":{$password}")
|
||||||
);
|
);
|
||||||
$addr = Helper::wrapIPv6($server['host']);
|
$addr = Helper::wrapIPv6($server['host']);
|
||||||
$plugin = data_get($protocol_settings, 'plugin');
|
$plugin = data_get($protocol_settings, 'plugin');
|
||||||
@@ -84,11 +84,11 @@ class General extends AbstractProtocol
|
|||||||
"port" => (string) $server['port'],
|
"port" => (string) $server['port'],
|
||||||
"id" => $uuid,
|
"id" => $uuid,
|
||||||
"aid" => '0',
|
"aid" => '0',
|
||||||
"net" => $server['protocol_settings']['network'],
|
"net" => data_get($server, 'protocol_settings.network'),
|
||||||
"type" => "none",
|
"type" => "none",
|
||||||
"host" => "",
|
"host" => "",
|
||||||
"path" => "",
|
"path" => "",
|
||||||
"tls" => $protocol_settings['tls'] ? "tls" : "",
|
"tls" => data_get($protocol_settings, 'tls') ? "tls" : "",
|
||||||
];
|
];
|
||||||
if ($serverName = data_get($protocol_settings, 'tls_settings.server_name')) {
|
if ($serverName = data_get($protocol_settings, 'tls_settings.server_name')) {
|
||||||
$config['sni'] = $serverName;
|
$config['sni'] = $serverName;
|
||||||
@@ -97,7 +97,7 @@ class General extends AbstractProtocol
|
|||||||
$config['fp'] = $fp;
|
$config['fp'] = $fp;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch ($protocol_settings['network']) {
|
switch (data_get($protocol_settings, 'network')) {
|
||||||
case 'tcp':
|
case 'tcp':
|
||||||
if (data_get($protocol_settings, 'network_settings.header.type', 'none') !== 'none') {
|
if (data_get($protocol_settings, 'network_settings.header.type', 'none') !== 'none') {
|
||||||
$config['type'] = data_get($protocol_settings, 'network_settings.header.type', 'http');
|
$config['type'] = data_get($protocol_settings, 'network_settings.header.type', 'http');
|
||||||
@@ -152,11 +152,11 @@ class General extends AbstractProtocol
|
|||||||
'mode' => 'multi', //grpc传输模式
|
'mode' => 'multi', //grpc传输模式
|
||||||
'security' => '', //传输层安全 tls/reality
|
'security' => '', //传输层安全 tls/reality
|
||||||
'encryption' => 'none', //加密方式
|
'encryption' => 'none', //加密方式
|
||||||
'type' => $server['protocol_settings']['network'], //传输协议
|
'type' => data_get($server, 'protocol_settings.network'), //传输协议
|
||||||
'flow' => data_get($protocol_settings, 'flow'),
|
'flow' => data_get($protocol_settings, 'flow'),
|
||||||
];
|
];
|
||||||
// 处理TLS
|
// 处理TLS
|
||||||
switch ($server['protocol_settings']['tls']) {
|
switch (data_get($server, 'protocol_settings.tls')) {
|
||||||
case 1:
|
case 1:
|
||||||
$config['security'] = "tls";
|
$config['security'] = "tls";
|
||||||
if ($fp = Helper::getTlsFingerprint(data_get($protocol_settings, 'utls'))) {
|
if ($fp = Helper::getTlsFingerprint(data_get($protocol_settings, 'utls'))) {
|
||||||
@@ -184,7 +184,7 @@ class General extends AbstractProtocol
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// 处理传输协议
|
// 处理传输协议
|
||||||
switch ($server['protocol_settings']['network']) {
|
switch (data_get($server, 'protocol_settings.network')) {
|
||||||
case 'ws':
|
case 'ws':
|
||||||
if ($path = data_get($protocol_settings, 'network_settings.path'))
|
if ($path = data_get($protocol_settings, 'network_settings.path'))
|
||||||
$config['path'] = $path;
|
$config['path'] = $path;
|
||||||
@@ -256,7 +256,7 @@ class General extends AbstractProtocol
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch ($server['protocol_settings']['network']) {
|
switch (data_get($server, 'protocol_settings.network')) {
|
||||||
case 'ws':
|
case 'ws':
|
||||||
$array['type'] = 'ws';
|
$array['type'] = 'ws';
|
||||||
if ($path = data_get($protocol_settings, 'network_settings.path'))
|
if ($path = data_get($protocol_settings, 'network_settings.path'))
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ class QuantumultX extends AbstractProtocol
|
|||||||
$addr = Helper::wrapIPv6($server['host']);
|
$addr = Helper::wrapIPv6($server['host']);
|
||||||
$config = [
|
$config = [
|
||||||
"shadowsocks={$addr}:{$server['port']}",
|
"shadowsocks={$addr}:{$server['port']}",
|
||||||
"method={$protocol_settings['cipher']}",
|
"method=" . data_get($protocol_settings, 'cipher'),
|
||||||
"password={$password}",
|
"password={$password}",
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ class Shadowrocket extends AbstractProtocol
|
|||||||
$str = str_replace(
|
$str = str_replace(
|
||||||
['+', '/', '='],
|
['+', '/', '='],
|
||||||
['-', '_', ''],
|
['-', '_', ''],
|
||||||
base64_encode("{$protocol_settings['cipher']}:{$password}")
|
base64_encode(data_get($protocol_settings, 'cipher') . ":{$password}")
|
||||||
);
|
);
|
||||||
$addr = Helper::wrapIPv6($server['host']);
|
$addr = Helper::wrapIPv6($server['host']);
|
||||||
|
|
||||||
@@ -98,7 +98,7 @@ class Shadowrocket extends AbstractProtocol
|
|||||||
'remark' => $server['name'],
|
'remark' => $server['name'],
|
||||||
'alterId' => 0
|
'alterId' => 0
|
||||||
];
|
];
|
||||||
if ($protocol_settings['tls']) {
|
if (data_get($protocol_settings, 'tls')) {
|
||||||
$config['tls'] = 1;
|
$config['tls'] = 1;
|
||||||
if (data_get($protocol_settings, 'tls_settings')) {
|
if (data_get($protocol_settings, 'tls_settings')) {
|
||||||
if (!!data_get($protocol_settings, 'tls_settings.allow_insecure'))
|
if (!!data_get($protocol_settings, 'tls_settings.allow_insecure'))
|
||||||
@@ -352,7 +352,7 @@ class Shadowrocket extends AbstractProtocol
|
|||||||
}
|
}
|
||||||
$params['insecure'] = data_get($protocol_settings, 'tls.allow_insecure');
|
$params['insecure'] = data_get($protocol_settings, 'tls.allow_insecure');
|
||||||
if (isset($protocol_settings['hop_interval'])) {
|
if (isset($protocol_settings['hop_interval'])) {
|
||||||
$params['keepalive'] = $protocol_settings['hop_interval'];
|
$params['keepalive'] = data_get($protocol_settings, 'hop_interval');
|
||||||
}
|
}
|
||||||
if (isset($server['ports'])) {
|
if (isset($server['ports'])) {
|
||||||
$params['mport'] = $server['ports'];
|
$params['mport'] = $server['ports'];
|
||||||
|
|||||||
@@ -434,8 +434,8 @@ class SingBox extends AbstractProtocol
|
|||||||
$array['flow'] = $flow;
|
$array['flow'] = $flow;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($protocol_settings['tls']) {
|
if (data_get($protocol_settings, 'tls')) {
|
||||||
$tlsMode = (int) $protocol_settings['tls'];
|
$tlsMode = (int) data_get($protocol_settings, 'tls', 0);
|
||||||
$tlsConfig = [
|
$tlsConfig = [
|
||||||
'enabled' => true,
|
'enabled' => true,
|
||||||
'insecure' => $tlsMode === 2
|
'insecure' => $tlsMode === 2
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ class Surfboard extends AbstractProtocol
|
|||||||
"{$server['name']}=ss",
|
"{$server['name']}=ss",
|
||||||
"{$server['host']}",
|
"{$server['host']}",
|
||||||
"{$server['port']}",
|
"{$server['port']}",
|
||||||
"encrypt-method={$protocol_settings['cipher']}",
|
"encrypt-method=" . data_get($protocol_settings, 'cipher'),
|
||||||
"password={$password}",
|
"password={$password}",
|
||||||
'tfo=true',
|
'tfo=true',
|
||||||
'udp-relay=true'
|
'udp-relay=true'
|
||||||
|
|||||||
Reference in New Issue
Block a user