~providers功能适配1.9.0+版本singboxp内核

~修复启动时提示ip命令相关报错
This commit is contained in:
juewuy 2024-06-08 09:46:40 +08:00
parent 1dee6eaaed
commit 44efdb99ea
2 changed files with 15 additions and 15 deletions

View File

@ -865,10 +865,10 @@ cn_ip_route() { #CN-IP绕过
ckgeo cn_ip.txt china_ip_list.txt ckgeo cn_ip.txt china_ip_list.txt
[ -f "$BINDIR"/cn_ip.txt ] && [ "$firewall_mod" = iptables ] && { [ -f "$BINDIR"/cn_ip.txt ] && [ "$firewall_mod" = iptables ] && {
# see https://raw.githubusercontent.com/Hackl0us/GeoIP2-CN/release/CN-ip-cidr.txt # see https://raw.githubusercontent.com/Hackl0us/GeoIP2-CN/release/CN-ip-cidr.txt
echo "create cn_ip hash:net family inet hashsize 10240 maxelem 10240" >"$TMPDIR"/cn_ip.ipset echo "create cn_ip hash:net family inet hashsize 10240 maxelem 10240" > "$TMPDIR"/cn_ip.ipset
awk '!/^$/&&!/^#/{printf("add cn_ip %s'" "'\n",$0)}' "$BINDIR"/cn_ip.txt >>"$TMPDIR"/cn_ip.ipset awk '!/^$/&&!/^#/{printf("add cn_ip %s'" "'\n",$0)}' "$BINDIR"/cn_ip.txt >> "$TMPDIR"/cn_ip.ipset
ipset destroy cn_ip >/dev/null 2>&1 ipset destroy cn_ip >/dev/null 2>&1
ipset -! restore <"$TMPDIR"/cn_ip.ipset ipset -! restore < "$TMPDIR"/cn_ip.ipset
rm -rf "$TMPDIR"/cn_ip.ipset rm -rf "$TMPDIR"/cn_ip.ipset
} }
} }
@ -877,10 +877,10 @@ cn_ipv6_route() { #CN-IPV6绕过
[ -f "$BINDIR"/cn_ipv6.txt ] && [ "$firewall_mod" = iptables ] && { [ -f "$BINDIR"/cn_ipv6.txt ] && [ "$firewall_mod" = iptables ] && {
#ipv6 #ipv6
#see https://ispip.clang.cn/all_cn_ipv6.txt #see https://ispip.clang.cn/all_cn_ipv6.txt
echo "create cn_ip6 hash:net family inet6 hashsize 5120 maxelem 5120" >"$TMPDIR"/cn_ipv6.ipset echo "create cn_ip6 hash:net family inet6 hashsize 5120 maxelem 5120" > "$TMPDIR"/cn_ipv6.ipset
awk '!/^$/&&!/^#/{printf("add cn_ip6 %s'" "'\n",$0)}' "$BINDIR"/cn_ipv6.txt >>"$TMPDIR"/cn_ipv6.ipset awk '!/^$/&&!/^#/{printf("add cn_ip6 %s'" "'\n",$0)}' "$BINDIR"/cn_ipv6.txt >> "$TMPDIR"/cn_ipv6.ipset
ipset destroy cn_ip6 >/dev/null 2>&1 ipset destroy cn_ip6 >/dev/null 2>&1
ipset -! restore <"$TMPDIR"/cn_ipv6.ipset ipset -! restore < "$TMPDIR"/cn_ipv6.ipset
rm -rf "$TMPDIR"/cn_ipv6.ipset rm -rf "$TMPDIR"/cn_ipv6.ipset
} }
} }
@ -1253,7 +1253,7 @@ start_firewall() { #路由规则总入口
#设置策略路由 #设置策略路由
[ "$firewall_area" != 4 ] && { [ "$firewall_area" != 4 ] && {
local table=100 local table=100
[ "$redir_mod" = "Tproxy模式" ] && ip route add local default dev lo table $table [ "$redir_mod" = "Tproxy模式" ] && ip route add local default dev lo table $table 2>/dev/null
[ "$redir_mod" = "Tun模式" -o "$redir_mod" = "混合模式" ] && { [ "$redir_mod" = "Tun模式" -o "$redir_mod" = "混合模式" ] && {
i=1 i=1
while [ -z "$(ip route list | grep utun)" -a "$i" -le 29 ]; do while [ -z "$(ip route list | grep utun)" -a "$i" -le 29 ]; do
@ -1266,14 +1266,14 @@ start_firewall() { #路由规则总入口
ip route add default dev utun table $table && tun_statu=true ip route add default dev utun table $table && tun_statu=true
fi fi
} }
[ "$firewall_area" = 5 ] && ip route add default via $bypass_host table $table [ "$firewall_area" = 5 ] && ip route add default via $bypass_host table $table 2>/dev/null
[ "$redir_mod" != "Redir模式" ] && ip rule add fwmark $fwmark table $table [ "$redir_mod" != "Redir模式" ] && ip rule add fwmark $fwmark table $table 2>/dev/null
} }
#添加ipv6路由 #添加ipv6路由
[ "$ipv6_redir" = "已开启" -a "$firewall_area" -le 3 ] && { [ "$ipv6_redir" = "已开启" -a "$firewall_area" -le 3 ] && {
[ "$redir_mod" = "Tproxy模式" ] && ip -6 route add local default dev lo table $((table + 1)) [ "$redir_mod" = "Tproxy模式" ] && ip -6 route add local default dev lo table $((table + 1)) 2>/dev/null
[ -n "$(ip route list | grep utun)" ] && ip -6 route add default dev utun table $((table + 1)) [ -n "$(ip route list | grep utun)" ] && ip -6 route add default dev utun table $((table + 1)) 2>/dev/null
[ "$redir_mod" != "Redir模式" ] && ip -6 rule add fwmark $fwmark table $((table + 1)) [ "$redir_mod" != "Redir模式" ] && ip -6 rule add fwmark $fwmark table $((table + 1)) 2>/dev/null
} }
#判断代理用途 #判断代理用途
[ "$firewall_area" = 2 -o "$firewall_area" = 3 ] && [ -n "$(grep '0:7890' /etc/passwd)" ] && local_proxy=true [ "$firewall_area" = 2 -o "$firewall_area" = 3 ] && [ -n "$(grep '0:7890' /etc/passwd)" ] && local_proxy=true

View File

@ -347,7 +347,7 @@ gen_clash_providers(){ #生成clash的providers配置文件
fi fi
cat >> $TMPDIR/providers/providers.yaml <<EOF cat >> $TMPDIR/providers/providers.yaml <<EOF
${1}: ${1}:
type: http type: $type
url: "$download_url" url: "$download_url"
path: "$path" path: "$path"
interval: 43200 interval: 43200
@ -432,7 +432,7 @@ gen_singbox_providers(){ #生成singbox的providers配置文件
cat >> ${TMPDIR}/providers/providers.json <<EOF cat >> ${TMPDIR}/providers/providers.json <<EOF
{ {
"tag": "${1}", "tag": "${1}",
"type": "file", "type": "local",
"healthcheck_url": "https://www.gstatic.com/generate_204", "healthcheck_url": "https://www.gstatic.com/generate_204",
"healthcheck_interval": "10m", "healthcheck_interval": "10m",
"path": "${2}" "path": "${2}"
@ -442,7 +442,7 @@ EOF
cat >> ${TMPDIR}/providers/providers.json <<EOF cat >> ${TMPDIR}/providers/providers.json <<EOF
{ {
"tag": "${1}", "tag": "${1}",
"type": "http", "type": "remote",
"healthcheck_url": "https://www.gstatic.com/generate_204", "healthcheck_url": "https://www.gstatic.com/generate_204",
"healthcheck_interval": "10m", "healthcheck_interval": "10m",
"download_url": "${2}", "download_url": "${2}",