Open Zoey2936 opened 1 year ago
Thanks for the report, and for investigating -- we'll look into this soon, or anyone else is welcome to take a stab at it too.
I think with update 4, the problem should now be clear
Can I ask what the actually wanted behaivior is? Is it wanted that 0.0.0.0 included [::]/[::] inclued 0.0.0.0, since this makes no sense to me? If I say I want to bind 0.0.0.0 then I don't want to bind [::] (and the other way, wanting to bind [::] and NOT 0.0.0.0). So will this be fixed by saying 0.0.0.0 only means IPv4 and [::] only IPv6 or will it be fixed by fixing the double binding on udp?
Yeah I think that's correct, it should only bind for the same IP version as explicitly specified.
The IPv6 address space does include the IPv4 address space, e.g. ::ffff:192.168.0.1
. Nevertheless, it makes sense to interpret [::]
as IPv6-only. 0.0.0.0
should never be considered equivalent to [::]
though. Changing that means fighting Go's standard library a bit: https://github.com/golang/go/issues/48723.
I'm in agreement; we can use tcp4 or tcp6 network strings accordingly. Even though ipv6 includes ipv4 address space, I don't think that's what users intend when they express a bind address that way.
Hello, if I run one of this Caddyfiles:
it results in (the first caddyfile):
But if I remove
h3
from theprotocols
directive or if I remove thedefault_bind
directive, it works. The same errors appear if I usebind 0.0.0.0 [::]
inside theexample.com
host instead of setting thedefault_bind
directive as a global option. And yes, UDP on port 443 is not used, I've tested it inside docker alpine, WSL Debian and alpine. netstat output on Debian WSL:(sorry for the edits, but I've tried to make the caddyfile smaller, so it can be clearly seen where the problem is)
Update 1: these caddyfiles also work, so it seems that the crash only appears with multiple bind IPs:
Update 2: these caddyfiles also don't work:
Error: loading initial config: loading new config: http app module: start: listen udp 0.0.0.0:443: bind: address already in use
- it seems like[::]
is handles by caddy on UDP as "all" IPv4 and IPv6 IPs, even if it should only handle "all" IPv6 IPs. Not sure if0.0.0.0
is also handled as IPv6Error: loading initial config: loading new config: http app module: start: listen udp [::1]:443: bind: address already in use
Update 3: this caddy file works, so maybe
0.0.0.0
already includes[::]
in UDP while[::]
included0.0.0.0
in UDP, so that if0.0.0.0 [::]
is used, it tries to bind0.0.0.0
and[::]
twice (or at least using [::] includes [::] AND 0.0.0.0)? (again, only in udp/h3 with h3 disabled, all caddyfiles I showed here work.) So Caddy handles tcp and udp binds differently?:Update 4: Interesting 0.0.0.0 seems to include [::] on TCP AND UDP and [::] also seems to include 0.0.0.0 on TCP AND UDP, but only on UDP it causes double binding, which causes a crash