Documentation ¶
Index ¶
- Constants
- func WriteBlock(block *Block, crypter Crypter, writer BlockWriter) error
- type AESCrypter
- type AESDecryptionReader
- type AESEncryptionReader
- type Block
- type BlockLocation
- type BlockMetadata
- type BlockReader
- type BlockWriter
- type Config
- type Crypter
- type File
- type FileMetadata
- type Index
- func (ix *Index) AddFile(file File, reader BlockReader, writer BlockWriter, crypter Crypter) error
- func (ix *Index) DeleteFile(filename string, reader BlockReader, writer BlockWriter, crypter Crypter, ...) error
- func (ix *Index) GetFile(filename string, destination io.Writer, reader BlockReader, crypter Crypter) error
- func (ix *Index) ListFiles() []FileMetadata
- func (ix *Index) Save(writer IndexWriter, crypter Crypter) error
- type IndexReader
- type IndexWriter
- type LocalFileReadWriter
Constants ¶
const ( // ConfigfilePath is the default config file path ConfigfilePath string = "config.json" // DefaultBlockSize is the default block size (5 MB) DefaultBlockSize int = 5242880 // 5 MB // DefaultChunkSize is the default chunk size (512 bytes) DefaultChunkSize int = 512 // 512 bytes // DefaultIndexfile is the default index file path DefaultIndexfile string = "index" )
Variables ¶
This section is empty.
Functions ¶
func WriteBlock ¶
func WriteBlock(block *Block, crypter Crypter, writer BlockWriter) error
Types ¶
type AESCrypter ¶
type AESCrypter struct {
// contains filtered or unexported fields
}
AESCrypter is a struct that can encrypt and decypt bytes using AES and a common key
func NewAESCrypter ¶
func NewAESCrypter(key []byte) (*AESCrypter, error)
NewAESCrypter creates a new AESCrypter with the provided key
func (*AESCrypter) Decrypt ¶
func (a *AESCrypter) Decrypt(bytes []byte) ([]byte, error)
Decrypt decrypts the bytes passed to it
func (*AESCrypter) Decrypter ¶
Decrypter returns an io.Reader which, when read, returns the decrypted bytes of the `source` io.Reader
type AESDecryptionReader ¶
AESDecryptionReader is an io.Reader which provides the decrypted version of a source io.Reader when read The source io.Reader should be positioned at the start of the ciphertext when initialized
type AESEncryptionReader ¶
type AESEncryptionReader struct { Source io.Reader Stream cipher.Stream IV []byte // contains filtered or unexported fields }
AESEncyptionReader is an io.Reader which provides the encrypted version of a source io.Reader when read
type Block ¶
type BlockLocation ¶
BlockLocation describes a section of bytes on a block
type BlockMetadata ¶
type BlockReader ¶
type BlockWriter ¶
type Config ¶
Config is the basic configuration for enstore
func NewDefaultConfig ¶
func NewDefaultConfig() *Config
NewDefaultConfig returns a pointer to a new Config with default values
type FileMetadata ¶
type FileMetadata struct { Filename string Size int64 Blocks []BlockLocation }
FileMetadata contains file metadata in the Index
type Index ¶
type Index struct {
// contains filtered or unexported fields
}
Index keeps track of all files and blocks and where all files exist across each block. It has methods for adding, removing, getting, and listing files on the blocks.
func LoadIndex ¶
func LoadIndex(reader IndexReader, crypter Crypter, cfg *Config) (*Index, error)
LoadIndex will attempt to load an existing index file and decrypt its store. If no file exists, it will create a new one with the supplied key.
func (*Index) AddFile ¶
func (ix *Index) AddFile(file File, reader BlockReader, writer BlockWriter, crypter Crypter) error
AddFile will add a file to the index and write it to any blocks with space, creating new blocks as necessary
func (*Index) DeleteFile ¶
func (ix *Index) DeleteFile(filename string, reader BlockReader, writer BlockWriter, crypter Crypter, zeroOut bool) error
func (*Index) GetFile ¶
func (ix *Index) GetFile(filename string, destination io.Writer, reader BlockReader, crypter Crypter) error
GetFile will read all blocks a file in the index is stored on, and assemble and return the unencrypted file
func (*Index) ListFiles ¶
func (ix *Index) ListFiles() []FileMetadata
ListFiles returns a slice of all the files in the index. This slice is a copy of the internal store, so manipulations can be performed on it
type IndexReader ¶
type IndexReader interface { BlockReader Exists(filename string) bool }
IndexReader exposes BlockReader method(s), and a method to check the existence of a file
type LocalFileReadWriter ¶
type LocalFileReadWriter struct {
BasePath string
}
func (*LocalFileReadWriter) Exists ¶
func (lfrw *LocalFileReadWriter) Exists(filename string) bool