Merge branch 'master' into dev

# Conflicts:
#	adblock-for-dnsmasq.conf
#	anti-ad-domains.txt
#	anti-ad-easylist.txt
#	anti-ad-surge.txt
This commit is contained in:
gently 2020-02-13 17:23:12 +08:00
commit d096415e77
6 changed files with 48 additions and 21 deletions

View File

@ -1,6 +1,7 @@
#VER=20200212032819
#TITLE=anti-AD
#VER=20200213025631
#URL=https://github.com/privacy-protection-tools/anti-AD
#TOTAL_COUNT=31352
#TOTAL_LINES=31352
address=/0024aaaa.com/
address=/0026645142c89aeb1.com/
address=/003store.com/

View File

@ -1,6 +1,7 @@
#VER=20200212032819
#TITLE=anti-AD
#VER=20200213025631
#URL=https://github.com/privacy-protection-tools/anti-AD
#TOTAL_COUNT=35807
#TOTAL_LINES=35807
0024aaaa.com
0026645142c89aeb1.com
003store.com

View File

@ -1,6 +1,7 @@
!AdBlock-style blocklists
!VER=20200212032819
!TITLE=anti-AD
!VER=20200213091608
!URL=https://github.com/privacy-protection-tools/anti-AD
!TOTAL_LINES=30093
||201*.myhard.com^
||8*.tianya.cn^
||a*.chajiaotong.com^
@ -211,7 +212,7 @@
||0xxd.com^
||0z5jn.cn^
||1-cl0ud.com^
/^[1-3]\.[0-9a-z\.\-]+\.(com|cn|net|org|cc|me)$/
/^[1-2]\.[0-9a-z\.\-]+\.(com|cn|net|cc|me)$/
||92caijing.com^
||as1.m.hao123.com^
||mini.hao123.com^
@ -531,7 +532,10 @@
||2xbpub.com^
||2zfzly.com^
||2zm4.cn^
||3.chuanyi5.com^
||3.guidaye.com^
||ff.guidaye.com^
||3.ssqzj.com^
||301848.com^
||303marketplace.com^
||304c40d20085e.com^
@ -30087,3 +30091,7 @@
@@||tongji.*kuwo.cn^
@@||ntp.org^
@@||*push-apple.com.akadns.net^
@@||tracking.epicgames.com^
@@||tracker.eu.org^
@@||1.itzmx.com^
@@||stats.uptimerobot.com^

View File

@ -1,6 +1,7 @@
#VER=20200212032819
#TITLE=anti-AD
#VER=20200213025631
#URL=https://github.com/privacy-protection-tools/anti-AD
#TOTAL_COUNT=31352
#TOTAL_LINES=31352
DOMAIN-SUFFIX,0024aaaa.com
DOMAIN-SUFFIX,0026645142c89aeb1.com
DOMAIN-SUFFIX,003store.com

View File

@ -11,7 +11,7 @@ class writerFormat{
/*dnsmasq支持格式的屏蔽广告列表*/
const DNSMASQ = array(
'format' => 'address=/{DOMAIN}/',
'header' => "#VER={DATE}\n#URL={URL}\n#TOTAL_COUNT={COUNT}\n",
'header' => "#TITLE=anti-AD\n#VER={DATE}\n#URL={URL}\n#TOTAL_LINES={COUNT}\n",
'full_domain' => 0,
'name' => 'dnsmasq',
'filename' => 'adblock-for-dnsmasq.conf',
@ -39,7 +39,7 @@ class writerFormat{
/*easylist 兼容格式的屏蔽广告列表*/
const EASYLIST = array(
'format' => '||{DOMAIN}^',
'header' => "!AdBlock-style blocklists\n!VER={DATE}\n!URL={URL}\n",
'header' => "!TITLE=anti-AD\n!VER={DATE}\n!URL={URL}\n!TOTAL_LINES=00000\n",
'full_domain' => 0,
'name' => 'easylist',
'filename' => 'anti-ad-easylist.txt',
@ -67,7 +67,7 @@ class writerFormat{
/*Surge 兼容格式的屏蔽广告列表*/
const SURGE = array(
'format' => 'DOMAIN-SUFFIX,{DOMAIN}',
'header' => "#VER={DATE}\n#URL={URL}\n#TOTAL_COUNT={COUNT}\n",
'header' => "#TITLE=anti-AD\n#VER={DATE}\n#URL={URL}\n#TOTAL_LINES={COUNT}\n",
'full_domain' => 0,
'name' => 'surge',
'filename' => 'anti-ad-surge.txt',
@ -95,7 +95,7 @@ class writerFormat{
/*Domains 格式的屏蔽广告列表用于支持pi-hole等*/
const DOMAINS = array(
'format' => '{DOMAIN}',
'header' => "#VER={DATE}\n#URL={URL}\n#TOTAL_COUNT={COUNT}\n",
'header' => "#TITLE=anti-AD\n#VER={DATE}\n#URL={URL}\n#TOTAL_LINES={COUNT}\n",
'full_domain' => 1, //保留子域名,即使其上级域名
'name' => 'domains',
'filename' => 'anti-ad-domains.txt',

View File

@ -70,7 +70,7 @@ $ARR_MERGED_WILD_LIST = array(
$ARR_REGEX_LIST = array(
'/01daa\.[a-z]+\.com$/' => null,
'/9377[a-z]{2}\.com$/' => null,
'/^[1-3]\.[0-9a-z\.\-]+\.(com|cn|net|org|cc|me)$/' => null,
'/^[1-2]\.[0-9a-z\.\-]+\.(com|cn|net|cc|me)$/' => null,
// '/^a1\.[0-9a-z\.]+\.(com|cn|org|net|me)$/' => null,
'/^ad([0-9]|m|s)?\./' => null,
'/^([a-z0-9\-\.]+\.)?affiliat(es|ion|e)\./' => null,
@ -90,9 +90,12 @@ $ARR_REGEX_LIST = array(
//对通配符匹配或正则匹配增加的额外赦免规则
$ARR_WHITE_RULE_LIST = array(
'@@||tongji.*kuwo.cn^' => 0,
'@@||ntp.org^' => 1, //针对上面正则表达式的一个赦免规则例如2.android.pool.ntp.org
'@@||ntp.org^' => 1, //强制加白,针对上面正则表达式的一个赦免规则例如2.android.pool.ntp.org
'@@||*push-apple.com.akadns.net^' => 1, //强制加白, 苹果推送2.courier-push-apple.com.akadns.net
'@@||tracking.epicgames.com' => 0,
'@@||tracking.epicgames.com^' => 0,
'@@||tracker.eu.org^' => 1, //强制加白BT tracker有形如2.tracker.eu.org的域
'@@||1.itzmx.com^' => 0, //PT tracker
'@@||stats.uptimerobot.com^' => 0, //uptimerobot监测相关
);
//针对上游赦免规则anti-AD不予赦免的规则即赦免名单的黑名单
@ -162,15 +165,19 @@ while(!feof($wild_fp)){
fclose($wild_fp);
$arr_wild_src = array_merge($arr_wild_src, $ARR_MERGED_WILD_LIST);
$insert_pos = $written_size = $line_count = 0;
while(!feof($src_fp)){
$row = fgets($src_fp, 512);
if(empty($row)){
continue;
}
if(($row{0} === '!') && (substr($row, 0, 13) === '!TOTAL_LINES=')){
$insert_pos = $written_size;
}
if(!preg_match('/^\|.+?/', $row)){
fwrite($new_fp, $row);
$written_size += fwrite($new_fp, $row);
continue;
}
@ -179,7 +186,8 @@ while(!feof($src_fp)){
if(preg_match($regex_str, substr(trim($row), 2, -1))){
$matched = true;
if(!array_key_exists($regex_str, $wrote_wild)){
fwrite($new_fp, "${regex_str}\n");
$written_size += fwrite($new_fp, "${regex_str}\n");
$line_count++;
$wrote_wild[$regex_str] = 1;
}
}
@ -192,7 +200,8 @@ while(!feof($src_fp)){
foreach($arr_wild_src as $core_str => $wild_row){
$match_rule = str_replace('*', '.*', $core_str);
if(!array_key_exists($core_str, $wrote_wild)){
fwrite($new_fp, "||${core_str}^\n");
$written_size += fwrite($new_fp, "||${core_str}^\n");
$line_count++;
$wrote_wild[$core_str] = 1;
}
if(preg_match("/\|${match_rule}/", $row)){
@ -204,7 +213,8 @@ while(!feof($src_fp)){
if($matched){
continue;
}
fwrite($new_fp, $row);
$written_size += fwrite($new_fp, $row);
$line_count++;
}
//按需写入白名单规则
@ -227,6 +237,7 @@ foreach($ARR_WHITE_RULE_LIST as $row => $v){
if($v === 1){
$wrote_whitelist[$matches[1]] = null;
fwrite($new_fp, "@@||${matches[1]}^\n");
$line_count++;
continue;
}
@ -249,10 +260,15 @@ foreach($ARR_WHITE_RULE_LIST as $row => $v){
}
$wrote_whitelist[$matches[1]] = null;
fwrite($new_fp, "@@||${matches[1]}^\n");
$line_count++;
}
}
}
if(($insert_pos > 0) && (fseek($new_fp, $insert_pos) === 0)){
fwrite($new_fp, "!TOTAL_LINES={$line_count}\n");
}
fclose($src_fp);
fclose($new_fp);
rename($src_file . '.txt', $src_file);