Skip to content

Make the addon configure mitmproxy itself to only intercept discord#36

Open
tbodt wants to merge 1 commit intoRoachbones:mainfrom
tbodt:push-muulwlutwmuq
Open

Make the addon configure mitmproxy itself to only intercept discord#36
tbodt wants to merge 1 commit intoRoachbones:mainfrom
tbodt:push-muulwlutwmuq

Conversation

@tbodt
Copy link
Copy Markdown

@tbodt tbodt commented Mar 16, 2026

Turns out you can just do this, no need for a long flag when you start the program

Comment thread wumpus_in_the_middle.py

def configure(self, updated: set[str]):
if "override_allow_hosts" in updated and ctx.options.override_allow_hosts:
ctx.options.allow_hosts = [re.escape(host) for host in DISCORD_DOMAINS]
Copy link
Copy Markdown
Author

@tbodt tbodt Mar 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure about this way of matching hosts? This will search for the name anywhere inside the request hostname, so it could be at the start or at the end or in the middle and it would get intercepted. The big regex was probably better at this and only matched at the end of the hostname right? kinda annoying

@tbodt tbodt changed the title ilo insa kute o toki a e ni tawa ilo mitmproxy: ona li wile kute e ilo siko taso Make the addon configure mitmproxy itself to only intercept discord Mar 16, 2026
Copy link
Copy Markdown
Owner

@Roachbones Roachbones left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sina pona.

ilo allow_hosts li pali seme

tenpo ale la mi sona pona ala e kon pi ilo allow_hosts. tan ni la, mi wile sitelen e sona lon ni, li lukin sin e ona lon tenpo kama.

lipu pi ilo mitmproxy li toki e ni: ilo allow_hosts li sama ilo ignore_hosts. ilo ignore_hosts la, lipu li toki e ni:

Ignore host and forward all traffic without processing it. In transparent mode, it is recommended to use an IP address (range), not the hostname. In regular mode, only SSL traffic is ignored and the hostname should be used. The supplied value is interpreted as a regular expression and matched on the ip or the hostname.

taso, nimi "match on" li toki e seme? ona li sama re.match anu re.search anu re.fullmatch?

lon: ona li sama re.search. lawa --allow-hosts pona li weka ala e toki lon tokipona.rose.systems. (ni li nasa lili tawa mi.)

(nasa nanpa tu la, ilo allow_hosts li weka ala e toki HTTP.)

pali sina

  • mi wile pona e [re.escape(host) for host in DISCORD_DOMAINS] sama ["^(((.+\\.)?"+re.escape(host)+"$" for host in DISCORD_DOMAINS].

  • NameError: name 're' is not defined. Did you forget to import 're'?

English

Thank you, I didn't know we could do that.

What allow_hosts does

I never remember how allow_hosts works (and am not the only one), so let me break it down for my own future reference if nothing else:

allow_hosts is documented as "Opposite of --ignore-hosts.", and ignore_hosts is documented to be:

Ignore host and forward all traffic without processing it. In transparent mode, it is recommended to use an IP address (range), not the hostname. In regular mode, only SSL traffic is ignored and the hostname should be used. The supplied value is interpreted as a regular expression and matched on the ip or the hostname.

but "match on" is ambiguous; is that a re.match (pattern matches beginning of string), re.search (pattern matches any substring) or re.fullmatch (pattern matches entire string)? Answer: it's like re.search.

Also, allow_hosts doesn't filter any HTTP traffic.

Back to the PR

  • I think we should do something like ["^(((.+\\.)?"+re.escape(host)+"$" for host in DISCORD_DOMAINS] for exact matching.

  • Need to import re.

Comment thread readme.md Outdated
Comment thread readme.md Outdated
@tbodt
Copy link
Copy Markdown
Author

tbodt commented Mar 19, 2026

mi wile pona e [re.escape(host) for host in DISCORD_DOMAINS] sama ["^(((.+\.)?"+re.escape(host)+"$" for host in DISCORD_DOMAINS].

mi pilin sama. taso mi lukin sin e insa pi ilo mitmproxy li kama sona e ni: ilo li alasa e ijo alasa wile lon nimi ilo taso ala - ona li wan e nimi ilo e : e nanpa. la mi o ante e $ tawa : anu seme. mi alasa

NameError: name 're' is not defined. Did you forget to import 're'?

seme pakala la ale li pona lon ilo mi. ante ni li lon ilo mi taso la mi kama ala pana e ona anu seme

Turns out you can just do this
@tbodt tbodt force-pushed the push-muulwlutwmuq branch from 4d8b1c5 to d97abf7 Compare March 19, 2026 03:26
@Roachbones
Copy link
Copy Markdown
Owner

mi pilin sama. taso mi lukin sin e insa pi ilo mitmproxy li kama sona e ni: ilo li alasa e ijo alasa wile lon nimi ilo taso ala - ona li wan e nimi ilo e : e nanpa. la mi o ante e $ tawa : anu seme. mi alasa

a, jan recursivetree li pana e (?::\d+)? lon #25.

ni li lukin pona tawa mi:

["^(.+\\.)?"+re.escape(host)+"(:\\d+)?$" for host in DISCORD_DOMAINS]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants