Skip to content

Commit

Permalink
testing awk
Browse files Browse the repository at this point in the history
  • Loading branch information
NotaInutilis committed Sep 16, 2023
1 parent 54cc2bc commit 2af6aa4
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 14 deletions.
9 changes: 9 additions & 0 deletions scripts/domains_to_dnsmasq.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# This script converts domains.txt into dnsmasq's blocking syntax.
# python domains_to_dnsmasq.py > dnsmasq.txt

text_file = open("domains.txt", "r")
lines = text_file.readlines()
text_file.close()

for line in lines:
print('address=/' + line.strip() + '/')
3 changes: 2 additions & 1 deletion scripts/domains_to_hosts.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@
text_file.close()

for line in lines:
print('0.0.0.0 ' + line.strip() + ' www.'+ line.strip())
print('0.0.0.0 ' + line.strip())
print('0.0.0.0 www.'+ line.strip())
3 changes: 2 additions & 1 deletion scripts/domains_to_hosts_ipv6.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@
text_file.close()

for line in lines:
print('::1 ' + line.strip() + ' www.'+ line.strip())
print('::1 ' + line.strip())
print('::1 www.'+ line.strip())
10 changes: 0 additions & 10 deletions scripts/domains_to_regex.py

This file was deleted.

5 changes: 3 additions & 2 deletions scripts/update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
find ./sources -type f -name "*.txt" -exec sed -i 's/^www\.//i' {} \;
## Remove duplicates from each source file. (TO DO: keep "duplicate" line jumps and comments)
find ./sources -type f -name "*.txt" -exec bash -c '
cat -n "$0" | sort -uk2 | sort -nk1 | cut -f2- > "$0_temp.txt";
awk "!NF || !seen[\$0]++" "$0" > "$0_temp.txt";
mv "$0_temp.txt" "$0";
' {} \;

Expand All @@ -26,8 +26,9 @@ mv domains_temp.txt domains.txt
# Generate blocklists:
## From the domain list.
python scripts/domains_to_hosts.py > hosts.txt
cp hosts.txt etc_hosts.txt # Previous filename for PiHole installations still subscribed to the old url.
python scripts/domains_to_hosts_ipv6.py > hosts.txt.ipv6
python scripts/domains_to_regex.py > regex.txt
python scripts/domains_to_dnsmasq.py > dnsmasq.txt

## For browser extensions.
python scripts/domains_to_netsane.py > netsane.txt
Expand Down
22 changes: 22 additions & 0 deletions sources/Cults/Falun Gong.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ learnfalungong.in
learnfalungong.org.au
es-learnfalungong.com
faluninfo.net


# The Epoch Times
theepochtimes.com
epochtimes.com
Expand All @@ -42,16 +44,36 @@ theepochtimes.gr
epochtimes.co.kr
epochtimesbusiness.it
theepochtimes.es
falundafa.org
falundafa.hr
falundafa.ca
falundafa.at
falungong.rs
falungong.se
epochtimes.es
es.theepochtimes.com
kr.theepochtimes.com
subscribe.theepochtimes.com

# Shen Yun
shenyun.com
falundafa.org
falundafa.hr
falundafa.ca
falundafa.at
falungong.rs
falungong.se
shenyunperformingarts.org
shenyuncollections.com
shenyundancer.com

# Minghui
falundafa.org
falundafa.hr
falundafa.ca
falundafa.at
falungong.rs
falungong.se
minghui.org
mhpublishing.org
tiantibooks.org
Expand Down

0 comments on commit 2af6aa4

Please sign in to comment.