config

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2021 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ClientConfigFile Filename of client configuration
	ClientConfigFile string = "bitmaelum-client-config.yml"
	// ServerConfigFile Filename of server configuration
	ServerConfigFile string = "bitmaelum-server-config.yml"
)
View Source
var (
	LoadedClientConfigPath string
	LoadedServerConfigPath string
)

Absolute paths of the loaded configurations

View Source
var Server = ServerConfig{}

Server keeps all server configuration settings

Functions

func GenerateClientConfig

func GenerateClientConfig(w io.Writer) error

GenerateClientConfig Generates a default client configuration

func GenerateServerConfig

func GenerateServerConfig(w io.Writer) error

GenerateServerConfig Generates a default server configuration

func LoadClientConfig

func LoadClientConfig(configPath string)

LoadClientConfig loads client configuration from given path or panic if cannot load

func LoadClientConfigOrPass

func LoadClientConfigOrPass(configPath string) error

LoadClientConfigOrPass loads client configuration, but return false if not able

func LoadServerConfig

func LoadServerConfig(configPath string)

LoadServerConfig loads server configuration from given path or panic if cannot load

func LoadServerConfigOrPass

func LoadServerConfigOrPass(configPath string) error

LoadServerConfigOrPass loads client configuration, but return false if not able

func ReadRouting

func ReadRouting(p string) error

ReadRouting will read the routing file and merge it into the server configuration

func SaveRouting

func SaveRouting(p string, routing *RoutingConfig) error

SaveRouting will save the routing into a file. It will overwrite if exists

Types

type ClientConfig

type ClientConfig struct {
	Vault struct {
		Path string `yaml:"path"`
	} `yaml:"vault"`

	Composer struct {
		Editor string `yaml:"editor"`
	} `yaml:"composer"`

	Server struct {
		AllowInsecure bool `yaml:"allow_insecure"`
		DebugHTTP     bool `yaml:"debug_http"`
	} `yaml:"server"`

	Resolver struct {
		Remote struct {
			Enabled       bool   `yaml:"enabled"`
			URL           string `yaml:"url"`
			AllowInsecure bool   `yaml:"allow_insecure"`
		} `yaml:"remote"`
	} `yaml:"resolver"`
}

ClientConfig is the representation of the client configuration

var Client ClientConfig = ClientConfig{}

Client keeps all client configuration settings

func (*ClientConfig) LoadConfig

func (c *ClientConfig) LoadConfig(r io.Reader) error

LoadConfig loads the client configuration from the given path

type RoutingConfig

type RoutingConfig struct {
	Version   int               `json:"version"`
	RoutingID string            `json:"routing_id"`
	KeyPair   *bmcrypto.KeyPair `json:"keypair,omitempty"`
}

RoutingConfig holds routing configuration for the mail server

var Routing RoutingConfig

Routing keeps the routing ID and keys

func GenerateRouting

func GenerateRouting() (*RoutingConfig, error)

GenerateRouting generates a new routing structure

func GenerateRoutingFromMnemonic

func GenerateRoutingFromMnemonic(mnemonic string) (*RoutingConfig, error)

GenerateRoutingFromMnemonic generates a new routing file from the given seed

type ServerConfig

type ServerConfig struct {
	Logging struct {
		Level   string `yaml:"log_level"`
		Format  string `yaml:"log_format" default:"text"`
		LogPath string `yaml:"log_path" default:"stdout"`

		ApacheLogging bool   `yaml:"apache_log" default:"false"`
		ApacheLogPath string `yaml:"apache_log_path"`
	} `yaml:"logging"`

	Work struct {
		Pow struct {
			Bits int `yaml:"bits"`
		} `yaml:"pow"`
	} `yaml:"work"`

	Paths struct {
		Processing string `yaml:"processing"`
		Retry      string `yaml:"retry"`
		Incoming   string `yaml:"incoming"`
		Accounts   string `yaml:"accounts"`
	} `yaml:"paths"`

	Server struct {
		Hostname      string `yaml:"hostname"`
		Host          string `yaml:"host"`
		Port          int    `yaml:"port"`
		CertFile      string `yaml:"certfile"`
		KeyFile       string `yaml:"keyfile"`
		VerboseInfo   bool   `yaml:"verbose_info"`
		AllowInsecure bool   `yaml:"allow_insecure"`
		RoutingFile   string `yaml:"routingfile"`
	} `yaml:"server"`

	Management struct {
		Enabled bool `yaml:"remote_enabled"`
	} `yaml:"management"`

	Organisations []string `yaml:"organisations"`

	Webhooks struct {
		Enabled bool   `yaml:"enabled"`
		System  string `yaml:"system"`
		Workers int    `yaml:"workers"`
	} `yaml:"webhooks"`

	Acme struct {
		Enabled         bool   `yaml:"enabled"`
		Domain          string `yaml:"domain"`
		Path            string `yaml:"path"`
		Email           string `yaml:"email"`
		RenewBeforeDays string `yaml:"renew_days"`
	} `yaml:"acme"`

	Redis struct {
		Host string `yaml:"host"`
		Db   int    `yaml:"port"`
	} `yaml:"redis"`

	Bolt struct {
		DatabasePath string `yaml:"database_path"`
	} `yaml:"bolt"`

	Resolver struct {
		Sqlite struct {
			Enabled bool   `yaml:"enabled"`
			Dsn     string `yaml:"dsn"`
		} `yaml:"sqlite"`

		Remote struct {
			Enabled       bool   `yaml:"enabled"`
			URL           string `yaml:"url"`
			AllowInsecure bool   `yaml:"allow_insecure"`
		} `yaml:"remote"`
	} `yaml:"resolver"`
}

ServerConfig is the representation of the server configuration

func (*ServerConfig) LoadConfig

func (c *ServerConfig) LoadConfig(r io.Reader) error

LoadConfig loads the server configuration from the given path

Jump to

Keyboard shortcuts

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