Commit 85ec3fa7 authored by Sam Rushing's avatar Sam Rushing

terminal.__init__(): removed dead code for Logout exception

terminal.handle_packet(): support ctrl-n with ctrl-p (kinda works)
__main__: use tlslite server (for security)
parent b5d25975
...@@ -24,10 +24,7 @@ class terminal (websocket): ...@@ -24,10 +24,7 @@ class terminal (websocket):
self.history = [] self.history = []
self.history_index = 0 self.history_index = 0
self.line = [] self.line = []
try: self.repl.read_eval_print_loop()
self.repl.read_eval_print_loop()
except Logout:
pass
def handle_close (self): def handle_close (self):
pass pass
...@@ -53,8 +50,11 @@ class terminal (websocket): ...@@ -53,8 +50,11 @@ class terminal (websocket):
self.repl.inlines.push (line) self.repl.inlines.push (line)
elif ascii == 4: # ctrl-d elif ascii == 4: # ctrl-d
self.repl.inlines.push (None) self.repl.inlines.push (None)
elif ascii == 16: # ctrl-p elif ascii in (16, 14): # ctrl-p, ctrl-n
self.history_index = (self.history_index + 1) % len(self.history) if ascii == 16:
self.history_index = (self.history_index + 1) % len(self.history)
else:
self.history_index = (self.history_index - 1) % len(self.history)
line = self.history[0 - self.history_index] line = self.history[0 - self.history_index]
# turn into a list of chars... # turn into a list of chars...
self.line = [x for x in line] self.line = [x for x in line]
...@@ -111,19 +111,19 @@ if __name__ == '__main__': ...@@ -111,19 +111,19 @@ if __name__ == '__main__':
import coro.http import coro.http
import coro.backdoor import coro.backdoor
import os import os
cwd = os.getcwd()
ih = coro.http.handlers.favicon_handler() ih = coro.http.handlers.favicon_handler()
sh = coro.http.handlers.coro_status_handler() sh = coro.http.handlers.coro_status_handler()
th = handler ('/term', terminal) th = handler ('/term', terminal)
th.auth_dict = {'foo':'bar'} th.auth_dict = {'foo':'bar'}
fh = coro.http.handlers.file_handler (cwd) # serve files out of this directory
fh = coro.http.handlers.file_handler (os.getcwd())
handlers = [th, ih, sh, fh] handlers = [th, ih, sh, fh]
#server = coro.http.server (('0.0.0.0', 9001)) #server = coro.http.server()
server = coro.http.server() server = coro.http.tlslite_server (
#server = coro.http.tlslite_server ( # should point to the test cert in coro/http/cert/
# '/home/rushing/src/spdy/cert/server.crt', '../../../cert/server.crt',
# '/home/rushing/src/spdy/cert/server.key', '../../../cert/server.key',
# ) )
for h in handlers: for h in handlers:
server.push_handler (h) server.push_handler (h)
#coro.spawn (server.start) #coro.spawn (server.start)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment