Documentation ¶
Index ¶
- Variables
- func CreateRPCServiceClient() *gorpc.DispatcherClient
- func ReadConfigFromFile(path string) error
- func ReadConfigFromReader(reader io.Reader) error
- func ResetConfig()
- func ValidConfig() bool
- type IncognitoData
- func (a *IncognitoData) Close()
- func (a *IncognitoData) DeleteAccount(secret string)
- func (a *IncognitoData) DeleteAccountHandle(secret, handle string)
- func (a *IncognitoData) GetAccountTarget(secret string) (string, error)
- func (a *IncognitoData) HasAccount(secret string) bool
- func (a *IncognitoData) HasHandleGlobal(handle string) bool
- func (a *IncognitoData) ListAccountHandles(secret string) ([]string, error)
- func (a *IncognitoData) NewAccount(secret, target string) error
- func (a *IncognitoData) NewAccountHandle(secret, handle string) error
- type MailSystemHandleWriter
- type PostfixWriter
- type Server
- func (s *Server) DeleteAccount(secret string) error
- func (s *Server) DeleteHandle(secret, handle string) error
- func (s *Server) ListHandles(secret string) ([]string, error)
- func (s *Server) NewAccount(target string) (string, error)
- func (s *Server) NewHandle(accountSecret string) (string, error)
- func (s *Server) SendCommand(source, args string) (string, error)
- func (s *Server) Start()
- func (s *Server) Stop()
- func (s *Server) Wait() error
Constants ¶
This section is empty.
Variables ¶
var ( // Config holds all global configuration. Config = defaultConfig // ErrInvalidConfig is used when loading a configuration with invalid values. ErrInvalidConfig = errors.New("invalid configuration values") )
var ( // ErrEmptySecret is used when an empty account secret is used. ErrEmptySecret = errors.New("empty secret") // ErrEmptyTarget is used when an empty account target is used. ErrEmptyTarget = errors.New("empty target") // ErrAccountNotFound is used when an action requires an account to exist, but it wasn't found. ErrAccountNotFound = errors.New("account not found") // ErrAccountExists is used when trying to create an account with a given secret, but it already exists. ErrAccountExists = errors.New("account already exists") // ErrHandleNotFound is used when an action requires a handle to exist, but it wasn't found. ErrHandleNotFound = errors.New("handle not found") // ErrHandleExists is used when trying to create a handle, but it already exists. ErrHandleExists = errors.New("handle already exists") )
var ( // ErrServerNotStarted is used whenever an action is taken that expects a started server, but the server is actually not started. ErrServerNotStarted = errors.New("server not started") // ErrLockFileAlreadyExists is used only when trying to acquire a lock file, but the lock file already exists. ErrLockFileAlreadyExists = errors.New("lock file already exists") // ErrLockFileNotFound is used whenever an action requires a lock file to be used, but the lock file handle is nil. ErrLockFileNotFound = errors.New("could not find lock file") // ErrEmptyCommand is used when the server receives an empty command. ErrEmptyCommand = errors.New("empty command received") // ErrUnknownCommand is used when the server receives an unknown/garbage command. ErrUnknownCommand = errors.New("unknown command received") // ErrWrongCommand is used when a known command is received, but is malformed. ErrWrongCommand = errors.New("wrong command usage") // ErrInvalidPermission is used when a command has been received from the websocket, but the server shouldn't execute it. ErrInvalidPermission = errors.New("invalid permission to do this") )
Functions ¶
func CreateRPCServiceClient ¶
func CreateRPCServiceClient() *gorpc.DispatcherClient
CreateRPCServiceClient creates and returns a reasy to use RPC dispatcher client.
func ReadConfigFromFile ¶
ReadConfigFromFile reads the file in the given path and parses all config data from it. Any value not defined in this configuration file will be kept as its default value.
func ReadConfigFromReader ¶
ReadConfigFromReader parses all config data from the given reader. Any value not defined in the read string will be kept as its default value.
func ValidConfig ¶
func ValidConfig() bool
ValidConfig returns true if the current Config is valid, i.e. not likely to crash the server.
Types ¶
type IncognitoData ¶
type IncognitoData struct {
// contains filtered or unexported fields
}
IncognitoData holds a "connection" to the persistence layer. To create a valid IncognitoData object, call OpenIncognitoData().
func OpenIncognitoData ¶
func OpenIncognitoData() (*IncognitoData, error)
OpenIncognitoData returns an IncognitoData object with a successful "connection" to the persistence layer, ready to be used.
func (*IncognitoData) Close ¶
func (a *IncognitoData) Close()
Close closes the "connection" with the persistence layer.
func (*IncognitoData) DeleteAccount ¶
func (a *IncognitoData) DeleteAccount(secret string)
DeleteAccount deletes all information related to the account with the given secret. If no account with that secret exists, it does nothing.
func (*IncognitoData) DeleteAccountHandle ¶
func (a *IncognitoData) DeleteAccountHandle(secret, handle string)
DeleteAccountHandle deletes the given handle from the account with the given secret. If either the account or the handle does not exist, this does nothing.
func (*IncognitoData) GetAccountTarget ¶
func (a *IncognitoData) GetAccountTarget(secret string) (string, error)
GetAccountTarget returns the target registered for the account with the given secret.
func (*IncognitoData) HasAccount ¶
func (a *IncognitoData) HasAccount(secret string) bool
HasAccount returns true if an account with the given secret exists, false otherwise.
func (*IncognitoData) HasHandleGlobal ¶
func (a *IncognitoData) HasHandleGlobal(handle string) bool
HasHandleGlobal returns true if the given handle exists for any account, false otherwise.
func (*IncognitoData) ListAccountHandles ¶
func (a *IncognitoData) ListAccountHandles(secret string) ([]string, error)
ListAccountHandles returns an array with all handles from the account with the given secret.
func (*IncognitoData) NewAccount ¶
func (a *IncognitoData) NewAccount(secret, target string) error
NewAccount generates a new account with the given secret and target email address.
func (*IncognitoData) NewAccountHandle ¶
func (a *IncognitoData) NewAccountHandle(secret, handle string) error
NewAccountHandle stores the given handle for the account with the given secret.
type MailSystemHandleWriter ¶
type MailSystemHandleWriter interface { AddHandle(string, string) (string, error) RemoveHandle(string) error }
MailSystemHandleWriter has methods for adding and removing mappings from the mail system.
type PostfixWriter ¶
type PostfixWriter struct {
// contains filtered or unexported fields
}
PostfixWriter holds all the information required to add or remove handles to a postfix system.
func NewPostfixWriter ¶
func NewPostfixWriter() *PostfixWriter
NewPostfixWriter returns a PostfixWriter object initialized with values from the config.
func (*PostfixWriter) AddHandle ¶
func (p *PostfixWriter) AddHandle(h string, t string) (string, error)
AddHandle adds a handle to the map file.
func (*PostfixWriter) RemoveHandle ¶
func (p *PostfixWriter) RemoveHandle(h string) error
RemoveHandle scans a map file for a line starting with the handle and removes it.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server holds all the data required to run the server.
func (*Server) DeleteAccount ¶
DeleteAccount deletes all data from the account with the given secret. If the account does not exist, it returns an error.
func (*Server) DeleteHandle ¶
DeleteHandle deletes the given handle from the account with the given secret. If the account does not exist, it returns an error.
func (*Server) ListHandles ¶
ListHandles returns all handles from the account with the given secret.
func (*Server) NewAccount ¶
NewAccount creates a new account with the given target email address and returns the secret.
func (*Server) SendCommand ¶
SendCommand is executed for every message received either by the websocket or RPC interface. Builds a well-defined command to send to the goroutine listening for commands to execute.