@cryptotaxi247 / kubo / commits / 9dbc9dfeb

fix(cmds): use kubo in CheckVersionOption

Using both names to avoid dev problems during the transition from go-ipfs 0.13 to kubo 0.14

Marcin Rataj committed Jul 6, 2022 at 20:16 UTC 9dbc9dfeb2ed47b6aae4bb1d78c637df96fc53c4
2 files changed +5 -5
README.md
+1 -1
@@ -2,7 +2,7 @@
2
3 > the oldest IPFS implementation, previously known as "go-ipfs"
4
5 -![kubo](https://user-images.githubusercontent.com/157609/167471494-dee3a355-b551-4fbf-98e0-2eb76e867b48.png)
5 +![kubo, an IPFS node in Go](https://ipfs.io/ipfs/bafykbzacecaesuqmivkauix25v6i6xxxsvsrtxknhgb5zak3xxsg2nb4dhs2u/ipfs.go.png)
6
7 [![](https://img.shields.io/badge/made%20by-Protocol%20Labs-blue.svg?style=flat-square&cacheSeconds=3600)](https://protocol.ai)
8 [![GoDoc](https://img.shields.io/badge/godoc-reference-5272B4.svg?style=flat-square&cacheSeconds=3600)](https://godoc.org/github.com/ipfs/kubo)
core/corehttp/commands.go
+4 -4
@@ -85,7 +85,7 @@ func addHeadersFromConfig(c *cmdsHttp.ServerConfig, nc *config.Config) {
85 c.Headers[h] = v
86 }
87 }
88 - c.Headers["Server"] = []string{"go-ipfs/" + version.CurrentVersionNumber}
88 + c.Headers["Server"] = []string{"kubo/" + version.CurrentVersionNumber}
89 }
90
91 func addCORSDefaults(c *cmdsHttp.ServerConfig) {
@@ -163,7 +163,7 @@ func CommandsROOption(cctx oldcmds.Context) ServeOption {
163 return commandsOption(cctx, corecommands.RootRO, true)
164 }
165
166 -// CheckVersionOption returns a ServeOption that checks whether the client ipfs version matches. Does nothing when the user agent string does not contain `/go-ipfs/`
166 +// CheckVersionOption returns a ServeOption that checks whether the client ipfs version matches. Does nothing when the user agent string does not contain `/kubo/` or `/go-ipfs/`
167 func CheckVersionOption() ServeOption {
168 daemonVersion := version.ApiVersion
169
@@ -177,8 +177,8 @@ func CheckVersionOption() ServeOption {
177 // backwards compatibility to previous version check
178 if len(pth) >= 2 && pth[1] != "version" {
179 clientVersion := r.UserAgent()
180 - // skips check if client is not go-ipfs
181 - if strings.Contains(clientVersion, "/go-ipfs/") && daemonVersion != clientVersion {
180 + // skips check if client is not kubo (go-ipfs)
181 + if (strings.Contains(clientVersion, "/go-ipfs/") || strings.Contains(clientVersion, "/kubo/")) && daemonVersion != clientVersion {
182 http.Error(w, fmt.Sprintf("%s (%s != %s)", errAPIVersionMismatch, daemonVersion, clientVersion), http.StatusBadRequest)
183 return
184 }