Skip to content

Commit

Permalink
set a default client-version using go modules
Browse files Browse the repository at this point in the history
This should help us improve network stats on who's using libp2p.
  • Loading branch information
Stebalien committed Aug 13, 2019
1 parent f4e778d commit 009eeba
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion p2p/protocol/identify/id.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package identify

import (
"context"
"fmt"
"runtime/debug"
"sync"
"time"

Expand Down Expand Up @@ -31,9 +33,27 @@ const ID = "/ipfs/id/1.0.0"

// LibP2PVersion holds the current protocol version for a client running this code
// TODO(jbenet): fix the versioning mess.
// XXX: Don't change this till 2020. You'll break all go-ipfs versions prior to
// 0.4.17 which asserted an exact version match.
const LibP2PVersion = "ipfs/0.1.0"

var ClientVersion = "go-libp2p/3.3.4"
// ClientVersion is the default user agent.
//
// Deprecated: Set this with the UserAgent option.
var ClientVersion = "github.com/libp2p/go-libp2p"

func init() {
bi, ok := debug.ReadBuildInfo()
if !ok {
return
}
version := bi.Main.Version
if version == "(devel)" {
ClientVersion = bi.Main.Path
} else {
ClientVersion = fmt.Sprintf("%s@%s", bi.Main.Path, bi.Main.Version)
}
}

// transientTTL is a short ttl for invalidated previously connected addrs
const transientTTL = 10 * time.Second
Expand Down

0 comments on commit 009eeba

Please sign in to comment.