From 7a20b5e6d9c0fa77b579959145d1c4e30bdab9f6 Mon Sep 17 00:00:00 2001 From: Matthew Lopez <73856503+MatthewL246@users.noreply.github.com> Date: Sun, 17 Dec 2023 14:24:42 -0500 Subject: [PATCH] Set up script for custom Pretendo hosts --- pretendo_addon.py | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/pretendo_addon.py b/pretendo_addon.py index f81631e..1271c55 100644 --- a/pretendo_addon.py +++ b/pretendo_addon.py @@ -17,14 +17,33 @@ def load(self, loader) -> None: help="Sets Pretendo requests to HTTP", ) + loader.add_option( + name="pretendo_host", + typespec=str, + default="pretendo.cc", + help="Host to send Pretendo requests to (keeps the original host in the Host header)", + ) + + loader.add_option( + name="pretendo_host_port", + typespec=int, + default=80, + help="Port to send Pretendo requests to", + ) + def request(self, flow: http.HTTPFlow) -> None: if ctx.options.pretendo_redirect: if 'nintendo.net' in flow.request.pretty_host: - flow.request.host_header = flow.request.pretty_host.replace('nintendo.net', 'pretendo.cc') + flow.request.host = flow.request.pretty_host.replace('nintendo.net', 'pretendo.cc') elif 'nintendowifi.net' in flow.request.pretty_host: - flow.request.host_header = flow.request.pretty_host.replace('nintendowifi.net', 'pretendo.cc') - elif 'rverse.club' in flow.request.pretty_host: - flow.request.host_header = flow.request.pretty_host.replace('rverse.club', 'pretendo.cc') + 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 + + 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'