aboutsummaryrefslogtreecommitdiffstats
path: root/libpathod
diff options
context:
space:
mode:
authorAldo Cortesi <aldo@nullcube.com>2012-07-23 23:31:26 +1200
committerAldo Cortesi <aldo@nullcube.com>2012-07-23 23:31:26 +1200
commita950a4d7a3097685d54f325f32a169034e9435f1 (patch)
tree70c183f1a892cef1413ad1676a2f6a3b26171287 /libpathod
parent190392ea13f998fe298d48738131779f522d62e9 (diff)
downloadmitmproxy-a950a4d7a3097685d54f325f32a169034e9435f1.tar.gz
mitmproxy-a950a4d7a3097685d54f325f32a169034e9435f1.tar.bz2
mitmproxy-a950a4d7a3097685d54f325f32a169034e9435f1.zip
Add pathod --noapi to turn off the service API.
Diffstat (limited to 'libpathod')
-rw-r--r--libpathod/app.py29
-rw-r--r--libpathod/pathod.py7
2 files changed, 19 insertions, 17 deletions
diff --git a/libpathod/app.py b/libpathod/app.py
index c94e61ca..2c4cea23 100644
--- a/libpathod/app.py
+++ b/libpathod/app.py
@@ -5,24 +5,25 @@ import version, rparse, utils
logging.basicConfig(level="DEBUG")
app = Flask(__name__)
-@app.route('/api/info')
-def api_info():
- return jsonify(
- version = version.IVERSION
- )
+def api():
+ @app.route('/api/info')
+ def api_info():
+ return jsonify(
+ version = version.IVERSION
+ )
-@app.route('/api/log')
-def api_log():
- return jsonify(
- log = app.config["pathod"].get_log()
- )
+ @app.route('/api/log')
+ def api_log():
+ return jsonify(
+ log = app.config["pathod"].get_log()
+ )
-@app.route('/api/clear_log')
-def api_clear_log():
- app.config["pathod"].clear_log()
- return "OK"
+ @app.route('/api/clear_log')
+ def api_clear_log():
+ app.config["pathod"].clear_log()
+ return "OK"
@app.route('/')
diff --git a/libpathod/pathod.py b/libpathod/pathod.py
index 4d1f9e2c..90064581 100644
--- a/libpathod/pathod.py
+++ b/libpathod/pathod.py
@@ -150,7 +150,7 @@ class Pathod(tcp.TCPServer):
LOGBUF = 500
def __init__( self,
addr, ssloptions=None, prefix="/p/", staticdir=None, anchors=None,
- sizelimit=None, noweb=False, nocraft=False
+ sizelimit=None, noweb=False, nocraft=False, noapi=False
):
"""
addr: (address, port) tuple. If port is 0, a free port will be
@@ -166,9 +166,10 @@ class Pathod(tcp.TCPServer):
self.staticdir = staticdir
self.prefix = prefix
self.sizelimit = sizelimit
+ self.noweb, self.nocraft, self.noapi = noweb, nocraft, noapi
+ if not noapi:
+ app.api()
self.app = app.app
- self.noweb = noweb
- self.nocraft = nocraft
self.app.config["pathod"] = self
self.log = []
self.logid = 0