aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAldo Cortesi <aldo@nullcube.com>2011-02-06 10:52:54 +1300
committerAldo Cortesi <aldo@nullcube.com>2011-02-06 10:52:54 +1300
commit44dc3a052e724bdf10e9c04e1756db89615f5685 (patch)
tree992da575144f1886aa5f333c86805a0ef09cca41
parentd0c2d9480cdf80c680937c97c790add902f718fa (diff)
downloadmitmproxy-44dc3a052e724bdf10e9c04e1756db89615f5685.tar.gz
mitmproxy-44dc3a052e724bdf10e9c04e1756db89615f5685.tar.bz2
mitmproxy-44dc3a052e724bdf10e9c04e1756db89615f5685.zip
Add option to tell mitmproxy which interfaces to bind to.
-rw-r--r--libmproxy/console.py9
-rw-r--r--libmproxy/proxy.py6
-rwxr-xr-xmitmproxy10
3 files changed, 19 insertions, 6 deletions
diff --git a/libmproxy/console.py b/libmproxy/console.py
index 04e46064..84ef6a5f 100644
--- a/libmproxy/console.py
+++ b/libmproxy/console.py
@@ -632,7 +632,14 @@ class StatusBar(WWrap):
if self.expire and time.time() > self.expire:
self.message("")
status = urwid.Columns([
- urwid.Text([('title', "mproxy:%s"%self.master.server.port)]),
+ urwid.Text(
+ [
+ (
+ 'title',
+ "mitmproxy %s:%s"%(self.master.server.address, self.master.server.port)
+ )
+ ]
+ ),
urwid.Text(
[
self.text,
diff --git a/libmproxy/proxy.py b/libmproxy/proxy.py
index 4c29d747..63f4ceb4 100644
--- a/libmproxy/proxy.py
+++ b/libmproxy/proxy.py
@@ -471,9 +471,9 @@ ServerBase = SocketServer.ThreadingTCPServer
class ProxyServer(ServerBase):
request_queue_size = 20
allow_reuse_address = True
- def __init__(self, port):
- self.port = port
- ServerBase.__init__(self, ('', port), ProxyHandler)
+ def __init__(self, port, address=''):
+ self.port, self.address = port, address
+ ServerBase.__init__(self, (address, port), ProxyHandler)
self.masterq = None
def set_mqueue(self, q):
diff --git a/mitmproxy b/mitmproxy
index 2fc61a80..7b55b848 100755
--- a/mitmproxy
+++ b/mitmproxy
@@ -23,11 +23,17 @@ from optparse import OptionParser, OptionGroup
if __name__ == '__main__':
parser = OptionParser(
- usage = "%prog [options]",
+ usage = "%prog [options] [flowdump path]",
version="%%prog %s"%VERSION,
)
parser.add_option(
+ "-a", "--addr", action="store",
+ type = "str", dest="addr", default='',
+ help = "Address to bind proxy to (defaults to all interfaces)"
+ )
+
+ parser.add_option(
"-c", "--cert", action="store",
type = "str", dest="cert", default="~/.mitmproxy/cert.pem",
help = "SSL certificate file."
@@ -76,7 +82,7 @@ if __name__ == '__main__':
proxy.config = proxy.Config(
certpath
)
- server = proxy.ProxyServer(options.port)
+ server = proxy.ProxyServer(options.port, options.addr)
m = console.ConsoleMaster(server, options)
for i in args: