backend

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2016 License: AGPL-3.0-or-later Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	RANDOM_TAG_ALPHABET = "abcdefghijklmnopqrstuvwxyz0123456789"
	RANDOM_TAG_LENGTH   = 9
)
View Source
var (
	ErrConfigExists = errors.New("Backend config already exists")
)
View Source
var (
	HttpGetTimeout = 300 * time.Second
)

Functions

func CreateFileRow

func CreateFileRow(bk Backend, pairs types.TagPairs, filename string, plaintags []string) (*types.Row, error)

func CreateJSONRow

func CreateJSONRow(bk Backend, pairs types.TagPairs, obj interface{}, plaintags []string) (*types.Row, error)

func CreateRow

func CreateRow(bk Backend, pairs types.TagPairs, rowData []byte, plaintags []string) (*types.Row, error)

func CreateTag

func CreateTag(backend Backend, plaintag string) (*types.TagPair, error)

func CreateTagsFromPlain

func CreateTagsFromPlain(backend Backend, plaintags []string, pairs types.TagPairs) (newPairs types.TagPairs, err error)

func DeleteRows

func DeleteRows(bk Backend, pairs types.TagPairs, plaintags cryptag.PlainTags) error

func DropboxConfigToMap

func DropboxConfigToMap(cfg DropboxConfig) map[string]interface{}

func ListRowsFromPlainTags

func ListRowsFromPlainTags(bk Backend, pairs types.TagPairs, plaintags cryptag.PlainTags) (types.Rows, error)

func NewTagPair

func NewTagPair(key *[32]byte, plaintag string) (*types.TagPair, error)

func PopulateRowBeforeSave

func PopulateRowBeforeSave(backend Backend, row *types.Row, pairs types.TagPairs) (newPairs types.TagPairs, err error)

func RowsFromPlainTags

func RowsFromPlainTags(bk Backend, pairs types.TagPairs, plaintags cryptag.PlainTags) (types.Rows, error)

func UpdateKey

func UpdateKey(bk Backend, newKey interface{}) error

newKey can be of type *[32]byte, []byte (with length 32), or a string to be parsed with keyutil.Parse.

func WebserverConfigToMap

func WebserverConfigToMap(cfg WebserverConfig) map[string]interface{}

Types

type Backend

type Backend interface {
	Name() string
	Key() *[32]byte

	AllTagPairs(oldPairs types.TagPairs) (types.TagPairs, error)
	TagPairsFromRandomTags(randtags cryptag.RandomTags) (types.TagPairs, error)
	SaveTagPair(pair *types.TagPair) error

	ListRows(randtags cryptag.RandomTags) (types.Rows, error)
	RowsFromRandomTags(randtags cryptag.RandomTags) (types.Rows, error)
	SaveRow(row *types.Row) error
	DeleteRows(randtags cryptag.RandomTags) error

	ToConfig() (*Config, error)
}

type Config

type Config struct {
	Name     string
	New      bool `json:"-"`
	Key      *[32]byte
	Local    bool
	DataPath string // Used by backend.FileSystem, other local backends

	Custom map[string]interface{} `json:",omitempty"` // Used by Dropbox, Webserver, other backends
}

func (*Config) Backup

func (conf *Config) Backup(backendsDir string) error

func (*Config) Canonicalize

func (conf *Config) Canonicalize() error

func (*Config) Save

func (conf *Config) Save(backendsDir string) error

func (*Config) Update

func (conf *Config) Update(backendsDir string) error

type DropboxConfig

type DropboxConfig struct {
	AppKey      string
	AppSecret   string
	AccessToken string
	BasePath    string // e.g., "/cryptag_folder_in_dropbox_root"
}

func DropboxConfigFromMap

func DropboxConfigFromMap(m map[string]interface{}) (DropboxConfig, error)

func (*DropboxConfig) Valid

func (dc *DropboxConfig) Valid() error

type DropboxRemote

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

func LoadDropboxRemote

func LoadDropboxRemote(backendPath, backendName string) (*DropboxRemote, error)

func NewDropboxRemote

func NewDropboxRemote(key []byte, name string, cfg DropboxConfig) (*DropboxRemote, error)

NewDropboxRemote will save this backend to disk if len(key) == 0 or name == "".

func (*DropboxRemote) AllTagPairs

func (db *DropboxRemote) AllTagPairs(oldPairs types.TagPairs) (types.TagPairs, error)

func (*DropboxRemote) DeleteRows

func (db *DropboxRemote) DeleteRows(randTags cryptag.RandomTags) error

func (*DropboxRemote) GetTagCursor

func (db *DropboxRemote) GetTagCursor() string

GetTagCursor gets the cursor for the remote tags directory used for incremental TagPair fetching.

func (*DropboxRemote) Key

func (db *DropboxRemote) Key() *[32]byte

func (*DropboxRemote) ListRows

func (db *DropboxRemote) ListRows(randtags cryptag.RandomTags) (types.Rows, error)

func (*DropboxRemote) Name

func (db *DropboxRemote) Name() string

func (*DropboxRemote) RowsFromRandomTags

func (db *DropboxRemote) RowsFromRandomTags(randtags cryptag.RandomTags) (types.Rows, error)

func (*DropboxRemote) SaveRow

func (db *DropboxRemote) SaveRow(row *types.Row) error

func (*DropboxRemote) SaveTagPair

func (db *DropboxRemote) SaveTagPair(pair *types.TagPair) error

func (*DropboxRemote) SetHTTPClient

func (db *DropboxRemote) SetHTTPClient(c *http.Client)

SetHTTPClient sets the underlying HTTP client used. Probably most useful for using a custom client that does proxied requests, perhaps through Tor.

func (*DropboxRemote) SetTagCursor

func (db *DropboxRemote) SetTagCursor(cursor string)

SetTagCursor sets the cursor for the remote tags directory incremental TagPair fetching so it can be used for incremental TagPair fetching.

func (*DropboxRemote) TagPairsFromRandomTags

func (db *DropboxRemote) TagPairsFromRandomTags(randtags cryptag.RandomTags) (types.TagPairs, error)

func (*DropboxRemote) ToConfig

func (db *DropboxRemote) ToConfig() (*Config, error)

func (*DropboxRemote) UseTor

func (db *DropboxRemote) UseTor() error

UseTor sets db's HTTP client to one that uses Tor.

type FileSystem

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

func LoadOrCreateFileSystem

func LoadOrCreateFileSystem(backendPath, backendName string) (*FileSystem, error)

func NewFileSystem

func NewFileSystem(conf *Config) (*FileSystem, error)

func (*FileSystem) AllTagPairs

func (fs *FileSystem) AllTagPairs(oldPairs types.TagPairs) (types.TagPairs, error)

func (*FileSystem) DeleteRows

func (fs *FileSystem) DeleteRows(randTags cryptag.RandomTags) error

func (*FileSystem) Key

func (fs *FileSystem) Key() *[32]byte

func (*FileSystem) ListRows

func (fs *FileSystem) ListRows(randtags cryptag.RandomTags) (types.Rows, error)

func (*FileSystem) Name

func (fs *FileSystem) Name() string

func (*FileSystem) RowsFromRandomTags

func (fs *FileSystem) RowsFromRandomTags(randtags cryptag.RandomTags) (types.Rows, error)

func (*FileSystem) SaveRow

func (fs *FileSystem) SaveRow(row *types.Row) error

func (*FileSystem) SaveTagPair

func (fs *FileSystem) SaveTagPair(pair *types.TagPair) error

func (*FileSystem) TagPairsFromRandomTags

func (fs *FileSystem) TagPairsFromRandomTags(randtags cryptag.RandomTags) (types.TagPairs, error)

func (*FileSystem) ToConfig

func (fs *FileSystem) ToConfig() (*Config, error)

type WebserverBackend

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

func CreateWebserver

func CreateWebserver(key []byte, backendName, baseURL, authToken string) (*WebserverBackend, error)

CreateWebserver is a high-level function that creates a new WebserverBackend and saves its config to disk. (Useful for config init and more.)

func LoadWebserverBackend

func LoadWebserverBackend(backendPath, backendName string) (*WebserverBackend, error)

func NewWebserverBackend

func NewWebserverBackend(key []byte, serverName, serverBaseUrl, authToken string) (*WebserverBackend, error)

func (*WebserverBackend) AllTagPairs

func (wb *WebserverBackend) AllTagPairs(oldPairs types.TagPairs) (types.TagPairs, error)

func (*WebserverBackend) DeleteRows

func (wb *WebserverBackend) DeleteRows(randtags cryptag.RandomTags) error

func (*WebserverBackend) Key

func (wb *WebserverBackend) Key() *[32]byte

func (*WebserverBackend) ListRows

func (wb *WebserverBackend) ListRows(randtags cryptag.RandomTags) (types.Rows, error)

func (*WebserverBackend) Name

func (wb *WebserverBackend) Name() string

func (*WebserverBackend) RowsFromRandomTags

func (wb *WebserverBackend) RowsFromRandomTags(randtags cryptag.RandomTags) (types.Rows, error)

func (*WebserverBackend) SaveRow

func (wb *WebserverBackend) SaveRow(row *types.Row) error

func (*WebserverBackend) SaveTagPair

func (wb *WebserverBackend) SaveTagPair(pair *types.TagPair) error

func (*WebserverBackend) SetHTTPClient

func (wb *WebserverBackend) SetHTTPClient(client *http.Client)

SetHTTPClient sets the underlying HTTP client used. Useful for using a custom client that does proxied requests, perhaps through Tor.

func (*WebserverBackend) TagPairsFromRandomTags

func (wb *WebserverBackend) TagPairsFromRandomTags(randtags cryptag.RandomTags) (types.TagPairs, error)

func (*WebserverBackend) ToConfig

func (wb *WebserverBackend) ToConfig() (*Config, error)

func (*WebserverBackend) UseTor

func (wb *WebserverBackend) UseTor() error

UseTor sets wb's HTTP client to one that uses Tor and records that Tor should be used.

type WebserverConfig

type WebserverConfig struct {
	AuthToken string
	BaseURL   string
}

func WebserverConfigFromMap

func WebserverConfigFromMap(m map[string]interface{}) (WebserverConfig, error)

func (*WebserverConfig) Valid

func (wc *WebserverConfig) Valid() error

Jump to

Keyboard shortcuts

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