runner: Clear remaining warnings from gopls This clears some of the sea of yellow in my editor: - WriteTo collided with a method in some common interface - foo.Sub(time.Now()) now has a time.Until() helper - byte(foo) >> 8 should have been byte(foo >> 8) - Some constant lacked a type - Unused function Change-Id: Ie5d6e53aa5988deaec8f9fdf9db90be4eb593e90 Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/101868 Commit-Queue: David Benjamin <davidben@google.com> Auto-Submit: David Benjamin <davidben@google.com> Reviewed-by: Adam Langley <agl@google.com>
diff --git a/ssl/test/runner/common.go b/ssl/test/runner/common.go index c9952c3..f364753 100644 --- a/ssl/test/runner/common.go +++ b/ssl/test/runner/common.go
@@ -362,7 +362,7 @@ // SRTP protection profiles (See RFC 5764, section 4.1.2) const ( SRTP_AES128_CM_HMAC_SHA1_80 uint16 = 0x0001 - SRTP_AES128_CM_HMAC_SHA1_32 = 0x0002 + SRTP_AES128_CM_HMAC_SHA1_32 uint16 = 0x0002 ) // PskKeyExchangeMode values (see RFC 8446, section 4.2.9)
diff --git a/ssl/test/runner/recordingconn.go b/ssl/test/runner/recordingconn.go index df90623..a1fb5ce 100644 --- a/ssl/test/runner/recordingconn.go +++ b/ssl/test/runner/recordingconn.go
@@ -15,14 +15,10 @@ package runner import ( - "bufio" "encoding/hex" - "errors" "fmt" "io" "net" - "strconv" - "strings" "sync" ) @@ -85,8 +81,8 @@ r.appendFlow(specialFlow, message, data) } -// WriteTo writes hex dumps to w that contains the recorded traffic. -func (r *recordingConn) WriteTo(w io.Writer) { +// WriteFlowsTo writes hex dumps to w that contains the recorded traffic. +func (r *recordingConn) WriteFlowsTo(w io.Writer) { fmt.Fprintf(w, ">>> runner is %s, shim is %s\n", r.local, r.peer) for i, flow := range r.flows { switch flow.flowType { @@ -120,52 +116,3 @@ } return ret } - -func parseTestData(r io.Reader) (flows [][]byte, err error) { - var currentFlow []byte - - scanner := bufio.NewScanner(r) - for scanner.Scan() { - line := scanner.Text() - // If the line starts with ">>> " then it marks the beginning - // of a new flow. - if strings.HasPrefix(line, ">>> ") { - if len(currentFlow) > 0 || len(flows) > 0 { - flows = append(flows, currentFlow) - currentFlow = nil - } - continue - } - - // Otherwise the line is a line of hex dump that looks like: - // 00000170 fc f5 06 bf (...) |.....X{&?......!| - // (Some bytes have been omitted from the middle section.) - - if i := strings.IndexByte(line, ' '); i >= 0 { - line = line[i:] - } else { - return nil, errors.New("invalid test data") - } - - if i := strings.IndexByte(line, '|'); i >= 0 { - line = line[:i] - } else { - return nil, errors.New("invalid test data") - } - - hexBytes := strings.FieldsSeq(line) - for hexByte := range hexBytes { - val, err := strconv.ParseUint(hexByte, 16, 8) - if err != nil { - return nil, errors.New("invalid hex byte in test data: " + err.Error()) - } - currentFlow = append(currentFlow, byte(val)) - } - } - - if len(currentFlow) > 0 { - flows = append(flows, currentFlow) - } - - return flows, nil -}
diff --git a/ssl/test/runner/runner.go b/ssl/test/runner/runner.go index 80745eb..5862261 100644 --- a/ssl/test/runner/runner.go +++ b/ssl/test/runner/runner.go
@@ -221,8 +221,8 @@ ) var ( - testOCSPExtension = append([]byte{byte(extensionStatusRequest) >> 8, byte(extensionStatusRequest), 0, 8, statusTypeOCSP, 0, 0, 4}, testOCSPResponse...) - testSCTExtension = append([]byte{byte(extensionSignedCertificateTimestamp) >> 8, byte(extensionSignedCertificateTimestamp), 0, byte(len(testSCTList))}, testSCTList...) + testOCSPExtension = append([]byte{byte(extensionStatusRequest >> 8), byte(extensionStatusRequest), 0, 8, statusTypeOCSP, 0, 0, 4}, testOCSPResponse...) + testSCTExtension = append([]byte{byte(extensionSignedCertificateTimestamp >> 8), byte(extensionSignedCertificateTimestamp), 0, byte(len(testSCTList))}, testSCTList...) ) var ( @@ -813,7 +813,7 @@ } conn = connDebug if *flagDebug { - defer connDebug.WriteTo(os.Stdout) + defer connDebug.WriteFlowsTo(os.Stdout) } if *transcriptDir != "" { defer func() {
diff --git a/ssl/test/runner/tls.go b/ssl/test/runner/tls.go index b2b35a3..f2e386f 100644 --- a/ssl/test/runner/tls.go +++ b/ssl/test/runner/tls.go
@@ -103,7 +103,7 @@ timeout := dialer.Timeout if !dialer.Deadline.IsZero() { - deadlineTimeout := dialer.Deadline.Sub(time.Now()) + deadlineTimeout := time.Until(dialer.Deadline) if timeout == 0 || deadlineTimeout < timeout { timeout = deadlineTimeout }