-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add uTLS support in measurexlite (#918)
Closes ooni/probe#2253 Co-authored-by: decfox <decfox@github.com>
- Loading branch information
Showing
4 changed files
with
136 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package measurexlite | ||
|
||
import ( | ||
"github.com/ooni/probe-cli/v3/internal/model" | ||
utls "gitlab.com/yawning/utls.git" | ||
) | ||
|
||
// NewTLSHandshakerUTLS is equivalent to netxlite.NewTLSHandshakerUTLS | ||
// except that it returns a model.TLSHandshaker that uses this trace. | ||
func (tx *Trace) NewTLSHandshakerUTLS(dl model.DebugLogger, id *utls.ClientHelloID) model.TLSHandshaker { | ||
return &tlsHandshakerTrace{ | ||
thx: tx.newTLSHandshakerUTLS(dl, id), | ||
tx: tx, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package measurexlite | ||
|
||
import ( | ||
"testing" | ||
"time" | ||
|
||
"github.com/ooni/probe-cli/v3/internal/model" | ||
"github.com/ooni/probe-cli/v3/internal/model/mocks" | ||
utls "gitlab.com/yawning/utls.git" | ||
) | ||
|
||
func TestNewTLSHandshakerUTLS(t *testing.T) { | ||
t.Run("NewTLSHandshakerUTLS creates a wrapped TLSHandshaker", func(t *testing.T) { | ||
underlying := &mocks.TLSHandshaker{} | ||
zeroTime := time.Now() | ||
trace := NewTrace(0, zeroTime) | ||
trace.NewTLSHandshakerUTLSFn = func(dl model.DebugLogger, id *utls.ClientHelloID) model.TLSHandshaker { | ||
return underlying | ||
} | ||
thx := trace.NewTLSHandshakerUTLS(model.DiscardLogger, &utls.HelloGolang) | ||
thxt := thx.(*tlsHandshakerTrace) | ||
if thxt.thx != underlying { | ||
t.Fatal("invalid TLS handshaker") | ||
} | ||
if thxt.tx != trace { | ||
t.Fatal("invalid trace") | ||
} | ||
}) | ||
} |