summaryrefslogtreecommitdiff
path: root/pkg/snowflake/lib/interfaces.go
blob: 5378f4a2d39075328e39a924f34a35bf6c61bca2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package lib

import (
	"net"
)

// Interface for catching Snowflakes. (aka the remote dialer)
type Tongue interface {
	Catch() (*WebRTCPeer, error)

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

// Interface for collecting some number of Snowflakes, for passing along
// ultimately to the SOCKS handler.
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 to adapt to goptlib's SocksConn struct.
type SocksConnector interface {
	Grant(*net.TCPAddr) error
	Reject() error
	net.Conn
}