mirror of
https://github.com/netbirdio/netbird.git
synced 2025-08-19 03:16:58 +02:00
Use custom dialer in QUIC
This commit is contained in:
@@ -10,6 +10,8 @@ import (
|
|||||||
|
|
||||||
"github.com/quic-go/quic-go"
|
"github.com/quic-go/quic-go"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
|
|
||||||
|
nbnet "github.com/netbirdio/netbird/util/net"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -36,9 +38,19 @@ func Dial(address string) (net.Conn, error) {
|
|||||||
EnableDatagrams: true,
|
EnableDatagrams: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
// todo add support for custom dialer
|
udpConn, err := nbnet.ListenUDP("udp", &net.UDPAddr{IP: net.IPv4zero, Port: 0})
|
||||||
|
if err != nil {
|
||||||
|
log.Errorf("failed to listen on UDP: %s", err)
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
session, err := quic.DialAddr(ctx, quicURL, tlsConf, quicConfig)
|
udpAddr, err := net.ResolveUDPAddr("udp", quicURL)
|
||||||
|
if err != nil {
|
||||||
|
log.Errorf("failed to resolve UDP address: %s", err)
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
session, err := quic.Dial(ctx, udpConn, udpAddr, tlsConf, quicConfig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorf("failed to dial to Relay server via QUIC '%s': %s", quicURL, err)
|
log.Errorf("failed to dial to Relay server via QUIC '%s': %s", quicURL, err)
|
||||||
return nil, err
|
return nil, err
|
||||||
|
Reference in New Issue
Block a user