lib

package
v0.0.0-...-0a4c363 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2022 License: BSD-3-Clause Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BrokerError503        string = "No snowflake proxies currently available."
	BrokerError400        string = "You sent an invalid offer in the request."
	BrokerErrorUnexpected string = "Unexpected error, no answer."
)
View Source
const (
	ReconnectTimeout = 30 * time.Second
	SnowflakeTimeout = 30 * time.Second
	// How long to wait for the OnOpen callback on a DataChannel.
	DataChannelTimeout = 30 * time.Second
)
View Source
const (
	LogTimeInterval = 5 * time.Second
)

Variables

This section is empty.

Functions

func CreateBrokerTransport

func CreateBrokerTransport() http.RoundTripper

We make a copy of DefaultTransport because we want the default Dial and TLSHandshakeTimeout settings. But we want to disable the default ProxyFromEnvironment setting.

Types

type BrokerChannel

type BrokerChannel struct {
	// The Host header to put in the HTTP request (optional and may be
	// different from the host name in URL).
	Host string

	NATType string
	// contains filtered or unexported fields
}

Signalling Channel to the Broker.

func NewBrokerChannel

func NewBrokerChannel(broker string, front string, transport http.RoundTripper, keepLocalAddresses bool) (*BrokerChannel, error)

Construct a new BrokerChannel, where: |broker| is the full URL of the facilitating program which assigns proxies to clients, and |front| is the option fronting domain.

func (*BrokerChannel) Negotiate

func (bc *BrokerChannel) Negotiate(offer *webrtc.SessionDescription) (
	*webrtc.SessionDescription, error)

Roundtrip HTTP POST using WebRTC SessionDescriptions.

Send an SDP offer to the broker, which assigns a proxy and responds with an SDP answer from a designated remote WebRTC peer.

func (*BrokerChannel) SetNATType

func (bc *BrokerChannel) SetNATType(NATType string)

type BytesLogger

type BytesLogger interface {
	AddOutbound(int)
	AddInbound(int)
}

type BytesNullLogger

type BytesNullLogger struct{}

Default BytesLogger does nothing.

func (BytesNullLogger) AddInbound

func (b BytesNullLogger) AddInbound(amount int)

func (BytesNullLogger) AddOutbound

func (b BytesNullLogger) AddOutbound(amount int)

type BytesSyncLogger

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

BytesSyncLogger uses channels to safely log from multiple sources with output occuring at reasonable intervals.

func NewBytesSyncLogger

func NewBytesSyncLogger() *BytesSyncLogger

NewBytesSyncLogger returns a new BytesSyncLogger and starts it loggin.

func (*BytesSyncLogger) AddInbound

func (b *BytesSyncLogger) AddInbound(amount int)

func (*BytesSyncLogger) AddOutbound

func (b *BytesSyncLogger) AddOutbound(amount int)

type EncapsulationPacketConn

type EncapsulationPacketConn struct {
	io.ReadWriteCloser
	// contains filtered or unexported fields
}

EncapsulationPacketConn implements the net.PacketConn interface over an io.ReadWriteCloser stream, using the encapsulation package to represent packets in a stream.

func NewEncapsulationPacketConn

func NewEncapsulationPacketConn(
	localAddr, remoteAddr net.Addr,
	conn io.ReadWriteCloser,
) *EncapsulationPacketConn

NewEncapsulationPacketConn makes

func (*EncapsulationPacketConn) LocalAddr

func (c *EncapsulationPacketConn) LocalAddr() net.Addr

LocalAddr returns the localAddr value that was passed to NewEncapsulationPacketConn.

func (*EncapsulationPacketConn) ReadFrom

func (c *EncapsulationPacketConn) ReadFrom(p []byte) (int, net.Addr, error)

ReadFrom reads an encapsulated packet from the stream.

func (*EncapsulationPacketConn) SetDeadline

func (c *EncapsulationPacketConn) SetDeadline(t time.Time) error

func (*EncapsulationPacketConn) SetReadDeadline

func (c *EncapsulationPacketConn) SetReadDeadline(t time.Time) error

func (*EncapsulationPacketConn) SetWriteDeadline

func (c *EncapsulationPacketConn) SetWriteDeadline(t time.Time) error

func (*EncapsulationPacketConn) WriteTo

func (c *EncapsulationPacketConn) WriteTo(p []byte, addr net.Addr) (int, error)

WriteTo writes an encapsulated packet to the stream.

type Peers

type Peers struct {
	Tongue
	BytesLogger BytesLogger
	// contains filtered or unexported fields
}

Container which keeps track of multiple WebRTC remote peers. Implements |SnowflakeCollector|.

Maintaining a set of pre-connected Peers with fresh but inactive datachannels allows allows rapid recovery when the current WebRTC Peer disconnects.

Note: For now, only one remote can be active at any given moment. This is a property of Tor circuits & its current multiplexing constraints, but could be updated if that changes. (Also, this constraint does not necessarily apply to the more generic PT version of Snowflake)

func NewPeers

func NewPeers(tongue Tongue) (*Peers, error)

Construct a fresh container of remote peers.

func (*Peers) Collect

func (p *Peers) Collect() (*WebRTCPeer, error)

As part of |SnowflakeCollector| interface.

func (*Peers) Count

func (p *Peers) Count() int

Returns total available Snowflakes (including the active one) The count only reduces when connections themselves close, rather than when they are popped.

func (*Peers) End

func (p *Peers) End()

Close all Peers contained here.

func (*Peers) Melted

func (p *Peers) Melted() <-chan struct{}

As part of |SnowflakeCollector| interface.

func (*Peers) Pop

func (p *Peers) Pop() *WebRTCPeer

Pop blocks until an available, valid snowflake appears. Returns nil after End has been called.

type SnowflakeCollector

type SnowflakeCollector interface {
	// Add a Snowflake to the collection.
	// Implementation should decide how to connect and maintain the webRTCConn.
	Collect() (*WebRTCPeer, error)

	// Remove and return the most available Snowflake from the collection.
	Pop() *WebRTCPeer

	// Signal when the collector has stopped collecting.
	Melted() <-chan struct{}
}

Interface for collecting some number of Snowflakes, for passing along ultimately to the SOCKS handler.

type SnowflakeConn

type SnowflakeConn struct {
	*smux.Stream
	// contains filtered or unexported fields
}

func (*SnowflakeConn) Close

func (conn *SnowflakeConn) Close() error

type SocksConnector

type SocksConnector interface {
	Grant(*net.TCPAddr) error
	Reject() error
	net.Conn
}

Interface to adapt to goptlib's SocksConn struct.

type Tongue

type Tongue interface {
	Catch() (*WebRTCPeer, error)

	// Get the maximum number of snowflakes
	GetMax() int
}

Interface for catching Snowflakes. (aka the remote dialer)

type Transport

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

Transport is a structure with methods that conform to the Go PT v2.1 API https://github.com/Pluggable-Transports/Pluggable-Transports-spec/blob/master/releases/PTSpecV2.1/Pluggable%20Transport%20Specification%20v2.1%20-%20Go%20Transport%20API.pdf

func NewSnowflakeClient

func NewSnowflakeClient(brokerURL, frontDomain string, iceAddresses []string, keepLocalAddresses bool, max int) (*Transport, error)

Create a new Snowflake transport client that can spawn multiple Snowflake connections. brokerURL and frontDomain are the urls for the broker host and domain fronting host iceAddresses are the STUN/TURN urls needed for WebRTC negotiation keepLocalAddresses is a flag to enable sending local network addresses (for testing purposes) max is the maximum number of snowflakes the client should gather for each SOCKS connection

func (*Transport) Dial

func (t *Transport) Dial() (net.Conn, error)

Create a new Snowflake connection. Starts the collection of snowflakes and returns a smux Stream.

type WebRTCDialer

type WebRTCDialer struct {
	*BrokerChannel
	// contains filtered or unexported fields
}

Implements the |Tongue| interface to catch snowflakes, using BrokerChannel.

func NewWebRTCDialer

func NewWebRTCDialer(broker *BrokerChannel, iceServers []webrtc.ICEServer, max int) *WebRTCDialer

func (WebRTCDialer) Catch

func (w WebRTCDialer) Catch() (*WebRTCPeer, error)

Initialize a WebRTC Connection by signaling through the broker.

func (WebRTCDialer) GetMax

func (w WebRTCDialer) GetMax() int

Returns the maximum number of snowflakes to collect

type WebRTCPeer

type WebRTCPeer struct {
	BytesLogger BytesLogger
	// contains filtered or unexported fields
}

Remote WebRTC peer.

Handles preparation of go-webrtc PeerConnection. Only ever has one DataChannel.

func NewWebRTCPeer

func NewWebRTCPeer(config *webrtc.Configuration,
	broker *BrokerChannel) (*WebRTCPeer, error)

Construct a WebRTC PeerConnection.

func (*WebRTCPeer) Close

func (c *WebRTCPeer) Close() error

func (*WebRTCPeer) Read

func (c *WebRTCPeer) Read(b []byte) (int, error)

Read bytes from local SOCKS. As part of |io.ReadWriter|

func (*WebRTCPeer) Write

func (c *WebRTCPeer) Write(b []byte) (int, error)

Writes bytes out to remote WebRTC. As part of |io.ReadWriter|

Jump to

Keyboard shortcuts

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