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] IPv6 DNS Server [2620:fe::fe] 识别问题 #772

Open
4 tasks done
FrankLiangCN opened this issue Dec 17, 2023 · 2 comments
Open
4 tasks done

[Bug] IPv6 DNS Server [2620:fe::fe] 识别问题 #772

FrankLiangCN opened this issue Dec 17, 2023 · 2 comments

Comments

@FrankLiangCN
Copy link

在提交之前,请确认

  • 我已经尝试搜索过 Issue ,但没有找到相关问题。
  • 我正在使用最新的 mosdns 版本(或者最新的 commit),问题依旧存在。
  • 我仔细看过 wiki 后仍然无法自行解决该问题。
  • 我非常确定这是 mosdns 核心的问题。(如果是通过第三方衍生软件使用 mosdns 核心,不确定问题源头时,请先向衍生软件开发者提交问题。)

mosdns 版本

v5.3.1

操作系统

ubantu/apline Docker

Bug 描述和复现步骤

在上游服务器中使用- addr: "2620:fe::fe" 格式配置,会将最后的 :fe 识别为端口,导致错误
如果 将IPv6地址加上括号后,- addr: "[2620:fe::fe]",服务器地址识别正常,其它的IPv6地址不加 [] 均能正常识别

使用的配置文件

- tag: forward_remote
    type: forward
    args:
      concurrent: 3
      upstreams:
        - addr: "https://dns10.quad9.net/dns-query"    # Quad9 DNS
        - addr: "2620:fe::fe"       # Quad9 IPv6 DNS
        - addr: "2620:fe::9"        # Quad9 IPv6 DNS

mosdns 的 log 记录

failed to init plugin: failed to init upstream #5: invalid server address, parse "udp://2620:fe::fe": invalid port ":fe" after host
@ljcbaby
Copy link

ljcbaby commented Jan 5, 2024

// trySplitHostPort splits host and port.
// If s has no port, it returns s,0,nil
func trySplitHostPort(s string) (string, uint16, error) {
var port uint16
host, portS, err := net.SplitHostPort(s)
if err == nil {
n, err := strconv.ParseUint(portS, 10, 16)
if err != nil {
return "", 0, fmt.Errorf("invalid port, %w", err)
}
port = uint16(n)
return host, port, nil
}
return s, 0, nil
}

代码应该是这一块。但似乎不加方括号的v6并不能正确识别,只是最后一段是数字的话不会触发报错

@cctv4-cgtn
Copy link

直接把IPv6写进DoH的URL也有一样的问题,需要补上端口号才能正常使用,这种写法https://[2606:4700:4700::1111]/dns-query会报证书错误
目前能使用的写法:https://[2606:4700:4700::1111]:443/dns-query

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

3 participants