postfixadmin

package
v0.0.0-...-637ee02 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2015 License: GPL-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Administration of a postfixadmin database with ajax/rest

Index

Constants

This section is empty.

Variables

View Source
var Dbo gorm.DB

Functions

func AjaxAuth

func AjaxAuth(resp http.ResponseWriter, req *http.Request) bool

func AjaxHandlerAlias

func AjaxHandlerAlias(resp http.ResponseWriter, req *http.Request)

/ajax/alias/<email>

func AjaxHandlerAliases

func AjaxHandlerAliases(resp http.ResponseWriter, req *http.Request)

/ajax/domain/<domain>/aliases

func AjaxHandlerDomain

func AjaxHandlerDomain(resp http.ResponseWriter, req *http.Request)

= /ajax/domain/{domain}

func AjaxHandlerDomainAll

func AjaxHandlerDomainAll(resp http.ResponseWriter, req *http.Request)

/ajax/domain/{domain}/all

func AjaxHandlerDomainVirtual

func AjaxHandlerDomainVirtual(resp http.ResponseWriter, req *http.Request)

/ajax/domain/{domain}/virtual

func AjaxHandlerDomains

func AjaxHandlerDomains(resp http.ResponseWriter, req *http.Request)

Handles /ajax/domains

func AjaxHandlerMailbox

func AjaxHandlerMailbox(resp http.ResponseWriter, req *http.Request)

/ajax/domain/<example.com>/mailbox/<email>

func AjaxHandlerMailboxes

func AjaxHandlerMailboxes(resp http.ResponseWriter, req *http.Request)

/ajax/domain/<domain>/mailboxes

func AjaxHandlerVacation

func AjaxHandlerVacation(resp http.ResponseWriter, req *http.Request)

Handles /ajax/vacation/<email>

func AjaxHandlerVacations

func AjaxHandlerVacations(resp http.ResponseWriter, req *http.Request)

Handles /ajax/domain/<domain>/vacations

func CreatePermissionErrPayload

func CreatePermissionErrPayload() string

func DomainExists

func DomainExists(domain string) bool

func Initialize

func Initialize(conff *Config, db *sql.DB)

Initializes the postfix admin module..

func IsDomainValid

func IsDomainValid(domain_name string) error

func IsVacationAddress

func IsVacationAddress(address string) bool

func MailboxExists

func MailboxExists(address string) bool

func PassCrypt

func PassCrypt(raw_pass string, enc_pass string) (encrypted_pass string, err error)

Think idea is to pass in raw + salt and return enc, based on config..umm

func SetupRoutes

func SetupRoutes(router *mux.Router)

Add routes for postfixadmin module. Idea is that if your not admin or alike, then u get a 404 or 500

func SplitEmail

func SplitEmail(email_str string) []string

func UpdateVacationAlias

func UpdateVacationAlias(vac *Vacation)

Types

type Address

type Address struct {
	Address         string // foo@example.com
	User            string // foo
	Domain          string // example.com
	VacationAddress string // foo#example.com@autoreply.example.com
}

= Components of an email address

func ParseAddress

func ParseAddress(email_address string) (*Address, error)

Parses an email_address to Addr{} or error

type Alias

type Alias struct {
	Address  string `json:"address" gorm:"primary_key"`
	Goto     string `json:"goto"`
	Domain   string `json:"domain"`
	Created  string `json:"created"`
	Modified string `json:"modified"`
	Active   int    `json:"active"`
}

Represents the alias table

func GetAlias

func GetAlias(email string) (Alias, error)

func GetAliases

func GetAliases(domain string) ([]Alias, error)

func (*Alias) AddGoto

func (me *Alias) AddGoto(addr string)

Add address to forwarding

func (*Alias) RemoveGoto

func (me *Alias) RemoveGoto(addr string)

Remove address from forwarding

func (*Alias) Save

func (me *Alias) Save()

Save instance to Db

func (*Alias) TableName

func (me *Alias) TableName() string

type AliasPayload

type AliasPayload struct {
	Success bool   `json:"success"` // keep extjs happy
	Alias   Alias  `json:"alias"`
	Error   string `json:"error"`
}

func CreateAliasPayload

func CreateAliasPayload() AliasPayload

type AliasesPayload

type AliasesPayload struct {
	Success bool    `json:"success"` // keep extjs happy
	Aliases []Alias `json:"aliases"`
	Error   string  `json:"error"`
}

type Config

type Config struct {
	Debug bool `yaml:"debug" json:"debug" `

	AuthSecret string `yaml:"auth_secret" json:"auth_secret" `

	Db DbConf

	VacationDomain string `yaml:"vacation_domain" json:"vacation_domain" `

	HTTPListen  string `yaml:"http_listen" json:"http_listen"`
	IMAPAddress string `yaml:"imap_adddress" json:"imap_adddress"`
	SMTPLogin   string `yaml:"smtp_login" json:"smtp_login"`
}

type DbConf

type DbConf struct {
	Engine     string ` yaml:"engine" json:"engine" `
	Datasource string `yaml:"datasource" json:"connect"`
	Debug      bool   `yaml:"debug" json:"debug"`

	TableNames map[string]string `yaml:"table_names" json:"table_names"`
}

type Domain

type Domain struct {
	Domain      string ` json:"domain"`
	Description string ` json:"description"`
	Aliases     int    ` json:"aliases"`
	Mailboxes   int    ` json:"mailboxes"`
	MaxQuota    int    ` json:"maxquota"`
	Quota       int    ` json:"quota"`
	Transport   string ` json:"transport"`
	BackupMx    int    ` json:"backupmx"`
	Created     string ` json:"created"`
	Modified    string ` json:"modified"`
	Active      int    ` json:"active"`
}

= A domain is a database in postfix

func LoadDomain

func LoadDomain(domain_name string) (Domain, error)

= Loads a domain row from db

TODO check its in cache ?

func LoadDomains

func LoadDomains() ([]Domain, error)

Load domains from database

func (Domain) TableName

func (me Domain) TableName() string

type DomainAllPayload

type DomainAllPayload struct {
	Success   bool      `json:"success"` // keep extjs happy
	Domain    Domain    `json:"domain"`
	Mailboxes []Mailbox `json:"mailboxes"`
	Aliases   []Alias   `json:"aliases"`
	Error     string    `json:"error"`
}

Ajax struct for `domain` all

type DomainPayload

type DomainPayload struct {
	Success bool   `json:"success"` // keep extjs happy
	Domain  Domain `json:"domain"`
	Error   string `json:"error"`
}

= Ajax struct for `domain`

type DomainVirtualPayload

type DomainVirtualPayload struct {
	Success   bool              `json:"success"` // keep extjs happy
	Domain    Domain            `json:"domain"`
	Mailboxes []*MailboxVirtual `json:"mailboxes"`
	Aliases   []Alias           `json:"aliases"`
	Error     string            `json:"error"`
}

Ajax struct for `domain` all

type DomainsPayload

type DomainsPayload struct {
	Success bool     `json:"success"` // keep extjs happy
	Domains []Domain `json:"domains"`
	Error   string   `json:"error"`
}

type ErrPayload

type ErrPayload struct {
	Success bool   `json:"success"` // keep extjs happy
	Error   string `json:"error"`
}

= Ajax struct for `domain` all

type Mailbox

type Mailbox struct {
	Username  string `json:"username"`
	Password  string `json:"password"`
	Name      string `json:"name"`
	Maildir   string `json:"maildir"`
	Quota     int    `json:"quota"`
	LocalPart string `json:"local_part"`
	Domain    string `json:"domain"`
	Created   string `json:"created"`
	Modified  string `json:"modified"`
	Active    bool   `json:"active"`
}

func GetMailboxes

func GetMailboxes(domain string) ([]Mailbox, error)

func LoadMailbox

func LoadMailbox(username string) (Mailbox, error)

func (Mailbox) TableName

func (me Mailbox) TableName() string

type MailboxPayload

type MailboxPayload struct {
	Success bool    `json:"success"` // keep extjs happy
	Mailbox Mailbox `json:"mailbox"`
	Error   string  `json:"error"`
}

func CreateMailboxPayload

func CreateMailboxPayload() MailboxPayload

type MailboxVirtual

type MailboxVirtual struct {
	Mailbox
	Vacation    *Vacation `json:"vacation"`
	ForwardOnly bool      `json:"forward_only"`
	ForwardFrom []string  `json:"forward_from"`
	ForwardTo   []string  `json:"forward_to"`
}

func GetMailboxesVirtual

func GetMailboxesVirtual(domain string) ([]*MailboxVirtual, error)

type MailboxesPayload

type MailboxesPayload struct {
	Success   bool      `json:"success"` // keep extjs happy
	Mailboxes []Mailbox `json:"mailboxes"`
	Error     string    `json:"error"`
}

type Vacation

type Vacation struct {
	Email        string ` json:"email" gorm:"primary_key" `
	Subject      string ` json:"subject" `
	Body         string ` json:"body" `
	Activefrom   string ` json:"active_from" `
	Activeuntil  string ` json:"active_until" `
	Cache        string ` json:"cache" `
	Domain       string ` json:"domain" `
	IntervalTime int64  ` json:"interval_time" `
	Created      string ` json:"created" `
	Modified     string ` json:"modified" `
	Active       bool   ` json:"active" `
}

func GetVacation

func GetVacation(email string) (*Vacation, error)

func GetVacations

func GetVacations(domain string) ([]*Vacation, error)

type VacationNotification

type VacationNotification struct {
	OnVacation string ` json:"on_vacation" `
	Notified   string ` json:"notified" `
	NotifiedAt string ` json:"notified_at" `
}

type VacationPayload

type VacationPayload struct {
	Success  bool      `json:"success"` // keep extjs happy
	Vacation *Vacation `json:"vacation"`
	Error    string    `json:"error"`
}

type VacationsPayload

type VacationsPayload struct {
	Success   bool        `json:"success"` // keep extjs happy
	Vacations []*Vacation `json:"vacations"`
	Error     string      `json:"error"`
}

Jump to

Keyboard shortcuts

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