services

package
v0.0.0-...-5e81e3c Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2023 License: AGPL-3.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidLatencyTestResultLength    = errors.New("received invalid length of latency test results")
	ErrInvalidThroughputTestResultLength = errors.New("received invalid length of throughput test results")
	ErrSrcNotFound                       = errors.New("could not find source")
	ErrAdapterNotFound                   = errors.New("could not find adapter")
)
View Source
var (
	ErrSwitchAlreadyRegistered  = errors.New("could not register switch: A switch with this remote ID is already registered")
	ErrAdapterAlreadyRegistered = errors.New("could not register adapter: An adapter with this remote ID is already registered")
	ErrDstNotFound              = errors.New("could not find destination")
	ErrDstIsSrc                 = errors.New("could not find route when dst and src are the same")
	ErrRouteNotFound            = errors.New("could not find route")
	ErrSwitchNotFound           = errors.New("could not find switch")
	ErrInvalidPortsCount        = errors.New("could not proceed with invalid ports count")
)
View Source
var (
	ErrUnauthenticatedRole  = errors.New("unauthenticated role")
	ErrUnauthenticatedRoute = errors.New("unauthenticated route")
)
View Source
var (
	ErrNoPeersFound = errors.New("could not find any peers")
)

Functions

func HandleGatewayClientDisconnect

func HandleGatewayClientDisconnect(r *Router, g *Gateway, remoteID string) error

func HandleMetricsClientConnect

func HandleMetricsClientConnect(router *Router) error

func HandleRouterClientDisconnect

func HandleRouterClientDisconnect(r *Router, g *Gateway, remoteID string) error

func HandleRouterOpen

func HandleRouterOpen(router *Router)

func RequestCall

func RequestCall(adapter *Adapter, dstID, channelID string) (bool, string, error)

func SetAdapterCA

func SetAdapterCA(adapter *Adapter, caPEM []byte)

func SetSwitchCA

func SetSwitchCA(sw *Switch, caPEM []byte)

Types

type Adapter

type Adapter struct {
	Peers func() map[string]GatewayRemote
	// contains filtered or unexported fields
}

func NewAdapter

func NewAdapter(
	verbose bool,
	ahost string,

	onRequestCall func(ctx context.Context, srcID, srcEmail, routeID, channelID string) (bool, error),
	onCallDisconnected func(ctx context.Context, routeID, channelID string) error,
	onHandleCall func(ctx context.Context, routeID, channelID, raddr string) error,
	getIDToken func() (string, error),
) *Adapter

func (*Adapter) ProvisionRoute

func (a *Adapter) ProvisionRoute(
	ctx context.Context,
	routeID string,
	channelID string,
	raddr string,
	cert CertPair,
) error

func (*Adapter) RequestCall

func (a *Adapter) RequestCall(
	ctx context.Context,
	srcID,
	srcEmail,
	routeID,
	channelID string,
) (bool, error)

func (*Adapter) TestLatency

func (a *Adapter) TestLatency(ctx context.Context, timeout time.Duration, addrs []string, benchmarkClientCert CertPair) ([]time.Duration, error)

func (*Adapter) TestThroughput

func (a *Adapter) TestThroughput(ctx context.Context, timeout time.Duration, addrs []string, benchmarkClientCert CertPair, benchmarkLimit int64) ([]ThroughputResult, error)

func (*Adapter) UnprovisionRoute

func (a *Adapter) UnprovisionRoute(ctx context.Context, routeID string) error

type AdapterMetadata

type AdapterMetadata struct {
	Latencies   map[string]time.Duration
	Throughputs map[string]ThroughputResult
	UserEmail   string
}

type AdapterRemote

type AdapterRemote struct {
	RequestCall      func(ctx context.Context, srcID, srcEmail, routeID, channelID string) (bool, error)
	TestLatency      func(ctx context.Context, timeout time.Duration, addrs []string, benchmarkClientCert CertPair) ([]time.Duration, error)
	TestThroughput   func(ctx context.Context, timeout time.Duration, addrs []string, benchmarkClientCert CertPair, benchmarkLimit int64) ([]ThroughputResult, error)
	UnprovisionRoute func(ctx context.Context, routeID string) error
	ProvisionRoute   func(
		ctx context.Context,
		routeID,
		channelID,
		raddr string,
		cert CertPair,
	) error
}

type CertPair

type CertPair struct {
	CertPEM        []byte
	CertPrivKeyPEM []byte
}

type Gateway

type Gateway struct {
	Router *Router

	Peers func() map[string]AdapterRemote
	// contains filtered or unexported fields
}

func NewGateway

func NewGateway(
	verbose bool,

	oidcIssuer,
	oidcClientID string,

	caCfg *x509.Certificate,
	caPEM []byte,
	caPrivKey *rsa.PrivateKey,

	benchmarkClientCertValidity time.Duration,

	rsaBits int,

	benchmarkLimit int64,
) *Gateway

func (*Gateway) HangupCall

func (g *Gateway) HangupCall(ctx context.Context, token string, routeID string) error

func (*Gateway) Open

func (g *Gateway) Open(ctx context.Context) error

func (*Gateway) RegisterAdapter

func (g *Gateway) RegisterAdapter(ctx context.Context, token string) ([]byte, error)

func (*Gateway) RequestCall

func (g *Gateway) RequestCall(ctx context.Context, token string, dstID, channelID string) (RequestCallResult, error)

func (*Gateway) ResolveEmailToID

func (g *Gateway) ResolveEmailToID(ctx context.Context, token string, email string) (string, error)

type GatewayRemote

type GatewayRemote struct {
	RegisterAdapter  func(ctx context.Context, token string) ([]byte, error)
	RequestCall      func(ctx context.Context, token string, dstID, channelID string) (RequestCallResult, error)
	HangupCall       func(ctx context.Context, token string, routeID string) error
	ResolveEmailToID func(ctx context.Context, token string, email string) (string, error)
}

type Metrics

type Metrics struct {
	Peers func() map[string]VisualizerRemote
	// contains filtered or unexported fields
}

func NewMetrics

func NewMetrics(
	verbose bool,
	oidcIssuer,
	oidcClientID,
	authorizedEmail string,
) *Metrics

func (*Metrics) Open

func (m *Metrics) Open(ctx context.Context) error

type MetricsRemote

type MetricsRemote struct{}

type RequestCallResult

type RequestCallResult struct {
	Accept  bool
	RouteID string
}

type Router

type Router struct {
	Metrics *Metrics
	Gateway *Gateway

	Peers func() map[string]SwitchRemote
	// contains filtered or unexported fields
}

func NewRouter

func NewRouter(
	verbose bool,

	testInterval time.Duration,
	testTimeout time.Duration,

	oidcIssuer,
	oidcClientID,
	oidcAudience string,

	caCfg *x509.Certificate,
	caPEM []byte,
	caPrivKey *rsa.PrivateKey,

	callCertValidity time.Duration,
	benchmarkListenCertValidity time.Duration,
	benchmarkClientCertValidity time.Duration,

	rsaBits int,

	benchmarkLimit int64,
) *Router

func (*Router) Open

func (r *Router) Open(ctx context.Context) error

func (*Router) RegisterSwitch

func (r *Router) RegisterSwitch(ctx context.Context, token string, addr string) (SwitchConfiguration, error)

type RouterRemote

type RouterRemote struct {
	RegisterSwitch func(ctx context.Context, token string, addr string) (SwitchConfiguration, error)
}

type Switch

type Switch struct {
	Peers func() map[string]RouterRemote
	// contains filtered or unexported fields
}

func NewSwitch

func NewSwitch(verbose bool, ahost string) *Switch

func (*Switch) GetPublicIP

func (s *Switch) GetPublicIP(ctx context.Context) (string, error)

func (*Switch) ProvisionRoute

func (s *Switch) ProvisionRoute(
	ctx context.Context,
	routeID string,
	raddr string,
	switchListenCert,
	switchClientCert,
	adapterListenCert CertPair,
) ([]string, error)

func (*Switch) TestLatency

func (s *Switch) TestLatency(ctx context.Context, timeout time.Duration, addrs []string, benchmarkClientCert CertPair) ([]time.Duration, error)

func (*Switch) TestThroughput

func (s *Switch) TestThroughput(ctx context.Context, timeout time.Duration, addrs []string, benchmarkClientCert CertPair, benchmarkLimit int64) ([]ThroughputResult, error)

func (*Switch) UnprovisionRoute

func (s *Switch) UnprovisionRoute(ctx context.Context, routeID string) error

type SwitchConfiguration

type SwitchConfiguration struct {
	CAPEM               []byte
	BenchmarkListenCert CertPair
	BenchmarkLimit      int64
}

type SwitchMetadata

type SwitchMetadata struct {
	Addr        string
	Latencies   map[string]time.Duration
	Throughputs map[string]ThroughputResult
}

type SwitchRemote

type SwitchRemote struct {
	TestLatency      func(ctx context.Context, timeout time.Duration, addrs []string, benchmarkClientCert CertPair) ([]time.Duration, error)
	TestThroughput   func(ctx context.Context, timeout time.Duration, addrs []string, benchmarkClientCert CertPair, benchmarkLimit int64) ([]ThroughputResult, error)
	UnprovisionRoute func(ctx context.Context, routeID string) error
	GetPublicIP      func(ctx context.Context) (string, error)
	ProvisionRoute   func(
		ctx context.Context,
		routeID string,
		raddr string,
		switchListenCert,
		switchClientCert,
		adapterListenCert CertPair,
	) ([]string, error)
}

type ThroughputResult

type ThroughputResult struct {
	Read  time.Duration
	Write time.Duration
}

type Visualizer

type Visualizer struct {
	Peers func() map[string]MetricsRemote
	// contains filtered or unexported fields
}

func NewVisualizer

func NewVisualizer(
	verbose bool,
	networkFile *os.File,
	routesFile *os.File,
	command string,

	getIDToken func() (string, error),
) *Visualizer

func (*Visualizer) Attest

func (v *Visualizer) Attest(
	ctx context.Context,
) (string, error)

func (*Visualizer) RenderNetworkVisualization

func (v *Visualizer) RenderNetworkVisualization(
	ctx context.Context,
	switches map[string]SwitchMetadata,
	adapters map[string]AdapterMetadata,
) error

func (*Visualizer) RenderRoutesVisualization

func (v *Visualizer) RenderRoutesVisualization(
	ctx context.Context,
	routes map[string][]string,
) error

type VisualizerRemote

type VisualizerRemote struct {
	Attest func(
		ctx context.Context,
	) (string, error)
	RenderNetworkVisualization func(
		ctx context.Context,
		switches map[string]SwitchMetadata,
		adapters map[string]AdapterMetadata,
	) error
	RenderRoutesVisualization func(
		ctx context.Context,
		routes map[string][]string,
	) error
}

Jump to

Keyboard shortcuts

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