config

package
v0.87.0 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2021 License: MIT Imports: 18 Imported by: 0

Documentation

Overview

Package config parses a config from a file. Note: this is meant for python parity only and may be deprecated at some point. Since we validate in our setters and not at runtime, we have to parse into an intermediary struct managed by goconf

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// AccountPersistDir defines the directory to store accounts in
	AccountPersistDir string
	// ListenConfig defines the config to have generated beacons
	ListenConfig ListenConfig
	// RPCConfig defines the configuration for the rpc server to listen on
	RPCConfig RPCConfig
	// RelayConfig defines the configuration for the relay server (see: https://git.io/JmrYJ )
	RelayConfig RelayConfig
	// LndConfig defines the configuration for hooking up with the lnd server
	LndConfig LndConfig
}

Config for terminus/relayd.

func NewConfig

func NewConfig() *Config

NewConfig creates a new config.

func ParseConfig

func ParseConfig(fileContents string) (config Config, err error)

ParseConfig parses a Config from the file contents returns an error if parsing fails. Validation can be done on the Config object.

func ParseConfigFromFile

func ParseConfigFromFile(filePath string) (conf Config, err error)

ParseConfigFromFile is a wrapper around ParseConfig that also reads from the file returns an error if parsing fails. Validation can be done on the Config object.

func (*Config) GetAccountPersistDir

func (c *Config) GetAccountPersistDir() string

GetAccountPersistDir gets the account persist dir.

func (*Config) GetAddress

func (c *Config) GetAddress() string

GetAddress fetches the address of the rpc server.

func (*Config) GetBindHost

func (c *Config) GetBindHost() string

GetBindHost gets the listening bind setting for allowing connections from other hosts.

func (*Config) GetBindPort

func (c *Config) GetBindPort() int

GetBindPort gets the port to listen for websocket connections.

func (*Config) GetCertChainFile

func (c *Config) GetCertChainFile() string

GetCertChainFile fetches the ssl certificate chain file.

func (*Config) GetCertFile

func (c *Config) GetCertFile() string

GetCertFile fetches the ssl certificate file.

func (*Config) GetExternalHost

func (c *Config) GetExternalHost() string

GetExternalHost gets other devices to connect via the beacon.

func (*Config) GetExternalPort

func (c *Config) GetExternalPort() int

GetExternalPort gets the externally binded port for other devices to connect via the beacon.

func (*Config) GetHostName

func (c *Config) GetHostName() string

GetHostName fetches the hostname.

func (*Config) GetKeyFile

func (c *Config) GetKeyFile() string

GetKeyFile gets the ssl certificate file.

func (*Config) GetRPCAddress added in v0.54.0

func (c *Config) GetRPCAddress() string

GetRPCAddress fetches the address (w/ connection schema) of the rpc server.

func (*Config) GetRPCHostname added in v0.54.0

func (c *Config) GetRPCHostname() string

GetRPCHostname fetches the hostname of the rpc server.

func (*Config) GetRelayURL added in v0.54.0

func (c *Config) GetRelayURL() string

GetRelayURL gets the relay url.

func (*Config) GetSelfSignedCert

func (c *Config) GetSelfSignedCert() bool

GetSelfSignedCert fetches the ssl certificate file.

func (*Config) GetUseTLS added in v0.54.0

func (c *Config) GetUseTLS() bool

GetUseTLS determines wether or not to use tls.

func (*Config) RPCServerTimeout added in v0.54.0

func (c *Config) RPCServerTimeout() time.Duration

RPCServerTimeout fetches the server timeout.

func (Config) Validate

func (c Config) Validate() error

Validate validates the configuration.

type ListenConfig

type ListenConfig struct {
	// BindHost defines listening bind setting. Defaults to 127.0.0.1 for localhost connections, 0.0.0.0
	// for allowing connections from other hosts
	BindHost string
	// BindPort defines the default port to listen for websocket connections port not specified.
	BindPort int
	// ExternalHost defines the host for other devices to connect via the beacon
	ExternalHost string
	// ExternalPort for other devices to connect via the beacon
	ExternalPort int
	// contains filtered or unexported fields
}

ListenConfig specifies the configuration for terminus to listen on.

func (ListenConfig) Validate

func (l ListenConfig) Validate() error

Validate the configuration.

type LndConfig added in v0.48.0

type LndConfig struct {
	// LndDir is the lnd settings directory
	LndDir string
	// MacaroonPath is the path to the macaroon to use for the lnd connection (requires invoice permissions)
	MacaroonPath string
	// TLSCertPath for LND, which is different from the websocket listening TLS
	TLSCertPath string
	// Network the lnd node is running on (e.g. mainnet, testnet, regtest)
	// TODO this can be handled with a getinfo command
	Network string
	// GrpcHost is the grpc host of the lnd node
	GrpcHost string
	// GrpcPort is the grpc port of the lnd node
	GrpcPort int
}

LndConfig defines the lnd config (if lnd is in use).

func (LndConfig) GRPCConnection added in v0.48.0

func (l LndConfig) GRPCConnection(ctx context.Context) (conn *grpc.ClientConn, err error)

GRPCConnection returns the grpc connection object.

func (LndConfig) GetMacaroon added in v0.48.0

func (l LndConfig) GetMacaroon() (mac *macaroon.Macaroon, err error)

GetMacaroon fetches the encoded macaroon object from LndConfig.

func (LndConfig) GetTLSCert added in v0.48.0

func (l LndConfig) GetTLSCert() (cert *tls.Config, err error)

GetTLSCert fetches the tls cert from an LndConfig.

func (LndConfig) HasLndConfig added in v0.53.0

func (l LndConfig) HasLndConfig() bool

HasLndConfig is whether or not the lnd config exists.

func (LndConfig) LndHost added in v0.48.0

func (l LndConfig) LndHost() string

LndHost gets the lnd hostname/port.

func (LndConfig) RPCClient added in v0.48.0

func (l LndConfig) RPCClient(ctx context.Context) (rpcClient lnrpc.LightningClient, err error)

RPCClient generates an lnd rpc client from an LndConfig.

func (LndConfig) Validate added in v0.48.0

func (l LndConfig) Validate() (err error)

Validate validates the LndConfig is valid.

type RPCConfig added in v0.54.0

type RPCConfig struct {
	// BindHost for client to connect
	BindHost string
	// BindPort for client to connect
	BindPort int
	// ExternalHost for a client to connect
	ExternalHost string
	// ExternalPort for client to connect
	ExternalPort int
}

RPCConfig defines the config for the rpc server.

func (RPCConfig) Validate added in v0.54.0

func (r RPCConfig) Validate() error

Validate validates the RPCConfig.

type RelayConfig added in v0.42.0

type RelayConfig struct {
	// BindHost defines listening bind setting. Defaults to 127.0.0.1 for localhost connections, 0.0.0.0
	// for allowing connections from other hosts
	BindHost string
	// BindPort defines the default port to listen for websocket connections port not specified.
	BindPort int
	// contains filtered or unexported fields
}

RelayConfig defines the configuration for the relay.

func (RelayConfig) Validate added in v0.42.0

func (r RelayConfig) Validate() error

Validate the configuration.

type Section

type Section struct {
	// contains filtered or unexported fields
}

Section defines a section of the config.

func NewSection

func NewSection(name string, cfg *goconfigparser.ConfigParser) Section

NewSection create a new section object that reads from a a section of the config.

func (Section) GetBool

func (s Section) GetBool(option string) bool

GetBool gets an bool from the config section handles python None types (returning false).

func (Section) GetInt

func (s Section) GetInt(option string) int

GetInt gets an int from the config section handles python None types.

func (Section) GetString

func (s Section) GetString(option string) string

GetString gets a string from the config section handles python None types.

Jump to

Keyboard shortcuts

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