Closed doveccl closed 3 weeks ago
singbox老大难问题,不支持正则解析,这个请耐心等待我们找到别的解决思路。
初步计划是打算在规则生成阶段,直接让singbox的脚本不读取正则部分。
为什么不适应无正则版本呢 https://raw.githubusercontent.com/TG-Twilight/AWAvenue-Ads-Rule/main/Filters/AWAvenue-Ads-Rule-Singbox.json
少了部分规则
{
"domain_regex": [
"*.*.shouji.sogou.com",
"*.[a-zA-Z0-9.-]skwai.com",
"*.a.market.xiaomi.com",
"*.data.hicloud.com",
"*.log.aliyuncs.com",
"*.shouji.sogou.com",
"[a-zA-Z0-9.-]*-ad-[a-zA-Z0-9.-]*.byteimg.com",
"[a-zA-Z0-9.-]*-ad.sm.cn",
"[a-zA-Z0-9.-]*-ad.video.yximgs.com",
"[a-zA-Z0-9.-]*-ad.wtzw.com",
"[a-zA-Z0-9.-]*-be-pack-sign.pglstatp-toutiao.com",
"[a-zA-Z0-9.-]*-lm.adkwai.com",
"[a-zA-Z0-9.-]*-normal-[a-zA-Z0-9.-]*.zijieapi.com",
"[a-zA-Z0-9.-]*-normal.zijieapi.com",
"cloudinject[a-zA-Z0-9.-]*-dev.*.[a-zA-Z0-9.-]*-[a-zA-Z0-9.-]*-[a-zA-Z0-9.-]*.amazonaws.com"
]
}
anyway 我现在没在用 sing-box 了,影响倒是不大
不过问题应该出在以 *
开头的几个规则里,也许用 .*
代替 *
能解决这个问题
@TG-Twilight 刚才发现官方给了 adguard.txt -> srs 转换程序,是不是可以考虑直接用 https://sing-box.sagernet.org/zh/configuration/rule-set/adguard/
@doveccl 但是还是会包括正则内容
singbox不支持正则内容
@TG-Twilight 好像也是支持的吧
{
"inbounds": [{ "type": "mixed", "listen_port": 7890 }],
"outbounds": [
{ "type": "direct", "tag": "direct" },
{ "type": "block", "tag": "block" }
],
"route": {
"rules": [{ "domain_regex": "[a-zA-Z0-9.-]*-ad.sm.cn", "outbound": "block" }]
}
}
上面这个配置跑一下
./sing-box run -c config.json & (sleep 1; all_proxy=http://localhost:7890 curl -v 1-ad.sm.cn)
日志也很清楚路由到了
INFO[0000] router: updated default interface en0, index 6
INFO[0000] inbound/mixed[0]: tcp server started at 127.0.0.1:7890
INFO[0000] sing-box started (0.00s)
* Uses proxy env variable all_proxy == 'http://localhost:7890'
* Host localhost:7890 was resolved.
* IPv6: ::1
* IPv4: 127.0.0.1
* Trying [::1]:7890...
* connect to ::1 port 7890 from ::1 port 50812 failed: Connection refused
* Trying 127.0.0.1:7890...
* Connected to localhost (127.0.0.1) port 7890
> GET http://1-ad.sm.cn/ HTTP/1.1
> Host: 1-ad.sm.cn
> User-Agent: curl/8.6.0
> Accept: */*
> Proxy-Connection: Keep-Alive
>
INFO[0000] [976685108 0ms] inbound/mixed[0]: inbound connection from 127.0.0.1:50813
INFO[0000] [976685108 1ms] inbound/mixed[0]: inbound connection to 1-ad.sm.cn:80
DEBUG[0000] [976685108 1ms] router: match[0] domain_regex=[a-zA-Z0-9.-]*-ad.sm.cn => block
INFO[0000] [976685108 1ms] outbound/block[block]: blocked connection to 1-ad.sm.cn:80
< DEBUG[0000] [976685108 1ms] inbound/mixed[0]: connection closed: process connection from 127.0.0.1:50813: Get "http://1-ad.sm.cn/": io: read/write on closed pipe
HTTP/1.1 502 Bad Gateway
< Content-Length: 0
<
* Connection #0 to host localhost left intact
@doveccl 但是还是会包括正则内容
singbox不支持正则内容
在目前这个时间点上sing官方已经支持regex了,但使用的regex中.
的含义为任意字符,*
的含义为任意数量,与通配符解释略有不同
例如*.*.shouji.sogou.com
的正确写法应为.*\\..*\\.shouji\\.sogou\\.com
配置:
拦截*.*.shouji.sogou.com
未误伤*.shouji.sogou.com
好的,两位朋友们,之后我们会尝试解决这个问题,当然,你们亦可直接在我们解决之前进行Pr。🙏
问题描述
sing-box 规则 domain_regex 中出现不少以 * 打头的规则导致正则解析失败
复现步骤
No response
问题截图
No response
自查步骤