Преглед изворни кода

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.
Chih-Hsuan Yen пре 4 година
родитељ
комит
11c57b9097
1 измењених фајлова са 4 додато и 1 уклоњено
  1. 4 1
      lib/connections/quic_dial.go

+ 4 - 1
lib/connections/quic_dial.go

@@ -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
 	}