From 520707abaad09afcaea6c31f4426409dd9951d2f Mon Sep 17 00:00:00 2001 From: Favyen Bastani Date: Sat, 4 Jul 2015 17:23:32 -0400 Subject: [PATCH 01/28] Fix event listener loss on terminal reset. --- wssh/static/term.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/wssh/static/term.js b/wssh/static/term.js index 9489334..606ec43 100644 --- a/wssh/static/term.js +++ b/wssh/static/term.js @@ -131,7 +131,8 @@ function Terminal(cols, rows, handler) { this.rows = rows || Terminal.geometry[1]; if (handler) { - this.on('data', handler); + this.dataHandler = handler; + this.on('data', this.dataHandler); } this.ybase = 0; @@ -2432,7 +2433,7 @@ Terminal.prototype.reverseIndex = function() { // ESC c Full Reset (RIS). Terminal.prototype.reset = function() { - Terminal.call(this, this.cols, this.rows); + Terminal.call(this, this.cols, this.rows, this.dataHandler); this.refresh(0, this.rows - 1); }; From 60032df48a8fa3718274b5c6083a726c050a2161 Mon Sep 17 00:00:00 2001 From: sunyi00 Date: Mon, 7 Sep 2015 08:21:05 +0800 Subject: [PATCH 02/28] bugfix --- examples/flask_server.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/flask_server.py b/examples/flask_server.py index 51ee830..45858af 100644 --- a/examples/flask_server.py +++ b/examples/flask_server.py @@ -52,7 +52,7 @@ def index(): if __name__ == '__main__': from gevent.pywsgi import WSGIServer - from geventwebsocket import WebSocketHandler + from geventwebsocket.handler import WebSocketHandler app.debug = True http_server = WSGIServer(('localhost', 5000), app, From 7b33b14a3c11b72f40c4f30a5cb2737b47b01185 Mon Sep 17 00:00:00 2001 From: sunyi00 Date: Mon, 7 Sep 2015 08:57:38 +0800 Subject: [PATCH 03/28] bugfix: json dumps crashes when input unicode --- wssh/client.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/wssh/client.py b/wssh/client.py index d52caba..26c1dad 100644 --- a/wssh/client.py +++ b/wssh/client.py @@ -1,4 +1,5 @@ import os +import codecs import sys import signal import errno @@ -13,6 +14,11 @@ import platform +UTF8Reader = codecs.getreader('utf8') +sys.stdin = UTF8Reader(sys.stdin) +UTF8Writer = codecs.getwriter('utf8') +sys.stdout = UTF8Writer(sys.stdout) + try: import simplejson as json except ImportError: From c6e87a41cd5519f1c0ed6578cbd38e9e6cec52fe Mon Sep 17 00:00:00 2001 From: sunyi00 Date: Mon, 7 Sep 2015 09:04:44 +0800 Subject: [PATCH 04/28] bump version to 0.1.1 --- setup.py | 2 +- wssh/__init__.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index 148557d..c7d5f2e 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,7 @@ setup( name='wssh', - version='0.1.0', + version='0.1.1', author='Andrea Luzzardi ', packages=[ 'wssh' diff --git a/wssh/__init__.py b/wssh/__init__.py index 5c01378..af5cdf4 100644 --- a/wssh/__init__.py +++ b/wssh/__init__.py @@ -1,3 +1,3 @@ from server import WSSHBridge -__version__ = '0.1.0' +__version__ = '0.1.1' From 78e3c3a32abf68321ae801c7bee7c88ca4f36a2b Mon Sep 17 00:00:00 2001 From: sunyi00 Date: Mon, 7 Sep 2015 09:06:29 +0800 Subject: [PATCH 05/28] update gitignore --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index 0052dd0..01f4e66 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,8 @@ *.py[co] *.egg *.egg-info +*.tmp dist build eggs +.ropeproject/ From 2d3d170ba342c3d6c2488c3a17ee6706d5efe760 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E6=B8=90?= Date: Thu, 19 Nov 2015 10:31:25 +0800 Subject: [PATCH 06/28] Add custom header param to invoke_shell() --- wssh/client.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wssh/client.py b/wssh/client.py index d52caba..c76889b 100644 --- a/wssh/client.py +++ b/wssh/client.py @@ -41,8 +41,8 @@ def _resize(ws): ws.send(json.dumps({'resize': {'width': cols, 'height': rows}})) -def invoke_shell(endpoint): - ssh = websocket.create_connection(endpoint) +def invoke_shell(endpoint, header = None): + ssh = websocket.create_connection(url = endpoint, header = header) _resize(ssh) oldtty = termios.tcgetattr(sys.stdin) old_handler = signal.getsignal(signal.SIGWINCH) From d1f3fe7234ce820c50c4fb55428f18a42cf3c478 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E6=B8=90?= Date: Thu, 19 Nov 2015 10:40:37 +0800 Subject: [PATCH 07/28] Update setup.py --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 148557d..c7d5f2e 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,7 @@ setup( name='wssh', - version='0.1.0', + version='0.1.1', author='Andrea Luzzardi ', packages=[ 'wssh' From 58c444b986a40fc1ff082853acb624d323a616fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E6=B8=90?= Date: Fri, 20 Nov 2015 09:54:25 +0800 Subject: [PATCH 08/28] Update .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 0052dd0..b2b72ae 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ dist build eggs +*.DS_Store From 2d036bca48673a76308457fb8d5a2e4821a224a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E6=B8=90?= Date: Mon, 23 Nov 2015 10:38:53 +0800 Subject: [PATCH 09/28] Add header support --- setup.py | 2 +- wssh/client.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/setup.py b/setup.py index 148557d..c7d5f2e 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,7 @@ setup( name='wssh', - version='0.1.0', + version='0.1.1', author='Andrea Luzzardi ', packages=[ 'wssh' diff --git a/wssh/client.py b/wssh/client.py index d52caba..c76889b 100644 --- a/wssh/client.py +++ b/wssh/client.py @@ -41,8 +41,8 @@ def _resize(ws): ws.send(json.dumps({'resize': {'width': cols, 'height': rows}})) -def invoke_shell(endpoint): - ssh = websocket.create_connection(endpoint) +def invoke_shell(endpoint, header = None): + ssh = websocket.create_connection(url = endpoint, header = header) _resize(ssh) oldtty = termios.tcgetattr(sys.stdin) old_handler = signal.getsignal(signal.SIGWINCH) From 0b636c1948724cc6fd69ec33fd5483ec44d31dc0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E6=B8=90?= Date: Mon, 23 Nov 2015 15:38:20 +0800 Subject: [PATCH 10/28] Disable ssl cert verification --- wssh/client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wssh/client.py b/wssh/client.py index c76889b..2b70ad3 100644 --- a/wssh/client.py +++ b/wssh/client.py @@ -42,7 +42,7 @@ def _resize(ws): def invoke_shell(endpoint, header = None): - ssh = websocket.create_connection(url = endpoint, header = header) + ssh = websocket.create_connection(url = endpoint, header = header, sslopt={"cert_reqs": ssl.CERT_NONE}) _resize(ssh) oldtty = termios.tcgetattr(sys.stdin) old_handler = signal.getsignal(signal.SIGWINCH) From 3d1d1f408286540092cec8f88bd2de9eceb26120 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E6=B8=90?= Date: Mon, 23 Nov 2015 15:44:49 +0800 Subject: [PATCH 11/28] Fix an import error --- wssh/client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wssh/client.py b/wssh/client.py index 2b70ad3..955eaec 100644 --- a/wssh/client.py +++ b/wssh/client.py @@ -10,7 +10,7 @@ import tty import fcntl import struct - +import ssl import platform try: From c37fa6ada6c32ba263a2989f9fb615ebe414fab5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E6=B8=90?= Date: Mon, 23 Nov 2015 17:07:37 +0800 Subject: [PATCH 12/28] Update .gitignore --- .gitignore | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.gitignore b/.gitignore index a6aecaf..cdfe82e 100644 --- a/.gitignore +++ b/.gitignore @@ -5,8 +5,4 @@ dist build eggs -<<<<<<< HEAD *.DS_Store -======= -.ropeproject/ ->>>>>>> sunyi/master From 3e8cd6e5508456ccfdfd4849102509e9ccba73a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E6=B8=90?= Date: Mon, 23 Nov 2015 19:36:08 +0800 Subject: [PATCH 13/28] Revert "Fix an import error" This reverts commit 3d1d1f408286540092cec8f88bd2de9eceb26120. --- wssh/client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wssh/client.py b/wssh/client.py index 7cfeb3e..97ea41b 100644 --- a/wssh/client.py +++ b/wssh/client.py @@ -11,7 +11,7 @@ import tty import fcntl import struct -import ssl + import platform UTF8Reader = codecs.getreader('utf8') From c29705483560c98eda58b79610e952b3dd4de421 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E6=B8=90?= Date: Mon, 23 Nov 2015 19:37:12 +0800 Subject: [PATCH 14/28] Revert "Revert "Fix an import error"" This reverts commit 3e8cd6e5508456ccfdfd4849102509e9ccba73a1. --- wssh/client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wssh/client.py b/wssh/client.py index 97ea41b..7cfeb3e 100644 --- a/wssh/client.py +++ b/wssh/client.py @@ -11,7 +11,7 @@ import tty import fcntl import struct - +import ssl import platform UTF8Reader = codecs.getreader('utf8') From bda2ed93f704b0006a096e7a7af500abe4714b97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E6=B8=90?= Date: Mon, 23 Nov 2015 19:37:28 +0800 Subject: [PATCH 15/28] Revert "Fix an import error" This reverts commit 3d1d1f408286540092cec8f88bd2de9eceb26120. --- wssh/client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wssh/client.py b/wssh/client.py index 7cfeb3e..97ea41b 100644 --- a/wssh/client.py +++ b/wssh/client.py @@ -11,7 +11,7 @@ import tty import fcntl import struct -import ssl + import platform UTF8Reader = codecs.getreader('utf8') From c4d188e35fb90551be22be97c69299708ca7cf69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E6=B8=90?= Date: Mon, 23 Nov 2015 19:42:50 +0800 Subject: [PATCH 16/28] Revert --- wssh/client.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/wssh/client.py b/wssh/client.py index 97ea41b..257c650 100644 --- a/wssh/client.py +++ b/wssh/client.py @@ -11,13 +11,9 @@ import tty import fcntl import struct - +import url import platform -UTF8Reader = codecs.getreader('utf8') -sys.stdin = UTF8Reader(sys.stdin) -UTF8Writer = codecs.getwriter('utf8') -sys.stdout = UTF8Writer(sys.stdout) try: import simplejson as json From ba44435ab95d83cd2df2d4c3f5952f79026fbf0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E6=B8=90?= Date: Mon, 23 Nov 2015 20:05:13 +0800 Subject: [PATCH 17/28] Remove no-use import --- wssh/client.py | 1 - 1 file changed, 1 deletion(-) diff --git a/wssh/client.py b/wssh/client.py index 257c650..03dba5a 100644 --- a/wssh/client.py +++ b/wssh/client.py @@ -11,7 +11,6 @@ import tty import fcntl import struct -import url import platform From 410c9f81700a8724a14e4ae9805c4753f2ec1615 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E6=B8=90?= Date: Tue, 24 Nov 2015 09:51:10 +0800 Subject: [PATCH 18/28] Fix a bug of Chinese chars input --- wssh/client.py | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/wssh/client.py b/wssh/client.py index 03dba5a..c3eb6b5 100644 --- a/wssh/client.py +++ b/wssh/client.py @@ -43,9 +43,13 @@ def _resize(ws): def invoke_shell(endpoint, header = None): + UTF8Reader = codecs.getreader('utf8') + utf_in = UTF8Reader(sys.stdin) + UTF8Writer = codecs.getwriter('utf8') + utf_out = UTF8Writer(sys.stdout) ssh = websocket.create_connection(url = endpoint, header = header, sslopt={"cert_reqs": ssl.CERT_NONE}) _resize(ssh) - oldtty = termios.tcgetattr(sys.stdin) + oldtty = termios.tcgetattr(utf_in) old_handler = signal.getsignal(signal.SIGWINCH) def on_term_resize(signum, frame): @@ -53,15 +57,15 @@ def on_term_resize(signum, frame): signal.signal(signal.SIGWINCH, on_term_resize) try: - tty.setraw(sys.stdin.fileno()) - tty.setcbreak(sys.stdin.fileno()) + tty.setraw(utf_in.fileno()) + tty.setcbreak(utf_in.fileno()) rows, cols = _pty_size() ssh.send(json.dumps({'resize': {'width': cols, 'height': rows}})) while True: try: - r, w, e = select.select([ssh.sock, sys.stdin], [], []) + r, w, e = select.select([ssh.sock, utf_in], [], []) if ssh.sock in r: data = ssh.recv() if not data: @@ -69,10 +73,10 @@ def on_term_resize(signum, frame): message = json.loads(data) if 'error' in message: raise ConnectionError(message['error']) - sys.stdout.write(message['data']) - sys.stdout.flush() - if sys.stdin in r: - x = sys.stdin.read(1) + utf_out.write(message['data']) + utf_out.flush() + if utf_in in r: + x = utf_in.read(1) if len(x) == 0: break ssh.send(json.dumps({'data': x})) @@ -84,5 +88,5 @@ def on_term_resize(signum, frame): except websocket.WebSocketException: raise finally: - termios.tcsetattr(sys.stdin, termios.TCSADRAIN, oldtty) + termios.tcsetattr(utf_in, termios.TCSADRAIN, oldtty) signal.signal(signal.SIGWINCH, old_handler) From 380c8b9cfc75396bb186db9183f5f376328abbfa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E6=B8=90?= Date: Tue, 24 Nov 2015 10:44:11 +0800 Subject: [PATCH 19/28] Add a missed import --- wssh/client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wssh/client.py b/wssh/client.py index c3eb6b5..7dd9f7d 100644 --- a/wssh/client.py +++ b/wssh/client.py @@ -12,7 +12,7 @@ import fcntl import struct import platform - +import ssl try: import simplejson as json From fd4b86e7bca787b03e6fb8dc7205fa05ebfb7d23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E6=B8=90?= Date: Tue, 24 Nov 2015 11:37:23 +0800 Subject: [PATCH 20/28] Fix a bug of signature of functions --- wssh/client.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/wssh/client.py b/wssh/client.py index 7dd9f7d..9f92832 100644 --- a/wssh/client.py +++ b/wssh/client.py @@ -24,21 +24,21 @@ class ConnectionError(Exception): pass -def _pty_size(): +def _pty_size(utf_in, utf_out): rows, cols = 24, 80 # Can't do much for Windows if platform.system() == 'Windows': return rows, cols fmt = 'HH' buffer = struct.pack(fmt, 0, 0) - result = fcntl.ioctl(sys.stdout.fileno(), termios.TIOCGWINSZ, + result = fcntl.ioctl(utf_out.fileno(), termios.TIOCGWINSZ, buffer) rows, cols = struct.unpack(fmt, result) return rows, cols -def _resize(ws): - rows, cols = _pty_size() +def _resize(ws, utf_in, utf_out): + rows, cols = _pty_size(utf_in, utf_out) ws.send(json.dumps({'resize': {'width': cols, 'height': rows}})) @@ -48,19 +48,19 @@ def invoke_shell(endpoint, header = None): UTF8Writer = codecs.getwriter('utf8') utf_out = UTF8Writer(sys.stdout) ssh = websocket.create_connection(url = endpoint, header = header, sslopt={"cert_reqs": ssl.CERT_NONE}) - _resize(ssh) + _resize(ssh, utf_in, utf_out) oldtty = termios.tcgetattr(utf_in) old_handler = signal.getsignal(signal.SIGWINCH) def on_term_resize(signum, frame): - _resize(ssh) + _resize(ssh, utf_in, utf_out) signal.signal(signal.SIGWINCH, on_term_resize) try: tty.setraw(utf_in.fileno()) tty.setcbreak(utf_in.fileno()) - rows, cols = _pty_size() + rows, cols = _pty_size(utf_in, utf_out) ssh.send(json.dumps({'resize': {'width': cols, 'height': rows}})) while True: From 5c0abf2468a48ae1542c3c04f19f6513e1d6c70d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E6=B8=90?= Date: Wed, 25 Nov 2015 16:11:35 +0800 Subject: [PATCH 21/28] Update for test --- wssh/client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wssh/client.py b/wssh/client.py index 9f92832..e57c0c3 100644 --- a/wssh/client.py +++ b/wssh/client.py @@ -76,7 +76,7 @@ def on_term_resize(signum, frame): utf_out.write(message['data']) utf_out.flush() if utf_in in r: - x = utf_in.read(1) + x = utf_in.read(char = 1) if len(x) == 0: break ssh.send(json.dumps({'data': x})) From e9e2f07b0b7e337053e7cb503f56aa0ad5d4b7ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E6=B8=90?= Date: Wed, 25 Nov 2015 16:18:56 +0800 Subject: [PATCH 22/28] Reverse modify --- wssh/client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wssh/client.py b/wssh/client.py index e57c0c3..9f92832 100644 --- a/wssh/client.py +++ b/wssh/client.py @@ -76,7 +76,7 @@ def on_term_resize(signum, frame): utf_out.write(message['data']) utf_out.flush() if utf_in in r: - x = utf_in.read(char = 1) + x = utf_in.read(1) if len(x) == 0: break ssh.send(json.dumps({'data': x})) From abd5b487209e701e2653232a2c1e2e263d92c696 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E6=B8=90?= Date: Thu, 26 Nov 2015 12:38:20 +0800 Subject: [PATCH 23/28] Update version to 0.2 - Increase outbound buffer size of server - Fix curser issue --- setup.py | 4 ++-- wssh/client.py | 2 +- wssh/server.py | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/setup.py b/setup.py index c7d5f2e..377615f 100644 --- a/setup.py +++ b/setup.py @@ -3,8 +3,8 @@ setup( name='wssh', - version='0.1.1', - author='Andrea Luzzardi ', + version='0.2', + author='EricPai ', packages=[ 'wssh' ], diff --git a/wssh/client.py b/wssh/client.py index 9f92832..5310fd5 100644 --- a/wssh/client.py +++ b/wssh/client.py @@ -76,7 +76,7 @@ def on_term_resize(signum, frame): utf_out.write(message['data']) utf_out.flush() if utf_in in r: - x = utf_in.read(1) + x = os.read(utf_in.fileno(), 3) if len(x) == 0: break ssh.send(json.dumps({'data': x})) diff --git a/wssh/server.py b/wssh/server.py index 17a4965..ef5a4ec 100644 --- a/wssh/server.py +++ b/wssh/server.py @@ -127,7 +127,7 @@ def _forward_outbound(self, channel): try: while True: wait_read(channel.fileno()) - data = channel.recv(1024) + data = channel.recv(10240) if not len(data): return self._websocket.send(json.dumps({'data': data})) From 314eea829c39289f46e5c51e0c270d06e8440e29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E6=B8=90?= Date: Thu, 26 Nov 2015 14:13:38 +0800 Subject: [PATCH 24/28] Update client to adjust error output --- wssh/client.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/wssh/client.py b/wssh/client.py index 5310fd5..bd732bf 100644 --- a/wssh/client.py +++ b/wssh/client.py @@ -20,10 +20,6 @@ import json -class ConnectionError(Exception): - pass - - def _pty_size(utf_in, utf_out): rows, cols = 24, 80 # Can't do much for Windows @@ -72,7 +68,8 @@ def on_term_resize(signum, frame): break message = json.loads(data) if 'error' in message: - raise ConnectionError(message['error']) + utf_out.write(message['error']) + break utf_out.write(message['data']) utf_out.flush() if utf_in in r: @@ -90,3 +87,4 @@ def on_term_resize(signum, frame): finally: termios.tcsetattr(utf_in, termios.TCSADRAIN, oldtty) signal.signal(signal.SIGWINCH, old_handler) + print '\n' From f633acd5b714c6df5a93178fe3b5d6cd2439a706 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E6=B8=90?= Date: Fri, 27 Nov 2015 10:13:41 +0800 Subject: [PATCH 25/28] For debug --- wssh/server.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/wssh/server.py b/wssh/server.py index ef5a4ec..161c690 100644 --- a/wssh/server.py +++ b/wssh/server.py @@ -18,6 +18,7 @@ from paramiko.ssh_exception import SSHException import socket +import datetime try: import simplejson as json @@ -110,7 +111,9 @@ def _forward_inbound(self, channel): try: while True: data = self._websocket.receive() + print "[In]%s [%s]" % (data, datetime.datetime.now().time()) if not data: + print "[In ended] %s" % (datetime.datetime.now().time()) return data = json.loads(str(data)) if 'resize' in data: @@ -128,7 +131,9 @@ def _forward_outbound(self, channel): while True: wait_read(channel.fileno()) data = channel.recv(10240) + print "[Out]%s [%s]" % (data, datetime.datetime.now().time()) if not len(data): + print "[Out ended] %s" % (datetime.datetime.now().time()) return self._websocket.send(json.dumps({'data': data})) finally: From b60f2ccac611d7bce84d2267d527ca6ac957c7bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E6=B8=90?= Date: Fri, 27 Nov 2015 11:52:04 +0800 Subject: [PATCH 26/28] Add simulate `exit` command. Cann't do much --- setup.py | 2 +- wssh/__init__.py | 2 +- wssh/server.py | 6 ++---- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/setup.py b/setup.py index 377615f..f91924a 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,7 @@ setup( name='wssh', - version='0.2', + version='0.2.1', author='EricPai ', packages=[ 'wssh' diff --git a/wssh/__init__.py b/wssh/__init__.py index af5cdf4..bb2bc4e 100644 --- a/wssh/__init__.py +++ b/wssh/__init__.py @@ -1,3 +1,3 @@ from server import WSSHBridge -__version__ = '0.1.1' +__version__ = '0.2.1' diff --git a/wssh/server.py b/wssh/server.py index 161c690..0241a66 100644 --- a/wssh/server.py +++ b/wssh/server.py @@ -111,9 +111,9 @@ def _forward_inbound(self, channel): try: while True: data = self._websocket.receive() - print "[In]%s [%s]" % (data, datetime.datetime.now().time()) if not data: - print "[In ended] %s" % (datetime.datetime.now().time()) + channel.send('\x03\rexit\r') + time.sleep(10) return data = json.loads(str(data)) if 'resize' in data: @@ -131,9 +131,7 @@ def _forward_outbound(self, channel): while True: wait_read(channel.fileno()) data = channel.recv(10240) - print "[Out]%s [%s]" % (data, datetime.datetime.now().time()) if not len(data): - print "[Out ended] %s" % (datetime.datetime.now().time()) return self._websocket.send(json.dumps({'data': data})) finally: From d4d09591d4990176ca87d648f60afe6d143059af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E6=B8=90?= Date: Fri, 27 Nov 2015 11:55:43 +0800 Subject: [PATCH 27/28] Fix missed import --- wssh/server.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wssh/server.py b/wssh/server.py index 0241a66..d5a9fc3 100644 --- a/wssh/server.py +++ b/wssh/server.py @@ -18,7 +18,7 @@ from paramiko.ssh_exception import SSHException import socket -import datetime +import time try: import simplejson as json From 7adf7a566093305e87ea46333cd24ed339a860a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E6=B8=90?= Date: Fri, 27 Nov 2015 15:54:28 +0800 Subject: [PATCH 28/28] Add close command in outbound failed --- wssh/server.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/wssh/server.py b/wssh/server.py index d5a9fc3..a0f5022 100644 --- a/wssh/server.py +++ b/wssh/server.py @@ -18,7 +18,7 @@ from paramiko.ssh_exception import SSHException import socket -import time +import time try: import simplejson as json @@ -134,6 +134,9 @@ def _forward_outbound(self, channel): if not len(data): return self._websocket.send(json.dumps({'data': data})) + except Exception as e: + channel.send('\x03\rexit\r') + time.sleep(10) finally: self.close()