From acf547f173c56602e135f00a13c3ca0d086b3b90 Mon Sep 17 00:00:00 2001 From: Nite07 Date: Mon, 22 Apr 2024 23:44:04 +0800 Subject: [PATCH] :bug: Fix null pointer exception when parse ws headers in vless :wrench: Update templates --- parser/vless.go | 7 +- ...son => tun-fakeip-with-country-group.json} | 23 +- templates/tun-fakeip-with-dns-leaks.json | 247 ------------------ ...without-dns-leaks.json => tun-fakeip.json} | 23 +- ...group.json => tun-with-country-group.json} | 23 +- templates/tun-with-dns-leaks.json | 233 ----------------- .../{tun-without-dns-leaks.json => tun.json} | 23 +- 7 files changed, 46 insertions(+), 533 deletions(-) rename templates/{tun-fakeip-without-dns-leaks-country-group.json => tun-fakeip-with-country-group.json} (94%) delete mode 100644 templates/tun-fakeip-with-dns-leaks.json rename templates/{tun-fakeip-without-dns-leaks.json => tun-fakeip.json} (94%) rename templates/{tun-without-dns-leaks-country-group.json => tun-with-country-group.json} (94%) delete mode 100644 templates/tun-with-dns-leaks.json rename templates/{tun-without-dns-leaks.json => tun.json} (94%) diff --git a/parser/vless.go b/parser/vless.go index 987de8e..ab26c04 100644 --- a/parser/vless.go +++ b/parser/vless.go @@ -130,7 +130,12 @@ func ParseVless(proxy string) (model.Outbound, error) { Path: path, }, } - result.VLESSOptions.Transport.WebsocketOptions.Headers["Host"] = host + if host != "" { + if result.VLESSOptions.Transport.WebsocketOptions.Headers == nil { + result.VLESSOptions.Transport.WebsocketOptions.Headers = make(map[string]string) + } + result.VLESSOptions.Transport.WebsocketOptions.Headers["Host"] = host + } } if params.Get("type") == "quic" { diff --git a/templates/tun-fakeip-without-dns-leaks-country-group.json b/templates/tun-fakeip-with-country-group.json similarity index 94% rename from templates/tun-fakeip-without-dns-leaks-country-group.json rename to templates/tun-fakeip-with-country-group.json index d1e2e0b..c228a81 100644 --- a/templates/tun-fakeip-without-dns-leaks-country-group.json +++ b/templates/tun-fakeip-with-country-group.json @@ -143,21 +143,25 @@ "outbound": "dns-out" }, { - "ip_is_private": true, + "rule_set": "geosite-geolocation-!cn", + "outbound": "节点选择" + }, + { + "rule_set": "geosite-geolocation-cn", "outbound": "direct" }, { - "rule_set": ["geoip-cn", "geosite-geolocation-cn"], + "rule_set": "geoip-cn", + "outbound": "direct" + }, + { + "ip_is_private": true, "outbound": "direct" }, { "rule_set": "geosite-category-ads-all", "outbound": "Ads" }, - { - "rule_set": "geosite-microsoft", - "outbound": "Microsoft" - }, { "rule_set": "geosite-bilibili", "outbound": "Bilibili" @@ -203,13 +207,6 @@ "default": "block", "interrupt_exist_connections": true }, - { - "type": "selector", - "tag": "Microsoft", - "outbounds": ["节点选择", "", "direct"], - "default": "节点选择", - "interrupt_exist_connections": true - }, { "type": "selector", "tag": "Bilibili", diff --git a/templates/tun-fakeip-with-dns-leaks.json b/templates/tun-fakeip-with-dns-leaks.json deleted file mode 100644 index 2725ef6..0000000 --- a/templates/tun-fakeip-with-dns-leaks.json +++ /dev/null @@ -1,247 +0,0 @@ -{ - "log": { - "level": "info", - "timestamp": true - }, - "dns": { - "servers": [ - { - "tag": "google", - "address": "tls://8.8.8.8" - }, - { - "tag": "local", - "address": "https://223.5.5.5/dns-query", - "detour": "direct" - }, - { - "tag": "remote", - "address": "fakeip" - } - ], - "rules": [ - { - "outbound": "any", - "server": "local" - }, - { - "query_type": ["A", "AAAA"], - "server": "remote" - }, - { - "clash_mode": "Direct", - "server": "local" - }, - { - "clash_mode": "Global", - "server": "google" - }, - { - "rule_set": "geosite-geolocation-cn", - "server": "local" - } - ], - "fakeip": { - "enabled": true, - "inet4_range": "198.18.0.0/15", - "inet6_range": "fc00::/18" - }, - "independent_cache": true - }, - "route": { - "rule_set": [ - { - "tag": "geosite-geolocation-cn", - "type": "remote", - "format": "binary", - "url": "https://raw.githubusercontent.com/SagerNet/sing-geosite/rule-set/geosite-geolocation-cn.srs", - "download_detour": "节点选择" - }, - { - "tag": "geosite-geolocation-!cn", - "type": "remote", - "format": "binary", - "url": "https://raw.githubusercontent.com/SagerNet/sing-geosite/rule-set/geosite-geolocation-!cn.srs", - "download_detour": "节点选择" - }, - { - "tag": "geoip-cn", - "type": "remote", - "format": "binary", - "url": "https://raw.githubusercontent.com/SagerNet/sing-geoip/rule-set/geoip-cn.srs", - "download_detour": "节点选择" - }, - { - "tag": "geosite-category-ads-all", - "type": "remote", - "format": "binary", - "url": "https://raw.githubusercontent.com/SagerNet/sing-geosite/rule-set/geosite-category-ads-all.srs", - "download_detour": "节点选择" - }, - { - "tag": "geosite-microsoft", - "type": "remote", - "format": "binary", - "url": "https://raw.githubusercontent.com/SagerNet/sing-geosite/rule-set/geosite-microsoft.srs", - "download_detour": "节点选择" - }, - { - "tag": "geosite-bilibili", - "type": "remote", - "format": "binary", - "url": "https://raw.githubusercontent.com/SagerNet/sing-geosite/rule-set/geosite-bilibili.srs", - "download_detour": "节点选择" - }, - { - "tag": "geosite-bahamut", - "type": "remote", - "format": "binary", - "url": "https://raw.githubusercontent.com/SagerNet/sing-geosite/rule-set/geosite-bahamut.srs", - "download_detour": "节点选择" - }, - { - "tag": "geosite-category-games@cn", - "type": "remote", - "format": "binary", - "url": "https://raw.githubusercontent.com/SagerNet/sing-geosite/rule-set/geosite-category-games@cn.srs", - "download_detour": "节点选择" - }, - { - "tag": "geosite-category-games", - "type": "remote", - "format": "binary", - "url": "https://raw.githubusercontent.com/SagerNet/sing-geosite/rule-set/geosite-category-games.srs", - "download_detour": "节点选择" - } - ], - "rules": [ - { - "type": "logical", - "mode": "or", - "rules": [ - { - "protocol": "dns" - }, - { - "port": 53 - } - ], - "outbound": "dns-out" - }, - { - "ip_is_private": true, - "outbound": "direct" - }, - { - "rule_set": ["geoip-cn", "geosite-geolocation-cn"], - "outbound": "direct" - }, - { - "rule_set": "geosite-category-ads-all", - "outbound": "Ads" - }, - { - "rule_set": "geosite-microsoft", - "outbound": "Microsoft" - }, - { - "rule_set": "geosite-bilibili", - "outbound": "Bilibili" - }, - { - "rule_set": "geosite-category-games@cn", - "outbound": "Games(中国)" - }, - { - "rule_set": "geosite-category-games", - "outbound": "Games(全球)" - }, - { - "rule_set": "geosite-bahamut", - "outbound": "Bahamut" - } - ], - "final": "节点选择", - "auto_detect_interface": true - }, - "inbounds": [ - { - "type": "tun", - "inet4_address": "172.19.0.1/30", - "inet6_address": "fdfe:dcba:9876::1/126", - "auto_route": true, - "strict_route": true, - "sniff": true, - "sniff_override_destination": false - } - ], - "outbounds": [ - { - "type": "selector", - "tag": "节点选择", - "outbounds": ["", "direct"], - "interrupt_exist_connections": true - }, - { - "type": "selector", - "tag": "Ads", - "outbounds": ["direct", "block"], - "default": "block", - "interrupt_exist_connections": true - }, - { - "type": "selector", - "tag": "Microsoft", - "outbounds": ["节点选择", "", "direct"], - "default": "节点选择", - "interrupt_exist_connections": true - }, - { - "type": "selector", - "tag": "Bilibili", - "outbounds": ["节点选择", "", "direct"], - "default": "direct", - "interrupt_exist_connections": true - }, - { - "type": "selector", - "tag": "Games(全球)", - "outbounds": ["节点选择", "", "direct"], - "default": "节点选择", - "interrupt_exist_connections": true - }, - { - "type": "selector", - "tag": "Games(中国)", - "outbounds": ["节点选择", "", "direct"], - "default": "direct", - "interrupt_exist_connections": true - }, - { - "type": "selector", - "tag": "Bahamut", - "outbounds": ["节点选择", "", "direct"], - "default": "节点选择", - "interrupt_exist_connections": true - }, - { - "type": "direct", - "tag": "direct" - }, - { - "type": "block", - "tag": "block" - }, - { - "type": "dns", - "tag": "dns-out" - } - ], - "experimental": { - "clash_api": { - "external_controller": "127.0.0.1:9090", - "external_ui": "./ui", - "external_ui_download_detour": "节点选择" - } - } -} diff --git a/templates/tun-fakeip-without-dns-leaks.json b/templates/tun-fakeip.json similarity index 94% rename from templates/tun-fakeip-without-dns-leaks.json rename to templates/tun-fakeip.json index 3a530b1..516d614 100644 --- a/templates/tun-fakeip-without-dns-leaks.json +++ b/templates/tun-fakeip.json @@ -143,21 +143,25 @@ "outbound": "dns-out" }, { - "ip_is_private": true, + "rule_set": "geosite-geolocation-!cn", + "outbound": "节点选择" + }, + { + "rule_set": "geosite-geolocation-cn", "outbound": "direct" }, { - "rule_set": ["geoip-cn", "geosite-geolocation-cn"], + "rule_set": "geoip-cn", + "outbound": "direct" + }, + { + "ip_is_private": true, "outbound": "direct" }, { "rule_set": "geosite-category-ads-all", "outbound": "Ads" }, - { - "rule_set": "geosite-microsoft", - "outbound": "Microsoft" - }, { "rule_set": "geosite-bilibili", "outbound": "Bilibili" @@ -203,13 +207,6 @@ "default": "block", "interrupt_exist_connections": true }, - { - "type": "selector", - "tag": "Microsoft", - "outbounds": ["节点选择", "", "direct"], - "default": "节点选择", - "interrupt_exist_connections": true - }, { "type": "selector", "tag": "Bilibili", diff --git a/templates/tun-without-dns-leaks-country-group.json b/templates/tun-with-country-group.json similarity index 94% rename from templates/tun-without-dns-leaks-country-group.json rename to templates/tun-with-country-group.json index 93ca876..22bb6cc 100644 --- a/templates/tun-without-dns-leaks-country-group.json +++ b/templates/tun-with-country-group.json @@ -129,21 +129,25 @@ "outbound": "dns-out" }, { - "ip_is_private": true, + "rule_set": "geosite-geolocation-!cn", + "outbound": "节点选择" + }, + { + "rule_set": "geosite-geolocation-cn", "outbound": "direct" }, { - "rule_set": ["geoip-cn", "geosite-geolocation-cn"], + "rule_set": "geoip-cn", + "outbound": "direct" + }, + { + "ip_is_private": true, "outbound": "direct" }, { "rule_set": "geosite-category-ads-all", "outbound": "Ads" }, - { - "rule_set": "geosite-microsoft", - "outbound": "Microsoft" - }, { "rule_set": "geosite-bilibili", "outbound": "Bilibili" @@ -189,13 +193,6 @@ "default": "block", "interrupt_exist_connections": true }, - { - "type": "selector", - "tag": "Microsoft", - "outbounds": ["节点选择", "", "direct"], - "default": "节点选择", - "interrupt_exist_connections": true - }, { "type": "selector", "tag": "Bilibili", diff --git a/templates/tun-with-dns-leaks.json b/templates/tun-with-dns-leaks.json deleted file mode 100644 index 3db9a90..0000000 --- a/templates/tun-with-dns-leaks.json +++ /dev/null @@ -1,233 +0,0 @@ -{ - "log": { - "level": "info", - "timestamp": true - }, - "dns": { - "servers": [ - { - "tag": "google", - "address": "tls://8.8.8.8" - }, - { - "tag": "local", - "address": "https://223.5.5.5/dns-query", - "detour": "direct" - } - ], - "rules": [ - { - "outbound": "any", - "server": "local" - }, - { - "clash_mode": "Direct", - "server": "local" - }, - { - "clash_mode": "Global", - "server": "google" - }, - { - "rule_set": "geosite-geolocation-cn", - "server": "local" - } - ] - }, - "route": { - "rule_set": [ - { - "tag": "geosite-geolocation-cn", - "type": "remote", - "format": "binary", - "url": "https://raw.githubusercontent.com/SagerNet/sing-geosite/rule-set/geosite-geolocation-cn.srs", - "download_detour": "节点选择" - }, - { - "tag": "geosite-geolocation-!cn", - "type": "remote", - "format": "binary", - "url": "https://raw.githubusercontent.com/SagerNet/sing-geosite/rule-set/geosite-geolocation-!cn.srs", - "download_detour": "节点选择" - }, - { - "tag": "geoip-cn", - "type": "remote", - "format": "binary", - "url": "https://raw.githubusercontent.com/SagerNet/sing-geoip/rule-set/geoip-cn.srs", - "download_detour": "节点选择" - }, - { - "tag": "geosite-category-ads-all", - "type": "remote", - "format": "binary", - "url": "https://raw.githubusercontent.com/SagerNet/sing-geosite/rule-set/geosite-category-ads-all.srs", - "download_detour": "节点选择" - }, - { - "tag": "geosite-microsoft", - "type": "remote", - "format": "binary", - "url": "https://raw.githubusercontent.com/SagerNet/sing-geosite/rule-set/geosite-microsoft.srs", - "download_detour": "节点选择" - }, - { - "tag": "geosite-bilibili", - "type": "remote", - "format": "binary", - "url": "https://raw.githubusercontent.com/SagerNet/sing-geosite/rule-set/geosite-bilibili.srs", - "download_detour": "节点选择" - }, - { - "tag": "geosite-bahamut", - "type": "remote", - "format": "binary", - "url": "https://raw.githubusercontent.com/SagerNet/sing-geosite/rule-set/geosite-bahamut.srs", - "download_detour": "节点选择" - }, - { - "tag": "geosite-category-games@cn", - "type": "remote", - "format": "binary", - "url": "https://raw.githubusercontent.com/SagerNet/sing-geosite/rule-set/geosite-category-games@cn.srs", - "download_detour": "节点选择" - }, - { - "tag": "geosite-category-games", - "type": "remote", - "format": "binary", - "url": "https://raw.githubusercontent.com/SagerNet/sing-geosite/rule-set/geosite-category-games.srs", - "download_detour": "节点选择" - } - ], - "rules": [ - { - "type": "logical", - "mode": "or", - "rules": [ - { - "protocol": "dns" - }, - { - "port": 53 - } - ], - "outbound": "dns-out" - }, - { - "ip_is_private": true, - "outbound": "direct" - }, - { - "rule_set": ["geoip-cn", "geosite-geolocation-cn"], - "outbound": "direct" - }, - { - "rule_set": "geosite-category-ads-all", - "outbound": "Ads" - }, - { - "rule_set": "geosite-microsoft", - "outbound": "Microsoft" - }, - { - "rule_set": "geosite-bilibili", - "outbound": "Bilibili" - }, - { - "rule_set": "geosite-category-games@cn", - "outbound": "Games(中国)" - }, - { - "rule_set": "geosite-category-games", - "outbound": "Games(全球)" - }, - { - "rule_set": "geosite-bahamut", - "outbound": "Bahamut" - } - ], - "final": "节点选择", - "auto_detect_interface": true - }, - "inbounds": [ - { - "type": "tun", - "inet4_address": "172.19.0.1/30", - "inet6_address": "fdfe:dcba:9876::1/126", - "auto_route": true, - "strict_route": false, - "sniff": true, - "sniff_override_destination": false - } - ], - "outbounds": [ - { - "type": "selector", - "tag": "节点选择", - "outbounds": ["", "direct"], - "interrupt_exist_connections": true - }, - { - "type": "selector", - "tag": "Ads", - "outbounds": ["direct", "block"], - "default": "block", - "interrupt_exist_connections": true - }, - { - "type": "selector", - "tag": "Microsoft", - "outbounds": ["节点选择", "", "direct"], - "default": "节点选择", - "interrupt_exist_connections": true - }, - { - "type": "selector", - "tag": "Bilibili", - "outbounds": ["节点选择", "", "direct"], - "default": "direct", - "interrupt_exist_connections": true - }, - { - "type": "selector", - "tag": "Games(全球)", - "outbounds": ["节点选择", "", "direct"], - "default": "节点选择", - "interrupt_exist_connections": true - }, - { - "type": "selector", - "tag": "Games(中国)", - "outbounds": ["节点选择", "", "direct"], - "default": "direct", - "interrupt_exist_connections": true - }, - { - "type": "selector", - "tag": "Bahamut", - "outbounds": ["节点选择", "", "direct"], - "default": "节点选择", - "interrupt_exist_connections": true - }, - { - "type": "direct", - "tag": "direct" - }, - { - "type": "block", - "tag": "block" - }, - { - "type": "dns", - "tag": "dns-out" - } - ], - "experimental": { - "clash_api": { - "external_controller": "127.0.0.1:9090", - "external_ui": "./ui", - "external_ui_download_detour": "节点选择" - } - } -} diff --git a/templates/tun-without-dns-leaks.json b/templates/tun.json similarity index 94% rename from templates/tun-without-dns-leaks.json rename to templates/tun.json index 7236340..510e7a6 100644 --- a/templates/tun-without-dns-leaks.json +++ b/templates/tun.json @@ -129,21 +129,25 @@ "outbound": "dns-out" }, { - "ip_is_private": true, + "rule_set": "geosite-geolocation-!cn", + "outbound": "节点选择" + }, + { + "rule_set": "geosite-geolocation-cn", "outbound": "direct" }, { - "rule_set": ["geoip-cn", "geosite-geolocation-cn"], + "rule_set": "geoip-cn", + "outbound": "direct" + }, + { + "ip_is_private": true, "outbound": "direct" }, { "rule_set": "geosite-category-ads-all", "outbound": "Ads" }, - { - "rule_set": "geosite-microsoft", - "outbound": "Microsoft" - }, { "rule_set": "geosite-bilibili", "outbound": "Bilibili" @@ -189,13 +193,6 @@ "default": "block", "interrupt_exist_connections": true }, - { - "type": "selector", - "tag": "Microsoft", - "outbounds": ["节点选择", "", "direct"], - "default": "节点选择", - "interrupt_exist_connections": true - }, { "type": "selector", "tag": "Bilibili",