control

package
v0.13.2 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2026 License: Apache-2.0 Imports: 35 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ClientIDNil = ClientID{""}
View Source
var RelayIDNil = RelayID{""}

Functions

This section is empty.

Types

type ClientAuthenticateRequest

type ClientAuthenticateRequest struct {
	Proto        model.ClientControlNextProto
	Token        string
	Addr         net.Addr
	BuildVersion string
}

type ClientAuthentication

type ClientAuthentication []byte

type ClientAuthenticator

type ClientAuthenticator interface {
	Authenticate(req ClientAuthenticateRequest) (ClientAuthentication, error)
	Validate(auth ClientAuthentication, endpoint model.Endpoint, role model.Role) (model.Endpoint, error)
}

type ClientConnKey

type ClientConnKey struct {
	ID ClientID `json:"id"`
}

type ClientConnValue

type ClientConnValue struct {
	Authentication ClientAuthentication `json:"authentication"`
	Addr           string               `json:"addr"`
	Metadata       string               `json:"metadata"`
}

type ClientID

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

func NewClientID

func NewClientID() ClientID

func (ClientID) MarshalText

func (k ClientID) MarshalText() ([]byte, error)

func (ClientID) String

func (k ClientID) String() string

func (*ClientID) UnmarshalText

func (k *ClientID) UnmarshalText(b []byte) error

type ClientPeerKey

type ClientPeerKey struct {
	Endpoint model.Endpoint `json:"endpoint"`
	Role     model.Role     `json:"role"`
	ID       ClientID       `json:"id"` // TODO consider using the server cert key or peer id
}

type ClientPeerValue

type ClientPeerValue struct {
	Peer     *pbclient.Peer `json:"peer"`
	Metadata string         `json:"metadata"`
}

type ClientRelays

type ClientRelays interface {
	Client(ctx context.Context, endpoint model.Endpoint, role model.Role, cert *x509.Certificate, auth ClientAuthentication,
		notify func(map[RelayID]relayCacheValue) error) error
	Directs(ctx context.Context, endpoint model.Endpoint, role model.Role, cert *x509.Certificate, auth ClientAuthentication,
		notify func(map[RelayID]*pbclient.DirectRelay) error) error
}

type Config

type Config struct {
	ClientsIngress []Ingress
	ClientsAuth    ClientAuthenticator

	RelaysIngress []Ingress
	RelaysAuth    RelayAuthenticator

	Stores Stores

	Logger *slog.Logger
}

type ConfigKey

type ConfigKey string

type ConfigValue

type ConfigValue struct {
	Int64  int64  `json:"int64,omitempty"`
	String string `json:"string,omitempty"`
	Bytes  []byte `json:"bytes,omitempty"`
}

type Ingress

type Ingress struct {
	Addr  *net.UDPAddr
	TLS   *tls.Config
	Restr restr.IP
}

type IngressBuilder

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

func NewIngressBuilder

func NewIngressBuilder() *IngressBuilder

func (*IngressBuilder) Error

func (b *IngressBuilder) Error() error

func (*IngressBuilder) Ingress

func (b *IngressBuilder) Ingress() (Ingress, error)

func (*IngressBuilder) WithAddr

func (b *IngressBuilder) WithAddr(addr *net.UDPAddr) *IngressBuilder

func (*IngressBuilder) WithAddrFrom

func (b *IngressBuilder) WithAddrFrom(addrStr string) *IngressBuilder

func (*IngressBuilder) WithRestr

func (b *IngressBuilder) WithRestr(iprestr restr.IP) *IngressBuilder

func (*IngressBuilder) WithRestrFrom

func (b *IngressBuilder) WithRestrFrom(allows []string, denies []string) *IngressBuilder

func (*IngressBuilder) WithTLS

func (b *IngressBuilder) WithTLS(cfg *tls.Config) *IngressBuilder

func (*IngressBuilder) WithTLSCert

func (b *IngressBuilder) WithTLSCert(cert tls.Certificate) *IngressBuilder

func (*IngressBuilder) WithTLSCertFrom

func (b *IngressBuilder) WithTLSCertFrom(certFile, keyFile string) *IngressBuilder

type RelayAuthenticateRequest

type RelayAuthenticateRequest struct {
	Proto        model.RelayControlNextProto
	Token        string
	Addr         net.Addr
	BuildVersion string
}

type RelayAuthentication

type RelayAuthentication []byte

type RelayAuthenticator

type RelayAuthenticator interface {
	Authenticate(req RelayAuthenticateRequest) (RelayAuthentication, error)
	Allow(reAuth RelayAuthentication, clAuth ClientAuthentication, endpoint model.Endpoint) (bool, error)
}

type RelayClientKey

type RelayClientKey struct {
	Endpoint model.Endpoint `json:"endpoint"`
	Role     model.Role     `json:"role"`
	Key      model.Key      `json:"key"`
}

type RelayClientValue

type RelayClientValue struct {
	Cert           *x509.Certificate    `json:"cert"`
	Authentication ClientAuthentication `json:"authentication"`
}

func (RelayClientValue) MarshalJSON

func (v RelayClientValue) MarshalJSON() ([]byte, error)

func (*RelayClientValue) UnmarshalJSON

func (v *RelayClientValue) UnmarshalJSON(b []byte) error

type RelayConnKey

type RelayConnKey struct {
	ID RelayID `json:"id"`
}

type RelayConnValue

type RelayConnValue struct {
	Authentication RelayAuthentication `json:"authentication"`
	Hostports      []model.HostPort    `json:"hostports"`
	Metadata       string              `json:"metadata"`
}

type RelayDirectValue added in v0.13.0

type RelayDirectValue struct {
	Authentication        RelayAuthentication `json:"authentication"`
	Hostports             []model.HostPort    `json:"hostports"`
	Metadata              string              `json:"metadata"`
	Certificate           *x509.Certificate   `json:"certificate"`
	AuthenticationSealKey *[32]byte           `json:"authentication-seal-key"`
}

func (RelayDirectValue) MarshalJSON added in v0.13.0

func (v RelayDirectValue) MarshalJSON() ([]byte, error)

func (*RelayDirectValue) UnmarshalJSON added in v0.13.0

func (v *RelayDirectValue) UnmarshalJSON(b []byte) error

type RelayEndpointKey

type RelayEndpointKey struct {
	Endpoint model.Endpoint `json:"endpoint"`
}

type RelayEndpointValue

type RelayEndpointValue struct {
	Cert *x509.Certificate `json:"cert"`
}

func (RelayEndpointValue) MarshalJSON

func (v RelayEndpointValue) MarshalJSON() ([]byte, error)

func (*RelayEndpointValue) UnmarshalJSON

func (v *RelayEndpointValue) UnmarshalJSON(b []byte) error

type RelayID

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

func NewRelayID

func NewRelayID() RelayID

func (RelayID) MarshalText

func (k RelayID) MarshalText() ([]byte, error)

func (RelayID) String

func (k RelayID) String() string

func (*RelayID) UnmarshalText

func (k *RelayID) UnmarshalText(b []byte) error

type RelayServerKey

type RelayServerKey struct {
	Endpoint model.Endpoint `json:"endpoint"`
	RelayID  RelayID        `json:"relay_id"`
}

type RelayServerValue

type RelayServerValue struct {
	Hostports []model.HostPort  `json:"hostports"`
	Cert      *x509.Certificate `json:"cert"`
}

func (RelayServerValue) MarshalJSON

func (v RelayServerValue) MarshalJSON() ([]byte, error)

func (*RelayServerValue) UnmarshalJSON

func (v *RelayServerValue) UnmarshalJSON(b []byte) error

type Server

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

func NewServer

func NewServer(cfg Config) (*Server, error)

func (*Server) Run

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

func (*Server) Status

func (s *Server) Status(ctx context.Context) (Status, error)

type Status

type Status struct {
	BuildVersion string `json:"build-version"`

	ClientIngresses []StatusIngress           `json:"client-ingresses"`
	Clients         map[string]StatusClient   `json:"clients"`
	Endpoints       map[string]StatusEndpoint `json:"endpoints"`

	RelayServerID  string                 `json:"relay-server-id"`
	RelayIngresses []StatusIngress        `json:"relay-ingresses"`
	Relays         map[string]StatusRelay `json:"relays"`
}

type StatusClient

type StatusClient struct {
	ID       ClientID `json:"id"`
	Address  string   `json:"address"`
	Metadata string   `json:"metadata"`
}

type StatusEndpoint

type StatusEndpoint struct {
	Endpoint     model.Endpoint `json:"endpoint"`
	Destinations []ClientID     `json:"destinations"`
	Sources      []ClientID     `json:"sources"`
}

type StatusIngress

type StatusIngress struct {
	Address      string   `json:"address"`
	Restrictions restr.IP `json:"restrictions"`
}

func StatusIngressFn

func StatusIngressFn(ing Ingress) StatusIngress

type StatusRelay

type StatusRelay struct {
	ID        RelayID  `json:"id"`
	Hostports []string `json:"hostport"`
	Metadata  string   `json:"metadata"`
}

type Stores

type Stores interface {
	Config() (logc.KV[ConfigKey, ConfigValue], error)

	ClientConns() (logc.KV[ClientConnKey, ClientConnValue], error)
	ClientPeers() (logc.KV[ClientPeerKey, ClientPeerValue], error)

	RelayConns() (logc.KV[RelayConnKey, RelayConnValue], error)
	RelayClients() (logc.KV[RelayClientKey, RelayClientValue], error)
	RelayEndpoints(id RelayID) (logc.KV[RelayEndpointKey, RelayEndpointValue], error)
	RelayServers() (logc.KV[RelayServerKey, RelayServerValue], error)
	RelayServerOffsets() (logc.KV[RelayConnKey, int64], error)
	RelayDirects() (logc.KV[RelayConnKey, RelayDirectValue], error)
}

func NewFileStores

func NewFileStores(dir string) Stores

Jump to

Keyboard shortcuts

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