Documentation ¶
Index ¶
- func MarshalCredential(myKey wgtypes.Key, remoteKey wgtypes.Key, credential *Credential, ...) (*proto.Message, error)
- type Client
- type Credential
- 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) 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 ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
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 GrpcClient ¶ added in v0.3.4
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 ¶ added in v0.3.4
func (c *GrpcClient) Close() error
Close Closes underlying connections to the Signal Exchange
func (*GrpcClient) GetStatus ¶ added in v0.3.4
func (c *GrpcClient) GetStatus() Status
func (*GrpcClient) Ready ¶ added in v0.3.4
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 ¶ added in v0.3.4
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 ¶ added in v0.3.4
func (c *GrpcClient) Send(msg *proto.Message) error
Send sends a message to the remote Peer through the Signal Exchange.
func (*GrpcClient) SendToStream ¶ added in v0.3.4
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) StreamConnected ¶ added in v0.3.4
func (c *GrpcClient) StreamConnected() bool
func (*GrpcClient) WaitStreamConnected ¶ added in v0.3.4
func (c *GrpcClient) WaitStreamConnected()
WaitStreamConnected waits until the client is connected to the Signal stream
type MockClient ¶ added in v0.3.4
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 ¶ added in v0.3.4
func (sm *MockClient) Close() error
func (*MockClient) GetStatus ¶ added in v0.3.4
func (sm *MockClient) GetStatus() Status
func (*MockClient) Ready ¶ added in v0.3.4
func (sm *MockClient) Ready() bool
func (*MockClient) Receive ¶ added in v0.3.4
func (sm *MockClient) Receive(msgHandler func(msg *proto.Message) error) error
func (*MockClient) SendToStream ¶ added in v0.3.4
func (sm *MockClient) SendToStream(msg *proto.EncryptedMessage) error
func (*MockClient) StreamConnected ¶ added in v0.3.4
func (sm *MockClient) StreamConnected() bool
func (*MockClient) WaitStreamConnected ¶ added in v0.3.4
func (sm *MockClient) WaitStreamConnected()