mirror of
https://github.com/Dichgrem/singbox-example.git
synced 2025-12-18 12:31:59 -05:00
Compare commits
15 Commits
0b5f0408ce
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
04ce288ebc | ||
|
|
b734d178be | ||
|
|
22ac82223c | ||
|
|
db26e0df53 | ||
|
|
f68d592b18 | ||
|
|
54b4a998f5 | ||
|
|
ae11f4d057 | ||
|
|
b33f2bdaa1 | ||
|
|
f4fc4d3e29 | ||
|
|
79a2963043 | ||
|
|
b4bf29dc04 | ||
|
|
26e7216f66 | ||
|
|
d8d8962df1 | ||
|
|
053fd95952 | ||
|
|
67e1af851c |
@@ -4,7 +4,11 @@ Sing-box 是一个现代、高性能、功能强大的跨平台代理核心,
|
||||
|
||||
本仓库主要包括singbox示例配置以及快速,智能的部署脚本,可以一键部署以下协议并给出标准链接,具体实现见手动安装部分.
|
||||
|
||||
- 手动安装:见 [Hysteria2](https://github.com/Dichgrem/singbox-example/blob/main/hysteria2.md) / [Reality](https://github.com/Dichgrem/singbox-example/blob/main/singbox.md)
|
||||
<p align="center">
|
||||
<img src="https://github.com/Dichgrem/singbox-example/blob/main/run.png" width="400">
|
||||
</p>
|
||||
|
||||
- 手动安装:见 [Hysteria2](https://github.com/Dichgrem/singbox-example/blob/main/tutorial/hysteria2.md) / [Reality](https://github.com/Dichgrem/singbox-example/blob/main/tutorial/singbox.md)
|
||||
- 全自动安装Reality:
|
||||
``wget https://raw.githubusercontent.com/Dichgrem/singbox-example/refs/heads/main/script/singbox.sh``,随后``bash ./singbox.sh``
|
||||
- 全自动安装Hysteria2:
|
||||
|
||||
@@ -1,108 +0,0 @@
|
||||
{
|
||||
"dns":
|
||||
{
|
||||
"independent_cache": true,
|
||||
"rules":
|
||||
[
|
||||
{ "outbound": "any", "server": "dns-direct" },
|
||||
{ "query_type": [32, 33], "server": "dns-block" },
|
||||
{ "domain_suffix": ".lan", "server": "dns-block" },
|
||||
],
|
||||
"servers":
|
||||
[
|
||||
{
|
||||
"address": "https://8.8.8.8/dns-query",
|
||||
"address_resolver": "dns-local",
|
||||
"detour": "proxy",
|
||||
"strategy": "",
|
||||
"tag": "dns-remote",
|
||||
},
|
||||
{
|
||||
"address": "local",
|
||||
"address_resolver": "dns-local",
|
||||
"detour": "direct",
|
||||
"strategy": "",
|
||||
"tag": "dns-direct",
|
||||
},
|
||||
{ "address": "rcode://success", "tag": "dns-block" },
|
||||
{ "address": "local", "detour": "direct", "tag": "dns-local" },
|
||||
],
|
||||
},
|
||||
"inbounds":
|
||||
[
|
||||
{
|
||||
"domain_strategy": "",
|
||||
"listen": "127.0.0.1",
|
||||
"listen_port": 2080,
|
||||
"sniff": true,
|
||||
"sniff_override_destination": false,
|
||||
"tag": "mixed-in",
|
||||
"type": "mixed",
|
||||
},
|
||||
],
|
||||
"log": { "level": "info" },
|
||||
"outbounds":
|
||||
[
|
||||
{
|
||||
"domain_strategy": "",
|
||||
"flow": "xtls-rprx-vision",
|
||||
"packet_encoding": "",
|
||||
"server": "服务器IP",
|
||||
"server_port": 443,
|
||||
"tag": "proxy",
|
||||
"tls":
|
||||
{
|
||||
"enabled": true,
|
||||
"reality":
|
||||
{
|
||||
"enabled": true,
|
||||
"public_key": "singbox生成公钥",
|
||||
"short_id": "singbox生成ID",
|
||||
},
|
||||
"server_name": "yahoo.com",
|
||||
"utls": { "enabled": true, "fingerprint": "chrome" },
|
||||
},
|
||||
"type": "vless",
|
||||
"uuid": "singbox生成UUID",
|
||||
},
|
||||
{ "tag": "direct", "type": "direct" },
|
||||
{ "tag": "bypass", "type": "direct" },
|
||||
{ "tag": "block", "type": "block" },
|
||||
{ "tag": "dns-out", "type": "dns" },
|
||||
],
|
||||
"route":
|
||||
{
|
||||
"final": "proxy",
|
||||
"rules":
|
||||
[
|
||||
{ "outbound": "dns-out", "protocol": "dns" },
|
||||
{
|
||||
"domain": [],
|
||||
"domain_keyword": [],
|
||||
"domain_regex": [],
|
||||
"domain_suffix": ["appcenter.ms", "firebase.io", "crashlytics.com"],
|
||||
"geosite": ["category-ads-all"],
|
||||
"outbound": "block",
|
||||
},
|
||||
{
|
||||
"domain": [],
|
||||
"domain_keyword": [],
|
||||
"domain_regex": [],
|
||||
"domain_suffix": [],
|
||||
"geosite": ["cn"],
|
||||
"outbound": "bypass",
|
||||
},
|
||||
{ "geoip": ["cn", "private"], "ip_cidr": [], "outbound": "bypass" },
|
||||
{
|
||||
"network": "udp",
|
||||
"outbound": "block",
|
||||
"port": [135, 137, 138, 139, 5353],
|
||||
},
|
||||
{ "ip_cidr": ["224.0.0.0/3", "ff00::/8"], "outbound": "block" },
|
||||
{
|
||||
"outbound": "block",
|
||||
"source_ip_cidr": ["224.0.0.0/3", "ff00::/8"],
|
||||
},
|
||||
],
|
||||
},
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
[
|
||||
{
|
||||
"tag": "Jp-100G",
|
||||
"type": "vless",
|
||||
"server": "服务器IP",
|
||||
"server_port": 443,
|
||||
"uuid": "singbox生成UUID",
|
||||
"tls":
|
||||
{
|
||||
"enabled": true,
|
||||
"server_name": "icloud.com",
|
||||
"insecure": false,
|
||||
"reality":
|
||||
{
|
||||
"enabled": true,
|
||||
"public_key": "singbox生成公钥",
|
||||
"short_id": "singbox生成ID",
|
||||
},
|
||||
"utls": { "enabled": true, "fingerprint": "chrome" },
|
||||
},
|
||||
"flow": "xtls-rprx-vision",
|
||||
},
|
||||
]
|
||||
|
||||
@@ -1,62 +0,0 @@
|
||||
{
|
||||
"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" },
|
||||
{ "clash_mode": "Default", "server": "google" },
|
||||
{
|
||||
"type": "logical",
|
||||
"mode": "and",
|
||||
"rules":
|
||||
[
|
||||
{ "rule_set": "geosite-geolocation-!cn", "invert": true },
|
||||
{ "rule_set": "geoip-cn" },
|
||||
],
|
||||
"server": "local",
|
||||
},
|
||||
],
|
||||
},
|
||||
"route":
|
||||
{
|
||||
"rule_set":
|
||||
[
|
||||
{
|
||||
"type": "remote",
|
||||
"tag": "geosite-geolocation-cn",
|
||||
"format": "binary",
|
||||
"url": "https://raw.githubusercontent.com/SagerNet/sing-geosite/rule-set/geosite-geolocation-cn.srs",
|
||||
},
|
||||
{
|
||||
"type": "remote",
|
||||
"tag": "geosite-geolocation-!cn",
|
||||
"format": "binary",
|
||||
"url": "https://raw.githubusercontent.com/SagerNet/sing-geosite/rule-set/geosite-geolocation-!cn.srs",
|
||||
},
|
||||
{
|
||||
"type": "remote",
|
||||
"tag": "geoip-cn",
|
||||
"format": "binary",
|
||||
"url": "https://raw.githubusercontent.com/SagerNet/sing-geoip/rule-set/geoip-cn.srs",
|
||||
},
|
||||
],
|
||||
},
|
||||
"experimental":
|
||||
{
|
||||
"cache_file": { "enabled": true, "store_rdrc": true },
|
||||
"clash_api": { "default_mode": "Enhanced" },
|
||||
},
|
||||
}
|
||||
|
||||
@@ -1,61 +0,0 @@
|
||||
{
|
||||
"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", "invert": true },
|
||||
{ "rule_set": "geoip-cn" },
|
||||
],
|
||||
"server": "google",
|
||||
"client_subnet": "114.114.114.114/24", #Any China client IP address
|
||||
},
|
||||
],
|
||||
},
|
||||
"route":
|
||||
{
|
||||
"rule_set":
|
||||
[
|
||||
{
|
||||
"type": "remote",
|
||||
"tag": "geosite-geolocation-cn",
|
||||
"format": "binary",
|
||||
"url": "https://raw.githubusercontent.com/SagerNet/sing-geosite/rule-set/geosite-geolocation-cn.srs",
|
||||
},
|
||||
{
|
||||
"type": "remote",
|
||||
"tag": "geosite-geolocation-!cn",
|
||||
"format": "binary",
|
||||
"url": "https://raw.githubusercontent.com/SagerNet/sing-geosite/rule-set/geosite-geolocation-!cn.srs",
|
||||
},
|
||||
{
|
||||
"type": "remote",
|
||||
"tag": "geoip-cn",
|
||||
"format": "binary",
|
||||
"url": "https://raw.githubusercontent.com/SagerNet/sing-geoip/rule-set/geoip-cn.srs",
|
||||
},
|
||||
],
|
||||
},
|
||||
"experimental":
|
||||
{
|
||||
"cache_file": { "enabled": true, "store_rdrc": true },
|
||||
"clash_api": { "default_mode": "Enhanced" },
|
||||
},
|
||||
}
|
||||
|
||||
@@ -1,48 +0,0 @@
|
||||
{
|
||||
"dns":
|
||||
{
|
||||
"servers":
|
||||
[
|
||||
{ "tag": "google", "address": "tls://8.8.8.8" },
|
||||
{ "tag": "local", "address": "223.5.5.5", "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,
|
||||
},
|
||||
"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": "direct", "tag": "direct" },
|
||||
{ "type": "dns", "tag": "dns-out" },
|
||||
],
|
||||
"route":
|
||||
{
|
||||
"rules":
|
||||
[
|
||||
{ "protocol": "dns", "outbound": "dns-out" },
|
||||
{ "geoip": ["private"], "outbound": "direct" },
|
||||
],
|
||||
"auto_detect_interface": true,
|
||||
},
|
||||
} #
|
||||
|
||||
@@ -1,53 +0,0 @@
|
||||
{
|
||||
"outbounds":
|
||||
[
|
||||
{ "type": "direct", "tag": "direct" },
|
||||
{ "type": "block", "tag": "block" },
|
||||
],
|
||||
"route":
|
||||
{
|
||||
"rules":
|
||||
[
|
||||
{
|
||||
"type": "logical",
|
||||
"mode": "or",
|
||||
"rules": [{ "protocol": "dns" }, { "port": 53 }],
|
||||
"outbound": "dns",
|
||||
},
|
||||
{ "ip_is_private": true, "outbound": "direct" },
|
||||
{ "clash_mode": "Direct", "outbound": "direct" },
|
||||
{ "clash_mode": "Global", "outbound": "default" },
|
||||
{
|
||||
"type": "logical",
|
||||
"mode": "or",
|
||||
"rules":
|
||||
[
|
||||
{ "port": 853 },
|
||||
{ "network": "udp", "port": 443 },
|
||||
{ "protocol": "stun" },
|
||||
],
|
||||
"outbound": "block",
|
||||
},
|
||||
{
|
||||
"rule_set": ["geoip-cn", "geosite-geolocation-cn"],
|
||||
"outbound": "direct",
|
||||
},
|
||||
],
|
||||
"rule_set":
|
||||
[
|
||||
{
|
||||
"type": "remote",
|
||||
"tag": "geoip-cn",
|
||||
"format": "binary",
|
||||
"url": "https://raw.githubusercontent.com/SagerNet/sing-geoip/rule-set/geoip-cn.srs",
|
||||
},
|
||||
{
|
||||
"type": "remote",
|
||||
"tag": "geosite-geolocation-cn",
|
||||
"format": "binary",
|
||||
"url": "https://raw.githubusercontent.com/SagerNet/sing-geosite/rule-set/geosite-geolocation-cn.srs",
|
||||
},
|
||||
],
|
||||
},
|
||||
}
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
{
|
||||
"dns":
|
||||
{
|
||||
"servers":
|
||||
[
|
||||
{ "tag": "google", "address": "tls://8.8.8.8" },
|
||||
{ "tag": "local", "address": "223.5.5.5", "detour": "direct" },
|
||||
],
|
||||
"rules": [{ "outbound": "any", "server": "local" }],
|
||||
},
|
||||
"inbounds":
|
||||
[
|
||||
{
|
||||
"type": "tun",
|
||||
"inet4_address": "172.19.0.1/30",
|
||||
"inet6_address": "fdfe:dcba:9876::1/126",
|
||||
"auto_route": true,
|
||||
"strict_route": false,
|
||||
},
|
||||
],
|
||||
"outbounds": [
|
||||
# // ...
|
||||
{ "type": "direct", "tag": "direct" },
|
||||
{ "type": "dns", "tag": "dns-out" },
|
||||
],
|
||||
"route":
|
||||
{
|
||||
"rules":
|
||||
[
|
||||
{ "protocol": "dns", "outbound": "dns-out" },
|
||||
{ "geoip": ["private"], "outbound": "direct" },
|
||||
],
|
||||
"auto_detect_interface": true,
|
||||
},
|
||||
} #
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
{
|
||||
"dns":
|
||||
{
|
||||
"servers":
|
||||
[
|
||||
{ "tag": "google", "address": "tls://8.8.8.8" },
|
||||
{ "tag": "local", "address": "223.5.5.5", "detour": "direct" },
|
||||
],
|
||||
"rules": [{ "outbound": "any", "server": "local" }],
|
||||
"strategy": "ipv4_only",
|
||||
},
|
||||
"inbounds":
|
||||
[
|
||||
{
|
||||
"type": "tun",
|
||||
"inet4_address": "172.19.0.1/30",
|
||||
"auto_route": true,
|
||||
"strict_route": false,
|
||||
},
|
||||
],
|
||||
"outbounds": [
|
||||
#// ...
|
||||
{ "type": "direct", "tag": "direct" },
|
||||
{ "type": "dns", "tag": "dns-out" },
|
||||
],
|
||||
"route":
|
||||
{
|
||||
"rules":
|
||||
[
|
||||
{ "protocol": "dns", "outbound": "dns-out" },
|
||||
{ "geoip": ["private"], "outbound": "direct" },
|
||||
],
|
||||
"auto_detect_interface": true,
|
||||
},
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
205
config/client/luci-app-momo/ipv4+6.json
Normal file
205
config/client/luci-app-momo/ipv4+6.json
Normal file
@@ -0,0 +1,205 @@
|
||||
{
|
||||
"dns": {
|
||||
"servers": [
|
||||
{
|
||||
"tag": "local",
|
||||
"type": "udp",
|
||||
"server": "223.5.5.5"
|
||||
},
|
||||
{
|
||||
"tag": "public",
|
||||
"type": "https",
|
||||
"server": "dns.alidns.com",
|
||||
"domain_resolver": "local"
|
||||
},
|
||||
{
|
||||
"tag": "foreign",
|
||||
"type": "https",
|
||||
"server": "8.8.8.8",
|
||||
"detour": "Server1"
|
||||
},
|
||||
{
|
||||
"tag": "fakeip",
|
||||
"type": "fakeip",
|
||||
"inet4_range": "198.18.0.0/15",
|
||||
"inet6_range": "fc00::/18"
|
||||
}
|
||||
],
|
||||
"rules": [
|
||||
{
|
||||
"rule_set": "geosite-cn",
|
||||
"server": "public"
|
||||
},
|
||||
{
|
||||
"query_type": [
|
||||
"A",
|
||||
"AAAA"
|
||||
],
|
||||
"server": "fakeip",
|
||||
"rewrite_ttl": 1
|
||||
}
|
||||
],
|
||||
"final": "foreign",
|
||||
"strategy": "prefer_ipv4",
|
||||
"independent_cache": true,
|
||||
"reverse_mapping": true
|
||||
},
|
||||
"outbounds": [
|
||||
{
|
||||
"tag": "Server1",
|
||||
"type": "vless",
|
||||
"server": "xxx.xxx.xxx.xxx",
|
||||
"server_port": 8443,
|
||||
"uuid": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
|
||||
"tls": {
|
||||
"enabled": true,
|
||||
"server_name": "xxxxxxxxxxxx",
|
||||
"insecure": false,
|
||||
"reality": {
|
||||
"enabled": true,
|
||||
"public_key": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
|
||||
"short_id": "xxxxxxxxxxxx"
|
||||
},
|
||||
"utls": {
|
||||
"enabled": true,
|
||||
"fingerprint": "firefox"
|
||||
}
|
||||
},
|
||||
"flow": "xtls-rprx-vision"
|
||||
},
|
||||
{
|
||||
"tag": "Server2",
|
||||
"type": "vless",
|
||||
"server": "xxx.xxx.xxx.xxx",
|
||||
"server_port": 8443,
|
||||
"uuid": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
|
||||
"tls": {
|
||||
"enabled": true,
|
||||
"server_name": "xxxxxxxxxxxx",
|
||||
"insecure": false,
|
||||
"reality": {
|
||||
"enabled": true,
|
||||
"public_key": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
|
||||
"short_id": "xxxxxxxxxxxx"
|
||||
},
|
||||
"utls": {
|
||||
"enabled": true
|
||||
}
|
||||
},
|
||||
"flow": "xtls-rprx-vision"
|
||||
},
|
||||
{
|
||||
"tag": "GLOBAL",
|
||||
"type": "selector",
|
||||
"outbounds": [
|
||||
"Server1",
|
||||
"Server2",
|
||||
"direct"
|
||||
]
|
||||
},
|
||||
{
|
||||
"tag": "direct",
|
||||
"type": "direct"
|
||||
}
|
||||
],
|
||||
"route": {
|
||||
"rules": [
|
||||
{
|
||||
"action": "sniff",
|
||||
"sniffer": [
|
||||
"http",
|
||||
"tls",
|
||||
"quic",
|
||||
"dns"
|
||||
]
|
||||
},
|
||||
{
|
||||
"inbound": "dns-in",
|
||||
"action": "hijack-dns"
|
||||
},
|
||||
{
|
||||
"ip_is_private": true,
|
||||
"outbound": "direct"
|
||||
},
|
||||
{
|
||||
"rule_set": "geosite-cn",
|
||||
"outbound": "direct"
|
||||
},
|
||||
{
|
||||
"rule_set": "geoip-cn",
|
||||
"outbound": "direct"
|
||||
}
|
||||
],
|
||||
"rule_set": [
|
||||
{
|
||||
"tag": "geosite-cn",
|
||||
"type": "remote",
|
||||
"format": "binary",
|
||||
"url": "https://gh-proxy.com/https://raw.githubusercontent.com/MetaCubeX/meta-rules-dat/sing/geo/geosite/cn.srs",
|
||||
"download_detour": "direct"
|
||||
},
|
||||
{
|
||||
"tag": "geoip-cn",
|
||||
"type": "remote",
|
||||
"format": "binary",
|
||||
"url": "https://cdn.jsdelivr.net/gh/Loyalsoldier/geoip@release/srs/cn.srs",
|
||||
"download_detour": "direct"
|
||||
}
|
||||
],
|
||||
"final": "GLOBAL",
|
||||
"default_domain_resolver": {
|
||||
"server": "public"
|
||||
}
|
||||
},
|
||||
"inbounds": [
|
||||
{
|
||||
"tag": "dns-in",
|
||||
"type": "direct",
|
||||
"listen": "::",
|
||||
"listen_port": 1053
|
||||
},
|
||||
{
|
||||
"tag": "redirect-in",
|
||||
"type": "redirect",
|
||||
"listen": "::",
|
||||
"listen_port": 7890
|
||||
},
|
||||
{
|
||||
"tag": "tproxy-in",
|
||||
"type": "tproxy",
|
||||
"listen": "::",
|
||||
"listen_port": 7891
|
||||
},
|
||||
{
|
||||
"tag": "tun-in",
|
||||
"type": "tun",
|
||||
"interface_name": "momo",
|
||||
"address": [
|
||||
"172.31.0.1/30",
|
||||
"fdfe:dcba:9876::1/126"
|
||||
],
|
||||
"auto_route": false,
|
||||
"auto_redirect": false
|
||||
}
|
||||
],
|
||||
"experimental": {
|
||||
"cache_file": {
|
||||
"enabled": true,
|
||||
"path": "/etc/momo/run/cache.db",
|
||||
"store_fakeip": true
|
||||
},
|
||||
"clash_api": {
|
||||
"external_controller": "0.0.0.0:9095",
|
||||
"external_ui": "/etc/momo/run/ui",
|
||||
"external_ui_download_url": "https://gh-proxy.com/https://github.com/Zephyruso/zashboard/archive/refs/heads/gh-pages.zip",
|
||||
"external_ui_download_detour": "direct",
|
||||
"secret": "",
|
||||
"default_mode": "rule"
|
||||
}
|
||||
},
|
||||
"log": {
|
||||
"disabled": false,
|
||||
"level": "info",
|
||||
"timestamp": true
|
||||
}
|
||||
}
|
||||
204
config/client/luci-app-momo/ipv4only.json
Normal file
204
config/client/luci-app-momo/ipv4only.json
Normal file
@@ -0,0 +1,204 @@
|
||||
{
|
||||
"dns": {
|
||||
"servers": [
|
||||
{
|
||||
"tag": "local",
|
||||
"type": "udp",
|
||||
"server": "223.5.5.5"
|
||||
},
|
||||
{
|
||||
"tag": "public",
|
||||
"type": "https",
|
||||
"server": "dns.alidns.com",
|
||||
"domain_resolver": "local"
|
||||
},
|
||||
{
|
||||
"tag": "foreign",
|
||||
"type": "https",
|
||||
"server": "8.8.8.8",
|
||||
"detour": "Server1"
|
||||
},
|
||||
{
|
||||
"tag": "fakeip",
|
||||
"type": "fakeip",
|
||||
"inet4_range": "198.18.0.0/15",
|
||||
"inet6_range": "fc00::/18"
|
||||
}
|
||||
],
|
||||
"rules": [
|
||||
{
|
||||
"rule_set": "geosite-cn",
|
||||
"server": "public"
|
||||
},
|
||||
{
|
||||
"query_type": [
|
||||
"A",
|
||||
"AAAA"
|
||||
],
|
||||
"server": "fakeip",
|
||||
"rewrite_ttl": 1
|
||||
}
|
||||
],
|
||||
"final": "foreign",
|
||||
"strategy": "ipv4_only",
|
||||
"independent_cache": true,
|
||||
"reverse_mapping": true
|
||||
},
|
||||
"outbounds": [
|
||||
{
|
||||
"tag": "Server1",
|
||||
"type": "vless",
|
||||
"server": "xxx.xxx.xxx.xxx",
|
||||
"server_port": 8443,
|
||||
"uuid": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
|
||||
"tls": {
|
||||
"enabled": true,
|
||||
"server_name": "xxxxxxxxxxxx",
|
||||
"insecure": false,
|
||||
"reality": {
|
||||
"enabled": true,
|
||||
"public_key": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
|
||||
"short_id": "xxxxxxxxxxxx"
|
||||
},
|
||||
"utls": {
|
||||
"enabled": true,
|
||||
"fingerprint": "firefox"
|
||||
}
|
||||
},
|
||||
"flow": "xtls-rprx-vision"
|
||||
},
|
||||
{
|
||||
"tag": "Server2",
|
||||
"type": "vless",
|
||||
"server": "xxx.xxx.xxx.xxx",
|
||||
"server_port": 8443,
|
||||
"uuid": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
|
||||
"tls": {
|
||||
"enabled": true,
|
||||
"server_name": "xxxxxxxxxxxx",
|
||||
"insecure": false,
|
||||
"reality": {
|
||||
"enabled": true,
|
||||
"public_key": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
|
||||
"short_id": "xxxxxxxxxxxx"
|
||||
},
|
||||
"utls": {
|
||||
"enabled": true
|
||||
}
|
||||
},
|
||||
"flow": "xtls-rprx-vision"
|
||||
},
|
||||
{
|
||||
"tag": "GLOBAL",
|
||||
"type": "selector",
|
||||
"outbounds": [
|
||||
"Server1",
|
||||
"Server2",
|
||||
"direct"
|
||||
]
|
||||
},
|
||||
{
|
||||
"tag": "direct",
|
||||
"type": "direct"
|
||||
}
|
||||
],
|
||||
"route": {
|
||||
"rules": [
|
||||
{
|
||||
"action": "sniff",
|
||||
"sniffer": [
|
||||
"http",
|
||||
"tls",
|
||||
"quic",
|
||||
"dns"
|
||||
]
|
||||
},
|
||||
{
|
||||
"inbound": "dns-in",
|
||||
"action": "hijack-dns"
|
||||
},
|
||||
{
|
||||
"ip_is_private": true,
|
||||
"outbound": "direct"
|
||||
},
|
||||
{
|
||||
"rule_set": "geosite-cn",
|
||||
"outbound": "direct"
|
||||
},
|
||||
{
|
||||
"rule_set": "geoip-cn",
|
||||
"outbound": "direct"
|
||||
}
|
||||
],
|
||||
"rule_set": [
|
||||
{
|
||||
"tag": "geosite-cn",
|
||||
"type": "remote",
|
||||
"format": "binary",
|
||||
"url": "https://gh-proxy.com/https://raw.githubusercontent.com/MetaCubeX/meta-rules-dat/sing/geo/geosite/cn.srs",
|
||||
"download_detour": "direct"
|
||||
},
|
||||
{
|
||||
"tag": "geoip-cn",
|
||||
"type": "remote",
|
||||
"format": "binary",
|
||||
"url": "https://cdn.jsdelivr.net/gh/Loyalsoldier/geoip@release/srs/cn.srs",
|
||||
"download_detour": "direct"
|
||||
}
|
||||
],
|
||||
"final": "GLOBAL",
|
||||
"default_domain_resolver": {
|
||||
"server": "public"
|
||||
}
|
||||
},
|
||||
"inbounds": [
|
||||
{
|
||||
"tag": "dns-in",
|
||||
"type": "direct",
|
||||
"listen": "0.0.0.0",
|
||||
"listen_port": 1053
|
||||
},
|
||||
{
|
||||
"tag": "redirect-in",
|
||||
"type": "redirect",
|
||||
"listen": "0.0.0.0",
|
||||
"listen_port": 7890
|
||||
},
|
||||
{
|
||||
"tag": "tproxy-in",
|
||||
"type": "tproxy",
|
||||
"listen": "0.0.0.0",
|
||||
"listen_port": 7891
|
||||
},
|
||||
{
|
||||
"tag": "tun-in",
|
||||
"type": "tun",
|
||||
"interface_name": "momo",
|
||||
"address": [
|
||||
"172.31.0.1/30"
|
||||
],
|
||||
"auto_route": false,
|
||||
"auto_redirect": false
|
||||
}
|
||||
],
|
||||
"experimental": {
|
||||
"cache_file": {
|
||||
"enabled": true,
|
||||
"path": "/etc/momo/run/cache.db",
|
||||
"store_fakeip": true
|
||||
},
|
||||
"clash_api": {
|
||||
"external_controller": "0.0.0.0:9095",
|
||||
"external_ui": "/etc/momo/run/ui",
|
||||
"external_ui_download_url": "https://gh-proxy.com/https://github.com/Zephyruso/zashboard/archive/refs/heads/gh-pages.zip",
|
||||
"external_ui_download_detour": "direct",
|
||||
"secret": "",
|
||||
"default_mode": "rule"
|
||||
}
|
||||
},
|
||||
"log": {
|
||||
"disabled": false,
|
||||
"level": "info",
|
||||
"timestamp": true
|
||||
}
|
||||
}
|
||||
7
config/client/shellcrash/1_log.json
Normal file
7
config/client/shellcrash/1_log.json
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"log": {
|
||||
"disabled": false,
|
||||
"level": "info",
|
||||
"timestamp": true
|
||||
}
|
||||
}
|
||||
210
config/client/shellcrash/2_dns.json
Normal file
210
config/client/shellcrash/2_dns.json
Normal file
@@ -0,0 +1,210 @@
|
||||
{
|
||||
"dns": {
|
||||
"servers": [
|
||||
{
|
||||
"tag": "dns_proxy",
|
||||
"address": "https://223.5.5.5/dns-query",
|
||||
"strategy": "ipv4_only",
|
||||
"address_resolver": "dns_resolver"
|
||||
},
|
||||
{
|
||||
"tag": "dns_direct",
|
||||
"address": "https://8.8.8.8/dns-query",
|
||||
"strategy": "ipv4_only",
|
||||
"address_resolver": "dns_resolver",
|
||||
"detour": "DIRECT"
|
||||
},
|
||||
{
|
||||
"tag": "dns_fakeip",
|
||||
"address": "fakeip"
|
||||
},
|
||||
{
|
||||
"tag": "dns_resolver",
|
||||
"address": "223.5.5.5",
|
||||
"detour": "DIRECT"
|
||||
},
|
||||
{
|
||||
"tag": "block",
|
||||
"address": "rcode://success"
|
||||
},
|
||||
{
|
||||
"tag": "local",
|
||||
"address": "local",
|
||||
"detour": "DIRECT"
|
||||
}
|
||||
],
|
||||
"rules": [
|
||||
{
|
||||
"outbound": [
|
||||
"any"
|
||||
],
|
||||
"server": "dns_direct"
|
||||
},
|
||||
{
|
||||
"clash_mode": "Global",
|
||||
"server": "dns_fakeip",
|
||||
"rewrite_ttl": 1
|
||||
},
|
||||
{
|
||||
"clash_mode": "Direct",
|
||||
"server": "dns_direct"
|
||||
},
|
||||
{
|
||||
"domain": [
|
||||
"time-ios.apple.com",
|
||||
"time1.cloud.tencent.com",
|
||||
"music.163.com",
|
||||
"musicapi.taihe.com",
|
||||
"music.taihe.com",
|
||||
"songsearch.kugou.com",
|
||||
"trackercdn.kugou.com",
|
||||
"api-jooxtt.sanook.com",
|
||||
"api.joox.com",
|
||||
"joox.com",
|
||||
"y.qq.com",
|
||||
"streamoc.music.tc.qq.com",
|
||||
"mobileoc.music.tc.qq.com",
|
||||
"isure.stream.qqmusic.qq.com",
|
||||
"dl.stream.qqmusic.qq.com",
|
||||
"aqqmusic.tc.qq.com",
|
||||
"amobile.music.tc.qq.com",
|
||||
"music.migu.cn",
|
||||
"localhost.ptlogin2.qq.com",
|
||||
"localhost.sec.qq.com",
|
||||
"xnotify.xboxlive.com",
|
||||
"proxy.golang.org",
|
||||
"heartbeat.belkin.com",
|
||||
"mesu.apple.com",
|
||||
"swscan.apple.com",
|
||||
"swquery.apple.com",
|
||||
"swdownload.apple.com",
|
||||
"swcdn.apple.com",
|
||||
"swdist.apple.com",
|
||||
"lens.l.google.com",
|
||||
"stun.l.google.com",
|
||||
"na.b.g-tun.com",
|
||||
"ff.dorado.sdo.com",
|
||||
"shark007.net",
|
||||
"adguardteam.github.io",
|
||||
"adrules.top",
|
||||
"anti-ad.net",
|
||||
"local.adguard.org",
|
||||
"static.adtidy.org",
|
||||
"ps.res.netease.com"
|
||||
],
|
||||
"server": "dns_direct"
|
||||
},
|
||||
{
|
||||
"domain_suffix": [
|
||||
"lan",
|
||||
"localdomain",
|
||||
"example",
|
||||
"invalid",
|
||||
"localhost",
|
||||
"test",
|
||||
"local",
|
||||
"home.arpa",
|
||||
"direct",
|
||||
"time.edu.cn",
|
||||
"ntp.org.cn",
|
||||
"pool.ntp.org",
|
||||
"music.163.com",
|
||||
"126.net",
|
||||
"kuwo.cn",
|
||||
"y.qq.com",
|
||||
"xiami.com",
|
||||
"music.migu.cn",
|
||||
"msftconnecttest.com",
|
||||
"msftncsi.com",
|
||||
"steamcontent.com",
|
||||
"srv.nintendo.net",
|
||||
"n.n.srv.nintendo.net",
|
||||
"cdn.nintendo.net",
|
||||
"stun.playstation.net",
|
||||
"battle.net",
|
||||
"battlenet.com.cn",
|
||||
"wotgame.cn",
|
||||
"wggames.cn",
|
||||
"wowsgame.cn",
|
||||
"wargaming.net",
|
||||
"linksys.com",
|
||||
"linksyssmartwifi.com",
|
||||
"router.asus.com",
|
||||
"nflxvideo.net",
|
||||
"square-enix.com",
|
||||
"finalfantasyxiv.com",
|
||||
"ffxiv.com",
|
||||
"ff14.sdo.com",
|
||||
"mcdn.bilivideo.cn",
|
||||
"media.dssott.com",
|
||||
"market.xiaomi.com",
|
||||
"cmbchina.com",
|
||||
"cmbimg.com",
|
||||
"sandai.net",
|
||||
"n0808.com",
|
||||
"3gppnetwork.org",
|
||||
"uu.163.com",
|
||||
"oray.com",
|
||||
"orayimg.com",
|
||||
"gcloudcs.com",
|
||||
"gcloudsdk.com"
|
||||
],
|
||||
"server": "dns_direct"
|
||||
},
|
||||
{
|
||||
"domain_regex": [
|
||||
"time.*.com",
|
||||
"time.*.gov",
|
||||
"time.*.edu.cn",
|
||||
"time.*.apple.com",
|
||||
"time1.*.com",
|
||||
"time2.*.com",
|
||||
"time3.*.com",
|
||||
"time4.*.com",
|
||||
"time5.*.com",
|
||||
"time6.*.com",
|
||||
"time7.*.com",
|
||||
"ntp.*.com",
|
||||
"ntp1.*.com",
|
||||
"ntp2.*.com",
|
||||
"ntp3.*.com",
|
||||
"ntp4.*.com",
|
||||
"ntp5.*.com",
|
||||
"ntp6.*.com",
|
||||
"ntp7.*.com",
|
||||
"localhost.*.weixin.qq.com",
|
||||
"xbox.*.*.microsoft.com",
|
||||
".*.*.xboxlive.com",
|
||||
"xbox.*.microsoft.com",
|
||||
"stun.*.*",
|
||||
"stun.*.*.*",
|
||||
".+.stun.*.*",
|
||||
".+.stun.*.*.*",
|
||||
".+.stun.*.*.*.*",
|
||||
".+.stun.*.*.*.*.*"
|
||||
],
|
||||
"server": "dns_direct"
|
||||
},
|
||||
{
|
||||
"geosite": "cn",
|
||||
"server": "dns_direct"
|
||||
},
|
||||
{
|
||||
"query_type": [
|
||||
"A",
|
||||
"AAAA"
|
||||
],
|
||||
"server": "dns_fakeip",
|
||||
"rewrite_ttl": 1
|
||||
}
|
||||
],
|
||||
"final": "dns_proxy",
|
||||
"independent_cache": true,
|
||||
"reverse_mapping": true,
|
||||
"fakeip": {
|
||||
"enabled": true,
|
||||
"inet4_range": "198.18.0.0/16",
|
||||
"inet6_range": "fc00::/16"
|
||||
}
|
||||
}
|
||||
}
|
||||
9
config/client/shellcrash/3_ntp.json
Normal file
9
config/client/shellcrash/3_ntp.json
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ntp": {
|
||||
"enabled": true,
|
||||
"server": "time.apple.com",
|
||||
"server_port": 123,
|
||||
"interval": "30m",
|
||||
"detour": "DIRECT"
|
||||
}
|
||||
}
|
||||
19
config/client/shellcrash/4_inbounds.json
Normal file
19
config/client/shellcrash/4_inbounds.json
Normal file
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"inbounds": [
|
||||
{
|
||||
"type": "mixed",
|
||||
"tag": "mixed-in",
|
||||
"listen": "0.0.0.0",
|
||||
"listen_port": 2080
|
||||
},
|
||||
{
|
||||
"type": "tun",
|
||||
"tag": "tun-in",
|
||||
"inet4_address": "172.19.0.1/30",
|
||||
"auto_route": true,
|
||||
"strict_route": true,
|
||||
"stack": "mixed",
|
||||
"sniff": true
|
||||
}
|
||||
]
|
||||
}
|
||||
94
config/client/shellcrash/5_outbounds.json
Normal file
94
config/client/shellcrash/5_outbounds.json
Normal file
@@ -0,0 +1,94 @@
|
||||
{
|
||||
"outbounds": [
|
||||
{
|
||||
"type": "direct",
|
||||
"tag": "DIRECT"
|
||||
},
|
||||
{
|
||||
"type": "block",
|
||||
"tag": "REJECT"
|
||||
},
|
||||
{
|
||||
"type": "dns",
|
||||
"tag": "dns-out"
|
||||
},
|
||||
{
|
||||
"type": "vless",
|
||||
"tag": "🇺🇸 US-100G",
|
||||
"server": "666.666.666.666",
|
||||
"server_port": 443,
|
||||
"uuid": "xxxxxxxxxxxxxxxxxxxxx",
|
||||
"flow": "xtls-rprx-vision",
|
||||
"tls": {
|
||||
"enabled": true,
|
||||
"server_name": "xxxxxxxxxx",
|
||||
"insecure": true,
|
||||
"utls": {
|
||||
"enabled": true,
|
||||
"fingerprint": "firefox"
|
||||
},
|
||||
"reality": {
|
||||
"enabled": true,
|
||||
"public_key": "xxxxxxxx",
|
||||
"short_id": "xxxxxxxx"
|
||||
}
|
||||
},
|
||||
"network": "tcp",
|
||||
"tcp_fast_open": false
|
||||
},
|
||||
{
|
||||
"type": "selector",
|
||||
"tag": "🚀 节点选择",
|
||||
"outbounds": [
|
||||
"♻️ 自动选择",
|
||||
"DIRECT",
|
||||
"🇺🇸 US-100G"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "urltest",
|
||||
"tag": "♻️ 自动选择",
|
||||
"outbounds": [
|
||||
"🇺🇸 US-100G"
|
||||
],
|
||||
"url": "http://www.gstatic.com/generate_204",
|
||||
"interval": "5m",
|
||||
"tolerance": 50
|
||||
},
|
||||
{
|
||||
"type": "selector",
|
||||
"tag": "🎯 全球直连",
|
||||
"outbounds": [
|
||||
"DIRECT",
|
||||
"🚀 节点选择",
|
||||
"♻️ 自动选择"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "selector",
|
||||
"tag": "🛑 全球拦截",
|
||||
"outbounds": [
|
||||
"REJECT",
|
||||
"DIRECT"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "selector",
|
||||
"tag": "🐟 漏网之鱼",
|
||||
"outbounds": [
|
||||
"🚀 节点选择",
|
||||
"🎯 全球直连",
|
||||
"♻️ 自动选择",
|
||||
"🇺🇸 US-100G"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "selector",
|
||||
"tag": "GLOBAL",
|
||||
"outbounds": [
|
||||
"DIRECT",
|
||||
"🇺🇸 US-100G"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
3472
config/client/shellcrash/6_route.json
Normal file
3472
config/client/shellcrash/6_route.json
Normal file
File diff suppressed because it is too large
Load Diff
12
config/client/shellcrash/7_experimental.json
Normal file
12
config/client/shellcrash/7_experimental.json
Normal file
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"experimental": {
|
||||
"cache_file": {
|
||||
"enabled": true,
|
||||
"store_fakeip": true
|
||||
},
|
||||
"clash_api": {
|
||||
"external_controller": "0.0.0.0:9090",
|
||||
"external_ui": "/etc/mihomo/ui"
|
||||
}
|
||||
}
|
||||
}
|
||||
21
config/client/shellcrash/add_hosts.json
Normal file
21
config/client/shellcrash/add_hosts.json
Normal file
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"dns": {
|
||||
"servers": [
|
||||
{
|
||||
"tag": "hosts_local",
|
||||
"address": "local",
|
||||
"detour": "DIRECT"
|
||||
}
|
||||
],
|
||||
"rules": [
|
||||
{
|
||||
"domain": [
|
||||
"localhost",
|
||||
"time.android.com",
|
||||
"time.facebook.com"
|
||||
],
|
||||
"server": "hosts_local"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
11
config/client/shellcrash/add_route.json
Normal file
11
config/client/shellcrash/add_route.json
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"route": {
|
||||
"rules": [
|
||||
{
|
||||
"inbound": "dns-in",
|
||||
"outbound": "dns-out"
|
||||
}
|
||||
],
|
||||
"default_mark": 7894
|
||||
}
|
||||
}
|
||||
209
config/kernel/ipv4+6.json
Normal file
209
config/kernel/ipv4+6.json
Normal file
@@ -0,0 +1,209 @@
|
||||
{
|
||||
"dns": {
|
||||
"servers": [
|
||||
{
|
||||
"tag": "local",
|
||||
"type": "udp",
|
||||
"server": "223.5.5.5"
|
||||
},
|
||||
{
|
||||
"tag": "public",
|
||||
"type": "https",
|
||||
"server": "dns.alidns.com",
|
||||
"domain_resolver": "local"
|
||||
},
|
||||
{
|
||||
"tag": "foreign",
|
||||
"type": "https",
|
||||
"server": "8.8.8.8",
|
||||
"detour": "Azure-JP"
|
||||
},
|
||||
{
|
||||
"tag": "fakeip",
|
||||
"type": "fakeip",
|
||||
"inet4_range": "198.18.0.0/15",
|
||||
"inet6_range": "fc00::/18"
|
||||
}
|
||||
],
|
||||
"rules": [
|
||||
{
|
||||
"rule_set": "geosite-cn",
|
||||
"server": "local"
|
||||
},
|
||||
{
|
||||
"query_type": [
|
||||
"A",
|
||||
"AAAA"
|
||||
],
|
||||
"server": "fakeip",
|
||||
"rewrite_ttl": 1
|
||||
}
|
||||
],
|
||||
"final": "foreign",
|
||||
"strategy": "prefer_ipv4",
|
||||
"independent_cache": true,
|
||||
"reverse_mapping": false
|
||||
},
|
||||
"outbounds": [
|
||||
{
|
||||
"tag": "Server1",
|
||||
"type": "vless",
|
||||
"server": "xxx.xxx.xxx.xxx",
|
||||
"server_port": 8443,
|
||||
"uuid": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
|
||||
"tls": {
|
||||
"enabled": true,
|
||||
"server_name": "xxxxxxxxxxxx",
|
||||
"insecure": false,
|
||||
"reality": {
|
||||
"enabled": true,
|
||||
"public_key": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
|
||||
"short_id": "xxxxxxxxxxxx"
|
||||
},
|
||||
"utls": {
|
||||
"enabled": true,
|
||||
"fingerprint": "firefox"
|
||||
}
|
||||
},
|
||||
"flow": "xtls-rprx-vision"
|
||||
},
|
||||
{
|
||||
"tag": "Server2",
|
||||
"type": "vless",
|
||||
"server": "xxx.xxx.xxx.xxx",
|
||||
"server_port": 8443,
|
||||
"uuid": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
|
||||
"tls": {
|
||||
"enabled": true,
|
||||
"server_name": "xxxxxxxxxxxx",
|
||||
"insecure": false,
|
||||
"reality": {
|
||||
"enabled": true,
|
||||
"public_key": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
|
||||
"short_id": "xxxxxxxxxxxx"
|
||||
},
|
||||
"utls": {
|
||||
"enabled": true
|
||||
}
|
||||
},
|
||||
"flow": "xtls-rprx-vision"
|
||||
},
|
||||
{
|
||||
"tag": "GLOBAL",
|
||||
"type": "selector",
|
||||
"outbounds": [
|
||||
"Server1",
|
||||
"Server2",
|
||||
"direct"
|
||||
]
|
||||
},
|
||||
{
|
||||
"tag": "direct",
|
||||
"type": "direct"
|
||||
}
|
||||
],
|
||||
"route": {
|
||||
"rules": [
|
||||
{
|
||||
"inbound": "tun-in",
|
||||
"port": 53,
|
||||
"action": "hijack-dns"
|
||||
},
|
||||
{
|
||||
"inbound": "dns-in",
|
||||
"action": "hijack-dns"
|
||||
},
|
||||
{
|
||||
"ip_is_private": true,
|
||||
"outbound": "direct"
|
||||
},
|
||||
{
|
||||
"rule_set": "geosite-cn",
|
||||
"outbound": "direct"
|
||||
},
|
||||
{
|
||||
"rule_set": "geoip-cn",
|
||||
"outbound": "direct"
|
||||
},
|
||||
{
|
||||
"action": "sniff",
|
||||
"sniffer": [
|
||||
"http",
|
||||
"tls",
|
||||
"quic",
|
||||
"dns"
|
||||
]
|
||||
},
|
||||
{
|
||||
"outbound": "GLOBAL"
|
||||
}
|
||||
],
|
||||
"rule_set": [
|
||||
{
|
||||
"tag": "geosite-cn",
|
||||
"type": "remote",
|
||||
"format": "binary",
|
||||
"url": "https://gh-proxy.com/https://raw.githubusercontent.com/MetaCubeX/meta-rules-dat/sing/geo/geosite/cn.srs",
|
||||
"download_detour": "direct"
|
||||
},
|
||||
{
|
||||
"tag": "geoip-cn",
|
||||
"type": "remote",
|
||||
"format": "binary",
|
||||
"url": "https://cdn.jsdelivr.net/gh/Loyalsoldier/geoip@release/srs/cn.srs",
|
||||
"download_detour": "direct"
|
||||
}
|
||||
],
|
||||
"final": "GLOBAL",
|
||||
"auto_detect_interface": true,
|
||||
"default_domain_resolver": {
|
||||
"server": "public"
|
||||
}
|
||||
},
|
||||
"inbounds": [
|
||||
{
|
||||
"tag": "dns-in",
|
||||
"type": "direct",
|
||||
"listen": "127.0.0.1",
|
||||
"listen_port": 1053
|
||||
},
|
||||
{
|
||||
"tag": "tun-in",
|
||||
"type": "tun",
|
||||
"interface_name": "stun",
|
||||
"address": [
|
||||
"172.19.0.1/30",
|
||||
"fdfe:dcba:9876::1/126"
|
||||
],
|
||||
"mtu": 9000,
|
||||
"auto_route": true,
|
||||
"auto_redirect": true,
|
||||
"strict_route": false
|
||||
},
|
||||
{
|
||||
"type": "mixed",
|
||||
"listen": "127.0.0.1",
|
||||
"listen_port": 7890
|
||||
}
|
||||
],
|
||||
"experimental": {
|
||||
"cache_file": {
|
||||
"enabled": true,
|
||||
"path": "/var/lib/sing-box/cache.db",
|
||||
"store_fakeip": true
|
||||
},
|
||||
"clash_api": {
|
||||
"external_controller": "0.0.0.0:9191",
|
||||
"external_ui": "/var/lib/sing-box/ui",
|
||||
"external_ui_download_url": "https://gh-proxy.com/https://github.com/Zephyruso/zashboard/archive/refs/heads/gh-pages.zip",
|
||||
"external_ui_download_detour": "direct",
|
||||
"secret": "",
|
||||
"default_mode": "rule"
|
||||
}
|
||||
},
|
||||
"log": {
|
||||
"disabled": false,
|
||||
"level": "info",
|
||||
"timestamp": true
|
||||
}
|
||||
}
|
||||
208
config/kernel/ipv4only.json
Normal file
208
config/kernel/ipv4only.json
Normal file
@@ -0,0 +1,208 @@
|
||||
{
|
||||
"dns": {
|
||||
"servers": [
|
||||
{
|
||||
"tag": "local",
|
||||
"type": "udp",
|
||||
"server": "223.5.5.5"
|
||||
},
|
||||
{
|
||||
"tag": "public",
|
||||
"type": "https",
|
||||
"server": "dns.alidns.com",
|
||||
"domain_resolver": "local"
|
||||
},
|
||||
{
|
||||
"tag": "foreign",
|
||||
"type": "https",
|
||||
"server": "8.8.8.8",
|
||||
"detour": "Azure-JP"
|
||||
},
|
||||
{
|
||||
"tag": "fakeip",
|
||||
"type": "fakeip",
|
||||
"inet4_range": "198.18.0.0/15",
|
||||
"inet6_range": "fc00::/18"
|
||||
}
|
||||
],
|
||||
"rules": [
|
||||
{
|
||||
"rule_set": "geosite-cn",
|
||||
"server": "local"
|
||||
},
|
||||
{
|
||||
"query_type": [
|
||||
"A",
|
||||
"AAAA"
|
||||
],
|
||||
"server": "fakeip",
|
||||
"rewrite_ttl": 1
|
||||
}
|
||||
],
|
||||
"final": "foreign",
|
||||
"strategy": "ipv4_only",
|
||||
"independent_cache": true,
|
||||
"reverse_mapping": false
|
||||
},
|
||||
"outbounds": [
|
||||
{
|
||||
"tag": "Server1",
|
||||
"type": "vless",
|
||||
"server": "xxx.xxx.xxx.xxx",
|
||||
"server_port": 8443,
|
||||
"uuid": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
|
||||
"tls": {
|
||||
"enabled": true,
|
||||
"server_name": "xxxxxxxxxxxx",
|
||||
"insecure": false,
|
||||
"reality": {
|
||||
"enabled": true,
|
||||
"public_key": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
|
||||
"short_id": "xxxxxxxxxxxx"
|
||||
},
|
||||
"utls": {
|
||||
"enabled": true,
|
||||
"fingerprint": "firefox"
|
||||
}
|
||||
},
|
||||
"flow": "xtls-rprx-vision"
|
||||
},
|
||||
{
|
||||
"tag": "Server2",
|
||||
"type": "vless",
|
||||
"server": "xxx.xxx.xxx.xxx",
|
||||
"server_port": 8443,
|
||||
"uuid": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
|
||||
"tls": {
|
||||
"enabled": true,
|
||||
"server_name": "xxxxxxxxxxxx",
|
||||
"insecure": false,
|
||||
"reality": {
|
||||
"enabled": true,
|
||||
"public_key": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
|
||||
"short_id": "xxxxxxxxxxxx"
|
||||
},
|
||||
"utls": {
|
||||
"enabled": true
|
||||
}
|
||||
},
|
||||
"flow": "xtls-rprx-vision"
|
||||
},
|
||||
{
|
||||
"tag": "GLOBAL",
|
||||
"type": "selector",
|
||||
"outbounds": [
|
||||
"Server1",
|
||||
"Server2",
|
||||
"direct"
|
||||
]
|
||||
},
|
||||
{
|
||||
"tag": "direct",
|
||||
"type": "direct"
|
||||
}
|
||||
],
|
||||
"route": {
|
||||
"rules": [
|
||||
{
|
||||
"inbound": "tun-in",
|
||||
"port": 53,
|
||||
"action": "hijack-dns"
|
||||
},
|
||||
{
|
||||
"inbound": "dns-in",
|
||||
"action": "hijack-dns"
|
||||
},
|
||||
{
|
||||
"ip_is_private": true,
|
||||
"outbound": "direct"
|
||||
},
|
||||
{
|
||||
"rule_set": "geosite-cn",
|
||||
"outbound": "direct"
|
||||
},
|
||||
{
|
||||
"rule_set": "geoip-cn",
|
||||
"outbound": "direct"
|
||||
},
|
||||
{
|
||||
"action": "sniff",
|
||||
"sniffer": [
|
||||
"http",
|
||||
"tls",
|
||||
"quic",
|
||||
"dns"
|
||||
]
|
||||
},
|
||||
{
|
||||
"outbound": "GLOBAL"
|
||||
}
|
||||
],
|
||||
"rule_set": [
|
||||
{
|
||||
"tag": "geosite-cn",
|
||||
"type": "remote",
|
||||
"format": "binary",
|
||||
"url": "https://gh-proxy.com/https://raw.githubusercontent.com/MetaCubeX/meta-rules-dat/sing/geo/geosite/cn.srs",
|
||||
"download_detour": "direct"
|
||||
},
|
||||
{
|
||||
"tag": "geoip-cn",
|
||||
"type": "remote",
|
||||
"format": "binary",
|
||||
"url": "https://cdn.jsdelivr.net/gh/Loyalsoldier/geoip@release/srs/cn.srs",
|
||||
"download_detour": "direct"
|
||||
}
|
||||
],
|
||||
"final": "GLOBAL",
|
||||
"auto_detect_interface": true,
|
||||
"default_domain_resolver": {
|
||||
"server": "public"
|
||||
}
|
||||
},
|
||||
"inbounds": [
|
||||
{
|
||||
"tag": "dns-in",
|
||||
"type": "direct",
|
||||
"listen": "127.0.0.1",
|
||||
"listen_port": 1053
|
||||
},
|
||||
{
|
||||
"tag": "tun-in",
|
||||
"type": "tun",
|
||||
"interface_name": "stun",
|
||||
"address": [
|
||||
"172.19.0.1/30"
|
||||
],
|
||||
"mtu": 9000,
|
||||
"auto_route": true,
|
||||
"auto_redirect": true,
|
||||
"strict_route": false
|
||||
},
|
||||
{
|
||||
"type": "mixed",
|
||||
"listen": "127.0.0.1",
|
||||
"listen_port": 7890
|
||||
}
|
||||
],
|
||||
"experimental": {
|
||||
"cache_file": {
|
||||
"enabled": true,
|
||||
"path": "/var/lib/sing-box/cache.db",
|
||||
"store_fakeip": true
|
||||
},
|
||||
"clash_api": {
|
||||
"external_controller": "0.0.0.0:9191",
|
||||
"external_ui": "/var/lib/sing-box/ui",
|
||||
"external_ui_download_url": "https://gh-proxy.com/https://github.com/Zephyruso/zashboard/archive/refs/heads/gh-pages.zip",
|
||||
"external_ui_download_detour": "direct",
|
||||
"secret": "",
|
||||
"default_mode": "rule"
|
||||
}
|
||||
},
|
||||
"log": {
|
||||
"disabled": false,
|
||||
"level": "info",
|
||||
"timestamp": true
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
# install_singbox.sh
|
||||
# 版本号
|
||||
SCRIPT_VERSION="1.12.1"
|
||||
SCRIPT_VERSION="1.12.12"
|
||||
set -euo pipefail
|
||||
|
||||
# 颜色定义
|
||||
@@ -19,43 +19,79 @@ if [[ $EUID -ne 0 ]]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
CONFIG_DIR=/etc/singbox
|
||||
# 修复:使用正确的配置目录
|
||||
CONFIG_DIR=/etc/sing-box
|
||||
STATE_FILE="$CONFIG_DIR/state.env"
|
||||
BIN_NAME=sing-box
|
||||
|
||||
# 检测网络类型
|
||||
detect_network_type() {
|
||||
local has_ipv4=false
|
||||
local has_ipv6=false
|
||||
|
||||
# 检测IPv4
|
||||
if ping -4 -c1 -W2 8.8.8.8 &>/dev/null || curl -4 -s --connect-timeout 3 https://api.ipify.org &>/dev/null; then
|
||||
has_ipv4=true
|
||||
fi
|
||||
|
||||
# 检测IPv6
|
||||
if ping -6 -c1 -W2 2001:4860:4860::8888 &>/dev/null || curl -6 -s --connect-timeout 3 https://api64.ipify.org &>/dev/null; then
|
||||
has_ipv6=true
|
||||
fi
|
||||
|
||||
if $has_ipv4 && $has_ipv6; then
|
||||
echo "dual"
|
||||
elif $has_ipv6; then
|
||||
echo "ipv6"
|
||||
elif $has_ipv4; then
|
||||
echo "ipv4"
|
||||
else
|
||||
echo "none"
|
||||
fi
|
||||
}
|
||||
|
||||
# 获取服务器IP地址
|
||||
get_server_ip() {
|
||||
local network_type=$(detect_network_type)
|
||||
local ip=""
|
||||
|
||||
case "$network_type" in
|
||||
"ipv6")
|
||||
# 纯IPv6环境
|
||||
ip=$(curl -6 -s --connect-timeout 5 https://api64.ipify.org 2>/dev/null || \
|
||||
curl -6 -s --connect-timeout 5 https://ifconfig.co 2>/dev/null || \
|
||||
ip -6 addr show scope global | grep inet6 | head -n1 | awk '{print $2}' | cut -d'/' -f1)
|
||||
;;
|
||||
"dual"|"ipv4")
|
||||
# 双栈或IPv4环境
|
||||
ip=$(curl -4 -s --connect-timeout 5 https://api.ipify.org 2>/dev/null || \
|
||||
curl -4 -s --connect-timeout 5 https://ifconfig.me 2>/dev/null || \
|
||||
ip -4 addr show scope global | grep inet | head -n1 | awk '{print $2}' | cut -d'/' -f1)
|
||||
;;
|
||||
*)
|
||||
# 无法检测到网络
|
||||
ip=$(ip addr show scope global | grep -oP '(?<=inet6?\s)\S+' | head -n1 | cut -d'/' -f1)
|
||||
;;
|
||||
esac
|
||||
|
||||
echo "$ip"
|
||||
}
|
||||
|
||||
# 检查本地与远程版本,并提示
|
||||
check_update() {
|
||||
if command -v curl &>/dev/null && command -v grep &>/dev/null; then
|
||||
LOCAL_VER=$($BIN_NAME version 2>/dev/null | head -n1 | awk '{print $NF}') || LOCAL_VER="未安装"
|
||||
LATEST_VER=$(curl -s https://api.github.com/repos/SagerNet/sing-box/releases/latest |
|
||||
grep '"tag_name"' | head -n1 | cut -d '"' -f4 | sed 's/^v//') || LATEST_VER="未知"
|
||||
if [[ "$LOCAL_VER" != "$LATEST_VER" ]]; then
|
||||
printf "${YELLOW}检测到新版本:${LATEST_VER},当前版本:${LOCAL_VER}。请选择 6) 升级 Sing-box 二进制。${NC}\n"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# 升级/安装 Sing-box 二进制
|
||||
update_singbox() {
|
||||
printf "${CYAN}===== 升级/安装 Sing-box 二进制 =====${NC}\n"
|
||||
if command -v apt-get &>/dev/null; then
|
||||
bash <(curl -fsSL https://sing-box.app/deb-install.sh)
|
||||
elif command -v dnf &>/dev/null || command -v yum &>/dev/null; then
|
||||
bash <(curl -fsSL https://sing-box.app/rpm-install.sh)
|
||||
elif command -v pacman &>/dev/null; then
|
||||
bash <(curl -fsSL https://sing-box.app/arch-install.sh)
|
||||
else
|
||||
printf "${RED}无法识别发行版,请手动升级 Sing-box 二进制${NC}\n" >&2
|
||||
return 1
|
||||
fi
|
||||
hash -r
|
||||
NEW_VER=$($BIN_NAME version | head -n1 | awk '{print $NF}')
|
||||
printf "${GREEN}Sing-box 已升级到版本:%s${NC}\n" "$NEW_VER"
|
||||
printf "${CYAN}重启服务...${NC}\n"
|
||||
if systemctl restart sing-box.service; then
|
||||
printf "${GREEN}服务已重启。${NC}\n"
|
||||
else
|
||||
printf "${YELLOW}服务重启失败,请手动检查。${NC}\n"
|
||||
local network_type=$(detect_network_type)
|
||||
local curl_opts=""
|
||||
[[ "$network_type" == "ipv6" ]] && curl_opts="-6"
|
||||
|
||||
LATEST_VER=$(curl $curl_opts -s --connect-timeout 10 https://api.github.com/repos/SagerNet/sing-box/releases/latest 2>/dev/null |
|
||||
grep '"tag_name"' | head -n1 | cut -d '"' -f4 | sed 's/^v//') || LATEST_VER="未知"
|
||||
|
||||
if [[ "$LOCAL_VER" != "$LATEST_VER" && "$LATEST_VER" != "未知" ]]; then
|
||||
printf "${YELLOW}检测到新版本:${LATEST_VER},当前版本:${LOCAL_VER}。请选择 8) 升级 Sing-box 二进制。${NC}\n"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -64,13 +100,12 @@ install_singbox() {
|
||||
printf "${CYAN}===== 安装 Sing-box 并生成配置 =====${NC}\n"
|
||||
printf "${YELLOW}请输入用户名称 (name 字段,例如 AK-JP-100G):${NC}"
|
||||
read -r NAME
|
||||
[[ -z "$NAME" ]] && {
|
||||
printf "${RED}名称不能为空,退出。${NC}\n" >&2
|
||||
exit 1
|
||||
}
|
||||
[[ -z "$NAME" ]] && { printf "${RED}名称不能为空,退出。${NC}\n" >&2; exit 1; }
|
||||
printf "${YELLOW}请输入 SNI 域名 (默认: s0.awsstatic.com):${NC}"
|
||||
read -r SNI
|
||||
SNI=${SNI:-s0.awsstatic.com}
|
||||
read -rp "请输入监听端口 (默认: 443): " PORT
|
||||
PORT=${PORT:-443}
|
||||
|
||||
update_singbox
|
||||
hash -r
|
||||
@@ -87,56 +122,86 @@ install_singbox() {
|
||||
PRIVATE_KEY=$(echo "$KEY_OUTPUT" | awk -F': ' '/PrivateKey/ {print $2}')
|
||||
PUB_KEY=$(echo "$KEY_OUTPUT" | awk -F': ' '/PublicKey/ {print $2}')
|
||||
SHORT_ID=$(openssl rand -hex 8)
|
||||
FP="chrome"
|
||||
SERVER_IP=$(curl -s https://ifconfig.me)
|
||||
PORT=443
|
||||
FP="firefox"
|
||||
SERVER_IP=$(get_server_ip)
|
||||
SPX="/"
|
||||
|
||||
mkdir -p "$CONFIG_DIR"
|
||||
|
||||
# 根据网络类型选择 DNS
|
||||
NET_TYPE=$(detect_network_type)
|
||||
if [[ "$NET_TYPE" == "ipv6" ]]; then
|
||||
DNS_SERVER1="2606:4700:4700::1111" # Cloudflare IPv6
|
||||
DNS_SERVER2="2620:fe::fe" # Quad9 IPv6
|
||||
DNS_STRATEGY="prefer_ipv6"
|
||||
elif [[ "$NET_TYPE" == "dual" || "$NET_TYPE" == "ipv4" ]]; then
|
||||
DNS_SERVER1="8.8.8.8"
|
||||
DNS_SERVER2="1.1.1.1"
|
||||
DNS_STRATEGY="prefer_ipv4"
|
||||
else
|
||||
DNS_SERVER1="8.8.8.8"
|
||||
DNS_SERVER2="1.1.1.1"
|
||||
DNS_STRATEGY="prefer_ipv4"
|
||||
fi
|
||||
|
||||
cat >"$CONFIG_DIR/config.json" <<EOF
|
||||
{
|
||||
"log": {
|
||||
"disabled": false,
|
||||
"level": "info"
|
||||
},
|
||||
"dns": {
|
||||
"servers": [
|
||||
{
|
||||
"address": "tls://8.8.8.8"
|
||||
"type": "tls",
|
||||
"server": "$DNS_SERVER1",
|
||||
"server_port": 853,
|
||||
"tls": { "min_version": "1.2" }
|
||||
},
|
||||
{
|
||||
"type": "tls",
|
||||
"server": "$DNS_SERVER2",
|
||||
"server_port": 853,
|
||||
"tls": { "min_version": "1.2" }
|
||||
}
|
||||
]
|
||||
],
|
||||
"strategy": "$DNS_STRATEGY"
|
||||
},
|
||||
"inbounds": [
|
||||
{
|
||||
"type": "vless",
|
||||
"tag": "VLESSReality",
|
||||
"listen": "::",
|
||||
"listen_port": 443,
|
||||
"listen_port": ${PORT},
|
||||
"users": [
|
||||
{
|
||||
"name": "$NAME",
|
||||
"uuid": "$UUID",
|
||||
"name": "${NAME}",
|
||||
"uuid": "${UUID}",
|
||||
"flow": "xtls-rprx-vision"
|
||||
}
|
||||
],
|
||||
"tls": {
|
||||
"enabled": true,
|
||||
"server_name": "$SNI",
|
||||
"server_name": "${SNI}",
|
||||
"reality": {
|
||||
"enabled": true,
|
||||
"handshake": {
|
||||
"server": "$SNI",
|
||||
"server": "${SNI}",
|
||||
"server_port": 443
|
||||
},
|
||||
"private_key": "$PRIVATE_KEY",
|
||||
"short_id": "$SHORT_ID"
|
||||
"private_key": "${PRIVATE_KEY}",
|
||||
"short_id": "${SHORT_ID}"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"route": {
|
||||
"rules": [
|
||||
{ "type": "default", "outbound": "direct" }
|
||||
]
|
||||
},
|
||||
"outbounds": [
|
||||
{
|
||||
"type": "direct"
|
||||
}
|
||||
{ "type": "direct", "tag": "direct" }
|
||||
]
|
||||
}
|
||||
EOF
|
||||
@@ -155,37 +220,7 @@ EOF
|
||||
|
||||
systemctl enable sing-box.service
|
||||
systemctl restart sing-box.service
|
||||
printf "${GREEN}安装并启动完成。${NC}\n"
|
||||
}
|
||||
|
||||
# 更换 SNI 域名
|
||||
change_sni() {
|
||||
printf "${CYAN}===== 更换 SNI 域名 =====${NC}\n"
|
||||
[[ -f "$CONFIG_DIR/config.json" ]] || {
|
||||
printf "${RED}配置文件不存在,请先安装。${NC}\n"
|
||||
return
|
||||
}
|
||||
|
||||
printf "${YELLOW}请输入新的 SNI 域名 (当前: $(
|
||||
source "$STATE_FILE"
|
||||
echo "$SNI"
|
||||
)):${NC}"
|
||||
read -r NEW_SNI
|
||||
[[ -z "$NEW_SNI" ]] && {
|
||||
printf "${RED}SNI 域名不能为空,取消更换。${NC}\n"
|
||||
return
|
||||
}
|
||||
|
||||
# 替换 config.json 中的 SNI 字段
|
||||
sed -i "s/\"server_name\":\s*\"[^\"]*\"/\"server_name\": \"$NEW_SNI\"/" "$CONFIG_DIR/config.json"
|
||||
sed -i "s/\"server\":\s*\"[^\"]*\"/\"server\": \"$NEW_SNI\"/" "$CONFIG_DIR/config.json"
|
||||
|
||||
# 替换 state.env 中的 SNI
|
||||
sed -i "s/^SNI=.*/SNI=\"$NEW_SNI\"/" "$STATE_FILE"
|
||||
|
||||
systemctl restart sing-box.service &&
|
||||
printf "${GREEN}SNI 已更换为 $NEW_SNI,服务已重启。${NC}\n" ||
|
||||
printf "${RED}服务重启失败,请手动检查。${NC}\n"
|
||||
printf "${GREEN}安装并启动完成,DNS 已根据网络类型自动配置。${NC}\n"
|
||||
}
|
||||
|
||||
# 查看服务状态
|
||||
@@ -198,6 +233,20 @@ status_singbox() {
|
||||
fi
|
||||
}
|
||||
|
||||
# 开启服务
|
||||
start_singbox() {
|
||||
systemctl daemon-reload
|
||||
systemctl enable sing-box.service 2>/dev/null || true
|
||||
systemctl start sing-box.service 2>/dev/null || true
|
||||
}
|
||||
|
||||
# 停止服务
|
||||
stop_singbox(){
|
||||
systemctl stop sing-box.service 2>/dev/null || true
|
||||
systemctl disable sing-box.service 2>/dev/null || true
|
||||
systemctl daemon-reload
|
||||
}
|
||||
|
||||
# 显示 VLESS Reality 链接 + 二维码
|
||||
show_link() {
|
||||
printf "${CYAN}===== 您的 VLESS Reality 链接 =====${NC}\n"
|
||||
@@ -210,9 +259,9 @@ show_link() {
|
||||
SNI=$(grep -oP '"server_name"\s*:\s*"\K[^"]+' "$CONFIG_DIR/config.json")
|
||||
PUB_KEY=$(grep -oP '"public_key"\s*:\s*"\K[^"]+' "$CONFIG_DIR/config.json")
|
||||
SHORT_ID=$(grep -oP '"short_id"\s*:\s*"\K[^"]+' "$CONFIG_DIR/config.json")
|
||||
FP="chrome"
|
||||
SERVER_IP=$(curl -s https://ifconfig.me)
|
||||
PORT=443
|
||||
FP="firefox"
|
||||
SERVER_IP=$(get_server_ip)
|
||||
PORT=$(grep -oP '"listen_port"\s*:\s*\K[^,}]+' "$CONFIG_DIR/config.json")
|
||||
SPX="/"
|
||||
|
||||
# 保存新的 state.env
|
||||
@@ -236,7 +285,13 @@ EOF
|
||||
|
||||
# 读取 state.env
|
||||
source "$STATE_FILE"
|
||||
LINK="vless://${UUID}@${SERVER_IP}:${PORT}?security=reality&sni=${SNI}&fp=${FP}&pbk=${PUB_KEY}&sid=${SHORT_ID}&spx=${SPX}&type=tcp&flow=xtls-rprx-vision&encryption=none#${NAME}"
|
||||
|
||||
local formatted_ip="$SERVER_IP"
|
||||
if [[ "$SERVER_IP" =~ ":" ]]; then
|
||||
formatted_ip="[$SERVER_IP]"
|
||||
fi
|
||||
|
||||
LINK="vless://${UUID}@${formatted_ip}:${PORT}?security=reality&sni=${SNI}&fp=${FP}&pbk=${PUB_KEY}&sid=${SHORT_ID}&spx=${SPX}&type=tcp&flow=xtls-rprx-vision&encryption=none#${NAME}"
|
||||
|
||||
printf "${GREEN}%s${NC}\n\n" "$LINK"
|
||||
|
||||
@@ -254,16 +309,25 @@ EOF
|
||||
# 卸载 Sing-box
|
||||
uninstall_singbox() {
|
||||
printf "${CYAN}===== 卸载 Sing-box =====${NC}\n"
|
||||
|
||||
# 停止并禁用服务
|
||||
systemctl stop sing-box.service 2>/dev/null || true
|
||||
systemctl disable sing-box.service 2>/dev/null || true
|
||||
rm -rf "$CONFIG_DIR"
|
||||
if command -v apt-get &>/dev/null; then
|
||||
apt-get remove -y sing-box
|
||||
elif command -v yum &>/dev/null; then
|
||||
yum remove -y sing-box
|
||||
elif command -v pacman &>/dev/null; then
|
||||
pacman -Rss --noconfirm sing-box
|
||||
fi
|
||||
systemctl daemon-reload
|
||||
|
||||
# 删除服务文件
|
||||
rm -f /etc/systemd/system/sing-box.service
|
||||
|
||||
# 删除配置目录
|
||||
rm -rf /etc/singbox
|
||||
rm -rf /etc/sing-box
|
||||
|
||||
# 删除 Sing-box 可执行文件
|
||||
rm -f /usr/bin/sing-box
|
||||
|
||||
# 删除 env 文件
|
||||
rm -f /etc/sing-box/state.env
|
||||
|
||||
printf "${GREEN}卸载完成。${NC}\n"
|
||||
}
|
||||
|
||||
@@ -273,6 +337,149 @@ reinstall_singbox() {
|
||||
install_singbox
|
||||
}
|
||||
|
||||
# 升级/安装 Sing-box 二进制
|
||||
update_singbox() {
|
||||
printf "${CYAN}===== 升级/安装 Sing-box 二进制 =====${NC}\n"
|
||||
|
||||
set -e -o pipefail
|
||||
|
||||
# 检测体系架构
|
||||
ARCH_RAW=$(uname -m)
|
||||
case "${ARCH_RAW}" in
|
||||
'x86_64') ARCH='amd64';;
|
||||
'x86' | 'i686' | 'i386') ARCH='386';;
|
||||
'aarch64' | 'arm64') ARCH='arm64';;
|
||||
'armv7l') ARCH='armv7';;
|
||||
's390x') ARCH='s390x';;
|
||||
*) echo "❌ 不支持的架构: ${ARCH_RAW}"; return 1;;
|
||||
esac
|
||||
|
||||
# 检测网络类型
|
||||
local network_type=$(detect_network_type)
|
||||
echo "🌐 当前网络模式: $network_type"
|
||||
|
||||
local curl_opts=""
|
||||
case "$network_type" in
|
||||
"ipv6")
|
||||
curl_opts="-6"
|
||||
echo "📡 使用 IPv6 连接"
|
||||
;;
|
||||
"dual")
|
||||
echo "📡 双栈网络,优先使用 IPv4"
|
||||
;;
|
||||
"ipv4")
|
||||
curl_opts="-4"
|
||||
echo "📡 使用 IPv4 连接"
|
||||
;;
|
||||
"none")
|
||||
echo "⚠️ 无法检测到网络连接,尝试默认方式"
|
||||
;;
|
||||
esac
|
||||
|
||||
# 获取最新版本号
|
||||
VERSION=$(curl $curl_opts -fsSL --connect-timeout 15 https://api.github.com/repos/SagerNet/sing-box/releases/latest 2>/dev/null |
|
||||
grep '"tag_name"' | head -n1 | cut -d '"' -f4 | sed 's/^v//') || VERSION=""
|
||||
|
||||
if [[ -z "$VERSION" ]]; then
|
||||
echo "⚠️ 获取版本失败,尝试备用源..."
|
||||
VERSION=$(curl $curl_opts -fsSL --connect-timeout 15 https://fastly.jsdelivr.net/gh/SagerNet/sing-box@latest/version.txt 2>/dev/null || echo "")
|
||||
fi
|
||||
|
||||
[[ -z "$VERSION" ]] && { echo "❌ 无法获取最新版本号"; return 1; }
|
||||
|
||||
echo "🔖 最新版本:v${VERSION}"
|
||||
PKG_URL="https://github.com/SagerNet/sing-box/releases/download/v${VERSION}/sing-box_${VERSION}_linux_${ARCH}.deb"
|
||||
|
||||
echo "⬇️ 正在下载 ${PKG_URL}"
|
||||
curl $curl_opts -fL --connect-timeout 30 -o /tmp/sing-box.deb "$PKG_URL" || {
|
||||
echo "❌ 下载失败,请检查网络。"
|
||||
return 1
|
||||
}
|
||||
|
||||
sudo dpkg -i /tmp/sing-box.deb || {
|
||||
echo "⚠️ dpkg 安装失败,尝试修复依赖..."
|
||||
sudo apt-get install -f -y
|
||||
sudo dpkg -i /tmp/sing-box.deb
|
||||
}
|
||||
|
||||
rm -f /tmp/sing-box.deb
|
||||
|
||||
NEW_VER=$($BIN_NAME version 2>/dev/null | head -n1 | awk '{print $NF}')
|
||||
echo "✅ Sing-box 已升级到版本:$NEW_VER"
|
||||
echo "🔁 正在重启服务..."
|
||||
|
||||
if systemctl restart sing-box.service; then
|
||||
systemctl daemon-reload
|
||||
echo "✅ 服务已重启。"
|
||||
else
|
||||
echo "⚠️ 服务重启失败,请手动检查。"
|
||||
fi
|
||||
}
|
||||
|
||||
# 更换 SNI 域名
|
||||
change_sni() {
|
||||
printf "${CYAN}===== 更换 SNI 域名 =====${NC}\n"
|
||||
[[ -f "$CONFIG_DIR/config.json" ]] || {
|
||||
printf "${RED}配置文件不存在,请先安装。${NC}\n"
|
||||
return
|
||||
}
|
||||
|
||||
printf "${YELLOW}请输入新的 SNI 域名 (当前: $(
|
||||
source "$STATE_FILE"
|
||||
echo "$SNI"
|
||||
)):${NC}"
|
||||
read -r NEW_SNI
|
||||
[[ -z "$NEW_SNI" ]] && {
|
||||
printf "${RED}SNI 域名不能为空,取消更换。${NC}\n"
|
||||
return
|
||||
}
|
||||
|
||||
sed -i -E '/"reality": *\{/,/}/ s/"server_name": *"[^"]*"/"server_name": "'"$NEW_SNI"'"/' "$CONFIG_DIR/config.json"
|
||||
sed -i -E '/"handshake": *\{/,/}/ s/"server": *"[^"]*"/"server": "'"$NEW_SNI"'"/' "$CONFIG_DIR/config.json"
|
||||
|
||||
sed -i "s/^SNI=.*/SNI=\"$NEW_SNI\"/" "$STATE_FILE"
|
||||
|
||||
systemctl restart sing-box.service &&
|
||||
printf "${GREEN}SNI 已更换为 $NEW_SNI,服务已重启。${NC}\n" ||
|
||||
printf "${RED}服务重启失败,请手动检查。${NC}\n"
|
||||
}
|
||||
|
||||
# 设置BBR算法
|
||||
set_bbr() {
|
||||
if ! sysctl net.ipv4.tcp_available_congestion_control &>/dev/null; then
|
||||
echo "❌ 系统不支持 TCP 拥塞控制设置"
|
||||
return 1
|
||||
fi
|
||||
|
||||
echo "📋 支持的 TCP 拥塞控制算法:"
|
||||
sysctl net.ipv4.tcp_available_congestion_control
|
||||
|
||||
current=$(sysctl -n net.ipv4.tcp_congestion_control)
|
||||
echo "⚡ 当前使用的算法: $current"
|
||||
|
||||
if [ "$current" == "bbr" ]; then
|
||||
echo "✅ 当前已经在使用 BBR"
|
||||
return 0
|
||||
fi
|
||||
|
||||
read -p "⚠️ 当前使用的不是 BBR,是否切换为 BBR?(y/n): " confirm
|
||||
if [[ "$confirm" =~ ^[Yy]$ ]]; then
|
||||
# 临时生效
|
||||
sudo sysctl -w net.ipv4.tcp_congestion_control=bbr
|
||||
echo "✅ 已切换为 BBR(临时)"
|
||||
|
||||
# 永久生效
|
||||
if ! grep -q "^net.ipv4.tcp_congestion_control" /etc/sysctl.conf; then
|
||||
echo "net.ipv4.tcp_congestion_control = bbr" | sudo tee -a /etc/sysctl.conf
|
||||
else
|
||||
sudo sed -i "s/^net.ipv4.tcp_congestion_control.*/net.ipv4.tcp_congestion_control = bbr/" /etc/sysctl.conf
|
||||
fi
|
||||
echo "✅ 已写入 /etc/sysctl.conf,重启后永久生效"
|
||||
else
|
||||
echo "❌ 未修改 TCP 拥塞控制算法"
|
||||
fi
|
||||
}
|
||||
|
||||
# 更新脚本自身
|
||||
update_self() {
|
||||
local script_path="${BASH_SOURCE[0]}"
|
||||
@@ -282,7 +489,13 @@ update_self() {
|
||||
if command -v curl &>/dev/null; then
|
||||
local url="https://raw.githubusercontent.com/Dichgrem/singbox-example/refs/heads/main/script/singbox.sh"
|
||||
echo "从 $url 下载最新脚本..."
|
||||
if curl -fsSL "$url" -o "$tmp_file"; then
|
||||
|
||||
# 根据网络类型选择curl参数
|
||||
local network_type=$(detect_network_type)
|
||||
local curl_opts=""
|
||||
[[ "$network_type" == "ipv6" ]] && curl_opts="-6"
|
||||
|
||||
if curl $curl_opts -fsSL --connect-timeout 15 "$url" -o "$tmp_file"; then
|
||||
echo "下载成功,准备替换本地脚本..."
|
||||
chmod +x "$tmp_file"
|
||||
mv "$tmp_file" "$script_path"
|
||||
@@ -301,33 +514,52 @@ update_self() {
|
||||
# 菜单主循环
|
||||
check_update
|
||||
printf "${BLUE}当前脚本版本:${SCRIPT_VERSION}${NC}\n"
|
||||
|
||||
# 显示网络类型
|
||||
NETWORK_TYPE=$(detect_network_type)
|
||||
printf "${BLUE}检测到网络类型:${NETWORK_TYPE}${NC}\n"
|
||||
|
||||
# 显示 Sing-box 版本
|
||||
if command -v sing-box >/dev/null 2>&1; then
|
||||
SINGBOX_VERSION=$(sing-box version 2>/dev/null | head -n 1)
|
||||
else
|
||||
SINGBOX_VERSION="未安装"
|
||||
fi
|
||||
printf "${BLUE}当前 Sing-box 版本:${SINGBOX_VERSION}${NC}\n"
|
||||
|
||||
while true; do
|
||||
printf "${BOLD}${BLUE}请选择操作:${NC}\n"
|
||||
printf " ${YELLOW}1)${NC} 安装 Sing-box 并生成配置\n"
|
||||
printf " ${YELLOW}1)${NC} 安装 Sing-box&&Reality\n"
|
||||
printf " ${YELLOW}2)${NC} 查看服务状态\n"
|
||||
printf " ${YELLOW}3)${NC} 显示 VLESS Reality 链接\n"
|
||||
printf " ${YELLOW}4)${NC} 卸载 Sing-box\n"
|
||||
printf " ${YELLOW}5)${NC} 重新安装 Sing-box\n"
|
||||
printf " ${YELLOW}6)${NC} 升级 Sing-box 二进制\n"
|
||||
printf " ${YELLOW}7)${NC} 更换 SNI 域名\n"
|
||||
printf " ${YELLOW}8)${NC} 更新脚本自身\n"
|
||||
printf " ${YELLOW}9)${NC} 退出\n"
|
||||
printf "${BOLD}输入数字 [1-8]: ${NC}"
|
||||
printf " ${YELLOW}3)${NC} 开启服务\n"
|
||||
printf " ${YELLOW}4)${NC} 停止服务\n"
|
||||
printf " ${YELLOW}5)${NC} 卸载服务\n"
|
||||
printf " ${YELLOW}6)${NC} 显示节点链接\n"
|
||||
printf " ${YELLOW}7)${NC} 重新安装 Sing-box\n"
|
||||
printf " ${YELLOW}8)${NC} 升级 Sing-box 二进制\n"
|
||||
printf " ${YELLOW}9)${NC} 更换 SNI 域名\n"
|
||||
printf " ${YELLOW}10)${NC} 设置 BBR 算法\n"
|
||||
printf " ${YELLOW}11)${NC} 更新脚本自身\n"
|
||||
printf " ${YELLOW}0)${NC} 退出\n"
|
||||
printf "${BOLD}输入数字 [0-11]: ${NC}"
|
||||
read -r choice
|
||||
case "$choice" in
|
||||
1) install_singbox ;;
|
||||
2) status_singbox ;;
|
||||
3) show_link ;;
|
||||
4) uninstall_singbox ;;
|
||||
5) reinstall_singbox ;;
|
||||
6) update_singbox ;;
|
||||
7) change_sni ;;
|
||||
8) update_self ;;
|
||||
9)
|
||||
3) start_singbox ;;
|
||||
4) stop_singbox ;;
|
||||
5) uninstall_singbox ;;
|
||||
6) show_link ;;
|
||||
7) reinstall_singbox ;;
|
||||
8) update_singbox ;;
|
||||
9) change_sni ;;
|
||||
10) set_bbr ;;
|
||||
11) update_self ;;
|
||||
0)
|
||||
printf "${GREEN}退出。${NC}\n"
|
||||
exit 0
|
||||
;;
|
||||
*) printf "${RED}无效选项,请重试。${NC}\n" ;;
|
||||
esac
|
||||
echo
|
||||
done
|
||||
done
|
||||
Reference in New Issue
Block a user