devp2p

package
v0.0.0-...-22375db Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2019 License: GPL-3.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrPacketTooSmall   = errors.New("too small")
	ErrBadHash          = errors.New("bad hash")
	ErrExpired          = errors.New("expired")
	ErrUnsolicitedReply = errors.New("unsolicited reply")
	ErrUnknownNode      = errors.New("unknown node")
	ErrTimeout          = errors.New("RPC timeout")
	ErrClockWarp        = errors.New("reply deadline too far in the future")
	ErrClosed           = errors.New("socket closed")
	ErrResponseReceived = errors.New("response received")
	ErrPacketMismatch   = errors.New("packet mismatch")
	ErrCorruptDHT       = errors.New("corrupt neighbours data")
	UnexpectedPacket    = false
)

Errors

Functions

func EncodePubkey

func EncodePubkey(key *ecdsa.PublicKey) encPubkey

EncodePubkey convert to bytes

func GetInterfaceIP

func GetInterfaceIP(iface *net.Interface) (*net.IP, error)

GetInterfaceIP returns the IP address of the (usually eth0) interface (see above)

func GetNetworkInterface

func GetNetworkInterface() (*net.Interface, error)

GetNetworkInterface - Get the docker image's network interface

Types

type Config

type Config struct {
	// These settings are required and configure the UDP listener:
	PrivateKey *ecdsa.PrivateKey

	// These settings are optional:
	AnnounceAddr *net.UDPAddr      // local address announced in the DHT
	NodeDBPath   string            // if set, the node database is stored at this filesystem location
	NetRestrict  *netutil.Netlist  // network whitelist
	Bootnodes    []*enode.Node     // list of bootstrap nodes
	Unhandled    chan<- ReadPacket // unhandled packets are sent on this channel
}

Config holds Table-related settings.

type ReadPacket

type ReadPacket struct {
	Data []byte
	Addr *net.UDPAddr
}

ReadPacket is sent to the unhandled channel when it could not be processed

type V4Udp

type V4Udp struct {
	OurEndpoint rpcEndpoint
	// contains filtered or unexported fields
}

V4Udp is the v4UDP test class

func ListenUDP

func ListenUDP(c conn, cfg Config, l common.Logger) (*V4Udp, error)

ListenUDP returns a new table that listens for UDP packets on laddr.

func (*V4Udp) BondedSourceFindNeighbours

func (t *V4Udp) BondedSourceFindNeighbours(toid enode.ID, toaddr *net.UDPAddr, target encPubkey) error

BondedSourceFindNeighbours basic find neighbours tests

func (*V4Udp) BondedSourceFindNeighboursPastExpiration

func (t *V4Udp) BondedSourceFindNeighboursPastExpiration(toid enode.ID, toaddr *net.UDPAddr, target encPubkey) error

BondedSourceFindNeighboursPastExpiration -

func (*V4Udp) FindnodeWithoutBond

func (t *V4Udp) FindnodeWithoutBond(toid enode.ID, toaddr *net.UDPAddr, target encPubkey) error

FindnodeWithoutBond tries to find a node without a previous bond

func (*V4Udp) Ping

func (t *V4Udp) Ping(toid enode.ID, toaddr *net.UDPAddr, validateEnodeID bool, recoveryCallback func(e *ecdsa.PublicKey)) error

Ping sends a ping message to the given node and waits for a reply.

func (*V4Udp) PingBondedWithMangledFromField

func (t *V4Udp) PingBondedWithMangledFromField(toid enode.ID, toaddr *net.UDPAddr, validateEnodeID bool, recoveryCallback func(e *ecdsa.PublicKey)) error

PingBondedWithMangledFromField ping a bonded node with bad from fields

func (*V4Udp) PingExtraData

func (t *V4Udp) PingExtraData(toid enode.ID, toaddr *net.UDPAddr, validateEnodeID bool, recoveryCallback func(e *ecdsa.PublicKey)) error

PingExtraData ping with a 'future format' packet containing extra fields

func (*V4Udp) PingExtraDataWrongFrom

func (t *V4Udp) PingExtraDataWrongFrom(toid enode.ID, toaddr *net.UDPAddr, validateEnodeID bool, recoveryCallback func(e *ecdsa.PublicKey)) error

PingExtraDataWrongFrom ping with a 'future format' packet containing extra fields and make sure it works even with the wrong 'from' field

func (*V4Udp) PingPastExpiration

func (t *V4Udp) PingPastExpiration(toid enode.ID, toaddr *net.UDPAddr, validateEnodeID bool, recoveryCallback func(e *ecdsa.PublicKey)) error

PingPastExpiration check past expirations are handled correctly

func (*V4Udp) PingTargetWrongPacketType

func (t *V4Udp) PingTargetWrongPacketType(toid enode.ID, toaddr *net.UDPAddr, validateEnodeID bool, recoveryCallback func(e *ecdsa.PublicKey)) error

PingTargetWrongPacketType send a packet (a ping packet, though it could be something else) with an unknown packet type to the client and see how the target behaves. If the target responds to the ping, then fail.

func (*V4Udp) PingWrongFrom

func (t *V4Udp) PingWrongFrom(toid enode.ID, toaddr *net.UDPAddr, validateEnodeID bool, recoveryCallback func(e *ecdsa.PublicKey)) error

PingWrongFrom pings with incorrect from field

func (*V4Udp) PingWrongTo

func (t *V4Udp) PingWrongTo(toid enode.ID, toaddr *net.UDPAddr, validateEnodeID bool, recoveryCallback func(e *ecdsa.PublicKey)) error

PingWrongTo pings with incorrect to

func (*V4Udp) SpoofedPing

func (t *V4Udp) SpoofedPing(toid enode.ID, tomac string, toaddr *net.UDPAddr, fromaddr *net.UDPAddr, validateEnodeID bool, recoveryCallback func(e *ecdsa.PublicKey)) error

SpoofedPing - verify that the faked udp packets are being sent, received, and responses relayed correctly.

func (*V4Udp) SpoofingFindNodeCheck

func (t *V4Udp) SpoofingFindNodeCheck(toid enode.ID, tomac string, toaddr *net.UDPAddr, fromaddr *net.UDPAddr, validateEnodeID bool) error

SpoofingFindNodeCheck tests if a client is susceptible to being used as an attack vector for findnode amplification attacks

Jump to

Keyboard shortcuts

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