1
0
mirror of https://github.com/nitezs/sub2sing-box.git synced 2024-12-23 14:44:42 -05:00

Auto detect if need country group

This commit is contained in:
Nite07 2024-10-01 01:27:22 +08:00
parent a1dcc1867f
commit 59a258f4ef
10 changed files with 183 additions and 1239 deletions

View File

@ -45,7 +45,6 @@ func Convert(c *gin.Context) {
data.Template, data.Template,
data.Delete, data.Delete,
data.Rename, data.Rename,
data.Group,
data.GroupType, data.GroupType,
data.SortKey, data.SortKey,
data.SortType, data.SortType,

View File

@ -90,9 +90,6 @@
<!-- Policy Group Section --> <!-- Policy Group Section -->
<div class="section"> <div class="section">
<h3>策略组</h3> <h3>策略组</h3>
<div>
<label><mdui-checkbox type="checkbox" id="group" name="group" />启用</label>
</div>
<div> <div>
<mdui-text-field label="类型" type="text" id="group-type" name="group-type" value="selector" /> <mdui-text-field label="类型" type="text" id="group-type" name="group-type" value="selector" />
</div> </div>
@ -239,7 +236,6 @@
document.getElementsByName("rename_to[]") document.getElementsByName("rename_to[]")
).map((input) => input.value); ).map((input) => input.value);
const output = document.getElementById("output"); const output = document.getElementById("output");
const group = document.getElementById("group").checked;
const groupType = document.getElementById("group-type").value; const groupType = document.getElementById("group-type").value;
const sort = document.getElementById("sort").value; const sort = document.getElementById("sort").value;
const sortType = document.getElementById("sort-type").value; const sortType = document.getElementById("sort-type").value;
@ -256,7 +252,6 @@
delete: deleteRule, delete: deleteRule,
template, template,
rename, rename,
group,
"group-type": groupType, "group-type": groupType,
sort, sort,
"sort-type": sortType, "sort-type": sortType,

View File

@ -56,7 +56,6 @@ func convertRun(cmd *cobra.Command, args []string) {
template, template,
delete, delete,
rename, rename,
group,
groupType, groupType,
sortKey, sortKey,
sortType, sortType,
@ -121,9 +120,6 @@ func mergeConfig(cfg model.ConvertRequest) {
if len(rename) == 0 { if len(rename) == 0 {
rename = cfg.Rename rename = cfg.Rename
} }
if !group {
group = cfg.Group
}
if groupType == "" { if groupType == "" {
groupType = cfg.GroupType groupType = cfg.GroupType
} }

View File

@ -10,6 +10,7 @@ import (
"sort" "sort"
"strings" "strings"
"github.com/nitezs/sub2sing-box/constant"
C "github.com/nitezs/sub2sing-box/constant" C "github.com/nitezs/sub2sing-box/constant"
"github.com/nitezs/sub2sing-box/model" "github.com/nitezs/sub2sing-box/model"
"github.com/nitezs/sub2sing-box/parser" "github.com/nitezs/sub2sing-box/parser"
@ -19,10 +20,9 @@ import (
func Convert( func Convert(
subscriptions []string, subscriptions []string,
proxies []string, proxies []string,
template string, templatePath string,
delete string, delete string,
rename map[string]string, rename map[string]string,
group bool,
groupType string, groupType string,
sortKey string, sortKey string,
sortType string, sortType string,
@ -83,11 +83,21 @@ func Convert(
} }
} }
} }
if group {
outbounds = AddCountryGroup(outbounds, groupType, sortKey, sortType) if templatePath != "" {
} templateDate, err := ReadTemplate(templatePath)
if template != "" { if err != nil {
result, err = MergeTemplate(outbounds, template) return "", err
}
reg := regexp.MustCompile("\"<[A-Za-z]{2}>\"")
if reg.MatchString(templateDate) || strings.Contains(templateDate, constant.AllCountryTags) {
outbounds = AddCountryGroup(outbounds, groupType, sortKey, sortType)
}
var template model.Config
if err = json.Unmarshal([]byte(templateDate), &template); err != nil {
return "", err
}
result, err = MergeTemplate(outbounds, &template)
if err != nil { if err != nil {
return "", err return "", err
} }
@ -111,7 +121,7 @@ func AddCountryGroup(proxies []model.Outbound, groupType string, sortKey string,
group.SetOutbounds(append(group.GetOutbounds(), p.Tag)) group.SetOutbounds(append(group.GetOutbounds(), p.Tag))
newGroup[country] = group newGroup[country] = group
} else { } else {
if groupType == C.TypeSelector { if groupType == C.TypeSelector || groupType == "" {
newGroup[country] = model.Outbound{ newGroup[country] = model.Outbound{
Tag: country, Tag: country,
Type: groupType, Type: groupType,
@ -159,22 +169,16 @@ func AddCountryGroup(proxies []model.Outbound, groupType string, sortKey string,
return append(proxies, groups...) return append(proxies, groups...)
} }
func MergeTemplate(outbounds []model.Outbound, template string) (string, error) { func ReadTemplate(template string) (string, error) {
var config model.Config var data string
var err error var err error
isNetworkFile, err := regexp.MatchString(`^https?://`, template) isNetworkFile, _ := regexp.MatchString(`^https?://`, template)
if err != nil {
return "", err
}
if isNetworkFile { if isNetworkFile {
data, err := util.Fetch(template, 3) data, err = util.Fetch(template, 3)
if err != nil {
return "", err
}
err = json.Unmarshal([]byte(data), &config)
if err != nil { if err != nil {
return "", err return "", err
} }
return data, nil
} else { } else {
if !strings.Contains(template, string(filepath.Separator)) { if !strings.Contains(template, string(filepath.Separator)) {
path := filepath.Join("templates", template) path := filepath.Join("templates", template)
@ -182,11 +186,16 @@ func MergeTemplate(outbounds []model.Outbound, template string) (string, error)
template = path template = path
} }
} }
config, err = ReadTemplate(template) dataBytes, err := os.ReadFile(template)
if err != nil { if err != nil {
return "", err return "", err
} }
return string(dataBytes), nil
} }
}
func MergeTemplate(outbounds []model.Outbound, template *model.Config) (string, error) {
var err error
proxyTags := make([]string, 0) proxyTags := make([]string, 0)
groupTags := make([]string, 0) groupTags := make([]string, 0)
groups := make(map[string]model.Outbound) groups := make(map[string]model.Outbound)
@ -201,13 +210,13 @@ func MergeTemplate(outbounds []model.Outbound, template string) (string, error)
} }
} }
reg := regexp.MustCompile("<[A-Za-z]{2}>") reg := regexp.MustCompile("<[A-Za-z]{2}>")
for i, outbound := range config.Outbounds { for i, outbound := range template.Outbounds {
if outbound.Type == C.TypeSelector || outbound.Type == C.TypeURLTest { if outbound.Type == C.TypeSelector || outbound.Type == C.TypeURLTest {
var parsedOutbound []string = make([]string, 0) var parsedOutbound []string = make([]string, 0)
for _, o := range outbound.GetOutbounds() { for _, o := range outbound.GetOutbounds() {
if o == "<all-proxy-tags>" { if o == constant.AllProxyTags {
parsedOutbound = append(parsedOutbound, proxyTags...) parsedOutbound = append(parsedOutbound, proxyTags...)
} else if o == "<all-country-tags>" { } else if o == constant.AllCountryTags {
parsedOutbound = append(parsedOutbound, groupTags...) parsedOutbound = append(parsedOutbound, groupTags...)
} else if reg.MatchString(o) { } else if reg.MatchString(o) {
country := strings.ToUpper(strings.Trim(reg.FindString(o), "<>")) country := strings.ToUpper(strings.Trim(reg.FindString(o), "<>"))
@ -218,11 +227,11 @@ func MergeTemplate(outbounds []model.Outbound, template string) (string, error)
parsedOutbound = append(parsedOutbound, o) parsedOutbound = append(parsedOutbound, o)
} }
} }
config.Outbounds[i].SetOutbounds(parsedOutbound) template.Outbounds[i].SetOutbounds(parsedOutbound)
} }
} }
config.Outbounds = append(config.Outbounds, outbounds...) template.Outbounds = append(template.Outbounds, outbounds...)
data, err := json.Marshal(config) data, err := json.Marshal(template)
if err != nil { if err != nil {
return "", err return "", err
} }
@ -296,19 +305,6 @@ func ConvertSubscriptionsToJson(urls []string) (string, error) {
return string(result), nil return string(result), nil
} }
func ReadTemplate(path string) (model.Config, error) {
data, err := os.ReadFile(path)
if err != nil {
return model.Config{}, err
}
var res model.Config
err = json.Unmarshal(data, &res)
if err != nil {
return model.Config{}, err
}
return res, nil
}
func DeleteProxy(proxies []model.Outbound, regex string) ([]model.Outbound, error) { func DeleteProxy(proxies []model.Outbound, regex string) ([]model.Outbound, error) {
reg, err := regexp.Compile(regex) reg, err := regexp.Compile(regex)
if err != nil { if err != nil {

6
constant/placeholder.go Normal file
View File

@ -0,0 +1,6 @@
package constant
const (
AllCountryTags = "<all-country-tags>"
AllProxyTags = "<all-proxy-tags>"
)

View File

@ -4,26 +4,17 @@
"timestamp": true "timestamp": true
}, },
"dns": { "dns": {
"servers": [ "independent_cache": true,
{ "fakeip": {
"tag": "google", "enabled": true,
"address": "tls://8.8.8.8" "inet4_range": "198.18.0.0/15",
}, "inet6_range": "fc00::/18"
{ },
"tag": "local", "strategy": "prefer_ipv4",
"address": "https://223.5.5.5/dns-query",
"detour": "direct"
},
{
"tag": "fakeip",
"address": "fakeip"
}
],
"rules": [ "rules": [
{ {
"outbound": "any", "outbound": "any",
"server": "local", "server": "local"
"disable_cache": true
}, },
{ {
"clash_mode": "Direct", "clash_mode": "Direct",
@ -57,79 +48,54 @@
"server": "fakeip" "server": "fakeip"
} }
], ],
"fakeip": { "servers": [
"enabled": true,
"inet4_range": "198.18.0.0/15",
"inet6_range": "fc00::/18"
},
"independent_cache": true
},
"route": {
"rule_set": [
{ {
"tag": "geosite-geolocation-cn", "address": "tls://8.8.8.8",
"type": "remote", "tag": "google"
"format": "binary",
"url": "https://raw.githubusercontent.com/SagerNet/sing-geosite/rule-set/geosite-geolocation-cn.srs",
"download_detour": "节点选择"
}, },
{ {
"tag": "geosite-geolocation-!cn", "address": "https://223.5.5.5/dns-query",
"type": "remote", "detour": "direct",
"format": "binary", "tag": "local"
"url": "https://raw.githubusercontent.com/SagerNet/sing-geosite/rule-set/geosite-geolocation-!cn.srs",
"download_detour": "节点选择"
}, },
{ {
"tag": "geoip-cn", "tag": "fakeip",
"type": "remote", "address": "fakeip"
"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": "节点选择"
} }
], ]
},
"inbounds": [
{
"type": "tun",
"inet4_address": "172.19.0.1/30",
"inet6_address": "fdfe:dcba:9876::1/126",
"auto_route": true,
"strict_route": true,
"inet4_route_exclude_address": ["100.64.0.0/10"],
"inet6_route_exclude_address": ["fd7a:115c:a1e0::/48"]
}
],
"outbounds": [
{
"interrupt_exist_connections": true,
"outbounds": ["<all-proxy-tags>", "direct"],
"tag": "default",
"type": "selector"
},
{
"tag": "direct",
"type": "direct"
},
{
"tag": "block",
"type": "block"
},
{
"tag": "dns",
"type": "dns"
}
],
"route": {
"rules": [ "rules": [
{ {
"type": "logical", "type": "logical",
@ -142,125 +108,123 @@
"port": 53 "port": 53
} }
], ],
"outbound": "dns-out" "outbound": "dns"
},
{
"rule_set": "geosite-geolocation-!cn",
"outbound": "节点选择"
},
{
"rule_set": "geosite-geolocation-cn",
"outbound": "direct"
},
{
"rule_set": "geoip-cn",
"outbound": "direct"
}, },
{ {
"ip_is_private": true, "ip_is_private": true,
"outbound": "direct" "outbound": "direct"
}, },
{ {
"rule_set": "geosite-category-ads-all", "clash_mode": "Direct",
"outbound": "Ads" "outbound": "direct"
}, },
{ {
"rule_set": "geosite-bilibili", "clash_mode": "Global",
"outbound": "Bilibili" "outbound": "default"
}, },
{ {
"rule_set": "geosite-category-games@cn", "type": "logical",
"outbound": "Games(中国)" "mode": "or",
"rules": [
{
"port": 853
},
{
"network": "udp",
"port": 443
},
{
"protocol": "stun"
}
],
"outbound": "block"
}, },
{ {
"rule_set": "geosite-category-games", "rule_set": ["geosite-category-games@cn"],
"outbound": "Games(全球)" "outbound": "direct"
}, },
{ {
"rule_set": "geosite-bahamut", "rule_set": [
"outbound": "Bahamut" "geosite-geolocation-cn",
"geosite-cn",
"geosite-category-games@cn",
"geosite-google@cn",
"geosite-google-play@cn",
"geosite-steam@cn"
],
"outbound": "direct"
} }
], ],
"final": "节点选择", "rule_set": [
{
"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-google@cn",
"format": "binary",
"url": "https://raw.githubusercontent.com/SagerNet/sing-geosite/rule-set/geosite-google@cn.srs",
"download_detour": "default"
},
{
"type": "remote",
"tag": "geosite-google-play@cn",
"format": "binary",
"url": "https://raw.githubusercontent.com/SagerNet/sing-geosite/rule-set/geosite-google-play@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"
}
],
"final": "default",
"auto_detect_interface": true "auto_detect_interface": true
}, },
"inbounds": [
{
"auto_route": true,
"inet4_address": "172.19.0.1/30",
"inet6_address": "fdfe:dcba:9876::1/126",
"sniff": true,
"sniff_override_destination": true,
"strict_route": true,
"type": "tun",
"stack": "mixed"
}
],
"outbounds": [
{
"type": "selector",
"tag": "节点选择",
"outbounds": ["<all-proxy-tags>", "direct"],
"interrupt_exist_connections": true
},
{
"type": "selector",
"tag": "Ads",
"outbounds": ["direct", "block"],
"default": "block",
"interrupt_exist_connections": true
},
{
"type": "selector",
"tag": "Bilibili",
"outbounds": ["节点选择", "<all-proxy-tags>", "direct"],
"default": "direct",
"interrupt_exist_connections": true
},
{
"type": "selector",
"tag": "Games(全球)",
"outbounds": ["节点选择", "<all-proxy-tags>", "direct"],
"default": "节点选择",
"interrupt_exist_connections": true
},
{
"type": "selector",
"tag": "Games(中国)",
"outbounds": ["节点选择", "<all-proxy-tags>", "direct"],
"default": "direct",
"interrupt_exist_connections": true
},
{
"type": "selector",
"tag": "Bahamut",
"outbounds": ["节点选择", "<all-proxy-tags>", "direct"],
"default": "节点选择",
"interrupt_exist_connections": true
},
{
"type": "direct",
"tag": "direct"
},
{
"type": "block",
"tag": "block"
},
{
"type": "dns",
"tag": "dns-out"
}
],
"experimental": { "experimental": {
"cache_file": { "cache_file": {
"enabled": true, "enabled": false
"store_rdrc": true
}, },
"clash_api": { "clash_api": {
"default_mode": "Enhanced", "default_mode": "Enhanced",
"external_controller": "127.0.0.1:9090", "external_controller": "127.0.0.1:9090",
"external_ui": "./ui", "external_ui": "./ui",
"external_ui_download_detour": "节点选择" "external_ui_download_detour": "default"
} }
} }
} }

View File

@ -1,249 +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"
},
{
"type": "logical",
"mode": "and",
"rules": [
{
"rule_set": "geosite-geolocation-!cn"
},
{
"rule_set": "geoip-cn"
}
],
"server": "google",
"client_subnet": "114.114.114.114"
}
]
},
"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"
},
{
"rule_set": "geosite-geolocation-!cn",
"outbound": "节点选择"
},
{
"rule_set": "geosite-geolocation-cn",
"outbound": "direct"
},
{
"rule_set": "geoip-cn",
"outbound": "direct"
},
{
"ip_is_private": true,
"outbound": "direct"
},
{
"rule_set": "geosite-category-ads-all",
"outbound": "Ads"
},
{
"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": "mixed",
"tag": "mixed-in",
"listen": "::",
"listen_port": 5353,
"sniff": true,
"sniff_override_destination": false,
"set_system_proxy": false
}
],
"outbounds": [
{
"type": "selector",
"tag": "节点选择",
"outbounds": ["<all-proxy-tags>", "direct"],
"interrupt_exist_connections": true
},
{
"type": "selector",
"tag": "Ads",
"outbounds": ["direct", "block"],
"default": "block",
"interrupt_exist_connections": true
},
{
"type": "selector",
"tag": "Bilibili",
"outbounds": ["节点选择", "<all-proxy-tags>", "direct"],
"default": "direct",
"interrupt_exist_connections": true
},
{
"type": "selector",
"tag": "Games(全球)",
"outbounds": ["节点选择", "<all-proxy-tags>", "direct"],
"default": "节点选择",
"interrupt_exist_connections": true
},
{
"type": "selector",
"tag": "Games(中国)",
"outbounds": ["节点选择", "<all-proxy-tags>", "direct"],
"default": "direct",
"interrupt_exist_connections": true
},
{
"type": "selector",
"tag": "Bahamut",
"outbounds": ["节点选择", "<all-proxy-tags>", "direct"],
"default": "节点选择",
"interrupt_exist_connections": true
},
{
"type": "direct",
"tag": "direct"
},
{
"type": "block",
"tag": "block"
},
{
"type": "dns",
"tag": "dns-out"
}
],
"experimental": {
"cache_file": {
"enabled": true,
"store_rdrc": true
},
"clash_api": {
"default_mode": "Enhanced",
"external_controller": "127.0.0.1:9090",
"external_ui": "./ui",
"external_ui_download_detour": "节点选择"
}
}
}

View File

@ -1,265 +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": "fakeip",
"address": "fakeip"
}
],
"rules": [
{
"outbound": "any",
"server": "local",
"disable_cache": true
},
{
"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"
},
{
"query_type": ["A", "AAAA"],
"server": "fakeip"
}
],
"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"
},
{
"rule_set": "geosite-geolocation-!cn",
"outbound": "节点选择"
},
{
"rule_set": "geosite-geolocation-cn",
"outbound": "direct"
},
{
"rule_set": "geoip-cn",
"outbound": "direct"
},
{
"ip_is_private": true,
"outbound": "direct"
},
{
"rule_set": "geosite-category-ads-all",
"outbound": "Ads"
},
{
"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": ["<all-country-tags>", "direct"],
"interrupt_exist_connections": true
},
{
"type": "selector",
"tag": "Ads",
"outbounds": ["direct", "block"],
"default": "block",
"interrupt_exist_connections": true
},
{
"type": "selector",
"tag": "Bilibili",
"outbounds": ["节点选择", "<all-country-tags>", "direct"],
"default": "direct",
"interrupt_exist_connections": true
},
{
"type": "selector",
"tag": "Games(全球)",
"outbounds": ["节点选择", "<all-country-tags>", "direct"],
"default": "节点选择",
"interrupt_exist_connections": true
},
{
"type": "selector",
"tag": "Games(中国)",
"outbounds": ["节点选择", "<all-country-tags>", "direct"],
"default": "direct",
"interrupt_exist_connections": true
},
{
"type": "selector",
"tag": "Bahamut",
"outbounds": ["节点选择", "<all-country-tags>", "direct"],
"default": "节点选择",
"interrupt_exist_connections": true
},
{
"type": "direct",
"tag": "direct"
},
{
"type": "block",
"tag": "block"
},
{
"type": "dns",
"tag": "dns-out"
}
],
"experimental": {
"cache_file": {
"enabled": true,
"store_rdrc": true
},
"clash_api": {
"default_mode": "Enhanced",
"external_controller": "127.0.0.1:9090",
"external_ui": "./ui",
"external_ui_download_detour": "节点选择"
}
}
}

View File

@ -1,249 +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"
},
{
"type": "logical",
"mode": "and",
"rules": [
{
"rule_set": "geosite-geolocation-!cn"
},
{
"rule_set": "geoip-cn"
}
],
"server": "google",
"client_subnet": "114.114.114.114"
}
]
},
"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"
},
{
"rule_set": "geosite-geolocation-!cn",
"outbound": "节点选择"
},
{
"rule_set": "geosite-geolocation-cn",
"outbound": "direct"
},
{
"rule_set": "geoip-cn",
"outbound": "direct"
},
{
"ip_is_private": true,
"outbound": "direct"
},
{
"rule_set": "geosite-category-ads-all",
"outbound": "Ads"
},
{
"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": ["<all-country-tags>", "direct"],
"interrupt_exist_connections": true
},
{
"type": "selector",
"tag": "Ads",
"outbounds": ["direct", "block"],
"default": "block",
"interrupt_exist_connections": true
},
{
"type": "selector",
"tag": "Bilibili",
"outbounds": ["节点选择", "<all-country-tags>", "direct"],
"default": "direct",
"interrupt_exist_connections": true
},
{
"type": "selector",
"tag": "Games(全球)",
"outbounds": ["节点选择", "<all-country-tags>", "direct"],
"default": "节点选择",
"interrupt_exist_connections": true
},
{
"type": "selector",
"tag": "Games(中国)",
"outbounds": ["节点选择", "<all-country-tags>", "direct"],
"default": "direct",
"interrupt_exist_connections": true
},
{
"type": "selector",
"tag": "Bahamut",
"outbounds": ["节点选择", "<all-country-tags>", "direct"],
"default": "节点选择",
"interrupt_exist_connections": true
},
{
"type": "direct",
"tag": "direct"
},
{
"type": "block",
"tag": "block"
},
{
"type": "dns",
"tag": "dns-out"
}
],
"experimental": {
"cache_file": {
"enabled": true,
"store_rdrc": true
},
"clash_api": {
"default_mode": "Enhanced",
"external_controller": "127.0.0.1:9090",
"external_ui": "./ui",
"external_ui_download_detour": "节点选择"
}
}
}

View File

@ -1,249 +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"
},
{
"type": "logical",
"mode": "and",
"rules": [
{
"rule_set": "geosite-geolocation-!cn"
},
{
"rule_set": "geoip-cn"
}
],
"server": "google",
"client_subnet": "114.114.114.114"
}
]
},
"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"
},
{
"rule_set": "geosite-geolocation-!cn",
"outbound": "节点选择"
},
{
"rule_set": "geosite-geolocation-cn",
"outbound": "direct"
},
{
"rule_set": "geoip-cn",
"outbound": "direct"
},
{
"ip_is_private": true,
"outbound": "direct"
},
{
"rule_set": "geosite-category-ads-all",
"outbound": "Ads"
},
{
"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": ["<all-proxy-tags>", "direct"],
"interrupt_exist_connections": true
},
{
"type": "selector",
"tag": "Ads",
"outbounds": ["direct", "block"],
"default": "block",
"interrupt_exist_connections": true
},
{
"type": "selector",
"tag": "Bilibili",
"outbounds": ["节点选择", "<all-proxy-tags>", "direct"],
"default": "direct",
"interrupt_exist_connections": true
},
{
"type": "selector",
"tag": "Games(全球)",
"outbounds": ["节点选择", "<all-proxy-tags>", "direct"],
"default": "节点选择",
"interrupt_exist_connections": true
},
{
"type": "selector",
"tag": "Games(中国)",
"outbounds": ["节点选择", "<all-proxy-tags>", "direct"],
"default": "direct",
"interrupt_exist_connections": true
},
{
"type": "selector",
"tag": "Bahamut",
"outbounds": ["节点选择", "<all-proxy-tags>", "direct"],
"default": "节点选择",
"interrupt_exist_connections": true
},
{
"type": "direct",
"tag": "direct"
},
{
"type": "block",
"tag": "block"
},
{
"type": "dns",
"tag": "dns-out"
}
],
"experimental": {
"cache_file": {
"enabled": true,
"store_rdrc": true
},
"clash_api": {
"default_mode": "Enhanced",
"external_controller": "127.0.0.1:9090",
"external_ui": "./ui",
"external_ui_download_detour": "节点选择"
}
}
}