Skip to content

Commit

Permalink
docs: Add doc for multi filters
Browse files Browse the repository at this point in the history
  • Loading branch information
zu1k committed Oct 17, 2021
1 parent 22a3006 commit 9658ba3
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 19 deletions.
4 changes: 2 additions & 2 deletions docs/rule/action.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@

## 多个动作

`action`字段支持单个动作和多个动作,当需要执行多个动作时,应使用数组
`actions`字段支持单个动作和多个动作,当需要执行多个动作时,应使用数组

```yaml
- name: "youtube-1"
filter:
url-regex: '(^https?:\/\/(?!redirector)[\w-]+\.googlevideo\.com\/(?!dclk_video_ads).+)(ctier=L)(&.+)'
action:
actions:
- log-req:
- redirect: "$1$4"
```
16 changes: 16 additions & 0 deletions docs/rule/filter.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,19 @@
url-regex: '^https?:\/\/(www|s)\.youtube\.com\/(pagead|ptracking)'
action: reject
```

## 多个筛选器

`filters`字段支持单个筛选器和多个筛选器,多个筛选器之间的关系为`或`

```yaml
- name: "youtube-2"
filters:
- url-regex: '^https?:\/\/[\w-]+\.googlevideo\.com\/(?!(dclk_video_ads|videoplayback\?)).+(&oad|ctier)'
- url-regex: '^https?:\/\/(www|s)\.youtube\.com\/api\/stats\/ads'
- url-regex: '^https?:\/\/(www|s)\.youtube\.com\/(pagead|ptracking)'
- url-regex: '^https?:\/\/\s.youtube.com/api/stats/qoe?.*adformat='
action: reject
```

具有相同动作的多个规则可聚合为一个规则以便于维护
22 changes: 5 additions & 17 deletions rules/youtube.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,9 @@
redirect: "$1$4"

- name: "youtube-2"
filter:
url-regex: '^https?:\/\/[\w-]+\.googlevideo\.com\/(?!(dclk_video_ads|videoplayback\?)).+(&oad|ctier)'
action: reject

- name: "youtube-3"
filter:
url-regex: '^https?:\/\/(www|s)\.youtube\.com\/api\/stats\/ads'
action: reject

- name: "youtube-4"
filter:
url-regex: '^https?:\/\/(www|s)\.youtube\.com\/(pagead|ptracking)'
action: reject

- name: "youtube-5"
filter:
url-regex: '^https?:\/\/\s.youtube.com/api/stats/qoe?.*adformat='
filters:
- url-regex: '^https?:\/\/[\w-]+\.googlevideo\.com\/(?!(dclk_video_ads|videoplayback\?)).+(&oad|ctier)'
- url-regex: '^https?:\/\/(www|s)\.youtube\.com\/api\/stats\/ads'
- url-regex: '^https?:\/\/(www|s)\.youtube\.com\/(pagead|ptracking)'
- url-regex: '^https?:\/\/\s.youtube.com/api/stats/qoe?.*adformat='
action: reject

0 comments on commit 9658ba3

Please sign in to comment.