-
Notifications
You must be signed in to change notification settings - Fork 1
/
doh-update.sh
37 lines (32 loc) · 1.15 KB
/
doh-update.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/bin/bash
# Define the file path for the DNS-over-HTTPS markdown file
FILE="curl.wiki/DNS-over-HTTPS.md"
# Check if the file exists and is readable
if [ ! -r "$FILE" ]; then
echo "Error: File $FILE not found or not readable."
exit 1
fi
# Get the current date for the "Last modified" entry
CURRENT_DATE=$(date +"%Y-%m-%d %H:%M:%S")
# Extract only URLs from the "Base URL" column of the table
CONTENT=$(awk '
BEGIN { capture = 0; }
/^# Publicly available servers/ { capture = 1; }
/^# Private DNS Server with DoH setup examples/ { capture = 0; exit; }
capture && /^\|/ {
split($0, columns, "|");
print columns[3];
}
' "$FILE" | grep -o 'https://[a-zA-Z0-9./?=_%:-]*')
# Generate the doh-list.txt file with the header
{
echo "! Title: DoH DNS Block Filter"
echo "! Description: Filter to block the public available DoH servers."
echo "! Homepage: https://github.com/MohamedElashri/doh-list"
echo "! License: https://github.com/MohamedElashri/doh-list/blob/master/LICENSE"
echo "! Last modified: $CURRENT_DATE"
echo "#"
echo "# Full URLs of DoH services:"
echo "#"
echo "$CONTENT"
} > doh-list.txt