jeevanjohnson / local-osu-server

the name says it all
31 stars 5 forks source link

Redirect to `localosuserver.com` instead of `*.ppy.sh` #17

Closed github-actions[bot] closed 4 months ago

github-actions[bot] commented 4 months ago

Ensures safety of the user's bancho account

https://github.com/jeevanjohnson/local-osu-server/blob/b912a7b0b8d291da6deb2568aaf55807893223bc/mitmprox/main.py#L7


from mitmproxy import http # type: ignore
from mitmproxy.http import Response

class MyMitmproxy:
    async def request(self, flow: http.HTTPFlow) -> None:

        # TODO: Redirect to `localosuserver.com` instead of `*.ppy.sh`
        # Ensures safety of the user's bancho account
        if flow.request.pretty_host.endswith(".ppy.sh"):
            subdomain = flow.request.pretty_host.split(".")[0]
            location = flow.request.url.replace(f"https://{subdomain}.ppy.sh", f"http://localhost:8000/{subdomain}")

            flow.response = Response.make(
                status_code=307,
                headers={"Location": location},
            )

addons = [MyMitmproxy()]
github-actions[bot] commented 4 months ago

Closed in 1a46b45d3506c9fe750d32d1f2693e387e7674fe