Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

请问大佬能否适配sing-box的规则文件 #900

Open
LQ2002 opened this issue Mar 14, 2024 · 4 comments
Open

请问大佬能否适配sing-box的规则文件 #900

LQ2002 opened this issue Mar 14, 2024 · 4 comments
Labels
新增 添加新的拦截规则、过滤规则

Comments

@LQ2002
Copy link

LQ2002 commented Mar 14, 2024

singbox有劫持dns请求服务,能否适配下singbox的规则吖。

@LQ2002 LQ2002 added the 新增 添加新的拦截规则、过滤规则 label Mar 14, 2024
Copy link

welcome bot commented Mar 14, 2024

Thank you for opening your first issue in this repo. It’s people like you who make anti-AD better!

@gentlyxu
Copy link
Collaborator

有参考的列表格式吗?

@MkQtS
Copy link

MkQtS commented Mar 16, 2024

sing-box 的配置是 json 格式,要匹配doubleclick.net及其子域名,对于 sing-box 1.9.0 之前的版本,是这样的:

{
	"version": 1,
	"rules": [
		{
			"domain": [
				"doubleclick.net"
			]
		},
		{
			"domain_suffix": [
				".doubleclick.net"
			]
		}
	]
}

sing-box 1.9.0 之后这样:

{
	"version": 1,
	"rules": [
		{
			"domain_suffix": [
				"doubleclick.net"
			]
		}
	]
}

支持编译为二进制减小体积

参考:

  1. https://sing-box.sagernet.org/configuration/rule-set/source-format/#compile

  2. SagerNet/sing-box@f91a90c

不过似乎不支持在一个规则里匹配部分域名同时排除另外部分域名(例如屏蔽mmstat.com,但放行log.mmstat.com)可能需要生成两个文件

@merrkry
Copy link

merrkry commented Mar 17, 2024

不过似乎不支持在一个规则里匹配部分域名同时排除另外部分域名(例如屏蔽mmstat.com,但放行log.mmstat.com)可能需要生成两个文件

是可行的,使用逻辑规则即可,模板如下:

{
  "version": 1,
  "rules": [
    {
      "type": "logical",
      "mode": "and",
      "rules": [
        {
          "domain": [],
          "domain_suffix": []
        },
        {
          "domain": [],
          "domain_suffix": [],
          "invert": true
        }
      ]
    }
  ]
}

sing-box 1.9+ 仍然与旧版本写法兼容,使用旧版写法生成规则兼容性更佳。

另外由于 sing-box 的规则集引用机制,「引用的规则集可视为被合并,而不是作为一个单独的规则子项」,使用逻辑规则的规则集在与其他规则集合并使用的时候容易出现问题,需要在一条规则中单独使用。还请添加相关注释。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
新增 添加新的拦截规则、过滤规则
Projects
None yet
Development

No branches or pull requests

4 participants