Skip to content

Commit

Permalink
Improve domain suffix match behavior
Browse files Browse the repository at this point in the history
For historical reasons, sing-box's `domain_suffix` rule matches literal prefixes instead of the same as other projects.

This change modifies the behavior of `domain_suffix`: If the rule value is prefixed with `.`,
the behavior is unchanged, otherwise it matches `(domain|.+\.domain)` instead.
  • Loading branch information
nekohasekai committed Jan 5, 2024
1 parent 62ac3c8 commit f91a90c
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 3 deletions.
7 changes: 7 additions & 0 deletions docs/migration.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@ icon: material/arrange-bring-forward

This version is still under development, and the following migration guide may be changed in the future.

### `domain_suffix` behavior update

For historical reasons, sing-box's `domain_suffix` rule matches literal prefixes instead of the same as other projects.

sing-box 1.9.0 modifies the behavior of `domain_suffix`: If the rule value is prefixed with `.`,
the behavior is unchanged, otherwise it matches `(domain|.+\.domain)` instead.

### `process_path` format update on Windows

The `process_path` rule of sing-box is inherited from Clash,
Expand Down
6 changes: 6 additions & 0 deletions docs/migration.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ icon: material/arrange-bring-forward

该版本仍在开发中,迁移指南可能将在未来更改。

### `domain_suffix` 行为更新

由于历史原因,sing-box 的 `domain_suffix` 规则匹配字面前缀,而不与其他项目相同。

sing-box 1.9.0 修改了 `domain_suffix` 的行为:如果规则值以 `.` 为前缀则行为不变,否则改为匹配 `(domain|.+\.domain)`

### 对 Windows 上 `process_path` 格式的更新

sing-box 的 `process_path` 规则继承自Clash,
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ require (
github.com/sagernet/gvisor v0.0.0-20231209105102-8d27a30e436e
github.com/sagernet/quic-go v0.40.1-beta.2
github.com/sagernet/reality v0.0.0-20230406110435-ee17307e7691
github.com/sagernet/sing v0.3.0-rc.7
github.com/sagernet/sing v0.3.0-rc.7.0.20240105061852-782bc05c5573
github.com/sagernet/sing-dns v0.1.12
github.com/sagernet/sing-mux v0.1.8-rc.1
github.com/sagernet/sing-quic v0.1.7-rc.2
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ github.com/sagernet/quic-go v0.40.1-beta.2/go.mod h1:CcKTpzTAISxrM4PA5M20/wYuz9T
github.com/sagernet/reality v0.0.0-20230406110435-ee17307e7691 h1:5Th31OC6yj8byLGkEnIYp6grlXfo1QYUfiYFGjewIdc=
github.com/sagernet/reality v0.0.0-20230406110435-ee17307e7691/go.mod h1:B8lp4WkQ1PwNnrVMM6KyuFR20pU8jYBD+A4EhJovEXU=
github.com/sagernet/sing v0.2.18/go.mod h1:OL6k2F0vHmEzXz2KW19qQzu172FDgSbUSODylighuVo=
github.com/sagernet/sing v0.3.0-rc.7 h1:FmnzFRYC6usVgWf112cUxiexwvL+iAurKmCL4Axa9+A=
github.com/sagernet/sing v0.3.0-rc.7/go.mod h1:9pfuAH6mZfgnz/YjP6xu5sxx882rfyjpcrTdUpd6w3g=
github.com/sagernet/sing v0.3.0-rc.7.0.20240105061852-782bc05c5573 h1:aBpX3AIQ6jfIFBj4Gwofd3jZc2s1dC6/ChoyUOglyrc=
github.com/sagernet/sing v0.3.0-rc.7.0.20240105061852-782bc05c5573/go.mod h1:9pfuAH6mZfgnz/YjP6xu5sxx882rfyjpcrTdUpd6w3g=
github.com/sagernet/sing-dns v0.1.12 h1:1HqZ+ln+Rezx/aJMStaS0d7oPeX2EobSV1NT537kyj4=
github.com/sagernet/sing-dns v0.1.12/go.mod h1:rx/DTOisneQpCgNQ4jbFU/JNEtnz0lYcHXenlVzpjEU=
github.com/sagernet/sing-mux v0.1.8-rc.1 h1:5dsZgWmNr9W6JzQj4fb3xX2pMP0OyJH6kVtlqc2kFKA=
Expand Down

2 comments on commit f91a90c

@PuerNya
Copy link
Contributor

@PuerNya PuerNya commented on f91a90c Jan 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

domain_suffix 行为的修改可能不是一个好的决定。

其他项目的 domain_suffix 项目由于历史原因,都采用的那套标准,实际上这会带来语义上的模糊。这套方案丢失了 suffixstring 中的基础语义,仅提供了书写上的便利。

sing-box 现行 domain_suffix 匹配方案与 string 中的语义一致,同事可以根据需要进行匹配的精准度把控,在特定情况下亦可减小开销。

在以下情况中:
我想匹配 /.+le.com/,使用现有 suffix 我可以直接 "domain_suffix": "le.com",而匹配方案修改后,我必须使用正则表达式进行匹配,会带来毫无必要的开销。

请保留现有 domain_suffix 匹配方案,它不应该为其他匹配规则设计不够完善的代理程序埋单

@nekohasekai
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

其他项目的 domain_suffix 项目由于历史原因,都采用的那套标准,实际上这会带来语义上的模糊。

很多项目都明确说明了语义。

这套方案丢失了 suffix 在 string 中的基础语义,仅提供了书写上的便利。

原有语义很少确切被使用,且制造了不便。

同事可以根据需要进行匹配的精准度把控,在特定情况下亦可减小开销。

在大多数情况下都没有作用。

在以下情况中我想匹配... 会带来毫无必要的开销

你的场景很小众,修改很有必要。

它不应该为其他匹配规则设计不够完善的代理程序埋单

你的话充满了没有根据的情绪,如何设计,应该怎么做,以你的认知和技术水平还不够评价。请不要再用长篇大论的事实错误来污染评论了。

Please sign in to comment.