Skip to content

don't disconnect on protocol version mismatch #461

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 24, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 0 additions & 36 deletions p2p/protocol/identify/id.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@ package identify

import (
"context"
"strings"
"sync"

pb "github.com/libp2p/go-libp2p/p2p/protocol/identify/pb"

semver "github.com/coreos/go-semver/semver"
ggio "github.com/gogo/protobuf/io"
logging "github.com/ipfs/go-log"
ic "github.com/libp2p/go-libp2p-crypto"
Expand Down Expand Up @@ -225,15 +223,6 @@ func (ids *IDService) consumeMessage(mes *pb.Identify, c inet.Conn) {
pv := mes.GetProtocolVersion()
av := mes.GetAgentVersion()

// version check. if we shouldn't talk, bail.
// TODO: at this point, we've already exchanged information.
// move this into a first handshake before the connection can open streams.
if !protocolVersionsAreCompatible(pv, LibP2PVersion) {
logProtocolMismatchDisconnect(c, pv, av)
c.Close()
return
}

ids.Host.Peerstore().Put(p, "ProtocolVersion", pv)
ids.Host.Peerstore().Put(p, "AgentVersion", av)

Expand Down Expand Up @@ -406,31 +395,6 @@ func addrInAddrs(a ma.Multiaddr, as []ma.Multiaddr) bool {
return false
}

// protocolVersionsAreCompatible checks that the two implementations
// can talk to each other. It will use semver, but for now while
// we're in tight development, we will return false for minor version
// changes too.
func protocolVersionsAreCompatible(v1, v2 string) bool {
if strings.HasPrefix(v1, "ipfs/") {
v1 = v1[5:]
}
if strings.HasPrefix(v2, "ipfs/") {
v2 = v2[5:]
}

v1s, err := semver.NewVersion(v1)
if err != nil {
return false
}

v2s, err := semver.NewVersion(v2)
if err != nil {
return false
}

return v1s.Major == v2s.Major && v1s.Minor == v2s.Minor
}

// netNotifiee defines methods to be used with the IpfsDHT
type netNotifiee IDService

Expand Down
5 changes: 0 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,6 @@
"goversion": "1.5.2"
},
"gxDependencies": [
{
"hash": "QmcrrEpx3VMUbrbgVroH3YiYyUS5c4YAykzyPJWKspUYLa",
"name": "go-semver",
"version": "0.0.0"
},
{
"hash": "QmekaTKpWkYGcn4ZEC5PwJDRCQHapwugmmG86g2Xpz5GBH",
"name": "mdns",
Expand Down