diff options
| -rwxr-xr-x | wg-netns-exec | 8 |
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)) && |
