summaryrefslogtreecommitdiff
path: root/contrib/scripts/netjail/netjail_core.sh
diff options
context:
space:
mode:
authorTheJackiMonster <thejackimonster@gmail.com>2021-05-02 21:33:35 +0200
committerTheJackiMonster <thejackimonster@gmail.com>2021-05-02 21:33:35 +0200
commit2a027d304a09fa9645cb7e121a2650085328fb6c (patch)
tree1697b4ad145c8bdaeee8ad826b7929669cae3e1c /contrib/scripts/netjail/netjail_core.sh
parenta5082240f035f1851715771b0265e25088bb687c (diff)
-added optional stunserver to netjail script
Signed-off-by: TheJackiMonster <thejackimonster@gmail.com>
Diffstat (limited to 'contrib/scripts/netjail/netjail_core.sh')
-rwxr-xr-xcontrib/scripts/netjail/netjail_core.sh29
1 files changed, 29 insertions, 0 deletions
diff --git a/contrib/scripts/netjail/netjail_core.sh b/contrib/scripts/netjail/netjail_core.sh
index 6a18ea902..8dbbeacf1 100755
--- a/contrib/scripts/netjail/netjail_core.sh
+++ b/contrib/scripts/netjail/netjail_core.sh
@@ -9,6 +9,25 @@ JAILOR=${SUDO_USER:?must run in sudo}
export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
+netjail_opt() {
+ OPT=$1
+ shift 1
+
+ INDEX=1
+
+ while [ $# -gt 0 ]; do
+ if [ "$1" = "$OPT" ]; then
+ printf "%d" $INDEX
+ return
+ fi
+
+ INDEX=$(($INDEX + 1))
+ shift 1
+ done
+
+ printf "%d" 0
+}
+
netjail_check() {
NODE_COUNT=$1
@@ -74,6 +93,15 @@ netjail_node_link_bridge() {
ip link set $LINK_BR up
}
+netjail_node_unlink_bridge() {
+ NODE=$1
+ BRIDGE=$2
+
+ LINK_BR="$NODE-$BRIDGE-1"
+
+ ip link delete $LINK_BR
+}
+
netjail_node_add_nat() {
NODE=$1
ADDRESS=$2
@@ -98,3 +126,4 @@ netjail_node_exec() {
unshare -fp --kill-child -- ip netns exec $NODE sudo -u $JAILOR -- $@ 1>& $FD_OUT 0<& $FD_IN
}
+