Documentation ¶
Overview ¶
Package options contains configuration parsing for the nodecmd.
Index ¶
- Variables
- func InterceptorLogger() logging.Logger
- type APIOptions
- type AuthOptions
- type BasicAuthOptions
- type BootstrapOptions
- type BootstrapTransportOptions
- type BridgeMeshDNSOptions
- type BridgeOptions
- type Config
- func (o *Config) BindFlags(prefix string, fs *pflag.FlagSet) *Config
- func (o *Config) IsRaftMember() bool
- func (c *Config) LoadFrom(fs *pflag.FlagSet, confFiles []string) error
- func (c Config) MarshalJSON() ([]byte, error)
- func (c Config) MarshalTOML() ([]byte, error)
- func (c Config) MarshalYAML() ([]byte, error)
- func (o *Config) NewBootstrapTransport(ctx context.Context, nodeID string, conn mesh.Mesh) (transport.BootstrapTransport, error)
- func (o *Config) NewConnectOptions(ctx context.Context, conn mesh.Mesh, raft raft.Raft) (opts mesh.ConnectOptions, err error)
- func (o *Config) NewDualStorage() (storage.DualStorage, error)
- func (o *Config) NewFeatureSet() []*v1.FeaturePort
- func (o *Config) NewJoinTransport(ctx context.Context, nodeID string, conn mesh.Mesh) (transport.JoinRoundTripper, error)
- func (o *Config) NewMeshConfig(ctx context.Context) (conf mesh.Config, err error)
- func (o *Config) NewPluginSet(ctx context.Context) (map[string]plugins.Plugin, error)
- func (o *Config) NewRaftNode(ctx context.Context, conn mesh.Mesh) (raft.Raft, error)
- func (o *Config) NewRaftStartOptions(conn mesh.Mesh) (opts raft.StartOptions, err error)
- func (o *Config) NewRaftTransport(conn mesh.Mesh) (transport.RaftTransport, error)
- func (o *Config) NewServerTLSOptions() (grpc.ServerOption, error)
- func (o *Config) NewServiceOptions(ctx context.Context, conn mesh.Mesh) (conf services.Options, err error)
- func (o *Config) NodeID() (string, error)
- func (o *Config) RaftListenPort() int
- func (o *Config) RegisterAPIs(ctx context.Context, conn mesh.Mesh, srv *services.Server) error
- func (c Config) ToMapStructure() map[string]interface{}
- func (c *Config) UnmarshalJSON(b []byte) error
- func (c *Config) UnmarshalTOML(b []byte) error
- func (c *Config) UnmarshalYAML(b []byte) error
- func (o *Config) Validate() error
- type DiscoveryOptions
- type ExecutablePluginConfig
- type GlobalOptions
- type LDAPAuthOptions
- type MTLSOptions
- type MeshDNSOptions
- type MeshOptions
- type MetricsOptions
- type PluginConfig
- type PluginMapConfig
- type PluginOptions
- type RaftOptions
- type RemotePluginConfig
- type ServiceOptions
- type TLSOptions
- type TURNOptions
- type WebRTCOptions
- type WireGuardOptions
Constants ¶
This section is empty.
Variables ¶
var DefaultNodeID = func() string { hostname, err := os.Hostname() if err != nil { return uuid.NewString() } return hostname }()
DefaultNodeID is the default node ID used if no other is configured
var ErrNoMesh = fmt.Errorf("no mesh configured")
ErrNoMesh is returned when no mesh is configured to be bootstrapped or joined.
Functions ¶
func InterceptorLogger ¶
InterceptorLogger returns a logging.Logger that logs to the given slog.Logger.
Types ¶
type APIOptions ¶
type APIOptions struct { // MeshEnabled is true if the mesh API should be registered. MeshEnabled bool `koanf:"mesh-enabled,omitempty"` // AdminEnabled is true if the admin API should be registered. AdminEnabled bool `koanf:"admin-enabled,omitempty"` }
APIOptions are the options for which APIs to register and expose.
type AuthOptions ¶
type AuthOptions struct { // MTLS are options for mutual TLS. This is the recommended // authentication method. MTLS MTLSOptions `koanf:"mtls,omitempty"` // Basic are options for basic authentication. Basic BasicAuthOptions `koanf:"basic,omitempty"` // LDAP are options for LDAP authentication. LDAP LDAPAuthOptions `koanf:"ldap,omitempty"` }
AuthOptions are options for authentication into the mesh.
func (*AuthOptions) BindFlags ¶
func (o *AuthOptions) BindFlags(prefix string, fl *pflag.FlagSet)
BindFlags binds the flags to the options.
func (*AuthOptions) Validate ¶
func (o *AuthOptions) Validate() error
type BasicAuthOptions ¶
type BasicAuthOptions struct { // Username is the username. Username string `koanf:"username,omitempty"` // Password is the password. Password string `koanf:"password,omitempty"` }
BasicAuthOptions are options for basic authentication.
type BootstrapOptions ¶
type BootstrapOptions struct { // Enabled is the flag to attempt bootstrapping. If true, the node will only bootstrap a new cluster // if no data is found. To force a bootstrap, set Force to true. Enabled bool `koanf:"enabled,omitempty"` // ElectionTimeout is the election timeout to use when bootstrapping a new cluster. ElectionTimeout time.Duration `koanf:"election-timeout,omitempty"` // Transport are the bootstrap transport options Transport BootstrapTransportOptions `koanf:"transport,omitempty"` // IPv4Network is the IPv4 network of the mesh to write to the database when bootstraping a new cluster. IPv4Network string `koanf:"ipv4-network,omitempty"` // MeshDomain is the domain of the mesh to write to the database when bootstraping a new cluster. MeshDomain string `koanf:"mesh-domain,omitempty"` // Admin is the user and/or node name to assign administrator privileges to when bootstraping a new cluster. Admin string `koanf:"admin,omitempty"` // Voters is a comma separated list of node IDs to assign voting privileges to when bootstraping a new cluster. // BootstrapServers are automatically added to this list. Voters []string `koanf:"voters,omitempty"` // DefaultNetworkPolicy is the default network policy to apply to the mesh when bootstraping a new cluster. DefaultNetworkPolicy string `koanf:"default-network-policy,omitempty"` // DisableRBAC is the flag to disable RBAC when bootstrapping a new cluster. DisableRBAC bool `koanf:"disable-rbac,omitempty"` // Force is the force new bootstrap flag. Force bool `koanf:"force,omitempty"` }
BootstrapOptions are options for bootstrapping a new mesh.
func NewBootstrapOptions ¶ added in v0.3.3
func NewBootstrapOptions() BootstrapOptions
NewBootstrapOptions returns a new BootstrapOptions with the default values.
func (*BootstrapOptions) BindFlags ¶
func (o *BootstrapOptions) BindFlags(prefix string, fs *pflag.FlagSet)
BindFlags binds the bootstrap options to a flag set.
func (*BootstrapOptions) Validate ¶
func (o *BootstrapOptions) Validate() error
Validate validates the bootstrap options.
type BootstrapTransportOptions ¶ added in v0.4.1
type BootstrapTransportOptions struct { // TCPAdvertiseAddress is the initial address to advertise for raft consensus. TCPAdvertiseAddress string `koanf:"tcp-advertise-address,omitempty"` // TCPListenAddress is the initial address to use when using TCP raft consensus to bootstrap. TCPListenAddress string `koanf:"tcp-listen-address,omitempty"` // TCPServers is a map of node IDs to addresses to bootstrap with. If empty, the node will use the advertise // address as the bootstrap server. If not empty, all nodes in the map should be started with the same // list configurations. If any are different then the first node to become leader will pick them. This // can cause bootstrap to fail when using ACLs. Servers should be in the form of <node-id>=<address>. TCPServers map[string]string `koanf:"tcp-servers,omitempty"` // TCPConnectionPool is the maximum number of TCP connections to maintain to other nodes. TCPConnectionPool int `koanf:"tcp-connection-pool,omitempty"` // TCPConnectTimeout is the maximum amount of time to wait for a TCP connection to be established. TCPConnectTimeout time.Duration `koanf:"tcp-connect-timeout,omitempty"` // ServerGRPCPorts is a map of node IDs to gRPC ports to bootstrap with. If empty, the node will use the // advertise address and locally configured gRPC port for every node in bootstrap-servers. Ports should // be in the form of <node-id>=<port>. ServerGRPCPorts map[string]int `koanf:"server-grpc-ports,omitempty"` // Rendezvous is the rendezvous string to use when using libp2p to bootstrap. Rendezvous string `koanf:"rendezvous,omitempty"` // RendezvousNodes is the list of node IDs to use when using libp2p to bootstrap. RendezvousNodes []string `koanf:"rendezvous-nodes,omitempty"` // RendezvousLinger is the amount of time to wait for other nodes to join when using libp2p to bootstrap. RendezvousLinger time.Duration `koanf:"rendezvous-linger,omitempty"` // PSK is the pre-shared key to use when using libp2p to bootstrap. PSK string `koanf:"psk,omitempty"` }
BootstrapTransportOptions are options for the bootstrap transport.
func NewBootstrapTransportOptions ¶ added in v0.4.1
func NewBootstrapTransportOptions() BootstrapTransportOptions
NewBootstrapTransportOptions returns a new BootstrapTransportOptions with the default values.
func (*BootstrapTransportOptions) BindFlags ¶ added in v0.4.1
func (o *BootstrapTransportOptions) BindFlags(prefix string, fs *pflag.FlagSet)
BindFlags binds the bootstrap transport options to a flag set.
func (*BootstrapTransportOptions) Validate ¶ added in v0.4.1
func (o *BootstrapTransportOptions) Validate() error
Validate validates the bootstrap transport options.
type BridgeMeshDNSOptions ¶
type BridgeMeshDNSOptions struct { // Enabled enables mesh DNS. Enabled bool `koanf:"enabled,omitempty"` // ListenUDP is the UDP address to listen on. ListenUDP string `koanf:"listen-udp,omitempty"` // ListenTCP is the address to listen on for TCP DNS requests. ListenTCP string `koanf:"listen-tcp,omitempty"` // ReusePort sets the number of listeners to start on each port. // This is only supported on Linux. ReusePort int `koanf:"reuse-port,omitempty"` // EnableCompression is true if DNS compression should be enabled. EnableCompression bool `koanf:"compression,omitempty"` // RequestTimeout is the timeout for DNS requests. RequestTimeout time.Duration `koanf:"request-timeout,omitempty"` // Forwarders are the DNS forwarders to use. If empty, the system DNS servers will be used. Forwarders []string `koanf:"forwarders,omitempty"` // SubscribeForwarders will subscribe to new nodes that are able to forward requests for other meshes. // These forwarders will be placed at the bottom of the forwarders list. SubscribeForwarders bool `koanf:"subscribe-forwarders,omitempty"` // DisableForwarding disables forwarding requests entirely. DisableForwarding bool `koanf:"disable-forwarding,omitempty"` // CacheSize is the size of the remote DNS cache. CacheSize int `koanf:"cache-size,omitempty"` }
func (*BridgeMeshDNSOptions) BindFlags ¶
func (m *BridgeMeshDNSOptions) BindFlags(fl *pflag.FlagSet)
BindFlags binds the flags.
func (*BridgeMeshDNSOptions) Validate ¶
func (m *BridgeMeshDNSOptions) Validate() error
Validate validates the bridge dns options.
type BridgeOptions ¶
type BridgeOptions struct { // Meshes are the meshes to bridge. Meshes map[string]*Config `koanf:"meshes,omitempty"` // MeshDNS are options for running a meshdns server bridging all meshes. MeshDNS BridgeMeshDNSOptions `koanf:"meshdns,omitempty"` // UseMeshDNS is true if the bridge should use the meshdns server for local name resolution. UseMeshDNS bool `koanf:"use-meshdns,omitempty"` }
BridgeOptions are options for the bridge.
func (*BridgeOptions) BindFlags ¶
func (b *BridgeOptions) BindFlags(fs *pflag.FlagSet)
BindFlags binds the flags.
func (*BridgeOptions) Validate ¶
func (b *BridgeOptions) Validate() error
Validate recursively validates the config.
type Config ¶
type Config struct { // Global are global options that are overlaid on all other options. Global GlobalOptions `koanf:"global,omitempty"` // Bootstrap are the bootstrap options. Bootstrap BootstrapOptions `koanf:"bootstrap,omitempty"` // Auth are the authentication options. Auth AuthOptions `koanf:"auth,omitempty"` // Mesh are the mesh options. Mesh MeshOptions `koanf:"mesh,omitempty"` // Raft are the raft options. Raft RaftOptions `koanf:"raft,omitempty"` // Services are the service options. Services ServiceOptions `koanf:"services,omitempty"` // TLS are the TLS options. TLS TLSOptions `koanf:"tls,omitempty"` // WireGuard are the WireGuard options. WireGuard WireGuardOptions `koanf:"wireguard,omitempty"` // Discovery are the discovery options. Discovery DiscoveryOptions `koanf:"discovery,omitempty"` // Plugins are the plugin options. Plugins PluginOptions `koanf:"plugins,omitempty"` // Bridge are the bridge options. Bridge BridgeOptions `koanf:"bridge,omitempty"` }
Config are the configuration options for running a webmesh node.
func NewDefaultConfig ¶ added in v0.3.3
NewDefaultConfig returns a new config with the default options. If nodeID is empty, the hostname or a randomly generated one will be used.
func (*Config) IsRaftMember ¶
IsRaftMember returns true if the node is a raft member.
func (*Config) LoadFrom ¶
LoadFrom attempts to load this configuration from the given flag set, configuration files, and environment variables. If fs is not nil, it is assumed the configuration has already been bound to the flag set and that the flagset has already been parsed. The order of precedence for parsing is: 1. Files 2. Environment variables 3. Flags
func (Config) MarshalJSON ¶
MarshalJSON implements json.Marshaler.
func (Config) MarshalTOML ¶
MarshalTOML implements toml.Marshaler.
func (Config) MarshalYAML ¶
MarshalYAML implements yaml.Marshaler.
func (*Config) NewBootstrapTransport ¶
func (o *Config) NewBootstrapTransport(ctx context.Context, nodeID string, conn mesh.Mesh) (transport.BootstrapTransport, error)
NewBootstrapTransport returns the bootstrap transport for the configuration.
func (*Config) NewConnectOptions ¶
func (o *Config) NewConnectOptions(ctx context.Context, conn mesh.Mesh, raft raft.Raft) (opts mesh.ConnectOptions, err error)
NewConnectOptions returns new connection options for the configuration. The given raft node must be started it can be used.
func (*Config) NewDualStorage ¶
func (o *Config) NewDualStorage() (storage.DualStorage, error)
NewDualStorage creates a new mesh and raft storage for the current configuration.
func (*Config) NewFeatureSet ¶
func (o *Config) NewFeatureSet() []*v1.FeaturePort
NewFeatureSet returns a new FeatureSet for the given node options.
func (*Config) NewJoinTransport ¶
func (*Config) NewMeshConfig ¶
NewMeshConfig return a new Mesh configuration based on the node configuration.
func (*Config) NewPluginSet ¶
NewPluginSet returns a new plugin set for the node configuration.
func (*Config) NewRaftNode ¶
NewRaftNode creates a new raft node for the given mesh instance.
func (*Config) NewRaftStartOptions ¶
NewRaftStartOptions creates a new start options for the current configuration.
func (*Config) NewRaftTransport ¶
NewRaftTransport creates a new raft transport for the current configuration.
func (*Config) NewServerTLSOptions ¶
func (o *Config) NewServerTLSOptions() (grpc.ServerOption, error)
NewServerTLSOptions returns new TLS options for the gRPC server.
func (*Config) NewServiceOptions ¶
func (o *Config) NewServiceOptions(ctx context.Context, conn mesh.Mesh) (conf services.Options, err error)
NewServiceOptions returns new options for the webmesh services.
func (*Config) NodeID ¶
NodeID returns the node ID for this configuration, or any error attempting to determine it.
func (*Config) RaftListenPort ¶
RaftListenPort returns the listen port for the raft transport.
func (*Config) RegisterAPIs ¶
RegisterAPIs registers the configured APIs to the given server.
func (Config) ToMapStructure ¶
ToMapStructure converts the configuration to a map[string]interface{} structure.
func (*Config) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler.
func (*Config) UnmarshalTOML ¶
UnmarshalTOML implements toml.Unmarshaler.
func (*Config) UnmarshalYAML ¶
UnmarshalYAML implements yaml.Unmarshaler.
type DiscoveryOptions ¶
type DiscoveryOptions struct { // Announce is a flag to announce this peer to the discovery service. // Otherwise this peer will only discover other peers. Announce bool `koanf:"announce,omitempty"` // Discover is a flag to use the libp2p kademlia DHT for discovery. Discover bool `koanf:"discover,omitempty"` // PSK is the pre-shared key to use as a rendezvous point for peer discovery. PSK string `koanf:"psk,omitempty"` // BootstrapServers is a list of bootstrap servers to use for the DHT. // If empty or nil, the default bootstrap servers will be used. BootstrapServers []string `koanf:"bootstrap-servers,omitempty"` // AnnounceTTL is the TTL for the announcement. AnnounceTTL time.Duration `koanf:"announce-ttl,omitempty"` // LocalAddrs is a list of local addresses to announce to the discovery service. // If empty, the default local addresses will be used. LocalAddrs []string `koanf:"local-addrs,omitempty"` // ConnectTimeout is the timeout for connecting to a peer. ConnectTimeout time.Duration `koanf:"connect-timeout,omitempty"` }
DiscoveryOptions are options for discovering peers.
func NewDiscoveryOptions ¶ added in v0.3.3
func NewDiscoveryOptions(psk string, announce bool) DiscoveryOptions
NewDiscoveryOptions returns a new DiscoveryOptions for the given PSK. Or one ready with sensible defaults if the PSK is empty.
func (*DiscoveryOptions) BindFlags ¶
func (o *DiscoveryOptions) BindFlags(prefix string, fs *pflag.FlagSet)
BindFlags binds the flags for the discovery options.
func (*DiscoveryOptions) HostOptions ¶ added in v0.4.1
func (o *DiscoveryOptions) HostOptions(ctx context.Context) libp2p.HostOptions
NewHostConfig returns a new HostOptions for the discovery config.
func (*DiscoveryOptions) Validate ¶
func (o *DiscoveryOptions) Validate() error
Validate validates the discovery options.
type ExecutablePluginConfig ¶
type ExecutablePluginConfig struct { // Path is the path to an executable for the plugin. Path string `kaonf:"path,omitempty"` }
ExecutablePluginConfig is the configuration for an executable plugin.
type GlobalOptions ¶
type GlobalOptions struct { // LogLevel is the log level. LogLevel string `koanf:"log-level,omitempty"` // TLSCertFile is the TLS certificate file. TLSCertFile string `koanf:"tls-cert-file,omitempty"` // TLSKeyFile is the TLS key file. TLSKeyFile string `koanf:"tls-key-file,omitempty"` // TLACAFile is the TLS CA file. TLSCAFile string `koanf:"tls-ca-file,omitempty"` // TLSClientCAFile is the path to the TLS client CA file. // If empty, either TLSCAFile or the system CA pool is used. TLSClientCAFile string `koanf:"tls-client-ca-file,omitempty"` // MTLS is true if mutual TLS is enabled. MTLS bool `koanf:"mtls,omitempty"` // VerifyChainOnly is true if only the chain should be verified. VerifyChainOnly bool `koanf:"verify-chain-only,omitempty"` // InsecureSkipVerify is true if the server TLS cert should not be verified. InsecureSkipVerify bool `koanf:"insecure-skip-verify,omitempty"` // Insecure is true if TLS should be disabled. Insecure bool `koanf:"insecure,omitempty"` // PrimaryEndpoint is the preferred publicly routable address of this node. // Setting this value will override the mesh advertise address with its // configured listen port. PrimaryEndpoint string `koanf:"primary-endpoint,omitempty"` // Endpoints are the additional publicly routable addresses of this node. // If PrimaryEndpoint is not set, it will be set to the first endpoint. // Setting this value will override the mesh advertise with its configured // listen port. Endpoints []string `koanf:"endpoints,omitempty"` // DetectEndpoints is true if the endpoints should be detected. DetectEndpoints bool `koanf:"detect-endpoints,omitempty"` // DetectPrivateEndpoints is true if private IP addresses should be included in detection. // This automatically enables DetectEndpoints. DetectPrivateEndpoints bool `koanf:"detect-private-endpoints,omitempty"` // AllowRemoteDetection is true if remote detection is allowed. AllowRemoteDetection bool `koanf:"allow-remote-detection,omitempty"` // DetectIPv6 is true if IPv6 addresses should be included in detection. DetectIPv6 bool `koanf:"detect-ipv6,omitempty"` // DisableIPv4 is true if IPv4 should be disabled. DisableIPv4 bool `koanf:"disable-ipv4,omitempty"` // DisableIPv6 is true if IPv6 should be disabled. DisableIPv6 bool `koanf:"disable-ipv6,omitempty"` }
GlobalOptions are options that will be re-applied to all relevant configurations after parsing.
func (*GlobalOptions) ApplyGlobals ¶
func (global *GlobalOptions) ApplyGlobals(o *Config) (*Config, error)
ApplyGlobals applies the global options to the given options. It returns the options for convenience.
func (*GlobalOptions) BindFlags ¶
func (o *GlobalOptions) BindFlags(fs *pflag.FlagSet)
func (*GlobalOptions) Validate ¶
func (o *GlobalOptions) Validate() error
Validate validates the global options.
type LDAPAuthOptions ¶
type LDAPAuthOptions struct { // Username is the username. Username string `koanf:"username,omitempty"` // Password is the password. Password string `koanf:"password,omitempty"` }
LDAPAuthOptions are options for LDAP authentication.
type MTLSOptions ¶
type MTLSOptions struct { // CertFile is the path to a TLS certificate file to present when joining. Either this // or CertData must be set. CertFile string `koanf:"cert-file,omitempty"` // CertData is the base64 encoded TLS certificate data to present when joining. Either this // or CertFile must be set. CertData string `koanf:"cert-data,omitempty"` // KeyFile is the path to a TLS key file for the certificate. Either this or KeyData must be set. KeyFile string `koanf:"key-file,omitempty"` // KeyData is the base64 encoded TLS key data for the certificate. Either this or KeyFile must be set. KeyData string `koanf:"key-data,omitempty"` }
MTLSOptions are options for mutual TLS.
type MeshDNSOptions ¶
type MeshDNSOptions struct { // Enabled enables mesh DNS. Enabled bool `koanf:"enabled,omitempty"` // ListenUDP is the UDP address to listen on. ListenUDP string `koanf:"listen-udp,omitempty"` // ListenTCP is the address to listen on for TCP DNS requests. ListenTCP string `koanf:"listen-tcp,omitempty"` // ReusePort sets the number of listeners to start on each port. // This is only supported on Linux. ReusePort int `koanf:"reuse-port,omitempty"` // EnableCompression is true if DNS compression should be enabled. EnableCompression bool `koanf:"compression,omitempty"` // RequestTimeout is the timeout for DNS requests. RequestTimeout time.Duration `koanf:"request-timeout,omitempty"` // Forwarders are the DNS forwarders to use. If empty, the system DNS servers will be used. Forwarders []string `koanf:"forwarders,omitempty"` // SubscribeForwarders will subscribe to new nodes that are able to forward requests for other meshes. // These forwarders will be placed at the bottom of the forwarders list. SubscribeForwarders bool `koanf:"subscribe-forwarders,omitempty"` // DisableForwarding disables forwarding requests entirely. DisableForwarding bool `koanf:"disable-forwarding,omitempty"` // CacheSize is the size of the remote DNS cache. CacheSize int `koanf:"cache-size,omitempty"` // IPv6Only will only respond to IPv6 requests. IPv6Only bool `koanf:"ipv6-only,omitempty"` }
BindFlags binds the flags.
func NewMeshDNSOptions ¶ added in v0.3.3
func NewMeshDNSOptions() MeshDNSOptions
NewMeshDNSOptions returns a new MeshDNSOptions with the default values.
func (*MeshDNSOptions) BindFlags ¶
func (m *MeshDNSOptions) BindFlags(prefix string, fl *pflag.FlagSet)
BindFlags binds the flags.
func (*MeshDNSOptions) ListenPort ¶ added in v0.4.0
func (m *MeshDNSOptions) ListenPort() uint16
ListenPort returns the listen port for the MeshDNS server is enabled.
type MeshOptions ¶
type MeshOptions struct { // NodeID is the node ID. NodeID string `koanf:"node-id,omitempty"` // PrimaryEndpoint is the primary endpoint to advertise when joining. // This can be empty to signal the node is not publicly reachable. PrimaryEndpoint string `koanf:"primary-endpoint,omitempty"` // ZoneAwarenessID is the zone awareness ID. ZoneAwarenessID string `koanf:"zone-awareness-id,omitempty"` // JoinAddress is the address of a node to join. JoinAddress string `koanf:"join-address,omitempty"` // MaxJoinRetries is the maximum number of join retries. MaxJoinRetries int `koanf:"max-join-retries,omitempty"` // Routes are additional routes to advertise to the mesh. These routes are advertised to all peers. // If the node is not allowed to put routes in the mesh, the node will be unable to join. Routes []string `koanf:"routes,omitempty"` // ICEPeers are peers to request direct edges to over ICE. If the node is not allowed to create edges // and data channels, the node will be unable to join. ICEPeers []string `koanf:"ice-peers,omitempty"` // LibP2PPeers is a map of peer IDs to libp2p rendezvous strings where peers are accepting edges // over libp2p. If a peer is present in this map, the node will attempt to connect to the peer over // libp2p. If the node is not allowed to create edges and data channels, the node will be unable to join. LibP2PPeers map[string]string `koanf:"libp2p-peers,omitempty"` // GRPCAdvertisePort is the port to advertise for gRPC. GRPCAdvertisePort int `koanf:"grpc-advertise-port,omitempty"` // MeshDNSAdvertisePort is the port to advertise for DNS. MeshDNSAdvertisePort int `koanf:"meshdns-advertise-port,omitempty"` // UseMeshDNS indicates whether to set mesh DNS servers to the system configuration. UseMeshDNS bool `koanf:"use-meshdns,omitempty"` // DisableIPv4 disables IPv4 usage. DisableIPv4 bool `koanf:"disable-ipv4,omitempty"` // DisableIPv6 disables IPv6 usage. DisableIPv6 bool `koanf:"disable-ipv6,omitempty"` // DisableFeatureAdvertisement is true if feature advertisement should be disabled. DisableFeatureAdvertisement bool `koanf:"disable-feature-advertisement,omitempty"` }
MeshOptions are the options for participating in a mesh.
func NewMeshOptions ¶ added in v0.3.3
func NewMeshOptions(nodeID string) MeshOptions
NewMeshOptions returns a new MeshOptions with the default values. If node id is empty it will be assumed from the system or generated.
func (*MeshOptions) BindFlags ¶
func (o *MeshOptions) BindFlags(prefix string, fs *pflag.FlagSet)
BindFlags binds the flags to the options.
func (*MeshOptions) Validate ¶
func (o *MeshOptions) Validate() error
Validate validates the options.
type MetricsOptions ¶
type MetricsOptions struct { // Enabled is true if metrics should be enabled. Enabled bool `koanf:"enabled,omitempty"` // MetricsListenAddress is the address to listen on for metrics. ListenAddress string `koanf:"listen-address,omitempty"` // MetricsPath is the path to serve metrics on. Path string `koanf:"path,omitempty"` }
Metrics are options for exposing metrics.
func NewMetricsOptions ¶ added in v0.3.3
func NewMetricsOptions() MetricsOptions
NewMetricsOptions returns a new MetricsOptions with the default values.
func (*MetricsOptions) BindFlags ¶
func (m *MetricsOptions) BindFlags(prefix string, fl *pflag.FlagSet)
BindFlags binds the flags.
func (*MetricsOptions) ListenPort ¶ added in v0.4.0
func (m *MetricsOptions) ListenPort() uint16
ListenPort returns the listen port for the Metrics server is enabled.
func (*MetricsOptions) Validate ¶
func (m *MetricsOptions) Validate() error
Validate validates the options.
type PluginConfig ¶
type PluginConfig struct { // Exec is the configuration for an executable plugin. Exec ExecutablePluginConfig `koanf:"exec,omitempty"` // Remote is the configuration for a plugin that connects to an external server. Remote RemotePluginConfig `koanf:"remote,omitempty"` // Config is the configuration that will be passed to the plugin's Configure method. Config PluginMapConfig `koanf:"config,omitempty"` }
PluginConfig is the configuration for a plugin.
type PluginMapConfig ¶
PluginMapConfig implements a pflag.Value and wraps a map[string]any.
func (PluginMapConfig) Set ¶
func (p PluginMapConfig) Set(s string) error
func (PluginMapConfig) String ¶
func (p PluginMapConfig) String() string
func (PluginMapConfig) Type ¶
func (p PluginMapConfig) Type() string
type PluginOptions ¶
type PluginOptions struct { // Configs is a map of plugin names to plugin configurations. Configs map[string]PluginConfig `koanf:"configs"` }
PluginOptions are options for configuring plugins
type RaftOptions ¶
type RaftOptions struct { // ListenAddress is the address to listen on. ListenAddress string `koanf:"listen-address,omitempty"` // DataDir is the directory to store data in. DataDir string `koanf:"data-dir,omitempty"` // InMemory is if the store should be in memory. This should only be used for testing and ephemeral nodes. InMemory bool `koanf:"in-memory,omitempty"` // ConnectionPoolCount is the number of connections to pool. If 0, no connection pooling is used. ConnectionPoolCount int `koanf:"connection-pool-count,omitempty"` // ConnectionTimeout is the timeout for connections. ConnectionTimeout time.Duration `koanf:"connection-timeout,omitempty"` // HeartbeatTimeout is the timeout for heartbeats. HeartbeatTimeout time.Duration `koanf:"heartbeat-timeout,omitempty"` // ElectionTimeout is the timeout for elections. ElectionTimeout time.Duration `koanf:"election-timeout,omitempty"` // ApplyTimeout is the timeout for applying. ApplyTimeout time.Duration `koanf:"apply-timeout,omitempty"` // CommitTimeout is the timeout for committing. CommitTimeout time.Duration `koanf:"commit-timeout,omitempty"` // MaxAppendEntries is the maximum number of append entries. MaxAppendEntries int `koanf:"max-append-entries,omitempty"` // LeaderLeaseTimeout is the timeout for leader leases. LeaderLeaseTimeout time.Duration `koanf:"leader-lease-timeout,omitempty"` // SnapshotInterval is the interval to take snapshots. SnapshotInterval time.Duration `koanf:"snapshot-interval,omitempty"` // SnapshotThreshold is the threshold to take snapshots. SnapshotThreshold uint64 `koanf:"snapshot-threshold,omitempty"` // SnapshotRetention is the number of snapshots to retain. SnapshotRetention uint64 `koanf:"snapshot-retention,omitempty"` // ObserverChanBuffer is the buffer size for the observer channel. ObserverChanBuffer int `koanf:"observer-chan-buffer,omitempty"` // RequestVote is true if the node should request a vote in raft elections. RequestVote bool `koanf:"request-vote,omitempty"` // RequestObserver is true if the node should be a raft observer. RequestObserver bool `koanf:"request-observer,omitempty"` // PreferIPv6 is the prefer IPv6 flag. PreferIPv6 bool `koanf:"prefer-ipv6,omitempty"` // HeartbeatPurgeThreshold is the threshold of failed heartbeats before purging a peer. HeartbeatPurgeThreshold int `koanf:"heartbeat-purge-threshold,omitempty"` // LogLevel is the log level for the raft backend. LogLevel string `koanf:"log-level,omitempty"` }
RaftOptions are options for the raft backend.
func NewRaftOptions ¶ added in v0.3.3
func NewRaftOptions() RaftOptions
NewRaftOptions returns a new RaftOptions with the default values.
func (*RaftOptions) BindFlags ¶
func (o *RaftOptions) BindFlags(prefix string, fs *pflag.FlagSet)
BindFlags binds the flags.
func (*RaftOptions) Validate ¶
func (o *RaftOptions) Validate() error
Validate validates the options.
type RemotePluginConfig ¶
type RemotePluginConfig struct { // Server is the address of a server for the plugin. Server string `koanf:"server,omitempty"` // Insecure is whether to use an insecure connection to the plugin server. Insecure bool `koanf:"insecure,omitempty"` // TLSCAFile is the path to a CA for verifying certificates. TLSCAFile string `koanf:"tls-ca-file,omitempty"` // TLSCertFile is the path to a certificate for authenticating to the plugin server. TLSCertFile string `koanf:"tls-cert-file,omitempty"` // TLSKeyFile is the path to a key for authenticating to the plugin server. TLSKeyFile string `koanf:"tls-key-file,omitempty"` // TLSSkipVerify is whether to skip verifying the plugin server's certificate. TLSSkipVerify bool `koanf:"tls-skip-verify,omitempty"` }
RemotePluginConfig is the configuration for a plugin that connects to an external server.
type ServiceOptions ¶
type ServiceOptions struct { // GRPCWebListenAddress is the gRPC address to listen on. GRPCListenAddress string `koanf:"grpc-listen-address,omitempty"` // GRPCWebEnabled enables serving gRPC over HTTP/1.1. GRPCWebEnabled bool `koanf:"grpc-web-enabled,omitempty"` // TLSCertFile is the path to the TLS certificate file. TLSCertFile string `koanf:"tls-cert-file,omitempty"` // TLSCertData is the TLS certificate data. TLSCertData string `koanf:"tls-cert-data,omitempty"` // TLSKeyFile is the path to the TLS key file. TLSKeyFile string `koanf:"tls-key-file,omitempty"` // TLSKeyData is the TLS key data. TLSKeyData string `koanf:"tls-key-data,omitempty"` // Insecure is true if the transport is insecure. Insecure bool `koanf:"insecure,omitempty"` // DisableLeaderProxy is true if the leader proxy should be disabled. DisableLeaderProxy bool `koanf:"disable-leader-proxy,omitempty"` // API options API APIOptions `koanf:"api,omitempty"` // WebRTC options WebRTC WebRTCOptions `koanf:"webrtc,omitempty"` // MeshDNS options MeshDNS MeshDNSOptions `koanf:"meshdns,omitempty"` // TURN options TURN TURNOptions `koanf:"turn,omitempty"` // Metrics options Metrics MetricsOptions `koanf:"metrics,omitempty"` }
ServiceOptions contains the configuration for the mesh services.
func NewServiceOptions ¶ added in v0.3.3
func NewServiceOptions() ServiceOptions
NewServiceOptions returns a new ServiceOptions with the default values.
func (*ServiceOptions) BindFlags ¶
func (s *ServiceOptions) BindFlags(prefix string, fl *pflag.FlagSet)
BindFlags binds the flags.
func (*ServiceOptions) Validate ¶
func (s *ServiceOptions) Validate() error
Validate validates the options.
type TLSOptions ¶
type TLSOptions struct { // CAFile is the path to a TLS CA file for verification. If this and CAData are empty, the system CA pool is used. CAFile string `koanf:"tls-ca-file,omitempty"` // CAData is the base64 encoded TLS CA data for verification. If this and CAFile are empty, the system CA pool is used. CAData string `koanf:"tls-ca-data,omitempty"` // VerifyChainOnly is true if only the certificate chain should be verified. VerifyChainOnly bool `koanf:"verify-chain-only,omitempty"` // InsecureSkipVerify is true if the server TLS cert should not be verified. InsecureSkipVerify bool `koanf:"insecure-skip-verify,omitempty"` // Insecure is true if the gRPC connection should be insecure. Insecure bool `koanf:"insecure,omitempty"` }
TLSOptions are options for TLS communication when joining a mesh.
type TURNOptions ¶
type TURNOptions struct { // Enabled enables the TURN server. Enabled bool `koanf:"enabled,omitempty"` // Endpoint is the endpoint to advertise for the TURN server. If empty, the public IP and listen port is used. Endpoint string `koanf:"endpoint,omitempty"` // PublicIP is the address advertised for STUN/TURN requests. PublicIP string `koanf:"public-ip,omitempty"` // ListenAddress is the address to listen on for STUN/TURN connections. ListenAddress string `koanf:"listen-address,omitempty"` // Realm is the realm used for TURN server authentication. Realm string `koanf:"realm,omitempty"` // TURNPortRange is the port range to use for allocating TURN relays. TURNPortRange string `koanf:"port-range,omitempty"` }
TURNOptions are the options for the TURN server.
func NewTURNOptions ¶ added in v0.3.3
func NewTURNOptions() TURNOptions
NewTURNOptions returns a new TURNOptions with the default values.
func (*TURNOptions) BindFlags ¶
func (t *TURNOptions) BindFlags(prefix string, fl *pflag.FlagSet)
BindFlags binds the flags.
func (*TURNOptions) ListenPort ¶ added in v0.4.0
func (t *TURNOptions) ListenPort() uint16
ListenPort returns the listen port for this TURN configuration. or 0 if not enabled or invalid.
func (*TURNOptions) Validate ¶
func (t *TURNOptions) Validate() error
Validate values the TURN options.
type WebRTCOptions ¶ added in v0.4.0
type WebRTCOptions struct { // Enabled enables the WebRTC API. Enabled bool `koanf:"enabled,omitempty"` // STUNServers is a list of STUN servers to use for the WebRTC API. STUNServers []string `koanf:"stun-servers,omitempty"` }
WebRTCOptions are the options for the WebRTC API.
func NewWebRTCOptions ¶ added in v0.4.0
func NewWebRTCOptions() WebRTCOptions
NewWebRTCOptions returns a new WebRTCOptions with the default values.
func (*WebRTCOptions) BindFlags ¶ added in v0.4.0
func (w *WebRTCOptions) BindFlags(prefix string, fl *pflag.FlagSet)
BindFlags binds the flags.
func (*WebRTCOptions) Validate ¶ added in v0.4.0
func (w *WebRTCOptions) Validate() error
Validate validates the options.
type WireGuardOptions ¶
type WireGuardOptions struct { // ListenPort is the port to listen on. ListenPort int `koanf:"listen-port,omitempty"` // InterfaceName is the name of the interface. InterfaceName string `koanf:"interface-name,omitempty"` // ForceInterfaceName forces the use of the given name by deleting // any pre-existing interface with the same name. ForceInterfaceName bool `koanf:"force-interface-name,omitempty"` // ForceTUN forces the use of a TUN interface. ForceTUN bool `koanf:"force-tun,omitempty"` // Masquerade enables masquerading of traffic from the wireguard interface. Masquerade bool `koanf:"masquerade,omitempty"` // PersistentKeepAlive is the interval at which to send keepalive packets // to peers. If unset, keepalive packets will automatically be sent to publicly // accessible peers when this instance is behind a NAT. Otherwise, no keep-alive // packets are sent. PersistentKeepAlive time.Duration `koanf:"persistent-keepalive,omitempty"` // MTU is the MTU to use for the interface. MTU int `koanf:"mtu,omitempty"` // Endpoints are additional WireGuard endpoints to broadcast when joining. Endpoints []string `koanf:"endpoints,omitempty"` // KeyFile is the path to the WireGuard private key. If it does not exist it will be created. KeyFile string `koanf:"key-file,omitempty"` // KeyRotationInterval is the interval to rotate wireguard keys. // Set this to 0 to disable key rotation. KeyRotationInterval time.Duration `koanf:"key-rotation-interval,omitempty"` // RecordMetrics enables recording of WireGuard metrics. These are only exposed if the // metrics server is enabled. RecordMetrics bool `koanf:"record-metrics,omitempty"` // RecordMetricsInterval is the interval at which to update WireGuard metrics. RecordMetricsInterval time.Duration `koanf:"record-metrics-interval,omitempty"` }
WireGuardOptions are options for configuring the WireGuard interface.
func NewWireGuardOptions ¶ added in v0.3.3
func NewWireGuardOptions() WireGuardOptions
NewWireGuardOptions returns a new WireGuardOptions with sensible defaults.
func (*WireGuardOptions) BindFlags ¶
func (o *WireGuardOptions) BindFlags(prefix string, fs *pflag.FlagSet)
BindFlags binds the flags.
func (*WireGuardOptions) Validate ¶
func (o *WireGuardOptions) Validate() error
Validate validates the options.