Skip to content

Commit

Permalink
fix_port_range
Browse files Browse the repository at this point in the history
  • Loading branch information
gsanchietti committed Feb 28, 2024
1 parent 6826bc7 commit 32b1246
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
3 changes: 2 additions & 1 deletion imageroot/actions/configure-module/20configure
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ import hashlib

request = json.load(sys.stdin)

ports = os.environ["TCP_PORTS"].split(',')
(start,end) = os.environ["TCP_PORTS_RANGE"].split('-')
ports = [*range(int(start), int(end))]

# Configure Traefik to route requests to the nethsec-controller service
response = agent.tasks.run(
Expand Down
12 changes: 7 additions & 5 deletions imageroot/actions/create-module/20initialize
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@
exec 1>&2 # Send any output to stderr, to not alter the action response protocol
set -e

ovpn_udp_port=$(echo $TCP_PORTS | cut -d',' -f1)
api_port=$(echo $TCP_PORTS | cut -d',' -f2)
ui_port=$(echo $TCP_PORTS | cut -d',' -f3)
proxy_port=$(echo $TCP_PORTS | cut -d',' -f4)
promtail_port=$(echo $TCP_PORTS | cut -d',' -f5)
start=$(echo $TCP_PORTS_RANGE | cut -d'-' -f1)

ovpn_udp_port=$start
api_port=$(($start+1))
ui_port=$(($start+2))
proxy_port=$(($start+3))
promtail_port=$(($start+4))
# port 6 and 7 are reserved for loki
# port 8 is reserved for prometheus
# port 9 is reserved for grafana
Expand Down
2 changes: 1 addition & 1 deletion imageroot/actions/create-module/40firewall
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
import os
import agent

ovpn_port = os.environ['TCP_PORTS'].split(',')[0]
ovpn_port = os.environ['TCP_PORTS_RANGE'].split('-')[0]
agent.assert_exp(agent.add_public_service(os.environ['MODULE_ID'], [f"{ovpn_port}/udp"]))

0 comments on commit 32b1246

Please sign in to comment.