Documentation ¶
Index ¶
- Variables
- func ConnectionStateToType() map[string]ConnectionState
- func NewTokenBoardClient(acn connectivity.ACN, Y *ristretto255.Element, tokenServiceOnion string, ...) tapir.Application
- type ConnectionState
- type Engine
- type PeerApp
- type PeerMessage
- type TokenBoardClient
- func (ta *TokenBoardClient) Init(connection tapir.Connection)
- func (ta *TokenBoardClient) Listen()
- func (ta *TokenBoardClient) MakePayment() error
- func (ta *TokenBoardClient) NewInstance() tapir.Application
- func (ta *TokenBoardClient) NextToken(data []byte, hostname string) (privacypass.SpentToken, int, error)
- func (ta *TokenBoardClient) Post(ct []byte, sig []byte) (bool, int)
- func (ta *TokenBoardClient) PurchaseTokens()
- func (ta *TokenBoardClient) Replay()
Constants ¶
This section is empty.
Variables ¶
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), 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) RetValHandler func(string, []byte, []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 PeerMessage)
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 PeerMessage ¶
type PeerMessage struct { ID string // A unique Message ID (primarily used for acknowledgments) Context string // A unique context identifier i.e. im.cwtch.chat Data []byte // The serialized data packet. }
PeerMessage is an encapsulation that can be used by higher level applications
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.