clientcore

package
v0.0.0-...-37b0c19 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2024 License: GPL-3.0 Imports: 25 Imported by: 1

Documentation

Overview

broflake.go defines mid-layer abstractions for constructing and describing a Broflake instance

ipc.go defines structures and functionality for communication between client system components

producer.go defines standard producer behavior over WebRTC, including the discovery process, signaling, connection establishment, connection error detection, and reset. See: https://docs.google.com/spreadsheets/d/1qM1gwPRtTKTFfZZ0e51R7AdS6qkPlKMuJX3D3vmpG_U/edit#gid=471342300

protocol.go provides primitives for defining client protocol behavior

routing.go defines upstream and downstream router components

ui.go defines a standard interface for UI status bindings across build platforms

ui_default_impl.go implements the UI interface (see ui.go) for non-wasm build targets

user.go provides a facility for proxying user-generated bytestreams - ie, streams which originate from a process running on the user's computer (like a web browser) or streams which are generated as part of the user's Lantern control plane activity. We can operationalize a user stream in a WorkerFSM just like we do an RTCPeerConnection or a websocket.Conn, such that bytestreams from the user can be neatly managed alongside bytestreams from remote peers in their consumer table. In other words: we treat the user's web browser just like any connected consumer.

Index

Constants

View Source
const (
	ChunkIPC msgType = iota
	PathAssertionIPC
	ConsumerInfoIPC
	ConnectivityCheckIPC
)
View Source
const (
	NoRoute        = workerID(-1)
	BroadcastRoute = workerID(-2)
)

Variables

This section is empty.

Functions

func CreateHTTPTransport

func CreateHTTPTransport(c ReliableStreamLayer) *http.Transport

func DefaultSTUNBatchFunc

func DefaultSTUNBatchFunc(size uint32) (batch []string, err error)

func DownstreamUIHandler

func DownstreamUIHandler(ui UIImpl, netstated, tag string) func(msg IPCMsg)

func NewBroflake

func NewBroflake(bfOpt *BroflakeOptions, rtcOpt *WebRTCOptions, egOpt *EgressOptions) (bfconn *BroflakeConn, ui *UIImpl, err error)

func NewConsumerRouter

func NewConsumerRouter(bus *ipcChan, table *WorkerTable) *consumerRouter

func NewIpcObserver

func NewIpcObserver(bufferSz int, onTx, onRx func(IPCMsg)) *ipcObserver

func NewProducerPoolRouter

func NewProducerPoolRouter(bus *ipcChan, table *WorkerTable) *producerPoolRouter

func NewProducerSerialRouter

func NewProducerSerialRouter(bus *ipcChan, table *WorkerTable, cTableSize int) *producerSerialRouter

func NewProducerUserStream

func NewProducerUserStream(wg *sync.WaitGroup) (*BroflakeConn, *WorkerFSM)

func UpstreamUIHandler

func UpstreamUIHandler(ui UIImpl, netstated, tag string) func(msg IPCMsg)

Types

type BroflakeConn

type BroflakeConn struct {
	net.PacketConn
	// contains filtered or unexported fields
}

func (BroflakeConn) LocalAddr

func (c BroflakeConn) LocalAddr() net.Addr

func (BroflakeConn) ReadFrom

func (c BroflakeConn) ReadFrom(p []byte) (n int, addr net.Addr, err error)

func (BroflakeConn) SetReadDeadline

func (c BroflakeConn) SetReadDeadline(t time.Time) error

XXX: A note about deadlines: as of quic-go 0.34, the QUIC dialer didn't seem to care about read or write deadlines, and it was happy to use a net.PacketConn which didn't properly implement them. But when we bumped to quic-go 0.40, it emerged that the dialer wouldn't work unless we added support for read deadlines. Since there's still no evidence that the dialer cares about write deadlines, we haven't added support for those yet.

func (BroflakeConn) WriteTo

func (c BroflakeConn) WriteTo(p []byte, addr net.Addr) (n int, err error)

type BroflakeEngine

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

func NewBroflakeEngine

func NewBroflakeEngine(cTable, pTable *WorkerTable, ui UI, wg *sync.WaitGroup, netstated, tag string) *BroflakeEngine

type BroflakeOptions

type BroflakeOptions struct {
	ClientType  string
	CTableSize  int
	PTableSize  int
	BusBufferSz int
	Netstated   string
}

func NewDefaultBroflakeOptions

func NewDefaultBroflakeOptions() *BroflakeOptions

type EgressOptions

type EgressOptions struct {
	Addr           string
	Endpoint       string
	ConnectTimeout time.Duration
	ErrorBackoff   time.Duration
}

func NewDefaultEgressOptions

func NewDefaultEgressOptions() *EgressOptions

type FSMstate

type FSMstate func(ctx context.Context, com *ipcChan, input []interface{}) (int, []interface{})

FSMstate encapsulates logic for one state in a WorkerFSM. An FSMstate must return an int corresponding to the next state and a list of any inputs to propagate to the next state. TODO: a state's number simply corresponds to its index in WorkerFSM.state, but we perform no sanity checking of state indices.

type IPCMsg

type IPCMsg struct {
	IpcType msgType
	Data    interface{}
	Wid     workerID
}

type QUICLayer

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

func NewQUICLayer

func NewQUICLayer(bfconn *BroflakeConn, qopt *QUICLayerOptions) (*QUICLayer, error)

func (*QUICLayer) Close

func (c *QUICLayer) Close()

Close a QUICLayer which was previously opened via a call to DialAndMaintainQUICConnection.

func (*QUICLayer) DialAndMaintainQUICConnection

func (c *QUICLayer) DialAndMaintainQUICConnection()

DialAndMaintainQUICConnection attempts to create and maintain an e2e QUIC connection by dialing the other end, detecting if that connection breaks, and redialing. Forever.

func (*QUICLayer) DialContext

func (c *QUICLayer) DialContext(ctx context.Context) (net.Conn, error)

type QUICLayerOptions

type QUICLayerOptions struct {
	ServerName         string
	InsecureSkipVerify bool
	CA                 *x509.CertPool
}

type ReliableStreamLayer

type ReliableStreamLayer interface {
	DialContext(ctx context.Context) (net.Conn, error)
}

type STUNCache

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

STUNCache implements the operations which support our strategy for evading STUN server blocking in-country. That is: populate the cache with the largest set of currently known STUN servers and shuffle it; select a cohort of the first N servers in the list to use in parallel; if any of those servers work, continue using that cohort; if all of those servers fail, delete the cohort from the list; when the list is empty, repeat the steps.

type TableRouter

type TableRouter interface {
	Init()
	// contains filtered or unexported methods
}

A tableRouter is a multiplexer/demultiplexer which functions as the interface to a WorkerTable, abstracting the complexity of connecting a WorkerTable of arbitrary size to the message bus. An upstream tableRouter, in managing a WorkerTable consisting of workers which handle egress traffic, decides how to best utilize those connections (ie, in serial, in parallel, 1:1, multipath, etc.)

type UI

type UI interface {
	Init(bf *BroflakeEngine)

	Start()

	Stop()

	Debug()

	OnReady()

	OnStartup()

	OnDownstreamChunk(size int, workerIdx int)

	OnDownstreamThroughput(bytesPerSec int)

	OnConsumerConnectionChange(state int, workerIdx int, addr net.IP)
}

type UIImpl

type UIImpl struct {
	UI
	BroflakeEngine *BroflakeEngine
}

func (UIImpl) Debug

func (ui UIImpl) Debug()

func (*UIImpl) Init

func (ui *UIImpl) Init(bf *BroflakeEngine)

func (UIImpl) OnConsumerConnectionChange

func (ui UIImpl) OnConsumerConnectionChange(state int, workerIdx int, addr net.IP)

func (UIImpl) OnDownstreamChunk

func (ui UIImpl) OnDownstreamChunk(size int, workerIdx int)

func (UIImpl) OnDownstreamThroughput

func (ui UIImpl) OnDownstreamThroughput(bytesPerSec int)

func (UIImpl) OnReady

func (ui UIImpl) OnReady()

func (UIImpl) OnStartup

func (ui UIImpl) OnStartup()

func (UIImpl) Start

func (ui UIImpl) Start()

func (UIImpl) Stop

func (ui UIImpl) Stop()

type WebRTCOptions

type WebRTCOptions struct {
	DiscoverySrv   string
	Endpoint       string
	GenesisAddr    string
	NATFailTimeout time.Duration
	ICEFailTimeout time.Duration
	STUNBatch      func(size uint32) (batch []string, err error)
	STUNBatchSize  uint32
	Tag            string
	HttpClient     *http.Client
	Patience       time.Duration
	ErrorBackoff   time.Duration
}

func NewDefaultWebRTCOptions

func NewDefaultWebRTCOptions() *WebRTCOptions

type WorkerFSM

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

WorkerFSM implements a Mealy machine: https://en.wikipedia.org/wiki/Mealy_machine A WorkerFSM independently manages the lifetime of a single connection slot. A client maintains two pools of WorkerFSMs - one for upstream channels and one for downstream channels.

func NewConsumerWebRTC

func NewConsumerWebRTC(options *WebRTCOptions, wg *sync.WaitGroup) *WorkerFSM

func NewEgressConsumerWebSocket

func NewEgressConsumerWebSocket(options *EgressOptions, wg *sync.WaitGroup) *WorkerFSM

func NewProducerWebRTC

func NewProducerWebRTC(options *WebRTCOptions, wg *sync.WaitGroup) *WorkerFSM

func NewWorkerFSM

func NewWorkerFSM(wg *sync.WaitGroup, states []FSMstate) *WorkerFSM

Construct a new WorkerFSM

func (*WorkerFSM) Start

func (fsm *WorkerFSM) Start()

Start this WorkerFSM

func (*WorkerFSM) Stop

func (fsm *WorkerFSM) Stop()

Stop this WorkerFSM (takes effect upon returning from the currently executing state)

type WorkerTable

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

WorkerTable ts the structure we use to represent the producer and consumer tables

func NewWorkerTable

func NewWorkerTable(list []WorkerFSM) *WorkerTable

Construct a new WorkerTable; len(list) corresponds to max concurrent connections for this table. By mixing WorkerFSMs, you can construct a table consisting of connections over different transports.

func (WorkerTable) Size

func (t WorkerTable) Size() int

func (WorkerTable) Start

func (t WorkerTable) Start()

Start all of this table's workers

func (WorkerTable) Stop

func (t WorkerTable) Stop()

Stop all of this table's workers

Jump to

Keyboard shortcuts

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