Documentation ¶
Index ¶
- Constants
- Variables
- func CreateKeychain(logger *zap.Logger, filepath, auth string, scryptN, scryptP int) error
- func CreateKeychains(logger *zap.Logger, keychainDir, auth string, scryptN, scryptP int) error
- func LoadKeychains(keychainDir, auth string) (keychain.GetterSampler, keychain.GetterSampler, error)
- func MissingKeychains(keychainDir string) (bool, error)
- type Author
- func (a *Author) Close() error
- func (a *Author) CloseAndRemove() error
- func (a *Author) Download(content io.Writer, envKey id.ID) error
- func (a *Author) Healthcheck() (bool, map[string]healthpb.HealthCheckResponse_ServingStatus)
- func (a *Author) Share(envKey id.ID, readerPub *ecdsa.PublicKey) (*api.Document, id.ID, error)
- func (a *Author) ShareEnvelope(env *api.Envelope, readerPub *ecdsa.PublicKey) (*api.Document, id.ID, error)
- func (a *Author) Upload(content io.Reader, mediaType string) (*api.Document, id.ID, error)
- type Config
- func (c *Config) WithDBDir(dbDir string) *Config
- func (c *Config) WithDataDir(dataDir string) *Config
- func (c *Config) WithDefaultDBDir() *Config
- func (c *Config) WithDefaultDataDir() *Config
- func (c *Config) WithDefaultKeychainDir() *Config
- func (c *Config) WithDefaultLibrarianAddrs() *Config
- func (c *Config) WithDefaultLogLevel() *Config
- func (c *Config) WithDefaultPrint() *Config
- func (c *Config) WithDefaultPublish() *Config
- func (c *Config) WithKeychainDir(keychainDir string) *Config
- func (c *Config) WithLibrarianAddrs(librarianAddrs []*net.TCPAddr) *Config
- func (c *Config) WithLogLevel(logLevel zapcore.Level) *Config
- func (c *Config) WithPrint(params *print.Parameters) *Config
- func (c *Config) WithPublish(params *publish.Parameters) *Config
Constants ¶
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" )
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
const ( // AuthorKeychainFilename defines the author keychain filename AuthorKeychainFilename = "author.keys" // SelfReaderKeychainFilename defines the self reader keychain filename SelfReaderKeychainFilename = "self-reader.keys" )
Variables ¶
var ( // ErrKeychainExists indicates when a keychain file already exists. ErrKeychainExists = errors.New("keychain already exists") )
Functions ¶
func CreateKeychain ¶
CreateKeychain creates a keychain in the given filepath with the given auth and Scrypt params.
func CreateKeychains ¶
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 ¶
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) CloseAndRemove ¶
CloseAndRemove closes the author and removes all local state.
func (*Author) Download ¶
Download downloads, join, decrypts, and decompressed the content, writing it to a unified output content writer.
func (*Author) Healthcheck ¶
func (a *Author) Healthcheck() (bool, map[string]healthpb.HealthCheckResponse_ServingStatus)
Healthcheck executes and reports healthcheck status for all connected librarians.
func (*Author) Share ¶
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.
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 ¶
WithDBDir sets the DB dir to the given value or the default if the given value is empty.
func (*Config) WithDataDir ¶
WithDataDir sets the data dir to the given value or the default if the given value is empty.
func (*Config) WithDefaultDBDir ¶
WithDefaultDBDir sets the DB dir to a local name subdir of the data dir.
func (*Config) WithDefaultDataDir ¶
WithDefaultDataDir sets the data dir to a 'data' subdir of the current working directory..
func (*Config) WithDefaultKeychainDir ¶
WithDefaultKeychainDir sets the keychain dir to a local name subdir of the data dir.
func (*Config) WithDefaultLibrarianAddrs ¶
WithDefaultLibrarianAddrs sets the librarian addresses to a single address of the default IP and port.
func (*Config) WithDefaultLogLevel ¶
WithDefaultLogLevel sets the log level to INFO.
func (*Config) WithDefaultPrint ¶
WithDefaultPrint sets the Print parameters to the default values specified in the print package.
func (*Config) WithDefaultPublish ¶
WithDefaultPublish sets the Publish parameters to the default values specified in the publish package.
func (*Config) WithKeychainDir ¶
WithKeychainDir sets the keychain dir to the given value or the default if the given value is empty.
func (*Config) WithLibrarianAddrs ¶
WithLibrarianAddrs sets the librarian addresses to the given value or the default if the given value is empty.
func (*Config) WithLogLevel ¶
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.