diff --git a/.gitignore b/.gitignore index da2ac96..68d6a21 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ -.vscode +.vscode/launch.json dist *test.go template.json \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..358c602 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,21 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "build", + "type": "shell", + "command": "go", + "args": [ + "build", + "-ldflags='-s -w'", + "-o", + "${workspaceFolder}/dist/sub2sing-box.exe", + "${workspaceFolder}/main.go" + ], + "group": { + "kind": "build", + "isDefault": true + } + } + ] +} diff --git a/template/tun-fakeip.json b/template/tun-fakeip.json new file mode 100644 index 0000000..d38dcc1 --- /dev/null +++ b/template/tun-fakeip.json @@ -0,0 +1,234 @@ +{ + "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" + } + ], + "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": "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" + }, + { + "protocol": "dns", + "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 + } + ], + "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": "节点选择", + "interrupt_exist_connections": true + }, + { + "type": "selector", + "tag": "Games(全球)", + "outbounds": ["节点选择", "手动切换", "", "direct"], + "default": "节点选择", + "interrupt_exist_connections": true + }, + { + "type": "selector", + "tag": "Games(中国)", + "outbounds": ["节点选择", "手动切换", "", "direct"], + "default": "节点选择", + "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, + "path": "cache.db" + }, + "clash_api": { + "external_controller": "127.0.0.1:9090", + "external_ui": "./ui", + "external_ui_download_detour": "手动切换" + } + } +}