mirror of
https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake.git
synced 2025-10-13 20:11:19 -04:00
Start refactoring out a client and library
This commit is contained in:
parent
7662ccb00c
commit
cce7ee64a7
8 changed files with 120 additions and 105 deletions
56
client/lib/interfaces.go
Normal file
56
client/lib/interfaces.go
Normal file
|
@ -0,0 +1,56 @@
|
|||
package lib
|
||||
|
||||
import (
|
||||
"io"
|
||||
"net"
|
||||
)
|
||||
|
||||
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 {
|
||||
io.ReadWriteCloser
|
||||
Resetter
|
||||
Connector
|
||||
}
|
||||
|
||||
// Interface for catching Snowflakes. (aka the remote dialer)
|
||||
type Tongue interface {
|
||||
Catch() (Snowflake, 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() (Snowflake, error)
|
||||
|
||||
// Remove and return the most available Snowflake from the collection.
|
||||
Pop() Snowflake
|
||||
|
||||
// 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)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue