This commit is contained in:
paldier 2019-01-15 02:21:05 +08:00
parent 75d8745af9
commit 1635282827
13 changed files with 188202 additions and 0 deletions

10004
maintain_files/Routing.txt Normal file

File diff suppressed because it is too large Load Diff

52733
maintain_files/WhiteList.txt Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,88 @@
#!/usr/bin/env python
#coding=utf-8
#
# Generate a list of dnsmasq rules with ipset for gfwlist
#
# Copyright (C) 2014 http://www.shuyz.com
# Ref https://code.google.com/p/autoproxy-gfwlist/wiki/Rules
import sys
import urllib2
import re
import os
import datetime
import base64
#import shutil
#mydnsip = '127.0.0.1'
#mydnsport = '1053'
if len(sys.argv) != 2:
print("fwlist.py outfile.txt")
sys.exit(-1)
outfile = sys.argv[1]
# the url of gfwlist
baseurl = 'https://raw.githubusercontent.com/gfwlist/gfwlist/master/gfwlist.txt'
# baseurl = 'https://autoproxy-gfwlist.googlecode.com/svn/trunk/gfwlist.txt'
# match comments/title/whitelist/ip address
comment_pattern = '^\!|\[|^@@|^\d+\.\d+\.\d+\.\d+'
domain_pattern = '([\w\-\_]+\.[\w\.\-\_]+)[\/\*]*'
tmpfile = '/tmp/gfwlisttmp'
# do not write to router internal flash directly
#outfile = '/tmp/gfwlist.conf'
#rulesfile = '/etc/dnsmasq.d/gfwlist.conf'
fs = file(outfile, 'w')
#fs.write('# gfw list ipset rules for dnsmasq\n')
#fs.write('# updated on ' + datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S") + '\n')
#fs.write('#\n')
print 'fetching list...'
content = urllib2.urlopen(baseurl, timeout=15).read().decode('base64')
# write the decoded content to file then read line by line
tfs = open(tmpfile, 'w')
tfs.write(content)
tfs.close()
tfs = open(tmpfile, 'r')
print 'page content fetched, analysis...'
# remember all blocked domains, in case of duplicate records
domainlist = []
for line in tfs.readlines():
if re.findall(comment_pattern, line):
#print 'this is a comment line: ' + line
#fs.write('#' + line)
pass
else:
domain = re.findall(domain_pattern, line)
if domain:
try:
found = domainlist.index(domain[0])
#print domain[0] + ' exists.'
except ValueError:
#print 'saving ' + domain[0]
domainlist.append(domain[0])
#fs.write('server=/.%s/%s#%s\n'%(domain[0],mydnsip,mydnsport))
#fs.write('ipset=/.%s/gfwlist\n'%domain[0])
fs.write('%s\n'%domain[0])
else:
#print 'no valid domain in this line: ' + line
pass
tfs.close()
fs.close();
#print 'moving generated file to dnsmasg directory'
#print outfile
#shutil.move(outfile, rulesfile)
#print 'restart dnsmasq...'
#print os.popen('/etc/init.d/dnsmasq restart').read()
print 'saving to file: ', outfile
print 'done!'

View File

@ -0,0 +1,83 @@
services.googleapis.cn
google.com.ao
google.com.bw
google.com.ck
google.com.cr
google.com.id
google.com.il
google.com.in
google.com.jp
google.com.ke
google.com.kr
google.com.ls
google.com.ma
google.com.mz
google.com.nz
google.com.th
google.com.tz
google.com.ug
google.com.uk
google.com.uz
google.com.ve
google.com.vi
google.com.za
google.com.zm
google.com.zw
google.com.af
google.com.ag
google.com.ai
google.com.ar
google.com.au
google.com.bd
google.com.bh
google.com.bn
google.com.bo
google.com.br
google.com.bz
google.com.cu
google.com.cy
google.com.do
google.com.ec
google.com.eg
google.com.et
google.com.fj
google.com.gh
google.com.gi
google.com.gt
google.com.hk
google.com.jm
google.com.kh
google.com.kw
google.com.lb
google.com.ly
google.com.mm
google.com.mt
google.com.mx
google.com.my
google.com.na
google.com.nf
google.com.ng
google.com.ni
google.com.np
google.com.om
google.com.pa
google.com.pe
google.com.pg
google.com.ph
google.com.pk
google.com.pr
google.com.py
google.com.qa
google.com.sa
google.com.sb
google.com.sg
google.com.sl
google.com.sv
google.com.tj
google.com.tr
google.com.ua
google.com.uy
google.com.vc
google.com.vn
google.com.it
google.co.th

View File

@ -0,0 +1,160 @@
#!/bin/sh
CurrentDate=`date +%Y-%m-%d`
# ======================================
# get gfwlist for shadowsocks ipset mode
./fwlist.py gfwlist_download.conf
if [ -f "gfwlist_download.conf" ];then
cat gfwlist_download.conf gfwlist_koolshare.conf | grep -Ev "([0-9]{1,3}[\.]){3}[0-9]{1,3}" | sed "s/^/server=&\/./g" | sed "s/$/\/127.0.0.1#7913/g" > gfwlist_merge.conf
cat gfwlist_download.conf gfwlist_koolshare.conf | sed "s/^/ipset=&\/./g" | sed "s/$/\/gfwlist/g" >> gfwlist_merge.conf
fi
sort -k 2 -t. -u gfwlist_merge.conf > gfwlist1.conf
rm gfwlist_merge.conf
# delete site below
sed -i '/m-team/d' "gfwlist1.conf"
sed -i '/windowsupdate/d' "gfwlist1.conf"
sed -i '/v2ex/d' "gfwlist1.conf"
md5sum1=$(md5sum gfwlist1.conf | sed 's/ /\n/g'| sed -n 1p)
md5sum2=$(md5sum ../gfwlist.conf | sed 's/ /\n/g'| sed -n 1p)
echo =================
if [ "$md5sum1"x = "$md5sum2"x ];then
echo gfwlist same md5!
else
echo update gfwlist!
cp -f gfwlist1.conf ../gfwlist.conf
sed -i "1c `date +%Y-%m-%d` # $md5sum1 gfwlist" ../version1
fi
echo =================
# ======================================
# get chnroute for shadowsocks chn and game mode
wget -4 -O- http://ftp.apnic.net/apnic/stats/apnic/delegated-apnic-latest > apnic.txt
cat apnic.txt| awk -F\| '/CN\|ipv4/ { printf("%s/%d\n", $4, 32-log($5)/log(2)) }' > chnroute1.txt
md5sum3=$(md5sum chnroute1.txt | sed 's/ /\n/g'| sed -n 1p)
md5sum4=$(md5sum ../chnroute.txt | sed 's/ /\n/g'| sed -n 1p)
echo =================
if [ "$md5sum3"x = "$md5sum4"x ];then
echo chnroute same md5!
else
echo update chnroute!
cp -f chnroute1.txt ../chnroute.txt
sed -i "2c `date +%Y-%m-%d` # $md5sum3 chnroute" ../version1
fi
echo =================
# ======================================
# get cdn list for shadowsocks chn and game mode
wget -4 https://raw.githubusercontent.com/felixonmars/dnsmasq-china-list/master/accelerated-domains.china.conf
cat accelerated-domains.china.conf | sed '/^#/d' |sed "s/server=\/\.//g" | sed "s/server=\///g" | sed -r "s/\/\S{1,30}//g" | sed -r "s/\/\S{1,30}//g" > cdn_download.txt
cat cdn_koolshare.txt cdn_download.txt | sort -u > cdn1.txt
md5sum5=$(md5sum cdn1.txt | sed 's/ /\n/g'| sed -n 1p)
md5sum6=$(md5sum ../cdn.txt | sed 's/ /\n/g'| sed -n 1p)
echo =================
if [ "$md5sum5"x = "$md5sum6"x ];then
echo cdn list same md5!
else
echo update cdn!
cp -f cdn1.txt ../cdn.txt
sed -i "4c `date +%Y-%m-%d` # $md5sum5 cdn" ../version1
fi
echo =================
# ======================================
echo -e "[Local Routing]\n## China mainland routing blocks\n## Sources: https://ftp.apnic.net/apnic/stats/apnic/delegated-apnic-latest" > Routing.txt
echo -n "## Last update: " >> Routing.txt
echo $CurrentDate >> Routing.txt
echo -e "\n" >> Routing.txt
# IPv4
echo "## IPv4" >> Routing.txt
cat apnic.txt | grep ipv4 | grep CN | awk -F\| '{printf("%s/%d\n", $4, 32-log($5)/log(2))}' >> Routing.txt
echo "\n" >> Routing.txt
# IPv6
echo "## IPv6" >> Routing.txt
cat apnic.txt | grep ipv6 | grep CN | awk -F\| '{printf("%s/%d\n", $4, $5)}' >> Routing.txt
[ ! -f "../Routing.txt" ] && cp Routing.txt ..
md5sum9=$(md5sum Routing.txt | sed 's/ /\n/g'| sed -n 1p)
md5sum10=$(md5sum ../Routing.txt | sed 's/ /\n/g'| sed -n 1p)
echo =================
if [ "$md5sum9"x = "$md5sum10"x ];then
echo Routing same md5!
else
echo update Routing!
cp Routing.txt ..
sed -i "5c `date +%Y-%m-%d` # $md5sum9 Routing" ../version1
fi
echo =================
# ======================================
sed 's|/114.114.114.114$||' accelerated-domains.china.conf > WhiteList_tmp.txt
sed -i 's|\(\.\)|\\\1|g' WhiteList_tmp.txt
sed -i 's|server=/|.*\\\b|' WhiteList_tmp.txt
sed -i 's|b\(cn\)$|\.\1|' WhiteList_tmp.txt
echo '[Local Hosts]' >> WhiteList.txt
echo '## China mainland domains' >> WhiteList.txt
echo '## Get the latest database: https://github.com/xinhugo/Free-List/blob/master/WhiteList.txt' >> WhiteList.txt
echo '## Report an issue: https://github.com/xinhugo/Free-List/issues' >> WhiteList.txt
echo "## Last update: $DATE\n" >> WhiteList.txt
cat WhiteList_tmp.txt >> WhiteList.txt
[ ! -f "../WhiteList.txt" ] && mv WhiteList_tmp.txt >> WhiteList.txt
md5sum7=$(md5sum WhiteList.txt | sed 's/ /\n/g'| sed -n 1p)
md5sum8=$(md5sum ../WhiteList.txt | sed 's/ /\n/g'| sed -n 1p)
echo =================
if [ "$md5sum7"x = "$md5sum8"x ];then
echo WhiteList same md5!
else
echo update WhiteList!
cp -f WhiteList.txt ../WhiteList.txt
sed -i "6c `date +%Y-%m-%d` # $md5sum7 WhiteList" ../version1
fi
echo =================
# ======================================
echo -e "[Local Hosts]\n## China mainland domains\n## Source: https://github.com/felixonmars/dnsmasq-china-list" > WhiteList_new.txt
echo -n "## Last update: " >> WhiteList_new.txt
echo $CurrentDate >> WhiteList_new.txt
echo -e "\n" >> WhiteList_new.txt
sed -e "s|114.114.114.114$||" -e "s|^s|S|" accelerated-domains.china.conf >> WhiteList_new.txt
# Download domain data of Google in Mainland China part.
curl -O https://raw.githubusercontent.com/felixonmars/dnsmasq-china-list/master/google.china.conf
sed -e "s|114.114.114.114$||" -e "s|^s|S|" google.china.conf >> WhiteList_new.txt
# Download domain data of Apple in Mainland China part.
curl -O https://raw.githubusercontent.com/felixonmars/dnsmasq-china-list/master/apple.china.conf
sed -e "s|114.114.114.114$||" -e "s|^s|S|" apple.china.conf >> WhiteList_new.txt
# ok
[ ! -f "../WhiteList_new.txt" ] && cp WhiteList_new.txt ..
md5sum11=$(md5sum WhiteList_new.txt | sed 's/ /\n/g'| sed -n 1p)
md5sum12=$(md5sum ../WhiteList_new.txt | sed 's/ /\n/g'| sed -n 1p)
echo =================
if [ "$md5sum11"x = "$md5sum12"x ];then
echo WhiteList_new same md5!
else
echo update WhiteList_new!
cp WhiteList_new.txt ..
sed -i "7c `date +%Y-%m-%d` # $md5sum11 WhiteList_new" ../version1
fi
echo =================
# ======================================
rm -rf google.china.conf
rm -rf apple.china.conf
rm gfwlist1.conf gfwlist_download.conf chnroute1.txt
rm cdn1.txt accelerated-domains.china.conf cdn_download.txt
rm WhiteList.txt WhiteList_tmp.txt apnic.txt WhiteList_new.txt Routing.txt

52726
maintain_files/cdn.txt Normal file

File diff suppressed because it is too large Load Diff

8325
maintain_files/chnroute.txt Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,148 @@
#!/bin/sh
# 1 gfwlist.conf
if type md5sum >/dev/null 2>&1; then
md5sum1=`md5sum gfwlist.conf|tr " " "\n"|sed -n 1p`
oldmd5sum1=`cat version1 | sed -n 1p | tr " " "\n" | sed -n 3p`
if [ "$md5sum1"x = "$oldmd5sum1"x ];then
echo 'gfwlist not changed'
else
echo 'update gfwlist!'
sed -i "1c `date +%Y-%m-%d` # $md5sum1 gfwlist" version1
fi
else
md5sum1=`md5 gfwlist.conf|tr " " "\n"|sed -n 4p`
oldmd5sum1=`cat version1 | sed -n 1p | tr " " "\n" | sed -n 3p`
if [ "$md5sum1"x = "$oldmd5sum1"x ];then
echo 'gfwlist not changed'
else
echo 'update gfwlist!'
gsed -i "1c `date +%Y-%m-%d` # $md5sum1 gfwlist" version1
fi
fi
# 2 chnroute.txt
if type md5sum >/dev/null 2>&1; then
md5sum2=`md5sum chnroute.txt|tr " " "\n"|sed -n 1p`
oldmd5sum2=`cat version1 | sed -n 2p | tr " " "\n" | sed -n 3p`
if [ "$md5sum2"x = "$oldmd5sum2"x ];then
echo 'chnroute not changed'
else
echo 'update chnroute!'
sed -i "2c `date +%Y-%m-%d` # $md5sum2 chnroute" version1
fi
else
md5sum2=`md5 chnroute.txt|tr " " "\n"|sed -n 4p`
oldmd5sum2=`cat version1 | sed -n 2p | tr " " "\n" | sed -n 3p`
if [ "$md5sum2"x = "$oldmd5sum2"x ];then
echo 'chnroute not changed'
else
echo 'update chnroute!'
gsed -i "2c `date +%Y-%m-%d` # $md5sum2 chnroute" version1
fi
fi
# 3 adblock.conf
if type md5sum >/dev/null 2>&1; then
md5sum3=`md5sum adblock.conf|tr " " "\n"|sed -n 1p`
oldmd5sum3=`cat version1 | sed -n 3p | tr " " "\n" | sed -n 3p`
if [ "$md5sum3"x = "$oldmd5sum3"x ];then
echo 'adblock not changed'
else
echo 'update adblock!'
sed -i "3c `date +%Y-%m-%d` # $md5sum3 adblock" version1
fi
else
md5sum3=`md5 adblock.conf|tr " " "\n"|sed -n 4p`
oldmd5sum3=`cat version1 | sed -n 3p | tr " " "\n" | sed -n 3p`
if [ "$md5sum3"x = "$oldmd5sum3"x ];then
echo 'adblock not changed'
else
echo 'update adblock!'
gsed -i "3c `date +%Y-%m-%d` # $md5sum3 adblock" version1
fi
fi
# 4 cdn.txt
if type md5sum >/dev/null 2>&1; then
md5sum4=`md5sum cdn.txt|tr " " "\n"|sed -n 1p`
oldmd5sum4=`cat version1 | sed -n 4p | tr " " "\n" | sed -n 3p`
if [ "$md5sum4"x = "$oldmd5sum4"x ];then
echo 'cdn not changed'
else
echo 'update cdn!'
sed -i "4c `date +%Y-%m-%d` # $md5sum4 cdn" version1
fi
else
md5sum4=`md5 cdn.txt|tr " " "\n"|sed -n 4p`
oldmd5sum4=`cat version1 | sed -n 4p | tr " " "\n" | sed -n 3p`
if [ "$md5sum4"x = "$oldmd5sum4"x ];then
echo 'cdn not changed'
else
echo 'update cdn!'
gsed -i "4c `date +%Y-%m-%d` # $md5sum4 cdn" version1
fi
fi
# 5 Routing.txt
if type md5sum >/dev/null 2>&1; then
md5sum5=`md5sum Routing.txt|tr " " "\n"|sed -n 1p`
oldmd5sum5=`cat version1 | sed -n 5p | tr " " "\n" | sed -n 3p`
if [ "$md5sum5"x = "$oldmd5sum5"x ];then
echo 'Routing not changed'
else
echo 'update Routing!'
sed -i "5c `date +%Y-%m-%d` # $md5sum5 Routing" version1
fi
else
md5sum5=`md5 Routing.txt|tr " " "\n"|sed -n 4p`
oldmd5sum5=`cat version1 | sed -n 5p | tr " " "\n" | sed -n 3p`
if [ "$md5sum5"x = "$oldmd5sum5"x ];then
echo 'Routing not changed'
else
echo 'update Routing!'
gsed -i "5c `date +%Y-%m-%d` # $md5sum5 Routing" version1
fi
fi
# 6 WhiteList.txt
if type md5sum >/dev/null 2>&1; then
md5sum6=`md5sum WhiteList.txt|tr " " "\n"|sed -n 1p`
oldmd5sum6=`cat version1 | sed -n 6p | tr " " "\n" | sed -n 3p`
if [ "$md5sum6"x = "$oldmd5sum6"x ];then
echo 'WhiteList not changed'
else
echo 'update WhiteList!'
sed -i "6c `date +%Y-%m-%d` # $md5sum6 WhiteList" version1
fi
else
md5sum6=`md5 WhiteList.txt|tr " " "\n"|sed -n 4p`
oldmd5sum6=`cat version1 | sed -n 6p | tr " " "\n" | sed -n 3p`
if [ "$md5sum6"x = "$oldmd5sum6"x ];then
echo 'WhiteList not changed'
else
echo 'update WhiteList!'
gsed -i "6c `date +%Y-%m-%d` # $md5sum6 WhiteList" version1
fi
fi
# 7 WhiteList_new.txt
if type md5sum >/dev/null 2>&1; then
md5sum7=`md5sum WhiteList_new.txt|tr " " "\n"|sed -n 1p`
oldmd5sum7=`cat version1 | sed -n 7p | tr " " "\n" | sed -n 3p`
if [ "$md5sum7"x = "$oldmd5sum7"x ];then
echo 'WhiteList_new not changed'
else
echo 'update WhiteList_new!'
sed -i "7c `date +%Y-%m-%d` # $md5sum7 WhiteList_new" version1
fi
else
md5sum7=`md5 WhiteList_new.txt|tr " " "\n"|sed -n 4p`
oldmd5sum7=`cat version1 | sed -n 7p | tr " " "\n" | sed -n 3p`
if [ "$md5sum7"x = "$oldmd5sum7"x ];then
echo 'WhiteList_new not changed'
else
echo 'update WhiteList_new!'
gsed -i "7c `date +%Y-%m-%d` # $md5sum7 WhiteList_new" version1
fi
fi

11000
maintain_files/gfwlist.conf Normal file

File diff suppressed because it is too large Load Diff

0
maintain_files/version1 Normal file
View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 KiB

View File

@ -0,0 +1,77 @@
var $j = jQuery.noConflict();
var $G = function (id) {
return document.getElementById(id);
};
function done_validating() {
return true;
}
String.prototype.replaceAll = function(s1,s2){
  return this.replace(new RegExp(s1,"gm"),s2);
}
//跨域请求支持
$j.ajax = (function(_ajax){
var protocol = location.protocol,
hostname = location.hostname,
exRegex = RegExp(protocol + '//' + hostname),
YQL = 'http' + (/^https/.test(protocol)?'s':'') + '://query.yahooapis.com/v1/public/yql?callback=?',
query = 'select * from html where url="{URL}" and xpath="*"';
function isExternal(url) {
return !exRegex.test(url) && /:\/\//.test(url);
}
return function(o) {
var url = o.url;
if ( /get/i.test(o.type) && !/json/i.test(o.dataType) && isExternal(url) ) {
// Manipulate options so that JSONP-x request is made to YQL
o.url = YQL;
o.dataType = 'json';
o.data = {
q: query.replace(
'{URL}',
url + (o.data ?
(/\?/.test(url) ? '&' : '?') + jQuery.param(o.data)
: '')
),
format: 'xml'
};
// Since it's a JSONP request
// complete === success
if (!o.success && o.complete) {
o.success = o.complete;
delete o.complete;
}
o.success = (function(_success){
return function(data) {
if (_success) {
// Fake XHR callback.
_success.call(this, {
responseText: (data.results[0] || '')
// YQL screws with <script>s
// Get rid of them
.replace(/<script[^>]+?\/>|<script(.|\s)*?\/script>/gi, '')
}, 'success');
}
};
})(o.success);
}
return _ajax.apply(this, arguments);
};
})($j.ajax);