forked from quic-go/quic-go
define a quic.TokenStore interface and provide a LRU implementation
This commit is contained in:
17
interface.go
17
interface.go
@@ -27,6 +27,23 @@ type Token struct {
|
||||
SentTime time.Time
|
||||
}
|
||||
|
||||
// A ClientToken is a token received by the client.
|
||||
// It can be used to skip address validation on future connection attempts.
|
||||
type ClientToken struct {
|
||||
data []byte
|
||||
}
|
||||
|
||||
type TokenStore interface {
|
||||
// Pop searches for a ClientToken associated with the given key.
|
||||
// Since tokens are not supposed to be reused, it must remove the token from the cache.
|
||||
// It returns nil when no token is found.
|
||||
Pop(key string) (token *ClientToken)
|
||||
|
||||
// Put adds a token to the cache with the given key. It might get called
|
||||
// multiple times in a connection.
|
||||
Put(key string, token *ClientToken)
|
||||
}
|
||||
|
||||
// An ErrorCode is an application-defined error code.
|
||||
// Valid values range between 0 and MAX_UINT62.
|
||||
type ErrorCode = protocol.ApplicationErrorCode
|
||||
|
||||
Reference in New Issue
Block a user