Documentation
¶
Index ¶
- Constants
- func MaxRecvMsgSize() int
- type Client
- type ConnStateNotifier
- type ExposeRequest
- type ExposeResponse
- type GrpcClient
- func (c *GrpcClient) Close() error
- func (c *GrpcClient) CreateExpose(ctx context.Context, req ExposeRequest) (*ExposeResponse, error)
- func (c *GrpcClient) ExtendAuthSession(sysInfo *system.Info, jwtToken string) (*proto.ExtendAuthSessionResponse, error)
- func (c *GrpcClient) GetDeviceAuthorizationFlow() (*proto.DeviceAuthorizationFlow, error)
- func (c *GrpcClient) GetPKCEAuthorizationFlow(sessionExtend bool) (*proto.PKCEAuthorizationFlow, error)
- func (c *GrpcClient) GetServerURL() string
- func (c *GrpcClient) HealthCheck() error
- func (c *GrpcClient) IsHealthy() bool
- func (c *GrpcClient) Job(ctx context.Context, msgHandler func(msg *proto.JobRequest) *proto.JobResponse) error
- func (c *GrpcClient) Login(sysInfo *system.Info, pubSSHKey []byte, dnsLabels domain.List) (*proto.LoginResponse, error)
- func (c *GrpcClient) Logout() error
- func (c *GrpcClient) Register(setupKey string, jwtToken string, sysInfo *system.Info, pubSSHKey []byte, ...) (*proto.LoginResponse, error)
- func (c *GrpcClient) RenewExpose(ctx context.Context, domain string) error
- func (c *GrpcClient) SetConnStateListener(notifier ConnStateNotifier)
- func (c *GrpcClient) StopExpose(ctx context.Context, domain string) error
- func (c *GrpcClient) Sync(ctx context.Context, getInfo func(ctx context.Context) *system.Info, ...) error
- func (c *GrpcClient) SyncMeta(sysInfo *system.Info) error
- type MockClient
- func (m *MockClient) Close() error
- func (m *MockClient) CreateExpose(ctx context.Context, req ExposeRequest) (*ExposeResponse, error)
- func (m *MockClient) ExtendAuthSession(info *system.Info, jwtToken string) (*proto.ExtendAuthSessionResponse, error)
- func (m *MockClient) GetDeviceAuthorizationFlow() (*proto.DeviceAuthorizationFlow, error)
- func (m *MockClient) GetPKCEAuthorizationFlow(sessionExtend bool) (*proto.PKCEAuthorizationFlow, error)
- func (m *MockClient) GetServerURL() string
- func (m *MockClient) HealthCheck() error
- func (m *MockClient) IsHealthy() bool
- func (m *MockClient) Job(ctx context.Context, msgHandler func(msg *proto.JobRequest) *proto.JobResponse) error
- func (m *MockClient) Login(info *system.Info, sshKey []byte, dnsLabels domain.List) (*proto.LoginResponse, error)
- func (m *MockClient) Logout() error
- func (m *MockClient) Register(setupKey string, jwtToken string, info *system.Info, sshKey []byte, ...) (*proto.LoginResponse, error)
- func (m *MockClient) RenewExpose(ctx context.Context, domain string) error
- func (m *MockClient) StopExpose(ctx context.Context, domain string) error
- func (m *MockClient) Sync(ctx context.Context, getInfo func(ctx context.Context) *system.Info, ...) error
- func (m *MockClient) SyncMeta(sysInfo *system.Info) error
- type Option
Constants ¶
const ConnectTimeout = 10 * time.Second
const ( // EnvMaxRecvMsgSize overrides the default gRPC max receive message size // for the management client connection. Value is in bytes. EnvMaxRecvMsgSize = "NB_MANAGEMENT_GRPC_MAX_MSG_SIZE" )
Variables ¶
This section is empty.
Functions ¶
func MaxRecvMsgSize ¶ added in v0.67.0
func MaxRecvMsgSize() int
MaxRecvMsgSize returns the configured max gRPC receive message size from the environment, or defaultMaxRecvMsgSize (16 MB) if unset or invalid.
Types ¶
type Client ¶
type Client interface {
io.Closer
Sync(ctx context.Context, getInfo func(ctx context.Context) *system.Info, msgHandler func(msg *proto.SyncResponse) error) error
Job(ctx context.Context, msgHandler func(msg *proto.JobRequest) *proto.JobResponse) error
Register(setupKey string, jwtToken string, sysInfo *system.Info, sshKey []byte, dnsLabels domain.List) (*proto.LoginResponse, error)
Login(sysInfo *system.Info, sshKey []byte, dnsLabels domain.List) (*proto.LoginResponse, error)
// ExtendAuthSession refreshes the peer's SSO session deadline using a fresh JWT.
// Returns the new absolute deadline; zero time when the server reports the peer
// is not eligible for session extension.
ExtendAuthSession(sysInfo *system.Info, jwtToken string) (*proto.ExtendAuthSessionResponse, error)
GetDeviceAuthorizationFlow() (*proto.DeviceAuthorizationFlow, error)
// GetPKCEAuthorizationFlow returns the PKCE authorization flow information.
//
// sessionExtend marks the flow as renewing an existing peer's session rather
// than logging one in. See PKCEAuthorizationFlowRequest.
GetPKCEAuthorizationFlow(sessionExtend bool) (*proto.PKCEAuthorizationFlow, error)
GetServerURL() string
// IsHealthy returns the current connection status without blocking.
// Used by the engine to monitor connectivity in the background.
IsHealthy() bool
// HealthCheck actively probes the management server and returns an error if unreachable.
// Used to validate connectivity before committing configuration changes.
HealthCheck() error
SyncMeta(sysInfo *system.Info) error
Logout() error
CreateExpose(ctx context.Context, req ExposeRequest) (*ExposeResponse, error)
RenewExpose(ctx context.Context, domain string) error
StopExpose(ctx context.Context, domain string) error
}
Client is the interface for the management service client.
type ConnStateNotifier ¶
type ConnStateNotifier interface {
MarkManagementDisconnected(error)
MarkManagementConnected()
}
ConnStateNotifier is a wrapper interface of the status recorders
type ExposeRequest ¶ added in v0.66.0
type ExposeResponse ¶ added in v0.66.0
type GrpcClient ¶
type GrpcClient struct {
// contains filtered or unexported fields
}
func NewClient ¶
func NewClient(ctx context.Context, addr string, ourPrivateKey wgtypes.Key, tlsEnabled bool, opts ...Option) (*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) CreateExpose ¶ added in v0.66.0
func (c *GrpcClient) CreateExpose(ctx context.Context, req ExposeRequest) (*ExposeResponse, error)
CreateExpose calls the management server to create a new expose service.
func (*GrpcClient) ExtendAuthSession ¶ added in v0.72.0
func (c *GrpcClient) ExtendAuthSession(sysInfo *system.Info, jwtToken string) (*proto.ExtendAuthSessionResponse, error)
ExtendAuthSession refreshes the peer's SSO session deadline on the management server using a freshly issued JWT. The tunnel is untouched: no network map sync, no peer reconnect. Returns the new absolute UTC deadline (zero time when the server reports the field empty).
func (*GrpcClient) GetDeviceAuthorizationFlow ¶
func (c *GrpcClient) GetDeviceAuthorizationFlow() (*proto.DeviceAuthorizationFlow, error)
GetDeviceAuthorizationFlow returns a device authorization flow information. It also takes care of encrypting and decrypting messages.
func (*GrpcClient) GetPKCEAuthorizationFlow ¶
func (c *GrpcClient) GetPKCEAuthorizationFlow(sessionExtend bool) (*proto.PKCEAuthorizationFlow, error)
GetPKCEAuthorizationFlow returns the PKCE authorization flow information. It also takes care of encrypting and decrypting messages.
sessionExtend tells the server the flow will renew an existing peer's session rather than log one in, so it can rule out a configuration that would let the IdP answer from an unrelated account. See PKCEAuthorizationFlowRequest.
func (*GrpcClient) GetServerURL ¶ added in v0.67.0
func (c *GrpcClient) GetServerURL() string
GetServerURL returns the management server URL
func (*GrpcClient) HealthCheck ¶ added in v0.68.0
func (c *GrpcClient) HealthCheck() error
HealthCheck actively probes the management server and returns an error if unreachable. Used to validate connectivity before committing configuration changes.
func (*GrpcClient) IsHealthy ¶
func (c *GrpcClient) IsHealthy() bool
IsHealthy returns the current connection status without blocking. Used by the engine to monitor connectivity in the background.
func (*GrpcClient) Job ¶ added in v0.64.0
func (c *GrpcClient) Job(ctx context.Context, msgHandler func(msg *proto.JobRequest) *proto.JobResponse) error
Job wraps the real client's Job endpoint call and takes care of retries and encryption/decryption of messages Blocking request. The result will be sent via msgHandler callback function
func (*GrpcClient) Login ¶
func (c *GrpcClient) Login(sysInfo *system.Info, pubSSHKey []byte, dnsLabels domain.List) (*proto.LoginResponse, error)
Login attempts login to Management Server. Takes care of encrypting and decrypting messages.
func (*GrpcClient) Logout ¶
func (c *GrpcClient) Logout() error
func (*GrpcClient) Register ¶
func (c *GrpcClient) Register(setupKey string, jwtToken string, sysInfo *system.Info, pubSSHKey []byte, dnsLabels domain.List) (*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) RenewExpose ¶ added in v0.66.0
func (c *GrpcClient) RenewExpose(ctx context.Context, domain string) error
RenewExpose extends the TTL of an active expose session on the management server.
func (*GrpcClient) SetConnStateListener ¶
func (c *GrpcClient) SetConnStateListener(notifier ConnStateNotifier)
SetConnStateListener set the ConnStateNotifier
func (*GrpcClient) StopExpose ¶ added in v0.66.0
func (c *GrpcClient) StopExpose(ctx context.Context, domain string) error
StopExpose terminates an active expose session on the management server.
func (*GrpcClient) Sync ¶
func (c *GrpcClient) Sync(ctx context.Context, getInfo func(ctx context.Context) *system.Info, 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(ctx context.Context, getInfo func(ctx context.Context) *system.Info, msgHandler func(msg *proto.SyncResponse) error) error
RegisterFunc func(setupKey string, jwtToken string, info *system.Info, sshKey []byte, dnsLabels domain.List) (*proto.LoginResponse, error)
LoginFunc func(info *system.Info, sshKey []byte, dnsLabels domain.List) (*proto.LoginResponse, error)
ExtendAuthSessionFunc func(info *system.Info, jwtToken string) (*proto.ExtendAuthSessionResponse, error)
GetDeviceAuthorizationFlowFunc func() (*proto.DeviceAuthorizationFlow, error)
GetPKCEAuthorizationFlowFunc func(sessionExtend bool) (*proto.PKCEAuthorizationFlow, error)
GetServerURLFunc func() string
HealthCheckFunc func() error
SyncMetaFunc func(sysInfo *system.Info) error
LogoutFunc func() error
JobFunc func(ctx context.Context, msgHandler func(msg *proto.JobRequest) *proto.JobResponse) error
CreateExposeFunc func(ctx context.Context, req ExposeRequest) (*ExposeResponse, error)
RenewExposeFunc func(ctx context.Context, domain string) error
StopExposeFunc func(ctx context.Context, domain string) error
}
MockClient is a mock implementation of the Client interface for testing.
func (*MockClient) Close ¶
func (m *MockClient) Close() error
func (*MockClient) CreateExpose ¶ added in v0.66.0
func (m *MockClient) CreateExpose(ctx context.Context, req ExposeRequest) (*ExposeResponse, error)
func (*MockClient) ExtendAuthSession ¶ added in v0.72.0
func (m *MockClient) ExtendAuthSession(info *system.Info, jwtToken string) (*proto.ExtendAuthSessionResponse, error)
func (*MockClient) GetDeviceAuthorizationFlow ¶
func (m *MockClient) GetDeviceAuthorizationFlow() (*proto.DeviceAuthorizationFlow, error)
func (*MockClient) GetPKCEAuthorizationFlow ¶
func (m *MockClient) GetPKCEAuthorizationFlow(sessionExtend bool) (*proto.PKCEAuthorizationFlow, error)
GetPKCEAuthorizationFlow returns the PKCE authorization flow information.
func (*MockClient) GetServerURL ¶ added in v0.67.0
func (m *MockClient) GetServerURL() string
GetServerURL mock implementation of GetServerURL from mgm.Client interface
func (*MockClient) HealthCheck ¶ added in v0.68.0
func (m *MockClient) HealthCheck() error
func (*MockClient) IsHealthy ¶
func (m *MockClient) IsHealthy() bool
func (*MockClient) Job ¶ added in v0.64.0
func (m *MockClient) Job(ctx context.Context, msgHandler func(msg *proto.JobRequest) *proto.JobResponse) error
func (*MockClient) Login ¶
func (m *MockClient) Login(info *system.Info, sshKey []byte, dnsLabels domain.List) (*proto.LoginResponse, error)
func (*MockClient) Logout ¶
func (m *MockClient) Logout() error
func (*MockClient) RenewExpose ¶ added in v0.66.0
func (m *MockClient) RenewExpose(ctx context.Context, domain string) error
func (*MockClient) StopExpose ¶ added in v0.66.0
func (m *MockClient) StopExpose(ctx context.Context, domain string) error
type Option ¶ added in v0.77.1
type Option func(*GrpcClient)
Option configures optional GrpcClient behavior.
func WithNetEvents ¶ added in v0.78.0
WithNetEvents injects the OS network event handling.