Skip to content

Commit

Permalink
p2p-proxy: earlier peerID validation check
Browse files Browse the repository at this point in the history
  • Loading branch information
aschmahmann committed Dec 1, 2020
1 parent a329e4f commit 68e19dc
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions core/corehttp/p2p_proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"strings"

core "github.com/ipfs/go-ipfs/core"
peer "github.com/libp2p/go-libp2p-core/peer"

protocol "github.com/libp2p/go-libp2p-core/protocol"
p2phttp "github.com/libp2p/go-libp2p-http"
Expand Down Expand Up @@ -60,6 +61,10 @@ func parseRequest(request *http.Request) (*proxyRequest, error) {
return nil, fmt.Errorf("Invalid request path '%s'", path)
}

if _, err := peer.Decode(split[2]); err != nil {
return nil, fmt.Errorf("Invalid request path '%s'", path)
}

if split[3] == "http" {
return &proxyRequest{split[2], protocol.ID("/http"), split[4]}, nil
}
Expand Down

0 comments on commit 68e19dc

Please sign in to comment.