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"
|
import "github.com/quic-go/quic-go"
|
||||||
|
|
||||||
// Dial opens a connection to a server. The network must be one of "quic",
|
// 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) {
|
func Dial(ctx context.Context, network, address string) (Conn, error) {
|
||||||
return (Dialer { }).Dial(ctx, network, address)
|
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",
|
// 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) {
|
func (diale Dialer) Dial(ctx context.Context, network, address string) (Conn, error) {
|
||||||
switch network {
|
switch network {
|
||||||
case "quic", "quic4", "quic6": return diale.dialQUIC(ctx, network, address)
|
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) {
|
func (diale Dialer) dialQUIC(ctx context.Context, network, address string) (Conn, error) {
|
||||||
udpNetwork, err := quicNetworkToUDPNetwork(network)
|
// sorry i fucking lied to you about the network parameter. for all
|
||||||
if err != nil { return nil, err }
|
// quic-go's bullshit bloat, it doesnt even support that. not even when
|
||||||
addr, err := net.ResolveUDPAddr(udpNetwork, address)
|
// instantiating a transport. go figure :/
|
||||||
if err != nil { return nil, err }
|
conn, err := quic.DialAddr(ctx, address, tlsConfig(diale.TLSConfig), quicConfig())
|
||||||
udpConn, err := net.DialUDP(udpNetwork, nil, addr)
|
|
||||||
if err != nil { return nil, err }
|
|
||||||
conn, err := quic.Dial(ctx, udpConn, addr, tlsConfig(diale.TLSConfig), quicConfig())
|
|
||||||
if err != nil { return nil, err }
|
if err != nil { return nil, err }
|
||||||
return AdaptB(quicMultiConn { underlying: conn }), nil
|
return AdaptB(quicMultiConn { underlying: conn }), nil
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user