diff --git a/api/handler/convert.go b/api/handler/convert.go
index 79a2fe7..d847e1b 100644
--- a/api/handler/convert.go
+++ b/api/handler/convert.go
@@ -45,7 +45,6 @@ func Convert(c *gin.Context) {
data.Template,
data.Delete,
data.Rename,
- data.Group,
data.GroupType,
data.SortKey,
data.SortType,
diff --git a/api/static/index.html b/api/static/index.html
index fed8e47..7e1e04d 100644
--- a/api/static/index.html
+++ b/api/static/index.html
@@ -90,9 +90,6 @@
策略组
-
-
-
@@ -239,7 +236,6 @@
document.getElementsByName("rename_to[]")
).map((input) => input.value);
const output = document.getElementById("output");
- const group = document.getElementById("group").checked;
const groupType = document.getElementById("group-type").value;
const sort = document.getElementById("sort").value;
const sortType = document.getElementById("sort-type").value;
@@ -256,7 +252,6 @@
delete: deleteRule,
template,
rename,
- group,
"group-type": groupType,
sort,
"sort-type": sortType,
diff --git a/cmd/convert.go b/cmd/convert.go
index c999d62..834781d 100644
--- a/cmd/convert.go
+++ b/cmd/convert.go
@@ -56,7 +56,6 @@ func convertRun(cmd *cobra.Command, args []string) {
template,
delete,
rename,
- group,
groupType,
sortKey,
sortType,
@@ -121,9 +120,6 @@ func mergeConfig(cfg model.ConvertRequest) {
if len(rename) == 0 {
rename = cfg.Rename
}
- if !group {
- group = cfg.Group
- }
if groupType == "" {
groupType = cfg.GroupType
}
diff --git a/common/convert.go b/common/convert.go
index 8efa799..61e5de0 100644
--- a/common/convert.go
+++ b/common/convert.go
@@ -10,6 +10,7 @@ import (
"sort"
"strings"
+ "github.com/nitezs/sub2sing-box/constant"
C "github.com/nitezs/sub2sing-box/constant"
"github.com/nitezs/sub2sing-box/model"
"github.com/nitezs/sub2sing-box/parser"
@@ -19,10 +20,9 @@ import (
func Convert(
subscriptions []string,
proxies []string,
- template string,
+ templatePath string,
delete string,
rename map[string]string,
- group bool,
groupType string,
sortKey string,
sortType string,
@@ -83,11 +83,21 @@ func Convert(
}
}
}
- if group {
- outbounds = AddCountryGroup(outbounds, groupType, sortKey, sortType)
- }
- if template != "" {
- result, err = MergeTemplate(outbounds, template)
+
+ if templatePath != "" {
+ templateDate, err := ReadTemplate(templatePath)
+ if err != nil {
+ 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 {
return "", err
}
@@ -111,7 +121,7 @@ func AddCountryGroup(proxies []model.Outbound, groupType string, sortKey string,
group.SetOutbounds(append(group.GetOutbounds(), p.Tag))
newGroup[country] = group
} else {
- if groupType == C.TypeSelector {
+ if groupType == C.TypeSelector || groupType == "" {
newGroup[country] = model.Outbound{
Tag: country,
Type: groupType,
@@ -159,22 +169,16 @@ func AddCountryGroup(proxies []model.Outbound, groupType string, sortKey string,
return append(proxies, groups...)
}
-func MergeTemplate(outbounds []model.Outbound, template string) (string, error) {
- var config model.Config
+func ReadTemplate(template string) (string, error) {
+ var data string
var err error
- isNetworkFile, err := regexp.MatchString(`^https?://`, template)
- if err != nil {
- return "", err
- }
+ isNetworkFile, _ := regexp.MatchString(`^https?://`, template)
if isNetworkFile {
- data, err := util.Fetch(template, 3)
- if err != nil {
- return "", err
- }
- err = json.Unmarshal([]byte(data), &config)
+ data, err = util.Fetch(template, 3)
if err != nil {
return "", err
}
+ return data, nil
} else {
if !strings.Contains(template, string(filepath.Separator)) {
path := filepath.Join("templates", template)
@@ -182,11 +186,16 @@ func MergeTemplate(outbounds []model.Outbound, template string) (string, error)
template = path
}
}
- config, err = ReadTemplate(template)
+ dataBytes, err := os.ReadFile(template)
if err != nil {
return "", err
}
+ return string(dataBytes), nil
}
+}
+
+func MergeTemplate(outbounds []model.Outbound, template *model.Config) (string, error) {
+ var err error
proxyTags := make([]string, 0)
groupTags := make([]string, 0)
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}>")
- for i, outbound := range config.Outbounds {
+ for i, outbound := range template.Outbounds {
if outbound.Type == C.TypeSelector || outbound.Type == C.TypeURLTest {
var parsedOutbound []string = make([]string, 0)
for _, o := range outbound.GetOutbounds() {
- if o == "
" {
+ if o == constant.AllProxyTags {
parsedOutbound = append(parsedOutbound, proxyTags...)
- } else if o == "" {
+ } else if o == constant.AllCountryTags {
parsedOutbound = append(parsedOutbound, groupTags...)
} else if reg.MatchString(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)
}
}
- config.Outbounds[i].SetOutbounds(parsedOutbound)
+ template.Outbounds[i].SetOutbounds(parsedOutbound)
}
}
- config.Outbounds = append(config.Outbounds, outbounds...)
- data, err := json.Marshal(config)
+ template.Outbounds = append(template.Outbounds, outbounds...)
+ data, err := json.Marshal(template)
if err != nil {
return "", err
}
@@ -296,19 +305,6 @@ func ConvertSubscriptionsToJson(urls []string) (string, error) {
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) {
reg, err := regexp.Compile(regex)
if err != nil {
diff --git a/constant/placeholder.go b/constant/placeholder.go
new file mode 100644
index 0000000..61bf4ed
--- /dev/null
+++ b/constant/placeholder.go
@@ -0,0 +1,6 @@
+package constant
+
+const (
+ AllCountryTags = ""
+ AllProxyTags = ""
+)
diff --git a/templates/tun-fakeip.json b/templates/example.json
similarity index 52%
rename from templates/tun-fakeip.json
rename to templates/example.json
index 50e5812..258680d 100644
--- a/templates/tun-fakeip.json
+++ b/templates/example.json
@@ -4,26 +4,17 @@
"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"
- }
- ],
+ "independent_cache": true,
+ "fakeip": {
+ "enabled": true,
+ "inet4_range": "198.18.0.0/15",
+ "inet6_range": "fc00::/18"
+ },
+ "strategy": "prefer_ipv4",
"rules": [
{
"outbound": "any",
- "server": "local",
- "disable_cache": true
+ "server": "local"
},
{
"clash_mode": "Direct",
@@ -57,79 +48,54 @@
"server": "fakeip"
}
],
- "fakeip": {
- "enabled": true,
- "inet4_range": "198.18.0.0/15",
- "inet6_range": "fc00::/18"
- },
- "independent_cache": true
- },
- "route": {
- "rule_set": [
+ "servers": [
{
- "tag": "geosite-geolocation-cn",
- "type": "remote",
- "format": "binary",
- "url": "https://raw.githubusercontent.com/SagerNet/sing-geosite/rule-set/geosite-geolocation-cn.srs",
- "download_detour": "节点选择"
+ "address": "tls://8.8.8.8",
+ "tag": "google"
},
{
- "tag": "geosite-geolocation-!cn",
- "type": "remote",
- "format": "binary",
- "url": "https://raw.githubusercontent.com/SagerNet/sing-geosite/rule-set/geosite-geolocation-!cn.srs",
- "download_detour": "节点选择"
+ "address": "https://223.5.5.5/dns-query",
+ "detour": "direct",
+ "tag": "local"
},
{
- "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": "节点选择"
+ "tag": "fakeip",
+ "address": "fakeip"
}
- ],
+ ]
+ },
+ "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": ["", "direct"],
+ "tag": "default",
+ "type": "selector"
+ },
+ {
+ "tag": "direct",
+ "type": "direct"
+ },
+ {
+ "tag": "block",
+ "type": "block"
+ },
+ {
+ "tag": "dns",
+ "type": "dns"
+ }
+ ],
+ "route": {
"rules": [
{
"type": "logical",
@@ -142,125 +108,123 @@
"port": 53
}
],
- "outbound": "dns-out"
- },
- {
- "rule_set": "geosite-geolocation-!cn",
- "outbound": "节点选择"
- },
- {
- "rule_set": "geosite-geolocation-cn",
- "outbound": "direct"
- },
- {
- "rule_set": "geoip-cn",
- "outbound": "direct"
+ "outbound": "dns"
},
{
"ip_is_private": true,
"outbound": "direct"
},
{
- "rule_set": "geosite-category-ads-all",
- "outbound": "Ads"
+ "clash_mode": "Direct",
+ "outbound": "direct"
},
{
- "rule_set": "geosite-bilibili",
- "outbound": "Bilibili"
+ "clash_mode": "Global",
+ "outbound": "default"
},
{
- "rule_set": "geosite-category-games@cn",
- "outbound": "Games(中国)"
+ "type": "logical",
+ "mode": "or",
+ "rules": [
+ {
+ "port": 853
+ },
+ {
+ "network": "udp",
+ "port": 443
+ },
+ {
+ "protocol": "stun"
+ }
+ ],
+ "outbound": "block"
},
{
- "rule_set": "geosite-category-games",
- "outbound": "Games(全球)"
+ "rule_set": ["geosite-category-games@cn"],
+ "outbound": "direct"
},
{
- "rule_set": "geosite-bahamut",
- "outbound": "Bahamut"
+ "rule_set": [
+ "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
},
- "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": ["", "direct"],
- "interrupt_exist_connections": true
- },
- {
- "type": "selector",
- "tag": "Ads",
- "outbounds": ["direct", "block"],
- "default": "block",
- "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": {
"cache_file": {
- "enabled": true,
- "store_rdrc": true
+ "enabled": false
},
"clash_api": {
"default_mode": "Enhanced",
"external_controller": "127.0.0.1:9090",
"external_ui": "./ui",
- "external_ui_download_detour": "节点选择"
+ "external_ui_download_detour": "default"
}
}
}
diff --git a/templates/http+socks.json b/templates/http+socks.json
deleted file mode 100644
index 3764acb..0000000
--- a/templates/http+socks.json
+++ /dev/null
@@ -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": ["", "direct"],
- "interrupt_exist_connections": true
- },
- {
- "type": "selector",
- "tag": "Ads",
- "outbounds": ["direct", "block"],
- "default": "block",
- "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": {
- "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": "节点选择"
- }
- }
-}
diff --git a/templates/tun-fakeip-with-country-group.json b/templates/tun-fakeip-with-country-group.json
deleted file mode 100644
index 217225a..0000000
--- a/templates/tun-fakeip-with-country-group.json
+++ /dev/null
@@ -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": ["", "direct"],
- "interrupt_exist_connections": true
- },
- {
- "type": "selector",
- "tag": "Ads",
- "outbounds": ["direct", "block"],
- "default": "block",
- "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": {
- "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": "节点选择"
- }
- }
-}
diff --git a/templates/tun-with-country-group.json b/templates/tun-with-country-group.json
deleted file mode 100644
index 22bb6cc..0000000
--- a/templates/tun-with-country-group.json
+++ /dev/null
@@ -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": ["", "direct"],
- "interrupt_exist_connections": true
- },
- {
- "type": "selector",
- "tag": "Ads",
- "outbounds": ["direct", "block"],
- "default": "block",
- "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": {
- "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": "节点选择"
- }
- }
-}
diff --git a/templates/tun.json b/templates/tun.json
deleted file mode 100644
index 510e7a6..0000000
--- a/templates/tun.json
+++ /dev/null
@@ -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": ["", "direct"],
- "interrupt_exist_connections": true
- },
- {
- "type": "selector",
- "tag": "Ads",
- "outbounds": ["direct", "block"],
- "default": "block",
- "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": {
- "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": "节点选择"
- }
- }
-}