jeevanjohnson / local-osu-server

the name says it all
31 stars 5 forks source link

use hosts file, to 127.0.0.1 for c4.example.com and etc #28

Closed github-actions[bot] closed 4 months ago

github-actions[bot] commented 4 months ago

https://github.com/jeevanjohnson/local-osu-server/blob/255e03f31675fb667025ea0614fc014cf8313315/mitmprox/main.py#L8


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

DEVSERVER_DOMAIN = "ripple.moe"

class MyMitmproxy:
    async def request(self, flow: http.HTTPFlow) -> None:
        # TODO: use hosts file, to 127.0.0.1 for c4.example.com and etc

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

            flow.response = Response.make(
                status_code=307,
github-actions[bot] commented 4 months ago

Closed in 1a46b45d3506c9fe750d32d1f2693e387e7674fe