mirror of
https://github.com/huashengdun/webssh.git
synced 2026-08-20 04:36:42 +00:00
Added an option for specifying the default character encoding of your ssh servers
This commit is contained in:
+2
-1
@@ -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):
|
||||
|
||||
+2
-1
@@ -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)
|
||||
|
||||
+11
-1
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user