import "github.com/ethereum/go-ethereum/p2p/discover/v5wire"
crypto.go encoding.go msg.go session.go
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.
Public errors.
DecodePubkey decodes a public key in compressed format.
EncodePubkey encodes a public key.
type Codec struct {
// contains filtered or unexported fields
}
Codec encodes and decodes Discovery v5 packets. This type is not safe for concurrent use.
NewCodec creates a wire codec.
func (c *Codec) Decode(input []byte, addr string) (src enode.ID, n *enode.Node, p Packet, err error)
Decode decodes a discovery packet.
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.
EncodeRaw encodes a packet with the given header.
FINDNODE is a query for nodes in the given bucket.
type Header struct { IV [sizeofMaskingIV]byte StaticHeader AuthData []byte // contains filtered or unexported fields }
Header represents a packet header.
NODES is the reply to FINDNODE and TOPICQUERY.
Nonce represents a nonce used for AES/GCM.
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.
DecodeMessage decodes the message body of a packet.
PING is sent during liveness checks.
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.
REGCONFIRMATION is the reply to REGTOPIC.
func (*Regconfirmation) Kind() byte
func (*Regconfirmation) Name() string
func (p *Regconfirmation) RequestID() []byte
func (p *Regconfirmation) SetRequestID(id []byte)
REGTOPIC registers the sender in a topic queue using a ticket.
REQUESTTICKET requests a ticket for a topic queue.
func (*RequestTicket) Kind() byte
func (*RequestTicket) Name() string
func (p *RequestTicket) RequestID() []byte
func (p *RequestTicket) SetRequestID(id []byte)
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(maxItems int, clock mclock.Clock) *SessionCache
type StaticHeader struct { ProtocolID [6]byte Version uint16 Flag byte Nonce Nonce AuthSize uint16 }
StaticHeader contains the static fields of a packet header.
TALKREQ is an application-level request.
func (*TalkRequest) Kind() byte
func (*TalkRequest) Name() string
func (p *TalkRequest) RequestID() []byte
func (p *TalkRequest) SetRequestID(id []byte)
TALKRESP is the reply to TALKREQ.
func (*TalkResponse) Kind() byte
func (*TalkResponse) Name() string
func (p *TalkResponse) RequestID() []byte
func (p *TalkResponse) SetRequestID(id []byte)
TICKET is the response to REQUESTTICKET.
TOPICQUERY asks for nodes with the given topic.
func (*TopicQuery) Kind() byte
func (*TopicQuery) Name() string
func (p *TopicQuery) RequestID() []byte
func (p *TopicQuery) SetRequestID(id []byte)
Unknown represents any packet that can't be decrypted.
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.
Package v5wire imports 21 packages (graph) and is imported by 9 packages. Updated 2020-10-14. Refresh now. Tools for package owners.