Coder Social home page Coder Social logo

Comments (4)

ShadowOfTheDay avatar ShadowOfTheDay commented on July 19, 2024

顺便一提,如果是对于www.baidu.jp这种黑白名单匹配的域名完全一样(baidu.jp)的域名,新版本是可以按预期返回trust-dns的结果的。貌似只是上面那种,黑名单匹配结果为白名单子域名的情况才发现有问题。

from chinadns-ng.

zfl9 avatar zfl9 commented on July 19, 2024

感谢反馈,大概知道是哪段逻辑的问题了。


之前版本的 gfwlist 和 chnlist 的数据结构是分开的,所以之前版本的 --gfwlist-frist --chnlist-first 逻辑很简单,就是先匹配哪个map。

新版本的 gfwlist 和 chnlist 放到同一个数据结构了(为了减少匹配次数,减少内存碎片),所以处理哪个列表优先的逻辑发生了改变:--gfwlist-frist --chnlist-first 变为先加载哪个list到数据结构中,因此对于同一级别的域名(label数量相同),肯定是先加载的优先级高。

换句话说,gfw优先/chn优先 的粒度 从 列表 变为 同级别域名


对于这样一个域名:a.b.c.d,则匹配逻辑如下:

  • 检查 d 是否存在,存在则结束匹配
  • 检查 c.d 是否存在,存在则结束匹配
  • 检查 b.c.d 是否存在,存在则结束匹配
  • 检查 a.b.c.d 是否存在,存在则结束匹配

代入你说的情况:

tw.iqiyi.com在黑名单,iqiyi.com在白名单。

在匹配 iqiyi.com 时,会被白名单命中,所以被判定为 tag:chn,因此走 china 上游


如果调用一下匹配顺序,应该就可以解决此问题,也就是改为:

  • 检查 a.b.c.d 是否存在,存在则结束匹配
  • 检查 b.c.d 是否存在,存在则结束匹配
  • 检查 c.d 是否存在,存在则结束匹配
  • 检查 d 是否存在,存在则结束匹配

对于 使用同一个父域名,然后通过不同子域来区分国家/地区 的情况,应该是可以解决问题的,比如上面说的 iqiyi.com;google这一类恰好相反,他们是通过不同的顶级域来区分 国家/地区,比如 google.com、google.de、google.com.hk、google.co.jp 等。

from chinadns-ng.

zfl9 avatar zfl9 commented on July 19, 2024

更新到最新版本试试。

from chinadns-ng.

ShadowOfTheDay avatar ShadowOfTheDay commented on July 19, 2024

感谢作者!!!刚刚测试了下最新版本,的确解决了上述问题。
而且我认为新的匹配逻辑比之前v1.0版本更加合理:相当于对于某域名和其子域名分别在黑白名单的情况下,子域名优先,无论黑白名单哪个优先。举例来说,之前v1.0版,默认设置黑名单优先,其中包括google.com,那么白名单中的dl.google.com就无法生效。我之前的做法是把这些域名加到dnsmasq的规则里,优先级高于ChinaDNS;在新版本下,这一步就不需要了。优先级的选项现在只对黑白名单中完全重合的域名有用了,而这种情况几乎屈指可数(比如baidu.jp),没啥实际的影响。
再次感谢🙏🙏🙏

from chinadns-ng.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.