config

package
v0.8.9 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2024 License: MIT Imports: 18 Imported by: 18

Documentation

Index

Constants

View Source
const (
	// DefaultConfig is the default file path for the uhppoted configuration file
	DefaultConfig = "/etc/uhppoted/uhppoted.conf"
)

Variables

View Source
var BROADCAST_ADDR = netip.AddrFrom4([4]byte{255, 255, 255, 255})
View Source
var INADDR_ANY = netip.AddrFrom4([4]byte{0, 0, 0, 0})

Functions

Types

type ACL added in v0.8.2

type ACL struct {
	Verify string `conf:"verify"`
}

type AWS

type AWS struct {
	Credentials string `conf:"credentials"`
	Profile     string `conf:"profile"`
	Region      string `conf:"region"`
}

func NewAWS

func NewAWS() *AWS

type Alerts

type Alerts struct {
	QOS      byte `conf:"qos"`
	Retained bool `conf:"retained"`
}

type Config

type Config struct {
	System      `conf:""`
	Devices     DeviceMap `conf:"/^UT0311-L0x\\.([0-9]+)\\.(.*)/"`
	REST        `conf:"rest"`
	MQTT        `conf:"mqtt"`
	AWS         `conf:"aws"`
	HTTPD       `conf:"httpd"`
	WildApricot `conf:"wild-apricot"`
	OpenAPI     `conf:"openapi"`
}

func NewConfig

func NewConfig() *Config

func (*Config) Load

func (c *Config) Load(path string) error

func (*Config) Read

func (c *Config) Read(r io.Reader) error

func (*Config) Validate

func (c *Config) Validate() error

func (*Config) Write

func (c *Config) Write(w io.Writer) error

type Connection

type Connection struct {
	Broker            string `conf:"broker"`
	ClientID          string `conf:"client.ID"`
	Username          string `conf:"username"`
	Password          string `conf:"password"`
	BrokerCertificate string `conf:"broker.certificate"`
	ClientCertificate string `conf:"client.certificate"`
	ClientKey         string `conf:"client.key"`
	Verify            string `conf:"verify"`
}

type Device

type Device struct {
	Name     string
	Address  types.ControllerAddr
	Doors    []string
	TimeZone string
	Protocol string
}

type DeviceMap

type DeviceMap map[uint32]*Device

func (DeviceMap) MarshalConf

func (f DeviceMap) MarshalConf(tag string) ([]byte, error)

func (DeviceMap) ToControllers added in v0.8.9

func (f DeviceMap) ToControllers() []uhppote.Device

* Returns a list of uhppote.Device sorted by controller ID (required for ACLs) *

func (*DeviceMap) UnmarshalConf

func (f *DeviceMap) UnmarshalConf(tag string, values map[string]string) (any, error)

type Disconnects added in v0.8.2

type Disconnects struct {
	Enabled  bool          `conf:"enabled"`
	Interval time.Duration `conf:"interval"`
	Max      uint32        `conf:"max"`
}

type HMAC

type HMAC struct {
	Required bool   `conf:"required"`
	Key      string `conf:"key"`
}

type HOTP

type HOTP struct {
	Range    uint64 `conf:"range"`
	Secrets  string `conf:"secrets"`
	Counters string `conf:"counters"`
}

type HTTPD

type HTTPD struct {
	HTML                     string `conf:"html"`
	HttpEnabled              bool   `conf:"http.enabled"`
	HttpPort                 uint16 `conf:"http.port"`
	HttpsEnabled             bool   `conf:"https.enabled"`
	HttpsPort                uint16 `conf:"https.port"`
	CACertificate            string `conf:"tls.ca"`
	TLSCertificate           string `conf:"tls.certificate"`
	TLSKey                   string `conf:"tls.key"`
	RequireClientCertificate bool   `conf:"tls.client.certificates.required"`
	Security                 struct {
		Auth          string `conf:"auth"`
		AuthDB        string `conf:"local.db"`
		CookieMaxAge  int    `conf:"cookie.max-age"`
		LoginExpiry   string `conf:"login.expiry"`
		SessionExpiry string `conf:"session.expiry"`
		AdminRole     string `conf:"admin.role"`
		NoSetup       bool   `conf:"no-setup"`
		OTP           struct {
			Issuer string `conf:"issuer"`
			Login  string `conf:"login"`
		} `conf:"otp"`
	} `conf:"security"`
	RequestTimeout time.Duration `conf:"request.timeout"`
	System         struct {
		Interfaces  string        `conf:"interfaces"`
		Controllers string        `conf:"controllers"`
		Doors       string        `conf:"doors"`
		Groups      string        `conf:"groups"`
		Cards       string        `conf:"cards"`
		Events      string        `conf:"events"`
		Logs        string        `conf:"logs"`
		Users       string        `conf:"users"`
		History     string        `conf:"history"`
		Refresh     time.Duration `conf:"refresh"`
		Windows     struct {
			Ok          time.Duration `conf:"ok"`
			Uncertain   time.Duration `conf:"uncertain"`
			Systime     time.Duration `conf:"systime"`
			CacheExpiry time.Duration `conf:"expires"`
		} `conf:"windows"`
	} `conf:"system"`
	DB struct {
		Rules struct {
			ACL         string `conf:"acl"`
			Interfaces  string `conf:"interfaces"`
			Controllers string `conf:"controllers"`
			Cards       string `conf:"cards"`
			Doors       string `conf:"doors"`
			Groups      string `conf:"groups"`
			Events      string `conf:"events"`
			Logs        string `conf:"logs"`
			Users       string `conf:"users"`
		} `conf:"rules"`
	} `conf:"db"`

	Audit struct {
		File string `conf:"file"`
	} `conf:"audit"`

	Retention time.Duration `conf:"retention"`
	Timezones string        `conf:"timezones"`

	PIN struct {
		Enabled bool `conf:"enabled"`
	} `conf:"PIN"`

	Cards struct {
		DefaultStartDate string `conf:"default-start-date"`
		DefaultEndDate   string `conf:"default-end-date"`
	} `conf:"cards"`
}

func NewHTTPD

func NewHTTPD() *HTTPD

type Lockfile added in v0.8.3

type Lockfile struct {
	File   string `conf:"file"`
	Remove bool   `conf:"remove"`
}

type MQTT

type MQTT struct {
	ServerID        string      `conf:"server.ID"`
	Connection      Connection  `conf:"connection"`
	Topics          Topics      `conf:"topic"`
	Locale          string      `conf:"translation.locale"`
	Protocol        string      `conf:"protocol.version"`
	Alerts          Alerts      `conf:"alerts"`
	EventsKeyID     string      `conf:"events.key"`
	SystemKeyID     string      `conf:"system.key"`
	EventIDs        string      `conf:"events.index.filepath"`
	Permissions     Permissions `conf:"permissions"`
	Cards           string      `conf:"cards"`
	HMAC            HMAC        `conf:"security.HMAC"`
	Authentication  string      `conf:"security.authentication"`
	HOTP            HOTP        `conf:"security.hotp"`
	RSA             RSA         `conf:"security.rsa"`
	Nonce           Nonce       `conf:"security.nonce"`
	SignOutgoing    bool        `conf:"security.outgoing.sign"`
	EncryptOutgoing bool        `conf:"security.outgoing.encrypt"`
	LockfileRemove  bool        `conf:"lockfile.remove"`
	Disconnects     Disconnects `conf:"disconnects"`
	ACL             ACL         `conf:"acl"`
}

func NewMQTT

func NewMQTT() *MQTT

type Nonce

type Nonce struct {
	Required bool   `conf:"required"`
	Server   string `conf:"server"`
	Clients  string `conf:"clients"`
}

type OpenAPI

type OpenAPI struct {
	Enabled   bool   `conf:"enabled"`
	Directory string `conf:"directory"`
}

func NewOpenAPI

func NewOpenAPI() *OpenAPI

type Permissions

type Permissions struct {
	Enabled bool   `conf:"enabled"`
	Users   string `conf:"users"`
	Groups  string `conf:"groups"`
}

type REST

type REST struct {
	HttpEnabled               bool   `conf:"http.enabled"`
	HttpPort                  uint16 `conf:"http.port"`
	HttpsEnabled              bool   `conf:"https.enabled"`
	HttpsPort                 uint16 `conf:"https.port"`
	TLSKeyFile                string `conf:"tls.key"`
	TLSCertificateFile        string `conf:"tls.certificate"`
	CACertificateFile         string `conf:"tls.ca"`
	RequireClientCertificates bool   `conf:"tls.client.certificates"`
	CORSEnabled               bool   `conf:"CORS.enabled"`
	AuthEnabled               bool   `conf:"auth.enabled"`
	Users                     string `conf:"auth.users"`
	Groups                    string `conf:"auth.groups"`
	HOTP                      HOTP   `conf:"auth.hotp"`
	Locale                    string `conf:"translation.locale"`
	Protocol                  string `conf:"protocol.version"`
}

func NewREST

func NewREST() *REST

type RSA

type RSA struct {
	KeyDir string `conf:"keys"`
}

type System

type System struct {
	BindAddress         *types.BindAddr      `conf:"bind.address"`
	BroadcastAddress    *types.BroadcastAddr `conf:"broadcast.address"`
	ListenAddress       *types.ListenAddr    `conf:"listen.address"`
	Timeout             time.Duration        `conf:"timeout"`
	HealthCheckInterval time.Duration        `conf:"monitoring.healthcheck.interval"`
	HealthCheckIdle     time.Duration        `conf:"monitoring.healthcheck.idle"`
	HealthCheckIgnore   time.Duration        `conf:"monitoring.healthcheck.ignore"`
	WatchdogInterval    time.Duration        `conf:"monitoring.watchdog.interval"`
	CardFormat          types.CardFormat     `conf:"card.format"`
}

type Topics

type Topics struct {
	Root       string `conf:"root"`
	Requests   string `conf:"requests"`
	Replies    string `conf:"replies"`
	EventsFeed string `conf:"events"`
	LiveEvents string `conf:"events.live"`
	System     string `conf:"system"`
}

func (*Topics) Resolve

func (t *Topics) Resolve(subtopic string) string

type WildApricot

type WildApricot struct {
	HTTP struct {
		ClientTimeout time.Duration `conf:"client-timeout"`
		Retries       int           `conf:"retries"`
		RetryDelay    time.Duration `conf:"retry-delay"`
	} `conf:"http"`

	Fields struct {
		CardNumber string `conf:"card-number"`
		PIN        string `conf:"PIN"`
	} `conf:"fields"`

	DisplayOrder struct {
		Groups string `conf:"groups"`
		Doors  string `conf:"doors"`
	} `conf:"display-order"`

	FacilityCode string `conf:"facility-code"`
}

func NewWildApricot

func NewWildApricot() *WildApricot

Jump to

Keyboard shortcuts

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