Make the addon configure mitmproxy itself to only intercept discord#36
Make the addon configure mitmproxy itself to only intercept discord#36tbodt wants to merge 1 commit intoRoachbones:mainfrom
Conversation
|
|
||
| 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] |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
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
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
4d8b1c5 to
d97abf7
Compare
a, jan recursivetree li pana e ni li lukin pona tawa mi: ["^(.+\\.)?"+re.escape(host)+"(:\\d+)?$" for host in DISCORD_DOMAINS] |
Turns out you can just do this, no need for a long flag when you start the program