Skip to content

Commit

Permalink
shell: Fixed dns resolve and browse commands (#13451)
Browse files Browse the repository at this point in the history
Currently the dns resolve and dns browse commands don't work,
as after adding ResolverProxy the shell Dns module uses wrong
Resolver instance and operations fail due to delegate set to null.

Utilized ResolverProxy instead of Resolve Instace().
  • Loading branch information
kkasperczyk-no authored and pull[bot] committed May 17, 2022
1 parent 981a888 commit 3449188
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/lib/shell/commands/Dns.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include <lib/core/PeerId.h>
#include <lib/dnssd/Advertiser.h>
#include <lib/dnssd/Resolver.h>
#include <lib/dnssd/ResolverProxy.h>
#include <lib/dnssd/platform/Dnssd.h>
#include <lib/shell/Commands.h>
#include <lib/shell/Engine.h>
Expand Down Expand Up @@ -113,6 +114,7 @@ class DnsShellResolverDelegate : public Dnssd::ResolverDelegate
};

DnsShellResolverDelegate sDnsShellResolverDelegate;
Dnssd::ResolverProxy sResolverProxy;

CHIP_ERROR ResolveHandler(int argc, char ** argv)
{
Expand All @@ -124,7 +126,7 @@ CHIP_ERROR ResolveHandler(int argc, char ** argv)
peerId.SetCompressedFabricId(strtoull(argv[0], NULL, 10));
peerId.SetNodeId(strtoull(argv[1], NULL, 10));

return Dnssd::Resolver::Instance().ResolveNodeId(peerId, Inet::IPAddressType::kAny, Dnssd::Resolver::CacheBypass::On);
return sResolverProxy.ResolveNodeId(peerId, Inet::IPAddressType::kAny, Dnssd::Resolver::CacheBypass::On);
}

bool ParseSubType(int argc, char ** argv, Dnssd::DiscoveryFilter & filter)
Expand Down Expand Up @@ -184,7 +186,7 @@ CHIP_ERROR BrowseCommissionableHandler(int argc, char ** argv)

streamer_printf(streamer_get(), "Browsing commissionable nodes...\r\n");

return Dnssd::Resolver::Instance().FindCommissionableNodes(filter);
return sResolverProxy.FindCommissionableNodes(filter);
}

CHIP_ERROR BrowseCommissionerHandler(int argc, char ** argv)
Expand All @@ -199,7 +201,7 @@ CHIP_ERROR BrowseCommissionerHandler(int argc, char ** argv)

streamer_printf(streamer_get(), "Browsing commissioners...\r\n");

return Dnssd::Resolver::Instance().FindCommissioners(filter);
return sResolverProxy.FindCommissioners(filter);
}

CHIP_ERROR BrowseHandler(int argc, char ** argv)
Expand All @@ -221,8 +223,8 @@ CHIP_ERROR DnsHandler(int argc, char ** argv)
return CHIP_NO_ERROR;
}

Dnssd::Resolver::Instance().Init(DeviceLayer::UDPEndPointManager());
Dnssd::Resolver::Instance().SetResolverDelegate(&sDnsShellResolverDelegate);
sResolverProxy.Init(DeviceLayer::UDPEndPointManager());
sResolverProxy.SetResolverDelegate(&sDnsShellResolverDelegate);

return sShellDnsSubcommands.ExecCommand(argc, argv);
}
Expand Down

0 comments on commit 3449188

Please sign in to comment.