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
- func CreateHTTPTransport(c ReliableStreamLayer) *http.Transport
- func DefaultSTUNBatchFunc(size uint32) (batch []string, err error)
- func DownstreamUIHandler(ui UIImpl, netstated, tag string) func(msg IPCMsg)
- func NewBroflake(bfOpt *BroflakeOptions, rtcOpt *WebRTCOptions, egOpt *EgressOptions) (bfconn *BroflakeConn, ui *UIImpl, err error)
- func NewConsumerRouter(bus *ipcChan, table *WorkerTable) *consumerRouter
- func NewIpcObserver(bufferSz int, onTx, onRx func(IPCMsg)) *ipcObserver
- func NewProducerJITRouter(bus *ipcChan, table *WorkerTable) *producerJITRouter
- func NewProducerPoolRouter(bus *ipcChan, table *WorkerTable) *producerPoolRouter
- func NewProducerSerialRouter(bus *ipcChan, table *WorkerTable, cTableSize int) *producerSerialRouter
- func NewProducerUserStream(wg *sync.WaitGroup) (*BroflakeConn, *WorkerFSM)
- func UpstreamUIHandler(ui UIImpl, netstated, tag string) func(msg IPCMsg)
- type BroflakeConn
- func (c BroflakeConn) Close() error
- func (c BroflakeConn) LocalAddr() net.Addr
- func (c BroflakeConn) ReadFrom(p []byte) (n int, addr net.Addr, err error)
- func (c BroflakeConn) SetDeadline(t time.Time) error
- func (c BroflakeConn) SetReadDeadline(t time.Time) error
- func (c BroflakeConn) SetWriteDeadline(t time.Time) error
- func (c BroflakeConn) WriteTo(p []byte, addr net.Addr) (n int, err error)
- type BroflakeEngine
- type BroflakeOptions
- type EgressOptions
- type FSMstate
- type IPCMsg
- type QUICLayer
- type ReliableStreamLayer
- type SOCKS5Dialer
- type STUNCache
- type TableRouter
- type UI
- type UIImpl
- func (ui UIImpl) Debug()
- func (ui *UIImpl) Init(bf *BroflakeEngine)
- func (ui UIImpl) OnConsumerConnectionChange(state int, workerIdx int, addr net.IP)
- func (ui UIImpl) OnDownstreamChunk(size int, workerIdx int)
- func (ui UIImpl) OnDownstreamThroughput(bytesPerSec int)
- func (ui UIImpl) OnReady()
- func (ui UIImpl) OnStartup()
- func (ui UIImpl) Start()
- func (ui UIImpl) Stop()
- type WebRTCOptions
- type WorkerFSM
- func NewConsumerWebRTC(options *WebRTCOptions, wg *sync.WaitGroup) *WorkerFSM
- func NewEgressConsumerWebSocket(options *EgressOptions, wg *sync.WaitGroup) *WorkerFSM
- func NewJITEgressConsumer(options *EgressOptions, wg *sync.WaitGroup) *WorkerFSM
- func NewProducerWebRTC(options *WebRTCOptions, wg *sync.WaitGroup) *WorkerFSM
- func NewWorkerFSM(wg *sync.WaitGroup, states []FSMstate) *WorkerFSM
- type WorkerTable
Constants ¶
const ( ChunkIPC msgType = iota PathAssertionIPC ConsumerInfoIPC ConnectivityCheckIPC )
const ( NoRoute = workerID(-1) BroadcastRoute = workerID(-2) )
Variables ¶
This section is empty.
Functions ¶
func CreateHTTPTransport ¶
func CreateHTTPTransport(c ReliableStreamLayer) *http.Transport
func DefaultSTUNBatchFunc ¶
func DownstreamUIHandler ¶
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 NewProducerJITRouter ¶
func NewProducerJITRouter(bus *ipcChan, table *WorkerTable) *producerJITRouter
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 ¶
Types ¶
type BroflakeConn ¶
type BroflakeConn struct {
// contains filtered or unexported fields
}
func (BroflakeConn) Close ¶
func (c BroflakeConn) Close() error
func (BroflakeConn) LocalAddr ¶
func (c BroflakeConn) LocalAddr() net.Addr
func (BroflakeConn) SetDeadline ¶
func (c BroflakeConn) SetDeadline(t time.Time) 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) SetWriteDeadline ¶
func (c BroflakeConn) SetWriteDeadline(t time.Time) 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 ¶
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 QUICLayer ¶
type QUICLayer struct {
// contains filtered or unexported fields
}
func NewQUICLayer ¶
func NewQUICLayer(bfconn *BroflakeConn, tlsConfig *tls.Config) (*QUICLayer, error)
func (*QUICLayer) Close ¶
func (c *QUICLayer) Close()
Close a QUICLayer which was previously opened via a call to DialAndMaintainQUICConnection.
func (*QUICLayer) DialContext ¶
func (*QUICLayer) ListenAndMaintainQUICConnection ¶
func (c *QUICLayer) ListenAndMaintainQUICConnection()
type ReliableStreamLayer ¶
type SOCKS5Dialer ¶
func CreateSOCKS5Dialer ¶
func CreateSOCKS5Dialer(c ReliableStreamLayer) SOCKS5Dialer
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 UIImpl ¶
type UIImpl struct {
UI
BroflakeEngine *BroflakeEngine
}
func (*UIImpl) Init ¶
func (ui *UIImpl) Init(bf *BroflakeEngine)
func (UIImpl) OnConsumerConnectionChange ¶
func (UIImpl) OnDownstreamChunk ¶
func (UIImpl) OnDownstreamThroughput ¶
type WebRTCOptions ¶
type WebRTCOptions struct {
DiscoverySrv string
Endpoint string
GenesisAddr string
NATFailTimeout time.Duration
STUNBatch func(size uint32) (batch []string, err error)
STUNBatchSize uint32
Tag string
HTTPClient *http.Client
Patience time.Duration
ErrorBackoff time.Duration
ConsumerSessionID string
}
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 NewJITEgressConsumer ¶
func NewJITEgressConsumer(options *EgressOptions, wg *sync.WaitGroup) *WorkerFSM
func NewProducerWebRTC ¶
func NewProducerWebRTC(options *WebRTCOptions, wg *sync.WaitGroup) *WorkerFSM
func NewWorkerFSM ¶
Construct a new WorkerFSM
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