lib

package
v0.0.0-...-e3c9231 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2024 License: GPL-3.0 Imports: 24 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 = 10 * time.Second
	SnowflakeTimeout = 20 * time.Second
	// How long to wait for the OnOpen callback on a DataChannel.
	DataChannelTimeout = 10 * 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.

func Handler

func Handler(socks net.Conn, tongue Tongue) error

Given an accepted SOCKS connection, establish a WebRTC connection to the remote peer and exchange traffic.

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 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 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