Skip to content

Commit

Permalink
fix: uc bool type error
Browse files Browse the repository at this point in the history
Co-Authored-By: 世界 <[email protected]>
  • Loading branch information
M1Screw and nekohasekai committed Sep 16, 2023
1 parent 36bd606 commit 70c1c7d
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 29 deletions.
10 changes: 10 additions & 0 deletions config/appprofile.example.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,14 @@
],
],
'route' => [
'geoip' => [
'download_url' => 'https://cdn.jsdelivr.net/gh/MetaCubeX/meta-rules-dat@release/geoip-lite.db',
'download_detour' => 'direct',
],
'geosite' => [
'download_url' => 'https://cdn.jsdelivr.net/gh/MetaCubeX/meta-rules-dat@release/geosite-lite.db',
'download_detour' => 'direct',
],
'rules' => [
[
'protocol' => 'dns',
Expand Down Expand Up @@ -147,7 +155,9 @@
],
'experimental' => [
'clash_api' => [
'external_controller' => '0.0.0.0:9090',
'store_mode' => true,
'store_selected' => true,
'cache_id' => '',
],
],
Expand Down
28 changes: 12 additions & 16 deletions src/Services/Subscribe/Clash.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function getContent($user): string
'port' => (int) $user->port,
'password' => $user->passwd,
'cipher' => $user->method,
'udp' => $udp,
'udp' => (bool) $udp,
'client-fingerprint' => $client_fingerprint,
'plugin' => $plugin,
'plugin-opts' => $plugin_option,
Expand All @@ -64,12 +64,8 @@ public function getContent($user): string
};

$user_pk = Tools::getSs2022UserPk($user, $pk_len);
$plugin = $node_custom_config['plugin'] ?? '';
$plugin_option = $node_custom_config['plugin_option'] ?? null;
// Clash 特定配置
$udp = $node_custom_config['udp'] ?? true;
// Clash.Meta
$client_fingerprint = $node_custom_config['client_fingerprint'] ?? '';

$node = [
'name' => $node_raw->name,
Expand All @@ -78,17 +74,15 @@ public function getContent($user): string
'port' => (int) $ss_2022_port,
'password' => $user_pk,
'cipher' => $method,
'udp' => $udp,
'client-fingerprint' => $client_fingerprint,
'plugin' => $plugin,
'plugin-opts' => $plugin_option,
'udp' => (bool) $udp,
];

break;
case 2:
$tuic_port = $node_custom_config['tuic_port'] ?? ($node_custom_config['offset_port_user']
?? ($node_custom_config['offset_port_node'] ?? 443));
$sni = $node_custom_config['sni'] ?? '';
$host = $node_custom_config['host'] ?? '';
$congestion_control = $node_custom_config['congestion_control'] ?? 'bbr';

// Tuic V5 Only
$node = [
Expand All @@ -98,7 +92,9 @@ public function getContent($user): string
'port' => (int) $tuic_port,
'password' => $user->passwd,
'uuid' => $user->uuid,
'sni' => $sni,
'sni' => $host,
'congestion-controller' => $congestion_control,
'reduce-rtt' => true,
];

break;
Expand Down Expand Up @@ -134,12 +130,12 @@ public function getContent($user): string
'uuid' => $user->uuid,
'alterId' => (int) $alter_id,
'cipher' => $encryption,
'udp' => $udp,
'udp' => (bool) $udp,
'tls' => $tls,
'client-fingerprint' => $client_fingerprint,
'fingerprint' => $fingerprint,
'flow' => $flow,
'skip-cert-verify' => $allow_insecure,
'skip-cert-verify' => (bool) $allow_insecure,
'servername' => $host,
'network' => $network,
'ws-opts' => $ws_opts,
Expand Down Expand Up @@ -176,12 +172,12 @@ public function getContent($user): string
'port' => (int) $trojan_port,
'password' => $user->uuid,
'network' => $network,
'udp' => $udp,
'udp' => (bool) $udp,
'client-fingerprint' => $client_fingerprint,
'fingerprint' => $fingerprint,
'flow' => $flow,
'flow-show' => $flow_show,
'skip-cert-verify' => $allow_insecure,
'flow-show' => (bool) $flow_show,
'skip-cert-verify' => (bool) $allow_insecure,
'ws-opts' => $ws_opts,
'grpc-opts' => $grpc_opts,
];
Expand Down
30 changes: 17 additions & 13 deletions src/Services/Subscribe/SingBox.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,13 @@ public function getContent($user): string

switch ((int) $node_raw->sort) {
case 0:
$plugin = $node_custom_config['plugin'] ?? '';
$plugin_option = $node_custom_config['plugin_option'] ?? '';

$node = [
'type' => 'shadowsocks',
'tag' => $node_raw->name,
'server' => $server,
'server_port' => (int) $user->port,
'method' => $user->method,
'password' => $user->passwd,
'plugin' => $plugin,
'plugin_opts' => $plugin_option,
];

break;
Expand All @@ -56,24 +51,24 @@ public function getContent($user): string
};

$user_pk = Tools::getSs2022UserPk($user, $pk_len);
$plugin = $node_custom_config['plugin'] ?? '';
$plugin_option = $node_custom_config['plugin_option'] ?? '';
$server_key = $node_custom_config['server_key'] ?? '';

$node = [
'type' => 'shadowsocks',
'tag' => $node_raw->name,
'server' => $server,
'server_port' => (int) $ss_2022_port,
'method' => $method,
'password' => $user_pk,
'plugin' => $plugin,
'plugin_opts' => $plugin_option,
'password' => $server_key === '' ? $user_pk : $server_key . ':' .$user_pk,
];

break;
case 2:
$tuic_port = $node_custom_config['tuic_port'] ?? ($node_custom_config['offset_port_user']
?? ($node_custom_config['offset_port_node'] ?? 443));
$host = $node_custom_config['host'] ?? '';
$allow_insecure = $node_custom_config['allow_insecure'] ?? false;
$congestion_control = $node_custom_config['congestion_control'] ?? 'bbr';

$node = [
'type' => 'tuic',
Expand All @@ -82,8 +77,17 @@ public function getContent($user): string
'server_port' => (int) $tuic_port,
'uuid' => $user->uuid,
'password' => $user->passwd,
'congestion_control' => $congestion_control,
'zero_rtt_handshake' => true,
'tls' => [
'enabled' => true,
'server_name' => $host,
'insecure' => (bool) $allow_insecure,
],
];

$node['tls'] = array_filter($node['tls']);

break;
case 11:
$v2_port = $node_custom_config['v2_port'] ?? ($node_custom_config['offset_port_user']
Expand Down Expand Up @@ -122,7 +126,7 @@ public function getContent($user): string
$trojan_port = $node_custom_config['trojan_port'] ?? ($node_custom_config['offset_port_user']
?? ($node_custom_config['offset_port_node'] ?? 443));
$host = $node_custom_config['host'] ?? '';
$insecure = $node_custom_config['allow_insecure'] ?? false;
$allow_insecure = $node_custom_config['allow_insecure'] ?? false;
$transport = $node_custom_config['network']
?? (array_key_exists('grpc', $node_custom_config)
&& $node_custom_config['grpc'] === '1' ? 'grpc' : '');
Expand All @@ -139,7 +143,7 @@ public function getContent($user): string
'tls' => [
'enabled' => true,
'server_name' => $host,
'insecure' => $insecure,
'insecure' => (bool) $allow_insecure,
],
'transport' => [
'type' => $transport,
Expand Down Expand Up @@ -167,7 +171,7 @@ public function getContent($user): string
}

$singbox_config['outbounds'] = array_merge($singbox_config['outbounds'], $nodes);
$singbox_config['experimental']['clash_api']['cache_id'] = (string) $user->id;
$singbox_config['experimental']['clash_api']['cache_id'] = $_ENV['appName'];

return json_encode($singbox_config);
}
Expand Down

0 comments on commit 70c1c7d

Please sign in to comment.