author

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2018 License: Apache-2.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultLibrarianPort is the default port of the librarian server.
	DefaultLibrarianPort = 20100

	// DefaultLibrarianIP is the default IP of of the librarian server.
	DefaultLibrarianIP = "localhost"

	// DefaultLogLevel is the default log level to use.
	DefaultLogLevel = zap.InfoLevel

	// DataSubdir is the name of the data directory.
	DataSubdir = "author-data"

	// DBSubDir is the default DB subdirectory within the data dir.
	DBSubDir = "db"

	// KeychainSubDir is the default DB subdirectory within the data dir.
	KeychainSubDir = "keychain"
)
View Source
const (
	// LoggerClientID is a client ID.
	LoggerClientID = "clientId"

	// LoggerKeychainFilepath is a keychain filepath.
	LoggerKeychainFilepath = "keychainFilepath"

	// LoggerKeychainNKeys is the number of keys in the keychain.
	LoggerKeychainNKeys = "nKeys"
)

logger keys

View Source
const (
	// AuthorKeychainFilename defines the author keychain filename
	AuthorKeychainFilename = "author.keys"

	// SelfReaderKeychainFilename defines the self reader keychain filename
	SelfReaderKeychainFilename = "self-reader.keys"
)

Variables

View Source
var (
	// ErrKeychainExists indicates when a keychain file already exists.
	ErrKeychainExists = errors.New("keychain already exists")
)

Functions

func CreateKeychain

func CreateKeychain(logger *zap.Logger, filepath, auth string, scryptN, scryptP int) error

CreateKeychain creates a keychain in the given filepath with the given auth and Scrypt params.

func CreateKeychains

func CreateKeychains(logger *zap.Logger, keychainDir, auth string, scryptN, scryptP int) error

CreateKeychains creates the author and self reader keychains in the given keychain directory with the given authentication passphrase and Scrypt parameters.

func LoadKeychains

func LoadKeychains(keychainDir, auth string) (
	keychain.GetterSampler, keychain.GetterSampler, error)

LoadKeychains loads the author and self-reader keychains from a directory on the local filesystem.

func MissingKeychains

func MissingKeychains(keychainDir string) (bool, error)

MissingKeychains determines whether the author and self-reader keychains are missing.

Types

type Author

type Author struct {
	// ClientID is ID of this author client
	ClientID ecid.ID
	// contains filtered or unexported fields
}

Author is the main client of the libri network. It can upload, download, and share documents with other author clients.

func NewAuthor

func NewAuthor(
	config *Config,
	authorKeys keychain.GetterSampler,
	selfReaderKeys keychain.GetterSampler,
	logger *zap.Logger,
) (*Author, error)

NewAuthor creates a new *Author from the Config, decrypting the keychains with the supplied auth string.

func (*Author) Close

func (a *Author) Close() error

Close disconnects the author from its librarians and closes the DB.

func (*Author) CloseAndRemove

func (a *Author) CloseAndRemove() error

CloseAndRemove closes the author and removes all local state.

func (*Author) Download

func (a *Author) Download(content io.Writer, envKey id.ID) error

Download downloads, join, decrypts, and decompressed the content, writing it to a unified output content writer.

func (*Author) Healthcheck

Healthcheck executes and reports healthcheck status for all connected librarians.

func (*Author) Share

func (a *Author) Share(envKey id.ID, readerPub *ecdsa.PublicKey) (*api.Document, id.ID, error)

Share creates and uploads a new envelope with the given reader public key. The new envelope has the same entry and entry encryption key as that of envelopeKey.

func (*Author) ShareEnvelope added in v0.3.0

func (a *Author) ShareEnvelope(env *api.Envelope, readerPub *ecdsa.PublicKey) (
	*api.Document, id.ID, error)

ShareEnvelope creates and uploads a new envelope with the given reader public key. The new envelope has the same entry and entry encryption key as the envelope passed in.

func (*Author) Upload

func (a *Author) Upload(content io.Reader, mediaType string) (*api.Document, id.ID, error)

Upload compresses, encrypts, and splits the content into pages and then stores them in the libri network. It returns the uploaded envelope for self-storage and its key.

type Config

type Config struct {
	// DataDir is the directory on the local machine where the state and output of the
	// client is stored.
	DataDir string

	// DbDir is the local directory where this node's DB state is stored.
	DbDir string

	// KeychainDir is the local directory where the author keys are stored.
	KeychainDir string

	// OrgID is the organization ID of the peer, if one exists.
	OrgID ecid.ID

	// LibrarianAddrs is a list of public addresses of Librarian servers to issue request to.
	LibrarianAddrs []*net.TCPAddr

	// Print defines parameters for printing pages to local storage.
	Print *print.Parameters

	// Publish defines parameters for publishing pages to libri.
	Publish *publish.Parameters

	// LogLevel is the log level
	LogLevel zapcore.Level
}

Config is used to configure an Author.

func NewDefaultConfig

func NewDefaultConfig() *Config

NewDefaultConfig returns a reasonable default author configuration.

func (*Config) WithDBDir

func (c *Config) WithDBDir(dbDir string) *Config

WithDBDir sets the DB dir to the given value or the default if the given value is empty.

func (*Config) WithDataDir

func (c *Config) WithDataDir(dataDir string) *Config

WithDataDir sets the data dir to the given value or the default if the given value is empty.

func (*Config) WithDefaultDBDir

func (c *Config) WithDefaultDBDir() *Config

WithDefaultDBDir sets the DB dir to a local name subdir of the data dir.

func (*Config) WithDefaultDataDir

func (c *Config) WithDefaultDataDir() *Config

WithDefaultDataDir sets the data dir to a 'data' subdir of the current working directory..

func (*Config) WithDefaultKeychainDir

func (c *Config) WithDefaultKeychainDir() *Config

WithDefaultKeychainDir sets the keychain dir to a local name subdir of the data dir.

func (*Config) WithDefaultLibrarianAddrs

func (c *Config) WithDefaultLibrarianAddrs() *Config

WithDefaultLibrarianAddrs sets the librarian addresses to a single address of the default IP and port.

func (*Config) WithDefaultLogLevel

func (c *Config) WithDefaultLogLevel() *Config

WithDefaultLogLevel sets the log level to INFO.

func (*Config) WithDefaultPrint

func (c *Config) WithDefaultPrint() *Config

WithDefaultPrint sets the Print parameters to the default values specified in the print package.

func (*Config) WithDefaultPublish

func (c *Config) WithDefaultPublish() *Config

WithDefaultPublish sets the Publish parameters to the default values specified in the publish package.

func (*Config) WithKeychainDir

func (c *Config) WithKeychainDir(keychainDir string) *Config

WithKeychainDir sets the keychain dir to the given value or the default if the given value is empty.

func (*Config) WithLibrarianAddrs

func (c *Config) WithLibrarianAddrs(librarianAddrs []*net.TCPAddr) *Config

WithLibrarianAddrs sets the librarian addresses to the given value or the default if the given value is empty.

func (*Config) WithLogLevel

func (c *Config) WithLogLevel(logLevel zapcore.Level) *Config

WithLogLevel sets the log level to the given value, though this doesn't have any direct effect on the creation of the logger instance.

func (*Config) WithPrint

func (c *Config) WithPrint(params *print.Parameters) *Config

WithPrint sets the Print parameters to the given value or the default if it is nil.

func (*Config) WithPublish

func (c *Config) WithPublish(params *publish.Parameters) *Config

WithPublish sets the Publish parameters to the given value or the default if it is nil.

Directories

Path Synopsis
io
enc
Package keychain is a generated protocol buffer package.
Package keychain is a generated protocol buffer package.

Jump to

Keyboard shortcuts

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