forked from samzong/gfwlist2privoxy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgfwlist2privoxy
39 lines (26 loc) · 1.26 KB
/
gfwlist2privoxy
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
38
39
#!/bin/bash
echo -n 'proxy(socks5): '
read proxy
tee gfw.action << EOF
{+forward-override{forward-socks5 $proxy .}}
EOF
curl -sL https://raw.githubusercontent.com/gfwlist/gfwlist/master/gfwlist.txt | base64 -d > gfwlist.txt
cat gfwlist.txt | \
egrep -v '^!|^$|^@@|^\[' | \
sed -r 's@^\|\|([^\|].*)@\1@g' | \
sed -r 's@^\|\w+://(.*)@\1@g' \
> gfwlist_clean
cat gfwlist_clean | egrep '^\/' > gfwlist_regexp
cat gfwlist_clean | egrep '^[^\/]+\/.*(\*|\?).*' > gfwlist_uri_glob
cat gfwlist_clean | egrep -v -e '^\/' -e '^[^\/]+\/.*(\*|\?).*' > gfwlist_normal
cat gfwlist_uri_glob | sed -r 's@\*@\.\*@g;s@\?@\.@g' >> gfw.action
cat gfwlist_normal >> gfw.action
echo -e '.blogspot.\n.google.\ntwimg.edgesuite.net//?appledaily' >> gfw.action
# echo -e '\n============================================================\n'
# echo -e 'Add the following output address to gfw.action please.\nIt need to convert to privoxy format, see privoxy document: https://www.privoxy.org/user-manual/actions-file.html#AF-PATTERNS\n'
# echo -e "file: `pwd`/gfwlist_regexp\n"
# cat gfwlist_regexp
rm -fr gfwlist.txt gfwlist_clean gfwlist_regexp gfwlist_normal gfwlist_uri_glob
echo -e '\n=================================================================\n'
echo -e \"cp -af `pwd`/gfw.action /etc/privoxy/\"
echo ''