config

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2024 License: GPL-3.0 Imports: 21 Imported by: 1

Documentation

Index

Constants

View Source
const (
	NAME       string = "go-ma-actor"
	VERSION    string = "v0.3.1"
	ENV_PREFIX string = "GO_MA_ACTOR"
)
View Source
const (
	ALLOW_ALL_PEERS bool = true // Allow all peers by default. This is the norm for now. Use connmgr threshold and protection instead.

)
View Source
const CSVMode = 0664

Variables

View Source
var (
	ActorFlags = *pflag.NewFlagSet("actor", pflag.ContinueOnError)

	ErrEmptyIdentity = fmt.Errorf("identity is empty")
	ErrEmptyNick     = fmt.Errorf("nick is empty")
	ErrFakeIdentity  = fmt.Errorf("your identity is fake. You need to define actorKeyset or generate a new one")
)
View Source
var (
	CommonFlags = pflag.NewFlagSet("common", pflag.ContinueOnError)
)

Functions

func APIAddr added in v0.4.0

func APIAddr() string

func ActorKeyset added in v0.2.2

func ActorKeyset() set.Keyset

func ActorLocation added in v0.2.4

func ActorLocation() string

func ActorNick added in v0.2.2

func ActorNick() string

Fetches the actor nick from the config or the command line NB! This is a little more complex than the other config functions, as it needs to fetch the nick from the command line if it's not in the config. Due to being a required parameter when generating a new keyset.

func DBEntities added in v0.4.0

func DBEntities() string

func DBHistory added in v0.4.0

func DBHistory() string

func DBPeers added in v0.4.0

func DBPeers() string

func Debug added in v0.4.0

func Debug() bool

func File added in v0.3.1

func File() string

Returns the configfile name to use. The preferred value is the explcitily requested config file on the command line. Else it uses the nick of the actor or the mode.

func ForceFlag added in v0.3.1

func ForceFlag() bool

func Generate added in v0.3.1

func Generate(c Config)

This is a function that'll handle generateing and possible printing of the config. You can called his after gerenating your config to properly handle generate and show-config flags.

func GenerateFlag added in v0.3.1

func GenerateFlag() bool

func GetEditor added in v0.2.0

func GetEditor() string

func HelpNeeded added in v0.4.0

func HelpNeeded() bool

func HttpDebugSocket added in v0.4.0

func HttpDebugSocket() string

func HttpRefresh added in v0.2.4

func HttpRefresh() int

func HttpSocket added in v0.2.4

func HttpSocket() string

func Init added in v0.0.2

func Init() error

This should be called after pflag.Parse() in main. If you want to use a specific config file, you need to call SetProfile() before Init().

func InitCommon added in v0.4.0

func InitCommon()

func InitDB added in v0.4.0

func InitDB()

func InitHTTP added in v0.3.1

func InitHTTP()

func InitLog added in v0.4.0

func InitLog()

func InitP2P added in v0.0.4

func InitP2P()

func LogFile added in v0.2.4

func LogFile() string

func LogLevel added in v0.2.4

func LogLevel() string

func NodeIdentity added in v0.2.4

func NodeIdentity() crypto.PrivKey

func P2PConnMgrGracePeriod added in v0.2.4

func P2PConnMgrGracePeriod() time.Duration

func P2PConnmgrHighWatermark added in v0.2.4

func P2PConnmgrHighWatermark() int

func P2PConnmgrLowWatermark added in v0.2.4

func P2PConnmgrLowWatermark() int

func P2PDiscoveryAdvertiseInterval added in v0.3.0

func P2PDiscoveryAdvertiseInterval() time.Duration

func P2PDiscoveryAdvertiseLimit added in v0.3.0

func P2PDiscoveryAdvertiseLimit() int

func P2PDiscoveryAdvertiseTTL added in v0.3.0

func P2PDiscoveryAdvertiseTTL() time.Duration

func P2PDiscoveryDHT added in v0.3.0

func P2PDiscoveryDHT() bool

func P2PDiscoveryMDNS added in v0.3.0

func P2PDiscoveryMDNS() bool

func P2PIdentity added in v0.2.4

func P2PIdentity() (string, error)

func P2PPort added in v0.2.4

func P2PPort() int

func P2PPortString added in v0.2.4

func P2PPortString() string

func ParseActorFlags added in v0.4.0

func ParseActorFlags(exitOnHelp bool)

Initialise command line flags for the actor package The actor is optional for some commands, but required for others. exitOnHelp means that this function is the last called when help is needed. and the program should exit.

func ParseCommonFlags added in v0.4.0

func ParseCommonFlags(exitOnHelp bool)

func Print added in v0.2.2

func Print(c Config)

func PrintAll added in v0.4.0

func PrintAll() (int, error)

func Profile added in v0.3.0

func Profile() string

Profile is the mode unless overridden by the profile flag.

func Save added in v0.2.2

func Save(c Config) error

Write the generated config to the correct file NB! This fails fatally in case of an error.

func SetDefaultProfileName added in v0.4.0

func SetDefaultProfileName(p string)

Call this for special cmds like "relay", "node", etc. Before initConfig() like calls.

func ShowConfigFlag added in v0.3.1

func ShowConfigFlag() bool

func UIPeerslistWidth added in v0.3.0

func UIPeerslistWidth() int

func VersionFlag added in v0.4.0

func VersionFlag() bool

func XDGConfigHome added in v0.4.0

func XDGConfigHome() string

func XDGDataHome added in v0.4.0

func XDGDataHome() string

Types

type APIConfig added in v0.4.0

type APIConfig struct {
	Maddr string `yaml:"maddr"`
}

func API added in v0.4.0

func API() APIConfig

type ActorConfig added in v0.4.0

type ActorConfig struct {
	Identity string `yaml:"identity"`
	Nick     string `yaml:"nick"`
	Location string `yaml:"location"`
}

func Actor added in v0.4.0

func Actor() ActorConfig

Config for actor. Remember to parse the flags first. Eg. ActorFlags()

type Config added in v0.4.0

type Config interface {
	MarshalToYAML() ([]byte, error)
	Print()
	Save() error
}

type ConnmgrStruct added in v0.4.0

type ConnmgrStruct struct {
	LowWatermark  int           `yaml:"low-watermark"`
	HighWatermark int           `yaml:"high-watermark"`
	GracePeriod   time.Duration `yaml:"grace-period"`
}

type DBConfig added in v0.4.0

type DBConfig struct {
	Peers    string `yaml:"peers"`
	Entities string `yaml:"entities"`
	History  string `yaml:"history"`
}

func DB added in v0.4.0

func DB() DBConfig

type DiscoveryStruct added in v0.4.0

type DiscoveryStruct struct {
	AdvertiseInterval time.Duration `yaml:"advertise-interval"`
	AdvertiseTTL      time.Duration `yaml:"advertise-ttl"`
	AdvertiseLimit    int           `yaml:"advertise-limit"`
	DHT               bool          `yaml:"dht"`
	MDNS              bool          `yaml:"mdns"`
}

type HTTPConfig added in v0.4.0

type HTTPConfig struct {
	Socket      string `yaml:"socket"`
	Refresh     int    `yaml:"refresh"`
	DebugSocket string `yaml:"debug_socket"`
}

func HTTP added in v0.4.0

func HTTP() HTTPConfig

type LogConfig added in v0.4.0

type LogConfig struct {
	Level string `yaml:"level"`
	File  string `yaml:"file"`
}

func Log added in v0.4.0

func Log() LogConfig

type P2PConfig added in v0.4.0

type P2PConfig struct {
	Identity  string          `yaml:"identity"`
	Port      int             `yaml:"port"`
	Connmgr   ConnmgrStruct   `yaml:"connmgr"`
	Discovery DiscoveryStruct `yaml:"discovery"`
}

func P2P added in v0.4.0

func P2P() P2PConfig

type UIConfig added in v0.4.0

type UIConfig struct {
	UI UIStruct `yaml:"ui"`
}

func InitUIConfig added in v0.4.0

func InitUIConfig() UIConfig

type UIStruct added in v0.4.0

type UIStruct struct {
	PeerslistWidth int `yaml:"peerslist-width"`
}

Jump to

Keyboard shortcuts

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