Documentation ¶
Index ¶
- Variables
- func IsErrConstraintForeignKey(err error) bool
- func IsErrConstraintNotNull(err error) bool
- func IsErrConstraintUnique(err error) bool
- type Access
- type Address
- func (a *Address) Address() string
- func (a *Address) Alias() (*Alias, error)
- func (a *Address) AttachAlias(target string) error
- func (a *Address) ClearRclass() error
- func (a *Address) ClearTransport() error
- func (a *Address) Export() string
- func (a *Address) Id() int64
- func (a *Address) InVMailDomain() bool
- func (a *Address) IsLocal() bool
- func (a *Address) Rclass() string
- func (a *Address) SetRclass(name string) error
- func (a *Address) SetTransport(name string) error
- func (a *Address) Transport() string
- type AddressParts
- type Alias
- type Class
- type Domain
- func (d *Domain) Class() string
- func (d *Domain) ClearRclass() error
- func (d *Domain) ClearTransport() error
- func (d *Domain) ClearVGid() error
- func (d *Domain) ClearVUid() error
- func (d *Domain) Export() string
- func (d *Domain) Id() int64
- func (d *Domain) IsInternet() bool
- func (d *Domain) IsLocal() bool
- func (d *Domain) IsRelay() bool
- func (d *Domain) IsVirtual() bool
- func (d *Domain) IsVmailbox() bool
- func (d *Domain) Name() string
- func (d *Domain) Rclass() string
- func (d *Domain) SetClass(class string) error
- func (d *Domain) SetRclass(rclass string) error
- func (d *Domain) SetTransport(name string) error
- func (d *Domain) SetVGid(vgid int64) error
- func (d *Domain) SetVUid(vuid int64) error
- func (d *Domain) Transport() string
- func (d *Domain) Vgid() string
- func (d *Domain) Vuid() string
- type Input
- type MailDB
- func (mdb *MailDB) Begin()
- func (mdb *MailDB) Close()
- func (mdb *MailDB) DefaultInt(sym string) int64
- func (mdb *MailDB) DefaultString(sym string) string
- func (mdb *MailDB) DeleteAccess(name string) error
- func (mdb *MailDB) DeleteAddress(addr string) error
- func (mdb *MailDB) DeleteDomain(name string) error
- func (mdb *MailDB) DeleteTransport(name string) error
- func (mdb *MailDB) DeleteVMailbox(address string) error
- func (mdb *MailDB) End(err *error)
- func (mdb *MailDB) FindAccess(name string) ([]*Access, error)
- func (mdb *MailDB) FindAddress(address string) ([]*Address, error)
- func (mdb *MailDB) FindDomain(name string) ([]*Domain, error)
- func (mdb *MailDB) FindTransport(name string) ([]*Transport, error)
- func (mdb *MailDB) FindVMailbox(user string) ([]*VMailbox, error)
- func (mdb *MailDB) GetAccess(name string) (*Access, error)
- func (mdb *MailDB) GetAddress(addr string) (*Address, error)
- func (mdb *MailDB) GetDomain(name string) (*Domain, error)
- func (mdb *MailDB) GetOrInsAddress(addr string) (*Address, error)
- func (mdb *MailDB) GetTransport(name string) (*Transport, error)
- func (mdb *MailDB) GetVMailbox(user string) (*VMailbox, error)
- func (mdb *MailDB) InsertAccess(name string, action string) (*Access, error)
- func (mdb *MailDB) InsertAddress(address string) (*Address, error)
- func (mdb *MailDB) InsertDomain(name string) (*Domain, error)
- func (mdb *MailDB) InsertTransport(name string) (*Transport, error)
- func (mdb *MailDB) InsertVMailbox(user string) (*VMailbox, error)
- func (mdb *MailDB) LoadSchema(schema string) error
- func (mdb *MailDB) LookupAccess(name string) (*Access, error)
- func (mdb *MailDB) LookupAddress(addr string) (*Address, error)
- func (mdb *MailDB) LookupAlias(alias string) ([]*Alias, error)
- func (mdb *MailDB) LookupDomain(name string) (*Domain, error)
- func (mdb *MailDB) LookupTransport(name string) (*Transport, error)
- func (mdb *MailDB) LookupVMailbox(user string) (*VMailbox, error)
- func (mdb *MailDB) NewInput(name string, embeddedName string) (*Input, error)
- func (mdb *MailDB) Query(q string) ([]QueryRes, error)
- func (mdb *MailDB) RemoveAlias(alias string) error
- func (mdb *MailDB) RemoveRecipient(alias string, recipient string) error
- type QueryRes
- type Recipient
- type TableInfo
- type Transport
- func (tr *Transport) ClearNexthop() error
- func (tr *Transport) ClearTransport() error
- func (tr *Transport) Export() string
- func (tr *Transport) Name() string
- func (tr *Transport) Nexthop() string
- func (tr *Transport) SetNexthop(hop string) error
- func (tr *Transport) SetTransport(trans string) error
- func (tr *Transport) Transport() string
- type TransportParts
- type VMailbox
- func (m *VMailbox) ClearGid() error
- func (m *VMailbox) ClearHome() error
- func (m *VMailbox) ClearPassword() error
- func (m *VMailbox) ClearQuota() error
- func (m *VMailbox) ClearUid() error
- func (m *VMailbox) Disable() error
- func (m *VMailbox) Enable() error
- func (vm *VMailbox) Export() string
- func (vm *VMailbox) Gid() string
- func (vm *VMailbox) Home() string
- func (mb *VMailbox) IsEnabled() bool
- func (vm *VMailbox) Password() string
- func (vm *VMailbox) PwType() string
- func (vm *VMailbox) Quota() string
- func (m *VMailbox) ResetQuota() error
- func (m *VMailbox) SetGid(gid int64) error
- func (m *VMailbox) SetHome(home string) error
- func (m *VMailbox) SetPassword(ps string) error
- func (m *VMailbox) SetPwType(pwType string) error
- func (m *VMailbox) SetQuota(quota string) error
- func (m *VMailbox) SetUid(uid int64) error
- func (vm *VMailbox) String() string
- func (vm *VMailbox) Uid() string
- func (vm *VMailbox) User() string
Constants ¶
This section is empty.
Variables ¶
var ( ErrMdbTransaction = errors.New("Not in a transaction") ErrMdbAddressEmpty = errors.New("address is empty") ErrMdbTargetEmpty = errors.New("target is empty") ErrMdbAddrIllegalChars = errors.New("illegal chars in address") ErrMdbAddrNoAddr = errors.New("address extension without user part") ErrMdbNoLocalPipe = errors.New("no local pipe or redirect") ErrMdbNoQuotedSpace = errors.New("pipe with spaces requires quotes") ErrMdbBadInclude = errors.New("badly formed or empty include") ErrMdbArgStringEmpty = errors.New("Empty string not allowed here") ErrMdbTransNoColon = errors.New("No ':' separator") ErrMdbAddressNotFound = errors.New("address not found") ErrMdbDomainNotFound = errors.New("domain not found") ErrMdbDupAddress = errors.New("Address already exists") ErrMdbDupDomain = errors.New("Domain already exists") ErrMdbAddressBusy = errors.New("Address still in use") ErrMdbDomainBusy = errors.New("Domain still in use") ErrMdbTransNotFound = errors.New("Transport not found") ErrMdbDupTrans = errors.New("Transport already exists") ErrMdbTransBusy = errors.New("Transport still in use") ErrMdbAccessNotFound = errors.New("Access not found") ErrMdbAccessBadAction = errors.New("Access action cannot be empty") ErrMdbAccessBusy = errors.New("Access still in use") ErrMdbDupAccess = errors.New("Access already exists") ErrMdbNotAlias = errors.New("address is not an alias") ErrMdbNoAliases = errors.New("No Aliases") ErrMdbAddressTarget = errors.New("virtual alias must have an addressable target") ErrMdbNoRecipients = errors.New("No recipients supplied for alias") ErrMdbRecipientNotFound = errors.New("alias recipient not found") ErrMdbNoMailboxes = errors.New("No Mailboxes") ErrMdbMboxNoDomain = errors.New("Mailbox must have a domain") ErrMdbMboxNotMboxDomain = errors.New("Mailbox must be in a vmailbox domain") ErrMdbNotMbox = errors.New("address is not a mailbox") ErrMdbIsAlias = errors.New("New mailbox already an alias") ErrMdbIsMbox = errors.New("New alias already a mailbox") ErrMdbMboxBadPw = errors.New("Unrecognized password type") ErrMdbBadName = errors.New("Not a correct name") ErrMdbBadClass = errors.New("Unknown domain class") ErrMdbBadUid = errors.New("User ID must be unsigned decimal integer") ErrMdbBadGid = errors.New("Group ID must be unsigned decimal integer") ErrMdbBadUpdate = errors.New("Update did not happen") ErrMdbMboxIsRecip = errors.New("Mailbox is an alias recipient") )
Error return constants
var ( NullStr = sql.NullString{Valid: false} NullInt = sql.NullInt64{Valid: false} )
Useful constants
var DbContent embed.FS
Embedded files for database
Functions ¶
func IsErrConstraintForeignKey ¶
IsErrConstraintForeignKey attempting insert with either non-existent ref or delete with refs pointing to it.
Types ¶
type Address ¶
type Address struct {
// contains filtered or unexported fields
}
func (*Address) AttachAlias ¶
AttachAlias Attach an alias recipient to this address. If it was just a simple address before, it is now an alias with one or more recipients
type AddressParts ¶
type AddressParts struct {
// contains filtered or unexported fields
}
AddressParts
func DecodeRFC822 ¶
func DecodeRFC822(addr string) (*AddressParts, error)
DecodeRFC822 Decode an RFC822 address into its constituent parts Actually, we decode per RFC5322
func DecodeTarget ¶
func DecodeTarget(addr string) (*AddressParts, error)
DecodeTarget Decode an RFC822 address and the various options for extensions
func (*AddressParts) String ¶
func (ap *AddressParts) String() string
type Alias ¶
type Alias struct {
// contains filtered or unexported fields
}
Alias
type Class ¶
type Class int
Class domain classes are used for easy categorizing domains, some of which we actually own and others (like relay) are somewhere else.
type MailDB ¶
type MailDB struct {
// contains filtered or unexported fields
}
MailDB
func (*MailDB) Begin ¶
func (mdb *MailDB) Begin()
Begin If a begin() goes bad, we are in serious trouble. Just crash
func (*MailDB) Close ¶
func (mdb *MailDB) Close()
Close This must match a successful NewMailDB or it will panic best practice is to defer a call here in the same function that did the open
func (*MailDB) DefaultInt ¶
func (*MailDB) DefaultString ¶
DefaultString We panic() here because an error here means someone has changed/mis-matched to the schema and at that point the best thing to do is crash, not mess up the DB
func (*MailDB) DeleteAddress ¶
DeleteAddress does not need a transaction because the cleanup delete to an unreferenced domain is done by a trigger
func (*MailDB) DeleteTransport ¶
DeleteTransport
func (*MailDB) DeleteVMailbox ¶
DeleteVMailbox Potential cascaded delete of address is handled by triggers
func (*MailDB) End ¶
End This is deferred so pass a reference to the error var Commit on no errors, rollback otherwise
func (*MailDB) FindAccess ¶
FindAccess '*' find all access rules 'something*something' find matching names
func (*MailDB) FindAddress ¶
FindAddress
func (*MailDB) FindDomain ¶
FindDomain LookupDomain but with wildcards '*' - find all domains '*.somedomain' - find all subdomains of somedomain '*.*' - find all domains with subdomains
func (*MailDB) FindTransport ¶
FindTransport '*' find all transport rules 'something*something' find matching names
func (*MailDB) FindVMailbox ¶
FindVMailbox name@domain username for mailbox *@domain all users in this domain *@* all users in all domains * error. No local system users (for now) return a list of matched mailboxes
func (*MailDB) GetAddress ¶
GetAddress Lookup an address under an active transaction really a copy of LookupAddress with transaction queries...
func (*MailDB) GetOrInsAddress ¶
GetOrInsAddress get the address and if not found, insert it. Make this common pattern a function on its own. Transaction required
func (*MailDB) GetTransport ¶
GetTransport inside transactions
func (*MailDB) GetVMailbox ¶
GetVmailbox lookup a mailbox under a transaction
func (*MailDB) InsertAccess ¶
InsertAccess
func (*MailDB) InsertAddress ¶
InsertAddress Insert an address MUST be under a transaction
func (*MailDB) InsertDomain ¶
InsertDomain returns a *Domain. If error, rollback the transaction.
func (*MailDB) InsertTransport ¶
InsertTransport
func (*MailDB) InsertVMailbox ¶
InsertVMailbox must be under a transaction
func (*MailDB) LoadSchema ¶
LoadSchema if the schema name starts with "/" or ".", read from the filesystem otherwise read from the embedded files
func (*MailDB) LookupAccess ¶
LookupAccess outside transactions
func (*MailDB) LookupAddress ¶
LookupAddress Lookup an address without an active transaction
func (*MailDB) LookupAlias ¶
LookupAlias get either "local_user" or "mbox@domain" aliases name@domain returns that alias recipients for this address * returns all local (/etc/aliases) aliases *@domain returns all aliases in this domain name@* returns all aliases of this name, e.g. abuse@foo.com, abuse@example.org *@* returns all virtual aliases in the database
func (*MailDB) LookupDomain ¶
LookupDomain Does lookup outside a transaction
func (*MailDB) LookupTransport ¶
LookupTransport outside transactions
func (*MailDB) LookupVMailbox ¶
LookupVmailbox lookup a mailbox without transactions
func (*MailDB) RemoveAlias ¶
RemoveAlias and all its targets All we need to do here is delete the aliases that aliasAddr points to As the set of aliases disappear, their delete triggers clean up all the orphan targets (and the alias address itself) on the way out
type Recipient ¶
type Recipient struct {
// contains filtered or unexported fields
}
Recipient in alias list
type Transport ¶
type Transport struct {
// contains filtered or unexported fields
}
Transport DB table
type TransportParts ¶
type TransportParts struct {
// contains filtered or unexported fields
}