storj

package
v0.22.2 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2019 License: AGPL-3.0 Imports: 23 Imported by: 0

Documentation

Overview

Package storj contains the types which represent the main entities of the Storj domain.

Index

Constants

View Source
const (
	// EncUnspecified indicates no encryption suite has been selected.
	EncUnspecified = CipherSuite(iota)
	// EncNull indicates use of the NULL cipher; that is, no encryption is
	// done. The ciphertext is equal to the plaintext.
	EncNull
	// EncAESGCM indicates use of AES128-GCM encryption.
	EncAESGCM
	// EncSecretBox indicates use of XSalsa20-Poly1305 encryption, as provided
	// by the NaCl cryptography library under the name "Secretbox".
	EncSecretBox
)
View Source
const (
	KeySize   = 32
	NonceSize = 24
)

Constant definitions for key and nonce sizes

View Source
const (
	// Before lists backwards from cursor, without cursor
	Before = ListDirection(-2)
	// Backward lists backwards from cursor, including cursor
	Backward = ListDirection(-1)
	// Forward lists forwards from cursor, including cursor
	Forward = ListDirection(1)
	// After lists forwards from cursor, without cursor
	After = ListDirection(2)
)
View Source
const (
	InvalidRedundancyAlgorithm = RedundancyAlgorithm(iota)
	ReedSolomon
)

List of supported redundancy algorithms

View Source
const NodeIDSize = sha256.Size

NodeIDSize is the byte length of a NodeID

View Source
const (
	// V0 represents identity version 0
	// NB: identities created before identity versioning (i.e. which don't have a
	// version extension; "legacy") will be recognized as V0.
	V0 = IDVersionNumber(iota)
)

Variables

View Source
var (
	// ErrBucket is an error class for general bucket errors
	ErrBucket = errs.Class("bucket")

	// ErrNoBucket is an error class for using empty bucket name
	ErrNoBucket = errs.Class("no bucket specified")

	// ErrBucketNotFound is an error class for non-existing bucket
	ErrBucketNotFound = errs.Class("bucket not found")
)
View Source
var (
	// IDVersions is a map of all identity versions
	IDVersions = map[IDVersionNumber]IDVersion{
		V0: {
			Number:        V0,
			NewPrivateKey: pkcrypto.GeneratePrivateKey,
		},
	}

	// IDVersionHandler compares the identity version of the remote peers
	// certificate chain to the extension options passed to the factory.
	IDVersionHandler = extensions.NewHandlerFactory(
		&extensions.IdentityVersionExtID, idVersionHandler,
	)
)
View Source
var (
	// ErrNodeID is used when something goes wrong with a node id.
	ErrNodeID = errs.Class("node ID error")
	// ErrVersion is used for identity version related errors.
	ErrVersion = errs.Class("node ID version error")
)
View Source
var (
	// ErrNoPath is an error class for using empty path
	ErrNoPath = errs.Class("no path specified")

	// ErrObjectNotFound is an error class for non-existing object
	ErrObjectNotFound = errs.Class("object not found")
)
View Source
var (
	// ErrNodeURL is used when something goes wrong with a node url.
	ErrNodeURL = errs.Class("node URL error")
)
View Source
var ErrNonce = errs.Class("nonce error")

ErrNonce is used when something goes wrong with a stream ID

View Source
var ErrPieceID = errs.Class("piece ID error")

ErrPieceID is used when something goes wrong with a piece ID

View Source
var ErrPieceKey = errs.Class("piece key error")

ErrPieceKey is used when something goes wrong with a piece key

View Source
var ErrSegmentID = errs.Class("segment ID error")

ErrSegmentID is used when something goes wrong with a segment ID

View Source
var ErrSerialNumber = errs.Class("serial number error")

ErrSerialNumber is used when something goes wrong with a serial number

View Source
var ErrStreamID = errs.Class("stream ID error")

ErrStreamID is used when something goes wrong with a stream ID

Functions

func IDVersionInVersions added in v0.9.0

func IDVersionInVersions(versionNumber IDVersionNumber, versionsStr string) error

IDVersionInVersions returns an error if the given version is in the given string of version(s)/range(s).

func NewPieceKey added in v0.15.0

func NewPieceKey() (PiecePublicKey, PiecePrivateKey, error)

NewPieceKey creates a piece key pair

func NewVersionExt added in v0.9.0

func NewVersionExt(version IDVersion) pkix.Extension

NewVersionExt creates a new identity version certificate extension for the given identity version,

func SplitPath

func SplitPath(path Path) []string

SplitPath splits path into a slice of path components

Types

type Bucket

type Bucket struct {
	ID                          uuid.UUID
	Name                        string
	ProjectID                   uuid.UUID
	PartnerID                   uuid.UUID
	Created                     time.Time
	PathCipher                  CipherSuite
	DefaultSegmentsSize         int64
	DefaultRedundancyScheme     RedundancyScheme
	DefaultEncryptionParameters EncryptionParameters
}

Bucket contains information about a specific bucket

type BucketList

type BucketList struct {
	More  bool
	Items []Bucket
}

BucketList is a list of buckets

type BucketListOptions

type BucketListOptions struct {
	Cursor    string
	Direction ListDirection
	Limit     int
}

BucketListOptions lists objects

func (BucketListOptions) NextPage

func (opts BucketListOptions) NextPage(list BucketList) BucketListOptions

NextPage returns options for listing the next page

type CipherSuite

type CipherSuite byte

CipherSuite specifies one of the encryption suites supported by Storj libraries for encryption of in-network data.

type CreateObject

type CreateObject struct {
	Metadata    map[string]string
	ContentType string
	Expires     time.Time

	RedundancyScheme
	EncryptionParameters
}

CreateObject has optional parameters that can be set

func (CreateObject) Object

func (create CreateObject) Object(bucket Bucket, path Path) Object

Object converts the CreateObject to an object with unitialized values

type EncryptedPrivateKey

type EncryptedPrivateKey []byte

EncryptedPrivateKey is a private key that has been encrypted

type EncryptionParameters

type EncryptionParameters struct {
	// CipherSuite specifies the cipher suite to be used for encryption.
	CipherSuite CipherSuite
	// BlockSize determines the unit size at which encryption is performed.
	// It is important to distinguish this from the block size used by the
	// cipher suite (probably 128 bits). There is some small overhead for
	// each encryption unit, so BlockSize should not be too small, but
	// smaller sizes yield shorter first-byte latency and better seek times.
	// Note that BlockSize itself is the size of data blocks _after_ they
	// have been encrypted and the authentication overhead has been added.
	// It is _not_ the size of the data blocks to _be_ encrypted.
	BlockSize int32
}

EncryptionParameters is the cipher suite and parameters used for encryption

func (EncryptionParameters) IsZero

func (params EncryptionParameters) IsZero() bool

IsZero returns true if no field in the struct is set to non-zero value

type IDVersion

type IDVersion struct {
	Number        IDVersionNumber
	NewPrivateKey func() (crypto.PrivateKey, error)
}

IDVersion holds fields that are used to distinguish different identity versions from one another; used in identity generation.

func GetIDVersion added in v0.9.0

func GetIDVersion(number IDVersionNumber) (IDVersion, error)

GetIDVersion looks up the given version number in the map of registered versions, returning an error if none is found.

func IDVersionFromCert added in v0.9.0

func IDVersionFromCert(cert *x509.Certificate) (IDVersion, error)

IDVersionFromCert parsed the IDVersion from the passed certificate's IDVersion extension.

func LatestIDVersion added in v0.9.0

func LatestIDVersion() IDVersion

LatestIDVersion returns the last IDVersion registered.

type IDVersionNumber added in v0.9.0

type IDVersionNumber uint8

IDVersionNumber is the number of an identity version.

type Key

type Key [KeySize]byte

Key represents the largest key used by any encryption protocol

func NewKey added in v0.12.0

func NewKey(humanReadableKey []byte) (*Key, error)

NewKey creates a new Storj key from humanReadableKey.

func (*Key) IsZero added in v0.12.0

func (key *Key) IsZero() bool

IsZero returns true if key is nil or it points to its zero value

func (*Key) Raw

func (key *Key) Raw() *[KeySize]byte

Raw returns the key as a raw byte array pointer

type LastSegment

type LastSegment struct {
	Size              int64
	EncryptedKeyNonce Nonce
	EncryptedKey      EncryptedPrivateKey
}

LastSegment contains info about last segment TODO: remove

type ListDirection

type ListDirection int8

ListDirection specifies listing direction

type ListOptions

type ListOptions struct {
	Prefix    Path
	Cursor    Path // Cursor is relative to Prefix, full path is Prefix + Cursor
	Delimiter rune
	Recursive bool
	Direction ListDirection
	Limit     int
}

ListOptions lists objects

func (ListOptions) NextPage

func (opts ListOptions) NextPage(list ObjectList) ListOptions

NextPage returns options for listing the next page

type Metainfo

type Metainfo interface {
	// Limits returns limits for this metainfo database
	Limits() (MetainfoLimits, error)

	// CreateBucket creates a new bucket with the specified information
	// Database automatically sets different values in the information
	CreateBucket(ctx context.Context, bucket string, info *Bucket) (Bucket, error)
	// DeleteBucket deletes bucket
	DeleteBucket(ctx context.Context, bucket string) error
	// GetBucket gets bucket information
	GetBucket(ctx context.Context, bucket string) (Bucket, error)
	// ListBuckets lists buckets starting from first
	ListBuckets(ctx context.Context, options BucketListOptions) (BucketList, error)

	// GetObject returns information about an object
	GetObject(ctx context.Context, bucket string, path Path) (Object, error)
	// GetObjectStream returns interface for reading the object stream
	GetObjectStream(ctx context.Context, bucket string, path Path) (ReadOnlyStream, error)

	// CreateObject creates a mutable object for uploading stream info
	CreateObject(ctx context.Context, bucket string, path Path, info *CreateObject) (MutableObject, error)
	// ModifyObject creates a mutable object for updating a partially uploaded object
	ModifyObject(ctx context.Context, bucket string, path Path) (MutableObject, error)
	// DeleteObject deletes an object from database
	DeleteObject(ctx context.Context, bucket string, path Path) error
	// ListObjects lists objects in bucket based on the ListOptions
	ListObjects(ctx context.Context, bucket string, options ListOptions) (ObjectList, error)

	// ModifyPendingObject creates a mutable object for updating a partially uploaded object
	ModifyPendingObject(ctx context.Context, bucket string, path Path) (MutableObject, error)
	// ListPendingObjects lists pending objects in bucket based on the ListOptions
	ListPendingObjects(ctx context.Context, bucket string, options ListOptions) (ObjectList, error)
}

Metainfo represents a database for storing meta-info about objects

type MetainfoLimits

type MetainfoLimits struct {
	// ListLimit specifies the maximum amount of items that can be listed at a time.
	ListLimit int64

	// MinimumRemoteSegmentSize specifies the minimum remote segment that is allowed to be stored.
	MinimumRemoteSegmentSize int64
	// MaximumInlineSegmentSize specifies the maximum inline segment that is allowed to be stored.
	MaximumInlineSegmentSize int64
}

MetainfoLimits lists limits specified for the Metainfo database

type MutableObject

type MutableObject interface {
	// Info gets the current information about the object
	Info() Object

	// CreateStream creates a new stream for the object
	CreateStream(ctx context.Context) (MutableStream, error)
	// ContinueStream starts to continue a partially uploaded stream.
	ContinueStream(ctx context.Context) (MutableStream, error)
	// DeleteStream deletes any information about this objects stream
	DeleteStream(ctx context.Context) error

	// Commit commits the changes to the database
	Commit(ctx context.Context) error
}

MutableObject is an interface for manipulating creating/deleting object stream

type MutableStream

type MutableStream interface {
	Info() Object
	// AddSegments adds segments to the stream.
	AddSegments(ctx context.Context, segments ...Segment) error
	// UpdateSegments updates information about segments.
	UpdateSegments(ctx context.Context, segments ...Segment) error
}

MutableStream is an interface for manipulating stream information

type NodeID

type NodeID [NodeIDSize]byte

NodeID is a unique node identifier

func NewVersionedID added in v0.9.0

func NewVersionedID(id NodeID, version IDVersion) NodeID

NewVersionedID adds an identity version to a node ID.

func NodeIDFromBytes

func NodeIDFromBytes(b []byte) (NodeID, error)

NodeIDFromBytes converts a byte slice into a node id

func NodeIDFromString

func NodeIDFromString(s string) (NodeID, error)

NodeIDFromString decodes a base58check encoded node id string

func (NodeID) Bytes

func (id NodeID) Bytes() []byte

Bytes returns raw bytes of the id

func (NodeID) Difficulty

func (id NodeID) Difficulty() (uint16, error)

Difficulty returns the number of trailing zero bits in a node ID

func (NodeID) IsZero

func (id NodeID) IsZero() bool

IsZero returns whether NodeID is unassigned

func (NodeID) Less

func (id NodeID) Less(other NodeID) bool

Less returns whether id is smaller than other in lexicographic order.

func (NodeID) Marshal

func (id NodeID) Marshal() ([]byte, error)

Marshal serializes a node id

func (NodeID) MarshalJSON

func (id NodeID) MarshalJSON() ([]byte, error)

MarshalJSON serializes a node ID to a json string as bytes

func (*NodeID) MarshalTo

func (id *NodeID) MarshalTo(data []byte) (n int, err error)

MarshalTo serializes a node ID into the passed byte slice

func (*NodeID) Scan

func (id *NodeID) Scan(src interface{}) (err error)

Scan extracts a NodeID from a database field

func (*NodeID) Size

func (id *NodeID) Size() int

Size returns the length of a node ID (implements gogo's custom type interface)

func (NodeID) String

func (id NodeID) String() string

String returns NodeID as base58 encoded string with checksum and version bytes

func (*NodeID) Unmarshal

func (id *NodeID) Unmarshal(data []byte) error

Unmarshal deserializes a node ID

func (*NodeID) UnmarshalJSON

func (id *NodeID) UnmarshalJSON(data []byte) error

UnmarshalJSON deserializes a json string (as bytes) to a node ID

func (NodeID) Value

func (id NodeID) Value() (driver.Value, error)

Value converts a NodeID to a database field

func (NodeID) Version added in v0.9.0

func (id NodeID) Version() IDVersion

Version returns the version of the identity format

type NodeIDList

type NodeIDList []NodeID

NodeIDList is a slice of NodeIDs (implements sort)

func NodeIDsFromBytes

func NodeIDsFromBytes(b [][]byte) (ids NodeIDList, err error)

NodeIDsFromBytes converts a 2d byte slice into a list of nodes

func (NodeIDList) Bytes

func (n NodeIDList) Bytes() (idsBytes [][]byte)

Bytes returns a 2d byte slice of the node IDs

func (NodeIDList) Len

func (n NodeIDList) Len() int

Len implements sort.Interface.Len()

func (NodeIDList) Less

func (n NodeIDList) Less(i, j int) bool

Less implements sort.Interface.Less()

func (NodeIDList) Strings added in v0.13.0

func (n NodeIDList) Strings() []string

Strings returns a string slice of the node IDs

func (NodeIDList) Swap

func (n NodeIDList) Swap(i, j int)

Swap implements sort.Interface.Swap()

type NodeURL added in v0.15.0

type NodeURL struct {
	ID      NodeID
	Address string
}

NodeURL defines a structure for connecting to a node.

func ParseNodeURL added in v0.15.0

func ParseNodeURL(s string) (NodeURL, error)

ParseNodeURL parses node URL string.

Examples:

raw IP:
  33.20.0.1:7777
  [2001:db8:1f70::999:de8:7648:6e8]:7777

with NodeID:
  12vha9oTFnerxYRgeQ2BZqoFrLrnmmf5UWTCY2jA77dF3YvWew7@33.20.0.1:7777
  12vha9oTFnerxYRgeQ2BZqoFrLrnmmf5UWTCY2jA77dF3YvWew7@[2001:db8:1f70::999:de8:7648:6e8]:7777

without host:
  12vha9oTFnerxYRgeQ2BZqoFrLrnmmf5UWTCY2jA77dF3YvWew7@

func (NodeURL) IsZero added in v0.15.0

func (url NodeURL) IsZero() bool

IsZero returns whether the url is empty.

func (*NodeURL) Set added in v0.15.0

func (url *NodeURL) Set(s string) error

Set implements flag.Value interface

func (NodeURL) String added in v0.15.0

func (url NodeURL) String() string

String converts NodeURL to a string

func (NodeURL) Type added in v0.15.0

func (NodeURL) Type() string

Type implements pflag.Value

type NodeURLs added in v0.15.0

type NodeURLs []NodeURL

NodeURLs defines a comma delimited flag for defining a list node url-s.

func ParseNodeURLs added in v0.15.0

func ParseNodeURLs(s string) (NodeURLs, error)

ParseNodeURLs parses comma delimited list of node urls

func (*NodeURLs) Set added in v0.15.0

func (urls *NodeURLs) Set(s string) error

Set implements flag.Value interface

func (NodeURLs) String added in v0.15.0

func (urls NodeURLs) String() string

String converts NodeURLs to a string

func (NodeURLs) Type added in v0.15.0

func (NodeURLs) Type() string

Type implements pflag.Value

type Nonce

type Nonce [NonceSize]byte

Nonce represents the largest nonce used by any encryption protocol

func NonceFromBytes added in v0.16.0

func NonceFromBytes(b []byte) (Nonce, error)

NonceFromBytes converts a byte slice into a nonce

func NonceFromString added in v0.16.0

func NonceFromString(s string) (Nonce, error)

NonceFromString decodes an base32 encoded

func (Nonce) Bytes added in v0.16.0

func (nonce Nonce) Bytes() []byte

Bytes returns bytes of the nonce

func (Nonce) IsZero added in v0.16.0

func (nonce Nonce) IsZero() bool

IsZero returns whether nonce is unassigned

func (Nonce) Marshal added in v0.16.0

func (nonce Nonce) Marshal() ([]byte, error)

Marshal serializes a nonce

func (Nonce) MarshalJSON added in v0.16.0

func (nonce Nonce) MarshalJSON() ([]byte, error)

MarshalJSON serializes a nonce to a json string as bytes

func (*Nonce) MarshalTo added in v0.16.0

func (nonce *Nonce) MarshalTo(data []byte) (n int, err error)

MarshalTo serializes a nonce into the passed byte slice

func (*Nonce) Raw

func (nonce *Nonce) Raw() *[NonceSize]byte

Raw returns the nonce as a raw byte array pointer

func (Nonce) Size added in v0.16.0

func (nonce Nonce) Size() int

Size returns the length of a nonce (implements gogo's custom type interface)

func (Nonce) String added in v0.16.0

func (nonce Nonce) String() string

String representation of the nonce

func (*Nonce) Unmarshal added in v0.16.0

func (nonce *Nonce) Unmarshal(data []byte) error

Unmarshal deserializes a nonce

func (*Nonce) UnmarshalJSON added in v0.16.0

func (nonce *Nonce) UnmarshalJSON(data []byte) error

UnmarshalJSON deserializes a json string (as bytes) to a nonce

type Object

type Object struct {
	Version  uint32
	Bucket   Bucket
	Path     Path
	IsPrefix bool

	Metadata map[string]string

	ContentType string
	Created     time.Time
	Modified    time.Time
	Expires     time.Time

	Stream
}

Object contains information about a specific object

type ObjectInfo added in v0.17.0

type ObjectInfo struct {
	Version  uint32
	Bucket   string
	Path     Path
	IsPrefix bool

	StreamID StreamID

	Metadata []byte

	ContentType string
	Created     time.Time
	Modified    time.Time
	Expires     time.Time

	Stream
}

ObjectInfo contains information about a specific object

type ObjectList

type ObjectList struct {
	Bucket string
	Prefix Path
	More   bool

	// Items paths are relative to Prefix
	// To get the full path use list.Prefix + list.Items[0].Path
	Items []Object
}

ObjectList is a list of objects

type ObjectListItem added in v0.16.0

type ObjectListItem struct {
	EncryptedPath          []byte
	Version                int32
	Status                 int32
	CreatedAt              time.Time
	StatusAt               time.Time
	ExpiresAt              time.Time
	EncryptedMetadataNonce Nonce
	EncryptedMetadata      []byte
	IsPrefix               bool
}

ObjectListItem represents listed object

type Path

type Path = string

Path represents a object path

func JoinPaths

func JoinPaths(paths ...Path) Path

JoinPaths concatenates paths to a new single path

type Piece

type Piece struct {
	Number   byte
	Location NodeID
}

Piece is information where a piece is located

type PieceID

type PieceID [32]byte

PieceID is the unique identifier for pieces

func NewPieceID

func NewPieceID() PieceID

NewPieceID creates a piece ID

func PieceIDFromBytes

func PieceIDFromBytes(b []byte) (PieceID, error)

PieceIDFromBytes converts a byte slice into a piece ID

func PieceIDFromString

func PieceIDFromString(s string) (PieceID, error)

PieceIDFromString decodes a hex encoded piece ID string

func (PieceID) Bytes

func (id PieceID) Bytes() []byte

Bytes returns bytes of the piece ID

func (PieceID) Derive

func (id PieceID) Derive(storagenodeID NodeID, pieceNum int32) PieceID

Derive a new PieceID from the current piece ID, the given storage node ID and piece number

func (PieceID) IsZero

func (id PieceID) IsZero() bool

IsZero returns whether piece ID is unassigned

func (PieceID) Marshal

func (id PieceID) Marshal() ([]byte, error)

Marshal serializes a piece ID

func (PieceID) MarshalJSON

func (id PieceID) MarshalJSON() ([]byte, error)

MarshalJSON serializes a piece ID to a json string as bytes

func (*PieceID) MarshalTo

func (id *PieceID) MarshalTo(data []byte) (n int, err error)

MarshalTo serializes a piece ID into the passed byte slice

func (*PieceID) Scan

func (id *PieceID) Scan(src interface{}) (err error)

Scan extracts a PieceID from a database field

func (*PieceID) Size

func (id *PieceID) Size() int

Size returns the length of a piece ID (implements gogo's custom type interface)

func (PieceID) String

func (id PieceID) String() string

String representation of the piece ID

func (*PieceID) Unmarshal

func (id *PieceID) Unmarshal(data []byte) error

Unmarshal deserializes a piece ID

func (*PieceID) UnmarshalJSON

func (id *PieceID) UnmarshalJSON(data []byte) error

UnmarshalJSON deserializes a json string (as bytes) to a piece ID

func (PieceID) Value

func (id PieceID) Value() (driver.Value, error)

Value set a PieceID to a database field

type PiecePrivateKey added in v0.15.0

type PiecePrivateKey struct {
	// contains filtered or unexported fields
}

PiecePrivateKey is the unique identifier for pieces

func PiecePrivateKeyFromBytes added in v0.15.0

func PiecePrivateKeyFromBytes(data []byte) (PiecePrivateKey, error)

PiecePrivateKeyFromBytes converts bytes to a piece private key.

func (PiecePrivateKey) Bytes added in v0.15.0

func (key PiecePrivateKey) Bytes() []byte

Bytes returns bytes of the piece private key

func (PiecePrivateKey) IsZero added in v0.15.0

func (key PiecePrivateKey) IsZero() bool

IsZero returns whether the key is empty.

func (PiecePrivateKey) Marshal added in v0.15.0

func (key PiecePrivateKey) Marshal() ([]byte, error)

Marshal serializes a piece private key

func (*PiecePrivateKey) MarshalTo added in v0.15.0

func (key *PiecePrivateKey) MarshalTo(data []byte) (n int, err error)

MarshalTo serializes a piece private key into the passed byte slice

func (*PiecePrivateKey) Scan added in v0.15.0

func (key *PiecePrivateKey) Scan(src interface{}) (err error)

Scan extracts a PiecePrivateKey from a database field

func (PiecePrivateKey) Sign added in v0.15.0

func (key PiecePrivateKey) Sign(data []byte) ([]byte, error)

Sign signs the message with privateKey and returns a signature.

func (*PiecePrivateKey) Size added in v0.15.0

func (key *PiecePrivateKey) Size() int

Size returns the length of a piece private key (implements gogo's custom type interface)

func (*PiecePrivateKey) Unmarshal added in v0.15.0

func (key *PiecePrivateKey) Unmarshal(data []byte) error

Unmarshal deserializes a piece private key

func (PiecePrivateKey) Value added in v0.15.0

func (key PiecePrivateKey) Value() (driver.Value, error)

Value set a PiecePrivateKey to a database field

type PiecePublicKey added in v0.15.0

type PiecePublicKey struct {
	// contains filtered or unexported fields
}

PiecePublicKey is the unique identifier for pieces

func PiecePublicKeyFromBytes added in v0.15.0

func PiecePublicKeyFromBytes(data []byte) (PiecePublicKey, error)

PiecePublicKeyFromBytes converts bytes to a piece public key.

func (PiecePublicKey) Bytes added in v0.15.0

func (key PiecePublicKey) Bytes() []byte

Bytes returns bytes of the piece public key

func (PiecePublicKey) IsZero added in v0.15.0

func (key PiecePublicKey) IsZero() bool

IsZero returns whether the key is empty.

func (PiecePublicKey) Marshal added in v0.15.0

func (key PiecePublicKey) Marshal() ([]byte, error)

Marshal serializes a piece public key

func (*PiecePublicKey) MarshalTo added in v0.15.0

func (key *PiecePublicKey) MarshalTo(data []byte) (n int, err error)

MarshalTo serializes a piece public key into the passed byte slice

func (*PiecePublicKey) Scan added in v0.15.0

func (key *PiecePublicKey) Scan(src interface{}) (err error)

Scan extracts a PiecePublicKey from a database field

func (*PiecePublicKey) Size added in v0.15.0

func (key *PiecePublicKey) Size() int

Size returns the length of a piece public key (implements gogo's custom type interface)

func (*PiecePublicKey) Unmarshal added in v0.15.0

func (key *PiecePublicKey) Unmarshal(data []byte) error

Unmarshal deserializes a piece public key

func (PiecePublicKey) Value added in v0.15.0

func (key PiecePublicKey) Value() (driver.Value, error)

Value set a PiecePublicKey to a database field

func (PiecePublicKey) Verify added in v0.15.0

func (key PiecePublicKey) Verify(data, signature []byte) error

Verify reports whether signature is a valid signature of message by publicKey.

type ReadOnlyStream

type ReadOnlyStream interface {
	Info() Object

	// SegmentsAt returns the segment that contains the byteOffset and following segments.
	// Limit specifies how much to return at most.
	SegmentsAt(ctx context.Context, byteOffset int64, limit int64) (infos []Segment, more bool, err error)
	// Segments returns the segment at index.
	// Limit specifies how much to return at most.
	Segments(ctx context.Context, index int64, limit int64) (infos []Segment, more bool, err error)
}

ReadOnlyStream is an interface for reading segment information

type RedundancyAlgorithm

type RedundancyAlgorithm byte

RedundancyAlgorithm is the algorithm used for redundancy

type RedundancyScheme

type RedundancyScheme struct {
	// Algorithm determines the algorithm to be used for redundancy.
	Algorithm RedundancyAlgorithm

	// ShareSize is the size in bytes for each erasure shares.
	ShareSize int32

	// RequiredShares is the minimum number of shares required to recover a
	// stripe, reed-solomon k.
	RequiredShares int16
	// RepairShares is the minimum number of safe shares that can remain
	// before a repair is triggered.
	RepairShares int16
	// OptimalShares is the desired total number of shares for a segment.
	OptimalShares int16
	// TotalShares is the number of shares to encode. If it is larger than
	// OptimalShares, slower uploads of the excess shares will be aborted in
	// order to improve performance.
	TotalShares int16
}

RedundancyScheme specifies the parameters and the algorithm for redundancy

func (RedundancyScheme) IsZero

func (scheme RedundancyScheme) IsZero() bool

IsZero returns true if no field in the struct is set to non-zero value

func (RedundancyScheme) StripeSize added in v0.13.0

func (scheme RedundancyScheme) StripeSize() int32

StripeSize is the number of bytes for a stripe. Stripes are erasure encoded and split into n shares, where we need k to reconstruct the stripe. Therefore a stripe size is the erasure share size times the required shares, k.

type Segment

type Segment struct {
	Index int64
	// Size is the size of the content in bytes
	Size int64
	// Checksum is the checksum of the content
	Checksum []byte
	// Local data
	Inline []byte
	// Remote data
	PieceID PieceID
	Pieces  []Piece
	// Encryption
	EncryptedKeyNonce Nonce
	EncryptedKey      EncryptedPrivateKey
}

Segment is full segment information

type SegmentDownloadInfo added in v0.16.0

type SegmentDownloadInfo struct {
	SegmentID           SegmentID
	Size                int64
	EncryptedInlineData []byte
	Next                SegmentPosition
	PiecePrivateKey     PiecePrivateKey

	SegmentEncryption SegmentEncryption
}

SegmentDownloadInfo represents segment download information inline/remote

type SegmentEncryption added in v0.17.0

type SegmentEncryption struct {
	EncryptedKeyNonce Nonce
	EncryptedKey      EncryptedPrivateKey
}

SegmentEncryption represents segment encryption key and nonce

type SegmentID added in v0.16.0

type SegmentID []byte

SegmentID is the unique identifier for segment related to object

func SegmentIDFromBytes added in v0.16.0

func SegmentIDFromBytes(b []byte) (SegmentID, error)

SegmentIDFromBytes converts a byte slice into a segment ID

func SegmentIDFromString added in v0.16.0

func SegmentIDFromString(s string) (SegmentID, error)

SegmentIDFromString decodes an base32 encoded

func (SegmentID) Bytes added in v0.16.0

func (id SegmentID) Bytes() []byte

Bytes returns bytes of the segment ID

func (SegmentID) IsZero added in v0.16.0

func (id SegmentID) IsZero() bool

IsZero returns whether segment ID is unassigned

func (SegmentID) Marshal added in v0.16.0

func (id SegmentID) Marshal() ([]byte, error)

Marshal serializes a segment ID (implements gogo's custom type interface)

func (SegmentID) MarshalJSON added in v0.16.0

func (id SegmentID) MarshalJSON() ([]byte, error)

MarshalJSON serializes a segment ID to a json string as bytes (implements gogo's custom type interface)

func (*SegmentID) MarshalTo added in v0.16.0

func (id *SegmentID) MarshalTo(data []byte) (n int, err error)

MarshalTo serializes a segment ID into the passed byte slice (implements gogo's custom type interface)

func (SegmentID) Size added in v0.16.0

func (id SegmentID) Size() int

Size returns the length of a segment ID (implements gogo's custom type interface)

func (SegmentID) String added in v0.16.0

func (id SegmentID) String() string

String representation of the segment ID

func (*SegmentID) Unmarshal added in v0.16.0

func (id *SegmentID) Unmarshal(data []byte) error

Unmarshal deserializes a segment ID (implements gogo's custom type interface)

func (*SegmentID) UnmarshalJSON added in v0.16.0

func (id *SegmentID) UnmarshalJSON(data []byte) error

UnmarshalJSON deserializes a json string (as bytes) to a segment ID (implements gogo's custom type interface)

type SegmentListItem added in v0.16.0

type SegmentListItem struct {
	Position SegmentPosition
}

SegmentListItem represents listed segment

type SegmentPosition added in v0.16.0

type SegmentPosition struct {
	PartNumber int32
	Index      int32
}

SegmentPosition segment position in object

type SerialNumber

type SerialNumber [16]byte

SerialNumber is the unique identifier for pieces

func SerialNumberFromBytes

func SerialNumberFromBytes(b []byte) (SerialNumber, error)

SerialNumberFromBytes converts a byte slice into a serial number

func SerialNumberFromString

func SerialNumberFromString(s string) (SerialNumber, error)

SerialNumberFromString decodes an base32 encoded

func (SerialNumber) Bytes

func (id SerialNumber) Bytes() []byte

Bytes returns bytes of the serial number

func (SerialNumber) IsZero

func (id SerialNumber) IsZero() bool

IsZero returns whether serial number is unassigned

func (SerialNumber) Less added in v0.20.2

func (id SerialNumber) Less(other SerialNumber) bool

Less returns whether id is smaller than other in lexicographic order.

func (SerialNumber) Marshal

func (id SerialNumber) Marshal() ([]byte, error)

Marshal serializes a serial number

func (SerialNumber) MarshalJSON

func (id SerialNumber) MarshalJSON() ([]byte, error)

MarshalJSON serializes a serial number to a json string as bytes

func (*SerialNumber) MarshalTo

func (id *SerialNumber) MarshalTo(data []byte) (n int, err error)

MarshalTo serializes a serial number into the passed byte slice

func (*SerialNumber) Scan

func (id *SerialNumber) Scan(src interface{}) (err error)

Scan extracts a SerialNumber from a database field

func (*SerialNumber) Size

func (id *SerialNumber) Size() int

Size returns the length of a serial number (implements gogo's custom type interface)

func (SerialNumber) String

func (id SerialNumber) String() string

String representation of the serial number

func (*SerialNumber) Unmarshal

func (id *SerialNumber) Unmarshal(data []byte) error

Unmarshal deserializes a serial number

func (*SerialNumber) UnmarshalJSON

func (id *SerialNumber) UnmarshalJSON(data []byte) error

UnmarshalJSON deserializes a json string (as bytes) to a serial number

func (SerialNumber) Value

func (id SerialNumber) Value() (driver.Value, error)

Value set a SerialNumber to a database field

type Stream

type Stream struct {
	// Size is the total size of the stream in bytes
	Size int64
	// Checksum is the checksum of the segment checksums
	Checksum []byte

	// SegmentCount is the number of segments
	SegmentCount int64
	// FixedSegmentSize is the size of each segment,
	// when all segments have the same size. It is -1 otherwise.
	FixedSegmentSize int64

	// RedundancyScheme specifies redundancy strategy used for this stream
	RedundancyScheme
	// EncryptionParameters specifies encryption strategy used for this stream
	EncryptionParameters

	LastSegment LastSegment // TODO: remove
}

Stream is information about an object stream

type StreamID added in v0.15.0

type StreamID []byte

StreamID is the unique identifier for stream related to object

func StreamIDFromBytes added in v0.15.0

func StreamIDFromBytes(b []byte) (StreamID, error)

StreamIDFromBytes converts a byte slice into a stream ID

func StreamIDFromString added in v0.15.0

func StreamIDFromString(s string) (StreamID, error)

StreamIDFromString decodes an base32 encoded

func (StreamID) Bytes added in v0.15.0

func (id StreamID) Bytes() []byte

Bytes returns bytes of the stream ID

func (StreamID) IsZero added in v0.15.0

func (id StreamID) IsZero() bool

IsZero returns whether stream ID is unassigned

func (StreamID) Marshal added in v0.15.0

func (id StreamID) Marshal() ([]byte, error)

Marshal serializes a stream ID

func (StreamID) MarshalJSON added in v0.15.0

func (id StreamID) MarshalJSON() ([]byte, error)

MarshalJSON serializes a stream ID to a json string as bytes

func (*StreamID) MarshalTo added in v0.15.0

func (id *StreamID) MarshalTo(data []byte) (n int, err error)

MarshalTo serializes a stream ID into the passed byte slice

func (*StreamID) Scan added in v0.15.0

func (id *StreamID) Scan(src interface{}) (err error)

Scan extracts a stream ID from a database field

func (StreamID) Size added in v0.15.0

func (id StreamID) Size() int

Size returns the length of a stream ID (implements gogo's custom type interface)

func (StreamID) String added in v0.15.0

func (id StreamID) String() string

String representation of the stream ID

func (*StreamID) Unmarshal added in v0.15.0

func (id *StreamID) Unmarshal(data []byte) error

Unmarshal deserializes a stream ID

func (*StreamID) UnmarshalJSON added in v0.15.0

func (id *StreamID) UnmarshalJSON(data []byte) error

UnmarshalJSON deserializes a json string (as bytes) to a stream ID

func (StreamID) Value added in v0.15.0

func (id StreamID) Value() (driver.Value, error)

Value set a stream ID to a database field

Jump to

Keyboard shortcuts

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