Skip to content

Commit

Permalink
Merge pull request quic-go#1942 from lucas-clemente/token-expiry-time
Browse files Browse the repository at this point in the history
reduce the Retry token expiry time to 10 seconds
  • Loading branch information
marten-seemann authored Jun 2, 2019
2 parents 4e709ef + 1873503 commit 7fbae1c
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ type Config struct {
IdleTimeout time.Duration
// AcceptToken determines if a Token is accepted.
// It is called with token = nil if the client didn't send a token.
// If not set, it verifies that the address matches, and that the token was issued within the last 24 hours.
// If not set, it verifies that the address matches, and that the token was issued within the last 5 seconds.
// This option is only valid for the server.
AcceptToken func(clientAddr net.Addr, token *Token) bool
// MaxReceiveStreamFlowControlWindow is the maximum stream-level flow control window for receiving data.
Expand Down
4 changes: 2 additions & 2 deletions internal/protocol/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ const MaxTrackedSkippedPackets = 10
// If the queue is full, new connection attempts will be rejected.
const MaxAcceptQueueSize = 32

// TokenExpiryTime is the valid time of a token
const TokenExpiryTime = 24 * time.Hour
// RetryTokenValidity is the duration that a retry token is considered valid
const RetryTokenValidity = 10 * time.Second

// MaxOutstandingSentPackets is maximum number of packets saved for retransmission.
// When reached, it imposes a soft limit on sending new packets:
Expand Down
2 changes: 1 addition & 1 deletion server.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ var defaultAcceptToken = func(clientAddr net.Addr, token *Token) bool {
if token == nil {
return false
}
if time.Now().After(token.SentTime.Add(protocol.TokenExpiryTime)) {
if time.Now().After(token.SentTime.Add(protocol.RetryTokenValidity)) {
return false
}
var sourceAddr string
Expand Down
4 changes: 2 additions & 2 deletions server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,7 @@ var _ = Describe("default source address verification", func() {
remoteAddr := &net.UDPAddr{IP: net.IPv4(192, 168, 0, 1)}
token := &Token{
RemoteAddr: "192.168.0.1",
SentTime: time.Now().Add(-protocol.TokenExpiryTime).Add(time.Second), // will expire in 1 second
SentTime: time.Now().Add(-protocol.RetryTokenValidity).Add(time.Second), // will expire in 1 second
}
Expect(defaultAcceptToken(remoteAddr, token)).To(BeTrue())
})
Expand Down Expand Up @@ -586,7 +586,7 @@ var _ = Describe("default source address verification", func() {
remoteAddr := &net.UDPAddr{IP: net.IPv4(192, 168, 0, 1)}
token := &Token{
RemoteAddr: "192.168.0.1",
SentTime: time.Now().Add(-protocol.TokenExpiryTime).Add(-time.Second), // expired 1 second ago
SentTime: time.Now().Add(-protocol.RetryTokenValidity).Add(-time.Second), // expired 1 second ago
}
Expect(defaultAcceptToken(remoteAddr, token)).To(BeFalse())
})
Expand Down

0 comments on commit 7fbae1c

Please sign in to comment.