mirror of
https://github.com/privacy-protection-tools/anti-AD.git
synced 2025-02-02 19:53:02 +08:00
3.0版本合并分支
This commit is contained in:
commit
dbcb8de232
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,3 +1,4 @@
|
|||||||
|
|
||||||
optimize-dns.conf
|
optimize-dns.conf
|
||||||
|
.gitignore
|
||||||
.idea/
|
.idea/
|
@ -80,6 +80,8 @@ return array( 'cnzz.com' => array('cnzz.com'),
|
|||||||
'cruisingsmallship.com' => array('.cruisingsmallship.com', 'cruisingsmallship.com'),
|
'cruisingsmallship.com' => array('.cruisingsmallship.com', 'cruisingsmallship.com'),
|
||||||
'frost-electric-supply.com' => array('.frost-electric-supply.com', 'frost-electric-supply.com'),
|
'frost-electric-supply.com' => array('.frost-electric-supply.com', 'frost-electric-supply.com'),
|
||||||
'iptvdeals.com' => array('iptvdeals.com'),
|
'iptvdeals.com' => array('iptvdeals.com'),
|
||||||
|
'baidu.com' => array('tuisong.baidu.com'),
|
||||||
|
'youdao.com' => array('corp.youdao.com'),
|
||||||
'crsspxl.com' => array('crsspxl.com'),
|
'crsspxl.com' => array('crsspxl.com'),
|
||||||
|
|
||||||
'011211.cn' => array('.011211.cn'),
|
'011211.cn' => array('.011211.cn'),
|
||||||
|
@ -4,6 +4,8 @@
|
|||||||
|
|
||||||
set_time_limit(600);
|
set_time_limit(600);
|
||||||
|
|
||||||
|
error_reporting(0);
|
||||||
|
|
||||||
if(PHP_SAPI != 'cli'){
|
if(PHP_SAPI != 'cli'){
|
||||||
die('nothing.');
|
die('nothing.');
|
||||||
}
|
}
|
||||||
@ -16,28 +18,22 @@ $arr_result = array();
|
|||||||
|
|
||||||
|
|
||||||
$easylist1 = file_get_contents('./easylistchina+easylist.txt');
|
$easylist1 = file_get_contents('./easylistchina+easylist.txt');
|
||||||
|
|
||||||
$arr_result = array_merge_recursive($arr_result, makeAddr::get_domain_from_easylist($easylist1));
|
$arr_result = array_merge_recursive($arr_result, makeAddr::get_domain_from_easylist($easylist1));
|
||||||
|
|
||||||
$easylist2 = file_get_contents('./cjx-annoyance.txt');
|
$easylist2 = file_get_contents('./cjx-annoyance.txt');
|
||||||
|
|
||||||
$arr_result = array_merge_recursive($arr_result, makeAddr::get_domain_from_easylist($easylist2));
|
$arr_result = array_merge_recursive($arr_result, makeAddr::get_domain_from_easylist($easylist2));
|
||||||
|
|
||||||
|
$host1 = file_get_contents('./hosts1');
|
||||||
echo '开始下载host1....',"\n";
|
|
||||||
$host1 = makeAddr::http_get('https://hosts.nfz.moe/full/hosts');
|
|
||||||
$arr_result = array_merge_recursive($arr_result, makeAddr::get_domain_list($host1));
|
$arr_result = array_merge_recursive($arr_result, makeAddr::get_domain_list($host1));
|
||||||
|
|
||||||
echo '开始下载host2....',"\n";
|
|
||||||
// $host2 = makeAddr::http_get('http://www.malwaredomainlist.com/hostslist/hosts.txt');
|
// $host2 = makeAddr::http_get('http://www.malwaredomainlist.com/hostslist/hosts.txt');
|
||||||
$host2 = makeAddr::http_get('https://raw.githubusercontent.com/vokins/yhosts/master/hosts');
|
$host2 = file_get_contents('./hosts2');
|
||||||
$arr_result = array_merge_recursive($arr_result, makeAddr::get_domain_list($host2));
|
$arr_result = array_merge_recursive($arr_result, makeAddr::get_domain_list($host2));
|
||||||
|
|
||||||
|
$arr_result = array_merge_recursive($arr_result, $arr_blacklist);
|
||||||
|
|
||||||
$arr_result = array_merge($arr_result, $arr_blacklist);
|
echo 'Written file size:';
|
||||||
|
echo makeAddr::write_to_conf($arr_result, './adblock-for-dnsmasq.conf');
|
||||||
echo '写入文件大小:';
|
|
||||||
var_dump(makeAddr::write_to_conf($arr_result, './adblock-for-dnsmasq.conf'));
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -53,7 +49,7 @@ class makeAddr{
|
|||||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
||||||
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
|
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
|
||||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||||
curl_setopt($ch, CURLOPT_USERAGENT, 'T_T angent 2.0.5/' . phpversion());
|
curl_setopt($ch, CURLOPT_USERAGENT, '^_^ angent 2.2.5/' . phpversion());
|
||||||
$result = curl_exec($ch);
|
$result = curl_exec($ch);
|
||||||
$errno = curl_errno($ch);
|
$errno = curl_errno($ch);
|
||||||
curl_close($ch);
|
curl_close($ch);
|
||||||
@ -66,7 +62,7 @@ class makeAddr{
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
$str_reg = '/^[a-z0-9\-\.]*?([a-z0-9\-]+(\.com|\.cn|\.net|\.org|\.cn|\.me|\.co|\.info|\.cc|\.tv';
|
$str_reg = '/^(?:(?:[a-z0-9\-]+\.)*?|\.)?([a-z0-9\-]+(\.com|\.cn|\.net|\.org|\.cn|\.me|\.co|\.info|\.cc|\.tv';
|
||||||
$str_reg .= '|\.pw|\.biz|\.top|\.win|\.bid|\.cf|\.club|\.ne|\.de|\.la|\.us|\.mobi|\.hn|\.asia';
|
$str_reg .= '|\.pw|\.biz|\.top|\.win|\.bid|\.cf|\.club|\.ne|\.de|\.la|\.us|\.mobi|\.hn|\.asia';
|
||||||
$str_reg .= '|\.jp|\.tw|\.am|\.hk|\.site|\.live|\.xyz|\.space|\.fr|\.es|\.nl|\.au|\.in|\.ru';
|
$str_reg .= '|\.jp|\.tw|\.am|\.hk|\.site|\.live|\.xyz|\.space|\.fr|\.es|\.nl|\.au|\.in|\.ru';
|
||||||
$str_reg .= '|\.su|\.world|\.io|\.trade|\.bet|\.im|\.fm|\.today|\.wang|\.rocks|\.vip|\.eu|\.run';
|
$str_reg .= '|\.su|\.world|\.io|\.trade|\.bet|\.im|\.fm|\.today|\.wang|\.rocks|\.vip|\.eu|\.run';
|
||||||
@ -74,10 +70,12 @@ class makeAddr{
|
|||||||
$str_reg .= '|\.cl|\.tk|\.cz|\.hu|\.ro|\.vg|\.ws|\.nu|\.vn|\.lt|\.edu|\.lv|\.mx|\.by|\.gr|\.br|\.fi';
|
$str_reg .= '|\.cl|\.tk|\.cz|\.hu|\.ro|\.vg|\.ws|\.nu|\.vn|\.lt|\.edu|\.lv|\.mx|\.by|\.gr|\.br|\.fi';
|
||||||
$str_reg .= '|\.pt|\.dk|\.se|\.at|\.id|\.ve|\.ir|\.ma|\.ch|\.nf|\.bg|\.ua|\.is|\.hr|\.shop|\.xin|\.si|\.or';
|
$str_reg .= '|\.pt|\.dk|\.se|\.at|\.id|\.ve|\.ir|\.ma|\.ch|\.nf|\.bg|\.ua|\.is|\.hr|\.shop|\.xin|\.si|\.or';
|
||||||
$str_reg .= '|\.sk|\.kz|\.tt|\.so|\.gg|\.ms|\.ink|\.pro|\.work|\.click|\.link|\.ly|\.ai|\.tech|\.kr|\.to';
|
$str_reg .= '|\.sk|\.kz|\.tt|\.so|\.gg|\.ms|\.ink|\.pro|\.work|\.click|\.link|\.ly|\.ai|\.tech|\.kr|\.to';
|
||||||
$str_reg .= '|\.uk|\.ad|\.ac|\.md|\.ml|\.cm|\.re|\.ph|\.my';
|
$str_reg .= '|\.uk|\.ad|\.ac|\.md|\.ml|\.cm|\.re|\.ph|\.my|\.lu|\.network|\.sh|\.fun|\.az|\.cx|\.ga';
|
||||||
|
$str_reg .= '|\.ae|\.bz|\.gq|\.gs|\.pk|\.sex|\.stream|\.support|\.pub|\.nz|\.ng|\.zw|\.sx|\.studio|\.media|\.zone';
|
||||||
|
$str_reg .= '|\.icu|\.ie|\.li|\.bar|\.video|\.wiki|\.ltd|\.cash|\.pink|\.loan|\.gdn|\.app|\.ovh|\.land|\.st|\.how';
|
||||||
$str_reg .= ')';
|
$str_reg .= ')';
|
||||||
|
|
||||||
$str_reg .= '(\.cn|\.tw|\.uk|\.jp|\.kr|\.th|\.au|\.ua|\.so|\.br|\.sg|\.pt|\.ec|\.ar|\.my|\.tr|\.bd|\.mk|\.za|\.ng|\.nz)?)$/';
|
$str_reg .= '(\.cn|\.hk|\.tw|\.uk|\.jp|\.kr|\.th|\.au|\.ua|\.so|\.br|\.sg|\.pt|\.ec|\.ar|\.my|\.tr|\.bd|\.mk|\.za|\.mt)?)$/';
|
||||||
if(preg_match($str_reg, $str_domain,$matchs)){
|
if(preg_match($str_reg, $str_domain,$matchs)){
|
||||||
return strval($matchs[1]);
|
return strval($matchs[1]);
|
||||||
}
|
}
|
||||||
@ -111,7 +109,7 @@ class makeAddr{
|
|||||||
if(preg_match('/^\|\|([0-9a-z\-\.]+[a-z]+)[\^\$]*(image|third-party|script)?$/', $line, $matchs)){
|
if(preg_match('/^\|\|([0-9a-z\-\.]+[a-z]+)[\^\$]*(image|third-party|script)?$/', $line, $matchs)){
|
||||||
|
|
||||||
if(substr($matchs[1], 0, 4) == 'www.'){
|
if(substr($matchs[1], 0, 4) == 'www.'){
|
||||||
$row = substr($matchs[1], 3);
|
$row = substr($matchs[1], 4);
|
||||||
}else{
|
}else{
|
||||||
$row = $matchs[1];
|
$row = $matchs[1];
|
||||||
}
|
}
|
||||||
@ -163,22 +161,11 @@ class makeAddr{
|
|||||||
|
|
||||||
$fp = fopen($str_file, 'w');
|
$fp = fopen($str_file, 'w');
|
||||||
$write_len = fwrite($fp, '#TIME=' . date('YmdHis'). "\n");
|
$write_len = fwrite($fp, '#TIME=' . date('YmdHis'). "\n");
|
||||||
$write_len = fwrite($fp, '#URL=https://github.com/gentlyxu/anti-AD' . "\n");
|
$write_len += fwrite($fp, '#URL=https://github.com/gentlyxu/anti-AD' . "\n");
|
||||||
|
|
||||||
//集中塞入黑名单所有内容
|
|
||||||
foreach($GLOBALS['arr_blacklist'] as $bk => $bv){
|
|
||||||
if(in_array($bk, $bv) || in_array('.' . $bk , $bv)){
|
|
||||||
$write_len += fwrite($fp, 'address=/' . $bk . '/' . "\n");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach($bv as $bvv){
|
|
||||||
$write_len += fwrite($fp, 'address=/' . $bvv . '/' . "\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach($arr_result as $rk => $rv){
|
foreach($arr_result as $rk => $rv){
|
||||||
if(array_key_exists($rk, $GLOBALS['arr_blacklist'])){//黑名单操作
|
|
||||||
|
if(array_key_exists($rk, $GLOBALS['arr_whitelist'])){//主域名在白名单的,整个不写入屏蔽列表
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -187,13 +174,8 @@ class makeAddr{
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
//白名单机制,优先级低于黑名单,即某域名同时存在黑白名单中,那么它会在黑名单中生效
|
|
||||||
if(array_key_exists($rk, $GLOBALS['arr_whitelist'])){
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!is_array($rv)){
|
if(!is_array($rv)){
|
||||||
if(array_key_exists($rv, $GLOBALS['arr_whitelist'])){//白名单机制
|
if(array_key_exists($rv, $GLOBALS['arr_whitelist'])){//单个域名的白名单检查
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$write_len += fwrite($fp, 'address=/' . $rv . '/' . "\n");
|
$write_len += fwrite($fp, 'address=/' . $rv . '/' . "\n");
|
||||||
@ -202,15 +184,43 @@ class makeAddr{
|
|||||||
|
|
||||||
$rv = array_unique($rv);
|
$rv = array_unique($rv);
|
||||||
|
|
||||||
if(in_array('.' . $rk, $rv) || in_array('www.' . $rk, $rv)){
|
if(in_array('.' . $rk, $rv) || in_array('www.' . $rk, $rv) || in_array($rk, $rv)){
|
||||||
$write_len += fwrite($fp, 'address=/' . $rk . '/' . "\n");
|
$write_len += fwrite($fp, 'address=/' . $rk . '/' . "\n");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$arr_written = [];
|
||||||
foreach($rv as $rvv){
|
foreach($rv as $rvv){
|
||||||
if(array_key_exists($rvv, $GLOBALS['arr_whitelist'])){//白名单机制
|
if(array_key_exists($rvv, $GLOBALS['arr_whitelist'])){
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//合并三级域名逻辑
|
||||||
|
$tmp_arr1 = explode('.', $rvv);
|
||||||
|
$written_flag = false;
|
||||||
|
|
||||||
|
if(count($tmp_arr1) > 2){
|
||||||
|
for($tmp_pos = 3; $tmp_pos <= count($tmp_arr1); $tmp_pos++){
|
||||||
|
$tmp_arr2 = array_slice($tmp_arr1, -1 * $tmp_pos);
|
||||||
|
if(in_array(implode('.', $tmp_arr2), $rv)){
|
||||||
|
if(!in_array(implode('.', $tmp_arr2), $arr_written)){
|
||||||
|
$arr_written[] = implode('.', $tmp_arr2);
|
||||||
|
if(array_key_exists(implode('.', $tmp_arr2), $GLOBALS['arr_whitelist'])){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$write_len += fwrite($fp, 'address=/' . implode('.', $tmp_arr2) . '/' . "\n");
|
||||||
|
}
|
||||||
|
$written_flag = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(in_array($rvv, $arr_written) || $written_flag){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$arr_written[] = $rvv;
|
||||||
$write_len += fwrite($fp, 'address=/' . $rvv . '/' . "\n");
|
$write_len += fwrite($fp, 'address=/' . $rvv . '/' . "\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
22
start.sh
22
start.sh
@ -3,7 +3,6 @@
|
|||||||
source /etc/profile
|
source /etc/profile
|
||||||
|
|
||||||
cd $(cd "$(dirname "$0")";pwd)
|
cd $(cd "$(dirname "$0")";pwd)
|
||||||
echo pwd is: `pwd`
|
|
||||||
git pull
|
git pull
|
||||||
|
|
||||||
echo '开始下载 easylist1...'
|
echo '开始下载 easylist1...'
|
||||||
@ -22,9 +21,26 @@ if [ $? -ne 0 ];then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
/usr/local/php/bin/php make-addr.php
|
echo '开始下载 hosts1...'
|
||||||
|
wget -O hosts1 --timeout 30 https://hosts.nfz.moe/full/hosts
|
||||||
|
|
||||||
|
if [ $? -ne 0 ];then
|
||||||
|
echo '下载失败,请重试'
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo '开始下载 hosts2...'
|
||||||
|
wget -O hosts2 --timeout 60 https://raw.githubusercontent.com/vokins/yhosts/master/hosts
|
||||||
|
|
||||||
|
if [ $? -ne 0 ];then
|
||||||
|
echo '下载失败,请重试'
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
PHP_RET=$(/user/local/php/bin/php make-addr.php)
|
||||||
|
|
||||||
git add adblock-for-dnsmasq.conf
|
git add adblock-for-dnsmasq.conf
|
||||||
git commit -am "auto commit"
|
git commit -am "auto commit. script output--- $PHP_RET"
|
||||||
git push --force
|
git push --force
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
//white_domain_list
|
//white_domain_list
|
||||||
//白名单机制...
|
//白名单机制...,白名单是
|
||||||
//@date 2018年12月23日
|
//@date 2018年12月23日
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
@ -8,11 +8,9 @@ return array(
|
|||||||
'cdn-thumb.fds.api.xiaomi.com' => true,
|
'cdn-thumb.fds.api.xiaomi.com' => true,
|
||||||
'.cdn-thumb.fds.api.xiaomi.com' => true,
|
'.cdn-thumb.fds.api.xiaomi.com' => true,
|
||||||
'bce.baidu.com' => true,
|
'bce.baidu.com' => true,
|
||||||
'.bce.baidu.com' => true,
|
|
||||||
'b.bdstatic.com' => true,
|
'b.bdstatic.com' => true,
|
||||||
'googleadapis.l.google.com' => true,
|
'googleadapis.l.google.com' => true, //解决google字体下载异常
|
||||||
'.googleadapis.l.google.com' => true,
|
'gstaticadssl.l.google.com' => true, //解决google字体下载异常
|
||||||
'gstaticadssl.l.google.com' => true,
|
|
||||||
'gvt1.com' => true,
|
'gvt1.com' => true,
|
||||||
'wangbase.com' => true,
|
'wangbase.com' => true,
|
||||||
'l.qq.com' => true, //解决腾讯视频无法播放
|
'l.qq.com' => true, //解决腾讯视频无法播放
|
||||||
|
Loading…
Reference in New Issue
Block a user