Commit dc0b48ce by Sheng

Enhancement

parent 650382ad
...@@ -200,7 +200,7 @@ class IndexHandler(MixinHandler, tornado.web.RequestHandler): ...@@ -200,7 +200,7 @@ class IndexHandler(MixinHandler, tornado.web.RequestHandler):
if isinstance(self.settings['policy'], paramiko.client.AutoAddPolicy): if isinstance(self.settings['policy'], paramiko.client.AutoAddPolicy):
ssh.load_host_keys(self.settings['host_file']) ssh.load_host_keys(self.settings['host_file'])
else: else:
ssh._host_keys = self.settings.get('host_keys') ssh._host_keys = self.settings['host_keys']
ssh.set_missing_host_key_policy(self.settings['policy']) ssh.set_missing_host_key_policy(self.settings['policy'])
args = self.get_args() args = self.get_args()
dst_addr = (args[0], args[1]) dst_addr = (args[0], args[1])
...@@ -253,7 +253,7 @@ class WsockHandler(MixinHandler, tornado.websocket.WebSocketHandler): ...@@ -253,7 +253,7 @@ class WsockHandler(MixinHandler, tornado.websocket.WebSocketHandler):
def open(self): def open(self):
self.src_addr = self.get_client_addr() self.src_addr = self.get_client_addr()
logging.info('Connected from {}:{}'.format(*self.src_addr)) logging.info('Connected from {}:{}'.format(*self.src_addr))
worker = workers.get(self.get_argument('id'), None) worker = workers.get(self.get_argument('id'))
if worker and worker.src_addr[0] == self.src_addr[0]: if worker and worker.src_addr[0] == self.src_addr[0]:
workers.pop(worker.id) workers.pop(worker.id)
self.set_nodelay(True) self.set_nodelay(True)
...@@ -304,8 +304,8 @@ def get_policy_class(policy): ...@@ -304,8 +304,8 @@ def get_policy_class(policy):
if not policy.endswith('policy'): if not policy.endswith('policy'):
policy += 'policy' policy += 'policy'
dic = {k.lower(): v for k, v in vars(paramiko.client).items()} dic = {k.lower(): v for k, v in vars(paramiko.client).items() if type(v)
is type and issubclass(v, paramiko.client.MissingHostKeyPolicy)}
try: try:
cls = dic[policy] cls = dic[policy]
except KeyError: except KeyError:
......
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