From be91816a3e1aa396d902225b4de72bd9f9c72537 Mon Sep 17 00:00:00 2001
From: joshemb <josh@elixxir.io>
Date: Wed, 12 Apr 2023 11:35:36 -0700
Subject: [PATCH] Fix bug in generation script

---
 broadcast/client-registrar.yaml |  4 ++--
 broadcast/gateway-1.yaml        |  4 ++--
 broadcast/gateway-2.yaml        |  4 ++--
 broadcast/gateway-3.yaml        |  4 ++--
 broadcast/gateway-4.yaml        |  4 ++--
 broadcast/gateway-5.yaml        |  4 ++--
 broadcast/network.config        |  2 +-
 broadcast/permissioning.yaml    |  6 +++---
 broadcast/regCodes.json         |  2 +-
 broadcast/run.sh                |  8 ++++----
 broadcast/server-1.yaml         |  6 +++---
 broadcast/server-2.yaml         |  6 +++---
 broadcast/server-3.yaml         |  6 +++---
 broadcast/server-4.yaml         |  6 +++---
 broadcast/server-5.yaml         |  6 +++---
 broadcast/udb.yaml              |  4 ++--
 generatePackage.py              | 19 ++++++++++++++-----
 17 files changed, 52 insertions(+), 43 deletions(-)

diff --git a/broadcast/client-registrar.yaml b/broadcast/client-registrar.yaml
index c0dbde0..fdb4f5f 100644
--- a/broadcast/client-registrar.yaml
+++ b/broadcast/client-registrar.yaml
@@ -8,9 +8,9 @@ logLevel: 0
 logPath: "results/client-registrar.log"
 
 # Public address, used in NDF it gives to client
-publicAddress: "0.0.0.0:20111"
+publicAddress: "0.0.0.0:20121"
 # The listening port of this server
-port: 20111
+port: 20121
 
 # === REQUIRED FOR ENABLING TLS ===
 # Path to the registration server private key file
diff --git a/broadcast/gateway-1.yaml b/broadcast/gateway-1.yaml
index 4b4f952..132f95c 100644
--- a/broadcast/gateway-1.yaml
+++ b/broadcast/gateway-1.yaml
@@ -16,10 +16,10 @@ loglevel: 2
 log: "results/gateways/gateway-1.log"
 
 # The public IP address and port of the node associated with this gateway
-cmixAddress:  "0.0.0.0:10110"
+cmixAddress:  "0.0.0.0:10120"
 
 # The listening port of this gateway
-Port: 1110
+Port: 1120
 
 # The public IPv4 address of the Gateway, as reported to the network, to use
 # instead of dynamically looking up Gateway's own IP address. If a port is not
diff --git a/broadcast/gateway-2.yaml b/broadcast/gateway-2.yaml
index 410eae6..d182c66 100644
--- a/broadcast/gateway-2.yaml
+++ b/broadcast/gateway-2.yaml
@@ -16,10 +16,10 @@ loglevel: 2
 log: "results/gateways/gateway-2.log"
 
 # The public IP address and port of the node associated with this gateway
-cmixAddress:  "0.0.0.0:10111"
+cmixAddress:  "0.0.0.0:10121"
 
 # The listening port of this gateway
-Port: 1111
+Port: 1121
 
 # The public IPv4 address of the Gateway, as reported to the network, to use
 # instead of dynamically looking up Gateway's own IP address. If a port is not
diff --git a/broadcast/gateway-3.yaml b/broadcast/gateway-3.yaml
index 5e55d5d..294bfc6 100644
--- a/broadcast/gateway-3.yaml
+++ b/broadcast/gateway-3.yaml
@@ -16,10 +16,10 @@ loglevel: 2
 log: "results/gateways/gateway-3.log"
 
 # The public IP address and port of the node associated with this gateway
-cmixAddress:  "0.0.0.0:10112"
+cmixAddress:  "0.0.0.0:10122"
 
 # The listening port of this gateway
-Port: 1112
+Port: 1122
 
 # The public IPv4 address of the Gateway, as reported to the network, to use
 # instead of dynamically looking up Gateway's own IP address. If a port is not
diff --git a/broadcast/gateway-4.yaml b/broadcast/gateway-4.yaml
index de4f19b..7667873 100644
--- a/broadcast/gateway-4.yaml
+++ b/broadcast/gateway-4.yaml
@@ -16,10 +16,10 @@ loglevel: 2
 log: "results/gateways/gateway-4.log"
 
 # The public IP address and port of the node associated with this gateway
-cmixAddress:  "0.0.0.0:10113"
+cmixAddress:  "0.0.0.0:10123"
 
 # The listening port of this gateway
-Port: 1113
+Port: 1123
 
 # The public IPv4 address of the Gateway, as reported to the network, to use
 # instead of dynamically looking up Gateway's own IP address. If a port is not
diff --git a/broadcast/gateway-5.yaml b/broadcast/gateway-5.yaml
index 7d684e0..71ed41a 100644
--- a/broadcast/gateway-5.yaml
+++ b/broadcast/gateway-5.yaml
@@ -16,10 +16,10 @@ loglevel: 2
 log: "results/gateways/gateway-5.log"
 
 # The public IP address and port of the node associated with this gateway
-cmixAddress:  "0.0.0.0:10114"
+cmixAddress:  "0.0.0.0:10124"
 
 # The listening port of this gateway
-Port: 1114
+Port: 1124
 
 # The public IPv4 address of the Gateway, as reported to the network, to use
 # instead of dynamically looking up Gateway's own IP address. If a port is not
diff --git a/broadcast/network.config b/broadcast/network.config
index 14a121f..038a582 100644
--- a/broadcast/network.config
+++ b/broadcast/network.config
@@ -1,4 +1,4 @@
-localhost:1110
+localhost:1120
 # This is the network configuration file. The top line of this file,
 # when not set via command line, is used to determine to which network
 # the integration test will be run against.
diff --git a/broadcast/permissioning.yaml b/broadcast/permissioning.yaml
index 5e25337..32c7965 100644
--- a/broadcast/permissioning.yaml
+++ b/broadcast/permissioning.yaml
@@ -9,7 +9,7 @@ loglevel: 2
 logPath: "results/permissioning.log"
 
 # The listening port of this  server
-port: 20110
+port: 20120
 
 # Database connection information
 dbUsername: ""
@@ -48,7 +48,7 @@ updateIdPath: "results/updateId.txt"
 
 
 # Public address used in NDF to give to client
-registrationAddress: "0.0.0.0:20111"
+registrationAddress: "0.0.0.0:20121"
 
 # Path to whitelisted IPs for client ratelimiting
 whitelistedIpAddressesPath: "whitelist.txt"
@@ -70,7 +70,7 @@ signedPartialNDFOutputPath: "results/permissions-ndfoutput-partial.json"
 udbCertPath: "../keys/cmix.rip.crt"
 # "Location of the user discovery contact file.
 udContactPath: "results/udbContact.bin"
-udbAddress: "127.0.0.1:30110"
+udbAddress: "127.0.0.1:30120"
 
 # Time interval (in minutes) in which the database is
 # checked for banned nodes
diff --git a/broadcast/regCodes.json b/broadcast/regCodes.json
index 65c1247..59ada42 100644
--- a/broadcast/regCodes.json
+++ b/broadcast/regCodes.json
@@ -1 +1 @@
-[{"RegCode": "qxkv", "Order": "CR"},{"RegCode": "bsms", "Order": "CR"},{"RegCode": "axcv", "Order": "CR"},{"RegCode": "vkgs", "Order": "CR"},{"RegCode": "qwuw", "Order": "CR"}]
\ No newline at end of file
+[{"RegCode": "enkf", "Order": "CR"},{"RegCode": "ozxl", "Order": "CR"},{"RegCode": "qgby", "Order": "CR"},{"RegCode": "llhb", "Order": "CR"},{"RegCode": "umks", "Order": "CR"}]
\ No newline at end of file
diff --git a/broadcast/run.sh b/broadcast/run.sh
index 0a2d432..a2b429c 100755
--- a/broadcast/run.sh
+++ b/broadcast/run.sh
@@ -71,7 +71,7 @@ fi
 
 echo "NETWORK: $NETWORKENTRYPOINT"
 
-if [ "$NETWORKENTRYPOINT" == "localhost:1090" ]
+if [ "$NETWORKENTRYPOINT" == "localhost:1120" ]
 then
     source network.sh
 
@@ -80,7 +80,7 @@ else
     echo $NETWORKENTRYPOINT > results/startgwserver.txt
 fi
 
-echo "localhost:1090" > results/startgwserver.txt
+echo "localhost:1120" > results/startgwserver.txt
 
 echo "DONE LETS DO STUFF"
 
@@ -177,7 +177,7 @@ for C in $(ls -1 $CLIENTCLEAN | grep -v client11[01]); do
 done
 
 GOLDOUTPUT=clients.goldoutput
-if [ "$NETWORKENTRYPOINT" != "localhost:1090" ]
+if [ "$NETWORKENTRYPOINT" != "localhost:1120" ]
 then
     rm -fr clients.net_goldoutput || true
     GOLDOUTPUT=clients.net_goldoutput
@@ -200,7 +200,7 @@ fi
 set +x
 diff -aru $GOLDOUTPUT $CLIENTCLEAN
 
-if [ "$NETWORKENTRYPOINT" == "localhost:1090" ]
+if [ "$NETWORKENTRYPOINT" == "localhost:1120" ]
 then
 
     #cat $CLIENTOUT/* | strings | grep -ae "ERROR" -e "FATAL" > results/client-errors || true
diff --git a/broadcast/server-1.yaml b/broadcast/server-1.yaml
index a241b8c..896cd77 100644
--- a/broadcast/server-1.yaml
+++ b/broadcast/server-1.yaml
@@ -1,5 +1,5 @@
 # START YAML ===
-registrationCode: "qxkv"
+registrationCode: "enkf"
 useGPU: false
 devMode: true
 rawPermAddr: true
@@ -18,7 +18,7 @@ cmix:
     log:  "results/servers/server-1.log"
     errOutput: "results/servers/server-1.err"
     ipListOutput: "results/servers/iplist-1.txt"
-  port: "10110"
+  port: "10120"
   overridePublicIP: "127.0.0.1"
 database:
   name: "cmix_server"
@@ -34,7 +34,7 @@ scheduling:
     # Path to the self signed TLS cert used by the permissioning. Provided by xx network
     cert: "../keys/cmix.rip.crt"
   # IP Address of the permissioning server, provided by xx network
-  address: "0.0.0.0:20110"
+  address: "0.0.0.0:20120"
 metrics:
   # location of stored metrics data. Modification to set to permissioning
   # server instead of saving will be made at a later date
diff --git a/broadcast/server-2.yaml b/broadcast/server-2.yaml
index d68cbf2..e4e7189 100644
--- a/broadcast/server-2.yaml
+++ b/broadcast/server-2.yaml
@@ -1,5 +1,5 @@
 # START YAML ===
-registrationCode: "bsms"
+registrationCode: "ozxl"
 useGPU: false
 devMode: true
 rawPermAddr: true
@@ -18,7 +18,7 @@ cmix:
     log:  "results/servers/server-2.log"
     errOutput: "results/servers/server-2.err"
     ipListOutput: "results/servers/iplist-1.txt"
-  port: "10111"
+  port: "10121"
   overridePublicIP: "127.0.0.1"
 database:
   name: "cmix_server"
@@ -34,7 +34,7 @@ scheduling:
     # Path to the self signed TLS cert used by the permissioning. Provided by xx network
     cert: "../keys/cmix.rip.crt"
   # IP Address of the permissioning server, provided by xx network
-  address: "0.0.0.0:20110"
+  address: "0.0.0.0:20120"
 metrics:
   # location of stored metrics data. Modification to set to permissioning
   # server instead of saving will be made at a later date
diff --git a/broadcast/server-3.yaml b/broadcast/server-3.yaml
index a45b687..4672d8b 100644
--- a/broadcast/server-3.yaml
+++ b/broadcast/server-3.yaml
@@ -1,5 +1,5 @@
 # START YAML ===
-registrationCode: "axcv"
+registrationCode: "qgby"
 useGPU: false
 devMode: true
 rawPermAddr: true
@@ -18,7 +18,7 @@ cmix:
     log:  "results/servers/server-3.log"
     errOutput: "results/servers/server-3.err"
     ipListOutput: "results/servers/iplist-1.txt"
-  port: "10112"
+  port: "10122"
   overridePublicIP: "127.0.0.1"
 database:
   name: "cmix_server"
@@ -34,7 +34,7 @@ scheduling:
     # Path to the self signed TLS cert used by the permissioning. Provided by xx network
     cert: "../keys/cmix.rip.crt"
   # IP Address of the permissioning server, provided by xx network
-  address: "0.0.0.0:20110"
+  address: "0.0.0.0:20120"
 metrics:
   # location of stored metrics data. Modification to set to permissioning
   # server instead of saving will be made at a later date
diff --git a/broadcast/server-4.yaml b/broadcast/server-4.yaml
index 17d87e0..ddf363c 100644
--- a/broadcast/server-4.yaml
+++ b/broadcast/server-4.yaml
@@ -1,5 +1,5 @@
 # START YAML ===
-registrationCode: "vkgs"
+registrationCode: "llhb"
 useGPU: false
 devMode: true
 rawPermAddr: true
@@ -18,7 +18,7 @@ cmix:
     log:  "results/servers/server-4.log"
     errOutput: "results/servers/server-4.err"
     ipListOutput: "results/servers/iplist-1.txt"
-  port: "10113"
+  port: "10123"
   overridePublicIP: "127.0.0.1"
 database:
   name: "cmix_server"
@@ -34,7 +34,7 @@ scheduling:
     # Path to the self signed TLS cert used by the permissioning. Provided by xx network
     cert: "../keys/cmix.rip.crt"
   # IP Address of the permissioning server, provided by xx network
-  address: "0.0.0.0:20110"
+  address: "0.0.0.0:20120"
 metrics:
   # location of stored metrics data. Modification to set to permissioning
   # server instead of saving will be made at a later date
diff --git a/broadcast/server-5.yaml b/broadcast/server-5.yaml
index fbc6865..91e72d1 100644
--- a/broadcast/server-5.yaml
+++ b/broadcast/server-5.yaml
@@ -1,5 +1,5 @@
 # START YAML ===
-registrationCode: "qwuw"
+registrationCode: "umks"
 useGPU: false
 devMode: true
 rawPermAddr: true
@@ -18,7 +18,7 @@ cmix:
     log:  "results/servers/server-5.log"
     errOutput: "results/servers/server-5.err"
     ipListOutput: "results/servers/iplist-1.txt"
-  port: "10114"
+  port: "10124"
   overridePublicIP: "127.0.0.1"
 database:
   name: "cmix_server"
@@ -34,7 +34,7 @@ scheduling:
     # Path to the self signed TLS cert used by the permissioning. Provided by xx network
     cert: "../keys/cmix.rip.crt"
   # IP Address of the permissioning server, provided by xx network
-  address: "0.0.0.0:20110"
+  address: "0.0.0.0:20120"
 metrics:
   # location of stored metrics data. Modification to set to permissioning
   # server instead of saving will be made at a later date
diff --git a/broadcast/udb.yaml b/broadcast/udb.yaml
index ebb8725..dae82f8 100644
--- a/broadcast/udb.yaml
+++ b/broadcast/udb.yaml
@@ -3,8 +3,8 @@ log: "./results/udb.log"
 sessionPath: "./results/udbsession"
 sessionPass: "hello"
 certPath: "../keys/cmix.rip.crt"
-port: "30110"
+port: "30120"
 keyPath: "../keys/cmix.rip.key"
 permCertPath: "../keys/cmix.rip.crt"
-permAddress: "0.0.0.0:20110"
+permAddress: "0.0.0.0:20120"
 devMode: true
\ No newline at end of file
diff --git a/generatePackage.py b/generatePackage.py
index efd3bb9..a76bca8 100755
--- a/generatePackage.py
+++ b/generatePackage.py
@@ -5,6 +5,7 @@ import os
 import string
 import random
 import argparse
+import re
 from collections.abc import Sequence
 # Generates a random string
 def random_string(stringLength=4):
@@ -34,7 +35,7 @@ def create_ports_list(offset, manualOffset=0):
         while regCode in node_regCodes:
             regCode = random_string()
         node_regCodes.append(regCode)
-    
+
     permissioningPort = 20000 + 10 * offset
 
     udbPort = 30000 + 10 * offset
@@ -120,13 +121,13 @@ def generate_server_side_config(offset: int, newPackage: string):
     reg_json = ""
     with open("gen/registration.json") as f:
         reg_json = f.read()
-    
+
     # Open udb proto file
     udb_proto = ""
     with open("gen/udbProto.json") as f:
         udb_proto = f.read()
 
-    # Create package 
+    # Create package
     if not os.path.exists(newPackage):
         os.makedirs(newPackage)
 
@@ -196,7 +197,7 @@ def generate_server_side_config(offset: int, newPackage: string):
             .replace("{udb_port}", str(udbPort))\
             .replace("{registration_port}", str(perm_port+1))
         f.write(reg_template)
-   
+
    # Generate registration configs
     with open("{}/registration.json".format(newPackage), "w") as f:
         f.write(reg_json)
@@ -204,7 +205,7 @@ def generate_server_side_config(offset: int, newPackage: string):
     with open("{}/client-registrar.yaml".format(newPackage), "w") as f:
         client_reg_template = client_reg_template.replace("{registration_port}", str(perm_port+1))
         f.write(client_reg_template)
-    
+
     with open("{}/noerrors.txt".format(newPackage), "w") as f:
         f.write(no_errors)
 
@@ -213,6 +214,14 @@ def generate_server_side_config(offset: int, newPackage: string):
             run_template = run_template.replace("{entry_point}", str(gateway_ports[0]))
             f.write(run_template)
 
+    else:
+        with open("{}/run.sh".format(newPackage), "r") as f:
+            filedata = f.read()
+        newdata = re.sub(r"(localhost:)(\d+)", f"localhost:{str(gateway_ports[0])}", filedata)
+        with open("{}/run.sh".format(newPackage), "w") as f:
+            f.write(newdata)
+
+
     # Set the executable permissions on the bash script file
     os.chmod("{}/run.sh".format(newPackage), 0o755)
 
-- 
GitLab