Skip to content

Commit f6fcce0

Browse files
committed
Make base port configurable
1 parent ff93042 commit f6fcce0

4 files changed

Lines changed: 27 additions & 14 deletions

File tree

client/__main__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@ def parse_command_line_arguments():
2222
parser = argparse.ArgumentParser(description="DSKE Client")
2323
parser.add_argument("name", type=str, help="Client name")
2424
parser.add_argument(
25-
"--port", type=int, default=configuration.DEFAULT_BASE_PORT, help="Port number"
25+
"--port", type=int, default=configuration._DEFAULT_BASE_PORT, help="Port number"
2626
)
2727
parser.add_argument(
2828
"--hubs",
2929
nargs="+",
3030
type=str,
31-
help=f"Base URLs for hubs (e.g., http://127.0.0.1:{configuration.DEFAULT_BASE_PORT})",
31+
help=f"Base URLs for hubs (e.g., http://127.0.0.1:{configuration._DEFAULT_BASE_PORT})",
3232
)
3333
parser.add_argument(
3434
"--encryptors",

common/configuration.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import yaml
99
from common.node import Node, NodeType
1010

11-
DEFAULT_BASE_PORT = 8100
11+
_DEFAULT_BASE_PORT = 8100
1212

1313

1414
class Configuration:
@@ -17,8 +17,9 @@ class Configuration:
1717
"""
1818

1919
_nodes: list[Node]
20+
_base_port: int
2021

21-
def __init__(self, nodes, base_port=DEFAULT_BASE_PORT):
22+
def __init__(self, nodes, base_port):
2223
# Sort nodes by type and name, so that clients are always before hubs (the order matters
2324
# for startup and shutdown).
2425
self._nodes = sorted(nodes)
@@ -68,6 +69,7 @@ def parse_configuration_file(filename: str):
6869
},
6970
}
7071
schema = {
72+
"base_port": {"type": "integer", "default": _DEFAULT_BASE_PORT},
7173
"hubs": {"type": "list", "schema": hub_schema, "default": []},
7274
"clients": {"type": "list", "schema": client_schema, "default": []},
7375
}
@@ -106,4 +108,5 @@ def parse_configuration_file(filename: str):
106108
encryptor_names = [pec["name"] for pec in parsed_encryptors_config]
107109
node = Node(NodeType.CLIENT, node_name, encryptor_names)
108110
nodes.append(node)
109-
return Configuration(nodes)
111+
base_port = parsed_config["base_port"]
112+
return Configuration(nodes, base_port)

dske-config.yaml

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,31 @@
1-
hubs:
2-
- name: hank
1+
# Configuration file for DSKE topology.
2+
3+
# base_port: 8000 # Base TCP port for the DSKE topology.
4+
# The first hub uses TCP port base_port.
5+
# The second hub uses TCP port base_port + 1, and so on.
6+
# The first client uses TCP port base_port + N, etc.
7+
# (where N is the number of hubs).
8+
# Optional; default value is 8100.
9+
10+
hubs: # List of hubs (aka DSKE security hubs) in the DSKE topology.
11+
- name: hank # Name of the hub.
312
- name: helen
413
- name: hilary
514
- name: holly
615
- name: hugo
7-
clients:
8-
- name: carol
9-
encryptors:
10-
- name: sam
16+
17+
clients: # List of client (aka DSKE clients) in the DSKE topology.`
18+
- name: carol # Name of the client node.
19+
encryptors: # List of encryptors (aka Secure Application Entity SAE) directly connected to this client (carol).
20+
- name: sam # Name of the encryptor.
1121
- name: celia
1222
encryptors:
1323
- name: serena
14-
- name: cindy
24+
- name: cindy # A client with zero directly connected encryptors.
1525
- name: connie
1626
encryptors:
1727
- name: sofia
1828
- name: curtis
19-
encryptors:
29+
encryptors: # A client with more than one (namely two) directly connected encryptors.
2030
- name: sunny
2131
- name: susan

hub/__main__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def parse_command_line_arguments():
2929
"-p",
3030
"--port",
3131
type=int,
32-
default=configuration.DEFAULT_BASE_PORT,
32+
default=configuration._DEFAULT_BASE_PORT,
3333
help="Port number",
3434
)
3535
args = parser.parse_args()

0 commit comments

Comments
 (0)