control

package
v0.10.1 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2025 License: Apache-2.0 Imports: 33 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 added in v0.7.0

type ClientAuthenticateRequest struct {
	Proto        model.ClientNextProto
	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"`
}

type ClientID added in v0.10.0

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

func NewClientID added in v0.10.0

func NewClientID() ClientID

func (ClientID) MarshalText added in v0.10.0

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

func (*ClientID) UnmarshalText added in v0.10.0

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"`
}

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
}

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 added in v0.8.0

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

type IngressBuilder added in v0.8.0

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

func NewIngressBuilder added in v0.8.0

func NewIngressBuilder() *IngressBuilder

func (*IngressBuilder) Error added in v0.8.0

func (b *IngressBuilder) Error() error

func (*IngressBuilder) Ingress added in v0.8.0

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

func (*IngressBuilder) WithAddr added in v0.8.0

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

func (*IngressBuilder) WithAddrFrom added in v0.8.0

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

func (*IngressBuilder) WithRestr added in v0.8.0

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

func (*IngressBuilder) WithRestrFrom added in v0.8.0

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

func (*IngressBuilder) WithTLS added in v0.8.0

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

func (*IngressBuilder) WithTLSCert added in v0.8.0

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

func (*IngressBuilder) WithTLSCertFrom added in v0.8.0

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

type RelayAuthenticateRequest added in v0.7.0

type RelayAuthenticateRequest struct {
	Proto        model.RelayNextProto
	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"`
	Hostport       model.HostPort      `json:"hostport"`
	Hostports      []model.HostPort    `json:"hostports"`
}

type RelayEndpointKey added in v0.9.0

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

type RelayEndpointValue added in v0.9.0

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

func (RelayEndpointValue) MarshalJSON added in v0.9.0

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

func (*RelayEndpointValue) UnmarshalJSON added in v0.9.0

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

type RelayID added in v0.10.0

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

func NewRelayID added in v0.10.0

func NewRelayID() RelayID

func (RelayID) MarshalText added in v0.10.0

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

func (*RelayID) UnmarshalText added in v0.10.0

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 {
	Hostport  model.HostPort    `json:"hostport"`
	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 added in v0.4.0

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

type Status added in v0.4.0

type Status struct {
	ServerID string         `json:"server_id"`
	Clients  []StatusClient `json:"clients"`
	Peers    []StatusPeer   `json:"peers"`
	Relays   []StatusRelay  `json:"relays"`
}

type StatusClient added in v0.4.0

type StatusClient struct {
	ID   ClientID `json:"id"`
	Addr string   `json:"addr"`
}

type StatusPeer added in v0.4.0

type StatusPeer struct {
	ID       ClientID       `json:"id"`
	Role     model.Role     `json:"role"`
	Endpoint model.Endpoint `json:"endpoint"`
}

type StatusRelay added in v0.4.0

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

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)
}

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