system

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: May 4, 2020 License: MIT Imports: 30 Imported by: 0

Documentation

Index

Constants

View Source
const MaxAttempts = 3

Variables

View Source
var ErrBadCredentials = errors.New("bad credentials")
View Source
var ErrExists = errors.New("record already exists")
View Source
var ErrNotFound = errors.New("not found")

Functions

func ReverseProxyHandler added in v0.0.4

func ReverseProxyHandler(config Config, path, dest string) (http.Handler, error)

Types

type Config

type Config struct {
	Meta           MetaConfig        `json:"Meta,omitempty"`
	Keys           KeyConfig         `json:"Keys,omitempty"`
	Sec            SecurityConfig    `json:"Security,omitempty"`
	ReverseProxy   map[string]string `json:"ReverseProxy"`
	ConfigFilePath string            `json:"-"` // unused in config.json, path to config for reload, empty if stdin
	DoMongo        bool              `json:"use-mongo"`
}

type Info

type Info struct {
	Contact string `json:"contact"`
}

type JSONError

type JSONError struct {
	Error string `json:"error"`
}

type KeyConfig

type KeyConfig struct {
	GoogleClientID    string `json:"GoogleClientID"`
	GoogleSecretKey   string `json:"GoogleSecretKey"`
	GithubClientID    string `json:"GithubClientID"`
	GithubSecretKey   string `json:"GithubSecretKey"`
	TwitterClientID   string `json:"TwitterClientID"`
	TwitterSecretKey  string `json:"TwitterSecretKey"`
	LinkedInClientID  string `json:"LinkedInClientID"`
	LinkedInSecretKey string `json:"LinkedInSecretKey"`
	PayPalClientID    string `json:"PayPalClientID"`
	PayPalSecretKey   string `json:"PayPalSecretKey"`
	SendgridUser      string `json:"SendgridUser"`
	SendgridPassword  string `json:"SendgridPassword"`
	MailgunUser       string `json:"MailgunUser"`
	MailgunPassword   string `json:"MailgunPassword"`
	TwilioSID         string `json:"TwilioSID"`
	TwilioAuthToken   string `json:"TwilioAuthToken"`
}

type LoginPacket

type LoginPacket struct {
	User string `json:"user"`
	Pass string `json:"pass"`
}

type MetaConfig

type MetaConfig struct {
	ListenAddr      string                 `json:"listen"`
	ListenAddrTLS   string                 `json:"listentls"`
	SiteName        string                 `json:"sitename"`
	SiteURL         string                 `json:"siteurl"`
	DevelopmentMode bool                   `json:"devmode"`
	CopyrightName   string                 `json:"copyright-name"`
	TemplateData    map[string]interface{} `json:"templatedata"`
}

type SecurityConfig

type SecurityConfig struct {
	HashKey     string `json:"hash-key"`
	BlockKey    string `json:"block-key"`
	CSRFKey     string `json:"csrf-key"`
	CookieName  string `json:"cookie-name"`
	Whitelist   string `json:"whitelist"`
	Blacklist   string `json:"blacklist"`
	ServePublic bool   `json:"servepublic"` // Serve All Unhandled URL in ./public
	BoltDB      string `json:"database"`
	OpenSignups bool   `json:"open-signups"`
}

type SignupPacket

type SignupPacket struct {
	User string `json:"user"`
	Pass string `json:"pass"`
}

type Stats

type Stats struct {
	Hits    uint64  `json:"hits"`
	Average float64 `json:"hits-per-second,omitempty"`

	Uptime float64 `json:"uptime,omitempty"`
	// contains filtered or unexported fields
}

type System

type System struct {
	Stats Stats
	Info  Info
	// contains filtered or unexported fields
}

func New

func New(config Config) (*System, error)

func (*System) ApiHandler

func (s *System) ApiHandler(w http.ResponseWriter, r *http.Request)

func (*System) ContactHandler

func (s *System) ContactHandler(w http.ResponseWriter, r *http.Request)

func (*System) DashboardHandler

func (s *System) DashboardHandler(w http.ResponseWriter, r *http.Request)

func (*System) ErrHandler

func (s *System) ErrHandler(w http.ResponseWriter, r *http.Request)

func (*System) HitCounter

func (s *System) HitCounter(h http.Handler) http.Handler

HitCounter http middleware that logs and counts

func (*System) HomeHandler

func (s *System) HomeHandler(w http.ResponseWriter, r *http.Request)

func (*System) InitDB

func (s *System) InitDB(doMongo bool) error

initialize database connections and create buckets

func (*System) LoginHandler

func (s *System) LoginHandler(w http.ResponseWriter, r *http.Request)

func (*System) LogoutHandler

func (s *System) LogoutHandler(w http.ResponseWriter, r *http.Request)

func (*System) ReloadConfig added in v0.0.3

func (s *System) ReloadConfig() error

func (*System) ReloadTemplates added in v0.0.3

func (s *System) ReloadTemplates() error

func (*System) SetCSPHeader

func (s *System) SetCSPHeader(w http.ResponseWriter)

func (*System) SetGreylist

func (s *System) SetGreylist(g *greylist.List)

func (*System) SignupHandler

func (s *System) SignupHandler(w http.ResponseWriter, r *http.Request)

func (*System) StaticHandler

func (s *System) StaticHandler(w http.ResponseWriter, r *http.Request)

func (*System) StatusHandler

func (s *System) StatusHandler(w http.ResponseWriter, r *http.Request)

type User

type User struct {
	Name string `json:"name"`
	ID   string `json:"id"`
	// contains filtered or unexported fields
}

func (User) String

func (u User) String() string

Jump to

Keyboard shortcuts

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