interfaces.go 1.18 KB
Newer Older
1
package lib
2
3

import (
4
	"io"
5
6
7
	"net"
)

8
9
10
11
12
13
14
15
16
17
18
19
type Connector interface {
	Connect() error
}

type Resetter interface {
	Reset()
	WaitForReset()
}

// Interface for a single remote WebRTC peer.
// In the Client context, "Snowflake" refers to the remote browser proxy.
type Snowflake interface {
20
	io.ReadWriteCloser
21
22
23
24
	Resetter
	Connector
}

25
// Interface for catching Snowflakes. (aka the remote dialer)
26
type Tongue interface {
27
	Catch() (Snowflake, error)
28
29
}

30
31
32
33
34
35
// 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.
36
	Collect() (Snowflake, error)
37
38

	// Remove and return the most available Snowflake from the collection.
39
	Pop() Snowflake
40
41
42

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

// Interface to adapt to goptlib's SocksConn struct.
46
47
48
49
50
51
type SocksConnector interface {
	Grant(*net.TCPAddr) error
	Reject() error
	net.Conn
}

52
53
// Interface for the Snowflake's transport. (Typically just webrtc.DataChannel)
type SnowflakeDataChannel interface {
54
	io.Closer
55
	Send([]byte) error
56
}