introduce NetworkParameters namedtuple
This commit is contained in:
@@ -84,13 +84,13 @@ class CustomTaskGroup(TaskGroup):
|
||||
return super().spawn(*args, **kwargs)
|
||||
|
||||
|
||||
def deserialize_server(server_str: str) -> Tuple[str, int, str]:
|
||||
def deserialize_server(server_str: str) -> Tuple[str, str, str]:
|
||||
# host might be IPv6 address, hence do rsplit:
|
||||
host, port, protocol = str(server_str).rsplit(':', 2)
|
||||
if protocol not in ('s', 't'):
|
||||
raise ValueError('invalid network protocol: {}'.format(protocol))
|
||||
port = int(port) # Throw if cannot be converted to int
|
||||
if not (0 < port < 2**16):
|
||||
int(port) # Throw if cannot be converted to int
|
||||
if not (0 < int(port) < 2**16):
|
||||
raise ValueError('port {} is out of valid range'.format(port))
|
||||
return host, port, protocol
|
||||
|
||||
@@ -106,6 +106,7 @@ class Interface(PrintError):
|
||||
self.ready = asyncio.Future()
|
||||
self.server = server
|
||||
self.host, self.port, self.protocol = deserialize_server(self.server)
|
||||
self.port = int(self.port)
|
||||
self.config_path = config_path
|
||||
self.cert_path = os.path.join(self.config_path, 'certs', self.host)
|
||||
self.tip_header = None
|
||||
|
||||
Reference in New Issue
Block a user