commit 090e2e7f87915959d25b4b9512b89f4bff93b151
parent 8d0567329fc7e1dee18afb7617a5ba6a4a5ca454
Author: Sheng <webmaster0115@gmail.com>
Date: Sun, 15 Sep 2019 08:30:46 +0800
Added support for terminal type configuration
Diffstat:
3 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/webssh/handler.py b/webssh/handler.py
@@ -412,7 +412,8 @@ class IndexHandler(MixinHandler, tornado.web.RequestHandler):
except paramiko.BadHostKeyException:
raise ValueError('Bad host key.')
- chan = ssh.invoke_shell(term='xterm')
+ term = self.get_argument('term', u'') or u'xterm'
+ chan = ssh.invoke_shell(term=term)
chan.setblocking(0)
worker = Worker(self.loop, ssh, chan, dst_addr)
worker.encoding = self.get_default_encoding(ssh)
diff --git a/webssh/static/js/main.js b/webssh/static/js/main.js
@@ -40,6 +40,7 @@ jQuery(function($){
button = $('.btn-primary'),
form_container = $('.form-container'),
waiter = $('#waiter'),
+ term_type = $('#term'),
style = {},
default_title = 'WebSSH',
title_element = document.querySelector('title'),
@@ -55,7 +56,7 @@ jQuery(function($){
key_max_size = 16384,
fields = ['hostname', 'port', 'username'],
form_keys = fields.concat(['password', 'totp']),
- opts_keys = ['bgcolor', 'title', 'encoding', 'command'],
+ opts_keys = ['bgcolor', 'title', 'encoding', 'command', 'term'],
url_form_data = {},
url_opts_data = {},
validated_form_data,
@@ -705,6 +706,7 @@ jQuery(function($){
return;
}
+ data.term = term_type.val();
data._xsrf = _xsrf.value;
if (event_origin) {
data._origin = event_origin;
@@ -819,6 +821,10 @@ jQuery(function($){
// console.log(url_form_data);
// console.log(url_opts_data);
+ if (url_opts_data.term) {
+ term_type.val(url_opts_data.term);
+ }
+
if (url_form_data.password === null) {
log_status('Password via url must be encoded in base64.');
} else {
diff --git a/webssh/templates/index.html b/webssh/templates/index.html
@@ -69,6 +69,7 @@
<div class="col">
</div>
</div>
+ <input type="hidden" id="term" name="term" value="xterm-256color">
{% module xsrf_form_html() %}
<button type="submit" class="btn btn-primary">Connect</button>
<button type="reset" class="btn btn-danger">Reset</button>