mirror of
https://github.com/kiddin9/op-packages.git
synced 2026-11-01 15:13:56 +08:00
🌴 Sync 2026-03-05 23:51:42
This commit is contained in:
1 parent
97c049ed0a
commit
0acff03804
14253 files changed
+3893239
No files matched your search
@@ -0,0 +1,44 @@
|
||||
#!/bin/sh
|
||||
|
||||
. /lib/functions/network.sh
|
||||
|
||||
iptables_insert() {
|
||||
local chain="$1"
|
||||
local position="$2"
|
||||
shift 2
|
||||
|
||||
local line="$(
|
||||
iptables -t "filter" --line-numbers -n -L "$chain" \
|
||||
| wc \
|
||||
| awk '{print $1 - 2}'
|
||||
)"
|
||||
|
||||
[[ "$position" -lt 0 ]] && position=$(( line + 1 + position + 1 ))
|
||||
|
||||
[[ "$position" -lt 1 ]] && position=1
|
||||
[[ "$position" -gt "$(( line + 1 ))" ]] && position="$(( line + 1 ))"
|
||||
|
||||
iptables -t "filter" -I "$chain" $position $@
|
||||
}
|
||||
|
||||
iptables_check_and_insert() {
|
||||
local chain="$1"
|
||||
local position="$2"
|
||||
shift 2
|
||||
|
||||
iptables -t "filter" -C "$chain" $@ 2>/dev/null \
|
||||
|| iptables_insert "$chain" "$position" $@
|
||||
}
|
||||
|
||||
main() {
|
||||
iptables -t "filter" -N "MNH" 2>/dev/null
|
||||
|
||||
network_find_wan wan_iface
|
||||
network_get_device wan_device "$wan_iface"
|
||||
wan_zone=$(fw3 -q device "$wan_device")
|
||||
|
||||
# before REJECT
|
||||
iptables_check_and_insert "zone_${wan_zone}_input" -2 -j MNH
|
||||
}
|
||||
|
||||
main
|
||||
Reference in new issue
Block a user