feat(netxlite): add CloseIdleConnections to quic dialer (#469)
Like before, do not touch the rest of the tree. Rather create compatibility types declared as legacy. We will soon be able to close idle connections for an HTTP3 transport using any kind of resolvers more easily. See https://github.com/ooni/probe/issues/1591
This commit is contained in:
parent
aa77867145
commit
3ba5626b95
10 changed files with 209 additions and 21 deletions
29
internal/netxlite/mocks/legacy_test.go
Normal file
29
internal/netxlite/mocks/legacy_test.go
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
package mocks
|
||||
|
||||
import (
|
||||
"context"
|
||||
"crypto/tls"
|
||||
"errors"
|
||||
"testing"
|
||||
|
||||
"github.com/lucas-clemente/quic-go"
|
||||
)
|
||||
|
||||
func TestQUICContextDialerDialContext(t *testing.T) {
|
||||
expected := errors.New("mocked error")
|
||||
qcd := &QUICContextDialer{
|
||||
MockDialContext: func(ctx context.Context, network string, address string, tlsConfig *tls.Config, quicConfig *quic.Config) (quic.EarlySession, error) {
|
||||
return nil, expected
|
||||
},
|
||||
}
|
||||
ctx := context.Background()
|
||||
tlsConfig := &tls.Config{}
|
||||
quicConfig := &quic.Config{}
|
||||
sess, err := qcd.DialContext(ctx, "udp", "dns.google:443", tlsConfig, quicConfig)
|
||||
if !errors.Is(err, expected) {
|
||||
t.Fatal("not the error we expected")
|
||||
}
|
||||
if sess != nil {
|
||||
t.Fatal("expected nil session")
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue