Documentation ¶
Overview ¶
Package hello provides the protocol between the client and the server. Ultimately it should be split into two packages, one for peering, one for syncing.
Index ¶
- Variables
- func AesDecrypt(psk []byte, ciphertext []byte) ([]byte, error)
- func AesEncrypt(psk []byte, plaintext []byte) ([]byte, error)
- type AppSource
- type AppStateChangeGenerator
- type IPPool
- type IncomingPairingRequest
- type IncomingSyncRequest
- type KeyPair
- type MetadataEnricher
- type PairingClient
- type PairingClientTransport
- type PairingEncoder
- type PairingRequest
- type PairingRequestClientError
- type PairingRequestServerError
- type PairingRequestWireguardConfig
- type PairingResponse
- type PairingResponseWireguardConfig
- type PairingServer
- type PairingServerTransport
- type PeerInfo
- type PeerStorage
- type ReservedAddressLister
- type SyncClientTransport
- type SyncServerTransport
- type SyncingClient
- type SyncingEncoder
- type SyncingMessage
- type SyncingServer
- type WireguardConfigReloader
Constants ¶
This section is empty.
Variables ¶
var ErrPeerDoesNotExist = errors.New("peer does not exist")
ErrPeerDoesNotExist is returned when a peer does not exist yet
Functions ¶
func AesDecrypt ¶
AesDecrypt decrypts ciphertext using the provided pre-shared key (psk).
Types ¶
type AppSource ¶
AppSource is an interface for listing apps
func NewAddressEnrichingAppSource ¶
NewAddressEnrichingAppSource creates a new AppSource that enriches the apps with the given hostname
func NewInMemoryAppStorage ¶
func NewInMemoryAppStorage() AppSource
NewInMemoryAppStorage creates a new in-memory AppSource instance
func NewPeerEnrichingAppSource ¶
NewPeerEnrichingAppSource creates a new AppSource that enriches the apps with the given peer
type AppStateChangeGenerator ¶
type AppStateChangeGenerator struct {
// contains filtered or unexported fields
}
AppStateChangeGenerator is a generator that listens for changes in the app state and generates events
func NewAppStateChangeGenerator ¶
func NewAppStateChangeGenerator() *AppStateChangeGenerator
NewAppStateChangeGenerator creates a new AppStateChangeGenerator
func (*AppStateChangeGenerator) Changes ¶
func (s *AppStateChangeGenerator) Changes() chan svcdetector.AppStateChange
Changes returns the channel where changes are sent
type IPPool ¶
IPPool is an interface for managing IP addresses
func NewIPPool ¶
func NewIPPool(starting string, reserved ReservedAddressLister) IPPool
NewIPPool creates a new IP pool
type IncomingPairingRequest ¶
IncomingPairingRequest is a request that was received by the server
type IncomingSyncRequest ¶
IncomingSyncRequest is a struct that represents raw incoming sync requests
type MetadataEnricher ¶
MetadataEnricher is an interface that allows transports exchanging information between their client/server implementations
type PairingClient ¶
type PairingClient struct {
// contains filtered or unexported fields
}
PairingClient is a client that can pair with a server
func NewPairingClient ¶
func NewPairingClient( clientName string, wgConfig *wg.Config, keyPair KeyPair, wgReloader WireguardConfigReloader, encoder PairingEncoder, transport PairingClientTransport, ) *PairingClient
NewPairingClient creates a new PairingClient instance
func (*PairingClient) Pair ¶
func (c *PairingClient) Pair() (PairingResponse, error)
Pair sends a pairing request to the server and returns the response
type PairingClientTransport ¶
PairingClientTransport is an interface for sending pairing requests
func NewHTTPClientPairingTransport ¶
func NewHTTPClientPairingTransport(serverURL string) PairingClientTransport
NewHTTPClientPairingTransport creates a new PairingClientTransport instance
func NewPSKClientPairingTransport ¶
func NewPSKClientPairingTransport(psk string, child PairingClientTransport) PairingClientTransport
NewPSKClientPairingTransport creates a new PairingClientTransport, that encrypts and decrypts requests using the provided pre-shared key (psk).
type PairingEncoder ¶
type PairingEncoder interface { EncodeRequest(PairingRequest) ([]byte, error) DecodeRequest([]byte) (PairingRequest, error) EncodeResponse(PairingResponse) ([]byte, error) DecodeResponse([]byte) (PairingResponse, error) }
PairingEncoder is an interface for encoding and decoding pairing requests and responses
func NewJSONPairingEncoder ¶
func NewJSONPairingEncoder() PairingEncoder
NewJSONPairingEncoder creates a new PairingEncoder instance
type PairingRequest ¶
type PairingRequest struct { Name string `json:"name"` // Name of the peer, that requests pairing, // for example `dev1`, `us-east-1`, etc Wireguard PairingRequestWireguardConfig `json:"wireguard"` Metadata map[string]string `json:"metadata"` // Any protocol-specific metadata }
PairingRequest is a request to pair with a server
type PairingRequestClientError ¶
type PairingRequestClientError struct {
Err error
}
PairingRequestClientError is an error that indicate, that it's something wrong with the client
func NewPairingRequestClientError ¶
func NewPairingRequestClientError(err error) PairingRequestClientError
NewPairingRequestClientError creates a new PairingRequestClientError instance
func (PairingRequestClientError) Error ¶
func (e PairingRequestClientError) Error() string
type PairingRequestServerError ¶
type PairingRequestServerError struct {
Err error
}
PairingRequestServerError is an error that indicate, that client request was OK, but server failed
func NewPairingRequestServerError ¶
func NewPairingRequestServerError(err error) PairingRequestServerError
NewPairingRequestServerError creates a new PairingRequestServerError instance
func (PairingRequestServerError) Error ¶
func (e PairingRequestServerError) Error() string
type PairingRequestWireguardConfig ¶
type PairingRequestWireguardConfig struct {
PublicKey string `json:"public_key"`
}
PairingRequestWireguardConfig is a wireguard configuration for the pairing request
type PairingResponse ¶
type PairingResponse struct { Name string `json:"name"` // Name of the server peer AssignedIP string `json:"assigned_ip"` // IP that the server assigned to the peer, // that requested pairing InternalServerIP string `json:"internal_server_ip"` // IP of the server in the internal network Wireguard PairingResponseWireguardConfig `json:"wireguard"` Metadata map[string]string `json:"metadata"` // Any protocol-specific metadata }
PairingResponse is a response to a pairing request
type PairingResponseWireguardConfig ¶
type PairingResponseWireguardConfig struct { PublicKey string `json:"public_key"` Endpoint string `json:"endpoint"` }
PairingResponseWireguardConfig is a wireguard configuration for the pairing response
type PairingServer ¶
type PairingServer struct {
// contains filtered or unexported fields
}
PairingServer is a server that can pair with multiple clients
func NewPairingServer ¶
func NewPairingServer( serverName string, publicWgHostPort string, wgConfig *wg.Config, keyPair KeyPair, wgReloader WireguardConfigReloader, encoder PairingEncoder, transport PairingServerTransport, ips IPPool, storage PeerStorage, enrichers []MetadataEnricher, ) *PairingServer
NewPairingServer creates a new PairingServer instance
type PairingServerTransport ¶
type PairingServerTransport interface {
Requests() <-chan IncomingPairingRequest
}
PairingServerTransport is an interface for receiving pairing requests
func NewHTTPServerPairingTransport ¶
func NewHTTPServerPairingTransport(server *http.Server) PairingServerTransport
NewHTTPServerPairingTransport creates a new PairingServerTransport instance
func NewPSKPairingServerTransport ¶
func NewPSKPairingServerTransport(psk string, child PairingServerTransport) PairingServerTransport
NewPSKPairingServerTransport creates a new PairingServerTransport, that encrypts and decrypts requests using the provided pre-shared key (psk).
type PeerInfo ¶
type PeerInfo struct { Name string `json:"name"` IP string `json:"ip"` PublicKey string `json:"public_key"` }
PeerInfo is a struct that contains information about a peer
type PeerStorage ¶
type PeerStorage interface { Store(PeerInfo) error GetByName(string) (PeerInfo, error) List() ([]PeerInfo, error) DeleteByName(string) error }
PeerStorage is an interface for storing and retrieving peers
func NewBoltPeerStorage ¶
func NewBoltPeerStorage(path string) PeerStorage
NewBoltPeerStorage creates a new BoltDB (persistent, on-disk storage) PeerStorage instance
func NewInMemoryPeerStorage ¶
func NewInMemoryPeerStorage() PeerStorage
NewInMemoryPeerStorage creates a new in-memory PeerStorage instance
type ReservedAddressLister ¶
ReservedAddressLister is an interface for listing reserved addresses
func NewReservedAddressLister ¶
func NewReservedAddressLister(storage PeerStorage) ReservedAddressLister
NewReservedAddressLister creates a new reserved address lister
type SyncClientTransport ¶
SyncClientTransport is an interface for syncing clients transport. Example implementations can be http, grpc, etc.
func NewHTTPClientSyncingTransport ¶
func NewHTTPClientSyncingTransport(serverURL string, timeout time.Duration) SyncClientTransport
NewHTTPClientSyncingTransport creates a new SyncClientTransport instance
type SyncServerTransport ¶
type SyncServerTransport interface { Syncs() <-chan IncomingSyncRequest Metadata() map[string]string }
SyncServerTransport is an interface for syncing servers transport, similar to SyncClientTransport
func NewHTTPServerSyncingTransport ¶
func NewHTTPServerSyncingTransport(server *http.Server) SyncServerTransport
NewHTTPServerSyncingTransport creates a new SyncServerTransport instance
type SyncingClient ¶
type SyncingClient struct {
// contains filtered or unexported fields
}
SyncingClient is a struct that orchestrates all the operations that are performed client-side when executing app list synchronizations
func NewHTTPSyncingClient ¶
func NewHTTPSyncingClient( myName string, nginxAdapter *AppStateChangeGenerator, encoder SyncingEncoder, interval time.Duration, apps AppSource, pr PairingResponse, ) (*SyncingClient, error)
NewHTTPSyncingClient creates a new SyncingClient instance with HTTP transport
func NewSyncingClient ¶
func NewSyncingClient( myName string, nginxAdapter *AppStateChangeGenerator, encoder SyncingEncoder, interval time.Duration, apps AppSource, transport SyncClientTransport, ) *SyncingClient
NewSyncingClient creates a new SyncingClient instance
type SyncingEncoder ¶
type SyncingEncoder interface { Encode(SyncingMessage) ([]byte, error) Decode([]byte) (SyncingMessage, error) }
SyncingEncoder is an interface for encoding and decoding syncing messages
func NewJSONSyncingEncoder ¶
func NewJSONSyncingEncoder() SyncingEncoder
NewJSONSyncingEncoder creates a new SyncingEncoder instance
type SyncingMessage ¶
SyncingMessage is a message that contains a list of apps and the peer that sent them
type SyncingServer ¶
type SyncingServer struct {
// contains filtered or unexported fields
}
SyncingServer orchestrates all the operations that are performed server-side when executing app list synchronizations
func NewSyncingServer ¶
func NewSyncingServer( myName string, stateGenerator *AppStateChangeGenerator, apps AppSource, encoder SyncingEncoder, transport SyncServerTransport, peers PeerStorage, ) *SyncingServer
NewSyncingServer creates a new SyncingServer instance
type WireguardConfigReloader ¶
WireguardConfigReloader is an interface for updating Wireguard configuration