From 2d5ca94151c3fe93964a5f0e006ac1eda0293d1b Mon Sep 17 00:00:00 2001 From: David Boreham Date: Tue, 19 Sep 2023 13:08:40 -0600 Subject: [PATCH 1/2] Handle udp ports mapped --- app/deployment_create.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/deployment_create.py b/app/deployment_create.py index cf47ec01..c988d01f 100644 --- a/app/deployment_create.py +++ b/app/deployment_create.py @@ -178,16 +178,18 @@ def _get_mapped_ports(stack: str, map_recipe: str): ports_array = ports[service] for x in range(0, len(ports_array)): orig_port = ports_array[x] + # Strip /udp suffix if present + bare_orig_port = orig_port.replace("/udp","") random_port = random.randint(20000, 50000) # Beware: we're relying on luck to not collide if map_recipe == "any-variable-random": # This is the default so take no action pass elif map_recipe == "localhost-same": # Replace instances of "- XX" with "- 127.0.0.1:XX" - ports_array[x] = f"127.0.0.1:{orig_port}:{orig_port}" + ports_array[x] = f"127.0.0.1:{bare_orig_port}:{orig_port}" elif map_recipe == "any-same": # Replace instances of "- XX" with "- 0.0.0.0:XX" - ports_array[x] = f"0.0.0.0:{orig_port}:{orig_port}" + ports_array[x] = f"0.0.0.0:{bare_orig_port}:{orig_port}" elif map_recipe == "localhost-fixed-random": # Replace instances of "- XX" with "- 127.0.0.1::XX" ports_array[x] = f"127.0.0.1:{random_port}:{orig_port}" From 43683bcf4537baf18daf2216f5711a05f8494907 Mon Sep 17 00:00:00 2001 From: David Boreham Date: Tue, 19 Sep 2023 13:11:42 -0600 Subject: [PATCH 2/2] Fix lint error --- app/deployment_create.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/deployment_create.py b/app/deployment_create.py index c988d01f..837aaa61 100644 --- a/app/deployment_create.py +++ b/app/deployment_create.py @@ -179,7 +179,7 @@ def _get_mapped_ports(stack: str, map_recipe: str): for x in range(0, len(ports_array)): orig_port = ports_array[x] # Strip /udp suffix if present - bare_orig_port = orig_port.replace("/udp","") + bare_orig_port = orig_port.replace("/udp", "") random_port = random.randint(20000, 50000) # Beware: we're relying on luck to not collide if map_recipe == "any-variable-random": # This is the default so take no action