From 65a77e8db3f67166b4d55499c021e4c04301178b Mon Sep 17 00:00:00 2001 From: Marcin Rataj Date: Wed, 6 Jul 2022 20:16:02 +0200 Subject: [PATCH] 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 was moved from ipfs/kubo@9dbc9dfeb2ed47b6aae4bb1d78c637df96fc53c4 --- gateway/core/corehttp/commands.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/gateway/core/corehttp/commands.go b/gateway/core/corehttp/commands.go index b433dfea7..c0ebf5506 100644 --- a/gateway/core/corehttp/commands.go +++ b/gateway/core/corehttp/commands.go @@ -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 }