This commit is contained in:
notfire 2024-09-18 13:18:25 -04:00
commit 7c6d06354e
5 changed files with 1527 additions and 0 deletions

3
.gitignore vendored Executable file
View file

@ -0,0 +1,3 @@
robots.txt
access.log
output_config.txt

1
allowed-agents.txt Executable file
View file

@ -0,0 +1 @@
Mastodon

50
blocked-agents.txt Executable file
View file

@ -0,0 +1,50 @@
-
2ip
AdsBot-Google
AdsBot-Google-Mobile
AGATHA
ALittle Client
Amazonbot
APIs-Google
Applebot
Baiduspider
Barkrowler
bingbot
BLEXBot
bot
ChatGPT-User
Chrome Privacy Preserving Prefetch Proxy
claudebot
DataForSeoBot
DotBot
ev-crawler
facebookexternalhit
glitch.th
Go-http-client
Google-Extended
Google-InspectionTool
Googlebot-Image
Googlebot-News
Googlebot-Video
GoogleOther
GoogleOther-Image
GoogleOther-Video
GPTBot
http.rb
InternetMeasurement
l9scan
Mediapartners-Google
NetcraftSurveyAgent
paloaltonetworks.com
python-requests
Searcherxweb
SemrushBot
SeznamBot
Storebot-Google
SummalyBot
SurdotlyBot
Twitterbot
yacybot
YandexBot
YandexFavicons
ZoominfoBot

1416
blocked-paths.txt Executable file

File diff suppressed because it is too large Load diff

57
generate_config.py Executable file
View file

@ -0,0 +1,57 @@
blocked_agents_import = open("blocked-agents.txt", "r")
blocked_agents = blocked_agents_import.readlines()
blocked_agents_sep_d = ""
for agent in blocked_agents:
if agent[-1] == "\n":
blocked_agents_sep_d += agent[:-1] + "|"
else:
blocked_agents_sep_d += agent + "|"
blocked_agents_sep_d = blocked_agents_sep_d[:-1]
blocked_paths_import = open("blocked-paths.txt", "r")
blocked_paths = blocked_paths_import.readlines()
blocked_paths_sep_d = ""
for path in blocked_paths:
if path[-1] == "\n":
blocked_paths_sep_d += path[:-1] + "|"
else:
blocked_paths_sep_d += path + "|"
blocked_paths_sep_d = blocked_paths_sep_d[:-1]
allowed_agents_import = open("allowed-agents.txt", "r")
allowed_agents = allowed_agents_import.readlines()
allowed_agents_sep_d = ""
for agent in allowed_agents:
if agent[-1] == "\n":
allowed_agents_sep_d += agent[:-1] + "|"
else:
allowed_agents_sep_d += agent + "|"
allowed_agents_sep_d = allowed_agents_sep_d[:-1]
# sorry this will be very messy
final_config = f''' set $redir_to_gz 1;
if ($http_user_agent !~* ({blocked_agents_sep_d})) {{
set $redir_to_gz 0;
}}
if ($http_user_agent ~* ({allowed_agents_sep_d})) {{
set $redir_to_gz 0;
}}
if ($http_user_agent == "") {{
set $redir_to_gz 1;
}}
location ~ ^/({blocked_paths_sep_d})/ {{
set $redir_to_gz 1;
}}
if ($redir_to_gz) {{
return 301 https://gz.notfire.cc;
}}'''
output_config = open("output_config.txt", "w+")
output_config.write(final_config)