vpp2p

package
v0.0.0-...-bf055c7 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2019 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Overview

Package vpp2p implements the top-level host, node and ring objects, required for the P2P system.

Index

Constants

View Source
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
)
View Source
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
)
View Source
const PackageCopyright = "Copyright (C)  2015, 2016  Christian Mauduit <ufoot@ufoot.org>" // PackageCopyright set by version.sh

PackageCopyright contains a short copyright notice.

View Source
const PackageEmail = "ufoot@ufoot.org" // PackageEmail set by version.sh

PackageEmail contains a contact email for the package.

View Source
const PackageLicense = "GNU GPL v3" // PackageLicense set by version.sh

PackageLicense contains a short license information.

View Source
const PackageName = "Vapor Toolkit" // PackageName set by version.sh

PackageName contains a readable name of the package, suitable for display.

View Source
const PackageTarname = "vapor" // PackageTarname set by version.sh

PackageTarname contains a short name of the package, suitable for a filename.

View Source
const PackageURL = "https://github.com/ufoot/vapor" // PackageURL set by version.sh

PackageURL contains the address of the project homepage.

View Source
const VersionMajor = 0 // VersionMajor set by version.sh

VersionMajor is the project major version.

View Source
const VersionMinor = 18 // VersionMinor set by version.sh

VersionMinor is the project minor version.

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

func (host *Host) CanSign() bool

CanSign returns true if the host has a key it can sign with.

func (*Host) CheckSig

func (host *Host) CheckSig() (bool, error)

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

func (host *Host) IsSigned() bool

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

func (host *Host) Ping() error

Ping is a simple ping function

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.

func (*Host) Uptime

func (host *Host) Uptime() (int64, error)

Uptime is a simple uptime function, returns time since host was created.

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 HostsRefsCreator interface {
	CreateHostsRefs(locallHost *vpp2papi.HostInfo, rings []*vpp2papi.RingInfo, nodes []*vpp2papi.NodeInfo) map[string]*vpp2papi.HostInfo
}

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

func NewNode(host *Host, ring *Ring, nodeID []byte, registerer NodeRegisterer) (*Node, error)

NewNode builds a new node object. Host and Ring are required, nodeID is optional, by default a new nodeID is provided.

func (*Node) CheckSig

func (node *Node) CheckSig() (int, error)

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

func (node *Node) GetD() *vpp2papi.NodeInfo

GetD returns the d of a given node

func (*Node) GetImaginaryNode

func (node *Node) GetImaginaryNode(key []byte) []byte

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

func (node *Node) GetPredecessor() *vpp2papi.NodeInfo

GetPredecessor returns the predecessor of a given node

func (*Node) GetSuccessors

func (node *Node) GetSuccessors() []*vpp2papi.NodeInfo

GetSuccessors returns the successors of a given node

func (*Node) IsSigned

func (node *Node) IsSigned() bool

IsSigned returns true if the node has been signed by corresponding host. It does not check if the signature is valid.

func (*Node) Lookup

func (node *Node) Lookup(key, keyShift, imaginaryNode []byte) (bool, []*vpp2papi.NodeInfo, error)

Lookup performs a lookup for a given key

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.

func (*Node) Sync

func (node *Node) Sync(source *vpp2papi.NodeInfo, key, keyShift, imaginaryNode []byte) (bool, []*vpp2papi.NodeInfo, []*vpp2papi.NodeInfo, *vpp2papi.NodeInfo, error)

Sync performs a lookup for a given key

func (*Node) Up

func (node *Node) Up() bool

Up tells wether the node is up or not.

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

func BuiltinRing0() (*Ring, error)

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 NewRing0

func NewRing0() (*Ring, error)

NewRing0 creates a new instance of the default directory ring.

func RingFromInfo

func RingFromInfo(ringInfo *vpp2papi.RingInfo, passwordHash []byte) (*Ring, error)

RingFromInfo creates a new Ring object from its info static data, typically retrieved from the network, on an application directory.

func (*Ring) CheckSig

func (ring *Ring) CheckSig() (int, error)

CheckSig checks if the ring 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 (*Ring) IsSigned

func (ring *Ring) IsSigned() bool

IsSigned returns true if the ring has been signed by corresponding host. It does not check if the signature is valid.

type RingSecret

type RingSecret struct {
	// Password hash
	PasswordHash []byte
}

RingSecret stores the secret data of a Ring.

Jump to

Keyboard shortcuts

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