rtcfg

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: May 22, 2021 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BINRPC added in v1.1.0

type BINRPC struct {
	Port int
}

BINRPC configuration for CUxD support

type CCU

type CCU struct {
	Address    string
	Interfaces itf.Types
	InitID     string
}

CCU configuration

type Certificates added in v1.1.0

type Certificates struct {
	AutoGenerate   bool
	CACertFile     string
	CAKeyFile      string
	ServerCertFile string
	ServerKeyFile  string
}

Certificates configuration

type Config

type Config struct {
	CCU          CCU
	Host         Host
	Logging      Logging
	HTTP         HTTP
	MQTT         MQTT
	BINRPC       BINRPC
	Certificates Certificates
	Users        map[string]*User /* Identifier is key. */
}

Config is the entry object of the runtime config.

func (*Config) AddUser

func (c *Config) AddUser(u *User)

AddUser adds a user to the security config.

func (*Config) Authenticate

func (c *Config) Authenticate(endpoint Endpoint, identifier, password string) *User

Authenticate authenticates a user.

type Endpoint

type Endpoint int

Endpoint is a communication interface/protocol.

const (
	EndpointVEAP Endpoint = 1 << iota
	EndpointMQTT
)

Possible endpoints.

type HTTP

type HTTP struct {
	Port        int
	PortTLS     int
	CORSOrigins []string
	WebUIDir    string
}

HTTP configuration

type Host

type Host struct {
	Name    string
	Address string
}

Host configuration

type Logging

type Logging struct {
	Level    logging.LogLevel
	FilePath string
}

Logging configuration

type MQTT

type MQTT struct {
	Port          int
	PortTLS       int
	WebSocketPath string
}

MQTT configuration

type PermKind

type PermKind int

PermKind specifies the kind if a permission.

const (
	PermConfig PermKind = 1 << iota
	PermWritePV
	PermReadPV
)

Possible kinds of a permission.

type Permission

type Permission struct {
	Identifier  string
	Description string
	Endpoint    Endpoint
	Kind        PermKind

	// pattern syntax q.v. path.Match()
	PVFilter string
}

Permission represents a allowance to access something.

type Store

type Store struct {
	FileName string
	Config   Config
	// contains filtered or unexported fields
}

Store holds a runtime configuration.

func (*Store) Close

func (s *Store) Close()

Close discards a pending write operation.

func (*Store) Lock

func (s *Store) Lock()

Lock locks the store for writing (q.v. Locker interface).

func (*Store) RLock

func (s *Store) RLock()

RLock locks the store for reading.

func (*Store) RLocker

func (s *Store) RLocker() sync.Locker

RLocker returns a Locker interface for RLock and RUnlock.

func (*Store) RUnlock

func (s *Store) RUnlock()

RUnlock unlocks the store.

func (*Store) Read

func (s *Store) Read() error

Read loads the runtime config from file.

func (*Store) Unlock

func (s *Store) Unlock()

Unlock unlocks the store (q.v. Locker interface).

func (*Store) Update

func (s *Store) Update(fn func(*Config) error) error

Update executes a function which updates the runtime config. If fn returns no error, a delayed save to file is triggered.

func (*Store) View

func (s *Store) View(fn func(*Config) error) error

View executes a function which reads the runtime config.

func (*Store) Write

func (s *Store) Write() error

Write stores the runtime config immediately into file.

type User

type User struct {
	Identifier        string
	Active            bool
	Description       string
	Password          string                 // unencrypted password (only temporary)
	EncryptedPassword string                 // bcrypt hash
	Permissions       map[string]*Permission /* Identifier is key. */
}

User represents a user or a device.

func (*User) AddPermission

func (u *User) AddPermission(per *Permission)

AddPermission adds a permission to a user.

func (*User) Authorized

func (u *User) Authorized(endpoint Endpoint, kind PermKind, pvPath string) bool

Authorized checks whether an authorization exists. The request must contain only a single endpoint and kind. pvPath is not yet checked.

func (*User) SetPassword

func (u *User) SetPassword(password string) error

SetPassword generates a new hash for the password.

Jump to

Keyboard shortcuts

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