feat: tlsmiddlebox experiment (#817)
See https://github.com/ooni/probe/issues/2124
This commit is contained in:
parent
b78b9aca51
commit
f2b88ddb4a
24 changed files with 1670 additions and 0 deletions
45
internal/engine/experiment/tlsmiddlebox/dialer.go
Normal file
45
internal/engine/experiment/tlsmiddlebox/dialer.go
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
package tlsmiddlebox
|
||||
|
||||
//
|
||||
// Custom TTL dialer
|
||||
//
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net"
|
||||
"time"
|
||||
|
||||
"github.com/ooni/probe-cli/v3/internal/model"
|
||||
"github.com/ooni/probe-cli/v3/internal/netxlite"
|
||||
)
|
||||
|
||||
const timeout time.Duration = 15 * time.Second
|
||||
|
||||
func NewDialerTTLWrapper() model.Dialer {
|
||||
return &dialerTTLWrapper{
|
||||
Dialer: &net.Dialer{Timeout: timeout},
|
||||
}
|
||||
}
|
||||
|
||||
// dialerTTLWrapper wraps errors and also returns a TTL wrapped conn
|
||||
type dialerTTLWrapper struct {
|
||||
Dialer model.SimpleDialer
|
||||
}
|
||||
|
||||
var _ model.Dialer = &dialerTTLWrapper{}
|
||||
|
||||
// DialContext implements model.Dialer.DialContext
|
||||
func (d *dialerTTLWrapper) DialContext(ctx context.Context, network string, address string) (net.Conn, error) {
|
||||
conn, err := d.Dialer.DialContext(ctx, network, address)
|
||||
if err != nil {
|
||||
return nil, netxlite.NewErrWrapper(netxlite.ClassifyGenericError, netxlite.ConnectOperation, err)
|
||||
}
|
||||
return &dialerTTLWrapperConn{
|
||||
Conn: conn,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// CloseIdleConnections implements model.Dialer.CloseIdleConnections
|
||||
func (d *dialerTTLWrapper) CloseIdleConnections() {
|
||||
// nothing to do here
|
||||
}
|
||||
Loading…
Reference in a new issue