client

package
v0.0.0-...-93fed14 Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2024 License: BSD-3-Clause Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {
	io.Closer
	Sync(msgHandler func(msg *proto.SyncResponse) error) error
	GetServerPublicKey() (*wgtypes.Key, error)
	Register(serverKey wgtypes.Key, setupKey string, jwtToken string, sysInfo *system.Info, sshKey []byte) (*proto.LoginResponse, error)
	Login(serverKey wgtypes.Key, sysInfo *system.Info, sshKey []byte) (*proto.LoginResponse, error)
	GetDeviceAuthorizationFlow(serverKey wgtypes.Key) (*proto.DeviceAuthorizationFlow, error)
	GetPKCEAuthorizationFlow(serverKey wgtypes.Key) (*proto.PKCEAuthorizationFlow, error)
	GetNetworkMap() (*proto.NetworkMap, error)
}

type ConnStateNotifier

type ConnStateNotifier interface {
	MarkManagementDisconnected()
	MarkManagementConnected()
}

ConnStateNotifier is a wrapper interface of the status recorders

type GrpcClient

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

func NewClient

func NewClient(ctx context.Context, addr string, ourPrivateKey wgtypes.Key, tlsEnabled bool) (*GrpcClient, error)

NewClient creates a new client to Management service

func (*GrpcClient) Close

func (c *GrpcClient) Close() error

Close closes connection to the Management Service

func (*GrpcClient) GetDeviceAuthorizationFlow

func (c *GrpcClient) GetDeviceAuthorizationFlow(serverKey wgtypes.Key) (*proto.DeviceAuthorizationFlow, error)

GetDeviceAuthorizationFlow returns a device authorization flow information. It also takes care of encrypting and decrypting messages.

func (*GrpcClient) GetNetworkMap

func (c *GrpcClient) GetNetworkMap() (*proto.NetworkMap, error)

GetNetworkMap return with the network map

func (*GrpcClient) GetPKCEAuthorizationFlow

func (c *GrpcClient) GetPKCEAuthorizationFlow(serverKey wgtypes.Key) (*proto.PKCEAuthorizationFlow, error)

GetPKCEAuthorizationFlow returns a pkce authorization flow information. It also takes care of encrypting and decrypting messages.

func (*GrpcClient) GetServerPublicKey

func (c *GrpcClient) GetServerPublicKey() (*wgtypes.Key, error)

GetServerPublicKey returns server's WireGuard public key (used later for encrypting messages sent to the server)

func (*GrpcClient) Login

func (c *GrpcClient) Login(serverKey wgtypes.Key, sysInfo *system.Info, pubSSHKey []byte) (*proto.LoginResponse, error)

Login attempts login to Management Server. Takes care of encrypting and decrypting messages.

func (*GrpcClient) Register

func (c *GrpcClient) Register(serverKey wgtypes.Key, setupKey string, jwtToken string, sysInfo *system.Info, pubSSHKey []byte) (*proto.LoginResponse, error)

Register registers peer on Management Server. It actually calls a Login endpoint with a provided setup key Takes care of encrypting and decrypting messages. This method will also collect system info and send it with the request (e.g. hostname, os, etc)

func (*GrpcClient) SetConnStateListener

func (c *GrpcClient) SetConnStateListener(notifier ConnStateNotifier)

SetConnStateListener set the ConnStateNotifier

func (*GrpcClient) Sync

func (c *GrpcClient) Sync(msgHandler func(msg *proto.SyncResponse) error) error

Sync wraps the real client's Sync endpoint call and takes care of retries and encryption/decryption of messages Blocking request. The result will be sent via msgHandler callback function

type MockClient

type MockClient struct {
	CloseFunc                      func() error
	SyncFunc                       func(msgHandler func(msg *proto.SyncResponse) error) error
	GetServerPublicKeyFunc         func() (*wgtypes.Key, error)
	RegisterFunc                   func(serverKey wgtypes.Key, setupKey string, jwtToken string, info *system.Info, sshKey []byte) (*proto.LoginResponse, error)
	LoginFunc                      func(serverKey wgtypes.Key, info *system.Info, sshKey []byte) (*proto.LoginResponse, error)
	GetDeviceAuthorizationFlowFunc func(serverKey wgtypes.Key) (*proto.DeviceAuthorizationFlow, error)
	GetPKCEAuthorizationFlowFunc   func(serverKey wgtypes.Key) (*proto.PKCEAuthorizationFlow, error)
}

func (*MockClient) Close

func (m *MockClient) Close() error

func (*MockClient) GetDeviceAuthorizationFlow

func (m *MockClient) GetDeviceAuthorizationFlow(serverKey wgtypes.Key) (*proto.DeviceAuthorizationFlow, error)

func (*MockClient) GetNetworkMap

func (m *MockClient) GetNetworkMap() (*proto.NetworkMap, error)

GetNetworkMap mock implementation of GetNetworkMap from mgm.Client interface

func (*MockClient) GetPKCEAuthorizationFlow

func (m *MockClient) GetPKCEAuthorizationFlow(serverKey wgtypes.Key) (*proto.PKCEAuthorizationFlow, error)

func (*MockClient) GetServerPublicKey

func (m *MockClient) GetServerPublicKey() (*wgtypes.Key, error)

func (*MockClient) Login

func (m *MockClient) Login(serverKey wgtypes.Key, info *system.Info, sshKey []byte) (*proto.LoginResponse, error)

func (*MockClient) Register

func (m *MockClient) Register(serverKey wgtypes.Key, setupKey string, jwtToken string, info *system.Info, sshKey []byte) (*proto.LoginResponse, error)

func (*MockClient) Sync

func (m *MockClient) Sync(msgHandler func(msg *proto.SyncResponse) error) error

Jump to

Keyboard shortcuts

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