Compare commits
2 Commits
b8c7c5bee8
...
00f55788c2
Author | SHA1 | Date | |
---|---|---|---|
00f55788c2 | |||
f1d6bf7b1b |
19
dial.go
19
dial.go
@ -6,7 +6,9 @@ import "crypto/tls"
|
||||
import "github.com/quic-go/quic-go"
|
||||
|
||||
// Dial opens a connection to a server. The network must be one of "quic",
|
||||
// "quic4", (IPv4-only) "quic6" (IPv6-only), or "unix".
|
||||
// "quic4", (IPv4-only) "quic6" (IPv6-only), or "unix". For now, "quic4" and
|
||||
// "quic6" don't do anything as the quic-go package doesn't seem to support this
|
||||
// behavior.
|
||||
func Dial(ctx context.Context, network, address string) (Conn, error) {
|
||||
return (Dialer { }).Dial(ctx, network, address)
|
||||
}
|
||||
@ -17,7 +19,9 @@ type Dialer struct {
|
||||
}
|
||||
|
||||
// Dial opens a connection to a server. The network must be one of "quic",
|
||||
// "quic4", (IPv4-only) "quic6" (IPv6-only), or "unix".
|
||||
// "quic4", (IPv4-only) "quic6" (IPv6-only), or "unix". For now, "quic4" and
|
||||
// "quic6" don't do anything as the quic-go package doesn't seem to support this
|
||||
// behavior.
|
||||
func (diale Dialer) Dial(ctx context.Context, network, address string) (Conn, error) {
|
||||
switch network {
|
||||
case "quic", "quic4", "quic6": return diale.dialQUIC(ctx, network, address)
|
||||
@ -27,13 +31,10 @@ func (diale Dialer) Dial(ctx context.Context, network, address string) (Conn, er
|
||||
}
|
||||
|
||||
func (diale Dialer) dialQUIC(ctx context.Context, network, address string) (Conn, error) {
|
||||
udpNetwork, err := quicNetworkToUDPNetwork(network)
|
||||
if err != nil { return nil, err }
|
||||
addr, err := net.ResolveUDPAddr(udpNetwork, address)
|
||||
if err != nil { return nil, err }
|
||||
udpConn, err := net.DialUDP(udpNetwork, nil, addr)
|
||||
if err != nil { return nil, err }
|
||||
conn, err := quic.Dial(ctx, udpConn, addr, tlsConfig(diale.TLSConfig), quicConfig())
|
||||
// sorry i fucking lied to you about the network parameter. for all
|
||||
// quic-go's bullshit bloat, it doesnt even support that. not even when
|
||||
// instantiating a transport. go figure :/
|
||||
conn, err := quic.DialAddr(ctx, address, tlsConfig(diale.TLSConfig), quicConfig())
|
||||
if err != nil { return nil, err }
|
||||
return AdaptB(quicMultiConn { underlying: conn }), nil
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user