mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-26 18:18:25 +00:00
Add option to specify craft anchor point.
This commit is contained in:
parent
97fe026c32
commit
eb1f2c3fc4
@ -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:
|
||||
|
5
pathod
5
pathod
@ -10,6 +10,10 @@ if __name__ == "__main__":
|
||||
"-a", dest='anchors', default=[], type=str, action="append", metavar="ANCHOR",
|
||||
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,
|
||||
|
Loading…
Reference in New Issue
Block a user