connections

package
v0.14.14 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2022 License: MIT Imports: 23 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ConnectionStateName allows conversion of states to their string representations
	ConnectionStateName = []string{"Disconnected", "Connecting", "Connected", "Authenticated", "Synced", "Failed", "Killed"}
)

Functions

func ConnectionStateToType

func ConnectionStateToType() map[string]ConnectionState

ConnectionStateToType allows conversion of strings to their state type

func NewTokenBoardClient added in v0.4.0

func NewTokenBoardClient(acn connectivity.ACN, Y *ristretto255.Element, tokenServiceOnion string, lastKnownSignature []byte, groupMessageHandler func(server string, gm *groups.EncryptedGroupMessage), serverAuthedHandler func(server string), serverSyncedHandler func(server string), serverClosedHandler func(server string)) tapir.Application

NewTokenBoardClient generates a new Client for Token Board

Types

type ConnectionState

type ConnectionState int

ConnectionState defines the various states a connection can be in from disconnected to authenticated

const (
	DISCONNECTED ConnectionState = iota
	CONNECTING
	CONNECTED
	AUTHENTICATED
	SYNCED
	FAILED
	KILLED
)

Connection States DISCONNECTED - No existing connection has been made, or all attempts have failed CONNECTING - We are in the process of attempting to connect to a given endpoint CONNECTED - We have connected but not yet authenticated AUTHENTICATED - im.ricochet.auth-hidden-server has succeeded on the connection. SYNCED - we have pulled all the messages for groups from the server and are ready to send

type Engine

type Engine interface {
	ACN() connectivity.ACN
	EventManager() event.Manager
	Shutdown()
}

Engine (ProtocolEngine) encapsulates the logic necessary to make and receive Cwtch connections. Note: ProtocolEngine doesn't have access to any information necessary to encrypt or decrypt GroupMessages Protocol Engine *can* associate Group Identifiers with Group Servers, although we don't currently make use of this fact other than to route errors back to the UI.

func NewProtocolEngine

func NewProtocolEngine(identity primitives.Identity, privateKey ed25519.PrivateKey, acn connectivity.ACN, eventManager event.Manager, peerAuthorizations map[string]model.Authorization) Engine

NewProtocolEngine initializes a new engine that runs Cwtch using the given parameters

type PeerApp

type PeerApp struct {
	applications.AuthApp

	MessageHandler    func(string, string, string, []byte)
	IsBlocked         func(string) bool
	IsAllowed         func(string) bool
	OnAcknowledgement func(string, string)
	OnAuth            func(string)
	OnClose           func(string)
	OnConnecting      func(string)
	// contains filtered or unexported fields
}

PeerApp encapsulates the behaviour of a Cwtch Peer

func (*PeerApp) Init

func (pa *PeerApp) Init(connection tapir.Connection)

Init is run when the connection is first started.

func (*PeerApp) NewInstance

func (pa *PeerApp) NewInstance() tapir.Application

NewInstance should always return a new instantiation of the application.

func (*PeerApp) SendMessage

func (pa *PeerApp) SendMessage(message model2.PeerMessage) error

SendMessage sends the peer a preformatted message NOTE: This is a stub, we will likely want to extend this to better reflect the desired protocol

type TokenBoardClient added in v0.4.0

type TokenBoardClient struct {
	applications.AuthApp
	// contains filtered or unexported fields
}

TokenBoardClient defines a client for the TokenBoard server

func (*TokenBoardClient) Init added in v0.4.0

func (ta *TokenBoardClient) Init(connection tapir.Connection)

Init initializes the cryptographic TokenBoardApp

func (*TokenBoardClient) Listen added in v0.4.0

func (ta *TokenBoardClient) Listen()

Listen processes the messages for this application

func (*TokenBoardClient) MakePayment added in v0.4.0

func (ta *TokenBoardClient) MakePayment() error

MakePayment uses the PoW based token protocol to obtain more tokens

func (*TokenBoardClient) NewInstance added in v0.4.0

func (ta *TokenBoardClient) NewInstance() tapir.Application

NewInstance Client a new TokenBoardApp

func (*TokenBoardClient) NextToken added in v0.4.0

func (ta *TokenBoardClient) NextToken(data []byte, hostname string) (privacypass.SpentToken, int, error)

NextToken retrieves the next token

func (*TokenBoardClient) Post added in v0.4.0

func (ta *TokenBoardClient) Post(ct []byte, sig []byte) (bool, int)

Post sends a Post Request to the server

func (*TokenBoardClient) PurchaseTokens added in v0.4.0

func (ta *TokenBoardClient) PurchaseTokens()

PurchaseTokens purchases the given number of tokens from the server (using the provided payment handler)

func (*TokenBoardClient) Replay added in v0.4.0

func (ta *TokenBoardClient) Replay()

Replay posts a Replay Message to the server.

Jump to

Keyboard shortcuts

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