Skip to content

[Bug] parse_singbox_dns() doesn't preserve URL path for DoH DNS servers #1053

@zwangzw-zw

Description

@zwangzw-zw

Verify steps

  • 我已经在 Issue Tracker 中找过我要提出的问题 I have searched on the issue tracker for a related issue.
  • 我已经使用公测版本测试过,问题依旧存在 I have tested using the test mod, and the issue still exists.
  • 我已经仔细看过 常见问题 并无法自行解决问题

Description

Issue Description

The parse_singbox_dns() function in scripts/starts/singbox_modify.sh doesn't properly handle DoH (DNS-over-HTTPS) server URLs because it strips the URL path component, which is required by some DoH servers.

Current Behavior

When parsing DoH URLs like:

  • https://dns.google/dns-query
  • https://dns.controld.com/unique_identifier_path

The function only extracts the protocol and server, discarding the path:

{"type": "https", "server": "dns.google"}
{"type": "https", "server": "dns.controld.com"}

Expected Behavior

For some DoH servers, the full URL path should be preserved. Sing-box allows the server path to be included in the DNS module. The output should be something like:

{"type": "https", "server": "dns.controld.com", "path": "/unique_identifier_path"}

Impact

Some DoH providers require specific URL paths:

  • ControlD: https://dns.controld.com/unique_identifier_path (custom paths per user)

Without the path field, these DoH servers won't work correctly.

Affected Code

File: scripts/starts/singbox_modify.sh

Lines 27-30 - This is where the path gets stripped:

*)
    server="${tmp%%[:/]*}"  # ⚠️ This line strips everything after the first : or /
    port="${tmp#*:}"
    [ "$port" = "$tmp" ] && port=""
    ;;

For a URL like https://dns.controld.com/unique_path:

  • tmp = dns.controld.com/unique_path
  • server="${tmp%%[:/]*}" extracts only dns.controld.com and discards /unique_path

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions