mirror of
https://github.com/Ysurac/openmptcprouter-feeds.git
synced 2025-02-15 03:51:51 +00:00
Only flush ipset when it's not a reload
This commit is contained in:
parent
5b394c608f
commit
26cf1ed8fa
1 changed files with 37 additions and 31 deletions
|
@ -36,7 +36,7 @@ _bypass_domain() {
|
||||||
if [ -n "$domain" ]; then
|
if [ -n "$domain" ]; then
|
||||||
domain=$(echo $domain | sed 's:^\.::')
|
domain=$(echo $domain | sed 's:^\.::')
|
||||||
#logger -t "omr-bypass" "Get IPs of $domain..."
|
#logger -t "omr-bypass" "Get IPs of $domain..."
|
||||||
if [ -z $BOOT ]; then
|
if [ -z $RELOAD ]; then
|
||||||
resolve=$(dig a +timeout=3 +nocmd +noall +answer $domain | awk '{print $5}')
|
resolve=$(dig a +timeout=3 +nocmd +noall +answer $domain | awk '{print $5}')
|
||||||
for ip in $resolve; do
|
for ip in $resolve; do
|
||||||
_bypass_ip $ip $intf
|
_bypass_ip $ip $intf
|
||||||
|
@ -185,6 +185,7 @@ _intf_rule() {
|
||||||
[ -z "$count" ] && return
|
[ -z "$count" ] && return
|
||||||
[ -z "$intf" ] && return
|
[ -z "$intf" ] && return
|
||||||
[ "$(echo $1 | grep _dev)" != "" ] && return
|
[ "$(echo $1 | grep _dev)" != "" ] && return
|
||||||
|
[ -z "$RELOAD" ] && {
|
||||||
ipset -q flush omr_dst_bypass_$intf > /dev/null 2>&1
|
ipset -q flush omr_dst_bypass_$intf > /dev/null 2>&1
|
||||||
ipset -q flush omr6_dst_bypass_$intf > /dev/null 2>&1
|
ipset -q flush omr6_dst_bypass_$intf > /dev/null 2>&1
|
||||||
ipset -q --exist restore <<-EOF
|
ipset -q --exist restore <<-EOF
|
||||||
|
@ -209,6 +210,7 @@ _intf_rule() {
|
||||||
ip rule add prio 1 fwmark 0x539$count lookup $count pref 1 > /dev/null 2>&1
|
ip rule add prio 1 fwmark 0x539$count lookup $count pref 1 > /dev/null 2>&1
|
||||||
ip -6 rule add prio 1 fwmark 0x6539$count lookup 6$count > /dev/null 2>&1
|
ip -6 rule add prio 1 fwmark 0x6539$count lookup 6$count > /dev/null 2>&1
|
||||||
fi
|
fi
|
||||||
|
}
|
||||||
if [ "$(iptables -w 40 -t mangle -L | grep omr_dst_bypass_$intf)" = "" ]; then
|
if [ "$(iptables -w 40 -t mangle -L | grep omr_dst_bypass_$intf)" = "" ]; then
|
||||||
iptables-restore --wait=60 --noflush <<-EOF
|
iptables-restore --wait=60 --noflush <<-EOF
|
||||||
*mangle
|
*mangle
|
||||||
|
@ -284,12 +286,14 @@ boot() {
|
||||||
start_service() {
|
start_service() {
|
||||||
#local count
|
#local count
|
||||||
logger -t "omr-bypass" "Starting OMR-ByPass..."
|
logger -t "omr-bypass" "Starting OMR-ByPass..."
|
||||||
|
[ -z "$RELOAD" ] && {
|
||||||
ipset -q flush omr_dst_bypass_all > /dev/null 2>&1
|
ipset -q flush omr_dst_bypass_all > /dev/null 2>&1
|
||||||
ipset -q flush omr6_dst_bypass_all > /dev/null 2>&1
|
ipset -q flush omr6_dst_bypass_all > /dev/null 2>&1
|
||||||
ipset -q --exist restore <<-EOF
|
ipset -q --exist restore <<-EOF
|
||||||
create omr_dst_bypass_all hash:net hashsize 64
|
create omr_dst_bypass_all hash:net hashsize 64
|
||||||
create omr6_dst_bypass_all hash:net family inet6 hashsize 64
|
create omr6_dst_bypass_all hash:net family inet6 hashsize 64
|
||||||
EOF
|
EOF
|
||||||
|
}
|
||||||
|
|
||||||
iptables-save --counters | grep -v omr-bypass | iptables-restore --counters
|
iptables-save --counters | grep -v omr-bypass | iptables-restore --counters
|
||||||
iptables-restore --wait=60 --noflush <<-EOF
|
iptables-restore --wait=60 --noflush <<-EOF
|
||||||
|
@ -398,7 +402,8 @@ start_service() {
|
||||||
config_load omr-bypass
|
config_load omr-bypass
|
||||||
config_foreach _bypass_proto dpis
|
config_foreach _bypass_proto dpis
|
||||||
|
|
||||||
/etc/init.d/dnsmasq restart
|
[ -z "$RELOAD" ] && /etc/init.d/dnsmasq restart
|
||||||
|
[ -n "$RELOAD" ] && /etc/init.d/dnsmasq restart
|
||||||
logger -t "omr-bypass" "OMR-ByPass is running"
|
logger -t "omr-bypass" "OMR-ByPass is running"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -420,5 +425,6 @@ service_triggers() {
|
||||||
|
|
||||||
reload_service() {
|
reload_service() {
|
||||||
[ "$( ipset -n list | grep omr_ )" = "" ] && return 0
|
[ "$( ipset -n list | grep omr_ )" = "" ] && return 0
|
||||||
|
RELOAD=1
|
||||||
start
|
start
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue