From 8821860f11a94e69ba642d874d3226480a68fc1b Mon Sep 17 00:00:00 2001 From: Joyee Cheung Date: Wed, 14 Sep 2022 15:08:26 +0800 Subject: dns: support dns module in the snapshot For the initial iteration, only the default resolver can be serialized/deserialized. If `dns.setServers()` has been called, we'll preserve the configured DNS servers in the snapshot. We can consider exposing the serialization method if it becomes necessary for user-land snapshots. PR-URL: https://github.com/nodejs/node/pull/44633 Reviewed-By: Matteo Collina Reviewed-By: Antoine du Hamel --- src/cares_wrap.cc | 36 +++++++++++++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 3 deletions(-) (limited to 'src/cares_wrap.cc') diff --git a/src/cares_wrap.cc b/src/cares_wrap.cc index d19705f94e7..eb3ebceeca6 100644 --- a/src/cares_wrap.cc +++ b/src/cares_wrap.cc @@ -19,18 +19,19 @@ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE // USE OR OTHER DEALINGS IN THE SOFTWARE. +#include "cares_wrap.h" #include "async_wrap-inl.h" -#include "base_object-inl.h" #include "base64-inl.h" -#include "cares_wrap.h" +#include "base_object-inl.h" #include "env-inl.h" #include "memory_tracker-inl.h" #include "node.h" #include "node_errors.h" +#include "node_external_reference.h" #include "req_wrap-inl.h" #include "util-inl.h" -#include "v8.h" #include "uv.h" +#include "v8.h" #include #include @@ -1955,7 +1956,36 @@ void Initialize(Local target, SetConstructorFunction(context, target, "ChannelWrap", channel_wrap); } +void RegisterExternalReferences(ExternalReferenceRegistry* registry) { + registry->Register(GetAddrInfo); + registry->Register(GetNameInfo); + registry->Register(CanonicalizeIP); + registry->Register(StrError); + registry->Register(ChannelWrap::New); + + registry->Register(Query); + registry->Register(Query); + registry->Register(Query); + registry->Register(Query); + registry->Register(Query); + registry->Register(Query); + registry->Register(Query); + registry->Register(Query); + registry->Register(Query); + registry->Register(Query); + registry->Register(Query); + registry->Register(Query); + registry->Register(Query); + + registry->Register(GetServers); + registry->Register(SetServers); + registry->Register(SetLocalAddress); + registry->Register(Cancel); +} + } // namespace cares_wrap } // namespace node NODE_MODULE_CONTEXT_AWARE_INTERNAL(cares_wrap, node::cares_wrap::Initialize) +NODE_MODULE_EXTERNAL_REFERENCE(cares_wrap, + node::cares_wrap::RegisterExternalReferences) -- cgit v1.2.3