Documentation ¶
Index ¶
- Constants
- func MarshalCredential(myKey wgtypes.Key, myPort int, remoteKey wgtypes.Key, credential *Credential, ...) (*proto.Message, error)
- type Client
- type ConnStateNotifier
- type Credential
- type FeaturesSupport
- type GrpcClient
- func (c *GrpcClient) Close() error
- func (c *GrpcClient) GetStatus() Status
- func (c *GrpcClient) Ready() bool
- func (c *GrpcClient) Receive(msgHandler func(msg *proto.Message) error) error
- func (c *GrpcClient) Send(msg *proto.Message) error
- func (c *GrpcClient) SendToStream(msg *proto.EncryptedMessage) error
- func (c *GrpcClient) SetConnStateListener(notifier ConnStateNotifier)
- func (c *GrpcClient) StreamConnected() bool
- func (c *GrpcClient) WaitStreamConnected()
- type MockClient
- func (sm *MockClient) Close() error
- func (sm *MockClient) GetStatus() Status
- func (sm *MockClient) Ready() bool
- func (sm *MockClient) Receive(msgHandler func(msg *proto.Message) error) error
- func (sm *MockClient) Send(msg *proto.Message) error
- func (sm *MockClient) SendToStream(msg *proto.EncryptedMessage) error
- func (sm *MockClient) StreamConnected() bool
- func (sm *MockClient) WaitStreamConnected()
- type Status
Constants ¶
const ( // DirectCheck indicates support to direct mode checks DirectCheck uint32 = 1 )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ConnStateNotifier ¶ added in v0.14.5
type ConnStateNotifier interface { MarkSignalDisconnected() MarkSignalConnected() }
ConnStateNotifier is a wrapper interface of the status recorder
type Credential ¶
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) 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) Ready ¶
func (sm *MockClient) Ready() bool
func (*MockClient) Receive ¶
func (sm *MockClient) Receive(msgHandler func(msg *proto.Message) error) 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()