snowflake/client/lib/interfaces.go
David Fifield 76732155e7 Remove Snowflake interface, use *WebRTCPeer directly.
The other interfaces in client/lib/interfaces.go exist for the purpose
of running tests, but not Snowflake. Existing code would not have worked
with other types anyway, because it does unchecked .(*WebRTCPeer)
conversions.
2020-04-27 17:51:21 -06:00

42 lines
965 B
Go

package lib
import (
"io"
"net"
)
type Connector interface {
Connect() error
}
// Interface for catching Snowflakes. (aka the remote dialer)
type Tongue interface {
Catch() (*WebRTCPeer, error)
}
// 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
}
// Interface for the Snowflake's transport. (Typically just webrtc.DataChannel)
type SnowflakeDataChannel interface {
io.Closer
Send([]byte) error
}