|
|
|
@ -300,7 +300,7 @@ func (c *Codec) encodeWhoareyou(toID enode.ID, packet *Whoareyou) (Header, error |
|
|
|
|
return head, nil |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// encodeHandshakeMessage encodes the handshake message packet header.
|
|
|
|
|
// encodeHandshakeHeader encodes the handshake message packet header.
|
|
|
|
|
func (c *Codec) encodeHandshakeHeader(toID enode.ID, addr string, challenge *Whoareyou) (Header, *session, error) { |
|
|
|
|
// Ensure calling code sets challenge.node.
|
|
|
|
|
if challenge.Node == nil { |
|
|
|
@ -337,7 +337,7 @@ func (c *Codec) encodeHandshakeHeader(toID enode.ID, addr string, challenge *Who |
|
|
|
|
return head, session, err |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// encodeAuthHeader creates the auth header on a request packet following WHOAREYOU.
|
|
|
|
|
// makeHandshakeAuth creates the auth header on a request packet following WHOAREYOU.
|
|
|
|
|
func (c *Codec) makeHandshakeAuth(toID enode.ID, addr string, challenge *Whoareyou) (*handshakeAuthData, *session, error) { |
|
|
|
|
auth := new(handshakeAuthData) |
|
|
|
|
auth.h.SrcID = c.localnode.ID() |
|
|
|
@ -379,7 +379,7 @@ func (c *Codec) makeHandshakeAuth(toID enode.ID, addr string, challenge *Whoarey |
|
|
|
|
return auth, sec, err |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// encodeMessage encodes an encrypted message packet.
|
|
|
|
|
// encodeMessageHeader encodes an encrypted message packet.
|
|
|
|
|
func (c *Codec) encodeMessageHeader(toID enode.ID, s *session) (Header, error) { |
|
|
|
|
head := c.makeHeader(toID, flagMessage, 0) |
|
|
|
|
|
|
|
|
@ -632,7 +632,7 @@ func (h *StaticHeader) checkValid(packetLen int) error { |
|
|
|
|
return nil |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// headerMask returns a cipher for 'masking' / 'unmasking' packet headers.
|
|
|
|
|
// mask returns a cipher for 'masking' / 'unmasking' packet headers.
|
|
|
|
|
func (h *Header) mask(destID enode.ID) cipher.Stream { |
|
|
|
|
block, err := aes.NewCipher(destID[:16]) |
|
|
|
|
if err != nil { |
|
|
|
|