Added beeping. --bireq and --bires enables beeping on intercepted requests/responses.

This commit is contained in:
Thomas Roth 2010-02-26 14:01:38 +01:00
parent c5eb3c592d
commit a5f87657e1
3 changed files with 31 additions and 4 deletions

View File

@ -714,6 +714,12 @@ class State:
#begin nocover
class ConsoleMaster(controller.Master):
beep = {
'intercepting_request':False,
'request':False,
'intercepting_response':False,
'response':False
}
palette = []
footer_text_default = [
('key', "?"), ":help ",
@ -724,15 +730,22 @@ class ConsoleMaster(controller.Master):
('key', "?"), ":help ",
('key', "q"), ":back ",
]
def __init__(self, server, config, terminal_background):
self.set_palette(terminal_background)
def __init__(self, server, options):
self.set_palette(options.terminal_background)
self.beep = {
'intercepting_request':options.beep_intercepted_request,
'intercepting_response':options.beep_intercepted_response}
controller.Master.__init__(self, server)
self.config = config
self.config = options.verbose
self.state = State()
self.stickycookie = None
self.stickyhosts = {}
def check_beep(self, source):
if self.beep.get(source, False):
urwid.curses_display.curses.beep()
def set_palette(self, terminal_background):
if terminal_background:
background_color = 'default'
@ -1084,8 +1097,10 @@ class ConsoleMaster(controller.Master):
f.request.headers["cookie"] = self.stickyhosts[hid]
if f.match(self.state.intercept):
self.check_beep('intercepting_request')
f.intercept()
else:
self.check_beep('request')
r.ack()
self.sync_list_view()
self.refresh_connection(f)
@ -1101,8 +1116,10 @@ class ConsoleMaster(controller.Master):
self.stickyhosts[hid] = f.response.headers["set-cookie"]
if f.match(self.state.intercept):
self.check_beep('intercepting_response')
f.intercept()
else:
self.check_beep('response')
r.ack()
self.sync_list_view()
self.refresh_connection(f)

View File

@ -25,6 +25,14 @@ if __name__ == '__main__':
usage = "%prog [options] output",
version="%prog 0.1",
)
parser.add_option(
"", "--bireq", action="store_true",
dest="beep_intercepted_request", default=False,
help = "Beep on intercepted request")
parser.add_option(
"", "--bires", action="store_true",
dest="beep_intercepted_response", default=False,
help = "Beep on intercepted response")
parser.add_option(
"-d", "--dump", action="store_true",
dest="dump", default=False,
@ -68,7 +76,7 @@ if __name__ == '__main__':
if options.dump:
m = controller.DumpMaster(server, options.verbose)
else:
m = console.ConsoleMaster(server, options.verbose, options.terminal_background)
m = console.ConsoleMaster(server, options)
if options.verbose > 0:
print >> sys.stderr, "Running on port %s"%options.port
m.run()

2
todo
View File

@ -10,6 +10,8 @@ Future:
- Shortcut for viewing in pager
- Serializing and de-serializing requests and responses.
- Use real non-blocking input handling to minimize cpu load.
- Give the ability to beep on certain events. (On intercepted
request/response already working.)
Bugs: