Documentation ¶
Overview ¶
Package mailfull contains operations for a mailfull repository.
Index ¶
- Constants
- Variables
- func InitRepository(rootPath string) error
- type AliasDomain
- type AliasUser
- type CatchAllUser
- type Domain
- type Repository
- func (r *Repository) AliasDomain(aliasDomainName string) (*AliasDomain, error)
- func (r *Repository) AliasDomainCreate(aliasDomain *AliasDomain) error
- func (r *Repository) AliasDomainRemove(aliasDomainName string) error
- func (r *Repository) AliasDomains() ([]*AliasDomain, error)
- func (r *Repository) AliasUser(domainName, aliasUserName string) (*AliasUser, error)
- func (r *Repository) AliasUserCreate(domainName string, aliasUser *AliasUser) error
- func (r *Repository) AliasUserRemove(domainName string, aliasUserName string) error
- func (r *Repository) AliasUserUpdate(domainName string, aliasUser *AliasUser) error
- func (r *Repository) AliasUsers(domainName string) ([]*AliasUser, error)
- func (r *Repository) CatchAllUser(domainName string) (*CatchAllUser, error)
- func (r *Repository) CatchAllUserSet(domainName string, catchAllUser *CatchAllUser) error
- func (r *Repository) CatchAllUserUnset(domainName string) error
- func (r *Repository) Domain(domainName string) (*Domain, error)
- func (r *Repository) DomainCreate(domain *Domain) error
- func (r *Repository) DomainRemove(domainName string) error
- func (r *Repository) DomainUpdate(domain *Domain) error
- func (r *Repository) Domains() ([]*Domain, error)
- func (r *Repository) GenerateConfigDovecot() string
- func (r *Repository) GenerateConfigPostfix() string
- func (r *Repository) GenerateDatabases() error
- func (r *Repository) User(domainName, userName string) (*User, error)
- func (r *Repository) UserCreate(domainName string, user *User) error
- func (r *Repository) UserRemove(domainName, userName string) error
- func (r *Repository) UserUpdate(domainName string, user *User) error
- func (r *Repository) Users(domainName string) ([]*User, error)
- type RepositoryConfig
- type User
Constants ¶
const ( DirNameConfig = ".mailfull" FileNameConfig = "config" FileNameDomainDisable = ".vdomaindisable" FileNameAliasDomains = ".valiasdomains" FileNameUsersPassword = ".vpasswd" FileNameUserForwards = ".forward" FileNameAliasUsers = ".valiases" FileNameCatchAllUser = ".vcatchall" FileNameDbDomains = "domains" FileNameDbDestinations = "destinations" FileNameDbMaildirs = "maildirs" FileNameDbLocaltable = "localtable" FileNameDbForwards = "forwards" FileNameDbPasswords = "vpasswd" )
Filenames that are contained in the Repository.
const NeverMatchHashedPassword = "{SSHA}!!"
NeverMatchHashedPassword is hash string that is never match with any password.
const Version = "v1.0.3"
Version is a version number.
Variables ¶
var ( ErrInvalidRepository = errors.New("invalid repository") ErrNotRepository = errors.New("not a Mailfull repository (or any of the parent directories)") ErrRepositoryExist = errors.New("a Mailfull repository exists") )
Errors for the Repository.
var ( ErrDomainNotExist = errors.New("Domain: not exist") ErrDomainAlreadyExist = errors.New("Domain: already exist") ErrDomainIsAliasDomainTarget = errors.New("Domain: is set as alias") ErrAliasDomainNotExist = errors.New("AliasDomain: not exist") ErrAliasDomainAlreadyExist = errors.New("AliasDomain: already exist") ErrUserNotExist = errors.New("User: not exist") ErrUserAlreadyExist = errors.New("User: already exist") ErrUserIsCatchAllUser = errors.New("User: is set as catchall") ErrAliasUserNotExist = errors.New("AliasUser: not exist") ErrAliasUserAlreadyExist = errors.New("AliasUser: already exist") ErrInvalidFormatDomainDisabled = errors.New("Domain: disabled file invalid format") ErrInvalidFormatUsersPassword = errors.New("User: password file invalid format") ErrInvalidFormatAliasDomain = errors.New("AliasDomain: file invalid format") ErrInvalidFormatAliasUsers = errors.New("AliasUsers: file invalid format") )
Errors for the operation of the Repository.
var ( ErrInvalidDomainName = errors.New("Domain: name incorrect format") ErrInvalidAliasDomainName = errors.New("AliasDomain: name incorrect format") ErrInvalidAliasDomainTarget = errors.New("AliasDomain: target incorrect format") ErrInvalidUserName = errors.New("User: name incorrect format") ErrInvalidAliasUserName = errors.New("AliasUser: name incorrect format") ErrInvalidAliasUserTarget = errors.New("AliasUser: target incorrect format") ErrInvalidCatchAllUserName = errors.New("CatchAllUser: name incorrect format") )
Errors for incorrect format.
var (
ErrNotEnoughAliasUserTargets = errors.New("AliasUser: targets not enough")
)
Errors for parameter.
Functions ¶
func InitRepository ¶
InitRepository initializes the input directory as a Repository.
Types ¶
type AliasDomain ¶
type AliasDomain struct {
// contains filtered or unexported fields
}
AliasDomain represents a AliasDomain.
func NewAliasDomain ¶
func NewAliasDomain(name, target string) (*AliasDomain, error)
NewAliasDomain creates a new AliasDomain instance.
func (*AliasDomain) SetTarget ¶
func (ad *AliasDomain) SetTarget(target string) error
SetTarget sets the target.
type AliasUser ¶
type AliasUser struct {
// contains filtered or unexported fields
}
AliasUser represents a AliasUser.
func NewAliasUser ¶
NewAliasUser creates a new AliasUser instance.
func (*AliasUser) SetTargets ¶
SetTargets sets targets.
type CatchAllUser ¶
type CatchAllUser struct {
// contains filtered or unexported fields
}
CatchAllUser represents a CatchAllUser.
func NewCatchAllUser ¶
func NewCatchAllUser(name string) (*CatchAllUser, error)
NewCatchAllUser creates a new CatchAllUser instance.
type Domain ¶
type Domain struct { Users []*User AliasUsers []*AliasUser CatchAllUser *CatchAllUser // contains filtered or unexported fields }
Domain represents a Domain.
func (*Domain) SetDisabled ¶ added in v0.0.4
SetDisabled disables the Domain if the input is true.
type Repository ¶
type Repository struct { *RepositoryConfig // contains filtered or unexported fields }
Repository represents a Repository.
func NewRepository ¶
func NewRepository(c *RepositoryConfig) (*Repository, error)
NewRepository creates a new Repository instance.
func OpenRepository ¶
func OpenRepository(basePath string) (*Repository, error)
OpenRepository opens a Repository and creates a new Repository instance.
func (*Repository) AliasDomain ¶
func (r *Repository) AliasDomain(aliasDomainName string) (*AliasDomain, error)
AliasDomain returns a AliasDomain of the input name.
func (*Repository) AliasDomainCreate ¶
func (r *Repository) AliasDomainCreate(aliasDomain *AliasDomain) error
AliasDomainCreate creates the input AliasDomain.
func (*Repository) AliasDomainRemove ¶
func (r *Repository) AliasDomainRemove(aliasDomainName string) error
AliasDomainRemove removes a AliasDomain of the input name.
func (*Repository) AliasDomains ¶
func (r *Repository) AliasDomains() ([]*AliasDomain, error)
AliasDomains returns a AliasDomain slice.
func (*Repository) AliasUser ¶
func (r *Repository) AliasUser(domainName, aliasUserName string) (*AliasUser, error)
AliasUser returns a AliasUser of the input name.
func (*Repository) AliasUserCreate ¶
func (r *Repository) AliasUserCreate(domainName string, aliasUser *AliasUser) error
AliasUserCreate creates the input AliasUser.
func (*Repository) AliasUserRemove ¶
func (r *Repository) AliasUserRemove(domainName string, aliasUserName string) error
AliasUserRemove removes a AliasUser of the input name.
func (*Repository) AliasUserUpdate ¶
func (r *Repository) AliasUserUpdate(domainName string, aliasUser *AliasUser) error
AliasUserUpdate updates the input AliasUser.
func (*Repository) AliasUsers ¶
func (r *Repository) AliasUsers(domainName string) ([]*AliasUser, error)
AliasUsers returns a AliasUser slice.
func (*Repository) CatchAllUser ¶
func (r *Repository) CatchAllUser(domainName string) (*CatchAllUser, error)
CatchAllUser returns a CatchAllUser that the input name has.
func (*Repository) CatchAllUserSet ¶
func (r *Repository) CatchAllUserSet(domainName string, catchAllUser *CatchAllUser) error
CatchAllUserSet sets a CatchAllUser to the input Domain.
func (*Repository) CatchAllUserUnset ¶
func (r *Repository) CatchAllUserUnset(domainName string) error
CatchAllUserUnset removes a CatchAllUser from the input Domain.
func (*Repository) Domain ¶
func (r *Repository) Domain(domainName string) (*Domain, error)
Domain returns a Domain of the input name.
func (*Repository) DomainCreate ¶
func (r *Repository) DomainCreate(domain *Domain) error
DomainCreate creates the input Domain.
func (*Repository) DomainRemove ¶
func (r *Repository) DomainRemove(domainName string) error
DomainRemove removes a Domain of the input name.
func (*Repository) DomainUpdate ¶ added in v0.0.4
func (r *Repository) DomainUpdate(domain *Domain) error
DomainUpdate updates the input Domain.
func (*Repository) Domains ¶
func (r *Repository) Domains() ([]*Domain, error)
Domains returns a Domain slice.
func (*Repository) GenerateConfigDovecot ¶
func (r *Repository) GenerateConfigDovecot() string
GenerateConfigDovecot generate a configuration for Dovecot.
func (*Repository) GenerateConfigPostfix ¶
func (r *Repository) GenerateConfigPostfix() string
GenerateConfigPostfix generate a configuration for Postfix.
func (*Repository) GenerateDatabases ¶
func (r *Repository) GenerateDatabases() error
GenerateDatabases generates databases from the Repository.
func (*Repository) User ¶
func (r *Repository) User(domainName, userName string) (*User, error)
User returns a User of the input name.
func (*Repository) UserCreate ¶
func (r *Repository) UserCreate(domainName string, user *User) error
UserCreate creates the input User.
func (*Repository) UserRemove ¶
func (r *Repository) UserRemove(domainName, userName string) error
UserRemove removes a User of the input name.
func (*Repository) UserUpdate ¶
func (r *Repository) UserUpdate(domainName string, user *User) error
UserUpdate updates the input User.
type RepositoryConfig ¶
type RepositoryConfig struct { DirDatabasePath string `toml:"dir_database"` DirMailDataPath string `toml:"dir_maildata"` Username string `toml:"username"` CmdPostalias string `toml:"cmd_postalias"` CmdPostmap string `toml:"cmd_postmap"` }
RepositoryConfig is used to configure a Repository.
func DefaultRepositoryConfig ¶
func DefaultRepositoryConfig() *RepositoryConfig
DefaultRepositoryConfig returns a RepositoryConfig with default parameter.
func (*RepositoryConfig) Normalize ¶
func (c *RepositoryConfig) Normalize(rootPath string)
Normalize normalizes paramaters of the RepositoryConfig.
type User ¶
type User struct {
// contains filtered or unexported fields
}
User represents a User.
func (*User) HashedPassword ¶
HashedPassword returns hashedPassword.
func (*User) SetHashedPassword ¶
SetHashedPassword sets the hashed password.