config

package
v0.0.0-...-314436a Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2023 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultP2PListenAddr       = "/ip4/0.0.0.0/udp/10042"
	DefaultP2PAnnounceInterval = time.Minute
)
View Source
const (
	// Default values for the Wireguard settings
	DefaultWgInterface           = "wesh0"
	DefaultWgNetworkRange        = "fd6d:142e:65e7:4cc1::/64"
	DefaultWgListenPort          = 10043
	DefaultWgPersistentKeepalive = time.Minute
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	P2P       P2P
	Wireguard Wireguard
	// contains filtered or unexported fields
}

TODO: validate config on load

func Load

func Load(filename string) (*Config, error)

func (*Config) Load

func (c *Config) Load() (bool, error)

func (*Config) Save

func (c *Config) Save() error

type P2P

type P2P struct {
	// Network PSK
	// If not present, will be generated.
	// TODO: find a nice way of configuring PSK?
	PSK string `validate:"base64"`
	// PrivateKey encoded in base64
	// If not present, will be generated.
	PrivateKey string `validate:"base64"`
	// List of Bootstrap nodes
	// Each node is a multiaddr, containing
	// * the last known peer addr
	// * the last known peer ID
	// Might be empty on start.
	// Will be periodically updated in runtime.
	Bootstrap []string
	// ListenAddr is a libp2p multiaddr
	ListenAddr       string
	AnnounceInterval time.Duration
}

func (*P2P) GeneratePrivateKey

func (p *P2P) GeneratePrivateKey() error

func (*P2P) GeneratePsk

func (p *P2P) GeneratePsk() error

func (*P2P) Load

func (p *P2P) Load() (bool, error)

func (*P2P) LoadBootstrapPeers

func (p *P2P) LoadBootstrapPeers() ([]peer.AddrInfo, error)

func (*P2P) LoadPrivateKey

func (p *P2P) LoadPrivateKey() (crypto.PrivKey, error)

func (*P2P) LoadPsk

func (p *P2P) LoadPsk() ([]byte, error)

type Wireguard

type Wireguard struct {
	// Wireguard interface name.
	Interface string
	// PrivateKey encoded in base64.
	// If not present, will be generated.
	PrivateKey string `validate:"base64"`
	// Wireguard listen port.
	ListenPort int
	// NetworkRange to use.
	NetworkRange string `validate:"cidr"`
	// NodeName is a network hostname will be used for generating the addr.
	// If not present, will be replaced with a hostname on the first time.
	NodeName string `validate:"hostname"`
	// Wireguard PersistentKeepalive setting.
	// Set to -1 to disable.
	PersistentKeepalive time.Duration
}

func (*Wireguard) GeneratePrivateKey

func (w *Wireguard) GeneratePrivateKey() error

func (*Wireguard) Load

func (w *Wireguard) Load() (bool, error)

Jump to

Keyboard shortcuts

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