summaryrefslogtreecommitdiff
path: root/wg-netns-exec
diff options
context:
space:
mode:
Diffstat (limited to 'wg-netns-exec')
-rwxr-xr-xwg-netns-exec8
1 files changed, 5 insertions, 3 deletions
diff --git a/wg-netns-exec b/wg-netns-exec
index c8e8d94..ee6831e 100755
--- a/wg-netns-exec
+++ b/wg-netns-exec
@@ -121,7 +121,7 @@ if ((enable_tap)); then
[[ "${saddr}" =~ ^${ip_re}:?([^/]*)/?(.*) ]]
saddr="${BASH_REMATCH[1]}"
sport="${BASH_REMATCH[4]}"
- proto="${BASH_REMATCH[5]:-tcp}"
+ proto="${BASH_REMATCH[5]}"
if [[ -n "${daddr}" ]]; then
[[ "${daddr}" =~ ^${ip_re}:?(.*) ]]
@@ -134,8 +134,10 @@ if ((enable_tap)); then
r="iifname ${wg_if}"
[[ -n "${saddr}" ]] && r+=" ip${ip6:+6} saddr ${saddr}"
- [[ -n "${sport}" ]] &&
- r+=" meta l4proto {${proto}} th dport ${sport}"
+ [[ -n "${sport}" || -n "${dport}" ||
+ -n "${proto}" ]] &&
+ r+=" meta l4proto {${proto:-tcp}}"
+ [[ -n "${sport}" ]] && r+=" th dport ${sport}"
dport="${dport:+:${dport}}"
((!ip6)) &&