Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Uim] fix: sing-box subscribe #2447

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
97 changes: 67 additions & 30 deletions config/appprofile.example.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php

Check failure on line 1 in config/appprofile.example.php

View workflow job for this annotation

GitHub Actions / lint

* [Binary operator spaces] @@ -49,3 +49,3 @@ 'level' => 'error', - "timestamp" => true, + "timestamp" => true, ], * [Single quote] @@ -47,3 +47,3 @@ 'log' => [ - "disabled" => false, + 'disabled' => false, 'level' => 'error', @@ -49,3 +49,3 @@ 'level' => 'error', - "timestamp" => true, + 'timestamp' => true, ], @@ -93,5 +93,5 @@ 'type' => 'tun', - "address" => [ - "172.18.0.1/30", - "fdfe:dcba:9876::1/126" + 'address' => [ + '172.18.0.1/30', + 'fdfe:dcba:9876::1/126' ],

declare(strict_types=1);

Expand Down Expand Up @@ -45,77 +45,110 @@

$_ENV['SingBox_Config'] = [
'log' => [
"disabled" => false,
'level' => 'error',
"timestamp" => true,
],
'dns' => [
'servers' => [
[
'tag' => 'proxy',
'address' => 'tls://1.1.1.1/',
'detour' => 'select',
],
[
'tag' => 'local',
'address' => 'local',
'address' => 'h3://223.5.5.5/dns-query',
'detour' => 'direct',
],
[
'tag' => 'block',
'address' => 'rcode://refused',
],
],
'rules' => [
[
'outbound' => 'any',
'server' => 'local',
'disable_cache' => true,
],
[
'clash_mode' => 'Global',
'server' => 'proxy',
],
[
'clash_mode' => 'Direct',
'server' => 'local',
],
[
'rule_set' => 'geosite-cn',
'server' => 'local',
],
],
'final' => 'local',
'strategy' => 'prefer_ipv6',
'final' => 'proxy',
'independent_cache' => true,
],
'inbounds' => [
[
'type' => 'tun',
'inet4_address' => '172.19.0.1/30',
"address" => [
"172.18.0.1/30",
"fdfe:dcba:9876::1/126"

Check failure on line 96 in config/appprofile.example.php

View workflow job for this annotation

GitHub Actions / lint

* [Trailing array comma] Multi-line arrays must have a trailing comma after the last element.
],

Check failure on line 97 in config/appprofile.example.php

View workflow job for this annotation

GitHub Actions / lint

* [Array indent] Array close brace not indented correctly; expected 12 spaces but found 16
'auto_route' => true,
'strict_route' => true,
'endpoint_independent_nat' => true,
'udp_timeout' => 60,
'platform' => [
'http_proxy' => [
'enabled' => true,
'server' => '127.0.0.1',
'server_port' => 7891,
],
],
'sniff' => true,
],
[
'type' => 'mixed',
'listen' => '127.0.0.1',
'listen_port' => 7891,
'sniff' => true,
'domain_strategy' => 'prefer_ipv6',
'sniff_override_destination' => true,
'domain_strategy' => 'prefer_ipv4',
'udp_timeout' => 60,
],
],
'outbounds' => [
[
'tag' => 'select',
'type' => 'selector',
'tag' => 'default',
'default' => 'auto',
'outbounds' => [
'auto',
],

Check failure on line 113 in config/appprofile.example.php

View workflow job for this annotation

GitHub Actions / lint

* [Array indent] Array close brace not indented correctly; expected 12 spaces but found 16
'interrupt_exist_connections' => true,
],
[
'tag' => 'auto',
'type' => 'urltest',
'outbounds' => [],
'url' => 'https://cp.cloudflare.com/generate_204',
'interval' => '3m',
'tolerance' => 50,
'idle_timeout' => '30m',
'interrupt_exist_connections' => true,
],
[
'type' => 'direct',
'tag' => 'direct',
'type' => 'direct',
],
[
'type' => 'block',
'tag' => 'block',
'type' => 'block',
],
[
'tag' => 'dns-out',
'type' => 'dns',
],
],
'route' => [
'rules' => [
[
'clash_mode' => 'Direct',
'outbound' => 'direct',
'protocol' => 'dns',
'outbound' => 'dns-out',
],
[
'clash_mode' => 'Rule',
'outbound' => 'default',
'clash_mode' => 'Direct',
'outbound' => 'direct',
],
[
'clash_mode' => 'Global',
'outbound' => 'default',
'outbound' => 'select',
],
[
'protocol' => 'stun',
Expand All @@ -140,22 +173,26 @@
'type' => 'remote',
'format' => 'binary',
'url' => 'https://' . $_ENV['jsdelivr_url'] . '/gh/SagerNet/sing-geoip@rule-set/geoip-cn.srs',
'download_detour' => 'direct',
'download_detour' => 'select',
'update_interval' => '1d',
],
[
'tag' => 'geosite-cn',
'type' => 'remote',
'format' => 'binary',
'url' => 'https://' . $_ENV['jsdelivr_url'] . '/gh/SagerNet/sing-geosite@rule-set/geosite-cn.srs',
'download_detour' => 'direct',
'download_detour' => 'select',
'update_interval' => '1d',
],
],
'auto_detect_interface' => true,
'final' => 'select',
],
'experimental' => [
'cache_file' => [
'enabled' => true,
'cache_id' => '',
'path' => 'cache.db',
],
'clash_api' => [
'external_controller' => '127.0.0.1:9090',
Expand Down
5 changes: 5 additions & 0 deletions src/Services/Subscribe/SingBox.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php

Check failure on line 1 in src/Services/Subscribe/SingBox.php

View workflow job for this annotation

GitHub Actions / lint

* [Single quote] @@ -107,3 +107,3 @@ ], - "packet_encoding" => "packetaddr", + 'packet_encoding' => 'packetaddr', 'transport' => [ @@ -113,4 +113,4 @@ 'service_name' => $service_name, - "max_early_data" => 2048, - "early_data_header_name" => "Sec-WebSocket-Protocol" + 'max_early_data' => 2048, + 'early_data_header_name' => 'Sec-WebSocket-Protocol' ],

declare(strict_types=1);

Expand Down Expand Up @@ -102,13 +102,17 @@
'security' => 'auto',
'alter_id' => 0,
'tls' => [
'enabled' => true,
'server_name' => $host,
],
"packet_encoding" => "packetaddr",
'transport' => [
'type' => $transport,
'path' => $path,
'headers' => $headers,
'service_name' => $service_name,
"max_early_data" => 2048,
"early_data_header_name" => "Sec-WebSocket-Protocol"

Check failure on line 115 in src/Services/Subscribe/SingBox.php

View workflow job for this annotation

GitHub Actions / lint

* [Trailing array comma] Multi-line arrays must have a trailing comma after the last element.
],
];

Expand Down Expand Up @@ -160,6 +164,7 @@

$nodes[] = $node;
$singbox_config['outbounds'][0]['outbounds'][] = $node_raw->name;
$singbox_config['outbounds'][1]['outbounds'][] = $node_raw->name;
}

$singbox_config['outbounds'] = array_merge($singbox_config['outbounds'], $nodes);
Expand Down
Loading