crypto/tls: fix WriteTo method signature

Give *recordingConn the correct WriteTo signature
to be an io.WriterTo. This makes vet happy.
It also means that it'll report errors,
which were previously being ignored.

Updates #11041

Change-Id: I13f171407d63f4b62427679bff362eb74faddca5
Reviewed-on: https://go-review.googlesource.com/27121
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
Josh Bleecher Snyder 2016-07-09 13:59:36 -07:00
parent 6a4ec07878
commit 8e34bdcdf7

View File

@ -88,21 +88,33 @@ func (r *recordingConn) Write(b []byte) (n int, err error) {
} }
// WriteTo writes Go source code to w that contains the recorded traffic. // WriteTo writes Go source code to w that contains the recorded traffic.
func (r *recordingConn) WriteTo(w io.Writer) { func (r *recordingConn) WriteTo(w io.Writer) (int64, error) {
// TLS always starts with a client to server flow. // TLS always starts with a client to server flow.
clientToServer := true clientToServer := true
var written int64
for i, flow := range r.flows { for i, flow := range r.flows {
source, dest := "client", "server" source, dest := "client", "server"
if !clientToServer { if !clientToServer {
source, dest = dest, source source, dest = dest, source
} }
fmt.Fprintf(w, ">>> Flow %d (%s to %s)\n", i+1, source, dest) n, err := fmt.Fprintf(w, ">>> Flow %d (%s to %s)\n", i+1, source, dest)
written += int64(n)
if err != nil {
return written, err
}
dumper := hex.Dumper(w) dumper := hex.Dumper(w)
dumper.Write(flow) n, err = dumper.Write(flow)
dumper.Close() written += int64(n)
if err != nil {
return written, err
}
err = dumper.Close()
if err != nil {
return written, err
}
clientToServer = !clientToServer clientToServer = !clientToServer
} }
return written, nil
} }
func parseTestData(r io.Reader) (flows [][]byte, err error) { func parseTestData(r io.Reader) (flows [][]byte, err error) {