From c402431bb3740150b316fbb8d6c878e12046fad2 Mon Sep 17 00:00:00 2001 From: nite07 Date: Tue, 22 Oct 2024 20:29:45 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fix=20vless=20reality=20missing?= =?UTF-8?q?=20utls?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- merge-templates.sh | 1 + parser/vless.go | 4 + templates/android/dns.json | 60 +++++++ templates/android/experimental.json | 13 ++ templates/android/inbounds.json | 12 ++ templates/android/log.json | 6 + templates/android/ntp.json | 8 + templates/android/outbounds.json | 21 +++ templates/android/route.json | 53 ++++++ templates/android/route_rule_set.json | 62 +++++++ templates/example-android.json | 223 ++++++++++++++++++++++++++ templates/example-linux.json | 18 ++- templates/example-windows.json | 18 ++- templates/linux/dns.json | 8 +- templates/linux/ntp.json | 8 + templates/linux/route_rule_set.json | 2 +- templates/windows/dns.json | 8 +- templates/windows/ntp.json | 8 + templates/windows/route_rule_set.json | 2 +- 19 files changed, 509 insertions(+), 26 deletions(-) create mode 100644 templates/android/dns.json create mode 100644 templates/android/experimental.json create mode 100644 templates/android/inbounds.json create mode 100644 templates/android/log.json create mode 100644 templates/android/ntp.json create mode 100644 templates/android/outbounds.json create mode 100644 templates/android/route.json create mode 100644 templates/android/route_rule_set.json create mode 100644 templates/example-android.json create mode 100644 templates/linux/ntp.json create mode 100644 templates/windows/ntp.json diff --git a/merge-templates.sh b/merge-templates.sh index 3549d3d..106bd47 100755 --- a/merge-templates.sh +++ b/merge-templates.sh @@ -1,3 +1,4 @@ #!/bin/bash sing-box merge -C ./templates/windows ./templates/example-windows.json sing-box merge -C ./templates/linux ./templates/example-linux.json +sing-box merge -C ./templates/android ./templates/example-android.json diff --git a/parser/vless.go b/parser/vless.go index f7ab8c0..804d52f 100644 --- a/parser/vless.go +++ b/parser/vless.go @@ -96,6 +96,10 @@ func ParseVless(proxy string) (model.Outbound, error) { PublicKey: pbk, ShortID: sid, }, + UTLS: &option.OutboundUTLSOptions{ + Enabled: true, + Fingerprint: fp, + }, }, } } diff --git a/templates/android/dns.json b/templates/android/dns.json new file mode 100644 index 0000000..d3d8860 --- /dev/null +++ b/templates/android/dns.json @@ -0,0 +1,60 @@ +{ + "dns": { + "servers": [ + { + "tag": "google", + "address": "https://8.8.8.8/dns-query", + "detour": "default" + }, + { + "tag": "local", + "address": "h3://223.5.5.5/dns-query", + "detour": "direct" + }, + { + "tag": "refused", + "address": "rcode://refused" + } + ], + "rules": [ + { + "rule_set": "geosite-category-ads-all", + "server": "refused" + }, + { + "outbound": "any", + "server": "local" + }, + { + "clash_mode": "Direct", + "server": "local" + }, + { + "clash_mode": "Global", + "server": "google" + }, + { + "rule_set": "geosite-geolocation-cn", + "server": "local" + }, + { + "type": "logical", + "mode": "and", + "rules": [ + { + "rule_set": "geosite-geolocation-!cn", + "invert": true + }, + { + "rule_set": "geoip-cn" + } + ], + "server": "google", + "client_subnet": "114.114.114.114/24" + } + ], + "final": "google", + "disable_cache": false, + "disable_expire": false + } +} diff --git a/templates/android/experimental.json b/templates/android/experimental.json new file mode 100644 index 0000000..3a610ad --- /dev/null +++ b/templates/android/experimental.json @@ -0,0 +1,13 @@ +{ + "experimental": { + "cache_file": { + "enabled": true + }, + "clash_api": { + "external_controller": "127.0.0.1:9090", + "external_ui": "./ui", + "external_ui_download_detour": "default", + "default_mode": "Enhanced" + } + } +} diff --git a/templates/android/inbounds.json b/templates/android/inbounds.json new file mode 100644 index 0000000..4d6b32c --- /dev/null +++ b/templates/android/inbounds.json @@ -0,0 +1,12 @@ +{ + "inbounds": [ + { + "type": "tun", + "auto_route": true, + "strict_route": true, + "sniff": true, + "address": ["172.16.0.1/30", "fdfe:dcba:9876::1/126"], + "exclude_interface": ["tailscale0"] + } + ] +} diff --git a/templates/android/log.json b/templates/android/log.json new file mode 100644 index 0000000..4a6dacf --- /dev/null +++ b/templates/android/log.json @@ -0,0 +1,6 @@ +{ + "log": { + "level": "info", + "timestamp": true + } +} diff --git a/templates/android/ntp.json b/templates/android/ntp.json new file mode 100644 index 0000000..aefbe47 --- /dev/null +++ b/templates/android/ntp.json @@ -0,0 +1,8 @@ +{ + "ntp": { + "enabled": true, + "server": "ntp.aliyun.com", + "server_port": 123, + "interval": "30m" + } +} diff --git a/templates/android/outbounds.json b/templates/android/outbounds.json new file mode 100644 index 0000000..9cbeaae --- /dev/null +++ b/templates/android/outbounds.json @@ -0,0 +1,21 @@ +{ + "outbounds": [ + { + "outbounds": ["", "direct"], + "tag": "default", + "type": "selector" + }, + { + "tag": "direct", + "type": "direct" + }, + { + "tag": "block", + "type": "block" + }, + { + "tag": "dns", + "type": "dns" + } + ] +} diff --git a/templates/android/route.json b/templates/android/route.json new file mode 100644 index 0000000..1824fab --- /dev/null +++ b/templates/android/route.json @@ -0,0 +1,53 @@ +{ + "route": { + "rules": [ + { + "type": "logical", + "mode": "or", + "rules": [ + { + "protocol": "dns" + }, + { + "port": 53 + } + ], + "outbound": "dns" + }, + { + "ip_is_private": true, + "outbound": "direct" + }, + { + "clash_mode": "Direct", + "outbound": "direct" + }, + { + "clash_mode": "Global", + "outbound": "default" + }, + { + "rule_set": "geosite-google", + "outbound": "default" + }, + { + "type": "logical", + "mode": "or", + "rules": [ + { + "rule_set": [ + "geoip-cn", + "geosite-geolocation-cn", + "geosite-cn", + "geosite-category-games@cn", + "geosite-steam@cn" + ] + } + ], + "outbound": "direct" + } + ], + "final": "default", + "auto_detect_interface": true + } +} diff --git a/templates/android/route_rule_set.json b/templates/android/route_rule_set.json new file mode 100644 index 0000000..20ec3a6 --- /dev/null +++ b/templates/android/route_rule_set.json @@ -0,0 +1,62 @@ +{ + "route": { + "rule_set": [ + { + "type": "remote", + "tag": "geosite-category-ads-all", + "format": "binary", + "url": "https://raw.githubusercontent.com/SagerNet/sing-geosite/rule-set/geosite-category-ads-all.srs", + "download_detour": "default" + }, + { + "type": "remote", + "tag": "geosite-geolocation-cn", + "format": "binary", + "url": "https://raw.githubusercontent.com/SagerNet/sing-geosite/rule-set/geosite-geolocation-cn.srs", + "download_detour": "default" + }, + { + "type": "remote", + "tag": "geosite-geolocation-!cn", + "format": "binary", + "url": "https://raw.githubusercontent.com/SagerNet/sing-geosite/rule-set/geosite-geolocation-!cn.srs", + "download_detour": "default" + }, + { + "type": "remote", + "tag": "geoip-cn", + "format": "binary", + "url": "https://raw.githubusercontent.com/SagerNet/sing-geoip/rule-set/geoip-cn.srs", + "download_detour": "default" + }, + { + "type": "remote", + "tag": "geosite-category-games@cn", + "format": "binary", + "url": "https://raw.githubusercontent.com/SagerNet/sing-geosite/rule-set/geosite-category-games@cn.srs", + "download_detour": "default" + }, + { + "type": "remote", + "tag": "geosite-steam@cn", + "format": "binary", + "url": "https://raw.githubusercontent.com/SagerNet/sing-geosite/rule-set/geosite-steam@cn.srs", + "download_detour": "default" + }, + { + "type": "remote", + "tag": "geosite-cn", + "format": "binary", + "url": "https://raw.githubusercontent.com/SagerNet/sing-geosite/rule-set/geosite-cn.srs", + "download_detour": "default" + }, + { + "type": "remote", + "tag": "geosite-google", + "format": "binary", + "url": "https://raw.githubusercontent.com/SagerNet/sing-geosite/rule-set/geosite-google.srs", + "download_detour": "default" + } + ] + } +} diff --git a/templates/example-android.json b/templates/example-android.json new file mode 100644 index 0000000..245eceb --- /dev/null +++ b/templates/example-android.json @@ -0,0 +1,223 @@ +{ + "log": { + "level": "info", + "timestamp": true + }, + "dns": { + "servers": [ + { + "tag": "google", + "address": "https://8.8.8.8/dns-query", + "detour": "default" + }, + { + "tag": "local", + "address": "h3://223.5.5.5/dns-query", + "detour": "direct" + }, + { + "tag": "refused", + "address": "rcode://refused" + } + ], + "rules": [ + { + "rule_set": "geosite-category-ads-all", + "server": "refused" + }, + { + "outbound": "any", + "server": "local" + }, + { + "clash_mode": "Direct", + "server": "local" + }, + { + "clash_mode": "Global", + "server": "google" + }, + { + "rule_set": "geosite-geolocation-cn", + "server": "local" + }, + { + "type": "logical", + "mode": "and", + "rules": [ + { + "rule_set": "geosite-geolocation-!cn", + "invert": true + }, + { + "rule_set": "geoip-cn" + } + ], + "server": "google", + "client_subnet": "114.114.114.114/24" + } + ], + "final": "google" + }, + "ntp": { + "enabled": true, + "interval": "30m0s", + "server": "ntp.aliyun.com", + "server_port": 123 + }, + "inbounds": [ + { + "type": "tun", + "address": [ + "172.16.0.1/30", + "fdfe:dcba:9876::1/126" + ], + "auto_route": true, + "strict_route": true, + "exclude_interface": "tailscale0", + "sniff": true + } + ], + "outbounds": [ + { + "type": "selector", + "tag": "default", + "outbounds": [ + "\u003call-proxy-tags\u003e", + "direct" + ] + }, + { + "type": "direct", + "tag": "direct" + }, + { + "type": "block", + "tag": "block" + }, + { + "type": "dns", + "tag": "dns" + } + ], + "route": { + "rules": [ + { + "type": "logical", + "mode": "or", + "rules": [ + { + "protocol": "dns" + }, + { + "port": 53 + } + ], + "outbound": "dns" + }, + { + "ip_is_private": true, + "outbound": "direct" + }, + { + "clash_mode": "Direct", + "outbound": "direct" + }, + { + "clash_mode": "Global", + "outbound": "default" + }, + { + "rule_set": "geosite-google", + "outbound": "default" + }, + { + "type": "logical", + "mode": "or", + "rules": [ + { + "rule_set": [ + "geoip-cn", + "geosite-geolocation-cn", + "geosite-cn", + "geosite-category-games@cn", + "geosite-steam@cn" + ] + } + ], + "outbound": "direct" + } + ], + "rule_set": [ + { + "type": "remote", + "tag": "geosite-category-ads-all", + "format": "binary", + "url": "https://raw.githubusercontent.com/SagerNet/sing-geosite/rule-set/geosite-category-ads-all.srs", + "download_detour": "default" + }, + { + "type": "remote", + "tag": "geosite-geolocation-cn", + "format": "binary", + "url": "https://raw.githubusercontent.com/SagerNet/sing-geosite/rule-set/geosite-geolocation-cn.srs", + "download_detour": "default" + }, + { + "type": "remote", + "tag": "geosite-geolocation-!cn", + "format": "binary", + "url": "https://raw.githubusercontent.com/SagerNet/sing-geosite/rule-set/geosite-geolocation-!cn.srs", + "download_detour": "default" + }, + { + "type": "remote", + "tag": "geoip-cn", + "format": "binary", + "url": "https://raw.githubusercontent.com/SagerNet/sing-geoip/rule-set/geoip-cn.srs", + "download_detour": "default" + }, + { + "type": "remote", + "tag": "geosite-category-games@cn", + "format": "binary", + "url": "https://raw.githubusercontent.com/SagerNet/sing-geosite/rule-set/geosite-category-games@cn.srs", + "download_detour": "default" + }, + { + "type": "remote", + "tag": "geosite-steam@cn", + "format": "binary", + "url": "https://raw.githubusercontent.com/SagerNet/sing-geosite/rule-set/geosite-steam@cn.srs", + "download_detour": "default" + }, + { + "type": "remote", + "tag": "geosite-cn", + "format": "binary", + "url": "https://raw.githubusercontent.com/SagerNet/sing-geosite/rule-set/geosite-cn.srs", + "download_detour": "default" + }, + { + "type": "remote", + "tag": "geosite-google", + "format": "binary", + "url": "https://raw.githubusercontent.com/SagerNet/sing-geosite/rule-set/geosite-google.srs", + "download_detour": "default" + } + ], + "final": "default", + "auto_detect_interface": true + }, + "experimental": { + "cache_file": { + "enabled": true + }, + "clash_api": { + "external_controller": "127.0.0.1:9090", + "external_ui": "./ui", + "external_ui_download_detour": "default", + "default_mode": "Enhanced" + } + } +} diff --git a/templates/example-linux.json b/templates/example-linux.json index b698cfd..889c358 100644 --- a/templates/example-linux.json +++ b/templates/example-linux.json @@ -1,20 +1,18 @@ { "log": { - "level": "trace", + "level": "info", "timestamp": true }, "dns": { "servers": [ { "tag": "google", - "address": "https://dns.google/dns-query", - "address_resolver": "local", - "address_strategy": "prefer_ipv4", - "client_subnet": "114.114.114.114/24" + "address": "https://8.8.8.8/dns-query", + "detour": "default" }, { "tag": "local", - "address": "https://223.5.5.5/dns-query", + "address": "h3://223.5.5.5/dns-query", "detour": "direct" }, { @@ -61,6 +59,12 @@ ], "final": "google" }, + "ntp": { + "enabled": true, + "interval": "30m0s", + "server": "ntp.aliyun.com", + "server_port": 123 + }, "inbounds": [ { "type": "tun", @@ -150,7 +154,7 @@ "type": "remote", "tag": "geosite-category-ads-all", "format": "binary", - "url": "https://ghp.ci/https://raw.githubusercontent.com/SagerNet/sing-geosite/rule-set/geosite-category-ads-all.srs", + "url": "https://raw.githubusercontent.com/SagerNet/sing-geosite/rule-set/geosite-category-ads-all.srs", "download_detour": "default" }, { diff --git a/templates/example-windows.json b/templates/example-windows.json index 212ed6f..245eceb 100644 --- a/templates/example-windows.json +++ b/templates/example-windows.json @@ -1,20 +1,18 @@ { "log": { - "level": "trace", + "level": "info", "timestamp": true }, "dns": { "servers": [ { "tag": "google", - "address": "https://dns.google/dns-query", - "address_resolver": "local", - "address_strategy": "prefer_ipv4", - "client_subnet": "114.114.114.114/24" + "address": "https://8.8.8.8/dns-query", + "detour": "default" }, { "tag": "local", - "address": "https://223.5.5.5/dns-query", + "address": "h3://223.5.5.5/dns-query", "detour": "direct" }, { @@ -61,6 +59,12 @@ ], "final": "google" }, + "ntp": { + "enabled": true, + "interval": "30m0s", + "server": "ntp.aliyun.com", + "server_port": 123 + }, "inbounds": [ { "type": "tun", @@ -149,7 +153,7 @@ "type": "remote", "tag": "geosite-category-ads-all", "format": "binary", - "url": "https://ghp.ci/https://raw.githubusercontent.com/SagerNet/sing-geosite/rule-set/geosite-category-ads-all.srs", + "url": "https://raw.githubusercontent.com/SagerNet/sing-geosite/rule-set/geosite-category-ads-all.srs", "download_detour": "default" }, { diff --git a/templates/linux/dns.json b/templates/linux/dns.json index a18b551..d3d8860 100644 --- a/templates/linux/dns.json +++ b/templates/linux/dns.json @@ -3,14 +3,12 @@ "servers": [ { "tag": "google", - "address": "https://dns.google/dns-query", - "address_resolver": "local", - "address_strategy": "prefer_ipv4", - "client_subnet": "114.114.114.114/24" + "address": "https://8.8.8.8/dns-query", + "detour": "default" }, { "tag": "local", - "address": "https://223.5.5.5/dns-query", + "address": "h3://223.5.5.5/dns-query", "detour": "direct" }, { diff --git a/templates/linux/ntp.json b/templates/linux/ntp.json new file mode 100644 index 0000000..aefbe47 --- /dev/null +++ b/templates/linux/ntp.json @@ -0,0 +1,8 @@ +{ + "ntp": { + "enabled": true, + "server": "ntp.aliyun.com", + "server_port": 123, + "interval": "30m" + } +} diff --git a/templates/linux/route_rule_set.json b/templates/linux/route_rule_set.json index abba2a2..20ec3a6 100644 --- a/templates/linux/route_rule_set.json +++ b/templates/linux/route_rule_set.json @@ -5,7 +5,7 @@ "type": "remote", "tag": "geosite-category-ads-all", "format": "binary", - "url": "https://ghp.ci/https://raw.githubusercontent.com/SagerNet/sing-geosite/rule-set/geosite-category-ads-all.srs", + "url": "https://raw.githubusercontent.com/SagerNet/sing-geosite/rule-set/geosite-category-ads-all.srs", "download_detour": "default" }, { diff --git a/templates/windows/dns.json b/templates/windows/dns.json index a18b551..d3d8860 100644 --- a/templates/windows/dns.json +++ b/templates/windows/dns.json @@ -3,14 +3,12 @@ "servers": [ { "tag": "google", - "address": "https://dns.google/dns-query", - "address_resolver": "local", - "address_strategy": "prefer_ipv4", - "client_subnet": "114.114.114.114/24" + "address": "https://8.8.8.8/dns-query", + "detour": "default" }, { "tag": "local", - "address": "https://223.5.5.5/dns-query", + "address": "h3://223.5.5.5/dns-query", "detour": "direct" }, { diff --git a/templates/windows/ntp.json b/templates/windows/ntp.json new file mode 100644 index 0000000..aefbe47 --- /dev/null +++ b/templates/windows/ntp.json @@ -0,0 +1,8 @@ +{ + "ntp": { + "enabled": true, + "server": "ntp.aliyun.com", + "server_port": 123, + "interval": "30m" + } +} diff --git a/templates/windows/route_rule_set.json b/templates/windows/route_rule_set.json index abba2a2..20ec3a6 100644 --- a/templates/windows/route_rule_set.json +++ b/templates/windows/route_rule_set.json @@ -5,7 +5,7 @@ "type": "remote", "tag": "geosite-category-ads-all", "format": "binary", - "url": "https://ghp.ci/https://raw.githubusercontent.com/SagerNet/sing-geosite/rule-set/geosite-category-ads-all.srs", + "url": "https://raw.githubusercontent.com/SagerNet/sing-geosite/rule-set/geosite-category-ads-all.srs", "download_detour": "default" }, {