From 400da0a636b36e6d54d20016cf0f916ce38e680e Mon Sep 17 00:00:00 2001 From: Henrique Dias Date: Tue, 12 Dec 2023 14:20:08 +0100 Subject: [PATCH] commands: remove deprecated 'dns' --- core/commands/dns.go | 78 --------------------------------- core/commands/root.go | 2 - test/cli/basic_commands_test.go | 1 - 3 files changed, 81 deletions(-) delete mode 100644 core/commands/dns.go diff --git a/core/commands/dns.go b/core/commands/dns.go deleted file mode 100644 index 065b4acdc9af..000000000000 --- a/core/commands/dns.go +++ /dev/null @@ -1,78 +0,0 @@ -package commands - -import ( - "fmt" - "io" - "strings" - - namesys "github.com/ipfs/boxo/namesys" - "github.com/ipfs/boxo/path" - cmdenv "github.com/ipfs/kubo/core/commands/cmdenv" - ncmd "github.com/ipfs/kubo/core/commands/name" - - cmds "github.com/ipfs/go-ipfs-cmds" -) - -const ( - dnsRecursiveOptionName = "recursive" -) - -var DNSCmd = &cmds.Command{ - Status: cmds.Deprecated, // https://github.com/ipfs/kubo/issues/8607 - Helptext: cmds.HelpText{ - Tagline: "Resolve DNSLink records. Deprecated: Use 'ipfs resolve /ipns/domain-name' instead.", - ShortDescription: ` -This command can only recursively resolve DNSLink TXT records. -It will fail to recursively resolve through IPNS keys etc. - -DEPRECATED: superseded by 'ipfs resolve' - -For general-purpose recursive resolution, use 'ipfs resolve -r'. -It will work across multiple DNSLinks and IPNS keys. -`, - }, - - Arguments: []cmds.Argument{ - cmds.StringArg("domain-name", true, false, "The domain-name name to resolve.").EnableStdin(), - }, - Options: []cmds.Option{ - cmds.BoolOption(dnsRecursiveOptionName, "r", "Resolve until the result is not a DNS link.").WithDefault(true), - }, - Run: func(req *cmds.Request, res cmds.ResponseEmitter, env cmds.Environment) error { - node, err := cmdenv.GetNode(env) - if err != nil { - return err - } - - recursive, _ := req.Options[dnsRecursiveOptionName].(bool) - name := req.Arguments[0] - resolver := namesys.NewDNSResolver(node.DNSResolver.LookupTXT) - - var routing []namesys.ResolveOption - if !recursive { - routing = append(routing, namesys.ResolveWithDepth(1)) - } - - if !strings.HasPrefix(name, "/ipns/") { - name = "/ipns/" + name - } - - p, err := path.NewPath(name) - if err != nil { - return err - } - - val, err := resolver.Resolve(req.Context, p, routing...) - if err != nil && (recursive || err != namesys.ErrResolveRecursion) { - return err - } - return cmds.EmitOnce(res, &ncmd.ResolvedPath{Path: val.Path.String()}) - }, - Encoders: cmds.EncoderMap{ - cmds.Text: cmds.MakeTypedEncoder(func(req *cmds.Request, w io.Writer, out *ncmd.ResolvedPath) error { - fmt.Fprintln(w, cmdenv.EscNonPrint(out.Path)) - return nil - }), - }, - Type: ncmd.ResolvedPath{}, -} diff --git a/core/commands/root.go b/core/commands/root.go index da290c5b6ef3..ea8782b29ff3 100644 --- a/core/commands/root.go +++ b/core/commands/root.go @@ -143,7 +143,6 @@ var rootSubcommands = map[string]*cmds.Command{ "dht": DhtCmd, "routing": RoutingCmd, "diag": DiagCmd, - "dns": DNSCmd, "id": IDCmd, "key": KeyCmd, "log": LogCmd, @@ -186,7 +185,6 @@ var rootROSubcommands = map[string]*cmds.Command{ }, }, "get": GetCmd, - "dns": DNSCmd, "ls": LsCmd, "name": { Subcommands: map[string]*cmds.Command{ diff --git a/test/cli/basic_commands_test.go b/test/cli/basic_commands_test.go index 27baafd3e5cf..6557b040388f 100644 --- a/test/cli/basic_commands_test.go +++ b/test/cli/basic_commands_test.go @@ -116,7 +116,6 @@ func TestAllRootCommandsAreMentionedInHelpText(t *testing.T) { notInHelp := map[string]bool{ "object": true, "shutdown": true, - "dns": true, } helpMsg := strings.TrimSpace(node.IPFS("--help").Stdout.String())