services

package
v0.2.7 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2023 License: Apache-2.0 Imports: 35 Imported by: 0

Documentation

Overview

Package services contains the gRPC server for inter-node communication.

Index

Constants

View Source
const (
	ListenAddressEnvVar = "SERVICES_LISTEN_ADDRESS"
	CertFileEnvVar      = "SERVICES_TLS_CERT_FILE"
	KeyFileEnvVar       = "SERVICES_TLS_KEY_FILE"
	InsecureEnvVar      = "SERVICES_INSECURE"

	DefaultGRPCPort = 8443
)
View Source
const (
	LeaderProxyDisabledEnvVar = "SERVICES_API_DISABLE_LEADER_PROXY"
	MeshEnabledEnvVar         = "SERVICES_API_MESH"
	AdminEnabledEnvVar        = "SERVICES_API_ADMIN"
	WebRTCEnabledEnvVar       = "SERVICES_API_WEBRTC"
	WebRTCSTUNServersEnvVar   = "SERVICES_API_STUN_SERVERS"
)
View Source
const (
	MeshDNSEnabledEnvVar             = "SERVICES_MESHDNS_ENABLED"
	MeshDNSListenUDPEnvVar           = "SERVICES_MESHDNS_LISTEN_UDP"
	MeshDNSListenTCPEnvVar           = "SERVICES_MESHDNS_LISTEN_TCP"
	MeshDNSTSIGKeyEnvVar             = "SERVICES_MESHDNS_TSIG_KEY"
	MeshDNSReusePortEnvVar           = "SERVICES_MESHDNS_REUSE_PORT"
	MeshDNSCompressionEnvVar         = "SERVICES_MESHDNS_COMPRESSION"
	MeshDNSRequestTimeoutEnvVar      = "SERVICES_MESHDNS_REQUEST_TIMEOUT"
	MeshDNSForwardersEnvVar          = "SERVICES_MESHDNS_FORWARDERS"
	MeshDNSSubscribeForwardersEnvVar = "SERVICES_MESHDNS_SUBSCRIBE_FORWARDERS"
	MeshDNSDisableForwardingEnvVar   = "SERVICES_MESHDNS_DISABLE_FORWARDING"
	MeshDNSCacheSizeEnvVar           = "SERVICES_MESHDNS_CACHE_SIZE"
)
View Source
const (
	MetricsEnabledEnvVar       = "SERVICES_METRICS_ENABLED"
	MetricsListenAddressEnvVar = "SERVICES_METRICS_LISTEN_ADDRESS"
	MetricsPathEnvVar          = "SERVICES_METRICS_PATH"
)
View Source
const (
	TURNEnabledEnvVar             = "SERVICES_TURN_ENABLED"
	TURNServerEndpointEnvVar      = "SERVICES_TURN_ENDPOINT"
	TURNServerPublicIPEnvVar      = "SERVICES_TURN_PUBLIC_IP"
	TURNServerListenAddressEnvVar = "SERVICES_TURN_LISTEN_ADDRESS"
	TURNServerPortEnvVar          = "SERVICES_TURN_SERVER_PORT"
	TURNServerRealmEnvVar         = "SERVICES_TURN_SERVER_REALM"
	TURNSTUNPortRangeEnvVar       = "SERVICES_TURN_STUN_PORT_RANGE"
)

Variables

This section is empty.

Functions

func InterceptorLogger

func InterceptorLogger() logging.Logger

InterceptorLogger returns a logging.Logger that logs to the given slog.Logger.

Types

type APIOptions

type APIOptions struct {
	// DisableLeaderProxy is true if the leader proxy should be disabled.
	DisableLeaderProxy bool `` /* 159-byte string literal not displayed */
	// Mesh is true if the mesh API should be registered.
	Mesh bool `json:"mesh,omitempty" yaml:"mesh,omitempty" toml:"mesh,omitempty" mapstructure:"mesh,omitempty"`
	// Admin is true if the admin API should be registered.
	Admin bool `json:"admin,omitempty" yaml:"admin,omitempty" toml:"admin,omitempty" mapstructure:"admin,omitempty"`
	// WebRTC is true if the WebRTC API should be registered.
	WebRTC bool `json:"webrtc,omitempty" yaml:"webrtc,omitempty" toml:"webrtc,omitempty" mapstructure:"webrtc,omitempty"`
	// STUNServers is a comma separated list of STUN servers to use if the WebRTC API is enabled.
	STUNServers string `` /* 127-byte string literal not displayed */
}

APIOptions are the options for which APIs to register and expose.

func NewAPIOptions

func NewAPIOptions() *APIOptions

NewAPIOptions creates a new APIOptions with default values.

func (*APIOptions) BindFlags

func (o *APIOptions) BindFlags(fs *flag.FlagSet, prefix ...string)

BindFlags binds the flags. The options are returned

func (*APIOptions) DeepCopy added in v0.1.13

func (o *APIOptions) DeepCopy() *APIOptions

DeepCopy returns a deep copy of the options.

func (*APIOptions) Validate

func (o *APIOptions) Validate() error

Validate validates the options.

type MeshDNSOptions

type MeshDNSOptions struct {
	// Enabled enables mesh DNS.
	Enabled bool `yaml:"enabled,omitempty" json:"enabled,omitempty" toml:"enabled,omitempty" mapstructure:"enabled,omitempty"`
	// ListenUDP is the UDP address to listen on.
	ListenUDP string `yaml:"listen-udp,omitempty" json:"listen-udp,omitempty" toml:"listen-udp,omitempty" mapstructure:"listen-udp,omitempty"`
	// ListenTCP is the address to listen on for TCP DNS requests.
	ListenTCP string `json:"listen-tcp,omitempty" yaml:"listen-tcp,omitempty" toml:"listen-tcp,omitempty" mapstructure:"listen-tcp,omitempty"`
	// ReusePort sets the number of listeners to start on each port.
	// This is only supported on Linux.
	ReusePort int `json:"reuse-port,omitempty" yaml:"reuse-port,omitempty" toml:"reuse-port,omitempty" mapstructure:"reuse-port,omitempty"`
	// EnableCompression is true if DNS compression should be enabled.
	EnableCompression bool `json:"compression,omitempty" yaml:"compression,omitempty" toml:"compression,omitempty" mapstructure:"compression,omitempty"`
	// RequestTimeout is the timeout for DNS requests.
	RequestTimeout time.Duration `` /* 139-byte string literal not displayed */
	// Forwarders are the DNS forwarders to use. If empty, the system DNS servers will be used.
	Forwarders []string `json:"forwarders,omitempty" yaml:"forwarders,omitempty" toml:"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 `` /* 159-byte string literal not displayed */
	// DisableForwarding disables forwarding requests entirely.
	DisableForwarding bool `` /* 151-byte string literal not displayed */
	// CacheSize is the size of the remote DNS cache.
	CacheSize int `json:"cache-size,omitempty" yaml:"cache-size,omitempty" toml:"cache-size,omitempty" mapstructure:"cache-size,omitempty"`
}

MeshDNSOptions are the mesh DNS options.

func NewMeshDNSOptions

func NewMeshDNSOptions() *MeshDNSOptions

NewMeshDNSOptions creates a new set of mesh DNS options.

func (*MeshDNSOptions) BindFlags

func (o *MeshDNSOptions) BindFlags(fs *flag.FlagSet, prefix ...string)

BindFlags binds the flags for the mesh DNS options.

func (*MeshDNSOptions) DeepCopy added in v0.1.13

func (o *MeshDNSOptions) DeepCopy() *MeshDNSOptions

DeepCopy copies the mesh DNS options.

func (*MeshDNSOptions) Validate

func (o *MeshDNSOptions) Validate() error

Validate validates the mesh DNS options.

type MetricsOptions

type MetricsOptions struct {
	// Enabled is true if metrics should be enabled.
	Enabled bool `json:"enabled,omitempty" yaml:"enabled,omitempty" toml:"enabled,omitempty" mapstructure:"enabled,omitempty"`
	// MetricsListenAddress is the address to listen on for metrics.
	ListenAddress string `` /* 135-byte string literal not displayed */
	// MetricsPath is the path to serve metrics on.
	Path string `json:"path,omitempty" yaml:"path,omitempty" toml:"path,omitempty" mapstructure:"path,omitempty"`
}

Metrics are options for exposing metrics.

func NewMetricsOptions

func NewMetricsOptions() *MetricsOptions

NewMetricsOptions creates a new MetricsOptions with default values.

func (*MetricsOptions) BindFlags

func (o *MetricsOptions) BindFlags(fs *flag.FlagSet, prefix ...string)

BindFlags binds the flags.

func (*MetricsOptions) DeepCopy added in v0.1.13

func (o *MetricsOptions) DeepCopy() *MetricsOptions

DeepCopy returns a deep copy.

type Options

type Options struct {
	// ListenAddress is the address to listen on.
	ListenAddress string `` /* 135-byte string literal not displayed */
	// TLSCertFile is the path to the TLS certificate file.
	TLSCertFile string `` /* 131-byte string literal not displayed */
	// TLSKeyFile is the path to the TLS key file.
	TLSKeyFile string `` /* 127-byte string literal not displayed */
	// Insecure is true if the transport is insecure.
	Insecure bool `json:"insecure,omitempty" yaml:"insecure,omitempty" toml:"insecure,omitempty" mapstructure:"insecure,omitempty"`
	// API options
	API *APIOptions `json:"api,omitempty" yaml:"api,omitempty" toml:"api,omitempty" mapstructure:"api,omitempty"`
	// MeshDNS options
	MeshDNS *MeshDNSOptions `json:"mesh-dns,omitempty" yaml:"mesh-dns,omitempty" toml:"mesh-dns,omitempty" mapstructure:"mesh-dns,omitempty"`
	// TURN options
	TURN *TURNOptions `json:"turn,omitempty" yaml:"turn,omitempty" toml:"turn,omitempty" mapstructure:"turn,omitempty"`
	// Metrics options
	Metrics *MetricsOptions `json:"metrics,omitempty" yaml:"metrics,omitempty" toml:"metrics,omitempty" mapstructure:"metrics,omitempty"`
	// Dashboard options
	Dashboard *dashboard.Options `json:"dashboard,omitempty" yaml:"dashboard,omitempty" toml:"dashboard,omitempty" mapstructure:"dashboard,omitempty"`
}

Options contains the configuration for the gRPC server.

func NewOptions

func NewOptions(grpcPort int) *Options

NewOptions returns new Options with sensible defaults. If grpcPort is 0 the default port is used.

func (*Options) BindFlags

func (o *Options) BindFlags(fs *flag.FlagSet, prefix ...string)

BindFlags binds the gRPC options to the given flag set.

func (*Options) DeepCopy added in v0.1.13

func (o *Options) DeepCopy() *Options

DeepCopy returns a deep copy of the options.

func (*Options) ListenPort

func (o *Options) ListenPort() (int, error)

ListenPort returns the port the options are configured to listen on.

func (*Options) ServerOptions

func (o *Options) ServerOptions(store mesh.Mesh, log *slog.Logger) (srvrOptions []grpc.ServerOption, err error)

ServerOptions converts the options to gRPC server options.

func (*Options) TLSConfig

func (o *Options) TLSConfig() (*tls.Config, error)

TLSConfig returns the TLS configuration.

func (*Options) ToFeatureSet

func (o *Options) ToFeatureSet(raftMember bool) []v1.Feature

ToFeatureSet converts the options to a feature set.

func (*Options) Validate

func (o *Options) Validate() error

Validate validates the options.

type Server

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

Server is the gRPC server.

func NewServer

func NewServer(store mesh.Mesh, o *Options) (*Server, error)

NewServer returns a new Server.

func (*Server) Check

Check implements grpc.health.v1.HealthServer.

func (*Server) GetServiceInfo

func (s *Server) GetServiceInfo() map[string]grpc.ServiceInfo

GetServiceInfo implements reflection.ServiceInfoProvider.

func (*Server) ListenAndServe

func (s *Server) ListenAndServe() error

ListenAndServe starts the gRPC server and optional metrics server then blocks until the gRPC server exits.

func (*Server) RegisterService

func (s *Server) RegisterService(desc *grpc.ServiceDesc, impl any)

RegisterService implements grpc.RegistrarService.

func (*Server) Stop

func (s *Server) Stop()

Stop stops the gRPC server gracefully. You cannot use the server again after calling Stop.

func (*Server) Watch

Watch implements grpc.health.v1.HealthServer.

type TURNOptions

type TURNOptions struct {
	// Enabled enables the TURN server.
	Enabled bool `json:"enabled,omitempty" yaml:"enabled,omitempty" toml:"enabled,omitempty" mapstructure:"enabled,omitempty"`
	// Endpoint is the endpoint to advertise for the TURN server. If empty, the public IP and listen port is used.
	Endpoint string `json:"endpoint,omitempty" yaml:"endpoint,omitempty" toml:"endpoint,omitempty" mapstructure:"endpoint,omitempty"`
	// PublicIP is the address advertised for STUN requests.
	PublicIP string `json:"public-ip,omitempty" yaml:"public-ip,omitempty" toml:"public-ip,omitempty" mapstructure:"public-ip,omitempty"`
	// ListenAddress is the address to listen on for TURN connections.
	ListenAddress string `` /* 135-byte string literal not displayed */
	// ListenPort is the port to listen on for TURN connections.
	ListenPort int `json:"listen-port,omitempty" yaml:"listen-port,omitempty" toml:"listen-port,omitempty" mapstructure:"listen-port,omitempty"`
	// ServerRealm is the realm used for TURN server authentication.
	ServerRealm string `json:"realm,omitempty" yaml:"realm,omitempty" toml:"realm,omitempty" mapstructure:"realm,omitempty"`
	// STUNPortRange is the port range to use for STUN.
	STUNPortRange string `` /* 139-byte string literal not displayed */
}

TURNOptions are the TURN Server options.

func NewTURNOptions

func NewTURNOptions() *TURNOptions

NewTURNOptions creates a new TURNOptions with default values.

func (*TURNOptions) BindFlags

func (o *TURNOptions) BindFlags(fs *flag.FlagSet, prefix ...string)

BindFlags binds the flags.

func (*TURNOptions) DeepCopy added in v0.1.13

func (o *TURNOptions) DeepCopy() *TURNOptions

DeepCopy returns a deep copy.

func (*TURNOptions) Validate

func (o *TURNOptions) Validate() error

Validate validates the options.

Directories

Path Synopsis
Package admin provides the admin gRPC server.
Package admin provides the admin gRPC server.
Package dashboard contains a service that serves a web dashboard.
Package dashboard contains a service that serves a web dashboard.
Package leaderproxy provides a gRPC interceptor that proxies requests to the leader node.
Package leaderproxy provides a gRPC interceptor that proxies requests to the leader node.
Package membership contains the webmesh membership service.
Package membership contains the webmesh membership service.
Package meshapi contains the webmesh Mesh API service.
Package meshapi contains the webmesh Mesh API service.
Package meshdns contains the Mesh DNS server.
Package meshdns contains the Mesh DNS server.
Package node contains the webmesh node service.
Package node contains the webmesh node service.
Package rbac contains utilities for evaluating requests against roles.
Package rbac contains utilities for evaluating requests against roles.
Package turn contains the STUN/TURN server.
Package turn contains the STUN/TURN server.
Package webrtc contains the webmesh WebRTC service.
Package webrtc contains the webmesh WebRTC service.

Jump to

Keyboard shortcuts

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