connections

package
v0.29.3 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2024 License: MIT Imports: 26 Imported by: 5

Documentation

Index

Constants

View Source
const TorMaxPendingConns = 28

32 from tor/src/app/config/config.c MaxClientCircuitsPending we lower a bit because there's a lot of spillage - just cus we get a SOCKS timeout doesn't mean tor has stopped trying as a huge sorce - potential multiple profiles as a huge source - second order connections like token service's second servers aren't tracked in our system adding a few extra periodically

View Source
const Version1 = 0x01
View Source
const Version2 = 0x02

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 MakePayment added in v0.18.4

func MakePayment(tokenServiceOnion string, tokenService *privacypass.TokenServer, acn connectivity.ACN, handler TokenBoardHandler) error

MakePayment uses the PoW based token protocol to obtain more tokens

func NewTokenBoardClient added in v0.4.0

func NewTokenBoardClient(acn connectivity.ACN, Y *ristretto255.Element, tokenServiceOnion string, lastKnownSignature []byte, tokenBoardHandler TokenBoardHandler) 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 DefaultEngineHooks added in v0.20.1

type DefaultEngineHooks struct {
}

func (DefaultEngineHooks) SendPeerMessage added in v0.20.1

func (deh DefaultEngineHooks) SendPeerMessage(connection tapir.Connection, message []byte) error

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, engineHooks EngineHooks) Engine

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

type EngineHooks added in v0.20.1

type EngineHooks interface {
	SendPeerMessage(connection tapir.Connection, message []byte) error
}

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)
	OnSendMessage     func(connection tapir.Connection, message []byte) error
	// 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) 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(group string, 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.

type TokenBoardHandler added in v0.17.3

type TokenBoardHandler interface {
	GroupMessageHandler(server string, gm *groups.EncryptedGroupMessage)
	ServerAuthedHandler(server string)
	ServerSyncedHandler(server string)
	ServerClosedHandler(server string)
	NewTokenHandler(tokenService string, tokens []*privacypass.Token)
	PostingFailed(server string, sig []byte)
	FetchToken(tokenService string) (*privacypass.Token, int, error)
}

TokenBoardHandler encapsulates all the various handlers a client needs to interact with a token board this includes handlers to receive new messages, as well as handlers to manage tokens.

type TokenManager added in v0.17.3

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

TokenManager maintains a list of tokens associated with a single TokenServer

func NewTokenManager added in v0.18.4

func NewTokenManager() *TokenManager

func (*TokenManager) FetchToken added in v0.17.3

func (tm *TokenManager) FetchToken() (*privacypass.Token, int, error)

FetchToken removes a token from the internal list and returns it, along with a count of the remaining tokens. Errors if no tokens available.

func (*TokenManager) NumTokens added in v0.17.3

func (tm *TokenManager) NumTokens() int

NumTokens returns the current number of tokens

func (*TokenManager) StoreNewTokens added in v0.18.4

func (tm *TokenManager) StoreNewTokens(tokens []*privacypass.Token)

StoreNewTokens adds tokens to the internal list managed by this TokenManager

Jump to

Keyboard shortcuts

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