lib/connections: Resolve IPv6 for quic6:// peers (fixes #7809) (#7810)

Before this patch, IPv4-compatible addresses (::ffff:aaa.bbb.ccc.ddd)
may be used if a quic6://some.domain:port is specified and both IPv4 and
IPv6 addresses exist for that domain name.
This commit is contained in:
Chih-Hsuan Yen 2021-07-05 19:19:56 +08:00 committed by GitHub
parent 1921533c4c
commit 11c57b9097
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 1 deletions

View File

@ -13,6 +13,7 @@ import (
"crypto/tls"
"net"
"net/url"
"strings"
"time"
"github.com/lucas-clemente/quic-go"
@ -45,7 +46,9 @@ type quicDialer struct {
func (d *quicDialer) Dial(ctx context.Context, _ protocol.DeviceID, uri *url.URL) (internalConn, error) {
uri = fixupPort(uri, config.DefaultQUICPort)
addr, err := net.ResolveUDPAddr("udp", uri.Host)
network := strings.ReplaceAll(uri.Scheme, "quic", "udp")
addr, err := net.ResolveUDPAddr(network, uri.Host)
if err != nil {
return internalConn{}, err
}