api

package
v0.22.0 Latest Latest
Warning

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

Go to latest
Published: May 1, 2023 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Overview

Package api implements api for pomerium desktop UI

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewConfig

func NewConfig() *config

Types

type Config

type Config interface{}

type ConfigProvider

type ConfigProvider interface {
	// Load returns configuration data,
	// should not throw an error if underlying storage does not exist
	Load() ([]byte, error)
	// Save stores data into storage
	Save([]byte) error
}

ConfigProvider provides interface to the configuration persistence

type EventBroadcaster

type EventBroadcaster interface {
	// Reset the history for the connection, called when listener starts accepting new connections
	Reset(ctx context.Context, id string) error
	// Update provides a peer connection state change updates
	Update(ctx context.Context, evt *pb.ConnectionStatusUpdate) error
	// Subscribe to updates for the tunnel; the channel will close when context provided is canceled
	Subscribe(ctx context.Context, id string) (chan *pb.ConnectionStatusUpdate, error)
}

EventBroadcaster is used to record and broadcast tunnel and connection state changes

func NewEventsBroadcaster

func NewEventsBroadcaster(ctx context.Context) EventBroadcaster

NewEventsBroadcaster creates a new broadcaster

type FileConfigProvider

type FileConfigProvider string

FileConfigProvider implements file based configuration storage

func (FileConfigProvider) Load

func (f FileConfigProvider) Load() ([]byte, error)

Load loads file data or returns empty data if it does not exist

func (FileConfigProvider) Save

func (f FileConfigProvider) Save(data []byte) error

Save stores data to the file

type ListenerStatus

type ListenerStatus interface {
	// Lock marks a particular ID locked and provides a function to be called on unlock
	SetListening(id string, onUnlock context.CancelFunc, addr string) error
	// IsListening checks whether particular ID is currently locked
	GetListenerStatus(id string) *pb.ListenerStatus
	// Unlock unlocks the ID and calls onUnlock function and clears listener status
	SetNotListening(id string) error
	// SetListenError sets listener status to an error
	SetListenerError(id string, err error) error
}

ListenerStatus marks individual records as locked

type MemCP

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

MemCP is in-memory config provider

func (*MemCP) Load

func (s *MemCP) Load() ([]byte, error)

Load loads the configuration data

func (*MemCP) Save

func (s *MemCP) Save(data []byte) error

Save saves configuration data

type Server

type Server interface {
	pb.ConfigServer
	pb.ListenerServer
}

Server implements both config and listener interfaces

func NewServer

func NewServer(ctx context.Context, opts ...ServerOption) (Server, error)

NewServer creates new configuration management server

type ServerOption

type ServerOption func(*server) error

ServerOption allows to customize certain behavior

func WithBrowserCommand

func WithBrowserCommand(cmd string) ServerOption

func WithConfigProvider

func WithConfigProvider(cp ConfigProvider) ServerOption

WithConfigProvider customizes configuration persistence

func WithServiceAccount added in v0.21.0

func WithServiceAccount(serviceAccount string) ServerOption

func WithServiceAccountFile added in v0.21.0

func WithServiceAccountFile(serviceAccountFile string) ServerOption

type Tunnel

type Tunnel interface {
	Run(context.Context, io.ReadWriter, tcptunnel.TunnelEvents) error
}

Tunnel is abstraction over tcptunnel.Tunnel to allow mocking

Jump to

Keyboard shortcuts

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