Coder Social home page Coder Social logo

配置问题请教 about mosdns HOT 14 CLOSED

irinesistiana avatar irinesistiana commented on June 4, 2024
配置问题请教

from mosdns.

Comments (14)

IrineSistiana avatar IrineSistiana commented on June 4, 2024

为何第二个forward_local不是放在exec里,而是在外面?

在exec里啊。这是个嵌套。外层是exec(往上看几行)。

wiki里有

args:
  exec: # 执行序列,由多个命令构成。执行顺序为从上到下。
    - do_something # 命令可以直接是要执行的功能性插件。
    - do_something

    # 也可以是 if 条件命令块。
    - if: # 运行命令块的条件,必须是匹配器插件。可配置多个匹配器,关系为或运算。任意匹配器为真命令块就会被执行。
        - match_something
        - '!match_something' # `!` 前缀可实现取反。
      exec: [] # 嵌套的执行序列,可以为空。
      goto: other_sequence # 如果非空,重定向到此路由插件。如果为空,则不重定向(继续执行后面的序列)。

为何过滤本地结果没有exec,且没有forward_local?

上一步的forward_local请求完上游会产生一个应答,这个应答可以直接返回。不需要再请求一次。直接 end 就好了。

后面的forward_remote会对复写之前的应答。

from mosdns.

douglas-lee avatar douglas-lee commented on June 4, 2024

那我去掉外面那个forward_local,直接写在match_chn_domain里的exec是不是也是等效的?

from mosdns.

IrineSistiana avatar IrineSistiana commented on June 4, 2024

不行。你要先请求上游,拿到应答后,match_local_ip 才生效。

from mosdns.

douglas-lee avatar douglas-lee commented on June 4, 2024

啊?那你帮我看下我现在这样配置有何问题?但是我现在这样配,貌似也能正常使用啊。

args:
        exec:
          # 非 A AAAA 的请求另行处理
          - if:
              - "!match_qtype_A_AAAA"
            exec:
              - forward_chn
              - add_ipset_chn
            goto: end

          - if:
              - match_nf_domain
            exec:
              - forward_nf
              - add_ipset_nf
            goto: end

          - if:
              - match_jp_domain
            exec:
              - forward_jp
              - add_ipset_jp
            goto: end

          - if:
              - match_us_domain
            exec:
              - forward_us
              - add_ipset_us
            goto: end
            
          - if:
              - match_chn_domain
              - match_chn_ip
            exec:
              - forward_chn
              - add_ipset_chn
            goto: end

          # 剩余请求(既不是已知的本地域名,也没有返回本地 IP)
          - forward_us                # 转发至远程服务器
          - add_ipset_us
        next: end                     # 结束

from mosdns.

IrineSistiana avatar IrineSistiana commented on June 4, 2024

能用是能用,但只有域名分流。

match_local_ip 没起作用,因为没有应答给它匹配,所以永远返回 false。

from mosdns.

douglas-lee avatar douglas-lee commented on June 4, 2024

那要怎么改合适?就是把外面那个forward加上即可?

from mosdns.

IrineSistiana avatar IrineSistiana commented on June 4, 2024

forward_chn 移上去

from mosdns.

Hades-001 avatar Hades-001 commented on June 4, 2024

借楼请教下配置问题,我目前使用的配置文件如下:

exec:
  - if:
      - "!match_qtype_A_AAAA"
    exec:
      - forward_local_dnsserver
    goto: end
  - if:
      - "match_chn_domain"
      - "match_chn_ip"
    exec:
      - add_local_ecs
      - forward_local_dnsserver
    goto: end
  - if:
      - "match_non_chn_domain"
    exec:
      - forward_remote_dnsserver
    goto: end
  - forward_remote_dnsserver
next: end

根据该issue,要使 match_chn_ip 起作用,需要把 add_local_ecs 和 forward_local_dnsserver 提到上面去,但这样会使转发到 forward_remote_dnsserver 的请求也带上 ECS,我现在想实现仅转发到 forward_local_dnsserver 的请求带上 ECS,这个配置文件应该怎么修改下?

from mosdns.

IrineSistiana avatar IrineSistiana commented on June 4, 2024

@Hades-001 这问题好像真的无解。

目前没有去掉ECS的方法。可能只能再加个 add_remote_ecs 把之前的ECS覆盖掉。

以后可能有.(几小时以后?)

from mosdns.

Hades-001 avatar Hades-001 commented on June 4, 2024

@IrineSistiana 能不能把 ECS 功能部分加到 forward 插件上,这样好设置也更直观一点。

from mosdns.

IrineSistiana avatar IrineSistiana commented on June 4, 2024

@Hades-001 不行。

from mosdns.

terrytw avatar terrytw commented on June 4, 2024
      - forward_local_dnsserver

  - if:
      - "match_chn_domain"
      - "match_chn_ip"
    exec:
      - add_local_ecs
      - forward_local_dnsserver
    goto: end

这种写法会用第二次forward_local_dnsserver的结果覆盖第一次的结果吗?

from mosdns.

IrineSistiana avatar IrineSistiana commented on June 4, 2024

@terrytw 会。

友情提醒,刚更新的版本 end_end 了。

from mosdns.

terrytw avatar terrytw commented on June 4, 2024

@IrineSistiana 谢谢提醒!
@Hades-001 那你的问题就可以用我上面提到的写法解决了?
第一次请求本地dns服务器,如果命中IP列表,就加上ECS再次请求本地dns服务器,获取(可能)更新过的结果
EDIT: 当我没说,作者加了删除ECS的功能

from mosdns.

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.