Documentation ¶
Overview ¶
Package quibit provides basic Peer-To-Peer asynchronous network functionality and peer management.
Index ¶
Constants ¶
const ( BROADCAST = iota REQUEST = iota REPLY = iota )
Message Types:
Broadcast goes to all connected peers except for the Peer specified in the Frame.
Request and Reply go to the Peer specified in the Frame.
const (
MAGIC = 6667787
)
Variables ¶
This section is empty.
Functions ¶
func Cleanup ¶
func Cleanup()
Cleanup the Quibit Service
End the mux and server routines, and Disconnect from all peers.
func Initialize ¶
func Initialize(log chan string, recvChan, sendChan chan Frame, peerChan chan Peer, port uint16) error
Initialize the Quibit Service
Frames from the network will be sent to recvChan, and includes the sending peer ¶
Frames for the network should be sent to sendChan, and include the receiving peer ¶
New Peers for connecting should be sent to peerChan.
A local server will be started on the port specified by "port"
If an error is returned, than neither the server or mux has been started.
Types ¶
type Frame ¶
type Header ¶
type Header struct { Magic uint32 // Known magic number Command uint8 // How to interpret payload Type uint8 // How to interpret payload Checksum [48]byte // SHA-384 Checksum of Payload Length uint32 // Length of Payload }
Used as a fixed-length description of a frame
type Peer ¶
type Peer struct { IP net.IP // Standard 16-byte IP Address Port uint16 // Standard 2-byte TCP Port // contains filtered or unexported fields }
func GetPeer ¶
Get Peer associated with the given <IP>:<Host> string
<nil> Signifies a disconnected or unknown peer.
func (*Peer) Disconnect ¶
func (p *Peer) Disconnect()
Forces Disconnect from Peer and closes all incoming connections.
type QuibitError ¶
type QuibitError int
Error type for Quibit-Specific Errors
func (QuibitError) Error ¶
func (e QuibitError) Error() string