mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-26 02:11:53 +00:00
* bugfixes for alpha.13 * minor fixes * version bump * start-tunnel workflow * sdk beta 44 * defaultFilter * fix reset-password on tunnel auth * explicitly rebuild types * fix typo * ubuntu-latest runner * add cleanup steps * fix env on attach
29 lines
747 B
Bash
Executable File
29 lines
747 B
Bash
Executable File
#!/bin/bash
|
|
|
|
if [ -z "$sip" ] || [ -z "$dip" ] || [ -z "$sport" ] || [ -z "$dport" ]; then
|
|
>&2 echo 'missing required env var'
|
|
exit 1
|
|
fi
|
|
|
|
rule_exists() {
|
|
iptables -t nat -C "$@" 2>/dev/null
|
|
}
|
|
|
|
apply_rule() {
|
|
if [ "$UNDO" = "1" ]; then
|
|
if rule_exists "$@"; then
|
|
iptables -t nat -D "$@"
|
|
fi
|
|
else
|
|
if ! rule_exists "$@"; then
|
|
iptables -t nat -A "$@"
|
|
fi
|
|
fi
|
|
}
|
|
|
|
apply_rule PREROUTING -p tcp -d $sip --dport $sport -j DNAT --to-destination $dip:$dport
|
|
apply_rule OUTPUT -p tcp -d $sip --dport $sport -j DNAT --to-destination $dip:$dport
|
|
|
|
if [ "$UNDO" = 1 ]; then
|
|
conntrack -D -p tcp -d $sip --dport $sport || true # conntrack returns exit 1 if no connections are active
|
|
fi |