1
0
Fork 0
mirror of https://github.com/Ysurac/openmptcprouter-feeds.git synced 2025-03-09 15:40:03 +00:00

Do no create ipset if there is no empty for a protocol

This commit is contained in:
Ycarus (Yannick Chabanois) 2023-05-28 07:51:38 +02:00
parent b80d40f5ec
commit 88e16d51f1

View file

@ -495,47 +495,49 @@ _bypass_proto_without_ndpi() {
[ -z "$intf" ] && intf="all" [ -z "$intf" ] && intf="all"
[ -z "$proto" ] && return [ -z "$proto" ] && return
if [ "$(uci -q get openmptcprouter.settings.ndpi)" == "0" ] || [ "$ndpi" == "0" ]; then if [ "$(uci -q get openmptcprouter.settings.ndpi)" == "0" ] || [ "$ndpi" == "0" ]; then
ipset -q flush bypass_$proto > /dev/null 2>&1 ALLIPS=$(sqlite3 /usr/share/omr-bypass/omr-bypass.db "select ip from ipproto where proto=\"$proto\";" ".exit")
ipset -q --exist restore <<-EOF if [ -n "$ALLIPS" ]; then
create bypass_$proto hash:net hashsize 64 ipset -q flush bypass_$proto > /dev/null 2>&1
EOF ipset -q --exist restore <<-EOF
ALLIPS=$(sqlite3 /usr/share/omr-bypass/omr-bypass.db "select ip from ipproto where proto='"$proto"';" ".exit") create bypass_$proto hash:net hashsize 64
for ip in $ALLIPS; do EOF
ipset -q add bypass_$proto $ip for ip in $ALLIPS; do
done ipset -q add bypass_$proto $ip
if [ "$intf" = "all" ]; then done
if [ "$family" = "ipv4" ] || [ "$family" = "ipv4ipv6" ]; then if [ "$intf" = "all" ]; then
$IPTABLESRESTORE -w --wait=60 --noflush <<-EOF if [ "$family" = "ipv4" ] || [ "$family" = "ipv4ipv6" ]; then
*mangle $IPTABLESRESTORE -w --wait=60 --noflush <<-EOF
-A omr-bypass-dpi -m set --match-set bypass_$proto dst -j MARK --set-mark 0x539 *mangle
-A omr-bypass-dpi -m mark --mark 0x539 -j RETURN -A omr-bypass-dpi -m set --match-set bypass_$proto dst -j MARK --set-mark 0x539
COMMIT -A omr-bypass-dpi -m mark --mark 0x539 -j RETURN
EOF COMMIT
fi EOF
if [ "$disableipv6" = "0" ] && ([ "$family" = "ipv6" ] || [ "$family" = "ipv4ipv6" ]); then fi
$IP6TABLESRESTORE -w --wait=60 --noflush <<-EOF if [ "$disableipv6" = "0" ] && ([ "$family" = "ipv6" ] || [ "$family" = "ipv4ipv6" ]); then
*mangle $IP6TABLESRESTORE -w --wait=60 --noflush <<-EOF
-A omr-bypass6-dpi -m set --match-set bypass_$proto dst -j MARK --set-mark 0x6539 *mangle
-A omr-bypass6-dpi -m mark --mark 0x6539 -j RETURN -A omr-bypass6-dpi -m set --match-set bypass_$proto dst -j MARK --set-mark 0x6539
COMMIT -A omr-bypass6-dpi -m mark --mark 0x6539 -j RETURN
EOF COMMIT
fi EOF
else fi
if [ "$family" = "ipv4" ] || [ "$family" = "ipv4ipv6" ]; then else
$IPTABLESRESTORE -w --wait=60 --noflush <<-EOF if [ "$family" = "ipv4" ] || [ "$family" = "ipv4ipv6" ]; then
*mangle $IPTABLESRESTORE -w --wait=60 --noflush <<-EOF
-A omr-bypass-dpi -m set --match-set bypass_$proto dst -j MARK --set-mark 0x539$intfid *mangle
-A omr-bypass-dpi -m mark --mark 0x539$intfid -j RETURN -A omr-bypass-dpi -m set --match-set bypass_$proto dst -j MARK --set-mark 0x539$intfid
COMMIT -A omr-bypass-dpi -m mark --mark 0x539$intfid -j RETURN
EOF COMMIT
fi EOF
if [ "$disableipv6" = "0" ] && ([ "$family" = "ipv6" ] || [ "$family" = "ipv4ipv6" ]); then fi
$IP6TABLESRESTORE -w --wait=60 --noflush <<-EOF if [ "$disableipv6" = "0" ] && ([ "$family" = "ipv6" ] || [ "$family" = "ipv4ipv6" ]); then
*mangle $IP6TABLESRESTORE -w --wait=60 --noflush <<-EOF
-A omr-bypass6-dpi -m set --match-set bypass_$proto dst -j MARK --set-mark 0x6539$intfid *mangle
-A omr-bypass6-dpi -m mark --mark 0x6539$intfid -j RETURN -A omr-bypass6-dpi -m set --match-set bypass_$proto dst -j MARK --set-mark 0x6539$intfid
COMMIT -A omr-bypass6-dpi -m mark --mark 0x6539$intfid -j RETURN
EOF COMMIT
EOF
fi
fi fi
fi fi
fi fi