forked from solderpunk/AV-98
support blocking subdomains with *
This commit is contained in:
parent
28d22c4d11
commit
2fa2fbc718
|
@ -17,7 +17,7 @@ This is an an experimental release. Bug reports and feedbacks are welcome on the
|
|||
- "--config-file" allows to start offpunk with custom config (#16)
|
||||
- "accept_bad_ssl_certificates" now more agressive for http and really accepts them all
|
||||
- Gemini-only: support for client generated certificates has been removed
|
||||
- blocked domains with "redirect" now also blocks related subdomains.
|
||||
- "redirect" supports domains starting with "*" to also block all subdomins
|
||||
- "file" is now marked as a dependency (thank Guillaume Loret)
|
||||
- "--images-mode" allow to choose at startup which images should be dowloaded (none,readable,full)
|
||||
- Support for multi-format rendering (such as RSS feeds with html elements)
|
||||
|
|
29
offpunk.py
29
offpunk.py
|
@ -181,19 +181,18 @@ class GeminiClient(cmd.Cmd):
|
|||
"accept_bad_ssl_certificates" : False,
|
||||
}
|
||||
self.redirects = {
|
||||
"twitter.com" : "nitter.42l.fr",
|
||||
"facebook.com" : "blocked",
|
||||
"tiktok.com" : "blocked",
|
||||
"doubleclick.net": "blocked",
|
||||
"google-analytics.com" : "blocked",
|
||||
"*twitter.com" : "nitter.42l.fr",
|
||||
"*facebook.com" : "blocked",
|
||||
"*tiktok.com" : "blocked",
|
||||
"*doubleclick.net": "blocked",
|
||||
"*google-analytics.com" : "blocked",
|
||||
"youtube.com" : "yewtu.be",
|
||||
"reddit.com" : "teddit.net",
|
||||
"old.reddit.com": "teddit.net",
|
||||
"medium.com" : "scribe.rip",
|
||||
"admanager.google.com": "blocked",
|
||||
"google-health-ads.blogspot.com": "blocked",
|
||||
"firebase.google.com": "blocked",
|
||||
"google-webfonts-helper.herokuapp.com": "blocked",
|
||||
"*reddit.com" : "teddit.net",
|
||||
"*medium.com" : "scribe.rip",
|
||||
"*admanager.google.com": "blocked",
|
||||
"*google-health-ads.blogspot.com": "blocked",
|
||||
"*firebase.google.com": "blocked",
|
||||
"*google-webfonts-helper.herokuapp.com": "blocked",
|
||||
|
||||
}
|
||||
term_width(new_width=self.options["width"])
|
||||
|
@ -287,7 +286,10 @@ class GeminiClient(cmd.Cmd):
|
|||
netloc = netloc[4:]
|
||||
#we block/redirect even subdomains
|
||||
for key in self.redirects.keys():
|
||||
if netloc.endswith(key):
|
||||
match = key == netloc
|
||||
if key.startswith("*"):
|
||||
match = netloc.endswith(key[1:])
|
||||
if match:
|
||||
if self.redirects[key] == "blocked":
|
||||
text = "This website has been blocked.\n"
|
||||
text += "Use the redirect command to unblock it."
|
||||
|
@ -427,6 +429,7 @@ class GeminiClient(cmd.Cmd):
|
|||
toprint +="\nTo add new, use \"redirect origine.com destination.org\""
|
||||
toprint +="\nTo remove a redirect, use \"redirect origine.com NONE\""
|
||||
toprint +="\nTo completely block a website, use \"redirect origine.com BLOCK\""
|
||||
toprint +="\nTo block also subdomains, prefix with *: \"redirect *origine.com BLOCK\""
|
||||
print(toprint)
|
||||
|
||||
def do_set(self, line):
|
||||
|
|
Loading…
Reference in New Issue