Documentation ¶
Index ¶
- Constants
- Variables
- func DecodePubkey(curve elliptic.Curve, e []byte) (*ecdsa.PublicKey, error)
- func EncodePubkey(key *ecdsa.PublicKey) []byte
- type Codec
- type Findnode
- type Header
- type Nodes
- type Nonce
- type Packet
- type Ping
- type Pong
- type Regconfirmation
- type Regtopic
- type RequestTicket
- type SessionCache
- type StaticHeader
- type TalkRequest
- type TalkResponse
- type Ticket
- type TopicQuery
- type Unknown
- type Whoareyou
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 represents error when the ID is invalid. ErrInvalidReqID = errors.New("request ID larger than 8 bytes") )
Public errors.
Functions ¶
func DecodePubkey ¶
DecodePubkey decodes a public key in compressed format.
func EncodePubkey ¶
EncodePubkey encodes a public key.
Types ¶
type Codec ¶
type Codec struct {
// contains filtered or unexported fields
}
Codec encodes and decodes Discovery v5 packets. This type is not safe for concurrent use.
func (*Codec) Decode ¶
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 ¶
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.
type Header ¶
type Header struct { IV [sizeofMaskingIV]byte StaticHeader AuthData []byte // contains filtered or unexported fields }
Header represents a packet header.
type Packet ¶
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.
type Pong ¶
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 external address (after NAT). }
Pong is the reply to Ping.
func (*Pong) SetRequestID ¶
type Regconfirmation ¶
Regconfirmation is the reply to Regtopic.
func (*Regconfirmation) Kind ¶
func (*Regconfirmation) Kind() byte
func (*Regconfirmation) Name ¶
func (*Regconfirmation) Name() string
func (*Regconfirmation) RequestID ¶
func (p *Regconfirmation) RequestID() []byte
func (*Regconfirmation) SetRequestID ¶
func (p *Regconfirmation) SetRequestID(id []byte)
type Regtopic ¶
Regtopic registers the sender in a topic queue using a ticket.
func (*Regtopic) SetRequestID ¶
type RequestTicket ¶
RequestTicket requests a ticket for a topic queue.
func (*RequestTicket) Kind ¶
func (*RequestTicket) Kind() byte
func (*RequestTicket) Name ¶
func (*RequestTicket) Name() string
func (*RequestTicket) RequestID ¶
func (p *RequestTicket) RequestID() []byte
func (*RequestTicket) SetRequestID ¶
func (p *RequestTicket) SetRequestID(id []byte)
type SessionCache ¶
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 ¶
func NewSessionCache(maxItems int, clock mclock.Clock) *SessionCache
type StaticHeader ¶
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 ¶
TalkRequest is an application-level request.
func (*TalkRequest) Kind ¶
func (*TalkRequest) Kind() byte
func (*TalkRequest) Name ¶
func (*TalkRequest) Name() string
func (*TalkRequest) RequestID ¶
func (p *TalkRequest) RequestID() []byte
func (*TalkRequest) SetRequestID ¶
func (p *TalkRequest) SetRequestID(id []byte)
type TalkResponse ¶
TalkResponse is the reply to TalkRequest.
func (*TalkResponse) Kind ¶
func (*TalkResponse) Kind() byte
func (*TalkResponse) Name ¶
func (*TalkResponse) Name() string
func (*TalkResponse) RequestID ¶
func (p *TalkResponse) RequestID() []byte
func (*TalkResponse) SetRequestID ¶
func (p *TalkResponse) SetRequestID(id []byte)
type TopicQuery ¶
TopicQuery asks for nodes with the given topic.
func (*TopicQuery) Kind ¶
func (*TopicQuery) Kind() byte
func (*TopicQuery) Name ¶
func (*TopicQuery) Name() string
func (*TopicQuery) RequestID ¶
func (p *TopicQuery) RequestID() []byte
func (*TopicQuery) SetRequestID ¶
func (p *TopicQuery) SetRequestID(id []byte)
type Unknown ¶
type Unknown struct {
Nonce Nonce
}
Unknown represents any packet that can't be decrypted.
func (*Unknown) SetRequestID ¶
type Whoareyou ¶
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.