Skip to content

Commit 305282b

Browse files
identify: don't send default protocol version (libp2p#2303)
1 parent 01651d2 commit 305282b

File tree

2 files changed

+7
-22
lines changed

2 files changed

+7
-22
lines changed

p2p/protocol/identify/id.go

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,6 @@ const (
4242
IDPush = "/ipfs/id/push/1.0.0"
4343
)
4444

45-
const DefaultProtocolVersion = "ipfs/0.1.0"
46-
4745
const ServiceName = "libp2p.identify"
4846

4947
const maxPushConcurrency = 32
@@ -189,16 +187,11 @@ func NewIDService(h host.Host, opts ...Option) (*idService, error) {
189187
userAgent = cfg.userAgent
190188
}
191189

192-
protocolVersion := DefaultProtocolVersion
193-
if cfg.protocolVersion != "" {
194-
protocolVersion = cfg.protocolVersion
195-
}
196-
197190
ctx, cancel := context.WithCancel(context.Background())
198191
s := &idService{
199192
Host: h,
200193
UserAgent: userAgent,
201-
ProtocolVersion: protocolVersion,
194+
ProtocolVersion: cfg.protocolVersion,
202195
ctx: ctx,
203196
ctxCancel: cancel,
204197
conns: make(map[network.Conn]entry),

p2p/protocol/identify/id_test.go

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -69,16 +69,8 @@ func testHasCertifiedAddrs(t *testing.T, h host.Host, p peer.ID, expected []ma.M
6969
require.True(t, assert.ElementsMatchf(t, expected, rec.Addrs, fmt.Sprintf("%s did not have certified addr for %s", h.ID(), p)))
7070
}
7171

72-
func testHasProtocolVersions(t *testing.T, h host.Host, p peer.ID) {
73-
v, err := h.Peerstore().Get(p, "ProtocolVersion")
74-
if v == nil {
75-
t.Error("no protocol version")
76-
return
77-
}
78-
if v.(string) != identify.DefaultProtocolVersion {
79-
t.Error("protocol mismatch", err)
80-
}
81-
v, err = h.Peerstore().Get(p, "AgentVersion")
72+
func testHasAgentVersion(t *testing.T, h host.Host, p peer.ID) {
73+
v, err := h.Peerstore().Get(p, "AgentVersion")
8274
if v.(string) != "github.com/libp2p/go-libp2p" { // this is the default user agent
8375
t.Error("agent version mismatch", err)
8476
}
@@ -201,7 +193,7 @@ func TestIDService(t *testing.T) {
201193
t.Log("test peer1 has peer2 addrs correctly")
202194
testKnowsAddrs(t, h1, h2p, h2.Addrs()) // has them
203195
testHasCertifiedAddrs(t, h1, h2p, h2.Peerstore().Addrs(h2p)) // should have signed addrs also
204-
testHasProtocolVersions(t, h1, h2p)
196+
testHasAgentVersion(t, h1, h2p)
205197
testHasPublicKey(t, h1, h2p, h2.Peerstore().PubKey(h2p)) // h1 should have h2's public key
206198

207199
// now, this wait we do have to do. it's the wait for the Listening side
@@ -214,7 +206,7 @@ func TestIDService(t *testing.T) {
214206
t.Log("test peer2 has peer1 addrs correctly")
215207
testKnowsAddrs(t, h2, h1p, h1.Addrs()) // has them
216208
testHasCertifiedAddrs(t, h2, h1p, h1.Peerstore().Addrs(h1p))
217-
testHasProtocolVersions(t, h2, h1p)
209+
testHasAgentVersion(t, h2, h1p)
218210
testHasPublicKey(t, h2, h1p, h1.Peerstore().PubKey(h1p)) // h1 should have h2's public key
219211

220212
// Need both sides to actually notice that the connection has been closed.
@@ -670,7 +662,7 @@ func TestLargeIdentifyMessage(t *testing.T) {
670662
t.Log("test peer1 has peer2 addrs correctly")
671663
testKnowsAddrs(t, h1, h2p, h2.Addrs()) // has them
672664
testHasCertifiedAddrs(t, h1, h2p, h2.Peerstore().Addrs(h2p)) // should have signed addrs also
673-
testHasProtocolVersions(t, h1, h2p)
665+
testHasAgentVersion(t, h1, h2p)
674666
testHasPublicKey(t, h1, h2p, h2.Peerstore().PubKey(h2p)) // h1 should have h2's public key
675667

676668
// now, this wait we do have to do. it's the wait for the Listening side
@@ -685,7 +677,7 @@ func TestLargeIdentifyMessage(t *testing.T) {
685677
t.Log("test peer2 has peer1 addrs correctly")
686678
testKnowsAddrs(t, h2, h1p, h1.Addrs()) // has them
687679
testHasCertifiedAddrs(t, h2, h1p, h1.Peerstore().Addrs(h1p))
688-
testHasProtocolVersions(t, h2, h1p)
680+
testHasAgentVersion(t, h2, h1p)
689681
testHasPublicKey(t, h2, h1p, h1.Peerstore().PubKey(h1p)) // h1 should have h2's public key
690682

691683
// Need both sides to actually notice that the connection has been closed.

0 commit comments

Comments
 (0)