aboutsummaryrefslogtreecommitdiffstats
path: root/libmproxy/web
diff options
context:
space:
mode:
authorAldo Cortesi <aldo@nullcube.com>2014-09-14 12:22:28 +1200
committerAldo Cortesi <aldo@nullcube.com>2014-09-14 12:22:28 +1200
commit6812d304a1a1893480360d5439fa09445ad55a2c (patch)
tree11974af622aac86a9adc47474b7d192889847d48 /libmproxy/web
parentadfaa1ed5ba07be267a90de8d7efb34613400bf2 (diff)
downloadmitmproxy-6812d304a1a1893480360d5439fa09445ad55a2c.tar.gz
mitmproxy-6812d304a1a1893480360d5439fa09445ad55a2c.tar.bz2
mitmproxy-6812d304a1a1893480360d5439fa09445ad55a2c.zip
Basic web service and options
Diffstat (limited to 'libmproxy/web')
-rw-r--r--libmproxy/web/__init__.py12
-rw-r--r--libmproxy/web/app.py18
2 files changed, 30 insertions, 0 deletions
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)
+