chore: upgrade deps and attempt to enable using go1.19 (#869)
* upgrade to our go.mod enabled of psiphon-tunnel-core such that we're now using v2.0.24 of the tunnel-core; * upgrade to the latest lucas-clemente/quic-go release; * upgrade to the latest ooni/oohttp release (which is based on go1.19 but the diff seems good enough to continue using go1.18.x as well); * upgrade to the latest ooni/oocrypto release (for which we can make the same remarks regarding using go1.18.x); * deal with changes in lucas-clemente/quic-go API as well as changes in what a go1.19 *tls.Conn compatible type should look like. Unfortunately, we cannot switch to go1.19 because psiphon forks quic-go and their fork's still not building using such a version of go. Part of ooni/probe#2211.
This commit is contained in:
@@ -24,17 +24,19 @@ func (ql *QUICListener) Listen(addr *net.UDPAddr) (model.UDPLikeConn, error) {
|
||||
// QUICDialer is a mockable netxlite.QUICDialer.
|
||||
type QUICDialer struct {
|
||||
// MockDialContext allows mocking DialContext.
|
||||
MockDialContext func(ctx context.Context, network, address string,
|
||||
MockDialContext func(ctx context.Context, address string,
|
||||
tlsConfig *tls.Config, quicConfig *quic.Config) (quic.EarlyConnection, error)
|
||||
|
||||
// MockCloseIdleConnections allows mocking CloseIdleConnections.
|
||||
MockCloseIdleConnections func()
|
||||
}
|
||||
|
||||
var _ model.QUICDialer = &QUICDialer{}
|
||||
|
||||
// DialContext calls MockDialContext.
|
||||
func (qcd *QUICDialer) DialContext(ctx context.Context, network, address string,
|
||||
func (qcd *QUICDialer) DialContext(ctx context.Context, address string,
|
||||
tlsConfig *tls.Config, quicConfig *quic.Config) (quic.EarlyConnection, error) {
|
||||
return qcd.MockDialContext(ctx, network, address, tlsConfig, quicConfig)
|
||||
return qcd.MockDialContext(ctx, address, tlsConfig, quicConfig)
|
||||
}
|
||||
|
||||
// CloseIdleConnections calls MockCloseIdleConnections.
|
||||
|
||||
@@ -37,14 +37,14 @@ func TestQUICDialer(t *testing.T) {
|
||||
t.Run("DialContext", func(t *testing.T) {
|
||||
expected := errors.New("mocked error")
|
||||
qcd := &QUICDialer{
|
||||
MockDialContext: func(ctx context.Context, network string, address string, tlsConfig *tls.Config, quicConfig *quic.Config) (quic.EarlyConnection, error) {
|
||||
MockDialContext: func(ctx context.Context, address string, tlsConfig *tls.Config, quicConfig *quic.Config) (quic.EarlyConnection, error) {
|
||||
return nil, expected
|
||||
},
|
||||
}
|
||||
ctx := context.Background()
|
||||
tlsConfig := &tls.Config{}
|
||||
quicConfig := &quic.Config{}
|
||||
qconn, err := qcd.DialContext(ctx, "udp", "dns.google:443", tlsConfig, quicConfig)
|
||||
qconn, err := qcd.DialContext(ctx, "dns.google:443", tlsConfig, quicConfig)
|
||||
if !errors.Is(err, expected) {
|
||||
t.Fatal("not the error we expected")
|
||||
}
|
||||
|
||||
@@ -28,6 +28,9 @@ type TLSConn struct {
|
||||
|
||||
// MockHandshakeContext allows to mock the HandshakeContext method.
|
||||
MockHandshakeContext func(ctx context.Context) error
|
||||
|
||||
// MockNetConn returns the underlying net.Conn
|
||||
MockNetConn func() net.Conn
|
||||
}
|
||||
|
||||
// ConnectionState calls MockConnectionState.
|
||||
@@ -40,6 +43,11 @@ func (c *TLSConn) HandshakeContext(ctx context.Context) error {
|
||||
return c.MockHandshakeContext(ctx)
|
||||
}
|
||||
|
||||
// NetConn calls MockNetConn.
|
||||
func (c *TLSConn) NetConn() net.Conn {
|
||||
return c.MockNetConn()
|
||||
}
|
||||
|
||||
// TLSDialer allows to mock netxlite.TLSDialer.
|
||||
type TLSDialer struct {
|
||||
// MockCloseIdleConnections allows to mock the CloseIdleConnections method.
|
||||
|
||||
@@ -60,6 +60,18 @@ func TestTLSConn(t *testing.T) {
|
||||
t.Fatal("not the error we expected", err)
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("NetConn", func(t *testing.T) {
|
||||
conn := &Conn{}
|
||||
c := &TLSConn{
|
||||
MockNetConn: func() net.Conn {
|
||||
return conn
|
||||
},
|
||||
}
|
||||
if o := c.NetConn(); o != conn {
|
||||
t.Fatal("unexpected result")
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func TestTLSDialer(t *testing.T) {
|
||||
|
||||
@@ -204,7 +204,7 @@ type QUICDialer interface {
|
||||
// - set NextProtos to []string{"h3"}.
|
||||
//
|
||||
// Typically, you want to pass `&quic.Config{}` as quicConfig.
|
||||
DialContext(ctx context.Context, network, address string,
|
||||
DialContext(ctx context.Context, address string,
|
||||
tlsConfig *tls.Config, quicConfig *quic.Config) (quic.EarlyConnection, error)
|
||||
|
||||
// CloseIdleConnections closes idle connections, if any.
|
||||
|
||||
Reference in New Issue
Block a user