mirror of
https://github.com/mitmproxy/mitmproxy.git
synced 2025-01-26 07:44:35 +00:00
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.
This commit is contained in:
parent
c6075e1d93
commit
f89581be1b
@ -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,
|
||||
)
|
||||
|
||||
|
||||
@ -41,6 +42,11 @@ def common_options(parser):
|
||||
action="store", type = "str", dest="confdir", default='~/.mitmproxy',
|
||||
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,
|
||||
|
@ -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.
|
||||
|
@ -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()
|
||||
|
@ -10,6 +10,7 @@ class Options(object):
|
||||
"client_replay",
|
||||
"keepserving",
|
||||
"kill",
|
||||
"no_server",
|
||||
"refresh_server_playback",
|
||||
"request_script",
|
||||
"response_script",
|
||||
|
14
mitmdump
14
mitmdump
@ -39,11 +39,15 @@ if __name__ == '__main__':
|
||||
options.verbose = 0
|
||||
|
||||
config = proxy.process_certificate_option_group(parser, options)
|
||||
try:
|
||||
server = proxy.ProxyServer(config, options.port, options.addr)
|
||||
except proxy.ProxyServerError, v:
|
||||
print >> sys.stderr, "mitmdump:", v.args[0]
|
||||
sys.exit(1)
|
||||
if options.no_server:
|
||||
server = None
|
||||
else:
|
||||
try:
|
||||
server = proxy.ProxyServer(config, options.port, options.addr)
|
||||
except proxy.ProxyServerError, v:
|
||||
print >> sys.stderr, "mitmdump:", v.args[0]
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
dumpopts = dump.Options(**cmdline.get_common_options(options))
|
||||
dumpopts.keepserving = options.keepserving
|
||||
|
14
mitmproxy
14
mitmproxy
@ -49,11 +49,15 @@ if __name__ == '__main__':
|
||||
options, args = parser.parse_args()
|
||||
|
||||
config = proxy.process_certificate_option_group(parser, options)
|
||||
try:
|
||||
server = proxy.ProxyServer(config, options.port, options.addr)
|
||||
except proxy.ProxyServerError, v:
|
||||
print >> sys.stderr, "mitmproxy:", v.args[0]
|
||||
sys.exit(1)
|
||||
|
||||
if options.no_server:
|
||||
server = None
|
||||
else:
|
||||
try:
|
||||
server = proxy.ProxyServer(config, options.port, options.addr)
|
||||
except proxy.ProxyServerError, v:
|
||||
print >> sys.stderr, "mitmproxy:", v.args[0]
|
||||
sys.exit(1)
|
||||
|
||||
opts = console.Options(**cmdline.get_common_options(options))
|
||||
opts.intercept = options.intercept
|
||||
|
Loading…
x
Reference in New Issue
Block a user