Skip to content

Commit

Permalink
chore: fix deprecation warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
Stebalien committed Sep 26, 2019
1 parent 9ee4adf commit 853ed0b
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 10 deletions.
3 changes: 2 additions & 1 deletion core/commands/id.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"io"
"strings"

version "github.com/ipfs/go-ipfs"
core "github.com/ipfs/go-ipfs/core"
cmdenv "github.com/ipfs/go-ipfs/core/commands/cmdenv"

Expand Down Expand Up @@ -189,6 +190,6 @@ func printSelf(node *core.IpfsNode) (interface{}, error) {
}
}
info.ProtocolVersion = identify.LibP2PVersion
info.AgentVersion = identify.ClientVersion
info.AgentVersion = version.UserAgent
return info, nil
}
7 changes: 0 additions & 7 deletions core/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,8 @@ package core
import (
"context"
"io"
"path"

"github.com/ipfs/go-filestore"
version "github.com/ipfs/go-ipfs"
"github.com/ipfs/go-ipfs/core/bootstrap"
"github.com/ipfs/go-ipfs/core/node"
"github.com/ipfs/go-ipfs/core/node/libp2p"
Expand Down Expand Up @@ -49,15 +47,10 @@ import (
record "github.com/libp2p/go-libp2p-record"
"github.com/libp2p/go-libp2p/p2p/discovery"
p2pbhost "github.com/libp2p/go-libp2p/p2p/host/basic"
"github.com/libp2p/go-libp2p/p2p/protocol/identify"
)

var log = logging.Logger("core")

func init() {
identify.ClientVersion = path.Join("go-ipfs", version.CurrentVersionNumber, version.CurrentCommit)
}

// IpfsNode is IPFS Core module. It represents an IPFS instance.
type IpfsNode struct {

Expand Down
2 changes: 1 addition & 1 deletion core/corehttp/gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ func VersionOption() ServeOption {
return func(_ *core.IpfsNode, _ net.Listener, mux *http.ServeMux) (*http.ServeMux, error) {
mux.HandleFunc("/version", func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "Commit: %s\n", version.CurrentCommit)
fmt.Fprintf(w, "Client Version: %s\n", id.ClientVersion)
fmt.Fprintf(w, "Client Version: %s\n", version.UserAgent)
fmt.Fprintf(w, "Protocol Version: %s\n", id.LibP2PVersion)
})
return mux, nil
Expand Down
2 changes: 1 addition & 1 deletion core/corehttp/gateway_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,7 @@ func TestVersion(t *testing.T) {
t.Fatalf("response doesn't contain commit:\n%s", s)
}

if !strings.Contains(s, "Client Version: "+id.ClientVersion) {
if !strings.Contains(s, "Client Version: "+version.UserAgent) {
t.Fatalf("response doesn't contain client version:\n%s", s)
}

Expand Down
1 change: 1 addition & 0 deletions core/node/groups.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
)

var BaseLibP2P = fx.Options(
fx.Provide(libp2p.UserAgent),
fx.Provide(libp2p.PNet),
fx.Provide(libp2p.ConnectionManager),
fx.Provide(libp2p.DefaultTransports),
Expand Down
4 changes: 4 additions & 0 deletions core/node/libp2p/libp2p.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package libp2p
import (
"time"

version "github.com/ipfs/go-ipfs"

logging "github.com/ipfs/go-log"
"github.com/libp2p/go-libp2p"
"github.com/libp2p/go-libp2p-connmgr"
Expand All @@ -22,6 +24,8 @@ type Libp2pOpts struct {

// Misc options

var UserAgent = simpleOpt(libp2p.UserAgent(version.UserAgent))

func ConnectionManager(low, high int, grace time.Duration) func() (opts Libp2pOpts, err error) {
return func() (opts Libp2pOpts, err error) {
cm := connmgr.NewConnManager(low, high, grace)
Expand Down
3 changes: 3 additions & 0 deletions version.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@ var CurrentCommit string
const CurrentVersionNumber = "0.5.0-dev"

const ApiVersion = "/go-ipfs/" + CurrentVersionNumber + "/"

// UserAgent is the libp2p user agent used by go-ipfs.
var UserAgent = ApiVersion + CurrentCommit

0 comments on commit 853ed0b

Please sign in to comment.