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

希望增加gfw模式,也就是通过geosite_gfw.txt判断使用国内dns还是国外dns #245

Closed
Jio0oiJ opened this issue Aug 27, 2024 · 2 comments

Comments

@Jio0oiJ
Copy link

Jio0oiJ commented Aug 27, 2024

希望增加gfw模式,也就是通过geosite_gfw.txt判断使用国内dns还是国外dns。
在gfw列表内的使用 fakeip 的dns,其余的使用默认dns,这样能完美的对非gfw域名零干扰。
自己跟着模板改了一个,但是还是希望能由大佬集成进去

log:
level: info
file: "/var/log/mosdns.log"

API 入口设置

api:
http: "0.0.0.0:9091"

include: []

plugins:

GFW

  • tag: gfw
    type: domain_set
    args:
    files:
    - "/var/mosdns/geosite_gfw.txt"

Greylist

  • tag: greylist
    type: domain_set
    args:
    files:
    - "/etc/mosdns/rule/greylist.txt"

缓存

  • tag: lazy_cache
    type: cache
    args:
    size: 20000
    lazy_cache_ttl: 86400
    dump_file: "/etc/mosdns/cache.dump"
    dump_interval: 600

转发至本地服务器

  • tag: forward_local
    type: forward
    args:
    upstreams:
    - addr: 127.0.0.1:3053

转发至远程服务器

  • tag: forward_remote
    type: forward
    args:
    upstreams:
    - addr: 127.0.0.1:7874

国内解析

  • tag: local_sequence
    type: sequence
    args:
    • exec: $forward_local

国外解析

  • tag: remote_sequence
    type: sequence
    args:
    • exec: prefer_ipv4
    • exec: $forward_remote

有响应终止返回

  • tag: has_resp_sequence
    type: sequence
    args:
    • matches: has_resp
      exec: accept

查询国内域名

  • tag: query_is_local_domain
    type: sequence
    args:
    exec: $local_sequence

gfw

  • tag: query_is_gfw
    type: sequence
    args:

    • matches: qname $gfw
      exec: $remote_sequence
  • tag: query_is_greylist
    type: sequence
    args:

    • matches: qname $greylist
      exec: $remote_sequence

主要的运行逻辑插件

sequence 插件中调用的插件 tag 必须在 sequence 前定义,

否则 sequence 找不到对应插件。

  • tag: main_sequence
    type: sequence
    args:

- exec: $lazy_cache

  - exec: $query_is_gfw
  - exec: jump has_resp_sequence      
  - exec: $query_is_greylist
  - exec: jump has_resp_sequence      
  - exec: $query_is_local_domain
  - exec: jump has_resp_sequence

启动 udp 服务器。

  • tag: udp_server
    type: udp_server
    args:
    entry: main_sequence
    listen: ":5335"

启动 tcp 服务器。

  • tag: tcp_server
    type: tcp_server
    args:
    entry: main_sequence
    listen: ":5335"
@Jio0oiJ Jio0oiJ changed the title 希望增加gfw模式,也是是通过geosite_gfw.txt判断使用国内dns还是国外dns 希望增加gfw模式,也就是通过geosite_gfw.txt判断使用国内dns还是国外dns Aug 27, 2024
@sbwml
Copy link
Owner

sbwml commented Aug 27, 2024 via email

@Jio0oiJ
Copy link
Author

Jio0oiJ commented Aug 28, 2024

通过gfw列表处理的肯定是和科学相关的,但只是把mosdns当做一个dns分流器,在gfw列表里的用dns1, 其余的用dns2。

@sbwml sbwml closed this as not planned Won't fix, can't repro, duplicate, stale Aug 28, 2024
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