aboutsummaryrefslogtreecommitdiffstats
path: root/libmproxy
diff options
context:
space:
mode:
authorAldo Cortesi <aldo@nullcube.com>2011-05-14 10:44:25 +1200
committerAldo Cortesi <aldo@nullcube.com>2011-05-14 10:44:25 +1200
commitf89581be1b2a884fe95b764a25eead280303f595 (patch)
tree7239b2491cb7d6833af39620b736aafb3681168b /libmproxy
parentc6075e1d93c61eab35bb3e0ae56337e579fea403 (diff)
downloadmitmproxy-f89581be1b2a884fe95b764a25eead280303f595.tar.gz
mitmproxy-f89581be1b2a884fe95b764a25eead280303f595.tar.bz2
mitmproxy-f89581be1b2a884fe95b764a25eead280303f595.zip
Add a -n option which tells the tools not to bind a proxy.
This is useful when you just want to inspect or process dumps.
Diffstat (limited to 'libmproxy')
-rw-r--r--libmproxy/cmdline.py20
-rw-r--r--libmproxy/console.py17
-rw-r--r--libmproxy/controller.py8
-rw-r--r--libmproxy/dump.py1
4 files changed, 31 insertions, 15 deletions
diff --git a/libmproxy/cmdline.py b/libmproxy/cmdline.py
index 4ff7cbe0..222defeb 100644
--- a/libmproxy/cmdline.py
+++ b/libmproxy/cmdline.py
@@ -15,18 +15,19 @@ def get_common_options(options):
stickyauth = options.stickyauth_filt
return dict(
- verbosity = options.verbose,
- wfile = options.wfile,
+ anticache = options.anticache,
+ client_replay = options.client_replay,
+ kill = options.kill,
+ no_server = options.no_server,
+ refresh_server_playback = not options.norefresh,
+ rheaders = options.rheaders,
request_script = options.request_script,
response_script = options.response_script,
server_replay = options.server_replay,
- kill = options.kill,
- rheaders = options.rheaders,
- client_replay = options.client_replay,
stickycookie = stickycookie,
stickyauth = stickyauth,
- anticache = options.anticache,
- refresh_server_playback = not options.norefresh,
+ wfile = options.wfile,
+ verbosity = options.verbose,
)
@@ -42,6 +43,11 @@ def common_options(parser):
help = "Configuration directory. (~/.mitmproxy)"
)
parser.add_option(
+ "-n",
+ action="store_true", dest="no_server",
+ help="Don't start a proxy server."
+ )
+ parser.add_option(
"-p",
action="store", type = "int", dest="port", default=8080,
help = "Proxy service port."
diff --git a/libmproxy/console.py b/libmproxy/console.py
index 399640c2..f0fb74e2 100644
--- a/libmproxy/console.py
+++ b/libmproxy/console.py
@@ -664,16 +664,19 @@ class StatusBar(WWrap):
('statusbar_text', ("[%s]"%len(self.master.state.flow_list)).ljust(7)),
]
t.extend(self.get_status())
+
+ if self.master.server:
+ boundaddr = "[%s:%s]"%(self.master.server.address or "*", self.master.server.port)
+ else:
+ boundaddr = "[no proxy]"
+
status = urwid.AttrWrap(urwid.Columns([
urwid.Text(t),
urwid.Text(
[
self.helptext,
" ",
- (
- 'statusbar_text',
- "[%s:%s]"%(self.master.server.address or "*", self.master.server.port)
- ),
+ ('statusbar_text', boundaddr),
],
align="right"
),
@@ -775,6 +778,7 @@ class Options(object):
"kill",
"intercept",
"limit",
+ "no_server",
"refresh_server_playback",
"request_script",
"response_script",
@@ -1024,8 +1028,9 @@ class ConsoleMaster(flow.FlowMaster):
self.view_connlist()
self.masterq = Queue.Queue()
- slave = controller.Slave(self.masterq, self.server)
- slave.start()
+ if self.server:
+ slave = controller.Slave(self.masterq, self.server)
+ slave.start()
self.ui.run_wrapper(self.loop)
# If True, quit just pops out to connection list view.
diff --git a/libmproxy/controller.py b/libmproxy/controller.py
index f0e65e7f..337f379d 100644
--- a/libmproxy/controller.py
+++ b/libmproxy/controller.py
@@ -58,6 +58,9 @@ class Slave(threading.Thread):
class Master:
def __init__(self, server):
+ """
+ server may be None if no server is needed.
+ """
self.server = server
self.masterq = Queue.Queue()
@@ -75,8 +78,9 @@ class Master:
pass
def run(self):
- slave = Slave(self.masterq, self.server)
- slave.start()
+ if self.server:
+ slave = Slave(self.masterq, self.server)
+ slave.start()
while not exit:
self.tick(self.masterq)
self.shutdown()
diff --git a/libmproxy/dump.py b/libmproxy/dump.py
index 6f18c8fe..3e645167 100644
--- a/libmproxy/dump.py
+++ b/libmproxy/dump.py
@@ -10,6 +10,7 @@ class Options(object):
"client_replay",
"keepserving",
"kill",
+ "no_server",
"refresh_server_playback",
"request_script",
"response_script",