Skip to content

Commit

Permalink
Fix usage without a custom host
Browse files Browse the repository at this point in the history
  • Loading branch information
MatthewL246 committed Dec 18, 2023
1 parent 7a20b5e commit d8ec9c9
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions pretendo_addon.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,25 @@ def load(self, loader) -> None:
help="Redirect all requests from Nintendo to Pretendo",
)

loader.add_option(
name="pretendo_http",
typespec=bool,
default=False,
help="Sets Pretendo requests to HTTP",
)

loader.add_option(
name="pretendo_host",
typespec=str,
default="pretendo.cc",
default="",
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",
help="Port to send Pretendo requests to (only applies if pretendo_host is set)",
)

def request(self, flow: http.HTTPFlow) -> None:
Expand All @@ -38,14 +38,14 @@ def request(self, flow: http.HTTPFlow) -> None:
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:
flow.request.port = ctx.options.pretendo_host_port

if 'pretendo.cc' in flow.request.pretty_host and ctx.options.pretendo_host:
original_host = flow.request.host_header
flow.request.host = ctx.options.pretendo_host
flow.request.host_header = original_host

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

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

addons = [PretendoAddon()]

0 comments on commit d8ec9c9

Please sign in to comment.