aboutsummaryrefslogtreecommitdiffstats
path: root/examples/mitmproxywrapper.py
diff options
context:
space:
mode:
authorMarc Liyanage <reg.gitcommit@entropy.ch>2013-07-07 15:58:21 -0700
committerMarc Liyanage <reg.gitcommit@entropy.ch>2013-07-08 20:56:05 -0700
commite5c0891e84be486ba56c3a80fb22d057a75c533d (patch)
treee5c6cbf7773566c7423536c962982b9993cadb74 /examples/mitmproxywrapper.py
parent09c95ece52456dc008283e626dd2a8b8ce2a0eec (diff)
downloadmitmproxy-e5c0891e84be486ba56c3a80fb22d057a75c533d.tar.gz
mitmproxy-e5c0891e84be486ba56c3a80fb22d057a75c533d.tar.bz2
mitmproxy-e5c0891e84be486ba56c3a80fb22d057a75c533d.zip
Pass extra command line arguments to mitmproxy
Diffstat (limited to 'examples/mitmproxywrapper.py')
-rwxr-xr-xexamples/mitmproxywrapper.py18
1 files changed, 13 insertions, 5 deletions
diff --git a/examples/mitmproxywrapper.py b/examples/mitmproxywrapper.py
index 344cd53b..27ffd609 100755
--- a/examples/mitmproxywrapper.py
+++ b/examples/mitmproxywrapper.py
@@ -16,8 +16,9 @@ import sys
class Wrapper(object):
- def __init__(self, port):
+ def __init__(self, port, extra_arguments=None):
self.port = port
+ self.extra_arguments = extra_arguments
def run_networksetup_command(self, *arguments):
return subprocess.check_output(['sudo', 'networksetup'] + list(arguments))
@@ -82,7 +83,11 @@ class Wrapper(object):
def wrap_mitmproxy(self):
with self.wrap_proxy():
- subprocess.check_call(['mitmproxy', '-p', str(self.port), '--palette', 'light'])
+ cmd = ['mitmproxy', '-p', str(self.port)]
+ if self.extra_arguments:
+ cmd.extend(self.extra_arguments)
+ cmd.extend(['--palette', 'light'])
+ subprocess.check_call(cmd)
def wrap_honeyproxy(self):
with self.wrap_proxy():
@@ -113,13 +118,16 @@ class Wrapper(object):
@classmethod
def main(cls):
- parser = argparse.ArgumentParser(description='Helper tool for OS X proxy configuration and mitmproxy')
+ parser = argparse.ArgumentParser(
+ description='Helper tool for OS X proxy configuration and mitmproxy.',
+ epilog='Any additional arguments will be passed on unchanged to mitmproxy.'
+ )
parser.add_argument('-t', '--toggle', action='store_true', help='just toggle the proxy configuration')
# parser.add_argument('--honeyproxy', action='store_true', help='run honeyproxy instead of mitmproxy')
parser.add_argument('-p', '--port', type=int, help='override the default port of 8080', default=8080)
- args = parser.parse_args()
+ args, extra_arguments = parser.parse_known_args()
- wrapper = cls(port=args.port)
+ wrapper = cls(port=args.port, extra_arguments=extra_arguments)
if args.toggle:
wrapper.toggle_proxy()