aboutsummaryrefslogtreecommitdiffstats
path: root/libmproxy
diff options
context:
space:
mode:
Diffstat (limited to 'libmproxy')
-rw-r--r--libmproxy/cmdline.py8
-rw-r--r--libmproxy/main.py28
-rw-r--r--libmproxy/web/__init__.py12
-rw-r--r--libmproxy/web/app.py18
4 files changed, 60 insertions, 6 deletions
diff --git a/libmproxy/cmdline.py b/libmproxy/cmdline.py
index caa3a9c8..a3cf07ef 100644
--- a/libmproxy/cmdline.py
+++ b/libmproxy/cmdline.py
@@ -314,23 +314,23 @@ def common_options(parser):
help="Override the HTTP request form sent upstream by the proxy"
)
- group = parser.add_argument_group("Web App")
+ group = parser.add_argument_group("Onboarding App")
group.add_argument(
"-a",
action="store_false", dest="app", default=True,
- help="Disable the mitmproxy web app."
+ help="Disable the mitmproxy onboarding app."
)
group.add_argument(
"--app-host",
action="store", dest="app_host", default=APP_HOST, metavar="host",
- help="Domain to serve the app from. For transparent mode, use an IP when\
+ help="Domain to serve the onboarding app from. For transparent mode, use an IP when\
a DNS entry for the app domain is not present. Default: %s" % APP_HOST
)
group.add_argument(
"--app-port",
action="store", dest="app_port", default=APP_PORT, type=int, metavar="80",
- help="Port to serve the app from."
+ help="Port to serve the onboarding app from."
)
group = parser.add_argument_group("Client Replay")
diff --git a/libmproxy/main.py b/libmproxy/main.py
index ba869e19..a3c91c02 100644
--- a/libmproxy/main.py
+++ b/libmproxy/main.py
@@ -170,8 +170,28 @@ def mitmweb_cmdline():
parser.add_argument(
'--version',
action='version',
- version=version.NAMEVERSION
+ version="mitmweb" + " " + version.VERSION
)
+
+ group = parser.add_argument_group("Mitmweb")
+ group.add_argument(
+ "--wport",
+ action="store", type=int, dest="wport", default=8081,
+ metavar="PORT",
+ help="Mitmweb port."
+ )
+ group.add_argument(
+ "--wiface",
+ action="store", dest="wiface", default="127.0.0.1",
+ metavar="IFACE",
+ help="Mitmweb interface."
+ )
+ group.add_argument(
+ "--wdebug",
+ action="store_true", dest="wdebug",
+ help="Turn on mitmweb debugging"
+ )
+
cmdline.common_options(parser)
group = parser.add_argument_group(
"Filters",
@@ -189,6 +209,10 @@ def mitmweb_cmdline():
proxy_config = process_proxy_options(parser, options)
web_options = web.Options(**cmdline.get_common_options(options))
+ web_options.intercept = options.intercept
+ web_options.wdebug = options.wdebug
+ web_options.wiface = options.wiface
+ web_options.wport = options.wport
return web_options, proxy_config
@@ -197,7 +221,7 @@ def mitmweb(): # pragma: nocover
check_versions()
assert_utf8_env()
- web_options, proxy_config = mitmproxy_cmdline()
+ web_options, proxy_config = mitmweb_cmdline()
server = get_server(web_options.no_server, proxy_config)
m = web.WebMaster(server, web_options)
diff --git a/libmproxy/web/__init__.py b/libmproxy/web/__init__.py
index 815142bb..99b190aa 100644
--- a/libmproxy/web/__init__.py
+++ b/libmproxy/web/__init__.py
@@ -2,6 +2,7 @@
import tornado.ioloop
import tornado.httpserver
from .. import controller, utils, flow, script, proxy
+import app
class Stop(Exception):
@@ -40,6 +41,10 @@ class Options(object):
"verbosity",
"wfile",
"nopop",
+
+ "wdebug",
+ "wport",
+ "wiface",
]
def __init__(self, **kwargs):
@@ -52,6 +57,7 @@ class Options(object):
class WebMaster(flow.FlowMaster):
def __init__(self, server, options):
+ self.options = options
flow.FlowMaster.__init__(self, server, WebState())
def tick(self):
@@ -63,6 +69,12 @@ class WebMaster(flow.FlowMaster):
controller.Channel(self.masterq, self.should_exit)
)
iol = tornado.ioloop.IOLoop.instance()
+
+ http_server = tornado.httpserver.HTTPServer(
+ app.Application(self.options.wdebug)
+ )
+ http_server.listen(self.options.wport)
+
tornado.ioloop.PeriodicCallback(self.tick, 5).start()
try:
iol.start()
diff --git a/libmproxy/web/app.py b/libmproxy/web/app.py
new file mode 100644
index 00000000..7c26c29d
--- /dev/null
+++ b/libmproxy/web/app.py
@@ -0,0 +1,18 @@
+
+import os.path
+import tornado.web
+
+
+class Application(tornado.web.Application):
+ def __init__(self, debug):
+ handlers = [
+ ]
+ settings = dict(
+ template_path=os.path.join(os.path.dirname(__file__), "templates"),
+ static_path=os.path.join(os.path.dirname(__file__), "static"),
+ xsrf_cookies=True,
+ cookie_secret="__TODO:_GENERATE_YOUR_OWN_RANDOM_VALUE_HERE__",
+ debug=debug,
+ )
+ tornado.web.Application.__init__(self, handlers, **settings)
+