save the STK expiry time as a time.Duration

This commit is contained in:
Marten Seemann
2017-04-01 13:41:38 +07:00
parent 81985f44bd
commit 6cc6d49a10
3 changed files with 4 additions and 4 deletions

View File

@@ -281,7 +281,7 @@ func (h *cryptoSetupServer) verifySTK(stk []byte) bool {
utils.Debugf("STK invalid: %s", err.Error()) utils.Debugf("STK invalid: %s", err.Error())
return false return false
} }
if time.Now().After(stkTime.Add(protocol.STKExpiryTimeSec * time.Second)) { if time.Now().After(stkTime.Add(protocol.STKExpiryTime)) {
return false return false
} }
return true return true

View File

@@ -441,7 +441,7 @@ var _ = Describe("Server Crypto Setup", func() {
}) })
It("REJ messages that have an expired STK", func() { It("REJ messages that have an expired STK", func() {
cs.scfg.stkSource.(*mockStkSource).stkTime = time.Now().Add(-protocol.STKExpiryTimeSec * time.Second).Add(-time.Second) cs.scfg.stkSource.(*mockStkSource).stkTime = time.Now().Add(-protocol.STKExpiryTime).Add(-time.Second)
Expect(cs.isInchoateCHLO(fullCHLO, cert)).To(BeTrue()) Expect(cs.isInchoateCHLO(fullCHLO, cert)).To(BeTrue())
}) })

View File

@@ -84,8 +84,8 @@ const SkipPacketAveragePeriodLength PacketNumber = 500
// MaxTrackedSkippedPackets is the maximum number of skipped packet numbers the SentPacketHandler keep track of for Optimistic ACK attack mitigation // MaxTrackedSkippedPackets is the maximum number of skipped packet numbers the SentPacketHandler keep track of for Optimistic ACK attack mitigation
const MaxTrackedSkippedPackets = 10 const MaxTrackedSkippedPackets = 10
// STKExpiryTimeSec is the valid time of a source address token in seconds // STKExpiryTime is the valid time of a source address token
const STKExpiryTimeSec = 24 * 60 * 60 const STKExpiryTime = 24 * time.Hour
// MaxTrackedSentPackets is maximum number of sent packets saved for either later retransmission or entropy calculation // MaxTrackedSentPackets is maximum number of sent packets saved for either later retransmission or entropy calculation
const MaxTrackedSentPackets = 2 * DefaultMaxCongestionWindow const MaxTrackedSentPackets = 2 * DefaultMaxCongestionWindow