Compare commits
No commits in common. "00f55788c2228abc2b6961ad1e3ac9627a15c506" and "b8c7c5bee8068c65d82eafd9952bb904af95d035" have entirely different histories.
00f55788c2
...
b8c7c5bee8
19
dial.go
19
dial.go
@ -6,9 +6,7 @@ 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". For now, "quic4" and
|
// "quic4", (IPv4-only) "quic6" (IPv6-only), or "unix".
|
||||||
// "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)
|
||||||
}
|
}
|
||||||
@ -19,9 +17,7 @@ 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". For now, "quic4" and
|
// "quic4", (IPv4-only) "quic6" (IPv6-only), or "unix".
|
||||||
// "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)
|
||||||
@ -31,10 +27,13 @@ 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) {
|
||||||
// sorry i fucking lied to you about the network parameter. for all
|
udpNetwork, err := quicNetworkToUDPNetwork(network)
|
||||||
// quic-go's bullshit bloat, it doesnt even support that. not even when
|
if err != nil { return nil, err }
|
||||||
// instantiating a transport. go figure :/
|
addr, err := net.ResolveUDPAddr(udpNetwork, address)
|
||||||
conn, err := quic.DialAddr(ctx, address, tlsConfig(diale.TLSConfig), quicConfig())
|
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())
|
||||||
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