client

package
v0.27.3 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2024 License: BSD-3-Clause Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DirectCheck indicates support to direct mode checks
	DirectCheck uint32 = 1
)

Variables

This section is empty.

Functions

func MarshalCredential

func MarshalCredential(myKey wgtypes.Key, myPort int, remoteKey wgtypes.Key, credential *Credential, t proto.Body_Type,
	rosenpassPubKey []byte, rosenpassAddr string) (*proto.Message, error)

MarshalCredential marshal a Credential instance and returns a Message object

Types

type Client

type Client interface {
	io.Closer
	StreamConnected() bool
	GetStatus() Status
	Receive(msgHandler func(msg *proto.Message) error) error
	Ready() bool
	IsHealthy() bool
	WaitStreamConnected()
	SendToStream(msg *proto.EncryptedMessage) error
	Send(msg *proto.Message) error
}

type ConnStateNotifier added in v0.14.5

type ConnStateNotifier interface {
	MarkSignalDisconnected(error)
	MarkSignalConnected()
}

ConnStateNotifier is a wrapper interface of the status recorder

type Credential

type Credential struct {
	UFrag string
	Pwd   string
}

Credential is an instance of a GrpcClient's Credential

func UnMarshalCredential

func UnMarshalCredential(msg *proto.Message) (*Credential, error)

UnMarshalCredential parses the credentials from the message and returns a Credential instance

type FeaturesSupport added in v0.14.5

type FeaturesSupport struct {
	DirectCheck bool
}

FeaturesSupport register protocol supported features

func ParseFeaturesSupported added in v0.14.5

func ParseFeaturesSupported(featuresMessage []uint32) FeaturesSupport

ParseFeaturesSupported parses a slice of supported features into FeaturesSupport

type GrpcClient

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

GrpcClient Wraps the Signal Exchange Service gRpc client

func NewClient

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

NewClient creates a new Signal client

func (*GrpcClient) Close

func (c *GrpcClient) Close() error

Close Closes underlying connections to the Signal Exchange

func (*GrpcClient) GetStatus

func (c *GrpcClient) GetStatus() Status

func (*GrpcClient) IsHealthy added in v0.25.5

func (c *GrpcClient) IsHealthy() bool

IsHealthy probes the gRPC connection and returns false on errors

func (*GrpcClient) Ready

func (c *GrpcClient) Ready() bool

Ready indicates whether the client is okay and Ready to be used for now it just checks whether gRPC connection to the service is in state Ready

func (*GrpcClient) Receive

func (c *GrpcClient) Receive(msgHandler func(msg *proto.Message) error) error

Receive Connects to the Signal Exchange message stream and starts receiving messages. The messages will be handled by msgHandler function provided. This function is blocking and reconnects to the Signal Exchange if errors occur (e.g. Exchange restart) The connection retry logic will try to reconnect for 30 min and if wasn't successful will propagate the error to the function caller.

func (*GrpcClient) Send

func (c *GrpcClient) Send(msg *proto.Message) error

Send sends a message to the remote Peer through the Signal Exchange.

func (*GrpcClient) SendToStream

func (c *GrpcClient) SendToStream(msg *proto.EncryptedMessage) error

SendToStream sends a message to the remote Peer through the Signal Exchange using established stream connection to the Signal Server The GrpcClient.Receive method must be called before sending messages to establish initial connection to the Signal Exchange GrpcClient.connWg can be used to wait

func (*GrpcClient) SetConnStateListener added in v0.14.5

func (c *GrpcClient) SetConnStateListener(notifier ConnStateNotifier)

SetConnStateListener set the ConnStateNotifier

func (*GrpcClient) StreamConnected

func (c *GrpcClient) StreamConnected() bool

func (*GrpcClient) WaitStreamConnected

func (c *GrpcClient) WaitStreamConnected()

WaitStreamConnected waits until the client is connected to the Signal stream

type MockClient

type MockClient struct {
	CloseFunc               func() error
	GetStatusFunc           func() Status
	StreamConnectedFunc     func() bool
	ReadyFunc               func() bool
	WaitStreamConnectedFunc func()
	ReceiveFunc             func(msgHandler func(msg *proto.Message) error) error
	SendToStreamFunc        func(msg *proto.EncryptedMessage) error
	SendFunc                func(msg *proto.Message) error
}

func (*MockClient) Close

func (sm *MockClient) Close() error

func (*MockClient) GetStatus

func (sm *MockClient) GetStatus() Status

func (*MockClient) IsHealthy added in v0.25.5

func (sm *MockClient) IsHealthy() bool

func (*MockClient) Ready

func (sm *MockClient) Ready() bool

func (*MockClient) Receive

func (sm *MockClient) Receive(msgHandler func(msg *proto.Message) error) error

func (*MockClient) Send

func (sm *MockClient) Send(msg *proto.Message) error

func (*MockClient) SendToStream

func (sm *MockClient) SendToStream(msg *proto.EncryptedMessage) error

func (*MockClient) StreamConnected

func (sm *MockClient) StreamConnected() bool

func (*MockClient) WaitStreamConnected

func (sm *MockClient) WaitStreamConnected()

type Status

type Status string

Status is the status of the client

const StreamConnected Status = "Connected"
const StreamDisconnected Status = "Disconnected"

Jump to

Keyboard shortcuts

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