Skip to content

Commit

Permalink
re-organize pages
Browse files Browse the repository at this point in the history
  • Loading branch information
tobyxdd committed Apr 2, 2024
1 parent 6efadc8 commit 4b10942
Show file tree
Hide file tree
Showing 7 changed files with 124 additions and 22 deletions.
2 changes: 0 additions & 2 deletions docs/analyzers.md → docs/docs/analyzers.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
---
title: Analyzers
hide:
- navigation
---

Analyzers are one of the main components of OpenGFW. Their job is to analyze a connection, see if it's a protocol they
Expand Down
2 changes: 0 additions & 2 deletions docs/analyzers.zh.md → docs/docs/analyzers.zh.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
---
title: 分析器
hide:
- navigation
---

分析器是 OpenGFW 的重要组件之一,作用是分析连接,检查是否是支持的协议,并从该连接中提取信息,作为提供给规则引擎的属性,以便与用户提供的规则进行匹配。OpenGFW 会自动分析提供的规则中引用了哪些分析器,仅启用需要的分析器。
Expand Down
14 changes: 6 additions & 8 deletions docs/build-run.md → docs/docs/build-run.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
---
title: Build & Run
hide:
- navigation
---

### Build
Expand Down Expand Up @@ -117,9 +115,9 @@ to [Expr Language Definition](https://expr-lang.org/docs/language-definition).
#### Supported actions
- `allow`: Allow the connection, no further processing.
- `block`: Block the connection, no further processing.
- `drop`: For UDP, drop the packet that triggered the rule, continue processing future packets in the same flow. For
TCP, same as `block`.
- `modify`: For UDP, modify the packet that triggered the rule using the given modifier, continue processing future
packets in the same flow. For TCP, same as `allow`.
| Action | TCP | UDP |
| -------- | -------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------ |
| `allow` | Allow the connection, no further processing. | Allow the connection, no further processing. |
| `block` | Block the connection, no further processing. | Block the connection, no further processing. |
| `drop` | Same as `block`. | Drop the packet that triggered the rule, continue processing future packets in the same flow. |
| `modify` | Same as `allow`. | Modify the packet that triggered the rule using the given modifier, continue processing future packets in the same flow. |
12 changes: 6 additions & 6 deletions docs/build-run.zh.md → docs/docs/build-run.zh.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
---
title: 构建与运行
hide:
- navigation
---

### 构建
Expand Down Expand Up @@ -116,7 +114,9 @@ workers:
#### 支持的 action
- `allow`: 放行连接,不再处理后续的包。
- `block`: 阻断连接,不再处理后续的包。
- `drop`: 对于 UDP,丢弃触发规则的包,但继续处理同一流中的后续包。对于 TCP,效果同 `block`。
- `modify`: 对于 UDP,用指定的修改器修改触发规则的包,然后继续处理同一流中的后续包。对于 TCP,效果同 `allow`。
| 动作 | TCP | UDP |
| -------- | ---------------------------- | -------------------------------------------------------------- |
| `allow` | 放行连接,不再处理后续的包。 | 放行连接,不再处理后续的包。 |
| `block` | 阻断连接,不再处理后续的包。 | 阻断连接,不再处理后续的包。 |
| `drop` | 效果同 `block`。 | 丢弃触发规则的包,但继续处理同一流中的后续包。 |
| `modify` | 效果同 `allow`。 | 用指定的修改器修改触发规则的包,然后继续处理同一流中的后续包。 |
51 changes: 51 additions & 0 deletions docs/docs/functions.md
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")
```
51 changes: 51 additions & 0 deletions docs/docs/functions.zh.md
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")
```
14 changes: 10 additions & 4 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,11 @@ repo_url: https://github.com/apernet/OpenGFW

nav:
- Home: index.md
- Build & Run: build-run.md
- Analyzers: analyzers.md
- Docs:
- Build & Run: docs/build-run.md
- Analyzers: docs/analyzers.md
- Functions: docs/functions.md
- GitHub: https://github.com/apernet/OpenGFW

plugins:
- search
Expand All @@ -97,5 +100,8 @@ plugins:
build: true
nav:
- 首页: index.md
- 构建与运行: build-run.md
- 分析器: analyzers.md
- 文档:
- 构建与运行: docs/build-run.md
- 分析器: docs/analyzers.md
- 内置函数: docs/functions.md
- GitHub: https://github.com/apernet/OpenGFW

0 comments on commit 4b10942

Please sign in to comment.