Commit dd7868a1 authored by Steven Allen's avatar Steven Allen
Browse files

don't disconnect on protocol version mismatch

Sending a protocol version is nice. However, this "disconnect if our versions
are different" logic makes the version entirely useless (because we can't change
it).

Really, each indevidual protocol is versioned so let's just leave it at that. If
we make a breaking change that requires a protocol bump, we can do that and
then switch on the other side's version. However, we'll have to wait for the
entire network to upgrade for that to work.
parent 11bd3221
...@@ -2,12 +2,10 @@ package identify ...@@ -2,12 +2,10 @@ package identify
import ( import (
"context" "context"
"strings"
"sync" "sync"
pb "github.com/libp2p/go-libp2p/p2p/protocol/identify/pb" pb "github.com/libp2p/go-libp2p/p2p/protocol/identify/pb"
semver "github.com/coreos/go-semver/semver"
ggio "github.com/gogo/protobuf/io" ggio "github.com/gogo/protobuf/io"
logging "github.com/ipfs/go-log" logging "github.com/ipfs/go-log"
ic "github.com/libp2p/go-libp2p-crypto" ic "github.com/libp2p/go-libp2p-crypto"
...@@ -225,15 +223,6 @@ func (ids *IDService) consumeMessage(mes *pb.Identify, c inet.Conn) { ...@@ -225,15 +223,6 @@ func (ids *IDService) consumeMessage(mes *pb.Identify, c inet.Conn) {
pv := mes.GetProtocolVersion() pv := mes.GetProtocolVersion()
av := mes.GetAgentVersion() 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, "ProtocolVersion", pv)
ids.Host.Peerstore().Put(p, "AgentVersion", av) ids.Host.Peerstore().Put(p, "AgentVersion", av)
...@@ -406,31 +395,6 @@ func addrInAddrs(a ma.Multiaddr, as []ma.Multiaddr) bool { ...@@ -406,31 +395,6 @@ func addrInAddrs(a ma.Multiaddr, as []ma.Multiaddr) bool {
return false 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 // netNotifiee defines methods to be used with the IpfsDHT
type netNotifiee IDService type netNotifiee IDService
......
...@@ -8,11 +8,6 @@ ...@@ -8,11 +8,6 @@
"goversion": "1.5.2" "goversion": "1.5.2"
}, },
"gxDependencies": [ "gxDependencies": [
{
"hash": "QmcrrEpx3VMUbrbgVroH3YiYyUS5c4YAykzyPJWKspUYLa",
"name": "go-semver",
"version": "0.0.0"
},
{ {
"hash": "QmekaTKpWkYGcn4ZEC5PwJDRCQHapwugmmG86g2Xpz5GBH", "hash": "QmekaTKpWkYGcn4ZEC5PwJDRCQHapwugmmG86g2Xpz5GBH",
"name": "mdns", "name": "mdns",
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment