Skip to content

Commit

Permalink
feat(netxlite): use *Netx for creating UTLS handshakers (#1256)
Browse files Browse the repository at this point in the history
While working on removing technical debt, as part of
ooni/probe#2531, it makes sense ensuring that
there is a single way of constructing netxlite types by always using an
instance of *Netx. This job is relatively easy because we are a couple
of patches away from achieving this goal and, by doing this, we would
avoid creating future technical debt. So, I am going to ahead and
implement this.
  • Loading branch information
bassosimone authored Sep 12, 2023
1 parent 2fc3866 commit abc0261
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions internal/netxlite/utls.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,20 @@ import (
// RootCAs field is zero initialized.
//
// Passing a nil `id` will make this function panic.
func NewTLSHandshakerUTLS(logger model.DebugLogger, id *utls.ClientHelloID) model.TLSHandshaker {
func (netx *Netx) NewTLSHandshakerUTLS(logger model.DebugLogger, id *utls.ClientHelloID) model.TLSHandshaker {
return newTLSHandshakerLogger(&tlsHandshakerConfigurable{
NewConn: newUTLSConnFactory(id),
NewConn: newUTLSConnFactory(id),
provider: netx.maybeCustomUnderlyingNetwork(),
}, logger)
}

// NewTLSHandshakerUTLS is equivalent to creating an empty [*Netx]
// and calling its NewTLSHandshakerUTLS method.
func NewTLSHandshakerUTLS(logger model.DebugLogger, id *utls.ClientHelloID) model.TLSHandshaker {
netx := &Netx{Underlying: nil}
return netx.NewTLSHandshakerUTLS(logger, id)
}

// UTLSConn implements TLSConn and uses a utls UConn as its underlying connection
type UTLSConn struct {
// We include the real UConn
Expand Down

0 comments on commit abc0261

Please sign in to comment.