web

package
v0.0.0-...-65e9c33 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2018 License: MIT Imports: 29 Imported by: 0

Documentation

Overview

Package xsrftoken provides methods for generating and validating secure XSRF tokens.

The web package contains all the code to provide SMTPD's web GUI

Index

Constants

This section is empty.

Variables

View Source
var DataStore *data.DataStore
View Source
var Router *mux.Router
View Source
var TemplateFuncs = template.FuncMap{
	"htmlSafe":     htmlSafe,
	"friendlyTime": friendlyTime,
	"reverse":      reverse,
	"textToHtml":   textToHtml,
}
View Source
var Websocket *incus.Server

Functions

func FileSize

func FileSize(s int64) string

FileSize calculates the file size and generate user-friendly string.

func GreyMailFromAdd

func GreyMailFromAdd(w http.ResponseWriter, r *http.Request, ctx *Context) (err error)

func GreyMailToAdd

func GreyMailToAdd(w http.ResponseWriter, r *http.Request, ctx *Context) (err error)

func Home

func Home(w http.ResponseWriter, r *http.Request, ctx *Context) (err error)

func Initialize

func Initialize(cfg config.WebConfig, ds *data.DataStore)

Initialize sets up things for unit tests or the Start() method

func Login

func Login(w http.ResponseWriter, req *http.Request, ctx *Context) error

func LoginForm

func LoginForm(w http.ResponseWriter, req *http.Request, ctx *Context) (err error)

func Logout

func Logout(w http.ResponseWriter, req *http.Request, ctx *Context) error

func MailAttachment

func MailAttachment(w http.ResponseWriter, r *http.Request, ctx *Context) (err error)

func MailDelete

func MailDelete(w http.ResponseWriter, r *http.Request, ctx *Context) (err error)

func MailList

func MailList(w http.ResponseWriter, r *http.Request, ctx *Context) (err error)

func MailView

func MailView(w http.ResponseWriter, r *http.Request, ctx *Context) (err error)

func NginxHTTPAuth

func NginxHTTPAuth(w http.ResponseWriter, r *http.Request, ctx *Context) error

If running Nginx as a proxy, give Nginx the IP address and port for the SMTP server Primary use of Nginx is to terminate TLS so that Go doesn't need to deal with it. This could perform auth and load balancing too See http://wiki.nginx.org/MailCoreModule

func ParseTemplate

func ParseTemplate(name string, partial bool) (*template.Template, error)

ParseTemplate loads the requested template along with _base.html, caching the result (if configured to do so)

func Ping

func Ping(w http.ResponseWriter, r *http.Request, ctx *Context) error

func Register

func Register(w http.ResponseWriter, req *http.Request, ctx *Context) error

func RegisterForm

func RegisterForm(w http.ResponseWriter, req *http.Request, ctx *Context) (err error)

func RenderPartial

func RenderPartial(name string, w http.ResponseWriter, data interface{}) error

RenderPartial fetches the named template and renders it to the provided ResponseWriter.

func RenderTemplate

func RenderTemplate(name string, w http.ResponseWriter, data interface{}) error

RenderTemplate fetches the named template and renders it to the provided ResponseWriter.

func Start

func Start()

Start() the web server

func Status

func Status(w http.ResponseWriter, r *http.Request, ctx *Context) (err error)

func Stop

func Stop()

Types

type CSRF

type CSRF struct {
	// Key is a secret key for your application.
	Key string
	// ID is a unique identifier for the user.
	Id string
	// actionID is the action the user is taking (e.g. POSTing to a particular path)
	Action string
	// The duration that XSRF tokens are valid. 20 * time.Minute
	Timeout time.Duration
}

func NewCSRF

func NewCSRF(action string, id string, timeout time.Duration) *CSRF

func (*CSRF) Generate

func (c *CSRF) Generate() string

Generate returns a URL-safe secure XSRF token that expires in 24 hours.

func (*CSRF) Valid

func (c *CSRF) Valid(token string) bool

Valid returns true if token is a valid, unexpired token returned by Generate.

type Context

type Context struct {
	Vars      map[string]string
	Session   *sessions.Session
	DataStore *data.DataStore
	IsJson    bool
	User      *data.User
	ClientIp  string
	Ds        *data.MongoDB
}

func NewContext

func NewContext(req *http.Request) (*Context, error)

func (*Context) Close

func (c *Context) Close()

type Pagination

type Pagination struct {
	// contains filtered or unexported fields
}

func NewPagination

func NewPagination(total int, limit int, curpage int, url string) *Pagination

func (*Pagination) Html

func (p *Pagination) Html(style int) (output template.HTML)

func (*Pagination) Limit

func (p *Pagination) Limit() int

func (*Pagination) Offset

func (p *Pagination) Offset() int

func (*Pagination) Pages

func (p *Pagination) Pages() int

func (*Pagination) Paginate

func (p *Pagination) Paginate()

func (*Pagination) Total

func (p *Pagination) Total() int

Jump to

Keyboard shortcuts

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