Skip to content

Commit

Permalink
Update echcheck test to 0.2.0 placing tls_handshakes into list
Browse files Browse the repository at this point in the history
* Update TLSHandshake model to include ECHConfig field
* Update tests
  • Loading branch information
hellais committed Nov 7, 2024
1 parent a0568bb commit 3fa848b
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 10 deletions.
4 changes: 3 additions & 1 deletion internal/experiment/echcheck/handshake.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ func handshakeWithEch(ctx context.Context, conn net.Conn, zeroTime time.Time,
utlsEchExtension.Id = echExtensionType
utlsEchExtension.Data = payload

return handshakeWithExtension(ctx, conn, zeroTime, address, sni, []utls.TLSExtension{&utlsEchExtension}, logger)
hs := handshakeWithExtension(ctx, conn, zeroTime, address, sni, []utls.TLSExtension{&utlsEchExtension}, logger)
hs.ECHConfig = "GREASE"
return hs
}

func handshakeMaybePrintWithECH(doprint bool) string {
Expand Down
7 changes: 3 additions & 4 deletions internal/experiment/echcheck/measure.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (

const (
testName = "echcheck"
testVersion = "0.1.2"
testVersion = "0.2.0"
defaultURL = "https://cloudflare-ech.com/cdn-cgi/trace"
)

Expand All @@ -30,8 +30,7 @@ var (

// TestKeys contains echcheck test keys.
type TestKeys struct {
Control model.ArchivalTLSOrQUICHandshakeResult `json:"control"`
Target model.ArchivalTLSOrQUICHandshakeResult `json:"target"`
TLSHandshakes []*model.ArchivalTLSOrQUICHandshakeResult `json:"tls_handshakes"`
}

// Measurer performs the measurement.
Expand Down Expand Up @@ -124,7 +123,7 @@ func (m *Measurer) Run(
control := <-controlChannel
target := <-targetChannel

args.Measurement.TestKeys = TestKeys{Control: control, Target: target}
args.Measurement.TestKeys = TestKeys{TLSHandshakes: []*model.ArchivalTLSOrQUICHandshakeResult{&control, &target}}

return nil
}
Expand Down
13 changes: 8 additions & 5 deletions internal/experiment/echcheck/measure_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,13 @@ func TestMeasurementSuccessRealWorld(t *testing.T) {

// check results
tk := msrmnt.TestKeys.(TestKeys)
if tk.Control.Failure != nil {
t.Fatal("unexpected control failure:", *tk.Control.Failure)
}
if tk.Target.Failure != nil {
t.Fatal("unexpected target failure:", *tk.Target.Failure)
for _, hs := range tk.TLSHandshakes {
if hs.Failure != nil {
if hs.ECHConfig == "GREASE" {
t.Fatal("unexpected exp failure:", hs.Failure)
} else {
t.Fatal("unexpected ctrl failure:", hs.Failure)
}
}
}
}
1 change: 1 addition & 0 deletions internal/model/archival.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ type ArchivalTLSOrQUICHandshakeResult struct {
NoTLSVerify bool `json:"no_tls_verify"`
PeerCertificates []ArchivalBinaryData `json:"peer_certificates"`
ServerName string `json:"server_name"`
ECHConfig string `json:"echconfig,omitempty"`
T0 float64 `json:"t0,omitempty"`
T float64 `json:"t"`
Tags []string `json:"tags"`
Expand Down

0 comments on commit 3fa848b

Please sign in to comment.