commit 795875807b1c89580a19b54850fb0373904fc8e6
parent 32d7236630f70ec252c55a8be8dc3692860e1540
Author: Sheng <webmaster0115@gmail.com>
Date: Sun, 23 Feb 2020 11:11:41 +0800
Added two options for user configuration
Diffstat:
2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/webssh/handler.py b/webssh/handler.py
@@ -443,7 +443,7 @@ class IndexHandler(MixinHandler, tornado.web.RequestHandler):
logging.info('Connecting to {}:{}'.format(*dst_addr))
try:
- ssh.connect(*args, timeout=6)
+ ssh.connect(*args, timeout=options.timeout)
except socket.error:
raise ValueError('Unable to connect to {}:{}'.format(*dst_addr))
except paramiko.BadAuthenticationType:
@@ -511,7 +511,8 @@ class IndexHandler(MixinHandler, tornado.web.RequestHandler):
clients[ip] = workers
worker.src_addr = (ip, port)
workers[worker.id] = worker
- self.loop.call_later(DELAY, recycle_worker, worker)
+ self.loop.call_later(options.delay or DELAY, recycle_worker,
+ worker)
self.result.update(id=worker.id, encoding=worker.encoding)
self.write(self.result)
diff --git a/webssh/settings.py b/webssh/settings.py
@@ -43,6 +43,8 @@ define('origin', default='same', help='''Origin policy,
separated by comma;
'*': wildcard policy, matches any domain, allowed in debug mode only.''')
define('wpintvl', type=int, default=0, help='Websocket ping interval')
+define('timeout', type=int, default=3, help='SSH connection timeout')
+define('delay', type=int, default=0, help='The delay to call recycle_worker')
define('maxconn', type=int, default=20,
help='Maximum live connections (ssh sessions) per client')
define('font', default='', help='custom font filename')