uptoken

package
v0.0.0-...-303e327 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 22, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// TokenSize max size of token array
	// clusterID + vid + bid + count + time + size
	TokenSize = 4 + 4 + 10 + 5 + 5 + 5
)

Variables

This section is empty.

Functions

func EncodeToken

func EncodeToken(token UploadToken) string

EncodeToken encode token to string

Types

type UploadToken

type UploadToken struct {
	Data   [TokenSize]byte
	Offset uint8
}

UploadToken token between alloc and putat [0:8] hmac (8) first 8 bytes of sha1 summary [8:16] minBid (8) in the SliceInfo [16:20] count (4) in the SliceInfo [20:24] time (4) expired unix utc time, 0 means not expired

func DecodeToken

func DecodeToken(s string) UploadToken

DecodeToken decode token from string

func NewUploadToken

func NewUploadToken(clusterID proto.ClusterID, vid proto.Vid, bid proto.BlobID,
	count, size uint32, expiration time.Duration, secretKey []byte) UploadToken

NewUploadToken returns a token corresponding one SliceInfo in Location with expiration expiration = 0 means not expired forever

func (*UploadToken) IsValid

func (t *UploadToken) IsValid(clusterID proto.ClusterID, vid proto.Vid, bid proto.BlobID,
	size uint32, secretKey []byte) bool

IsValid returns the token is valid or not

func (*UploadToken) IsValidBid

func (t *UploadToken) IsValidBid(bid proto.BlobID) bool

IsValidBid returns the bid is valid or not

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL