summaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
authorTheJackiMonster <thejackimonster@gmail.com>2021-07-01 20:37:51 +0200
committerTheJackiMonster <thejackimonster@gmail.com>2021-07-01 20:37:51 +0200
commite8db1a67cdd270d655e677ffff52f72d5fe4000b (patch)
tree1d76393653187b07dab5ed6ef4d6ff606a4e5ac8 /contrib
parentb6252033387779338051eb617f2594a0b3c851bc (diff)
-added global nodes without NAT to netjail
Signed-off-by: TheJackiMonster <thejackimonster@gmail.com>
Diffstat (limited to 'contrib')
-rwxr-xr-xcontrib/scripts/netjail/netjail_core.sh17
-rwxr-xr-xcontrib/scripts/netjail/netjail_setup_internet.sh50
2 files changed, 60 insertions, 7 deletions
diff --git a/contrib/scripts/netjail/netjail_core.sh b/contrib/scripts/netjail/netjail_core.sh
index 1cdbca816..d070f7220 100755
--- a/contrib/scripts/netjail/netjail_core.sh
+++ b/contrib/scripts/netjail/netjail_core.sh
@@ -28,6 +28,23 @@ netjail_opt() {
printf "%d" 0
}
+netjail_opts() {
+ local OPT=$1
+ local DEF=$2
+ shift 2
+
+ while [ $# -gt 0 ]; do
+ if [ "$1" = "$OPT" ]; then
+ printf "$2"
+ return
+ fi
+
+ shift 1
+ done
+
+ printf "$DEF"
+}
+
netjail_check() {
local NODE_COUNT=$1
local FD_COUNT=$(($(ls /proc/self/fd | wc -w) - 4))
diff --git a/contrib/scripts/netjail/netjail_setup_internet.sh b/contrib/scripts/netjail/netjail_setup_internet.sh
index de8ef8f15..6ae047274 100755
--- a/contrib/scripts/netjail/netjail_setup_internet.sh
+++ b/contrib/scripts/netjail/netjail_setup_internet.sh
@@ -9,15 +9,25 @@ export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
LOCAL_M=$1
GLOBAL_N=$2
-# TODO: globally known peer?
-
shift 2
netjail_check $(($LOCAL_M * $GLOBAL_N))
-# Starts optionally 'stunserver' on "92.68.150.$(($GLOBAL_N + 1))":
+# Starts optionally an amount of nodes without NAT starting with "92.68.151.1"
+KNOWN=$(netjail_opt '--known' $@)
+KNOWN_NUM=$(netjail_opts '--known' 0 $@)
+
+# Starts optionally 'stunserver' on "92.68.150.254":
STUN=$(netjail_opt '--stun' $@)
+if [ $KNOWN -gt 0 ]; then
+ shift 2
+
+ KNOWN=$KNOWN_NUM
+
+ netjail_check $(($LOCAL_M * $GLOBAL_N + $KNOWN))
+fi
+
if [ $STUN -gt 0 ]; then
netjail_check_bin stunserver
@@ -30,19 +40,27 @@ netjail_check_bin $1
LOCAL_GROUP="192.168.15"
GLOBAL_GROUP="92.68.150"
+KNOWN_GROUP="92.68.151"
CLEANUP=0
-echo "Start [local: $LOCAL_GROUP.0/24, global: $GLOBAL_GROUP.0/24, stun: $STUN]"
+echo "Start [local: $LOCAL_GROUP.0/24, global: $GLOBAL_GROUP.0/16, stun: $STUN]"
NETWORK_NET=$(netjail_print_name "n" $GLOBAL_N $LOCAL_M)
netjail_bridge $NETWORK_NET
+for X in $(seq $KNOWN); do
+ KNOWN_NODE=$(netjail_print_name "K" $X)
+
+ netjail_node $KNOWN_NODE
+ netjail_node_link_bridge $KNOWN_NODE $NETWORK_NET "$KNOWN_GROUP.$X" 16
+done
+
for N in $(seq $GLOBAL_N); do
ROUTER=$(netjail_print_name "R" $N)
netjail_node $ROUTER
- netjail_node_link_bridge $ROUTER $NETWORK_NET "$GLOBAL_GROUP.$N" 24
+ netjail_node_link_bridge $ROUTER $NETWORK_NET "$GLOBAL_GROUP.$N" 16
ROUTER_NET=$(netjail_print_name "r" $N)
@@ -72,16 +90,27 @@ KILLING=""
if [ $STUN -gt 0 ]; then
netjail_node $STUN_NODE
- netjail_node_link_bridge $STUN_NODE $NETWORK_NET "$GLOBAL_GROUP.254" 24
+ netjail_node_link_bridge $STUN_NODE $NETWORK_NET "$GLOBAL_GROUP.254" 16
netjail_node_exec $STUN_NODE 0 1 stunserver &
KILLING="$!"
fi
+for X in $(seq $KNOWN); do
+ KNOWN_NODE=$(netjail_print_name "K" $X)
+ INDEX=$(($X - 1))
+
+ FD_X=$(($INDEX * 2 + 3 + 0))
+ FD_Y=$(($INDEX * 2 + 3 + 1))
+
+ netjail_node_exec $KNOWN_NODE $FD_X $FD_Y $@ &
+ WAITING="$! $WAITING"
+done
+
for N in $(seq $GLOBAL_N); do
for M in $(seq $LOCAL_M); do
NODE=$(netjail_print_name "N" $N $M)
- INDEX=$(($LOCAL_M * ($N - 1) + $M - 1))
+ INDEX=$(($LOCAL_M * ($N - 1) + $M - 1 + $KNOWN))
FD_X=$(($INDEX * 2 + 3 + 0))
FD_Y=$(($INDEX * 2 + 3 + 1))
@@ -99,6 +128,13 @@ cleanup() {
netjail_node_clear $STUN_NODE
fi
+ for X in $(seq $KNOWN); do
+ KNOWN_NODE=$(netjail_print_name "K" $X)
+
+ netjail_node_unlink_bridge $KNOWN_NODE $NETWORK_NET
+ netjail_node_clear $KNOWN_NODE
+ done
+
for N in $(seq $GLOBAL_N); do
ROUTER_NET=$(netjail_print_name "r" $N)