📖
mosdns-wiki-zh
  • mosdns wiki
  • mosdns v5
    • 如何配置 mosdns
      • Sequence 插件
      • 服务器插件
      • 可执行插件
      • 数据插件
      • 域名匹配规则
      • 匹配器插件
    • Debug 内存与性能问题
    • 如何编写新插件
    • API 说明
  • mosdns v4
    • Debug 内存与性能问题
    • 插件及其参数
    • 如何配置 mosdns
    • 如何编写新插件
    • API 说明
Powered by GitBook
On this page

Was this helpful?

  1. mosdns v5
  2. 如何配置 mosdns

域名匹配规则

Last updated 2 years ago

Was this helpful?

域名规则有多个匹配方式:

  • 以 domain: 开头,域匹配。e.g: domain:google.com 会匹配自身 google.com,以及其子域名 www.google.com, maps.l.google.com 等。

  • 以 full: 开头,完整匹配。e.g: full:google.com 只会匹配自身。

  • 以 keyword: 开头,关键字匹配。e.g: keyword:google.com 会匹配包含这个字段的域名,如 google.com.hk, www.google.com.hk。

  • 以 regexp: 开头,正则匹配()。e.g: regexp:.+\.google\.com$。

匹配方式可省略。不同插件有不同的默认值。

匹配方式按如下顺序生效: full > domain > regexp > keyword。

相同匹配方式的规则按如下顺序生效:

  • domain 规则: 子域名优先。比如如果同时存在规则 google.com 和 com。 www.google.com 会优先匹配 google.com,然后 com。(v3.9.0+)

  • regexp 和 keyword 规则生效顺序为规则导入的顺序。

性能:

  • domain 和 full 匹配使用 HashMap,复杂度 O(1)。每 1w 域名约占用 1M 内存。

  • keyword 和 regexp 匹配需遍历,复杂度 O(n)。注意: regexp 正则匹配会消耗大量资源。

Golang 标准