Skip to content
This repository was archived by the owner on Mar 16, 2024. It is now read-only.

Commit 5f62e9d

Browse files
authored
Merge pull request #36 from peterisr/fix-reading-port-and-proto-from-conf
Fix iptables rules in case default OpenVPN port or proto is used.
2 parents f2a5eef + 8f5d3cd commit 5f62e9d

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

data/scripts/entry.sh

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -110,15 +110,18 @@ if [ "$KILL_SWITCH" = "on" ]; then
110110
# strip any comments from line that could mess up cuts
111111
clean_line=${line%% #*}
112112
addr=$(echo "$clean_line" | cut -d " " -f 1)
113-
port=$(echo "$clean_line" | cut -d " " -f 2)
114-
proto=$(echo "$clean_line" | cut -d " " -f 3 | cut -c1-3)
113+
port=$(echo "$clean_line" | cut -s -d " " -f 2)
114+
proto=$(echo "$clean_line" | cut -s -d " " -f 3 | cut -c1-3)
115+
port=${port:-${remote_port:-1194}}
116+
proto=${proto:-${remote_proto:-udp}}
117+
115118
if is_ip "$addr"; then
116-
echo " IP: $addr PORT: $port"
117-
iptables -A OUTPUT -o eth0 -d "$addr" -p "${proto:-$remote_proto}" --dport "${port:-$remote_port}" -j ACCEPT
119+
echo " IP: $addr PORT: $port PROTO: $proto"
120+
iptables -A OUTPUT -o eth0 -d "$addr" -p "${proto}" --dport "${port}" -j ACCEPT
118121
else
119122
for ip in $(dig -4 +short "$addr"); do
120-
echo " $addr (IP: $ip PORT: $port)"
121-
iptables -A OUTPUT -o eth0 -d "$ip" -p "${proto:-$remote_proto}" --dport "${port:-$remote_port}" -j ACCEPT
123+
echo " $addr (IP: $ip PORT: $port PROTO: $proto)"
124+
iptables -A OUTPUT -o eth0 -d "$ip" -p "${proto}" --dport "${port}" -j ACCEPT
122125
done
123126
fi
124127
done

0 commit comments

Comments
 (0)