divsd

package
v0.0.0-...-8e2bdd7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 5, 2014 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MSG_DIVS_PKG_ETH messageType = iota
	MSG_LAST
)

The list of available message types.

View Source
const DISCOVERED_CHAN_LEN = 10

discovered channel length

View Source
const JOINED_CHAN_LEN = 10

joined channel length

View Source
const LOG_MODULE = "divs"
View Source
const SEND_QUEUE_LEN = 100

the send queue length used for sending to a node

View Source
const TAP_BUFFER_LEN = 9000

the buffer length used for reading a packet from the TAP device

Variables

View Source
var ERR_COULD_NOT_PARSE_ADDR = fmt.Errorf("Could not parse address")

Could not parse address

View Source
var ERR_MALFORMED_MSG = fmt.Errorf("Malformed message")

Malformed message

View Source
var ERR_TIMEOUT_PEERS = fmt.Errorf("Timeout while waiting for peers")

Timeout while waiting for peers

View Source
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

func NewConfig

func NewConfig() (c *Config)

Create a new DiVS daemon configuration

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 Encodeable interface {
	Encode() (data []byte, err error)
}

type EthernetPacket

type EthernetPacket struct {
	layers.Ethernet
}

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) Close

func (node *Node) Close() error

Close the node, releasing all the resources associated with it

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)

func New

func New(config *Config) (s *Server, err error)

Creates a new server.

func (*Server) ListenAndServe

func (s *Server) ListenAndServe() error

Starts the server.

type UUID

type UUID struct {
	uuid.UUID
}

func NewSwitchFromString

func NewSwitchFromString(s string) UUID

Get a new switch device id from a string

func NewSwitchId

func NewSwitchId() UUID

Get a new switch device id

func (UUID) Empty

func (uuid UUID) Empty() bool

Return `true` if the UUID is empty

func (UUID) ToBase64

func (uuid UUID) ToBase64() string

Get a new UUID in Base64

func (UUID) ToHex

func (uuid UUID) ToHex() string

Get a new UUID in hexadecimal

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL