-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
124 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
--- | ||
title: Functions | ||
--- | ||
|
||
In addition to [everything that expr already provides](https://expr-lang.org/docs/language-definition), we also have some extra built-in functions that you can use in your expressions: | ||
|
||
### `cidr` | ||
|
||
``` | ||
cidr(ip: string, cidr: string) -> bool | ||
``` | ||
|
||
Check if an IP address is in a CIDR range. Example: | ||
|
||
```yaml | ||
- name: block cidr | ||
action: block | ||
expr: cidr(string(ip.dst), "192.168.0.0/16") | ||
``` | ||
### `geoip` | ||
|
||
``` | ||
geoip(ip: string, country: string) -> bool | ||
``` | ||
Check if an IP address belongs to a specific country, using data from https://github.com/Loyalsoldier/v2ray-rules-dat | ||
Example: | ||
```yaml | ||
- name: block CN geoip | ||
action: block | ||
expr: geoip(string(ip.dst), "cn") | ||
``` | ||
|
||
### `geosite` | ||
|
||
``` | ||
geosite(domain: string, category: string) -> bool | ||
``` | ||
|
||
Check if a domain belongs to a specific category, using data from https://github.com/Loyalsoldier/v2ray-rules-dat | ||
|
||
Example: | ||
|
||
```yaml | ||
- name: block bilibili geosite | ||
action: block | ||
expr: geosite(string(tls?.req?.sni), "bilibili") | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
--- | ||
title: 内置函数 | ||
--- | ||
|
||
除了 [expr 本身内置的函数以外](https://expr-lang.org/docs/language-definition),我们还提供了一些额外的内置函数,可以在表达式中使用: | ||
|
||
### `cidr` | ||
|
||
``` | ||
cidr(ip: string, cidr: string) -> bool | ||
``` | ||
|
||
检查一个 IP 地址是否在一个 CIDR 范围内。示例: | ||
|
||
```yaml | ||
- name: block cidr | ||
action: block | ||
expr: cidr(string(ip.dst), "192.168.0.0/16") | ||
``` | ||
### `geoip` | ||
|
||
``` | ||
geoip(ip: string, country: string) -> bool | ||
``` | ||
检查一个 IP 地址是否来自一个国家,使用来自 https://github.com/Loyalsoldier/v2ray-rules-dat 的数据。 | ||
示例: | ||
```yaml | ||
- name: block CN geoip | ||
action: block | ||
expr: geoip(string(ip.dst), "cn") | ||
``` | ||
|
||
### `geosite` | ||
|
||
``` | ||
geosite(domain: string, category: string) -> bool | ||
``` | ||
|
||
检查一个域名是否属于一个特定的类别,使用来自 https://github.com/Loyalsoldier/v2ray-rules-dat 的数据。 | ||
|
||
示例: | ||
|
||
```yaml | ||
- name: block bilibili geosite | ||
action: block | ||
expr: geosite(string(tls?.req?.sni), "bilibili") | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters