attachments

package
v2.3.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2018 License: BSD-3-Clause, BSD-3-Clause Imports: 38 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrAbortOnPartMismatch = errors.New("local part mismatch, aborting upload")

ErrAbortOnPartMismatch is returned when there is a mismatch between a current part and a previous attempt part. If ErrAbortOnPartMismatch is returned, the caller should abort the upload attempt and start from scratch.

View Source
var ErrPartNotFound = errors.New("part does not exist in stash")

Functions

func AssetFromMessage

func AssetFromMessage(ctx context.Context, g *globals.Context, uid gregor1.UID, convID chat1.ConversationID,
	msgID chat1.MessageID, preview bool) (res chat1.Asset, err error)

Types

type AssetSource

type AssetSource interface {
	FileSize() int
	Basename() string
	Open(sessionID int, cli *keybase1.StreamUiClient) (ReadResetter, error)
	Close() error
}

type AttachmentInfo

type AttachmentInfo struct {
	ObjectKey string                   // s3 destination
	EncKey    signencrypt.SecretboxKey // encryption key
	SignKey   signencrypt.SignKey      // signing key
	VerifyKey signencrypt.VerifyKey    // verification key
	Parts     map[int]string           // map of parts uploaded to S3, key == part number, value == hash of ciphertext
	StartedAt time.Time                // when the upload started
}

type AttachmentStash

type AttachmentStash interface {
	Start(key StashKey, info AttachmentInfo) error
	Lookup(key StashKey) (AttachmentInfo, bool, error)
	RecordPart(key StashKey, partNumber int, hash string) error
	Finish(key StashKey) error
}

type BufferSource

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

func (*BufferSource) Basename

func (b *BufferSource) Basename() string

func (*BufferSource) Bytes

func (b *BufferSource) Bytes() []byte

func (*BufferSource) Close

func (b *BufferSource) Close() error

func (*BufferSource) FileSize

func (b *BufferSource) FileSize() int

func (*BufferSource) Open

func (b *BufferSource) Open(sessionID int, cli *keybase1.StreamUiClient) (ReadResetter, error)

type Decrypter

type Decrypter interface {
	// Decrypt takes a ciphertext reader, encryption and verify keys.
	// It returns a plaintext reader.  It uses the constant nonce.
	Decrypt(ciphertext io.Reader, encKey, verifyKey []byte) (plaintext io.Reader)

	// DecryptWithNonce takes a ciphertext reader, nonce, encryption and verify keys.
	// It returns a plaintext reader.
	DecryptWithNonce(ciphertext io.Reader, nonce signencrypt.Nonce, encKey, verifyKey []byte) (plaintext io.Reader)
}

type Encrypter

type Encrypter interface {
	// EncryptedLen returns the number of bytes that the ciphertext of
	// size plaintext bytes will be.
	EncryptedLen(size int) int

	// Encrypt takes a plaintext reader and returns a ciphertext reader.
	// It generates new keys every time it is called and uses a
	// constant nonce.
	Encrypt(plaintext io.Reader) (ciphertext io.Reader, err error)

	// EncryptWithNonce takes a plaintext reader and returns a ciphertext reader.
	// It generates new keys every time it is called and uses
	// the provided nonce.
	EncryptWithNonce(plaintext io.Reader, nonce signencrypt.Nonce) (ciphertext io.Reader, err error)

	// EncryptResume takes a plaintext reader and a set of keys.  It
	// returns a ciphertext reader.  It *does not* generate new keys
	// but uses the parameter keys.  These keys should *only* be used
	// to encrypt the same plaintext as a previous attempt.
	EncryptResume(r io.Reader, nonce signencrypt.Nonce, encKey signencrypt.SecretboxKey, signKey signencrypt.SignKey, verifyKey signencrypt.VerifyKey) (io.Reader, error)

	// EncryptKey returns the ephemeral key that was used during the
	// last invocation of Encrypt.
	EncryptKey() []byte

	// VerifyKey returns the public portion of the signing key used during
	// the last invocation of Encrypt.  It can be used for signature
	// verification.
	VerifyKey() []byte
}

type ErrorWrapper

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

func NewErrorWrapper

func NewErrorWrapper(prefix string, err error) *ErrorWrapper

func (*ErrorWrapper) Details

func (e *ErrorWrapper) Details() string

func (*ErrorWrapper) Error

func (e *ErrorWrapper) Error() string

type FileSource

type FileSource struct {
	chat1.LocalFileSource
	// contains filtered or unexported fields
}

func NewFileSource

func NewFileSource(s chat1.LocalFileSource) (*FileSource, error)

func (*FileSource) Basename

func (f *FileSource) Basename() string

func (*FileSource) Close

func (f *FileSource) Close() error

func (*FileSource) FileSize

func (f *FileSource) FileSize() int

func (*FileSource) Open

func (f *FileSource) Open(sessionID int, cli *keybase1.StreamUiClient) (ReadResetter, error)

type FileStash

type FileStash struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func NewFileStash

func NewFileStash(dir string) *FileStash

func (*FileStash) Finish

func (f *FileStash) Finish(key StashKey) error

func (*FileStash) Lookup

func (f *FileStash) Lookup(key StashKey) (AttachmentInfo, bool, error)

func (*FileStash) RecordPart

func (f *FileStash) RecordPart(key StashKey, partNumber int, hash string) error

func (*FileStash) Start

func (f *FileStash) Start(key StashKey, info AttachmentInfo) error

type PreviewRes

type PreviewRes struct {
	Source            *BufferSource
	ContentType       string
	BaseWidth         int
	BaseHeight        int
	BaseDurationMs    int
	PreviewWidth      int
	PreviewHeight     int
	PreviewDurationMs int
}

func Preview

func Preview(ctx context.Context, log logger.Logger, src io.Reader, contentType, basename string, fileSize int) (*PreviewRes, error)

Preview creates preview assets from src. It returns an in-memory BufferSource and the content type of the preview asset.

type PutS3Result

type PutS3Result struct {
	Region   string
	Endpoint string
	Bucket   string
	Path     string
	Size     int64
}

PutS3Result is the success result of calling PutS3.

type ReadResetter

type ReadResetter interface {
	io.Reader
	Reset() error
}

type SignDecrypter

type SignDecrypter struct{}

func NewSignDecrypter

func NewSignDecrypter() *SignDecrypter

func (*SignDecrypter) Decrypt

func (s *SignDecrypter) Decrypt(r io.Reader, encKey, verifyKey []byte) io.Reader

func (*SignDecrypter) DecryptWithNonce

func (s *SignDecrypter) DecryptWithNonce(r io.Reader, nonce signencrypt.Nonce, encKey, verifyKey []byte) (plaintext io.Reader)

type SignEncrypter

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

func NewSignEncrypter

func NewSignEncrypter() *SignEncrypter

func (*SignEncrypter) Encrypt

func (s *SignEncrypter) Encrypt(r io.Reader) (io.Reader, error)

func (*SignEncrypter) EncryptKey

func (s *SignEncrypter) EncryptKey() []byte

func (*SignEncrypter) EncryptResume

func (s *SignEncrypter) EncryptResume(r io.Reader, nonce signencrypt.Nonce, encKey signencrypt.SecretboxKey, signKey signencrypt.SignKey, verifyKey signencrypt.VerifyKey) (io.Reader, error)

EncryptResume is used to create a SignEncrypter to resume an interrupted attachment upload. It is *very* important that the keys passed in are not used to encrypt different plaintext than their original usage.

func (*SignEncrypter) EncryptWithNonce

func (s *SignEncrypter) EncryptWithNonce(r io.Reader, nonce signencrypt.Nonce) (io.Reader, error)

func (*SignEncrypter) EncryptedLen

func (s *SignEncrypter) EncryptedLen(size int) int

func (*SignEncrypter) SignKey

func (s *SignEncrypter) SignKey() []byte

func (*SignEncrypter) VerifyKey

func (s *SignEncrypter) VerifyKey() []byte

type StashKey

type StashKey struct {
	PlaintextHash  []byte
	ConversationID chat1.ConversationID
	UserID         keybase1.UID
}

func NewStashKey

func NewStashKey(plaintextHash []byte, cid chat1.ConversationID, uid keybase1.UID) StashKey

func (StashKey) String

func (s StashKey) String() string

type Store

type Store struct {
	utils.DebugLabeler
	// contains filtered or unexported fields
}

func NewStore

func NewStore(logger logger.Logger, runtimeDir string) *Store

NewStore creates a standard Store that uses a real S3 connection.

func (*Store) DecryptAsset

func (a *Store) DecryptAsset(ctx context.Context, w io.Writer, body io.Reader, asset chat1.Asset,
	progress types.ProgressReporter) error

func (*Store) DeleteAsset

func (a *Store) DeleteAsset(ctx context.Context, params chat1.S3Params, signer s3.Signer, asset chat1.Asset) error

func (*Store) DeleteAssets

func (a *Store) DeleteAssets(ctx context.Context, params chat1.S3Params, signer s3.Signer, assets []chat1.Asset) error

func (*Store) DownloadAsset

func (a *Store) DownloadAsset(ctx context.Context, params chat1.S3Params, asset chat1.Asset, w io.Writer,
	signer s3.Signer, progress types.ProgressReporter) error

DownloadAsset gets an object from S3 as described in asset.

func (*Store) GetAssetReader

func (a *Store) GetAssetReader(ctx context.Context, params chat1.S3Params, asset chat1.Asset,
	signer s3.Signer) (io.ReadCloser, error)

func (*Store) PutS3

func (a *Store) PutS3(ctx context.Context, r io.Reader, size int64, task *UploadTask, previous *AttachmentInfo) (*PutS3Result, error)

PutS3 uploads the data in Reader r to S3. It chooses whether to use putSingle or putMultiPipeline based on the size of the object.

func (*Store) UploadAsset

func (a *Store) UploadAsset(ctx context.Context, task *UploadTask) (chat1.Asset, error)

type StreamSource

type StreamSource struct {
	chat1.LocalSource
	// contains filtered or unexported fields
}

func NewStreamSource

func NewStreamSource(s chat1.LocalSource) *StreamSource

func (*StreamSource) Basename

func (s *StreamSource) Basename() string

func (*StreamSource) Close

func (s *StreamSource) Close() error

func (*StreamSource) FileSize

func (s *StreamSource) FileSize() int

func (*StreamSource) Open

func (s *StreamSource) Open(sessionID int, cli *keybase1.StreamUiClient) (ReadResetter, error)

type UploadTask

type UploadTask struct {
	S3Params  chat1.S3Params
	Filename  string
	FileSize  int
	Plaintext ReadResetter

	S3Signer       s3.Signer
	ConversationID chat1.ConversationID
	UserID         keybase1.UID
	Progress       types.ProgressReporter
	// contains filtered or unexported fields
}

func (*UploadTask) Nonce

func (u *UploadTask) Nonce() signencrypt.Nonce

Jump to

Keyboard shortcuts

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