Documentation ¶
Overview ¶
Package campfire implements the "camp fire" protocol.
Index ¶
Constants ¶
const PSKSize = 32
PSKSize is the size of the PSK in bytes.
const Protocol = "/webmesh/campfire/1.0.0"
Protocol is the protocol name.
Variables ¶
var ( // ErrClosed is returned when the camp fire is closed. ErrClosed = net.ErrClosed )
var Now = time.Now
Now is the current time. It is a variable so it can be mocked out in tests.
Functions ¶
func GetDefaultTURNServers ¶
func GetDefaultTURNServers() []string
GetDefaultTURNServers returns the default list of TURN servers.
Types ¶
type CampFire ¶
type CampFire interface { // Accept returns a connection to a peer. Accept() (io.ReadWriteCloser, error) // Close closes the camp fire. Close() error // Errors returns a channel of errors. Errors() <-chan error // Expired returns a channel that is closed when the camp fire expires. Expired() <-chan struct{} }
CampFire is a connection to one or more peers sharing the same pre-shared key.
type Location ¶
type Location struct { // PSK is the pre-shared key. PSK []byte // LocalSecret is the computed local secret from the PSK. LocalSecret string // RemoteSecret is the computed remote secret from the PSK. RemoteSecret string // TURNServer is the selected TURN server. TURNServer string // ExpiresAt is the time at which the campfire expires. ExpiresAt time.Time }
Location is the secret and location of a campfire.
func Find ¶
Find finds a campfire using the given PSK and TURN servers. If turnServers is empty, a default list will be fetched from always-online-stun.
func (*Location) Expired ¶
func (l *Location) Expired() <-chan struct{}
Expired returns a channel that is closed when the campfire expires.
func (*Location) LocalUfrag ¶ added in v0.1.5
LocalUfrag returns the local ufrag.
func (*Location) RemoteUfrag ¶ added in v0.1.5
RemoteUfrag returns the remote ufrag.
func (*Location) TURNSessionID ¶ added in v0.1.5
TURNSessionID returns the TURN session ID.