config

package
v1.8.0 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2023 License: BSD-3-Clause Imports: 13 Imported by: 1

Documentation

Overview

Package config handles reading and parsing the config.yaml file, which contains the configuration for the server.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ComputeRecommendedHandlingOrder

func ComputeRecommendedHandlingOrder(msg message.Message) string

ComputeRecommendedHandlingOrder computes the recommended handling order for a message. Only message types with computed (non-static) recommended handling orders are handled by this function.

func Read

func Read() (err error)

Read reads the system configuration from the config.yaml file. If an error occurs, the previous configuration is retained and the error is returned.

func SetConfig

func SetConfig(newconfig *Config)

SetConfig sets the configuration that will be returned by subsequent calls to Get. It should not be called by production code; it is intended for testing only.

Types

type BBSConfig

type BBSConfig struct {
	Transport string            `yaml:"transport"`
	AX25      string            `yaml:"ax25"`
	TCP       string            `yaml:"tcp"`
	Passwords map[string]string `yaml:"passwords"`
}

BBSConfig holds the configuration of a single BBS.

type Config

type Config struct {
	BBSes           map[string]*BBSConfig         `yaml:"bbses"`
	MinPIFOVersion  string                        `yaml:"minPIFOVersion"`
	MessageTypes    map[string]*MessageTypeConfig `yaml:"messageTypes"`
	ServerURL       string                        `yaml:"serverURL"`
	ListenAddr      string                        `yaml:"listenAddr"`
	SMTP            *SMTPConfig                   `yaml:"smtp"`
	CanViewEveryone []string                      `yaml:"canViewEveryone"`
	CanEditSessions []string                      `yaml:"canEditSessions"`
}

Config holds all of the configuration data.

func Get

func Get() *Config

Get returns the current configuration. Successive calls to Get may return different configurations if the config file has been changed in the interim.

func (*Config) Validate

func (c *Config) Validate() (valid bool)

Validate checks the configuration to make sure all fields have valid values. If there are any errors, they are logged, and the function returns false. If the configuration is valid, the function returns true.

type MessageTypeConfig

type MessageTypeConfig struct {
	MinimumVersion string   `yaml:"minimumVersion"`
	HandlingOrder  string   `yaml:"handlingOrder"`
	ToICSPosition  []string `yaml:"toICSPosition"`
	ToLocation     []string `yaml:"toLocation"`
}

A MessageTypeConfig structure specifies the configuration for a particular message type.

type SMTPConfig

type SMTPConfig struct {
	From     string `yaml:"from"`
	Server   string `yaml:"server"`
	Username string `yaml:"username"`
	Password string `yaml:"password"`
}

An SMTPConfig describes how to send email via SMTP.

Jump to

Keyboard shortcuts

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