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

[BUG] Surge 的 DOMAIN-SET 生成问题 #667

Closed
2 tasks done
Energetic3906 opened this issue Nov 14, 2023 · 1 comment
Closed
2 tasks done

[BUG] Surge 的 DOMAIN-SET 生成问题 #667

Energetic3906 opened this issue Nov 14, 2023 · 1 comment

Comments

@Energetic3906
Copy link

确认版本最新

  • 我已经确认在最新Action编译的版本中复现

检索issue

  • 我已经确认之前没有issue涉及此BUG

subconverter版本

subconverter v0.8.1-885a63b backend

转换过程

将规则文件转换为 Surge DOMAIN-SET

转换设置

getruleset?type=3&url=aHR0cHM6Ly9yYXcuZ2l0aHVidXNlcmNvbnRlbnQuY29tL2JsYWNrbWF0cml4Ny9pb3NfcnVsZV9zY3JpcHQvbWFzdGVyL3J1bGUvQ2xhc2gvQWR2ZXJ0aXNpbmdMaXRlL0FkdmVydGlzaW5nTGl0ZS5saXN0

复现步骤

DOMAIN-SET:专为大量域名集列表文件设计,支持上万条记录的快速查询。文件中每行为一个域名,如果某行以 . 开头则表示匹配所有子域名和该域名本身。可用于广告过滤。

由官方文件可知,当规则是 DOMAIN-SUFFIX 的时候,应该以 . 开头;那么当规则是 DOMAIN 的时候,才是直接以域名开头。

定位代码:

https://raw.githubusercontent.com/tindy2013/subconverter/885a63b83778fbcf85765d10ec94ea06b9ca72da/src/handler/interfaces.cpp 的 242 行至249行,修改一下即可。

case 5:
if(!startsWith(strLine, "DOMAIN-SUFFIX,") && !startsWith(strLine, "DOMAIN,"))
continue;
if(filterLine())
continue;
output_content += strLine.substr(posb, pose);
output_content += '\n';
continue;

以个人的代码水平修改如下:

case 5:
if(!startsWith(strLine, "DOMAIN-SUFFIX,") && !startsWith(strLine, "DOMAIN,"))
continue;
if(filterLine())
continue;
if(strLine[posb - 2] == 'X')
output_content += ".";
output_content += strLine.substr(posb, pose);
output_content += "'\n";
continue;

期望结果

当规则是 DOMAIN-SUFFIX 的时候,应该以 . 开头;那么当规则是 DOMAIN 的时候,以域名开头

实际结果

不论是 DOMAIN-SUFFIX 还是 DOMAIN,转换后的规则都是以域名开头。

错误信息

No response

@Energetic3906 Energetic3906 changed the title Surge 的 DOMAIN-SET 生成问题 [BUG] Surge 的 DOMAIN-SET 生成问题 Nov 14, 2023
tindy2013 added a commit that referenced this issue Nov 26, 2023
Fix bad conversion of DOMAIN-SUFFIX rules when generating Surge DOMAIN-SET. (#667)
Optimize codes.
@tindy2013
Copy link
Owner

Fixed in 05a542c

littleneko pushed a commit to littleneko/subconverter that referenced this issue Feb 26, 2024
Fix bad conversion of DOMAIN-SUFFIX rules when generating Surge DOMAIN-SET. (tindy2013#667)
Optimize codes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants