gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gnunet] branch master updated (6b56928ab -> de50c9a2d)


From: gnunet
Subject: [gnunet] branch master updated (6b56928ab -> de50c9a2d)
Date: Wed, 18 Jan 2023 10:50:52 +0100

This is an automated email from the git hooks/post-receive script.

t3sserakt pushed a change to branch master
in repository gnunet.

    from 6b56928ab build: Remove changelog
     new 5e3980c4c TNG: Added topology file for nat upnp test case.
     new 369d046c3 TNG: Added script running miniupnpd on a router node for the 
nat upnp test case.
     new 8e1bf27b1 TNG: Handing over the global number of the router node to 
the script running on that node.
     new c524f91a6 TNG: miniupnpd only works with public IP addresses.
     new 4aec035ea TNG: Changed the format of the interface names to make 
miniupnpd happy.
     new 9d6ace0b9 TNG: Cleanup after scripts which were running on netjail 
nodes.
     new de50c9a2d Merge branch 'master' of ssh://git.gnunet.org/gnunet

The 7 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 contrib/netjail/netjail_core.sh                    | 19 ++++++++++---------
 contrib/netjail/netjail_start.sh                   | 15 ++++++++++++---
 contrib/netjail/netjail_stop.sh                    |  6 ++++++
 src/testing/gnunet-cmds-helper.c                   | 12 ++++++++++++
 src/testing/testing.c                              | 12 ++++++++++++
 .../testing_api_cmd_netjail_start_cmds_helper.c    |  3 ++-
 src/transport/test_transport_nat_upnp_topo.conf    |  7 +++++++
 src/transport/upnp.sh                              | 22 ++++++++++++++++++++++
 8 files changed, 83 insertions(+), 13 deletions(-)
 create mode 100644 src/transport/test_transport_nat_upnp_topo.conf
 create mode 100755 src/transport/upnp.sh

diff --git a/contrib/netjail/netjail_core.sh b/contrib/netjail/netjail_core.sh
index 8c1744853..302ae922f 100755
--- a/contrib/netjail/netjail_core.sh
+++ b/contrib/netjail/netjail_core.sh
@@ -1,7 +1,8 @@
 #!/bin/bash
 #
 
-
+INTERFACE_FORMAT_STRING="%s%06x-%06x"
+PREPREFIX=if
 PREFIX=${PPID:?must run from a parent process}
 
 # running with `sudo` is required to be
@@ -93,7 +94,7 @@ netjail_check_bin() {
 netjail_bridge() {
        netjail_next_interface
        local NUM=$RESULT
-       local BRIDGE=$(printf "%06x-%08x" $PREFIX $NUM)
+       local BRIDGE=$(printf $INTERFACE_FORMAT_STRING $PREPREFIX $PREFIX $NUM)
 
        ip link add $BRIDGE type bridge
        ip link set dev $BRIDGE up
@@ -104,7 +105,7 @@ netjail_bridge() {
 netjail_bridge_name() {
        netjail_next_interface
        local NUM=$RESULT
-       local BRIDGE=$(printf "%06x-%08x" $PREFIX $NUM)
+       local BRIDGE=$(printf $INTERFACE_FORMAT_STRING $PREPREFIX $PREFIX $NUM)
        
        RESULT=$BRIDGE
 }
@@ -118,7 +119,7 @@ netjail_bridge_clear() {
 netjail_node() {
        netjail_next_namespace
        local NUM=$RESULT
-       local NODE=$(printf "%06x-%08x" $PREFIX $NUM)
+       local NODE=$(printf $INTERFACE_FORMAT_STRING $PREPREFIX $PREFIX $NUM)
 
        ip netns add $NODE
        
@@ -128,7 +129,7 @@ netjail_node() {
 netjail_node_name() {
        netjail_next_namespace
        local NUM=$RESULT
-       local NODE=$(printf "%06x-%08x" $PREFIX $NUM)
+       local NODE=$(printf $INTERFACE_FORMAT_STRING $PREPREFIX $PREFIX $NUM)
        
        RESULT=$NODE
 }
@@ -150,8 +151,8 @@ netjail_node_link_bridge() {
        netjail_next_interface
        local NUM_BR=$RESULT
        
-       local LINK_IF=$(printf "%06x-%08x" $PREFIX $NUM_IF)
-       local LINK_BR=$(printf "%06x-%08x" $PREFIX $NUM_BR)
+       local LINK_IF=$(printf $INTERFACE_FORMAT_STRING $PREPREFIX $PREFIX 
$NUM_IF)
+       local LINK_BR=$(printf $INTERFACE_FORMAT_STRING $PREPREFIX $PREFIX 
$NUM_BR)
 
        ip link add $LINK_IF type veth peer name $LINK_BR
        ip link set $LINK_IF netns $NODE
@@ -172,7 +173,7 @@ netjail_node_link_bridge_name() {
        netjail_next_interface
        local NUM_BR=$RESULT
        
-       local LINK_BR=$(printf "%06x-%08x" $PREFIX $NUM_BR)
+       local LINK_BR=$(printf $INTERFACE_FORMAT_STRING $PREPREFIX $PREFIX 
$NUM_BR)
        
        RESULT=$LINK_BR
 }
@@ -192,7 +193,7 @@ netjail_node_add_nat() {
   ip netns exec $NODE nft add table nat
   ip netns exec $NODE nft add chain nat postrouting { type nat hook 
postrouting priority 0 \; }
   ip netns exec $NODE nft add rule ip nat postrouting ip saddr 
"$ADDRESS/$MASK" counter masquerade
-       # ip netns exec $NODE iptables -t nat -A POSTROUTING -s 
"$ADDRESS/$MASK" -j MASQUERADE
+  # ip netns exec $NODE iptables -t nat -A POSTROUTING -s "$ADDRESS/$MASK" -j 
MASQUERADE
 }
 
 netjail_node_add_default() {
diff --git a/contrib/netjail/netjail_start.sh b/contrib/netjail/netjail_start.sh
index 5e613048f..e68745746 100755
--- a/contrib/netjail/netjail_start.sh
+++ b/contrib/netjail/netjail_start.sh
@@ -24,8 +24,17 @@ fi
 shift 2
 
 LOCAL_GROUP="192.168.15"
-GLOBAL_GROUP="172.16.150"
-KNOWN_GROUP="172.16.151"
+GLOBAL_GROUP="92.68.150"
+KNOWN_GROUP="92.68.151"
+# Use the IP addresses below instead of the public ones,
+# if the script was not started from within a new namespace
+# created by unshare. The UPNP test case needs public IP
+# addresse for miniupnpd to function.
+# FIXME The ip addresses are used in the c code too. We should
+# introduce a switch indicating if public addresses should be
+# used or not. This info has to be propagated to the c code.
+#GLOBAL_GROUP="172.16.150"
+#KNOWN_GROUP="172.16.151"
 
 if [ $BROADCAST -eq 0  ]; then
    PORT="60002"
@@ -123,6 +132,6 @@ for N in $(seq $GLOBAL_N); do
     fi
     if [ "" != "${R_SCRIPT[$N]}" ]
     then
-        ip netns exec ${ROUTERS[$N]} ./${R_SCRIPT[$N]}
+        ip netns exec ${ROUTERS[$N]} ./${R_SCRIPT[$N]} ${ROUTER_NETS[$N]} 1
     fi
 done
diff --git a/contrib/netjail/netjail_stop.sh b/contrib/netjail/netjail_stop.sh
index c8739dc94..55bcf2a5e 100755
--- a/contrib/netjail/netjail_stop.sh
+++ b/contrib/netjail/netjail_stop.sh
@@ -43,6 +43,12 @@ for N in $(seq $GLOBAL_N); do
     netjail_node_link_bridge_name
     ROUTER_LINKS[$N]=$RESULT
 
+    if [ -d /tmp/netjail_scripts ]
+    then
+        ip netns exec ${ROUTERS[$N]} ./${R_SCRIPT[$N]} ${ROUTER_NETS[$N]} 0
+        rm -rf /tmp/netjail_scripts
+    fi
+
     netjail_node_unlink_bridge ${ROUTER_LINKS[$N]}
     
        for M in $(seq $LOCAL_M); do
diff --git a/src/testing/gnunet-cmds-helper.c b/src/testing/gnunet-cmds-helper.c
index 90b686891..de50aca3a 100644
--- a/src/testing/gnunet-cmds-helper.c
+++ b/src/testing/gnunet-cmds-helper.c
@@ -61,9 +61,21 @@
 
 #define NODE_BASE_IP "192.168.15."
 
+#define KNOWN_BASE_IP "92.68.151."
+
+#define ROUTER_BASE_IP "92.68.150."
+
+/* Use the IP addresses below instead of the public ones,
+ * if the start script was not started from within a new namespace
+ * created by unshare. The UPNP test case needs public IP
+ * addresse for miniupnpd to function.
+ * FIXME We should introduce a switch indicating if public 
+ * addresses should be used or not. This info has to be 
+ * propagated from the start script to the c code.
 #define KNOWN_BASE_IP "172.16.151."
 
 #define ROUTER_BASE_IP "172.16.150."
+*/
 
 struct GNUNET_SCHEDULER_Task *finished_task;
 
diff --git a/src/testing/testing.c b/src/testing/testing.c
index f2bf68c08..a1161925b 100644
--- a/src/testing/testing.c
+++ b/src/testing/testing.c
@@ -43,9 +43,21 @@
 
 #define CONNECT_ADDRESS_TEMPLATE "%s-192.168.15.%u"
 
+#define ROUTER_CONNECT_ADDRESS_TEMPLATE "%s-92.68.150.%u"
+
+#define KNOWN_CONNECT_ADDRESS_TEMPLATE "%s-92.68.151.%u"
+
+/* Use the IP addresses below instead of the public ones,
+ * if the start script was not started from within a new namespace
+ * created by unshare. The UPNP test case needs public IP
+ * addresse for miniupnpd to function.
+ * FIXME We should introduce a switch indicating if public 
+ * addresses should be used or not. This info has to be 
+ * propagated from the start script to the c code.
 #define ROUTER_CONNECT_ADDRESS_TEMPLATE "%s-172.16.150.%u"
 
 #define KNOWN_CONNECT_ADDRESS_TEMPLATE "%s-172.16.151.%u"
+*/
 
 #define PREFIX_TCP "tcp"
 
diff --git a/src/testing/testing_api_cmd_netjail_start_cmds_helper.c 
b/src/testing/testing_api_cmd_netjail_start_cmds_helper.c
index c0f238530..545b89b33 100644
--- a/src/testing/testing_api_cmd_netjail_start_cmds_helper.c
+++ b/src/testing/testing_api_cmd_netjail_start_cmds_helper.c
@@ -612,7 +612,8 @@ start_helper (struct NetJailState *ns,
   GNUNET_asprintf (&local_m_char, "%u", ns->local_m);
   GNUNET_asprintf (&global_n_char, "%u",ns->global_n);
   GNUNET_asprintf (&known_char, "%u",ns->known);
-  GNUNET_asprintf (&node_id, "%06x-%08x\n",
+  GNUNET_asprintf (&node_id, "%s%06x-%06x\n",
+                   "if",
                    pid,
                    script_num);
   // GNUNET_asprintf (&topology_data, "'%s'", ns->topology_data);
diff --git a/src/transport/test_transport_nat_upnp_topo.conf 
b/src/transport/test_transport_nat_upnp_topo.conf
new file mode 100644
index 000000000..e02633d4b
--- /dev/null
+++ b/src/transport/test_transport_nat_upnp_topo.conf
@@ -0,0 +1,7 @@
+M:1
+N:1
+X:1
+T:libgnunet_test_transport_plugin_cmd_nat_upnp
+K:1|{connect:{P:1:1:tcp}}
+R:1|{tcp_port:0}|{udp_port:0}|{script:upnp.sh}
+P:1:1|{connect:{K:1:udp}}
\ No newline at end of file
diff --git a/src/transport/upnp.sh b/src/transport/upnp.sh
new file mode 100755
index 000000000..d01a1a1a1
--- /dev/null
+++ b/src/transport/upnp.sh
@@ -0,0 +1,22 @@
+#!/bin/bash
+
+if [ $2 -eq 1 ]
+then
+    if [ ! -d /tmp/netjail_scripts ]
+    then
+        mkdir /tmp/netjail_scripts
+    fi
+
+    ext_ifname=$(ip addr |grep UP|grep "@"|awk -F: '{printf $2"\n"}'|tr  -d " 
"|awk -F@ '{printf $1" "}'|awk '{printf $1}')
+    listening_ip=$(ip addr |grep UP|grep "@"|awk -F: '{printf $2"\n"}'|tr  -d 
" "|awk -F@ '{printf $1" "}'|awk '{printf $2}')
+    uuid=$(uuidgen)
+    cat miniupnpd.conf |sed 
's/#ext_ifname=eth1/ext_ifname='$ext_ifname'/g'|sed 
's/#listening_ip=eth0/listening_ip='$listening_ip'/g'|sed 
's/uuid=73a9cb68-a00b-4d2c-8412-75fc989f0c6/uuid='$uuid'/g'|grep -v "^#"|grep 
-v '^$' > /tmp/netjail_scripts/gargoyle.txt
+    miniupnpd -d -f /tmp/netjail_scripts/gargoyle.txt -P 
/tmp/netjail_scripts/miniupnpd_$1.pid &
+else
+    kill $(cat /tmp/netjail_scripts/miniupnpd_$1.pid)
+fi
+
+
+
+
+

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]