Skip to content

Commit

Permalink
Merge pull request #10 from ksurl/nftables
Browse files Browse the repository at this point in the history
detect nftables or legacy iptables
  • Loading branch information
kaysond authored Dec 3, 2021
2 parents b57bf7e + 57227b4 commit 0882afb
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
12 changes: 9 additions & 3 deletions trafficjam-functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -190,11 +190,17 @@ function get_local_load_balancer_ip() {
fi
}

function iptables_tj() {
function detect_iptables_version() {
if iptables-nft -L DOCKER-USER &> /dev/null; then
IPTABLES_CMD=iptables-nft
fi
}

function iptables_tj() {
if [[ "$NETWORK_DRIVER" == "overlay" ]]; then
nsenter --net="$NETNS" -- iptables "$@"
nsenter --net="$NETNS" -- $IPTABLES_CMD "$@"
else
iptables "$@"
$IPTABLES_CMD "$@"
fi
}

Expand Down
5 changes: 5 additions & 0 deletions trafficjam.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ TJINSTANCE=$(echo -n "$NETWORK $WHITELIST_FILTER" | gzip -c | tail -c8 | hexdump
. trafficjam-functions.sh

ERRCOUNT=0

IPTABLES_CMD=iptables

detect_iptables_version

if [[ -n "$SWARM_DAEMON" ]]; then
remove_service

Expand Down

0 comments on commit 0882afb

Please sign in to comment.