webssh

Web based ssh client https://github.com/huashengdun/webssh webssh.huashengdun.org/
git clone http://git.hanabi.in/repos/webssh.git
Log | Files | Refs | README | LICENSE

commit 7110def7475776b4435880f4c9a754fa4af1d6f3
parent 7cf80e7372d76eb8c6c82c50a8fa69523489c005
Author: Sheng <webmaster0115@gmail.com>
Date:   Thu, 13 Feb 2020 09:40:42 +0800

Added an option for specifying the default character encoding of your ssh servers

Diffstat:
Mwebssh/handler.py | 3++-
Mwebssh/main.py | 3++-
Mwebssh/settings.py | 12+++++++++++-
3 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/webssh/handler.py b/webssh/handler.py @@ -457,7 +457,8 @@ class IndexHandler(MixinHandler, tornado.web.RequestHandler): chan = ssh.invoke_shell(term=term) chan.setblocking(0) worker = Worker(self.loop, ssh, chan, dst_addr) - worker.encoding = self.get_default_encoding(ssh) + worker.encoding = options.encoding if options.encoding else \ + self.get_default_encoding(ssh) return worker def check_origin(self): diff --git a/webssh/main.py b/webssh/main.py @@ -7,7 +7,7 @@ from webssh import handler from webssh.handler import IndexHandler, WsockHandler, NotFoundHandler from webssh.settings import ( get_app_settings, get_host_keys_settings, get_policy_setting, - get_ssl_context, get_server_settings + get_ssl_context, get_server_settings, check_encoding_setting ) @@ -42,6 +42,7 @@ def app_listen(app, port, address, server_settings): def main(): options.parse_command_line() + check_encoding_setting(options.encoding) loop = tornado.ioloop.IOLoop.current() app = make_app(make_handlers(loop, options), get_app_settings(options)) ssl_ctx = get_ssl_context(options) diff --git a/webssh/settings.py b/webssh/settings.py @@ -7,7 +7,9 @@ from tornado.options import define from webssh.policy import ( load_host_keys, get_policy_class, check_policy_setting ) -from webssh.utils import to_ip_address, parse_origin_from_url +from webssh.utils import ( + to_ip_address, parse_origin_from_url, is_valid_encoding +) from webssh._version import __version__ @@ -44,6 +46,8 @@ define('wpintvl', type=int, default=0, help='Websocket ping interval') define('maxconn', type=int, default=20, help='Maximum live connections (ssh sessions) per client') define('font', default='', help='custom font filename') +define('encoding', default='', + help='The default character encoding of ssh servers') define('version', type=bool, help='Show version information', callback=print_version) @@ -184,3 +188,9 @@ def get_font_filename(font, font_dir): font = filenames.pop() return font + + +def check_encoding_setting(encoding): + if encoding and not is_valid_encoding(encoding): + raise ValueError('Unknown character encoding.') + return encoding