Documentation
¶
Index ¶
- Constants
- Variables
- func ParseConfig(c []byte) (*stnrv1.StunnerConfig, error)
- func ZeroConfig(id string) *stnrv1.StunnerConfig
- type AllConfigsAPI
- func (a *AllConfigsAPI) Endpoint() (string, string)
- func (a *AllConfigsAPI) Get(ctx context.Context) ([]*stnrv1.StunnerConfig, error)
- func (a *AllConfigsAPI) Poll(ctx context.Context, ch chan<- stnrv1.StunnerConfig) error
- func (a *AllConfigsAPI) Watch(ctx context.Context, ch chan<- stnrv1.StunnerConfig) error
- type CDSAPI
- type CDSClient
- type Client
- type ConfigFileClient
- type ConfigList
- type ConfigNamespaceNameAPI
- func (a *ConfigNamespaceNameAPI) Endpoint() (string, string)
- func (a *ConfigNamespaceNameAPI) Get(ctx context.Context) ([]*stnrv1.StunnerConfig, error)
- func (a *ConfigNamespaceNameAPI) Poll(ctx context.Context, ch chan<- stnrv1.StunnerConfig) error
- func (a *ConfigNamespaceNameAPI) Watch(ctx context.Context, ch chan<- stnrv1.StunnerConfig) error
- type ConfigSkeleton
- type ConfigsNamespaceAPI
- func (a *ConfigsNamespaceAPI) Endpoint() (string, string)
- func (a *ConfigsNamespaceAPI) Get(ctx context.Context) ([]*stnrv1.StunnerConfig, error)
- func (a *ConfigsNamespaceAPI) Poll(ctx context.Context, ch chan<- stnrv1.StunnerConfig) error
- func (a *ConfigsNamespaceAPI) Watch(ctx context.Context, ch chan<- stnrv1.StunnerConfig) error
Constants ¶
const ( ConfigNamespaceNameAPIEndpoint = "/api/v1/configs/%s/%s" ConfigsNamespaceAPIEndpoint = "/api/v1/configs/%s" AllConfigsAPIEndpoint = "/api/v1/configs" )
Variables ¶
var ( // Send pings to the CDS server with this period. Must be less than PongWait. PingPeriod = 5 * time.Second // Time allowed to read the next pong message from the CDS server. PongWait = 8 * time.Second // Time allowed to write a message to the CDS server. WriteWait = 2 * time.Second // Period for retrying failed CDS connections. RetryPeriod = 1 * time.Second )
Functions ¶
func ParseConfig ¶
func ParseConfig(c []byte) (*stnrv1.StunnerConfig, error)
ParseConfig parses a raw buffer holding a configuration, substituting environment variables for placeholders in the configuration. Returns the new configuration or error if parsing fails.
func ZeroConfig ¶
func ZeroConfig(id string) *stnrv1.StunnerConfig
ZeroConfig builds a zero configuration useful for bootstrapping STUNner. The minimal config defaults to static authentication with a dummy username and password and opens no listeners or clusters.
Types ¶
type AllConfigsAPI ¶ added in v0.16.2
type AllConfigsAPI struct {
logging.LeveledLogger
// contains filtered or unexported fields
}
AllConfigsAPI is the API for listing all configs in a namespace.
func (*AllConfigsAPI) Endpoint ¶ added in v0.16.2
func (a *AllConfigsAPI) Endpoint() (string, string)
func (*AllConfigsAPI) Get ¶ added in v0.16.2
func (a *AllConfigsAPI) Get(ctx context.Context) ([]*stnrv1.StunnerConfig, error)
func (*AllConfigsAPI) Poll ¶ added in v0.16.2
func (a *AllConfigsAPI) Poll(ctx context.Context, ch chan<- stnrv1.StunnerConfig) error
func (*AllConfigsAPI) Watch ¶ added in v0.16.2
func (a *AllConfigsAPI) Watch(ctx context.Context, ch chan<- stnrv1.StunnerConfig) error
type CDSAPI ¶ added in v0.16.2
type CDSAPI interface {
// Endpoint returns the address of the server plus the WebSocket API endpoint.
Endpoint() (string, string)
// Get loads the config(s) from the API endpoint.
Get(ctx context.Context) ([]*stnrv1.StunnerConfig, error)
// Watch watches config(s) from the API endpoint of a CDS server. If the server is not
// available watch will retry, and if the connection goes away it will create a new one.
Watch(ctx context.Context, ch chan<- stnrv1.StunnerConfig) error
// Poll creates a one-shot config watcher without the retry mechanincs of Watch.
Poll(ctx context.Context, ch chan<- stnrv1.StunnerConfig) error
logging.LeveledLogger
}
func NewAllConfigsAPI ¶ added in v0.16.2
func NewAllConfigsAPI(addr string, logger logging.LeveledLogger) (CDSAPI, error)
func NewConfigNamespaceNameAPI ¶ added in v0.16.2
func NewConfigNamespaceNameAPI(addr, namespace, name string, logger logging.LeveledLogger) (CDSAPI, error)
func NewConfigsNamespaceAPI ¶ added in v0.16.2
func NewConfigsNamespaceAPI(addr, namespace string, logger logging.LeveledLogger) (CDSAPI, error)
type CDSClient ¶ added in v0.16.2
type CDSClient struct {
CDSAPI
// contains filtered or unexported fields
}
CDSClient is a client for the config discovery service that knows how to poll configs for a specific gateway. Use the CDSAPI to access the general CDS client set.
type Client ¶
type Client interface {
// Load grabs a new configuration from the config client.
Load() (*stnrv1.StunnerConfig, error)
// Watch grabs new configs from a config origin (config file or CDS server) and returns
// them on the channel. The context cancels the watcher. If the origin is not available
// watch will retry.
Watch(ctx context.Context, ch chan<- stnrv1.StunnerConfig) error
// Poll creates a one-shot config watcher without the retry mechanincs of Watch.
Poll(ctx context.Context, ch chan<- stnrv1.StunnerConfig) error
fmt.Stringer
}
Client represents a generic config client. Currently supported config providers: http, ws, or file. Configuration obtained through the client are not validated, make sure to validate on the receiver side.
func NewCDSClient ¶ added in v0.16.2
func NewCDSClient(addr, id string, logger logging.LeveledLogger) (Client, error)
func NewConfigFileClient ¶ added in v0.16.2
func NewConfigFileClient(origin, id string, logger logging.LeveledLogger) (Client, error)
type ConfigFileClient ¶ added in v0.16.2
type ConfigFileClient struct {
// contains filtered or unexported fields
}
ConfigFileClient is the implementation of the Client interface for config files.
func (*ConfigFileClient) Load ¶ added in v0.16.2
func (w *ConfigFileClient) Load() (*stnrv1.StunnerConfig, error)
func (*ConfigFileClient) Poll ¶ added in v0.16.2
func (w *ConfigFileClient) Poll(ctx context.Context, ch chan<- stnrv1.StunnerConfig) error
Poll watches the config file and emits new configs on the specified channel. Returns an error if further action is needed (tryWatchConfig is to be started) or nil on normal exit.
func (*ConfigFileClient) String ¶ added in v0.16.2
func (w *ConfigFileClient) String() string
func (*ConfigFileClient) Watch ¶ added in v0.16.2
func (w *ConfigFileClient) Watch(ctx context.Context, ch chan<- stnrv1.StunnerConfig) error
WatchConfig watches a configuration file for changes. If no file exists at the given path, WatchConfig will periodically retry until the file appears.
type ConfigList ¶ added in v0.16.2
type ConfigList struct {
Version string `json:"version"`
Items []*stnrv1.StunnerConfig `json:"items"`
}
type ConfigNamespaceNameAPI ¶ added in v0.16.2
type ConfigNamespaceNameAPI struct {
logging.LeveledLogger
// contains filtered or unexported fields
}
func (*ConfigNamespaceNameAPI) Endpoint ¶ added in v0.16.2
func (a *ConfigNamespaceNameAPI) Endpoint() (string, string)
func (*ConfigNamespaceNameAPI) Get ¶ added in v0.16.2
func (a *ConfigNamespaceNameAPI) Get(ctx context.Context) ([]*stnrv1.StunnerConfig, error)
func (*ConfigNamespaceNameAPI) Poll ¶ added in v0.16.2
func (a *ConfigNamespaceNameAPI) Poll(ctx context.Context, ch chan<- stnrv1.StunnerConfig) error
func (*ConfigNamespaceNameAPI) Watch ¶ added in v0.16.2
func (a *ConfigNamespaceNameAPI) Watch(ctx context.Context, ch chan<- stnrv1.StunnerConfig) error
type ConfigSkeleton ¶ added in v0.16.1
type ConfigSkeleton struct {
ApiVersion string `json:"version"`
}
type ConfigsNamespaceAPI ¶ added in v0.16.2
type ConfigsNamespaceAPI struct {
logging.LeveledLogger
// contains filtered or unexported fields
}
ConfigsNamespaceAPI is the API for listing all configs in a namespace.
func (*ConfigsNamespaceAPI) Endpoint ¶ added in v0.16.2
func (a *ConfigsNamespaceAPI) Endpoint() (string, string)
func (*ConfigsNamespaceAPI) Get ¶ added in v0.16.2
func (a *ConfigsNamespaceAPI) Get(ctx context.Context) ([]*stnrv1.StunnerConfig, error)
func (*ConfigsNamespaceAPI) Poll ¶ added in v0.16.2
func (a *ConfigsNamespaceAPI) Poll(ctx context.Context, ch chan<- stnrv1.StunnerConfig) error
func (*ConfigsNamespaceAPI) Watch ¶ added in v0.16.2
func (a *ConfigsNamespaceAPI) Watch(ctx context.Context, ch chan<- stnrv1.StunnerConfig) error