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
|
|
@ -2,7 +2,10 @@ package netxlite
|
|||
|
||||
import (
|
||||
"context"
|
||||
"crypto/tls"
|
||||
"net"
|
||||
|
||||
"github.com/lucas-clemente/quic-go"
|
||||
)
|
||||
|
||||
// These vars export internal names to legacy ooni/probe-cli code.
|
||||
|
|
@ -129,3 +132,39 @@ func (d *DialerLegacyAdapter) CloseIdleConnections() {
|
|||
ra.CloseIdleConnections()
|
||||
}
|
||||
}
|
||||
|
||||
// QUICContextDialer is a dialer for QUIC using Context.
|
||||
//
|
||||
// This is a LEGACY name. New code should use QUICDialer directly.
|
||||
//
|
||||
// Use NewQUICDialerFromContextDialerAdapter if you need to
|
||||
// adapt an existing QUICContextDialer to a QUICDialer.
|
||||
type QUICContextDialer interface {
|
||||
// DialContext establishes a new QUIC session using the given
|
||||
// network and address. The tlsConfig and the quicConfig arguments
|
||||
// MUST NOT be nil. Returns either the session or an error.
|
||||
DialContext(ctx context.Context, network, address string,
|
||||
tlsConfig *tls.Config, quicConfig *quic.Config) (quic.EarlySession, error)
|
||||
}
|
||||
|
||||
// NewQUICDialerFromContextDialerAdapter creates a new
|
||||
// QUICDialer from a QUICContextDialer.
|
||||
func NewQUICDialerFromContextDialerAdapter(d QUICContextDialer) QUICDialer {
|
||||
return &QUICContextDialerAdapter{d}
|
||||
}
|
||||
|
||||
// QUICContextDialerAdapter adapta a QUICContextDialer to be a QUICDialer.
|
||||
type QUICContextDialerAdapter struct {
|
||||
QUICContextDialer
|
||||
}
|
||||
|
||||
type quicContextDialerConnectionsCloser interface {
|
||||
CloseIdleConnections()
|
||||
}
|
||||
|
||||
// CloseIdleConnections implements QUICDialer.CloseIdleConnections.
|
||||
func (d *QUICContextDialerAdapter) CloseIdleConnections() {
|
||||
if o, ok := d.QUICContextDialer.(quicContextDialerConnectionsCloser); ok {
|
||||
o.CloseIdleConnections()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue