From 1dc65dfaf5a589020407e652a96e487ce9236b95 Mon Sep 17 00:00:00 2001 From: Linus Gasser Date: Wed, 14 Aug 2024 11:48:04 +0200 Subject: [PATCH] Use peer.ID.Validate --- Makefile | 4 ++-- go.mod | 2 +- mino/minows/address.go | 10 ++++++++-- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index b317bcc3..1364f4c5 100644 --- a/Makefile +++ b/Makefile @@ -14,7 +14,7 @@ generate: tidy # Some packages are excluded from staticcheck due to deprecated warnings: #208. lint: tidy # Coding style static check. - @go install honnef.co/go/tools/cmd/staticcheck@latest + @go install honnef.co/go/tools/cmd/staticcheck@v0.4.7 staticcheck `go list ./... | grep -Ev "(go\.dedis\.ch/dela/internal/testing|go\.dedis\.ch/dela/mino/minogrpc/ptypes)"` vet: tidy @@ -54,4 +54,4 @@ coverage: tidy pushdoc: @echo "Requesting the proxy..." @curl "https://proxy.golang.org/go.dedis.ch/dela/@v/$(shell git log origin/master -1 --format=format:%H).info" - @echo "\nDone." \ No newline at end of file + @echo "\nDone." diff --git a/go.mod b/go.mod index 4b7a349a..67e1249d 100644 --- a/go.mod +++ b/go.mod @@ -5,6 +5,7 @@ go 1.21 require ( github.com/golang/protobuf v1.5.4 github.com/libp2p/go-libp2p v0.36.1 + github.com/libp2p/go-yamux/v4 v4.0.1 github.com/multiformats/go-multiaddr v0.13.0 github.com/opentracing-contrib/go-grpc v0.0.0-20210225150812-73cb765af46e github.com/opentracing/opentracing-go v1.2.0 @@ -62,7 +63,6 @@ require ( github.com/libp2p/go-nat v0.2.0 // indirect github.com/libp2p/go-netroute v0.2.1 // indirect github.com/libp2p/go-reuseport v0.4.0 // indirect - github.com/libp2p/go-yamux/v4 v4.0.1 // indirect github.com/marten-seemann/tcp v0.0.0-20210406111302-dfbc87cc63fd // indirect github.com/mattn/go-colorable v0.1.13 // indirect github.com/mattn/go-isatty v0.0.20 // indirect diff --git a/mino/minows/address.go b/mino/minows/address.go index d23f5cbc..1d1a0cc6 100644 --- a/mino/minows/address.go +++ b/mino/minows/address.go @@ -25,9 +25,15 @@ type address struct { // newAddress creates a new address from a publicly reachable location with a // peer identity. func newAddress(location ma.Multiaddr, identity peer.ID) (address, error) { - if location == nil || identity.String() == "" { - return address{}, xerrors.New("address must have location and identity") + if location == nil { + return address{}, xerrors.New("address must have a location") } + + err := identity.Validate() + if err != nil { + return address{}, xerrors.Errorf("address must have a valid identity: %v", err) + } + return address{ location: location, identity: identity,