Made sure that port 9090 could not be randomly selected.
This commit is contained in:
parent
e40e190e1e
commit
e79cf82b62
@ -30,7 +30,7 @@ class Server:
|
|||||||
@property
|
@property
|
||||||
def port(self):
|
def port(self):
|
||||||
"""Get the port of the server."""
|
"""Get the port of the server."""
|
||||||
port = 9090
|
port = "9090"
|
||||||
if "MTT_PORT" in self.env:
|
if "MTT_PORT" in self.env:
|
||||||
port = self.env["MTT_PORT"]
|
port = self.env["MTT_PORT"]
|
||||||
return port
|
return port
|
||||||
@ -68,7 +68,8 @@ class Server:
|
|||||||
|
|
||||||
def set_safe_port(self):
|
def set_safe_port(self):
|
||||||
"""Set the server port to something not being used."""
|
"""Set the server port to something not being used."""
|
||||||
sock = socket()
|
while self.port == "9090":
|
||||||
sock.bind((self.address, 0))
|
sock = socket()
|
||||||
self.port = sock.getsockname()[1]
|
sock.bind((self.address, 0))
|
||||||
sock.close()
|
self.port = sock.getsockname()[1]
|
||||||
|
sock.close()
|
||||||
|
Loading…
Reference in New Issue
Block a user