aboutsummaryrefslogtreecommitdiffstats
path: root/p2p/enr/enr.go
diff options
context:
space:
mode:
authorFelix Lange <fjl@twurst.com>2019-06-07 21:31:00 +0800
committerGitHub <noreply@github.com>2019-06-07 21:31:00 +0800
commite83c3ccc47b2001b7871b60084d10c5f861c9c93 (patch)
tree54014c38b9cab361d2194304b19d2f51c11d7cda /p2p/enr/enr.go
parent896322bf88f40329b400d691cbdce9275739310e (diff)
downloadgo-tangerine-e83c3ccc47b2001b7871b60084d10c5f861c9c93.tar
go-tangerine-e83c3ccc47b2001b7871b60084d10c5f861c9c93.tar.gz
go-tangerine-e83c3ccc47b2001b7871b60084d10c5f861c9c93.tar.bz2
go-tangerine-e83c3ccc47b2001b7871b60084d10c5f861c9c93.tar.lz
go-tangerine-e83c3ccc47b2001b7871b60084d10c5f861c9c93.tar.xz
go-tangerine-e83c3ccc47b2001b7871b60084d10c5f861c9c93.tar.zst
go-tangerine-e83c3ccc47b2001b7871b60084d10c5f861c9c93.zip
p2p/enode: improve IPv6 support, add ENR text representation (#19663)
* p2p/enr: add entries for for IPv4/IPv6 separation This adds entry types for "ip6", "udp6", "tcp6" keys. The IP type stays around because removing it would break a lot of code and force everyone to care about the distinction. * p2p/enode: track IPv4 and IPv6 address separately LocalNode predicts the local node's UDP endpoint and updates the record. This change makes it predict IPv4 and IPv6 endpoints separately since they can now be in the record at the same time. * p2p/enode: implement base64 text format * all: switch to enode.Parse(...) This allows passing base64-encoded node records to all the places that previously accepted enode:// URLs. The URL format is still supported. * cmd/bootnode, p2p: log node URL instead of ENR ...and return the base64 record in NodeInfo.
Diffstat (limited to 'p2p/enr/enr.go')
-rw-r--r--p2p/enr/enr.go12
1 files changed, 11 insertions, 1 deletions
diff --git a/p2p/enr/enr.go b/p2p/enr/enr.go
index 444820c15..c36ae9e3e 100644
--- a/p2p/enr/enr.go
+++ b/p2p/enr/enr.go
@@ -163,6 +163,16 @@ func (r *Record) invalidate() {
r.raw = nil
}
+// Signature returns the signature of the record.
+func (r *Record) Signature() []byte {
+ if r.signature == nil {
+ return nil
+ }
+ cpy := make([]byte, len(r.signature))
+ copy(cpy, r.signature)
+ return cpy
+}
+
// EncodeRLP implements rlp.Encoder. Encoding fails if
// the record is unsigned.
func (r Record) EncodeRLP(w io.Writer) error {
@@ -173,7 +183,7 @@ func (r Record) EncodeRLP(w io.Writer) error {
return err
}
-// DecodeRLP implements rlp.Decoder. Decoding verifies the signature.
+// DecodeRLP implements rlp.Decoder. Decoding doesn't verify the signature.
func (r *Record) DecodeRLP(s *rlp.Stream) error {
dec, raw, err := decodeRecord(s)
if err != nil {