mirror of
https://github.com/Ysurac/openmptcprouter-feeds.git
synced 2025-03-09 15:40:03 +00:00
Set a different ipset to bypass all and one to bypass only shadowsocks
This commit is contained in:
parent
97ff6a8bd5
commit
eedd893c9c
10 changed files with 38 additions and 26 deletions
|
@ -41,7 +41,7 @@ function bypass_add()
|
|||
|
||||
ucic:save("omr-bypass")
|
||||
ucic:commit("omr-bypass")
|
||||
ucic:set_list("dhcp",ucic:get_first("dhcp","dnsmasq"),"ipset",domains_ipset .. "/ss_rules_dst_bypass")
|
||||
ucic:set_list("dhcp",ucic:get_first("dhcp","dnsmasq"),"ipset",domains_ipset .. "/ss_rules_dst_bypass_all")
|
||||
ucic:save("dhcp")
|
||||
ucic:commit("dhcp")
|
||||
luci.sys.exec("/etc/init.d/dnsmasq reload")
|
||||
|
|
|
@ -12,9 +12,9 @@ _bypass_ip() {
|
|||
valid_ip4=$( valid_subnet4 $ip)
|
||||
valid_ip6=$( valid_subnet6 $ip)
|
||||
if [ "$valid_ip4" = "ok" ]; then
|
||||
ipset add ss_rules_dst_bypass $ip
|
||||
ipset add ss_rules_dst_bypass_all $ip
|
||||
elif [ "$valid_ip6" = "ok" ]; then
|
||||
ipset add ss_rules6_dst_bypass $ip
|
||||
ipset add ss_rules6_dst_bypass_all $ip
|
||||
fi
|
||||
}
|
||||
|
||||
|
@ -22,7 +22,7 @@ _bypass_domain() {
|
|||
# Bypass domain even if OMR DNS is not used
|
||||
domains=$(uci -q get dhcp.@dnsmasq[0].ipset)
|
||||
for domain in ${domains//\// }; do
|
||||
if [ -n "$domain" ] && [ "$domain" != "ss_rules_dst_bypass" ]; then
|
||||
if [ -n "$domain" ] && [ "$domain" != "ss_rules_dst_bypass_all" ]; then
|
||||
resolve=$(dig a +nocmd +noall +answer $domain | awk '{print $5}')
|
||||
for ip in $resolve; do
|
||||
_bypass_ip $ip
|
||||
|
@ -43,9 +43,9 @@ _bypass_proto() {
|
|||
}
|
||||
|
||||
start_service() {
|
||||
ipset -q flush ss_rules_dst_bypass > /dev/null 2>&1
|
||||
ipset -q flush ss_rules_dst_bypass_all > /dev/null 2>&1
|
||||
ipset -q --exist restore <<-EOF
|
||||
create ss_rules_dst_bypass hash:net hashsize 64
|
||||
create ss_rules_dst_bypass_all hash:net hashsize 64
|
||||
EOF
|
||||
|
||||
config_load omr-bypass
|
||||
|
@ -55,10 +55,10 @@ start_service() {
|
|||
|
||||
ip rule add prio 1 fwmark 0x539 lookup 991337 > /dev/null 2>&1
|
||||
|
||||
if [ "$(iptables -w 40 -t mangle -L | grep 'match-set ss_rules_dst_bypass dst MARK set')" = "" ]; then
|
||||
if [ "$(iptables -w 40 -t mangle -L | grep 'match-set ss_rules_dst_bypass_all dst MARK set')" = "" ]; then
|
||||
iptables-restore --wait=60 --noflush <<-EOF
|
||||
*mangle
|
||||
-A PREROUTING -m set --match-set ss_rules_dst_bypass dst -j MARK --set-mark 0x539
|
||||
-A PREROUTING -m set --match-set ss_rules_dst_bypass_all dst -j MARK --set-mark 0x539
|
||||
COMMIT
|
||||
EOF
|
||||
fi
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue