DanielLavrushin 说明 b4 的 ASN 前缀选择与描述缓存修复

在 b4 #727 的讨论中,DanielLavrushin 表示,lookupASN 在较宽前缀排在前面时原会使用覆盖网络的 AS,修改后无论记录顺序如何都选择较窄前缀。他增加了两种顺序的假 DoH 服务测试,让 hub 直接调用 asnorigin.Pick,并收敛相关接口。他还说明,AS 描述查询失败时不再缓存空的组织名称,以免解析器一直被显示为遭到劫持,直至 b4 重启;ASN 仍保留缓存,只重新查询描述。此外,他补充了变更日志及 hub 测试发现规则。

作者原文

Thanks for the fix, @RyoKusnadi. It does what #685 asks: with the wide prefix first, lookupASN on main named the covering prefix's AS, and with this change it names the narrow one in either order.

I pushed a few commits on top so it can go in as is:

  • Removed the code comments in src/asnorigin. The repo keeps none; explanations go in commit messages.
  • Added src/detector/asn_test.go. It runs lookupASN against a fake DoH server with the wide prefix first and the narrow prefix first, so going back to the first record fails a test.
  • The hub calls asnorigin.Pick directly. The PickOrigin and ParseOrigin wrappers are gone and parse is unexported, so Pick is the only way in.
  • lookupASN no longer keeps an empty org in its cache when the AS description lookup fails, which made a resolver show as hijacked until b4 restarted. The ASN stays cached and only the description is asked again.
  • Changelog entries in changelog.md, changelog_ru.md and hub/CHANGELOG.md.
  • b4-check now lists the hub tests when a src package the hub imports changes, since the hub imports src/asnorigin now.