aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAldo Cortesi <aldo@nullcube.com>2012-07-24 21:51:43 +1200
committerAldo Cortesi <aldo@nullcube.com>2012-07-24 21:51:43 +1200
commiteb1f2c3fc40ccfc0db60776412add6a35af93bf9 (patch)
tree3ca4b9a19022eb369b53549073a9f25b2120e130
parent97fe026c3230e1be12536e7390ef374447ffe9e8 (diff)
downloadmitmproxy-eb1f2c3fc40ccfc0db60776412add6a35af93bf9.tar.gz
mitmproxy-eb1f2c3fc40ccfc0db60776412add6a35af93bf9.tar.bz2
mitmproxy-eb1f2c3fc40ccfc0db60776412add6a35af93bf9.zip
Add option to specify craft anchor point.
-rw-r--r--libpathod/pathod.py10
-rwxr-xr-xpathod5
2 files changed, 10 insertions, 5 deletions
diff --git a/libpathod/pathod.py b/libpathod/pathod.py
index 90064581..0ab7e915 100644
--- a/libpathod/pathod.py
+++ b/libpathod/pathod.py
@@ -83,8 +83,8 @@ class PathodHandler(tcp.BaseHandler):
if i[0].match(path):
return self.serve_crafted(i[1], request_log)
- if not self.server.nocraft and path.startswith(self.server.prefix):
- spec = urllib.unquote(path)[len(self.server.prefix):]
+ if not self.server.nocraft and path.startswith(self.server.craftanchor):
+ spec = urllib.unquote(path)[len(self.server.craftanchor):]
try:
crafted = rparse.parse_response(self.server.request_settings, spec)
except rparse.ParseException, v:
@@ -149,14 +149,14 @@ class PathodHandler(tcp.BaseHandler):
class Pathod(tcp.TCPServer):
LOGBUF = 500
def __init__( self,
- addr, ssloptions=None, prefix="/p/", staticdir=None, anchors=None,
+ addr, ssloptions=None, craftanchor="/p/", staticdir=None, anchors=None,
sizelimit=None, noweb=False, nocraft=False, noapi=False
):
"""
addr: (address, port) tuple. If port is 0, a free port will be
automatically chosen.
ssloptions: a dictionary containing certfile and keyfile specifications.
- prefix: string specifying the prefix at which to anchor response generation.
+ craftanchor: string specifying the path under which to anchor response generation.
staticdir: path to a directory of static resources, or None.
anchors: A list of (regex, spec) tuples, or None.
sizelimit: Limit size of served data.
@@ -164,7 +164,7 @@ class Pathod(tcp.TCPServer):
tcp.TCPServer.__init__(self, addr)
self.ssloptions = ssloptions
self.staticdir = staticdir
- self.prefix = prefix
+ self.craftanchor = craftanchor
self.sizelimit = sizelimit
self.noweb, self.nocraft, self.noapi = noweb, nocraft, noapi
if not noapi:
diff --git a/pathod b/pathod
index a5cc02ca..df044ae7 100755
--- a/pathod
+++ b/pathod
@@ -11,6 +11,10 @@ if __name__ == "__main__":
help='Add an anchor. Specified as a string with the form pattern=pagespec'
)
parser.add_argument(
+ "-c", dest='craftanchor', default="/p/", type=str,
+ help='Anchorpoint for URL crafting commands.'
+ )
+ parser.add_argument(
"-d", dest='staticdir', default=None, type=str,
help='Directory for static files.'
)
@@ -89,6 +93,7 @@ if __name__ == "__main__":
try:
pd = pathod.Pathod(
(args.address, args.port),
+ craftanchor = args.craftanchor,
ssloptions = ssl,
staticdir = args.staticdir,
anchors = alst,