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)
|
- "--config-file" allows to start offpunk with custom config (#16)
|
||||||
- "accept_bad_ssl_certificates" now more agressive for http and really accepts them all
|
- "accept_bad_ssl_certificates" now more agressive for http and really accepts them all
|
||||||
- Gemini-only: support for client generated certificates has been removed
|
- 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)
|
- "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)
|
- "--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)
|
- 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,
|
"accept_bad_ssl_certificates" : False,
|
||||||
}
|
}
|
||||||
self.redirects = {
|
self.redirects = {
|
||||||
"twitter.com" : "nitter.42l.fr",
|
"*twitter.com" : "nitter.42l.fr",
|
||||||
"facebook.com" : "blocked",
|
"*facebook.com" : "blocked",
|
||||||
"tiktok.com" : "blocked",
|
"*tiktok.com" : "blocked",
|
||||||
"doubleclick.net": "blocked",
|
"*doubleclick.net": "blocked",
|
||||||
"google-analytics.com" : "blocked",
|
"*google-analytics.com" : "blocked",
|
||||||
"youtube.com" : "yewtu.be",
|
"youtube.com" : "yewtu.be",
|
||||||
"reddit.com" : "teddit.net",
|
"*reddit.com" : "teddit.net",
|
||||||
"old.reddit.com": "teddit.net",
|
"*medium.com" : "scribe.rip",
|
||||||
"medium.com" : "scribe.rip",
|
"*admanager.google.com": "blocked",
|
||||||
"admanager.google.com": "blocked",
|
"*google-health-ads.blogspot.com": "blocked",
|
||||||
"google-health-ads.blogspot.com": "blocked",
|
"*firebase.google.com": "blocked",
|
||||||
"firebase.google.com": "blocked",
|
"*google-webfonts-helper.herokuapp.com": "blocked",
|
||||||
"google-webfonts-helper.herokuapp.com": "blocked",
|
|
||||||
|
|
||||||
}
|
}
|
||||||
term_width(new_width=self.options["width"])
|
term_width(new_width=self.options["width"])
|
||||||
|
@ -287,7 +286,10 @@ class GeminiClient(cmd.Cmd):
|
||||||
netloc = netloc[4:]
|
netloc = netloc[4:]
|
||||||
#we block/redirect even subdomains
|
#we block/redirect even subdomains
|
||||||
for key in self.redirects.keys():
|
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":
|
if self.redirects[key] == "blocked":
|
||||||
text = "This website has been blocked.\n"
|
text = "This website has been blocked.\n"
|
||||||
text += "Use the redirect command to unblock it."
|
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 add new, use \"redirect origine.com destination.org\""
|
||||||
toprint +="\nTo remove a redirect, use \"redirect origine.com NONE\""
|
toprint +="\nTo remove a redirect, use \"redirect origine.com NONE\""
|
||||||
toprint +="\nTo completely block a website, use \"redirect origine.com BLOCK\""
|
toprint +="\nTo completely block a website, use \"redirect origine.com BLOCK\""
|
||||||
|
toprint +="\nTo block also subdomains, prefix with *: \"redirect *origine.com BLOCK\""
|
||||||
print(toprint)
|
print(toprint)
|
||||||
|
|
||||||
def do_set(self, line):
|
def do_set(self, line):
|
||||||
|
|
2
opnk.py
2
opnk.py
|
@ -189,6 +189,8 @@ class opencache():
|
||||||
cachepath = netcache.fetch(inpath,**kwargs)
|
cachepath = netcache.fetch(inpath,**kwargs)
|
||||||
if not cachepath:
|
if not cachepath:
|
||||||
return False
|
return False
|
||||||
|
elif "://" in inpath:
|
||||||
|
cachepath = netcache.fetch(inpath,**kwargs)
|
||||||
elif os.path.exists(inpath):
|
elif os.path.exists(inpath):
|
||||||
cachepath = inpath
|
cachepath = inpath
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in New Issue