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
This commit is contained in:
Marcin Rataj 2022-07-06 20:16:02 +02:00
parent e5f63393ff
commit 9dbc9dfeb2
2 changed files with 5 additions and 5 deletions

View File

@ -2,7 +2,7 @@
> the oldest IPFS implementation, previously known as "go-ipfs"
![kubo](https://user-images.githubusercontent.com/157609/167471494-dee3a355-b551-4fbf-98e0-2eb76e867b48.png)
![kubo, an IPFS node in Go](https://ipfs.io/ipfs/bafykbzacecaesuqmivkauix25v6i6xxxsvsrtxknhgb5zak3xxsg2nb4dhs2u/ipfs.go.png)
[![](https://img.shields.io/badge/made%20by-Protocol%20Labs-blue.svg?style=flat-square&cacheSeconds=3600)](https://protocol.ai)
[![GoDoc](https://img.shields.io/badge/godoc-reference-5272B4.svg?style=flat-square&cacheSeconds=3600)](https://godoc.org/github.com/ipfs/kubo)

View File

@ -85,7 +85,7 @@ func addHeadersFromConfig(c *cmdsHttp.ServerConfig, nc *config.Config) {
c.Headers[h] = v
}
}
c.Headers["Server"] = []string{"go-ipfs/" + version.CurrentVersionNumber}
c.Headers["Server"] = []string{"kubo/" + version.CurrentVersionNumber}
}
func addCORSDefaults(c *cmdsHttp.ServerConfig) {
@ -163,7 +163,7 @@ func CommandsROOption(cctx oldcmds.Context) ServeOption {
return commandsOption(cctx, corecommands.RootRO, true)
}
// CheckVersionOption returns a ServeOption that checks whether the client ipfs version matches. Does nothing when the user agent string does not contain `/go-ipfs/`
// 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/`
func CheckVersionOption() ServeOption {
daemonVersion := version.ApiVersion
@ -177,8 +177,8 @@ func CheckVersionOption() ServeOption {
// backwards compatibility to previous version check
if len(pth) >= 2 && pth[1] != "version" {
clientVersion := r.UserAgent()
// skips check if client is not go-ipfs
if strings.Contains(clientVersion, "/go-ipfs/") && daemonVersion != clientVersion {
// skips check if client is not kubo (go-ipfs)
if (strings.Contains(clientVersion, "/go-ipfs/") || strings.Contains(clientVersion, "/kubo/")) && daemonVersion != clientVersion {
http.Error(w, fmt.Sprintf("%s (%s != %s)", errAPIVersionMismatch, daemonVersion, clientVersion), http.StatusBadRequest)
return
}