diff options
author | Joyee Cheung <joyeec9h3@gmail.com> | 2022-09-14 10:08:26 +0300 |
---|---|---|
committer | Joyee Cheung <joyeec9h3@gmail.com> | 2022-09-28 20:58:21 +0300 |
commit | 8821860f11a94e69ba642d874d3226480a68fc1b (patch) | |
tree | fe58fbf1bbaa791753d1a0076c24a2c1b63d3ba5 /src | |
parent | 7b368552743a713268a5a1b5c9d72eb82c1c8895 (diff) |
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 <matteo.collina@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/cares_wrap.cc | 36 | ||||
-rw-r--r-- | src/cares_wrap.h | 3 | ||||
-rw-r--r-- | src/node_external_reference.h | 1 |
3 files changed, 36 insertions, 4 deletions
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 <cerrno> #include <cstring> @@ -1955,7 +1956,36 @@ void Initialize(Local<Object> 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<QueryAnyWrap>); + registry->Register(Query<QueryAWrap>); + registry->Register(Query<QueryAaaaWrap>); + registry->Register(Query<QueryCaaWrap>); + registry->Register(Query<QueryCnameWrap>); + registry->Register(Query<QueryMxWrap>); + registry->Register(Query<QueryNsWrap>); + registry->Register(Query<QueryTxtWrap>); + registry->Register(Query<QuerySrvWrap>); + registry->Register(Query<QueryPtrWrap>); + registry->Register(Query<QueryNaptrWrap>); + registry->Register(Query<QuerySoaWrap>); + registry->Register(Query<GetHostByAddrWrap>); + + 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) diff --git a/src/cares_wrap.h b/src/cares_wrap.h index 60f99e65edf..ea339b77399 100644 --- a/src/cares_wrap.h +++ b/src/cares_wrap.h @@ -9,8 +9,9 @@ #include "base_object.h" #include "env.h" #include "memory_tracker.h" -#include "util.h" #include "node.h" +#include "node_internals.h" +#include "util.h" #include "ares.h" #include "v8.h" diff --git a/src/node_external_reference.h b/src/node_external_reference.h index a77c1ab14ee..9dc85d1b19a 100644 --- a/src/node_external_reference.h +++ b/src/node_external_reference.h @@ -62,6 +62,7 @@ class ExternalReferenceRegistry { V(blob) \ V(buffer) \ V(builtins) \ + V(cares_wrap) \ V(contextify) \ V(credentials) \ V(env_var) \ |