Documentation ¶
Index ¶
- Constants
- Variables
- func IDVersionInVersions(versionNumber IDVersionNumber, versionsStr string) error
- func NewVersionExt(version IDVersion) pkix.Extension
- func SplitPath(path Path) []string
- type Bucket
- type BucketList
- type BucketListOptions
- type Cipher
- type CipherSuite
- type CreateObject
- type EncryptedPrivateKey
- type EncryptionParameters
- type EncryptionScheme
- type IDVersion
- type IDVersionNumber
- type Key
- type LastSegment
- type ListDirection
- type ListOptions
- type Metainfo
- type MetainfoLimits
- type MutableObject
- type MutableStream
- type NodeID
- func (id NodeID) Bytes() []byte
- func (id NodeID) Difficulty() (uint16, error)
- func (id NodeID) IsZero() bool
- func (id NodeID) Less(b NodeID) bool
- func (id NodeID) Marshal() ([]byte, error)
- func (id NodeID) MarshalJSON() ([]byte, error)
- func (id *NodeID) MarshalTo(data []byte) (n int, err error)
- func (id *NodeID) Scan(src interface{}) (err error)
- func (id *NodeID) Size() int
- func (id NodeID) String() string
- func (id *NodeID) Unmarshal(data []byte) error
- func (id *NodeID) UnmarshalJSON(data []byte) error
- func (id NodeID) Value() (driver.Value, error)
- func (id NodeID) Version() IDVersion
- type NodeIDList
- type Nonce
- type Object
- type ObjectList
- type Path
- type Piece
- type PieceID
- func (id PieceID) Bytes() []byte
- func (id PieceID) Derive(storagenodeID NodeID) PieceID
- func (id PieceID) IsZero() bool
- func (id PieceID) Marshal() ([]byte, error)
- func (id PieceID) MarshalJSON() ([]byte, error)
- func (id *PieceID) MarshalTo(data []byte) (n int, err error)
- func (id *PieceID) Scan(src interface{}) (err error)
- func (id *PieceID) Size() int
- func (id PieceID) String() string
- func (id *PieceID) Unmarshal(data []byte) error
- func (id *PieceID) UnmarshalJSON(data []byte) error
- func (id PieceID) Value() (driver.Value, error)
- type ReadOnlyStream
- type RedundancyAlgorithm
- type RedundancyScheme
- type Segment
- type SerialNumber
- func (id SerialNumber) Bytes() []byte
- func (id SerialNumber) IsZero() bool
- func (id SerialNumber) Marshal() ([]byte, error)
- func (id SerialNumber) MarshalJSON() ([]byte, error)
- func (id *SerialNumber) MarshalTo(data []byte) (n int, err error)
- func (id *SerialNumber) Scan(src interface{}) (err error)
- func (id *SerialNumber) Size() int
- func (id SerialNumber) String() string
- func (id *SerialNumber) Unmarshal(data []byte) error
- func (id *SerialNumber) UnmarshalJSON(data []byte) error
- func (id SerialNumber) Value() (driver.Value, error)
- type Stream
Constants ¶
const ( // Unencrypted indicates no encryption or decryption is to be performed. Unencrypted = Cipher(iota) // AESGCM indicates use of AES128-GCM encryption. AESGCM // SecretBox indicates use of XSalsa20-Poly1305 encryption, as provided by // the NaCl cryptography library under the name "Secretbox". SecretBox // Invalid indicates a Cipher value whose use is not valid. This may be // used as a replacement for "unspecified" in a pinch, although it is not // the zero value. Invalid )
List of supported encryption algorithms
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 )
const ( KeySize = 32 NonceSize = 24 )
Constant definitions for key and nonce sizes
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) )
const ( InvalidRedundancyAlgorithm = RedundancyAlgorithm(iota) ReedSolomon )
List of supported redundancy algorithms
const NodeIDSize = sha256.Size
NodeIDSize is the byte length of a NodeID
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 ¶
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, ) )
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") )
var ( // ErrNoBucket is an error class for using empty bucket name ErrNoBucket = errs.Class("no bucket specified") // ErrNoPath is an error class for using empty path ErrNoPath = errs.Class("no path specified") // ErrBucketNotFound is an error class for non-existing bucket ErrBucketNotFound = errs.Class("bucket not found") // ErrObjectNotFound is an error class for non-existing object ErrObjectNotFound = errs.Class("object not found") )
var ErrPieceID = errs.Class("piece ID error")
ErrPieceID is used when something goes wrong with a piece ID
var ErrSerialNumber = errs.Class("serial number error")
ErrSerialNumber is used when something goes wrong with a serial number
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 NewVersionExt ¶ added in v0.9.0
NewVersionExt creates a new identity version certificate extension for the given identity version,
Types ¶
type Bucket ¶
type Bucket struct { Name string Created time.Time PathCipher Cipher SegmentsSize int64 RedundancyScheme RedundancyScheme EncryptionParameters EncryptionParameters }
Bucket contains information about a specific bucket
type BucketList ¶
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 Cipher ¶
type Cipher byte
Cipher specifies an encryption algorithm
func (Cipher) ToCipherSuite ¶
func (c Cipher) ToCipherSuite() CipherSuite
ToCipherSuite converts a Cipher value to a CipherSuite value.
type CipherSuite ¶
type CipherSuite byte
CipherSuite specifies one of the encryption suites supported by Storj libraries for encryption of in-network data.
func (CipherSuite) ToCipher ¶
func (cs CipherSuite) ToCipher() Cipher
ToCipher converts a CipherSuite value to a Cipher value.
type CreateObject ¶
type CreateObject struct { Metadata map[string]string ContentType string Expires time.Time RedundancyScheme EncryptionScheme }
CreateObject has optional parameters that can be set
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 It is like EncryptionScheme, but uses the CipherSuite type instead of Cipher. EncryptionParameters is preferred for new uses.
func (EncryptionParameters) IsZero ¶
func (params EncryptionParameters) IsZero() bool
IsZero returns true if no field in the struct is set to non-zero value
func (EncryptionParameters) ToEncryptionScheme ¶
func (params EncryptionParameters) ToEncryptionScheme() EncryptionScheme
ToEncryptionScheme transforms an EncryptionParameters object into the equivalent EncryptionScheme object.
type EncryptionScheme ¶
type EncryptionScheme struct { // Cipher specifies the cipher suite to be used for encryption. Cipher Cipher // 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 }
EncryptionScheme is the scheme and parameters used for encryption. Use the similar EncryptionParameters struct instead, if possible.
func (EncryptionScheme) IsZero ¶
func (scheme EncryptionScheme) IsZero() bool
IsZero returns true if no field in the struct is set to non-zero value
func (EncryptionScheme) ToEncryptionParameters ¶
func (scheme EncryptionScheme) ToEncryptionParameters() EncryptionParameters
ToEncryptionParameters transforms an EncryptionScheme object into the equivalent EncryptionParameters object.
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 LastSegment ¶
type LastSegment struct { Size int64 EncryptedKeyNonce Nonce EncryptedKey EncryptedPrivateKey }
LastSegment contains info about last segment TODO: remove
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
NewVersionedID adds an identity version to a node ID.
func NodeIDFromBytes ¶
NodeIDFromBytes converts a byte slice into a node id
func NodeIDFromString ¶
NodeIDFromString decodes a base58check encoded node id string
func (NodeID) Difficulty ¶
Difficulty returns the number of trailing zero bits in a node ID
func (NodeID) MarshalJSON ¶
MarshalJSON serializes a node ID to a json string as bytes
func (*NodeID) Size ¶
Size returns the length of a node ID (implements gogo's custom type interface)
func (NodeID) String ¶
String returns NodeID as base58 encoded string with checksum and version bytes
func (*NodeID) UnmarshalJSON ¶
UnmarshalJSON deserializes a json string (as bytes) to a node ID
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) Less ¶
func (n NodeIDList) Less(i, j int) bool
Less implements sort.Interface.Less()
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 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 PieceID ¶
type PieceID [32]byte
PieceID is the unique identifier for pieces
func PieceIDFromBytes ¶
PieceIDFromBytes converts a byte slice into a piece ID
func PieceIDFromString ¶
PieceIDFromString decodes a hex encoded piece ID string
func (PieceID) Derive ¶
Derive a new PieceID from the current piece ID and the given storage node ID
func (PieceID) MarshalJSON ¶
MarshalJSON serializes a piece ID to a json string as bytes
func (*PieceID) Size ¶
Size returns the length of a piece ID (implements gogo's custom type interface)
func (*PieceID) UnmarshalJSON ¶
UnmarshalJSON deserializes a json string (as bytes) to a piece ID
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 int32 // segment. RequiredShares int16 // before a repair is triggered. RepairShares int16 OptimalShares int16 // 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
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 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) 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
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 // EncryptionScheme specifies encryption strategy used for this stream EncryptionScheme LastSegment LastSegment // TODO: remove }
Stream is information about an object stream