1
Fork 0
mirror of https://github.com/RYGhub/royalnet.git synced 2024-11-23 19:44:20 +00:00

Allow selection of the local network server port

This commit is contained in:
Steffo 2019-11-07 19:03:22 +01:00
parent c0030e3643
commit 876f4cf97a

View file

@ -25,6 +25,8 @@ import logging
help="The Network server URL to connect to.") help="The Network server URL to connect to.")
@click.option("-l", "--local-network-server", is_flag=True, default=False, @click.option("-l", "--local-network-server", is_flag=True, default=False,
help="Locally run a Network server and bind it to port 44444. Overrides -n.") help="Locally run a Network server and bind it to port 44444. Overrides -n.")
@click.option("--local-network-server-port", type=int, default=44444,
help="The port on which the local network will be ran.")
@click.option("-s", "--secrets-name", type=str, default="__default__", @click.option("-s", "--secrets-name", type=str, default="__default__",
help="The name in the keyring that the secrets are stored with.") help="The name in the keyring that the secrets are stored with.")
@click.option("-v", "--verbose", is_flag=True, default=False, @click.option("-v", "--verbose", is_flag=True, default=False,
@ -37,6 +39,7 @@ def run(telegram: typing.Optional[bool],
packs: typing.Tuple[str], packs: typing.Tuple[str],
network_address: typing.Optional[str], network_address: typing.Optional[str],
local_network_server: bool, local_network_server: bool,
local_network_server_port: int,
secrets_name: str, secrets_name: str,
verbose: bool): verbose: bool):
# Setup logging # Setup logging
@ -80,10 +83,10 @@ def run(telegram: typing.Optional[bool],
# Start the network server # Start the network server
if local_network_server: if local_network_server:
server_process = multiprocessing.Process(name="Network Server", server_process = multiprocessing.Process(name="Network Server",
target=rh.Server("0.0.0.0", 44444, network_password).run_blocking, target=rh.Server("0.0.0.0", local_network_server_port, network_password).run_blocking,
daemon=True) daemon=True)
server_process.start() server_process.start()
network_address = "ws://127.0.0.1:44444/" network_address = f"ws://127.0.0.1:{local_network_server_port}/"
# Create a Royalnet configuration # Create a Royalnet configuration
network_config: typing.Optional[rh.Config] = None network_config: typing.Optional[rh.Config] = None