sing-box icon indicating copy to clipboard operation
sing-box copied to clipboard

[Bug] Route/DNS rules 内值为 bool 的值写 false 都没有效果。

Open daminit opened this issue 9 months ago • 1 comments

操作系统

Linux

系统版本

none

安装类型

sing-box 原始命令行程序

如果您使用图形客户端程序,请提供该程序版本。

No response

版本

sing-box version 1.13.0

Environment: go1.25.7 linux/amd64
Tags: with_gvisor,with_quic,with_dhcp,with_wireguard,with_utls,with_acme,with_clash_api,with_tailscale,with_ccm,with_ocm,badlinkname,tfogo_checklinkname0,with_naive_outbound,with_purego
Revision: 6da7e538e122b77c226ce48c1a6b4ecb61fd3fc4
CGO: disabled

描述

对于在dns规则或者路由规则里面值为 bool 类型的配置项,如果写 false 都不会进入 rule匹配内 ,要解决只有 写为 true , 然后再写一份 invert 。 https://github.com/SagerNet/sing-box/blob/239e6ec701ff9f3e63c7f5f61587d07c58414318/route/rule/rule_default.go#L56 大概和构建 Rule 的选项有关,如果 Rule 的值不为 false才构建。 也许应在 Option 里面修改为 *bool 再判断指针而不是判断 true和false 。

重现方式

{
  "inbounds": [
    {
      "type":"http",
      "tag":"http-in",
      "listen":"::",
      "listen_port": 15555
    }
  ],
  "route":{
    "rules": [
      {
        "ip_is_private": false,
        "action": "reject"
      }
    ],
    "final": "direct-internal"
  },
  "outbounds": [
    { "type":"direct", "tag":"direct-internal" }
  ],
  "log": {"level":"info"}
}

$ curl -so /dev/null -x http://127.0.0.1:15555 http://192.168.1.101:8000

在 curl 请求的时候,这个请求应该从 direct-internal 出站出去,而且实际是被拒绝了。

修改规则为下面表现正常。

{
  "ip_is_private": true,
  "inver": true,
  "action": "reject"
}

日志

INFO[0000] network: updated default interface wlxxxx, index 3
INFO[0000] inbound/http[http-in]: tcp server started at [::]:15555
INFO[0000] sing-box started (0.00s)
INFO[0005] [1439480417 0ms] inbound/http[http-in]: inbound connection from 127.0.0.1:46052
INFO[0005] [1439480417 0ms] inbound/http[http-in]: inbound connection to 192.168.1.101:8000
ERROR[0005] [1439480417 0ms] inbound/http[http-in]: process connection from 127.0.0.1:46052: (rejected | Get "http://192.168.1.101:8000/": io: read/write on closed pipe)

支持我们

完整性要求

  • [x] 我保证阅读了文档,了解所有我编写的配置文件项的含义,而不是大量堆砌看似有用的选项或默认值。
  • [x] 我保证提供了可以在本地重现该问题的服务器、客户端配置文件与流程,而不是一个脱敏的复杂客户端配置文件。
  • [x] 我保证提供了可用于重现我报告的错误的最简配置,而不是依赖远程服务器、TUN、图形界面客户端或者其他闭源软件。
  • [x] 我保证提供了完整的配置文件与日志,而不是出于对自身智力的自信而仅提供了部分认为有用的部分。

daminit avatar Feb 28 '26 10:02 daminit

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 5 days

github-actions[bot] avatar Apr 30 '26 02:04 github-actions[bot]