From 6c22bf8ef416fb8be6081d88cd15212f429428a2 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Thu, 4 Apr 2019 14:07:56 -0700 Subject: [PATCH] don't expose "version deps" on the gateway TMI License: MIT Signed-off-by: Steven Allen --- core/commands/root.go | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/core/commands/root.go b/core/commands/root.go index 0b1152348..6a7558dc5 100644 --- a/core/commands/root.go +++ b/core/commands/root.go @@ -160,6 +160,9 @@ var CommandsDaemonROCmd = CommandsCmd(RootRO) // RefsROCmd is `ipfs refs` command var RefsROCmd = &cmds.Command{} +// VersionROCmd is `ipfs version` command (without deps). +var VersionROCmd = &cmds.Command{} + var rootROSubcommands = map[string]*cmds.Command{ "commands": CommandsDaemonROCmd, "cat": CatCmd, @@ -192,24 +195,27 @@ var rootROSubcommands = map[string]*cmds.Command{ }, }, "resolve": ResolveCmd, - "version": VersionCmd, } func init() { Root.ProcessHelp() *RootRO = *Root - // sanitize readonly refs command - *RefsROCmd = *RefsCmd - RefsROCmd.Subcommands = map[string]*cmds.Command{} - // this was in the big map definition above before, // but if we leave it there lgc.NewCommand will be executed // before the value is updated (:/sanitize readonly refs command/) + + // sanitize readonly refs command + *RefsROCmd = *RefsCmd + RefsROCmd.Subcommands = map[string]*cmds.Command{} rootROSubcommands["refs"] = RefsROCmd - Root.Subcommands = rootSubcommands + // sanitize readonly version command (no need to expose precise deps) + *VersionROCmd = *VersionCmd + VersionROCmd.Subcommands = map[string]*cmds.Command{} + rootROSubcommands["version"] = VersionROCmd + Root.Subcommands = rootSubcommands RootRO.Subcommands = rootROSubcommands }