Documentation ¶
Overview ¶
Package vpp2p implements the top-level host, node and ring objects, required for the P2P system.
Index ¶
- Constants
- type Host
- func (host *Host) CanSign() bool
- func (host *Host) CheckSig() (bool, error)
- func (host *Host) GetPackage() (*vpcommonapi.Package, error)
- func (host *Host) GetPredecessor(request *vpp2papi.GetPredecessorRequest) (*vpp2papi.GetPredecessorResponse, error)
- func (host *Host) GetSuccessors(request *vpp2papi.GetSuccessorsRequest) (*vpp2papi.GetSuccessorsResponse, error)
- func (host *Host) GetVersion() (*vpcommonapi.Version, error)
- func (host *Host) IsSigned() bool
- func (host *Host) Lookup(request *vpp2papi.LookupRequest) (*vpp2papi.LookupResponse, error)
- func (host *Host) Ping() error
- func (host *Host) Status() (*vpp2papi.HostStatus, error)
- func (host *Host) Sync(request *vpp2papi.SyncRequest) (*vpp2papi.SyncResponse, error)
- func (host *Host) Uptime() (int64, error)
- type HostInfoCatalog
- func (c *HostInfoCatalog) CreateHostsRefs(localHost *vpp2papi.HostInfo, rings []*vpp2papi.RingInfo, ...) map[string]*vpp2papi.HostInfo
- func (c *HostInfoCatalog) GetHost(hostPubKey []byte) *vpp2papi.HostInfo
- func (c *HostInfoCatalog) HasAllHostsRefs(refs map[string]*vpp2papi.HostInfo) bool
- func (c *HostInfoCatalog) HasHost(hostPubKey []byte) bool
- func (c *HostInfoCatalog) List() []*vpp2papi.HostInfo
- func (c *HostInfoCatalog) RegisterHost(host *vpp2papi.HostInfo)
- func (c *HostInfoCatalog) UnregisterHost(host *vpp2papi.HostInfo)
- func (c *HostInfoCatalog) UpdateHostsRefs(refs map[string]*vpp2papi.HostInfo)
- type HostsRefsCreator
- type Node
- func (node *Node) CheckSig() (int, error)
- func (node *Node) GetD() *vpp2papi.NodeInfo
- func (node *Node) GetImaginaryNode(key []byte) []byte
- func (node *Node) GetPredecessor() *vpp2papi.NodeInfo
- func (node *Node) GetSuccessors() []*vpp2papi.NodeInfo
- func (node *Node) IsSigned() bool
- func (node *Node) Lookup(key, keyShift, imaginaryNode []byte) (bool, []*vpp2papi.NodeInfo, error)
- func (node *Node) Start()
- func (node *Node) Stop()
- func (node *Node) Sync(source *vpp2papi.NodeInfo, key, keyShift, imaginaryNode []byte) (bool, []*vpp2papi.NodeInfo, []*vpp2papi.NodeInfo, *vpp2papi.NodeInfo, error)
- func (node *Node) Up() bool
- type NodeCatalog
- func (c *NodeCatalog) ConnectToNode(nodeID []byte) (vpp2papi.VpP2pApi, error)
- func (c *NodeCatalog) GetNode(nodeID []byte) *Node
- func (c *NodeCatalog) HasNode(nodeID []byte) bool
- func (c *NodeCatalog) List() []*vpp2papi.NodeInfo
- func (c *NodeCatalog) ListPtr() []*Node
- func (c *NodeCatalog) RegisterNode(node *Node)
- func (c *NodeCatalog) UnregisterNode(node *Node)
- type NodeRegisterer
- type Ring
- type RingSecret
Constants ¶
const ( // NodeKeySeconds specifies how many seconds should we spend on creating // node keys in signed mode. NodeKeySeconds = 1 // NodeKeyZeroes specifies how many zeroes there should be at the end of // a node key sig in signed mode. NodeKeyZeroes = 8 )
const ( // RingKeySeconds specifies how many seconds should we spend on creating // ring keys in signed mode. RingKeySeconds = 3 // RingKeyZeroes specifies how many zeroes there should be at the end of // a ring key sig in signed mode. RingKeyZeroes = 12 )
const PackageCopyright = "Copyright (C) 2015, 2016 Christian Mauduit <ufoot@ufoot.org>" // PackageCopyright set by version.sh
PackageCopyright contains a short copyright notice.
const PackageEmail = "ufoot@ufoot.org" // PackageEmail set by version.sh
PackageEmail contains a contact email for the package.
const PackageLicense = "GNU GPL v3" // PackageLicense set by version.sh
PackageLicense contains a short license information.
const PackageName = "Vapor Toolkit" // PackageName set by version.sh
PackageName contains a readable name of the package, suitable for display.
const PackageTarname = "vapor" // PackageTarname set by version.sh
PackageTarname contains a short name of the package, suitable for a filename.
const PackageURL = "https://github.com/ufoot/vapor" // PackageURL set by version.sh
PackageURL contains the address of the project homepage.
const VersionMajor = 0 // VersionMajor set by version.sh
VersionMajor is the project major version.
const VersionMinor = 18 // VersionMinor set by version.sh
VersionMinor is the project minor version.
const VersionStamp = "c6a4298" // VersionStamp set by version.sh
VersionStamp is the project stamp, possibly changes for each build.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Host ¶
type Host struct { // Info about the host Info vpp2papi.HostInfo // contains filtered or unexported fields }
Host is a physical host, it is used to uniquely identify a host, it can be used to handle several apps or rings.
func NewHost ¶
func NewHost(title, url string, useSig bool, creator HostsRefsCreator) (*Host, error)
NewHost returns a new host object
func (*Host) CheckSig ¶
CheckSig checks if the host signature is OK, if it's not, returns false and an error.
func (*Host) GetPackage ¶
func (host *Host) GetPackage() (*vpcommonapi.Package, error)
GetPackage returns the package version. Program general information.
func (*Host) GetPredecessor ¶
func (host *Host) GetPredecessor(request *vpp2papi.GetPredecessorRequest) (*vpp2papi.GetPredecessorResponse, error)
GetPredecessor is called to retrieve the predecessor of a node.
func (*Host) GetSuccessors ¶
func (host *Host) GetSuccessors(request *vpp2papi.GetSuccessorsRequest) (*vpp2papi.GetSuccessorsResponse, error)
GetSuccessors is called to retrieve successors of a node.
func (*Host) GetVersion ¶
func (host *Host) GetVersion() (*vpcommonapi.Version, error)
GetVersion returns the version version. Program general information.
func (*Host) IsSigned ¶
IsSigned returns true if the has been self-signed. It does not check if the signature is valid.
func (*Host) Lookup ¶
func (host *Host) Lookup(request *vpp2papi.LookupRequest) (*vpp2papi.LookupResponse, error)
Lookup searches for a key on a given ring.
func (*Host) Status ¶
func (host *Host) Status() (*vpp2papi.HostStatus, error)
Status is called to get another host status.
func (*Host) Sync ¶
func (host *Host) Sync(request *vpp2papi.SyncRequest) (*vpp2papi.SyncResponse, error)
Sync is called to connect and synchronize on a host. Basically, it does a lookup and returns successors and predecessor.
type HostInfoCatalog ¶
type HostInfoCatalog struct {
// contains filtered or unexported fields
}
HostInfoCatalog is structure used to contain locally-known hosts.
func GlobalHostInfoCatalog ¶
func GlobalHostInfoCatalog() *HostInfoCatalog
GlobalHostInfoCatalog returns a catalog containing all local hosts.
func NewHostInfoCatalog ¶
func NewHostInfoCatalog() *HostInfoCatalog
NewHostInfoCatalog creates a new instance of a local host catalog
func (*HostInfoCatalog) CreateHostsRefs ¶
func (c *HostInfoCatalog) CreateHostsRefs(localHost *vpp2papi.HostInfo, rings []*vpp2papi.RingInfo, nodes []*vpp2papi.NodeInfo) map[string]*vpp2papi.HostInfo
CreateHostsRefs returns a list of known hosts for a given set of nodes and rings. The key index is the short string, there might be collisions but this should not be a major problem as internally, full keys are used.
func (*HostInfoCatalog) GetHost ¶
func (c *HostInfoCatalog) GetHost(hostPubKey []byte) *vpp2papi.HostInfo
GetHost returns a handler which makes possible API calls on it. It's thread-safe.
func (*HostInfoCatalog) HasAllHostsRefs ¶
func (c *HostInfoCatalog) HasAllHostsRefs(refs map[string]*vpp2papi.HostInfo) bool
HasAllHostsRefs returns true if all the refs given are already known
func (*HostInfoCatalog) HasHost ¶
func (c *HostInfoCatalog) HasHost(hostPubKey []byte) bool
HasHost returns true if the host exists in the catalog. It's thread-safe.
func (*HostInfoCatalog) List ¶
func (c *HostInfoCatalog) List() []*vpp2papi.HostInfo
List returns a list of known hosts. It returns static data about the host, not the hosts themselves.
func (*HostInfoCatalog) RegisterHost ¶
func (c *HostInfoCatalog) RegisterHost(host *vpp2papi.HostInfo)
RegisterHost registers a host within the catalog. It's thread-safe.
func (*HostInfoCatalog) UnregisterHost ¶
func (c *HostInfoCatalog) UnregisterHost(host *vpp2papi.HostInfo)
UnregisterHost unregisters a host within the catalog. It's thread-safe.
func (*HostInfoCatalog) UpdateHostsRefs ¶
func (c *HostInfoCatalog) UpdateHostsRefs(refs map[string]*vpp2papi.HostInfo)
UpdateHostsRefs updates the host catalog according to a set of refs.
type HostsRefsCreator ¶
type Node ¶
type Node struct { // Status about the node Status vpp2papi.NodeStatus // Successors is list of successing nodes within the ring, // use 1st elem for direct successor. Successor []vpp2papi.VpP2pApi // D is a list of nodes preceeding m*Id (the 1st Bruijn node), // so that it contains about O(Log(n)) before stumbling on D. // The first element is actually D, the other ones go backwards on the ring. D []vpp2papi.VpP2pApi // contains filtered or unexported fields }
Node is the link between a Ring and a Host. Basically a node is a point on the ring, which joins on the ring using the host as a connexion tool.
func NewNode ¶
NewNode builds a new node object. Host and Ring are required, nodeID is optional, by default a new nodeID is provided.
func (*Node) CheckSig ¶
CheckSig checks if the node signature is OK, if it's not, returns 0 and an error. If it's OK, returns the number of zeroes in the signature hash.
func (*Node) GetImaginaryNode ¶
GetImaginaryNode returns the ID of the imaginary node for a lookup. This is to be used for the first lookup step. Technically you could use any number but choosing it properly makes search faster. Note that keyShift is just key on the first iteration.
func (*Node) GetPredecessor ¶
GetPredecessor returns the predecessor of a given node
func (*Node) GetSuccessors ¶
GetSuccessors returns the successors of a given node
func (*Node) IsSigned ¶
IsSigned returns true if the node has been signed by corresponding host. It does not check if the signature is valid.
func (*Node) Start ¶
func (node *Node) Start()
Start starts the node, that is, makes it available and registers it into all the local node catalogs.
func (*Node) Stop ¶
func (node *Node) Stop()
Stop stops the node, that is, makes it unavailable and unregisters it from all the local node catalogs.
type NodeCatalog ¶
type NodeCatalog struct {
// contains filtered or unexported fields
}
NodeCatalog is structure used to contain locally-known hosts.
func GlobalNodeCatalog ¶
func GlobalNodeCatalog() *NodeCatalog
GlobalNodeCatalog returns a catalog containing all local nodes.
func NewNodeCatalog ¶
func NewNodeCatalog() *NodeCatalog
NewNodeCatalog creates a new instance of a local node catalog
func (*NodeCatalog) ConnectToNode ¶
func (c *NodeCatalog) ConnectToNode(nodeID []byte) (vpp2papi.VpP2pApi, error)
ConnectToNode returns a handler which makes possible API calls on it. It's thread-safe.
func (*NodeCatalog) GetNode ¶
func (c *NodeCatalog) GetNode(nodeID []byte) *Node
GetNode returns a handler which makes possible API calls on it. It's thread-safe.
func (*NodeCatalog) HasNode ¶
func (c *NodeCatalog) HasNode(nodeID []byte) bool
HasNode returns true if the node exists in the catalog. It's thread-safe.
func (*NodeCatalog) List ¶
func (c *NodeCatalog) List() []*vpp2papi.NodeInfo
List returns a list of local nodes. It returns static data about the node, not the nodes themselves.
func (*NodeCatalog) ListPtr ¶
func (c *NodeCatalog) ListPtr() []*Node
ListPtr returns a list of local nodes. It returns static a pointer on nodes themselves.
func (*NodeCatalog) RegisterNode ¶
func (c *NodeCatalog) RegisterNode(node *Node)
RegisterNode registers a node within the catalog. It's thread-safe.
func (*NodeCatalog) UnregisterNode ¶
func (c *NodeCatalog) UnregisterNode(node *Node)
UnregisterNode unregisters a node within the catalog. It's thread-safe.
type NodeRegisterer ¶
type NodeRegisterer interface { // RegisterNode should be called when the node is started, ready for action. RegisterNode(node *Node) // UnregisterNode should be called when node is stopped, not responding any more. UnregisterNode(node *Node) }
NodeRegisterer is and interface that records node registring and unregistring.
type Ring ¶
type Ring struct { // Info about the ring Info vpp2papi.RingInfo // contains filtered or unexported fields }
Ring is a community, a network of related nodes, which communicate through hosts. It is the logical artefact used to relate several hosts/nodes together.
func BuiltinRing0 ¶
BuiltinRing0 creates an instance of the default directory ring.
func NewRing ¶
func NewRing(host *Host, ringTitle, ringDescription string, appID []byte, config *vpp2papi.RingConfig, fc vpid.FilterChecker, passwordHash []byte) (*Ring, error)
NewRing creates a new ring from static data.
func RingFromInfo ¶
RingFromInfo creates a new Ring object from its info static data, typically retrieved from the network, on an application directory.
type RingSecret ¶
type RingSecret struct { // Password hash PasswordHash []byte }
RingSecret stores the secret data of a Ring.