mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-23 08:11:00 +00:00
Change the semantics of the craft anchor point specification
The anchor point is now defined as /p (rather than /p/), with the specification for a request just to /p or /p/ being empty.
This commit is contained in:
parent
dacb350040
commit
b0ab5297d1
@ -233,8 +233,8 @@ def args_pathod(argv, stdout=sys.stdout, stderr=sys.stderr):
|
||||
"""
|
||||
)
|
||||
parser.add_argument(
|
||||
"-c", dest='craftanchor', default="/p/", type=str,
|
||||
help='Anchorpoint for URL crafting commands. (/p/)'
|
||||
"-c", dest='craftanchor', default="/p", type=str,
|
||||
help='Anchorpoint for URL crafting commands. (/p)'
|
||||
)
|
||||
parser.add_argument(
|
||||
"--confdir",
|
||||
|
@ -201,11 +201,12 @@ class PathodHandler(tcp.BaseHandler):
|
||||
self.addlog(retlog)
|
||||
return again
|
||||
|
||||
if not self.server.nocraft and path.startswith(self.server.craftanchor):
|
||||
if not self.server.nocraft and utils.matchpath(path, self.server.craftanchor):
|
||||
spec = urllib.unquote(path)[len(self.server.craftanchor) + 1:]
|
||||
key = websockets.check_client_handshake(headers)
|
||||
if key:
|
||||
self.settings.websocket_key = key
|
||||
spec = urllib.unquote(path)[len(self.server.craftanchor):]
|
||||
if key and not spec:
|
||||
spec = "ws"
|
||||
self.info("crafting spec: %s" % spec)
|
||||
try:
|
||||
crafted = language.parse_response(spec)
|
||||
@ -301,7 +302,7 @@ class Pathod(tcp.TCPServer):
|
||||
addr,
|
||||
ssl=False,
|
||||
ssloptions=None,
|
||||
craftanchor="/p/",
|
||||
craftanchor="/p",
|
||||
staticdir=None,
|
||||
anchors=(),
|
||||
sizelimit=None,
|
||||
|
@ -136,3 +136,8 @@ def daemonize(stdin='/dev/null', stdout='/dev/null', stderr='/dev/null'): # prag
|
||||
os.dup2(si.fileno(), sys.stdin.fileno())
|
||||
os.dup2(so.fileno(), sys.stdout.fileno())
|
||||
os.dup2(se.fileno(), sys.stderr.fileno())
|
||||
|
||||
|
||||
def matchpath(path, spec):
|
||||
if path == spec or path.startswith(spec + "/"):
|
||||
return True
|
||||
|
@ -186,6 +186,7 @@ class CommonTests(tutils.DaemonTests):
|
||||
|
||||
def test_websocket(self):
|
||||
r = self.pathoc("ws:/p/")
|
||||
assert r.status_code == 101
|
||||
|
||||
|
||||
class TestDaemon(CommonTests):
|
||||
|
Loading…
Reference in New Issue
Block a user