mirror of
https://github.com/ipfs/kubo.git
synced 2026-02-21 18:37:45 +08:00
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:
parent
e5f63393ff
commit
9dbc9dfeb2
@ -2,7 +2,7 @@
|
||||
|
||||
> the oldest IPFS implementation, previously known as "go-ipfs"
|
||||
|
||||

|
||||

|
||||
|
||||
[](https://protocol.ai)
|
||||
[](https://godoc.org/github.com/ipfs/kubo)
|
||||
|
||||
@ -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
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user