Documentation ¶
Index ¶
- Constants
- Variables
- type Config
- type DevManager
- type Encodeable
- type EthernetPacket
- type Node
- type NodesManager
- func (nm *NodesManager) GetBroadcasts(overhead, limit int) [][]byte
- func (nm *NodesManager) Join(nodes []string) error
- func (nm *NodesManager) LocalState(join bool) []byte
- func (nm *NodesManager) MergeRemoteState(buf []byte, join bool)
- func (nm *NodesManager) NodeMeta(limit int) []byte
- func (nm *NodesManager) NotifyJoin(node *memberlist.Node)
- func (nm *NodesManager) NotifyLeave(node *memberlist.Node)
- func (nm *NodesManager) NotifyMsg(buf []byte)
- func (nm *NodesManager) NotifyUpdate(node *memberlist.Node)
- func (nm *NodesManager) SendPacket(packet *EthernetPacket) error
- func (nm *NodesManager) SendTo(packet []byte, node *Node) error
- func (nm *NodesManager) SetDevManager(dm *DevManager) error
- func (nm *NodesManager) Start(membersExtAddr net.UDPAddr) (err error)
- func (nm *NodesManager) Stop() (err error)
- func (this *NodesManager) WaitForNodes() error
- func (this *NodesManager) WaitForNodesForever() error
- func (nm *NodesManager) WaitForNodesTime(seconds time.Duration) (err error)
- type Server
- type UUID
Constants ¶
const ( MSG_DIVS_PKG_ETH messageType = iota MSG_LAST )
The list of available message types.
const DISCOVERED_CHAN_LEN = 10
discovered channel length
const JOINED_CHAN_LEN = 10
joined channel length
const LOG_MODULE = "divs"
const SEND_QUEUE_LEN = 100
the send queue length used for sending to a node
const TAP_BUFFER_LEN = 9000
the buffer length used for reading a packet from the TAP device
Variables ¶
var ERR_COULD_NOT_PARSE_ADDR = fmt.Errorf("Could not parse address")
Could not parse address
var ERR_MALFORMED_MSG = fmt.Errorf("Malformed message")
Malformed message
var ERR_TIMEOUT_PEERS = fmt.Errorf("Timeout while waiting for peers")
Timeout while waiting for peers
var ERR_UNKNOWN_DST_MAC = fmt.Errorf("Unknown destination mac")
Unknown destination mac
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { Global globalConfig Discover discoverConfig Mdns mdnsConfig Tun tunConfig }
The top configuration structure for the DiVS daemon
type DevManager ¶
type DevManager struct {
// contains filtered or unexported fields
}
func NewDevManager ¶
func NewDevManager(config *Config) (d *DevManager, err error)
Create a new devices manager, in practice a TAP device manager This manager will be responsible for reading from the device and sending data to the right peers
func (*DevManager) SetNodesManager ¶
func (dman *DevManager) SetNodesManager(nm *NodesManager) error
Set the nodes manager
func (*DevManager) Start ¶
func (dman *DevManager) Start() (err error)
Start the TAP device and start reading from it
func (*DevManager) Stop ¶
func (dman *DevManager) Stop()
type Encodeable ¶
type EthernetPacket ¶
An encapsulated ethernet packet
func NewEthernetPacketFromBuffer ¶
func NewEthernetPacketFromBuffer(in []byte) *EthernetPacket
Decode a ethernet packet from a buffer
func (EthernetPacket) Encode ¶
func (pkt EthernetPacket) Encode() (data []byte, err error)
Encode a ethernet packet to a ready-to-send buffer
type Node ¶
type Node struct { *memberlist.Node // contains filtered or unexported fields }
func NewNode ¶
func NewNode(address string, nm *NodesManager) (*Node, error)
@param address: a string in the form IP:port
func (Node) Equal ¶
func (node Node) Equal(other *memberlist.Node) bool
Compare to another node, returning "true" if they are equal
func (*Node) Send ¶
func (node *Node) Send(data Encodeable) error
Send some serializable object to this node Data is enqueued in a queue for sending This method will only be invoked from the NodesManager
type NodesManager ¶
type NodesManager struct {
// contains filtered or unexported fields
}
the peers manager is responsible for - establishing and keeping connections to peers - sending/receiving data to/from peers
func NewNodesManager ¶
func NewNodesManager(config *Config) (*NodesManager, error)
Create a new peers manager
func (*NodesManager) GetBroadcasts ¶
func (nm *NodesManager) GetBroadcasts(overhead, limit int) [][]byte
GetBroadcasts is called when user data messages can be broadcast. It can return a list of buffers to send. Each buffer should assume an overhead as provided with a limit on the total byte size allowed. The total byte size of the resulting data to send must not exceed the limit.
func (*NodesManager) Join ¶
func (nm *NodesManager) Join(nodes []string) error
Join a new peer This method is invoked when we have detected a new peer with the rendezvous subsystem. It triggers the `memberlist` join.
func (*NodesManager) LocalState ¶
func (nm *NodesManager) LocalState(join bool) []byte
LocalState is used for a TCP Push/Pull. This is sent to the remote side in addition to the membership information. Any data can be sent here. See MergeRemoteState as well. The `join` boolean indicates this is for a join instead of a push/pull.
func (*NodesManager) MergeRemoteState ¶
func (nm *NodesManager) MergeRemoteState(buf []byte, join bool)
MergeRemoteState is invoked after a TCP Push/Pull. This is the state received from the remote side and is the result of the remote side's LocalState call. The 'join' boolean indicates this is for a join instead of a push/pull.
func (*NodesManager) NodeMeta ¶
func (nm *NodesManager) NodeMeta(limit int) []byte
NodeMeta is used to retrieve meta-data about the current node when broadcasting an alive message. It's length is limited to the given byte size. This metadata is available in the Node structure.
func (*NodesManager) NotifyJoin ¶
func (nm *NodesManager) NotifyJoin(node *memberlist.Node)
NotifyJoin is invoked when a node is detected to have joined the memberlist. The Node argument must not be modified.
func (*NodesManager) NotifyLeave ¶
func (nm *NodesManager) NotifyLeave(node *memberlist.Node)
NotifyLeave is invoked when a node is detected to have left. The Node argument must not be modified.
func (*NodesManager) NotifyMsg ¶
func (nm *NodesManager) NotifyMsg(buf []byte)
NotifyMsg is called when a user-data message is received. Care should be taken that this method does not block, since doing so would block the entire UDP packet receive loop. Additionally, the byte slice may be modified after the call returns, so it should be copied if needed.
func (*NodesManager) NotifyUpdate ¶
func (nm *NodesManager) NotifyUpdate(node *memberlist.Node)
NotifyUpdate is invoked when a node is detected to have updated, usually involving the meta data. The Node argument must not be modified.
func (*NodesManager) SendPacket ¶
func (nm *NodesManager) SendPacket(packet *EthernetPacket) error
Sends a packet to the corresponding Node If no valid Node is found for this packet, it is silently discarded
func (*NodesManager) SendTo ¶
func (nm *NodesManager) SendTo(packet []byte, node *Node) error
Sends some data to some other node
func (*NodesManager) SetDevManager ¶
func (nm *NodesManager) SetDevManager(dm *DevManager) error
Set the devices manager
func (*NodesManager) Start ¶
func (nm *NodesManager) Start(membersExtAddr net.UDPAddr) (err error)
Start the nodes manager
func (*NodesManager) Stop ¶
func (nm *NodesManager) Stop() (err error)
wait some time for some peers
func (*NodesManager) WaitForNodes ¶
func (this *NodesManager) WaitForNodes() error
Wait for some peers
func (*NodesManager) WaitForNodesForever ¶
func (this *NodesManager) WaitForNodesForever() error
Wait for some peers
func (*NodesManager) WaitForNodesTime ¶
func (nm *NodesManager) WaitForNodesTime(seconds time.Duration) (err error)
Wait some time for some peers
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
The DiVS server starts the nodes manager (for the p2p network) and the devices manager (for the TAP device)
type UUID ¶
func NewSwitchFromString ¶
Get a new switch device id from a string
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
The NAT package is responsible for * obtaining a pair of public IP and port that can be announced to external nodes and can be used for sending traffic to this node.
|
The NAT package is responsible for * obtaining a pair of public IP and port that can be announced to external nodes and can be used for sending traffic to this node. |
The rendezvous package is responsible for starting the discovery service The discovery service must: * announce in the network the presence if this node * lookup other nodes that are using the same service
|
The rendezvous package is responsible for starting the discovery service The discovery service must: * announce in the network the presence if this node * lookup other nodes that are using the same service |