go-ethereum: github.com/ethereum/go-ethereum/p2p/discover/v5wire Index | Files

package v5wire

import "github.com/ethereum/go-ethereum/p2p/discover/v5wire"

Index

Package Files

crypto.go encoding.go msg.go session.go

Constants

const (
    PingMsg byte = iota + 1
    PongMsg
    FindnodeMsg
    NodesMsg
    TalkRequestMsg
    TalkResponseMsg
    RequestTicketMsg
    TicketMsg
    RegtopicMsg
    RegconfirmationMsg
    TopicQueryMsg

    UnknownPacket   = byte(255) // any non-decryptable packet
    WhoareyouPacket = byte(254) // the WHOAREYOU packet
)

Message types.

Variables

var (
    ErrInvalidReqID = errors.New("request ID larger than 8 bytes")
)

Public errors.

func DecodePubkey Uses

func DecodePubkey(curve elliptic.Curve, e []byte) (*ecdsa.PublicKey, error)

DecodePubkey decodes a public key in compressed format.

func EncodePubkey Uses

func EncodePubkey(key *ecdsa.PublicKey) []byte

EncodePubkey encodes a public key.

type Codec Uses

type Codec struct {
    // contains filtered or unexported fields
}

Codec encodes and decodes Discovery v5 packets. This type is not safe for concurrent use.

func NewCodec Uses

func NewCodec(ln *enode.LocalNode, key *ecdsa.PrivateKey, clock mclock.Clock) *Codec

NewCodec creates a wire codec.

func (*Codec) Decode Uses

func (c *Codec) Decode(input []byte, addr string) (src enode.ID, n *enode.Node, p Packet, err error)

Decode decodes a discovery packet.

func (*Codec) Encode Uses

func (c *Codec) Encode(id enode.ID, addr string, packet Packet, challenge *Whoareyou) ([]byte, Nonce, error)

Encode encodes a packet to a node. 'id' and 'addr' specify the destination node. The 'challenge' parameter should be the most recently received WHOAREYOU packet from that node.

func (*Codec) EncodeRaw Uses

func (c *Codec) EncodeRaw(id enode.ID, head Header, msgdata []byte) ([]byte, error)

EncodeRaw encodes a packet with the given header.

type Findnode Uses

type Findnode struct {
    ReqID     []byte
    Distances []uint
}

FINDNODE is a query for nodes in the given bucket.

func (*Findnode) Kind Uses

func (*Findnode) Kind() byte

func (*Findnode) Name Uses

func (*Findnode) Name() string

func (*Findnode) RequestID Uses

func (p *Findnode) RequestID() []byte

func (*Findnode) SetRequestID Uses

func (p *Findnode) SetRequestID(id []byte)
type Header struct {
    IV  [sizeofMaskingIV]byte
    StaticHeader
    AuthData []byte
    // contains filtered or unexported fields
}

Header represents a packet header.

type Nodes Uses

type Nodes struct {
    ReqID []byte
    Total uint8
    Nodes []*enr.Record
}

NODES is the reply to FINDNODE and TOPICQUERY.

func (*Nodes) Kind Uses

func (*Nodes) Kind() byte

func (*Nodes) Name Uses

func (*Nodes) Name() string

func (*Nodes) RequestID Uses

func (p *Nodes) RequestID() []byte

func (*Nodes) SetRequestID Uses

func (p *Nodes) SetRequestID(id []byte)

type Nonce Uses

type Nonce [gcmNonceSize]byte

Nonce represents a nonce used for AES/GCM.

type Packet Uses

type Packet interface {
    Name() string        // Name returns a string corresponding to the message type.
    Kind() byte          // Kind returns the message type.
    RequestID() []byte   // Returns the request ID.
    SetRequestID([]byte) // Sets the request ID.
}

Packet is implemented by all message types.

func DecodeMessage Uses

func DecodeMessage(ptype byte, body []byte) (Packet, error)

DecodeMessage decodes the message body of a packet.

type Ping Uses

type Ping struct {
    ReqID  []byte
    ENRSeq uint64
}

PING is sent during liveness checks.

func (*Ping) Kind Uses

func (*Ping) Kind() byte

func (*Ping) Name Uses

func (*Ping) Name() string

func (*Ping) RequestID Uses

func (p *Ping) RequestID() []byte

func (*Ping) SetRequestID Uses

func (p *Ping) SetRequestID(id []byte)

type Pong Uses

type Pong struct {
    ReqID  []byte
    ENRSeq uint64
    ToIP   net.IP // These fields should mirror the UDP envelope address of the ping
    ToPort uint16 // packet, which provides a way to discover the the external address (after NAT).
}

PONG is the reply to PING.

func (*Pong) Kind Uses

func (*Pong) Kind() byte

func (*Pong) Name Uses

func (*Pong) Name() string

func (*Pong) RequestID Uses

func (p *Pong) RequestID() []byte

func (*Pong) SetRequestID Uses

func (p *Pong) SetRequestID(id []byte)

type Regconfirmation Uses

type Regconfirmation struct {
    ReqID      []byte
    Registered bool
}

REGCONFIRMATION is the reply to REGTOPIC.

func (*Regconfirmation) Kind Uses

func (*Regconfirmation) Kind() byte

func (*Regconfirmation) Name Uses

func (*Regconfirmation) Name() string

func (*Regconfirmation) RequestID Uses

func (p *Regconfirmation) RequestID() []byte

func (*Regconfirmation) SetRequestID Uses

func (p *Regconfirmation) SetRequestID(id []byte)

type Regtopic Uses

type Regtopic struct {
    ReqID  []byte
    Ticket []byte
    ENR    *enr.Record
}

REGTOPIC registers the sender in a topic queue using a ticket.

func (*Regtopic) Kind Uses

func (*Regtopic) Kind() byte

func (*Regtopic) Name Uses

func (*Regtopic) Name() string

func (*Regtopic) RequestID Uses

func (p *Regtopic) RequestID() []byte

func (*Regtopic) SetRequestID Uses

func (p *Regtopic) SetRequestID(id []byte)

type RequestTicket Uses

type RequestTicket struct {
    ReqID []byte
    Topic []byte
}

REQUESTTICKET requests a ticket for a topic queue.

func (*RequestTicket) Kind Uses

func (*RequestTicket) Kind() byte

func (*RequestTicket) Name Uses

func (*RequestTicket) Name() string

func (*RequestTicket) RequestID Uses

func (p *RequestTicket) RequestID() []byte

func (*RequestTicket) SetRequestID Uses

func (p *RequestTicket) SetRequestID(id []byte)

type SessionCache Uses

type SessionCache struct {
    // contains filtered or unexported fields
}

The SessionCache keeps negotiated encryption keys and state for in-progress handshakes in the Discovery v5 wire protocol.

func NewSessionCache Uses

func NewSessionCache(maxItems int, clock mclock.Clock) *SessionCache

type StaticHeader Uses

type StaticHeader struct {
    ProtocolID [6]byte
    Version    uint16
    Flag       byte
    Nonce      Nonce
    AuthSize   uint16
}

StaticHeader contains the static fields of a packet header.

type TalkRequest Uses

type TalkRequest struct {
    ReqID    []byte
    Protocol string
    Message  []byte
}

TALKREQ is an application-level request.

func (*TalkRequest) Kind Uses

func (*TalkRequest) Kind() byte

func (*TalkRequest) Name Uses

func (*TalkRequest) Name() string

func (*TalkRequest) RequestID Uses

func (p *TalkRequest) RequestID() []byte

func (*TalkRequest) SetRequestID Uses

func (p *TalkRequest) SetRequestID(id []byte)

type TalkResponse Uses

type TalkResponse struct {
    ReqID   []byte
    Message []byte
}

TALKRESP is the reply to TALKREQ.

func (*TalkResponse) Kind Uses

func (*TalkResponse) Kind() byte

func (*TalkResponse) Name Uses

func (*TalkResponse) Name() string

func (*TalkResponse) RequestID Uses

func (p *TalkResponse) RequestID() []byte

func (*TalkResponse) SetRequestID Uses

func (p *TalkResponse) SetRequestID(id []byte)

type Ticket Uses

type Ticket struct {
    ReqID  []byte
    Ticket []byte
}

TICKET is the response to REQUESTTICKET.

func (*Ticket) Kind Uses

func (*Ticket) Kind() byte

func (*Ticket) Name Uses

func (*Ticket) Name() string

func (*Ticket) RequestID Uses

func (p *Ticket) RequestID() []byte

func (*Ticket) SetRequestID Uses

func (p *Ticket) SetRequestID(id []byte)

type TopicQuery Uses

type TopicQuery struct {
    ReqID []byte
    Topic []byte
}

TOPICQUERY asks for nodes with the given topic.

func (*TopicQuery) Kind Uses

func (*TopicQuery) Kind() byte

func (*TopicQuery) Name Uses

func (*TopicQuery) Name() string

func (*TopicQuery) RequestID Uses

func (p *TopicQuery) RequestID() []byte

func (*TopicQuery) SetRequestID Uses

func (p *TopicQuery) SetRequestID(id []byte)

type Unknown Uses

type Unknown struct {
    Nonce Nonce
}

Unknown represents any packet that can't be decrypted.

func (*Unknown) Kind Uses

func (*Unknown) Kind() byte

func (*Unknown) Name Uses

func (*Unknown) Name() string

func (*Unknown) RequestID Uses

func (*Unknown) RequestID() []byte

func (*Unknown) SetRequestID Uses

func (*Unknown) SetRequestID([]byte)

type Whoareyou Uses

type Whoareyou struct {
    ChallengeData []byte   // Encoded challenge
    Nonce         Nonce    // Nonce of request packet
    IDNonce       [16]byte // Identity proof data
    RecordSeq     uint64   // ENR sequence number of recipient

    // Node is the locally known node record of recipient.
    // This must be set by the caller of Encode.
    Node *enode.Node
    // contains filtered or unexported fields
}

WHOAREYOU contains the handshake challenge.

func (*Whoareyou) Kind Uses

func (*Whoareyou) Kind() byte

func (*Whoareyou) Name Uses

func (*Whoareyou) Name() string

func (*Whoareyou) RequestID Uses

func (*Whoareyou) RequestID() []byte

func (*Whoareyou) SetRequestID Uses

func (*Whoareyou) SetRequestID([]byte)

Package v5wire imports 21 packages (graph) and is imported by 9 packages. Updated 2020-10-14. Refresh now. Tools for package owners.