Skip to content

Commit

Permalink
Add support for pretendo.network and reformat
Browse files Browse the repository at this point in the history
(they hardcoded the website cookie domains)
  • Loading branch information
MatthewL246 committed Dec 18, 2023
1 parent b0789f1 commit 2d05ef8
Showing 1 changed file with 23 additions and 15 deletions.
38 changes: 23 additions & 15 deletions pretendo_addon.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ def load(self, loader) -> None:
loader.add_option(
name="pretendo_redirect",
typespec=bool,
default=False,
default=True,
help="Redirect all requests from Nintendo to Pretendo",
)

Expand All @@ -17,34 +17,42 @@ def load(self, loader) -> None:
help="Host to send Pretendo requests to (keeps the original host in the Host header)",
)

loader.add_option(
name="pretendo_http",
typespec=bool,
default=False,
help="Sets Pretendo requests to HTTP (only applies if pretendo_host is set)",
)

loader.add_option(
name="pretendo_host_port",
typespec=int,
default=80,
help="Port to send Pretendo requests to (only applies if pretendo_host is set)",
)

loader.add_option(
name="pretendo_http",
typespec=bool,
default=False,
help="Sets Pretendo requests to HTTP (only applies if pretendo_host is set)",
)

def request(self, flow: http.HTTPFlow) -> None:
if ctx.options.pretendo_redirect:
if 'nintendo.net' in flow.request.pretty_host:
flow.request.host = flow.request.pretty_host.replace('nintendo.net', 'pretendo.cc')
elif 'nintendowifi.net' in flow.request.pretty_host:
flow.request.host = flow.request.pretty_host.replace('nintendowifi.net', 'pretendo.cc')

if 'pretendo.cc' in flow.request.pretty_host and ctx.options.pretendo_host:
if "nintendo.net" in flow.request.pretty_host:
flow.request.host = flow.request.pretty_host.replace(
"nintendo.net", "pretendo.cc"
)
elif "nintendowifi.net" in flow.request.pretty_host:
flow.request.host = flow.request.pretty_host.replace(
"nintendowifi.net", "pretendo.cc"
)

if ctx.options.pretendo_host and (
"pretendo.cc" in flow.request.pretty_host
or "pretendo.network" in flow.request.pretty_host
):
original_host = flow.request.host_header
flow.request.host = ctx.options.pretendo_host
flow.request.port = ctx.options.pretendo_host_port
flow.request.host_header = original_host

if ctx.options.pretendo_http:
flow.request.scheme = 'http'
flow.request.scheme = "http"


addons = [PretendoAddon()]

0 comments on commit 2d05ef8

Please sign in to comment.