From a98b29b5627a5057658abd51331f705c36f24ed3 Mon Sep 17 00:00:00 2001 From: Loyalsoldier <10487845+Loyalsoldier@users.noreply.github.com> Date: Wed, 19 Aug 2020 20:44:54 +0800 Subject: [PATCH] Comply with go regexp & user defined regular expression prefix (#164) To avoid further confusion like this: https://github.com/v2fly/domain-list-community/issues/163 --- README.md | 10 ++++++---- data/amazon | 16 ++++++++-------- data/apple | 12 ++++++------ data/category-ads | 2 +- data/epicgames | 6 +++--- data/github | 2 +- data/gog | 2 +- data/google | 2 +- data/ookla-speedtest-ads | 2 +- data/viu | 2 +- main.go | 2 +- 11 files changed, 30 insertions(+), 28 deletions(-) diff --git a/README.md b/README.md index 35e3d599..381d754a 100644 --- a/README.md +++ b/README.md @@ -81,19 +81,21 @@ All data are under `data` directory. Each file in the directory represents a sub include:another-file domain:google.com @attr1 @attr2 keyword:google -regex:www\.google\.com +regexp:www\.google\.com$ full:www.google.com ``` **Syntax:** +> The following types of rules are **NOT** fully compatible with the ones that defined by user in V2Ray config file. Do **Not** copy and paste directly. + * Comment begins with `#`. It may begin anywhere in the file. The content in the line after `#` is treated as comment and ignored in production. * Inclusion begins with `include:`, followed by the file name of an existing file in the same directory. * Subdomain begins with `domain:`, followed by a valid domain name. The prefix `domain:` may be omitted. * Keyword begins with `keyword:`, followed by a string. -* Regular expression begins with `regex:`, followed by a valid regular expression (per Golang's standard). +* Regular expression begins with `regexp:`, followed by a valid regular expression (per Golang's standard). * Full domain begins with `full:`, followed by a complete and valid domain name. -* Domains (including `domain`, `keyword`, `regex` and `full`) may have one or more attributes. Each attribute begins with `@` and followed by the name of the attribute. +* Domains (including `domain`, `keyword`, `regexp` and `full`) may have one or more attributes. Each attribute begins with `@` and followed by the name of the attribute. ## How it works @@ -106,7 +108,7 @@ To generate a section: 3. Omit all empty lines. 4. Generate each `domain:` line into a [sub-domain routing rule](https://github.com/v2fly/v2ray-core/blob/master/app/router/config.proto#L21). 5. Generate each `keyword:` line into a [plain domain routing rule](https://github.com/v2fly/v2ray-core/blob/master/app/router/config.proto#L17). -6. Generate each `regex:` line into a [regex domain routing rule](https://github.com/v2fly/v2ray-core/blob/master/app/router/config.proto#L19). +6. Generate each `regexp:` line into a [regex domain routing rule](https://github.com/v2fly/v2ray-core/blob/master/app/router/config.proto#L19). 7. Generate each `full:` line into a [full domain routing rule](https://github.com/v2fly/v2ray-core/blob/master/app/router/config.proto#L23). ## How to organize domains diff --git a/data/amazon b/data/amazon index 6c06d41c..d6930a2f 100644 --- a/data/amazon +++ b/data/amazon @@ -147,14 +147,14 @@ elasticbeanstalk.com thinkboxsoftware.com # AWS DNS -regex:.+\.awsdns-[0-9][0-9]\.co\.uk$ -regex:.+\.awsdns-[0-9][0-9]\.com$ -regex:.+\.awsdns-[0-9][0-9]\.net$ -regex:.+\.awsdns-[0-9][0-9]\.org$ -regex:.+\.awsdns-cn-[0-9][0-9]\.biz$ -regex:.+\.awsdns-cn-[0-9][0-9]\.cn$ -regex:.+\.awsdns-cn-[0-9][0-9]\.com$ -regex:.+\.awsdns-cn-[0-9][0-9]\.net$ +regexp:.+\.awsdns-[0-9][0-9]\.co\.uk$ +regexp:.+\.awsdns-[0-9][0-9]\.com$ +regexp:.+\.awsdns-[0-9][0-9]\.net$ +regexp:.+\.awsdns-[0-9][0-9]\.org$ +regexp:.+\.awsdns-cn-[0-9][0-9]\.biz$ +regexp:.+\.awsdns-cn-[0-9][0-9]\.cn$ +regexp:.+\.awsdns-cn-[0-9][0-9]\.com$ +regexp:.+\.awsdns-cn-[0-9][0-9]\.net$ # Kindle kindle.cn @cn diff --git a/data/apple b/data/apple index 3d5d238e..870f8471 100644 --- a/data/apple +++ b/data/apple @@ -844,12 +844,12 @@ full:weather-data.apple.com @cn full:www.apple.com.edgekey.net.globalredir.akadns.net @cn full:www.apple.com.edgekey.net @cn full:www.apple.com @cn -regex:^a[1-5]\.mzstatic\.com$ @cn -regex:^cdn(-cn)?[1-4]?\.apple-mapkit\.com$ @cn -regex:^cl[1-5]-cdn\.origin-apple\.com\.akadns\.net$ @cn -regex:^cl[1-5]\.apple\.com$ @cn -regex:^is[1-5](-ssl)?\.mzstatic\.com$ @cn -regex:^s[1-5]?\.mzstatic\.com$ @cn +regexp:^a[1-5]\.mzstatic\.com$ @cn +regexp:^cdn(-cn)?[1-4]?\.apple-mapkit\.com$ @cn +regexp:^cl[1-5]-cdn\.origin-apple\.com\.akadns\.net$ @cn +regexp:^cl[1-5]\.apple\.com$ @cn +regexp:^is[1-5](-ssl)?\.mzstatic\.com$ @cn +regexp:^s[1-5]?\.mzstatic\.com$ @cn full:apple.com.akadns.net full:courier-push-apple.com.akadns.net diff --git a/data/category-ads b/data/category-ads index f60bcd76..17f10ac6 100644 --- a/data/category-ads +++ b/data/category-ads @@ -86,7 +86,7 @@ click.ali213.net pbmp.ali213.net # Caixin -regex:^pinggai\d\.caixin\.com$ +regexp:^pinggai\d\.caixin\.com$ # Chinaso adq.chinaso.com diff --git a/data/epicgames b/data/epicgames index 918616d5..f4fd0098 100644 --- a/data/epicgames +++ b/data/epicgames @@ -9,6 +9,6 @@ spyjinx.com unrealengine.com unrealtournament.com -regex:^cdn\d-epicgames-\d+\.file\.myqcloud\.com$ @cn -regex:^epicgames-download\d\.akamaized\.net$ -regex:^epicgames-download\d-\d+\.file\.myqcloud\.com$ @cn +regexp:^cdn\d-epicgames-\d+\.file\.myqcloud\.com$ @cn +regexp:^epicgames-download\d\.akamaized\.net$ +regexp:^epicgames-download\d-\d+\.file\.myqcloud\.com$ @cn diff --git a/data/github b/data/github index e8b4603b..faf78b40 100644 --- a/data/github +++ b/data/github @@ -14,4 +14,4 @@ githubstatus.com githubusercontent.com full:github-avatars.oss-cn-hongkong.aliyuncs.com -regex:github-production-release-asset-[0-9a-zA-Z]{6}\.s3\.amazonaws\.com +regexp:github-production-release-asset-[0-9a-zA-Z]{6}\.s3\.amazonaws\.com diff --git a/data/gog b/data/gog index cb7e00a9..4b44eff9 100644 --- a/data/gog +++ b/data/gog @@ -7,4 +7,4 @@ full:menu-static.gog-statics.com @cn full:productcard.gog-statics.com @cn full:static-login.gog-statics.com @cn full:www4-static.gog-statics.com @cn -regex:^images(-\d)?\.gog-statics\.com$ @cn +regexp:^images(-\d)?\.gog-statics\.com$ @cn diff --git a/data/google b/data/google index 4e5d68c7..87b8ac4c 100644 --- a/data/google +++ b/data/google @@ -565,4 +565,4 @@ full:translate.googleapis.com @cn full:update.googleapis.com @cn full:www-googletagmanager.l.google.com @cn full:www.gstatic.com @cn -regex:^khm([0-3]|db)?\.google(apis)?\.com$ @cn +regexp:^khm([0-3]|db)?\.google(apis)?\.com$ @cn diff --git a/data/ookla-speedtest-ads b/data/ookla-speedtest-ads index 7a081a00..d99b611a 100644 --- a/data/ookla-speedtest-ads +++ b/data/ookla-speedtest-ads @@ -1 +1 @@ -regex:^speed\.(coe|open)\.ad\.[a-z]{2,6}\.prod\.hosts\.ooklaserver\.net$ @ads +regexp:^speed\.(coe|open)\.ad\.[a-z]{2,6}\.prod\.hosts\.ooklaserver\.net$ @ads diff --git a/data/viu b/data/viu index 53185894..79dac718 100644 --- a/data/viu +++ b/data/viu @@ -1,7 +1,7 @@ # viu.tv viu.tv full:api.viu.now.com -regex:^ewcdn[0-9]{2}\.nowe\.com$ +regexp:^ewcdn[0-9]{2}\.nowe\.com$ #viu.com viu.com diff --git a/main.go b/main.go index 6faf491b..a8bf2a11 100644 --- a/main.go +++ b/main.go @@ -70,7 +70,7 @@ func (l *ParsedList) toProto() (*router.GeoSite, error) { Value: entry.Value, Attribute: entry.Attrs, }) - case "regex": + case "regexp": site.Domain = append(site.Domain, &router.Domain{ Type: router.Domain_Regex, Value: entry.Value,