Made sure that port 9090 could not be randomly selected.

This commit is contained in:
Jeff Baskin 2022-06-12 09:07:06 -04:00
parent e40e190e1e
commit e79cf82b62
1 changed files with 6 additions and 5 deletions

View File

@ -30,7 +30,7 @@ class Server:
@property
def port(self):
"""Get the port of the server."""
port = 9090
port = "9090"
if "MTT_PORT" in self.env:
port = self.env["MTT_PORT"]
return port
@ -68,7 +68,8 @@ class Server:
def set_safe_port(self):
"""Set the server port to something not being used."""
sock = socket()
sock.bind((self.address, 0))
self.port = sock.getsockname()[1]
sock.close()
while self.port == "9090":
sock = socket()
sock.bind((self.address, 0))
self.port = sock.getsockname()[1]
sock.close()