Skip to content

Commit

Permalink
optimize script ipv6 condition
Browse files Browse the repository at this point in the history
no more forking a sed process
  • Loading branch information
h0tw1r3 committed Apr 22, 2024
1 parent 2ffaf95 commit 8185b9f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 16 deletions.
9 changes: 3 additions & 6 deletions scripts/shield-trigger
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,9 @@ null_route() {
# louzy detection of IPv4 or IPv6 address
#
TASK="$1"
INET=$(echo "$2" | sed 's/[0-9\.]//g')
if [ -z "$INET" ]
then
INET=""
GW="127.0.0.1"
else
INET=""
GW="127.0.0.1"
if [ "${2#*:}" != "$2" ] ; then
INET="-f inet6"
GW="::1"
fi
Expand Down
12 changes: 2 additions & 10 deletions scripts/shield-trigger-iptables
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,8 @@
#

run_iptables() {
#
# louzy detection of IPv4 or IPv6 address
#
IPT=$(echo "$2" | sed 's/[0-9\.]//g')
if [ -z "$IPT" ]
then
IPT=iptables
else
IPT=ip6tables
fi
IPT="iptables"
[ "${2#*:}" != "$2" ] && IPT="ip6tables"

# switch -A for iptables to -I
if [ "$1" = "-A" ]
Expand Down

0 comments on commit 8185b9f

Please sign in to comment.