Commit a2c6f101 authored by ibuler's avatar ibuler

[Update] 修改config

parent 42fbefd0
......@@ -92,8 +92,9 @@ class Config(dict):
"""
def __init__(self, root_path, defaults=None):
dict.__init__(self, defaults or {})
self.defaults = defaults or {}
self.root_path = root_path
super().__init__({})
def from_envvar(self, variable_name, silent=False):
"""Loads a configuration from an environment variable pointing to
......@@ -269,6 +270,21 @@ class Config(dict):
rv[key] = v
return rv
def __getitem__(self, item):
try:
value = super().__getitem__(item)
except KeyError:
value = None
if value is not None:
return value
value = os.environ.get(item, None)
if value is not None:
return value
return self.defaults.get(item)
def __getattr__(self, item):
return self.__getitem__(item)
def __repr__(self):
return '<%s %s>' % (self.__class__.__name__, dict.__repr__(self))
......
......@@ -63,6 +63,7 @@ class SSHServer:
return connection
def handle_connection(self, sock, addr):
logger.debug("Handle new connection from: {}".format(addr))
transport = paramiko.Transport(sock, gss_kex=False)
try:
transport.load_server_moduli()
......@@ -77,7 +78,7 @@ class SSHServer:
server = SSHInterface(connection)
try:
transport.start_server(server=server)
except paramiko.SSHException:
except (paramiko.SSHException, socket.timeout):
logger.warning("SSH negotiation failed")
return
except EOFError as e:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment