Break out default TLS and QUIC configs
This commit is contained in:
parent
b6d6b1d777
commit
06d5e60341
15
dial.go
15
dial.go
@ -33,7 +33,7 @@ func (diale Dialer) dialQUIC(ctx context.Context, network, address string) (Conn
|
|||||||
if err != nil { return nil, err }
|
if err != nil { return nil, err }
|
||||||
udpConn, err := net.DialUDP(udpNetwork, nil, addr)
|
udpConn, err := net.DialUDP(udpNetwork, nil, addr)
|
||||||
if err != nil { return nil, err }
|
if err != nil { return nil, err }
|
||||||
conn, err := quic.Dial(ctx, udpConn, addr, diale.tlsConfig(), diale.quicConfig())
|
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
|
||||||
}
|
}
|
||||||
@ -44,21 +44,22 @@ func (diale Dialer) dialUnix(ctx context.Context, network, address string) (Conn
|
|||||||
if err != nil { return nil, err }
|
if err != nil { return nil, err }
|
||||||
conn, err := net.DialUnix(network, nil, addr)
|
conn, err := net.DialUnix(network, nil, addr)
|
||||||
if err != nil { return nil, err }
|
if err != nil { return nil, err }
|
||||||
// REMEMBER - THIS IS VERY IMPORTANT:
|
|
||||||
// WHEN YOU INEVITABLY COPY PASTE THIS FOR THE SERVER-SIDE, CHANGE THE
|
|
||||||
// PARTY CONSTANT TO ServerSide! OTHERWISE THERE WILL BE COLLISIONS!
|
|
||||||
return AdaptA(conn, ClientSide), nil
|
return AdaptA(conn, ClientSide), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (diale Dialer) tlsConfig() *tls.Config {
|
func tlsConfig(conf *tls.Config) *tls.Config {
|
||||||
conf := diale.TLSConfig.Clone()
|
if conf == nil {
|
||||||
|
conf = &tls.Config { }
|
||||||
|
} else {
|
||||||
|
conf = conf.Clone()
|
||||||
|
}
|
||||||
conf.NextProtos = []string {
|
conf.NextProtos = []string {
|
||||||
"HOPP/0",
|
"HOPP/0",
|
||||||
}
|
}
|
||||||
return conf
|
return conf
|
||||||
}
|
}
|
||||||
|
|
||||||
func (diale Dialer) quicConfig() *quic.Config {
|
func quicConfig() *quic.Config {
|
||||||
return &quic.Config {
|
return &quic.Config {
|
||||||
// TODO: perhaps we might want to put something here
|
// TODO: perhaps we might want to put something here
|
||||||
// the quic config shouldn't be exported, just set up
|
// the quic config shouldn't be exported, just set up
|
||||||
|
Loading…
Reference in New Issue
Block a user