connect

package
v4.7.4 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2024 License: BSD-2-Clause, BSD-2-Clause Imports: 27 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var File_authenticated_proto protoreflect.FileDescriptor

Functions

func TestSignVerify_Consistency added in v4.5.0

func TestSignVerify_Consistency(t *testing.T)

TestSignVerify_Consistency DOES NOT PERFORM A PROPER CONSISTENCY TEST WHEN COMPILED FOR WASM. This test currently only confirms that the formed signature can be verified when running in js/wasm.

Types

type AuthenticatedCallback

type AuthenticatedCallback func(connection AuthenticatedConnection)

AuthenticatedCallback is the callback format required to retrieve new AuthenticatedConnection objects as they are established.

type AuthenticatedConnection

type AuthenticatedConnection interface {
	// Connection is the base Connect API. This allows
	// sending and listening to the partner
	Connection

	// IsAuthenticated is a function which returns whether the
	// authenticated connection has been completely established.
	IsAuthenticated() bool
}

AuthenticatedConnection is a connect.Connection interface that has the receiver authenticating their identity back to the initiator.

func ConnectWithAuthentication

func ConnectWithAuthentication(recipient contact.Contact, user *xxdk.E2e,
	p xxdk.E2EParams) (AuthenticatedConnection, error)

ConnectWithAuthentication is called by the client, ie the one establishing connection with the server. Once a connect.Connection has been established with the server and then authenticate their identity to the server.

type Callback

type Callback func(connection Connection)

Callback is the callback format required to retrieve new Connection objects as they are established.

type Connection

type Connection interface {
	// Closer deletes this Connection's partner.Manager and releases resources
	io.Closer

	// GetPartner returns the partner.Manager for this Connection
	GetPartner() partner.Manager

	// SendE2E is a wrapper for sending specifically to the Connection's
	// partner.Manager
	SendE2E(mt catalog.MessageType, payload []byte, params clientE2e.Params) (
		cryptoE2e.SendReport, error)

	// RegisterListener is used for E2E reception
	// and allows for reading data sent from the partner.Manager
	RegisterListener(messageType catalog.MessageType,
		newListener receive.Listener) (receive.ListenerID, error)
	// Unregister listener for E2E reception
	Unregister(listenerID receive.ListenerID)

	// FirstPartitionSize returns the max partition payload size for the
	// first payload
	FirstPartitionSize() uint

	// SecondPartitionSize returns the max partition payload size for all
	// payloads after the first payload
	SecondPartitionSize() uint

	// PartitionSize returns the partition payload size for the given
	// payload index. The first payload is index 0.
	PartitionSize(payloadIndex uint) uint

	// PayloadSize Returns the max payload size for a partitionable E2E
	// message
	PayloadSize() uint

	// LastUse returns the timestamp of the last time the connection was
	// utilised.
	LastUse() time.Time
}

Connection is a wrapper for the E2E and auth packages. It can be used to automatically establish an E2E partnership with a partner.Manager, or be built from an existing E2E partnership. You can then use this interface to send to and receive from the newly-established partner.Manager.

func BuildConnection

func BuildConnection(partner partner.Manager, e2eHandler clientE2e.Handler,
	auth auth.State, p xxdk.E2EParams) Connection

BuildConnection assembles a Connection object after an E2E partnership has already been confirmed with the given partner.Manager.

func Connect

func Connect(recipient contact.Contact, user *xxdk.E2e,
	p xxdk.E2EParams) (Connection, error)

Connect performs auth key negotiation with the given recipient, and returns a Connection object for the newly-created partner.Manager This function is to be used sender-side and will block until the partner.Manager is confirmed.

type ConnectionList

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

ConnectionList is a list of all connections.

func NewConnectionList

func NewConnectionList(p ConnectionListParams) *ConnectionList

NewConnectionList initialises an empty ConnectionList.

func (*ConnectionList) Add

func (cl *ConnectionList) Add(c Connection)

Add adds the connection to the list.

func (*ConnectionList) Cleanup

func (cl *ConnectionList) Cleanup()

Cleanup disconnects all connections that have been stale for longer than the max allowed time.

func (*ConnectionList) CleanupThread

func (cl *ConnectionList) CleanupThread() (stoppable.Stoppable, error)

CleanupThread runs the loop that runs the cleanup processes periodically.

type ConnectionListParams

type ConnectionListParams struct {
	// CleanupPeriod is the duration between when cleanups occur.
	CleanupPeriod time.Duration

	// MaxAge is the maximum age of an unused connection before it is deleted.
	MaxAge time.Duration
}

ConnectionListParams are the parameters used for the ConnectionList.

func DefaultConnectionListParams

func DefaultConnectionListParams() ConnectionListParams

DefaultConnectionListParams returns a ConnectionListParams filled with default values.

type ConnectionServer

type ConnectionServer struct {
	User *xxdk.E2e
	Cl   *ConnectionList
}

ConnectionServer contains

func StartAuthenticatedServer

func StartAuthenticatedServer(identity xxdk.ReceptionIdentity,
	authCb AuthenticatedCallback, net *xxdk.Cmix, p xxdk.E2EParams,
	clParams ConnectionListParams) (
	*ConnectionServer, error)

StartAuthenticatedServer is called by the receiver of an authenticated connection request. Calling this will indicate that they will handle authenticated requests and verify the client's attempt to authenticate themselves. An established AuthenticatedConnection will be passed via the callback.

func StartServer

func StartServer(identity xxdk.ReceptionIdentity, connectionCallback Callback,
	net *xxdk.Cmix, params xxdk.E2EParams, clParams ConnectionListParams) (*ConnectionServer, error)

StartServer assembles a Connection object on the reception-side and feeds it into the given Callback whenever an incoming request for an E2E partnership with a partner.Manager is confirmed.

It is recommended that this be called before StartNetworkFollower to ensure no requests are missed.

This calls xxdk.LoginEphemeral under the hood and the connection server must be the only listener on auth.

type IdentityAuthentication

type IdentityAuthentication struct {
	Signature []byte `protobuf:"bytes,1,opt,name=Signature,proto3" json:"Signature,omitempty"` // Signature of the connection fingerprint
	// established between the two partners
	RsaPubKey []byte `protobuf:"bytes,2,opt,name=RsaPubKey,proto3" json:"RsaPubKey,omitempty"` // The RSA public key of the sender of this message,
	// PEM-encoded
	Salt []byte `protobuf:"bytes,3,opt,name=Salt,proto3" json:"Salt,omitempty"` // Salt used to generate the network ID of the client
	// contains filtered or unexported fields
}

Sent by the receiver of the authenticated connection request.

func (*IdentityAuthentication) Descriptor deprecated

func (*IdentityAuthentication) Descriptor() ([]byte, []int)

Deprecated: Use IdentityAuthentication.ProtoReflect.Descriptor instead.

func (*IdentityAuthentication) GetRsaPubKey

func (x *IdentityAuthentication) GetRsaPubKey() []byte

func (*IdentityAuthentication) GetSalt

func (x *IdentityAuthentication) GetSalt() []byte

func (*IdentityAuthentication) GetSignature

func (x *IdentityAuthentication) GetSignature() []byte

func (*IdentityAuthentication) ProtoMessage

func (*IdentityAuthentication) ProtoMessage()

func (*IdentityAuthentication) ProtoReflect

func (x *IdentityAuthentication) ProtoReflect() protoreflect.Message

func (*IdentityAuthentication) Reset

func (x *IdentityAuthentication) Reset()

func (*IdentityAuthentication) String

func (x *IdentityAuthentication) String() string

Jump to

Keyboard shortcuts

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