Skip to content

Commit

Permalink
fix(cmds): use kubo in CheckVersionOption
Browse files Browse the repository at this point in the history
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@9dbc9df
  • Loading branch information
lidel committed Jul 6, 2022
1 parent 1826a07 commit 65a77e8
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions gateway/core/corehttp/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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

Expand All @@ -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
}
Expand Down

0 comments on commit 65a77e8

Please sign in to comment.