@cryptotaxi247 / kubo / commits / e681a3aeb

fix: revert changes to the user agent

Go-ipfs user agents usually look like go-ipfs/VERSION/COMMIT_or_EMPTY. However, we changed this to /go-ipfs/VERSION(/COMMIT)? on master for a while. This change reverts this to make parsing the user agent simpler. Co-Authored-By: Oli Evans <oli@tableflip.io>

Steven Allen committed Mar 13, 2020 at 12:22 UTC e681a3aebe0b41dbed90338d70652b860dd9ccb4
2 files changed +41 -1
test/sharness/t0026-id.sh new
+38
@@ -0,0 +1,38 @@
1 +#!/usr/bin/env bash
2 +
3 +test_description="Test to make sure our identity information looks sane"
4 +
5 +. lib/test-lib.sh
6 +
7 +test_init_ipfs
8 +
9 +test_id_compute_agent() {
10 + AGENT_VERSION="$(ipfs version --number)" || return 1
11 + AGENT_COMMIT="$(ipfs version --number --commit)" || return 1
12 + if test "$AGENT_COMMIT" = "$AGENT_VERSION"; then
13 + AGENT_COMMIT=""
14 + else
15 + AGENT_COMMIT="${AGENT_COMMIT##$AGENT_VERSION-}"
16 + fi
17 + echo "go-ipfs/$AGENT_VERSION/$AGENT_COMMIT"
18 +}
19 +
20 +test_expect_success "checking AgentVersion" '
21 + test_id_compute_agent > expected-agent-version &&
22 + ipfs id -f "<aver>\n" > actual-agent-version &&
23 + test_cmp expected-agent-version actual-agent-version
24 +'
25 +
26 +test_expect_success "checking ProtocolVersion" '
27 + echo "ipfs/0.1.0" > expected-protocol-version &&
28 + ipfs id -f "<pver>\n" > actual-protocol-version &&
29 + test_cmp expected-protocol-version actual-protocol-version
30 +'
31 +
32 +test_expect_success "checking ID" '
33 + ipfs config Identity.PeerID > expected-id &&
34 + ipfs id -f "<id>\n" > actual-id &&
35 + test_cmp expected-id actual-id
36 +'
37 +
38 +test_done
version.go
+3 -1
@@ -9,4 +9,6 @@ const CurrentVersionNumber = "0.5.0-dev"
9 const ApiVersion = "/go-ipfs/" + CurrentVersionNumber + "/"
10
11 // UserAgent is the libp2p user agent used by go-ipfs.
12 -var UserAgent = ApiVersion + CurrentCommit
12 +//
13 +// Note: This will end in `/` when no commit is available. This is expected.
14 +var UserAgent = "go-ipfs/" + CurrentVersionNumber + "/" + CurrentCommit