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:
Simone Basso 2021-09-06 20:56:14 +02:00 committed by GitHub
commit 3ba5626b95
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 209 additions and 21 deletions

View file

@ -60,3 +60,21 @@ func TestDialerLegacyAdapterDefaults(t *testing.T) {
r := NewDialerLegacyAdapter(&net.Dialer{})
r.CloseIdleConnections() // does not crash
}
func TestQUICContextDialerAdapterWithCompatibleType(t *testing.T) {
var called bool
d := NewQUICDialerFromContextDialerAdapter(&mocks.QUICDialer{
MockCloseIdleConnections: func() {
called = true
},
})
d.CloseIdleConnections()
if !called {
t.Fatal("not called")
}
}
func TestQUICContextDialerAdapterDefaults(t *testing.T) {
d := NewQUICDialerFromContextDialerAdapter(&mocks.QUICContextDialer{})
d.CloseIdleConnections() // does not crash
}