bootstrap

package
v0.0.0-...-f2fe5c7 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2017 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PacketIDBootstrapInfo byte = 240
)

Variables

This section is empty.

Functions

func DestructPacket

func DestructPacket(p *Packet) (transport.Packet, error)

Types

type InfoRequestPacket

type InfoRequestPacket struct{}

InfoRequestPacket represents the structure of the packet used to request info from a bootstrap node. It contains infoRequestPacketLength - 1 useless bytes.

func (InfoRequestPacket) ID

func (p InfoRequestPacket) ID() byte

ID returns the packet ID of this packet.

func (*InfoRequestPacket) MarshalBinary

func (p *InfoRequestPacket) MarshalBinary() ([]byte, error)

MarshalBinary implements the encoding.BinaryMarshaler interface.

func (*InfoRequestPacket) UnmarshalBinary

func (p *InfoRequestPacket) UnmarshalBinary(data []byte) error

UnmarshalBinary implements the encoding.BinaryUnmarshaler interface.

type InfoResponsePacket

type InfoResponsePacket struct {
	Version uint32
	MOTD    string
}

InfoResponsePacket represents the structure of a packet that is sent in response to a bootstrap node info request.

func (InfoResponsePacket) ID

func (p InfoResponsePacket) ID() byte

ID returns the packet ID of this packet.

func (*InfoResponsePacket) MarshalBinary

func (p *InfoResponsePacket) MarshalBinary() ([]byte, error)

MarshalBinary implements the encoding.BinaryMarshaler interface.

func (*InfoResponsePacket) UnmarshalBinary

func (p *InfoResponsePacket) UnmarshalBinary(data []byte) error

UnmarshalBinary implements the encoding.BinaryUnmarshaler interface.

type Node

type Node struct {
	Ident       *dht.Ident
	Info        *NodeInfo
	IsBootstrap bool
	// contains filtered or unexported fields
}

func NewNode

func NewNode(tp transport.Transport) (*Node, error)

func (*Node) Bootstrap

func (n *Node) Bootstrap(node *dht.Node) error

func (*Node) Ping

func (n *Node) Ping(node *dht.Node) error

func (*Node) Pings

func (n *Node) Pings() *ping.Collection

func (*Node) Query

func (n *Node) Query(node *dht.Node, publicKey *[crypto.PublicKeySize]byte) error

Query queries the given DHT node to search for the given publicKey.

type NodeInfo

type NodeInfo struct {
	Version uint32
	MOTD    string
}

type Packet

type Packet struct {
	Type    byte
	Payload []byte
}

Packet represents the base of all bootstrap node packets.

func ConstructPacket

func ConstructPacket(packet transport.Packet) (*Packet, error)

func (*Packet) MarshalBinary

func (p *Packet) MarshalBinary() ([]byte, error)

MarshalBinary implements the encoding.BinaryMarshaler interface.

func (*Packet) UnmarshalBinary

func (p *Packet) UnmarshalBinary(data []byte) error

UnmarshalBinary implements the encoding.BinaryUnmarshaler interface.

Jump to

Keyboard shortcuts

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