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] (update)sing-box rule #2491

Merged
merged 17 commits into from
Feb 4, 2025
186 changes: 155 additions & 31 deletions config/appprofile.example.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,62 +53,104 @@
'servers' => [
[
'tag' => 'local',
'address' => 'local',
'type' => 'local',
'detour' => 'direct',
],
[
'tag' => 'resolver',
'address' => 'quic://223.6.6.6',
'strategy' => 'ipv4_only',
'tag' => 'alidns',
'type' => 'quic',
'server' => '223.6.6.6',
'server_port' => 853,
'detour' => 'direct',
],
[
'tag' => 'cloudflare',
'address' => 'tls://one.one.one.one',
'address_resolver' => 'resolver',
'address_strategy' => 'ipv4_only',
'strategy' => 'prefer_ipv6',
'type' => 'tls',
'server' => '1.1.1.1',
'server_port' => 853,
'detour' => 'select',
],
[
'tag' => 'google',
'type' => 'tls',
'server' => '8.8.4.4',
'server_port' => 853,
'detour' => 'direct',
],
[
'tag' => 'fakeip',
'address' => 'fakeip',
'type' => 'fakeip',
'inet4_range' => '198.18.0.0/15',
'inet6_range' => 'fc00::/18',
],
[
'tag' => 'block',
'address' => 'rcode://refused',
'type' => 'predefined',
'responses' => [
[
'rcode' => 'REFUSED',
],
],
],
],
'rules' => [
[
'outbound' => 'any',
'server' => 'local',
'query_type' => [
'SVCB',
'HTTPS',
],
'server' => 'block',
],
[
'clash_mode' => 'Global',
'server' => 'cloudflare',
'server' => 'fakeip',
],
[
'clash_mode' => 'Rule',
'rule_set' => 'geosite-geolocation-!cn',
'server' => 'cloudflare',
'rule_set' => [
'china-site',
'geosite-geolocation-cn',
'geosite-cn',
'geosite-netease',
'geosite-bilibili',
],
'server' => 'fakeip',
],
[
'type' => 'logical',
'mode' => 'and',
'rules' => [
[
'rule_set' => [
'geosite-geolocation-!cn',
],
'invert' => true,
],
[
'rule_set' => [
'geoip-cn',
],
],
],
'action' => 'route',
'server' => 'google',
'client_subnet' => '111.222.0.0',
],
[
'rule_set' => [
'china-site-add',
],
'server' => 'fakeip',
],
[
'clash_mode' => 'Rule',
'rule_set' => 'geosite-cn',
'server' => 'fakeip',
],
[
'clash_mode' => 'Direct',
'server' => 'local',
],
],
'final' => 'cloudflare',
'fakeip' => [
'enabled' => true,
'inet4_range' => '198.18.0.0/15',
'inet6_range' => 'fc00::/18',
],
'final' => 'block',
'disable_cache' => true,
'independent_cache' => true,
],
Expand Down Expand Up @@ -146,6 +188,17 @@
'idle_timeout' => '30m',
'interrupt_exist_connections' => true,
],
[
'tag' => 'rules_download',
'type' => 'selector',
'outbounds' => [
'select',
'auto',
'direct',
],
'default' => 'auto',
'interrupt_exist_connections' => true,
],
[
'type' => 'direct',
'tag' => 'direct',
Expand All @@ -167,23 +220,49 @@
'outbound' => 'direct',
],
[
'clash_mode' => 'Rule',
'clash_mode' => 'Global',
'outbound' => 'select',
],
[
'rule_set' => [
'geosite-geolocation-!cn',
],
'outbound' => 'select',
],
[
'clash_mode' => 'Rule',
'rule_set' => [
'geosite-cn',
'geoip-cn',
],
'outbound' => 'direct',
],
[
'clash_mode' => 'Global',
'outbound' => 'select',
'rule_set' => [
'china-site',
'geosite-geolocation-cn',
'geosite-cn',
'geosite-netease',
'geosite-bilibili',
],
'outbound' => 'direct',
],
[
'type' => 'logical',
'mode' => 'and',
'rules' => [
[
'rule_set' => [
'geosite-geolocation-!cn',
],
'invert' => true,
],
[
'rule_set' => [
'geoip-cn',
],
],
],
'action' => 'route',
'outbound' => 'direct',
],
[
'protocol' => 'stun',
Expand All @@ -201,29 +280,74 @@
'type' => 'remote',
'format' => 'binary',
'url' => 'https://' . $_ENV['jsdelivr_url'] . '/gh/SagerNet/sing-geoip@rule-set/geoip-cn.srs',
'download_detour' => 'auto',
'download_detour' => 'rules_download',
'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' => 'auto',
'download_detour' => 'rules_download',
'update_interval' => '1d',
],
[
'tag' => 'china-site',
'type' => 'remote',
'format' => 'binary',
'url' => 'https://github.com/77-QiQi/sing-box-rule-set/releases/download/china-rule-set/china_site.srs',
'download_detour' => 'rules_download',
'update_interval' => '1d',
],
[
'tag' => 'china-site-add',
'type' => 'remote',
'format' => 'binary',
'url' => 'https://github.com/77-QiQi/sing-box-rule-set/releases/download/china-rule-set/china_site_add.srs',
'download_detour' => 'rules_download',
'update_interval' => '1d',
],
[
'tag' => 'geosite-geolocation-cn',
'type' => 'remote',
'format' => 'binary',
'url' => 'https://' . $_ENV['jsdelivr_url'] . '/gh/SagerNet/sing-geosite@rule-set/geosite-geolocation-cn.srs',
'download_detour' => 'rules_download',
'update_interval' => '1d',
],
[
'tag' => 'geosite-geolocation-!cn',
'type' => 'remote',
'format' => 'binary',
'url' => 'https://' . $_ENV['jsdelivr_url'] . '/gh/SagerNet/sing-geosite@rule-set/geosite-geolocation-!cn.srs',
'download_detour' => 'auto',
'download_detour' => 'rules_download',
'update_interval' => '1d',
],
[
'tag' => 'geosite-netease',
'type' => 'remote',
'format' => 'binary',
'url' => 'https://' . $_ENV['jsdelivr_url'] . '/gh/SagerNet/sing-geosite@rule-set/geosite-netease.srs',
'download_detour' => 'rules_download',
'update_interval' => '1d',
],
[
'tag' => 'geosite-bilibili',
'type' => 'remote',
'format' => 'binary',
'url' => 'https://' . $_ENV['jsdelivr_url'] . '/gh/SagerNet/sing-geosite@rule-set/geosite-bilibili.srs',
'download_detour' => 'rules_download',
'update_interval' => '1d',
],
],
'final' => 'select',
'auto_detect_interface' => true,
'override_android_vpn' => true,
'default_domain_resolver' => [
'server' => 'local',
'rewrite_tll' => 60,
'client_subnet' => '111.222.0.0',
],
],
'experimental' => [
'cache_file' => [
Expand Down
2 changes: 2 additions & 0 deletions src/Services/Subscribe/Clash.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ public function getContent($user): string
// Clash 特定配置
$udp = $node_custom_config['udp'] ?? true;
$server_key = $node_custom_config['server_key'] ?? '';
$uot = $node_custom_config['uot'] ?? false;

$node = [
'name' => $node_raw->name,
Expand All @@ -67,6 +68,7 @@ public function getContent($user): string
'password' => $server_key === '' ? $user_pk : $server_key . ':' .$user_pk,
'cipher' => $method,
'udp' => (bool) $udp,
'udp_over_tcp' => (bool) $uot,
];

break;
Expand Down
2 changes: 2 additions & 0 deletions src/Services/Subscribe/SingBox.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public function getContent($user): string
($node_custom_config['offset_port_node'] ?? 443);
$method = $node_custom_config['method'] ?? '2022-blake3-aes-128-gcm';
$user_pk = Tools::genSs2022UserPk($user->passwd, $method);
$uot = $node_custom_config['uot'] ?? false;

if (! $user_pk) {
$node = [];
Expand All @@ -54,6 +55,7 @@ public function getContent($user): string
'server_port' => (int) $ss_2022_port,
'method' => $method,
'password' => $server_key === '' ? $user_pk : $server_key . ':' .$user_pk,
'udp_over_tcp' => (bool) $uot,
];

break;
Expand Down