use new time API
R=bradfitz, gri, r, dsymonds CC=golang-dev https://golang.org/cl/5390042
This commit is contained in:
parent
ff828b16dd
commit
37bb6649e2
@ -121,7 +121,7 @@ type Config struct {
|
||||
|
||||
// Time returns the current time as the number of seconds since the epoch.
|
||||
// If Time is nil, TLS uses the system time.Seconds.
|
||||
Time func() int64
|
||||
Time func() time.Time
|
||||
|
||||
// Certificates contains one or more certificate chains
|
||||
// to present to the other side of the connection.
|
||||
@ -175,10 +175,10 @@ func (c *Config) rand() io.Reader {
|
||||
return r
|
||||
}
|
||||
|
||||
func (c *Config) time() int64 {
|
||||
func (c *Config) time() time.Time {
|
||||
t := c.Time
|
||||
if t == nil {
|
||||
t = time.Seconds
|
||||
t = time.Now
|
||||
}
|
||||
return t()
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ func (c *Conn) clientHandshake() error {
|
||||
nextProtoNeg: len(c.config.NextProtos) > 0,
|
||||
}
|
||||
|
||||
t := uint32(c.config.time())
|
||||
t := uint32(c.config.time().Unix())
|
||||
hello.random[0] = byte(t >> 24)
|
||||
hello.random[1] = byte(t >> 16)
|
||||
hello.random[2] = byte(t >> 8)
|
||||
|
@ -95,7 +95,7 @@ FindCipherSuite:
|
||||
|
||||
hello.vers = vers
|
||||
hello.cipherSuite = suite.id
|
||||
t := uint32(config.time())
|
||||
t := uint32(config.time().Unix())
|
||||
hello.random = make([]byte, 32)
|
||||
hello.random[0] = byte(t >> 24)
|
||||
hello.random[1] = byte(t >> 16)
|
||||
|
@ -15,6 +15,7 @@ import (
|
||||
"strconv"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
type zeroSource struct{}
|
||||
@ -31,7 +32,7 @@ var testConfig *Config
|
||||
|
||||
func init() {
|
||||
testConfig = new(Config)
|
||||
testConfig.Time = func() int64 { return 0 }
|
||||
testConfig.Time = func() time.Time { return time.Unix(0, 0) }
|
||||
testConfig.Rand = zeroSource{}
|
||||
testConfig.Certificates = make([]Certificate, 1)
|
||||
testConfig.Certificates[0].Certificate = [][]byte{testCertificate}
|
||||
|
Loading…
Reference in New Issue
Block a user