server

package
v0.18.0 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ConfigDeletionUpdateDelay is the delay between deleting a config from the server and
	// sending the corresponing zero-config to the client. Set this to zero to suppress sending
	// the zero-config all together.
	ConfigDeletionUpdateDelay = 5 * time.Second
)

Functions

This section is empty.

Types

type ClientConfigPatcher added in v0.17.1

type ClientConfigPatcher func(conf *stnrv1.StunnerConfig) (*stnrv1.StunnerConfig, error)

type Config

type Config struct {
	Id     string
	Config *stnrv1.StunnerConfig
}

func (Config) String

func (e Config) String() string

type ConfigFilter added in v0.17.1

type ConfigFilter func(confId string) bool

ConfigFilter is a callback to filter config updates for a client.

type ConfigList

type ConfigList = api.V1ConfigList

type ConfigPatcher added in v0.17.1

type ConfigPatcher func(conf *stnrv1.StunnerConfig, node string) (*stnrv1.StunnerConfig, error)

ConfigPatcher is a callback to patch config updates for a client.

type ConfigStore

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

func NewConfigStore

func NewConfigStore() *ConfigStore

func (*ConfigStore) Delete

func (t *ConfigStore) Delete(id string)

func (*ConfigStore) Get

func (t *ConfigStore) Get(id string) *stnrv1.StunnerConfig

func (*ConfigStore) Snapshot

func (t *ConfigStore) Snapshot() []Config

func (*ConfigStore) Upsert

func (t *ConfigStore) Upsert(id string, c *stnrv1.StunnerConfig)

type Conn

type Conn struct {
	*websocket.Conn
	Filter ConfigFilter
	// contains filtered or unexported fields
}

Conn represents a client WebSocket connection.

func NewConn

func NewConn(conn *websocket.Conn, filter ConfigFilter, patch ClientConfigPatcher, cancel context.CancelFunc) *Conn

NewConn wraps a WebSocket connection.

func (*Conn) Id

func (c *Conn) Id() string

Id returns the IP 5-tuple for a client connection.

func (*Conn) ReadMessage

func (c *Conn) ReadMessage() (int, []byte, error)

ReadMessage reads a message from the client connection with proper locking.

func (*Conn) WriteMessage

func (c *Conn) WriteMessage(messageType int, data []byte) error

WriteMessage writes a message to the client connection with proper locking.

type ConnTrack

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

ConnTrack represents the server's connection tracking table.

func NewConnTrack

func NewConnTrack() *ConnTrack

NewConnTrack creates a new connection tracking table.

func (*ConnTrack) Delete

func (t *ConnTrack) Delete(conn *Conn)

Delete removes a client connection.

func (*ConnTrack) Get

func (t *ConnTrack) Get(cid string) *Conn

Get returns a client connection by the IP 5-tuple.

func (*ConnTrack) Snapshot

func (t *ConnTrack) Snapshot() []*Conn

Snapshot creates a snapshot of the connection tracking table.

func (*ConnTrack) Upsert

func (t *ConnTrack) Upsert(c *Conn)

Upsert insert a new client connection.

type Server

type Server struct {
	*http.Server
	// contains filtered or unexported fields
}

Server is a generic config discovery server implementation.

func New

func New(addr string, patch ConfigPatcher, logger logr.Logger) *Server

New creates a new config discovery server instance for the specified address.

func (*Server) Close

func (s *Server) Close()

Close closes the server and drops all active connections.

func (*Server) DeleteConfig

func (s *Server) DeleteConfig(id string)

DeleteConfig removes a config from the client. Theoretically, this should send the client a zero-config immediately. However, in order to avoid that a client being removed and entering the graceful shutdown cycle receive a zeroconfig and abruprly kill all listeners with all active connections allocated to them, we actually delay sending the zeroconfig with a configurable time (default is 5 sec, but a zero delay will suppress sending the zero-config all together). This should allow the client comfortable time to enter the grafeul shutdown cycle. Note that clients should stop actively reconciling config updates once they initiated graceful shutdown for this to work.

func (*Server) GetConfigChannel

func (s *Server) GetConfigChannel() chan Config

GetConfigChannel returns the channel that can be used to add configs to the server's config store. Use Update to specify more configs at once.

func (*Server) GetConfigStore

func (s *Server) GetConfigStore() *ConfigStore

GetConfigStore returns the dataplane configs stores in the server.

func (*Server) GetConnTrack

func (s *Server) GetConnTrack() *ConnTrack

GetConnTrack returns the client connection tracking table of the server.

func (*Server) GetV1ConfigNamespaceName

(GET /api/v1/configs/{namespace}/{name})

func (*Server) ListV1Configs

(GET /api/v1/configs)

func (*Server) ListV1ConfigsNamespace

(GET /api/v1/configs/{namespace})

func (*Server) RemoveClient

func (s *Server) RemoveClient(id string)

RemoveClient forcefully closes a client connection. This is used mainly for testing.

func (*Server) Start

func (s *Server) Start(ctx context.Context) error

Start let the config discovery server listen to new client connections.

func (*Server) UpdateConfig

func (s *Server) UpdateConfig(newConfigs []Config) error

UpdateConfig receives a set of ids and newConfigs that represent the state-of-the-world at a particular instance of time and generates an update per each change.

func (*Server) UpsertConfig

func (s *Server) UpsertConfig(id string, c *stnrv1.StunnerConfig)

UpsertConfig upserts a single config in the server.

func (*Server) WSUpgradeMiddleware added in v0.17.1

func (s *Server) WSUpgradeMiddleware(next api.StrictHandlerFunc, operationID string) api.StrictHandlerFunc

Directories

Path Synopsis
Package api provides primitives to interact with the openapi HTTP API.
Package api provides primitives to interact with the openapi HTTP API.

Jump to

Keyboard shortcuts

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