Skip to content

fix(hy2): defer server resolution#65

Open
jiaming-shi wants to merge 1 commit into
daeuniverse:mainfrom
jiaming-shi:codex/defer-hysteria2-resolve
Open

fix(hy2): defer server resolution#65
jiaming-shi wants to merge 1 commit into
daeuniverse:mainfrom
jiaming-shi:codex/defer-hysteria2-resolve

Conversation

@jiaming-shi

Copy link
Copy Markdown

Summary

  • defer hysteria2 server address resolution until connection setup
  • keep UDP port hopping support while avoiding DNS lookup during dialer construction
  • add a regression test covering unresolved normal and port-hopping hostnames

Root cause

The port-hopping change resolved hysteria2 hostnames in NewDialer, so dae node loading could fail before dae DNS initialization finished.

Validation

  • GOCACHE=/tmp/codex-go-cache GOMODCACHE=/tmp/codex-go-mod go test ./protocol/hysteria2 -run TestNewDialerDefersServerResolution -count=1

@jiaming-shi jiaming-shi requested a review from a team as a code owner April 26, 2026 02:11
@jiaming-shi

Copy link
Copy Markdown
Author

Fix daeuniverse/dae#982.

从 1.0.0 升级到 1.1.0 之后,hy2 节点无法正常使用,启动时报错:

level=info msg="failed to parse node: create hysteria2://yourpassword@quic.yourdomain.com:443/?insecure=0: lookup quic.yourdomain.com on [::1]:53: read udp [::1]:42518->[::1]:53: i/o timeout"

@olicesx

olicesx commented Apr 26, 2026

Copy link
Copy Markdown

@jiaming-shi 试试2.0看看

@jiaming-shi

Copy link
Copy Markdown
Author

@olicesx 下载 v2.0.0rc1 测试,没有 hy2 节点的解析报错,不过代理整体看起来不工作了,直连是正常的。

v2.0.0rc1 在配置上有什么 breaking changes 吗?

level=info msg="Include config files: [/etc/dae/config.dae]"
level=info msg="purging stale TC filter from dae0 (handle: 0x20220002)"
level=info msg="Waiting for network..."
level=info msg="Network online."
level=info msg="Building control plane and routing rules..."
level=info msg="Kernel v6.12.74 supports Netkit, attempting to create Netkit device pair"
level=info msg="ip command does not support Netkit; iproute2 version 6.7.0+ required"
level=info msg="createNetkitDevice failed: neither netlink API nor ip command support Netkit (kernel may be < 6.7 or CONFIG_NETKIT not enabled); iproute2 version 6.7.0+ required"
level=warning msg="Failed to create Netkit device, falling back to veth" error="failed to create Netkit device: neither netlink API nor ip command support Netkit (kernel may be < 6.7 or CONFIG_NETKIT not enabled); iproute2 version 6.7.0+ required" kernel=v6.12.74
level=info msg="Falling back to veth device creation"
level=info msg="Created veth device pair (compatibility mode; Netkit was attempted but failed)"
level=info msg="Loading eBPF programs and maps into the kernel..."
level=info msg="The loading process takes about 120MB free memory, which will be released after loading. Insufficient memory will cause loading failure."
level=info msg="Loaded eBPF programs and maps"
level=info msg="Optimizing and loading routing rules (this may take a while for large rule sets)..."
level=info msg="Building routing matcher..."
level=info msg="Loading routing rules into kernel space (BPF)..."
level=info msg="Building 2 LPM tries (deduplicated from 2 sets, 0.0% reduction)"
level=info msg="Routing match set len: 11/1024"
level=info msg="Building userspace routing matcher..."
level=info msg="Health check will only verify 2 outbounds referenced by routing rules: [direct proxy]"
level=info msg="Memory usage after routing build: Alloc=27MiB, Sys=46MiB, HeapObjects=59392"
level=info msg="Bind to LAN: br-lan.10"
level=info msg="TCP relay eBPF offload is disabled due to kernel panic issues; falling back to userspace relay"
level=info msg="Bind to WAN: pppoe-wan"
level=info msg="Control plane built in 1.312830928s"
level=info msg="Total startup time: 6.530541437s"

@olicesx

olicesx commented Apr 26, 2026

Copy link
Copy Markdown

@jiaming-shi 你的hy2 格式是怎么样的,我正在用hy2

@jiaming-shi

Copy link
Copy Markdown
Author

@jiaming-shi 你的hy2 格式是怎么样的,我正在用hy2

完整配置文件是这个样子:

global {
    tproxy_port: 12345
    tproxy_port_protect: true
    pprof_port: 0
    so_mark_from_dae: 0
    log_level: info
    disable_waiting_network: false
    lan_interface: 'br-lan.10'
    wan_interface: auto
    auto_config_kernel_parameter: false
    tcp_check_url: 'http://cp.cloudflare.com,1.1.1.1,2606:4700:4700::1111'
    tcp_check_http_method: HEAD
    udp_check_dns: 'dns.google:53,8.8.8.8,2001:4860:4860::8888'
    check_interval: 30s
    check_tolerance: 0s
    dial_mode: domain
    allow_insecure: false
    sniffing_timeout: 100ms
    tls_implementation: tls
    utls_imitate: chrome_auto
    mptcp: false
    fallback_resolver: '8.8.8.8:53'
}

subscription {}

node {
    hy2: 'hysteria2://yourpassword@quic.yourdomain.com:443/?insecure=0'
}

dns {
    ipversion_prefer: 4
    upstream {
        alih3: 'h3://223.5.5.5:443'
        googleh3: 'h3://8.8.8.8:443'
    }
    routing {
        request {
            qname(suffix: lan) -> asis
            qname(geosite:category-ads-all) -> reject
            qname(geosite:cn) -> alih3
            fallback: googleh3
        }
    }
}

group {
    proxy {
        policy: fixed(0)
    }
}

routing {
    pname(NetworkManager, systemd-resolved, dnsmasq) -> must_direct
    dip(224.0.0.0/3, 'ff00::/8') -> direct
    dip(geoip:private) -> direct
    dip(geoip:cn) -> direct
    domain(geosite:cn) -> direct
    fallback: proxy
}

@jiaming-shi

Copy link
Copy Markdown
Author

@olicesx 2.0.0rc1 验证没有问题,之前忘记把 auto_config_kernel_parameter 改成 true 了

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

Successfully merging this pull request may close these issues.

2 participants