use yaml lists instead of string for config

This commit is contained in:
Uriel
2026-03-05 08:35:51 -03:00
parent 8800124c4e
commit f8b730308d
3 changed files with 11 additions and 12 deletions

View File

@@ -43,7 +43,7 @@ app.config["SELFLAUNCHKEY"] = None # can point to a SSL Certificate Key to encr
app.config["SELFGEN"] = True # application process is in charge of scheduling Generations.
app.config["DEBUG"] = False
app.config["PORT"] = 80
app.config["GAME_PORTS"] = "49152-65535,0"
app.config["GAME_PORTS"] = ["49152-65535", 0]
app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER
app.config['MAX_CONTENT_LENGTH'] = 64 * 1024 * 1024 # 64 megabyte limit
# if you want to deploy, make sure you have a non-guessable secret key

View File

@@ -183,15 +183,14 @@ class WebHostContext(Context):
return d
def get_random_port(game_ports):
config_range_list = game_ports.split(",")
def get_random_port(game_ports: list):
available_ports = []
ephemeral_allowed = False
for item in config_range_list:
if '-' in item:
for item in game_ports:
if type(item) is str and '-' in item:
start, end = map(int, item.split('-'))
available_ports.append(range(start, end+1))
elif item == "0":
elif int(item) == "0":
ephemeral_allowed = True
else:
available_ports.append([int(item)])
@@ -277,7 +276,7 @@ def tear_down_logging(room_id):
def run_server_process(name: str, ponyconfig: dict, static_server_data: dict,
cert_file: typing.Optional[str], cert_key_file: typing.Optional[str],
host: str, game_ports: str, rooms_to_run: multiprocessing.Queue,
host: str, game_ports: list, rooms_to_run: multiprocessing.Queue,
rooms_shutting_down: multiprocessing.Queue):
from setproctitle import setproctitle

View File

@@ -17,11 +17,11 @@
# Web hosting port
#PORT: 80
# Ports used for game hosting. Values can be specific ports, port ranges or both. Default is: "49152-65535,0"
# Zero means it will use a random free port if there is none in the range available
# Examples of valid values: "40000-41000,49152-65535"
# If ports within the range(s) are already in use, the WebHost will fallback to the default "49152-65535,0" range.
#GAME_PORTS: "49152-65535,0"
# Ports used for game hosting. Values can be specific ports, port ranges or both. Default is: [49152-65535, 0]
# Zero means it will use a random free port if there is no port in the next 1024 randomly chosen ports from the range
# Examples of valid values: [40000-41000, 49152-65535]
# If ports within the range(s) are already in use, the WebHost will fallback to the default [49152-65535, 0] range.
#GAME_PORTS: [49152-65535, 0]
# Place where uploads go.
#UPLOAD_FOLDER: uploads