server

package
v3.6.5-1+incompatible Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2018 License: Apache-2.0 Imports: 32 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	FacilityMap = map[string]srslog.Priority{

		`LOG_KERN`:     srslog.LOG_KERN,
		`LOG_USER`:     srslog.LOG_USER,
		`LOG_MAIL`:     srslog.LOG_MAIL,
		`LOG_DAEMON`:   srslog.LOG_DAEMON,
		`LOG_AUTH`:     srslog.LOG_AUTH,
		`LOG_SYSLOG`:   srslog.LOG_SYSLOG,
		`LOG_LPR`:      srslog.LOG_LPR,
		`LOG_NEWS`:     srslog.LOG_NEWS,
		`LOG_UUCP`:     srslog.LOG_UUCP,
		`LOG_CRON`:     srslog.LOG_CRON,
		`LOG_AUTHPRIV`: srslog.LOG_AUTHPRIV,
		`LOG_FTP`:      srslog.LOG_FTP,

		`LOG_LOCAL0`: srslog.LOG_LOCAL0,
		`LOG_LOCAL1`: srslog.LOG_LOCAL1,
		`LOG_LOCAL2`: srslog.LOG_LOCAL2,
		`LOG_LOCAL3`: srslog.LOG_LOCAL3,
		`LOG_LOCAL4`: srslog.LOG_LOCAL4,
		`LOG_LOCAL5`: srslog.LOG_LOCAL5,
		`LOG_LOCAL6`: srslog.LOG_LOCAL6,
		`LOG_LOCAL7`: srslog.LOG_LOCAL7,
	}

	SeverityMap = map[string]srslog.Priority{

		`LOG_ALERT`:   srslog.LOG_ALERT,
		`LOG_CRIT`:    srslog.LOG_CRIT,
		`LOG_ERR`:     srslog.LOG_ERR,
		`LOG_WARNING`: srslog.LOG_WARNING,
		`LOG_NOTICE`:  srslog.LOG_NOTICE,
		`LOG_INFO`:    srslog.LOG_INFO,
		`LOG_DEBUG`:   srslog.LOG_DEBUG,
	}
)

Functions

func AuthTokenHandler

func AuthTokenHandler(next http.Handler, authSvc service.AuthSvc) http.Handler

AuthTokenHandler is middleWare that validates a client authentication token prior to allowing access to protected pages.

func MaxConnectionHandler

func MaxConnectionHandler(next http.Handler, maxConnections int) http.Handler

MaxConnectionHandler limits the number of concurrent connections using a counting semephore modeled with a buffered channel. At maxConnections active clients, new requests queue until a 'slot' becomes available. From https://pauladamsmith.com/blog/2016/04/max-clients-go-net-http.html.

func SigHandler

func SigHandler(conf *Config)

SignalHandler runs in an endless loop, blocking on the signal channel until a signal arrives, then handles the signal.

Types

type Config

type Config struct {
	Console        bool
	Refresh        bool
	RecoveryStack  bool
	MaxConnections int
	ServerTimeout  time.Duration
	ConfigFile     map[string]string

	AuthSvc    service.AuthSvc
	SerialSvc  service.SerialSvc
	LoggerSvc  service.LoggerSvc
	MetaUsbSvc service.MetaUsbSvc
	DataStore  store.DataStore

	AccessLog log.MLogger
	SystemLog log.MLogger
	ErrorLog  log.MLogger

	Syslog *Syslog
	Router *Router
	Server *Server

	Profiler *Profiler
}

Master configuration settings.

func NewConfig

func NewConfig(cf string, console, refresh bool) (*Config, error)

NewConfig creates a new master configuration object and reads its config from the provided JSON configuration file.

func (*Config) LoadMetaData

func (this *Config) LoadMetaData()

LoadMetaData loads the metadata tables in the datastore.

func (*Config) LogDataStoreInfo

func (this *Config) LogDataStoreInfo()

LogDataStoreInfo logs information about the datastore to the system log.

func (*Config) LogRouteInfo

func (this *Config) LogRouteInfo()

LogRouteInfo logs information about API endpoint routes.

func (*Config) LogServerInfo

func (this *Config) LogServerInfo()

LogServerInfo logs information about the server to the system log.

func (*Config) RefreshMetaData

func (this *Config) RefreshMetaData()

RefreshMetaData downloads a fresh copy of the device metadata.

type Profiler

type Profiler struct {
	Enabled bool
	Address string
}

Profiler contains configuration information for the profiler.

func (*Profiler) Serve

func (this *Profiler) Serve()

Serve starts the profiler.

type Router

type Router struct {
	*mux.Router
	AuthSvc service.AuthSvc
}

Router is a Gorilla Mux router with additional methods.

func NewRouter

func NewRouter(as service.AuthSvc) (*Router, error)

NewRouter creates and initializes a new Router instance.

func (*Router) AddRoutes

func (this *Router) AddRoutes(routes api.Routes) *Router

AddRoutes adds a collection of one or more routes to the Router.

type Server

type Server struct {
	*http.Server
}

server extends the http.Server object.

func NewServer

func NewServer(cf string, handler http.Handler) (*Server, error)

NewServer creates and initializes a new Server instance.

type Syslog

type Syslog struct {
	*srslog.Writer
	Enabled  bool
	Protocol string
	Port     string
	Host     string
	Tag      string
	Facility string
	Severity string
}

Syslog contains the Syslog configuration.

func NewSyslog

func NewSyslog(cf string) (*Syslog, error)

NewSyslog creates and initializes a new Syslog instance.

Jump to

Keyboard shortcuts

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