visaljs 0.0.9 → 0.0.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (232) hide show
  1. package/README.md +12 -4
  2. package/THIRD_PARTY_LICENSES +31 -1
  3. package/cli.js +3745 -890
  4. package/node/include/js_node.h +12 -1
  5. package/node/prelude/_http_common.js +29 -0
  6. package/node/prelude/async_hooks.js +50 -11
  7. package/node/prelude/child_process.js +31 -4
  8. package/node/prelude/console.js +311 -143
  9. package/node/prelude/crypto.js +6 -4
  10. package/node/prelude/dgram.js +1169 -0
  11. package/node/prelude/diagnostics_channel.js +3 -1
  12. package/node/prelude/dns.js +250 -45
  13. package/node/prelude/dns_promises.js +8 -2
  14. package/node/prelude/fs_promises.js +9 -1
  15. package/node/prelude/http.js +405 -94
  16. package/node/prelude/https.js +13 -4
  17. package/node/prelude/internal/console_class.js +7 -0
  18. package/node/prelude/internal/console_global.js +25 -0
  19. package/node/prelude/internal/crypto/key_encryption.js +217 -0
  20. package/node/prelude/internal/crypto/keys.js +161 -26
  21. package/node/prelude/internal/crypto/random.js +24 -0
  22. package/node/prelude/internal/crypto/util.js +2 -1
  23. package/node/prelude/internal/crypto_x509.js +161 -0
  24. package/node/prelude/internal/dns_classes.js +6 -0
  25. package/node/prelude/internal/dns_resolver.js +371 -0
  26. package/node/prelude/internal/errors.js +9 -0
  27. package/node/prelude/internal/events_on.js +82 -37
  28. package/node/prelude/internal/features.js +8 -4
  29. package/node/prelude/internal/fs_filehandle.js +10 -4
  30. package/node/prelude/internal/http_chars.ts +22 -0
  31. package/node/prelude/internal/perf_histogram.js +1 -1
  32. package/node/prelude/internal/process_more.js +32 -17
  33. package/node/prelude/internal/process_signals.js +8 -2
  34. package/node/prelude/internal/punycode.ts +163 -0
  35. package/node/prelude/internal/readline.js +648 -274
  36. package/node/prelude/internal/readline_editor.js +1240 -0
  37. package/node/prelude/internal/string_width.js +43 -0
  38. package/node/prelude/internal/tls/common.js +145 -33
  39. package/node/prelude/internal/tls/wrap.js +182 -49
  40. package/node/prelude/internal/tls/x509.js +4 -1
  41. package/node/prelude/internal/udp.js +177 -0
  42. package/node/prelude/net.js +30 -14
  43. package/node/prelude/os.js +24 -6
  44. package/node/prelude/perf_hooks.js +37 -2
  45. package/node/prelude/punycode.js +2 -130
  46. package/node/prelude/readline.js +113 -4
  47. package/node/prelude/readline_promises.js +56 -32
  48. package/node/prelude/tls.js +21 -4
  49. package/node/prelude/util.js +3 -16
  50. package/node/src/host_dns.c +623 -0
  51. package/node/src/host_http.c +12 -0
  52. package/node/src/host_net.c +46 -0
  53. package/node/src/host_os.c +1 -6
  54. package/node/src/host_sys.c +79 -0
  55. package/node/src/host_udp.c +418 -0
  56. package/node/third_party/c-ares/LICENSE.md +24 -0
  57. package/node/third_party/c-ares/config/darwin/ares_config.h +573 -0
  58. package/node/third_party/c-ares/config/freebsd/ares_config.h +573 -0
  59. package/node/third_party/c-ares/config/linux/ares_config.h +573 -0
  60. package/node/third_party/c-ares/config/openbsd/ares_config.h +583 -0
  61. package/node/third_party/c-ares/include/ares.h +1237 -0
  62. package/node/third_party/c-ares/include/ares_build.h +202 -0
  63. package/node/third_party/c-ares/include/ares_dns.h +127 -0
  64. package/node/third_party/c-ares/include/ares_dns_record.h +1119 -0
  65. package/node/third_party/c-ares/include/ares_nameser.h +510 -0
  66. package/node/third_party/c-ares/include/ares_version.h +47 -0
  67. package/node/third_party/c-ares/src/lib/ares_addrinfo2hostent.c +305 -0
  68. package/node/third_party/c-ares/src/lib/ares_addrinfo_localhost.c +245 -0
  69. package/node/third_party/c-ares/src/lib/ares_android.c +496 -0
  70. package/node/third_party/c-ares/src/lib/ares_android.h +38 -0
  71. package/node/third_party/c-ares/src/lib/ares_cancel.c +87 -0
  72. package/node/third_party/c-ares/src/lib/ares_close_sockets.c +137 -0
  73. package/node/third_party/c-ares/src/lib/ares_conn.c +511 -0
  74. package/node/third_party/c-ares/src/lib/ares_conn.h +202 -0
  75. package/node/third_party/c-ares/src/lib/ares_cookie.c +461 -0
  76. package/node/third_party/c-ares/src/lib/ares_data.c +168 -0
  77. package/node/third_party/c-ares/src/lib/ares_data.h +92 -0
  78. package/node/third_party/c-ares/src/lib/ares_destroy.c +159 -0
  79. package/node/third_party/c-ares/src/lib/ares_free_hostent.c +54 -0
  80. package/node/third_party/c-ares/src/lib/ares_free_string.c +33 -0
  81. package/node/third_party/c-ares/src/lib/ares_freeaddrinfo.c +67 -0
  82. package/node/third_party/c-ares/src/lib/ares_getaddrinfo.c +806 -0
  83. package/node/third_party/c-ares/src/lib/ares_getenv.c +38 -0
  84. package/node/third_party/c-ares/src/lib/ares_getenv.h +34 -0
  85. package/node/third_party/c-ares/src/lib/ares_gethostbyaddr.c +229 -0
  86. package/node/third_party/c-ares/src/lib/ares_gethostbyname.c +341 -0
  87. package/node/third_party/c-ares/src/lib/ares_getnameinfo.c +437 -0
  88. package/node/third_party/c-ares/src/lib/ares_hosts_file.c +960 -0
  89. package/node/third_party/c-ares/src/lib/ares_inet_net_pton.h +31 -0
  90. package/node/third_party/c-ares/src/lib/ares_init.c +631 -0
  91. package/node/third_party/c-ares/src/lib/ares_ipv6.h +115 -0
  92. package/node/third_party/c-ares/src/lib/ares_library_init.c +190 -0
  93. package/node/third_party/c-ares/src/lib/ares_metrics.c +261 -0
  94. package/node/third_party/c-ares/src/lib/ares_options.c +492 -0
  95. package/node/third_party/c-ares/src/lib/ares_parse_into_addrinfo.c +179 -0
  96. package/node/third_party/c-ares/src/lib/ares_private.h +648 -0
  97. package/node/third_party/c-ares/src/lib/ares_process.c +1649 -0
  98. package/node/third_party/c-ares/src/lib/ares_qcache.c +442 -0
  99. package/node/third_party/c-ares/src/lib/ares_query.c +151 -0
  100. package/node/third_party/c-ares/src/lib/ares_search.c +623 -0
  101. package/node/third_party/c-ares/src/lib/ares_send.c +300 -0
  102. package/node/third_party/c-ares/src/lib/ares_set_socket_functions.c +590 -0
  103. package/node/third_party/c-ares/src/lib/ares_setup.h +224 -0
  104. package/node/third_party/c-ares/src/lib/ares_socket.c +427 -0
  105. package/node/third_party/c-ares/src/lib/ares_socket.h +163 -0
  106. package/node/third_party/c-ares/src/lib/ares_sortaddrinfo.c +447 -0
  107. package/node/third_party/c-ares/src/lib/ares_strerror.c +91 -0
  108. package/node/third_party/c-ares/src/lib/ares_sysconfig.c +642 -0
  109. package/node/third_party/c-ares/src/lib/ares_sysconfig_files.c +851 -0
  110. package/node/third_party/c-ares/src/lib/ares_sysconfig_mac.c +373 -0
  111. package/node/third_party/c-ares/src/lib/ares_sysconfig_win.c +673 -0
  112. package/node/third_party/c-ares/src/lib/ares_timeout.c +162 -0
  113. package/node/third_party/c-ares/src/lib/ares_update_servers.c +1376 -0
  114. package/node/third_party/c-ares/src/lib/ares_version.c +36 -0
  115. package/node/third_party/c-ares/src/lib/config-dos.h +114 -0
  116. package/node/third_party/c-ares/src/lib/config-win32.h +396 -0
  117. package/node/third_party/c-ares/src/lib/dsa/ares_array.c +409 -0
  118. package/node/third_party/c-ares/src/lib/dsa/ares_htable.c +451 -0
  119. package/node/third_party/c-ares/src/lib/dsa/ares_htable.h +174 -0
  120. package/node/third_party/c-ares/src/lib/dsa/ares_htable_asvp.c +224 -0
  121. package/node/third_party/c-ares/src/lib/dsa/ares_htable_dict.c +230 -0
  122. package/node/third_party/c-ares/src/lib/dsa/ares_htable_strvp.c +210 -0
  123. package/node/third_party/c-ares/src/lib/dsa/ares_htable_szvp.c +188 -0
  124. package/node/third_party/c-ares/src/lib/dsa/ares_htable_vpstr.c +186 -0
  125. package/node/third_party/c-ares/src/lib/dsa/ares_htable_vpvp.c +194 -0
  126. package/node/third_party/c-ares/src/lib/dsa/ares_llist.c +385 -0
  127. package/node/third_party/c-ares/src/lib/dsa/ares_slist.c +479 -0
  128. package/node/third_party/c-ares/src/lib/dsa/ares_slist.h +207 -0
  129. package/node/third_party/c-ares/src/lib/event/ares_event.h +191 -0
  130. package/node/third_party/c-ares/src/lib/event/ares_event_configchg.c +746 -0
  131. package/node/third_party/c-ares/src/lib/event/ares_event_epoll.c +192 -0
  132. package/node/third_party/c-ares/src/lib/event/ares_event_kqueue.c +248 -0
  133. package/node/third_party/c-ares/src/lib/event/ares_event_poll.c +140 -0
  134. package/node/third_party/c-ares/src/lib/event/ares_event_select.c +159 -0
  135. package/node/third_party/c-ares/src/lib/event/ares_event_thread.c +575 -0
  136. package/node/third_party/c-ares/src/lib/event/ares_event_wake_pipe.c +172 -0
  137. package/node/third_party/c-ares/src/lib/event/ares_event_win32.c +981 -0
  138. package/node/third_party/c-ares/src/lib/event/ares_event_win32.h +161 -0
  139. package/node/third_party/c-ares/src/lib/include/ares_array.h +276 -0
  140. package/node/third_party/c-ares/src/lib/include/ares_buf.h +732 -0
  141. package/node/third_party/c-ares/src/lib/include/ares_htable_asvp.h +130 -0
  142. package/node/third_party/c-ares/src/lib/include/ares_htable_dict.h +123 -0
  143. package/node/third_party/c-ares/src/lib/include/ares_htable_strvp.h +130 -0
  144. package/node/third_party/c-ares/src/lib/include/ares_htable_szvp.h +118 -0
  145. package/node/third_party/c-ares/src/lib/include/ares_htable_vpstr.h +111 -0
  146. package/node/third_party/c-ares/src/lib/include/ares_htable_vpvp.h +128 -0
  147. package/node/third_party/c-ares/src/lib/include/ares_llist.h +239 -0
  148. package/node/third_party/c-ares/src/lib/include/ares_mem.h +41 -0
  149. package/node/third_party/c-ares/src/lib/include/ares_str.h +261 -0
  150. package/node/third_party/c-ares/src/lib/inet_net_pton.c +451 -0
  151. package/node/third_party/c-ares/src/lib/inet_ntop.c +219 -0
  152. package/node/third_party/c-ares/src/lib/legacy/ares_create_query.c +78 -0
  153. package/node/third_party/c-ares/src/lib/legacy/ares_expand_name.c +99 -0
  154. package/node/third_party/c-ares/src/lib/legacy/ares_expand_string.c +107 -0
  155. package/node/third_party/c-ares/src/lib/legacy/ares_fds.c +80 -0
  156. package/node/third_party/c-ares/src/lib/legacy/ares_getsock.c +85 -0
  157. package/node/third_party/c-ares/src/lib/legacy/ares_parse_a_reply.c +107 -0
  158. package/node/third_party/c-ares/src/lib/legacy/ares_parse_aaaa_reply.c +109 -0
  159. package/node/third_party/c-ares/src/lib/legacy/ares_parse_caa_reply.c +137 -0
  160. package/node/third_party/c-ares/src/lib/legacy/ares_parse_mx_reply.c +110 -0
  161. package/node/third_party/c-ares/src/lib/legacy/ares_parse_naptr_reply.c +132 -0
  162. package/node/third_party/c-ares/src/lib/legacy/ares_parse_ns_reply.c +154 -0
  163. package/node/third_party/c-ares/src/lib/legacy/ares_parse_ptr_reply.c +213 -0
  164. package/node/third_party/c-ares/src/lib/legacy/ares_parse_soa_reply.c +115 -0
  165. package/node/third_party/c-ares/src/lib/legacy/ares_parse_srv_reply.c +114 -0
  166. package/node/third_party/c-ares/src/lib/legacy/ares_parse_txt_reply.c +144 -0
  167. package/node/third_party/c-ares/src/lib/legacy/ares_parse_uri_reply.c +113 -0
  168. package/node/third_party/c-ares/src/lib/record/ares_dns_mapping.c +982 -0
  169. package/node/third_party/c-ares/src/lib/record/ares_dns_multistring.c +309 -0
  170. package/node/third_party/c-ares/src/lib/record/ares_dns_multistring.h +72 -0
  171. package/node/third_party/c-ares/src/lib/record/ares_dns_name.c +736 -0
  172. package/node/third_party/c-ares/src/lib/record/ares_dns_parse.c +1360 -0
  173. package/node/third_party/c-ares/src/lib/record/ares_dns_private.h +273 -0
  174. package/node/third_party/c-ares/src/lib/record/ares_dns_record.c +1701 -0
  175. package/node/third_party/c-ares/src/lib/record/ares_dns_write.c +1229 -0
  176. package/node/third_party/c-ares/src/lib/str/ares_buf.c +1510 -0
  177. package/node/third_party/c-ares/src/lib/str/ares_str.c +562 -0
  178. package/node/third_party/c-ares/src/lib/str/ares_strsplit.c +90 -0
  179. package/node/third_party/c-ares/src/lib/str/ares_strsplit.h +51 -0
  180. package/node/third_party/c-ares/src/lib/thirdparty/apple/dnsinfo.h +122 -0
  181. package/node/third_party/c-ares/src/lib/util/ares_iface_ips.c +640 -0
  182. package/node/third_party/c-ares/src/lib/util/ares_iface_ips.h +140 -0
  183. package/node/third_party/c-ares/src/lib/util/ares_math.c +167 -0
  184. package/node/third_party/c-ares/src/lib/util/ares_math.h +58 -0
  185. package/node/third_party/c-ares/src/lib/util/ares_rand.c +389 -0
  186. package/node/third_party/c-ares/src/lib/util/ares_rand.h +36 -0
  187. package/node/third_party/c-ares/src/lib/util/ares_threads.c +613 -0
  188. package/node/third_party/c-ares/src/lib/util/ares_threads.h +60 -0
  189. package/node/third_party/c-ares/src/lib/util/ares_time.h +49 -0
  190. package/node/third_party/c-ares/src/lib/util/ares_timeval.c +95 -0
  191. package/node/third_party/c-ares/src/lib/util/ares_uri.c +1627 -0
  192. package/node/third_party/c-ares/src/lib/util/ares_uri.h +252 -0
  193. package/node/third_party/c-ares/src/lib/windows_port.c +29 -0
  194. package/package.json +1 -1
  195. package/prebuilt/darwin-arm64/cares-a6286c65ca9374a3.a +0 -0
  196. package/prebuilt/darwin-x64/cares-a6286c65ca9374a3.a +0 -0
  197. package/prebuilt/linux-arm64/cares-4ba05ac8e948af8e.a +0 -0
  198. package/prebuilt/linux-arm64-musl/cares-4ba05ac8e948af8e.a +0 -0
  199. package/prebuilt/linux-x64/cares-4ba05ac8e948af8e.a +0 -0
  200. package/prebuilt/linux-x64-musl/cares-4ba05ac8e948af8e.a +0 -0
  201. package/prebuilt/win32-x64/boringssl-ce573858472b7fc9.a +0 -0
  202. package/prebuilt/win32-x64/brotli-20d86a61f30baeb3.a +0 -0
  203. package/prebuilt/win32-x64/cares-49c9ec95162b912d.a +0 -0
  204. package/prebuilt/win32-x64/uv-b11bae65d7fced82.a +0 -0
  205. package/prebuilt/win32-x64/zlib-4ce2317a4c3f5fb5.a +0 -0
  206. package/prebuilt/win32-x64/zstd-015315ac7c784c73.a +0 -0
  207. package/runtime/include/js_buffer.h +185 -0
  208. package/runtime/include/js_builtins.h +58 -0
  209. package/runtime/include/js_crypto.h +11 -0
  210. package/runtime/include/js_exception.h +3 -0
  211. package/runtime/include/js_function.h +1 -1
  212. package/runtime/include/js_gc.h +13 -10
  213. package/runtime/include/js_jobs.h +2 -0
  214. package/runtime/include/js_object.h +79 -3
  215. package/runtime/include/js_ops.h +27 -0
  216. package/runtime/include/js_runtime.h +1 -0
  217. package/runtime/include/js_web.h +0 -3
  218. package/runtime/include/jscontext.h +8 -0
  219. package/runtime/src/builtins.c +17 -4
  220. package/runtime/src/crypto_internal.h +1 -0
  221. package/runtime/src/crypto_subtle.c +66 -7
  222. package/runtime/src/crypto_tls.c +265 -19
  223. package/runtime/src/function.c +37 -10
  224. package/runtime/src/gc.c +76 -93
  225. package/runtime/src/inspect.c +18 -1
  226. package/runtime/src/iterator.c +5 -1
  227. package/runtime/src/jobs.c +37 -22
  228. package/runtime/src/object.c +91 -8
  229. package/runtime/src/os.c +16 -6
  230. package/runtime/src/os.h +2 -0
  231. package/runtime/src/process.c +97 -10
  232. package/runtime/src/typedarray.c +23 -0
@@ -0,0 +1,168 @@
1
+ /* MIT License
2
+ *
3
+ * Copyright (c) 2009 Daniel Stenberg
4
+ *
5
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ * of this software and associated documentation files (the "Software"), to deal
7
+ * in the Software without restriction, including without limitation the rights
8
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ * copies of the Software, and to permit persons to whom the Software is
10
+ * furnished to do so, subject to the following conditions:
11
+ *
12
+ * The above copyright notice and this permission notice (including the next
13
+ * paragraph) shall be included in all copies or substantial portions of the
14
+ * Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ * SOFTWARE.
23
+ *
24
+ * SPDX-License-Identifier: MIT
25
+ */
26
+
27
+ #include "ares_private.h"
28
+ #include <stddef.h>
29
+ #include <assert.h>
30
+ #include "ares_data.h"
31
+
32
+ /*
33
+ ** ares_free_data() - c-ares external API function.
34
+ **
35
+ ** This function must be used by the application to free data memory that
36
+ ** has been internally allocated by some c-ares function and for which a
37
+ ** pointer has already been returned to the calling application. The list
38
+ ** of c-ares functions returning pointers that must be free'ed using this
39
+ ** function is:
40
+ **
41
+ ** ares_get_servers()
42
+ ** ares_parse_srv_reply()
43
+ ** ares_parse_txt_reply()
44
+ */
45
+
46
+ void ares_free_data(void *dataptr)
47
+ {
48
+ while (dataptr != NULL) {
49
+ struct ares_data *ptr;
50
+ void *next_data = NULL;
51
+
52
+ #ifdef __INTEL_COMPILER
53
+ # pragma warning(push)
54
+ # pragma warning(disable : 1684)
55
+ /* 1684: conversion from pointer to same-sized integral type */
56
+ #endif
57
+
58
+ ptr = (void *)((char *)dataptr - offsetof(struct ares_data, data));
59
+
60
+ #ifdef __INTEL_COMPILER
61
+ # pragma warning(pop)
62
+ #endif
63
+
64
+ if (ptr->mark != ARES_DATATYPE_MARK) {
65
+ return;
66
+ }
67
+
68
+ switch (ptr->type) {
69
+ case ARES_DATATYPE_MX_REPLY:
70
+ next_data = ptr->data.mx_reply.next;
71
+ ares_free(ptr->data.mx_reply.host);
72
+ break;
73
+
74
+ case ARES_DATATYPE_SRV_REPLY:
75
+ next_data = ptr->data.srv_reply.next;
76
+ ares_free(ptr->data.srv_reply.host);
77
+ break;
78
+
79
+ case ARES_DATATYPE_URI_REPLY:
80
+ next_data = ptr->data.uri_reply.next;
81
+ ares_free(ptr->data.uri_reply.uri);
82
+ break;
83
+
84
+ case ARES_DATATYPE_TXT_REPLY:
85
+ case ARES_DATATYPE_TXT_EXT:
86
+ next_data = ptr->data.txt_reply.next;
87
+ ares_free(ptr->data.txt_reply.txt);
88
+ break;
89
+
90
+ case ARES_DATATYPE_ADDR_NODE:
91
+ next_data = ptr->data.addr_node.next;
92
+ break;
93
+
94
+ case ARES_DATATYPE_ADDR_PORT_NODE:
95
+ next_data = ptr->data.addr_port_node.next;
96
+ break;
97
+
98
+ case ARES_DATATYPE_NAPTR_REPLY:
99
+ next_data = ptr->data.naptr_reply.next;
100
+ ares_free(ptr->data.naptr_reply.flags);
101
+ ares_free(ptr->data.naptr_reply.service);
102
+ ares_free(ptr->data.naptr_reply.regexp);
103
+ ares_free(ptr->data.naptr_reply.replacement);
104
+ break;
105
+
106
+ case ARES_DATATYPE_SOA_REPLY:
107
+ ares_free(ptr->data.soa_reply.nsname);
108
+ ares_free(ptr->data.soa_reply.hostmaster);
109
+ break;
110
+
111
+ case ARES_DATATYPE_CAA_REPLY:
112
+ next_data = ptr->data.caa_reply.next;
113
+ ares_free(ptr->data.caa_reply.property);
114
+ ares_free(ptr->data.caa_reply.value);
115
+ break;
116
+
117
+ default:
118
+ return;
119
+ }
120
+
121
+ ares_free(ptr);
122
+ dataptr = next_data;
123
+ }
124
+ }
125
+
126
+ /*
127
+ ** ares_malloc_data() - c-ares internal helper function.
128
+ **
129
+ ** This function allocates memory for a c-ares private ares_data struct
130
+ ** for the specified ares_datatype, initializes c-ares private fields
131
+ ** and zero initializes those which later might be used from the public
132
+ ** API. It returns an interior pointer which can be passed by c-ares
133
+ ** functions to the calling application, and that must be free'ed using
134
+ ** c-ares external API function ares_free_data().
135
+ */
136
+
137
+ void *ares_malloc_data(ares_datatype type)
138
+ {
139
+ struct ares_data *ptr;
140
+
141
+ ptr = ares_malloc_zero(sizeof(*ptr));
142
+ if (!ptr) {
143
+ return NULL;
144
+ }
145
+
146
+ switch (type) {
147
+ case ARES_DATATYPE_MX_REPLY:
148
+ case ARES_DATATYPE_SRV_REPLY:
149
+ case ARES_DATATYPE_URI_REPLY:
150
+ case ARES_DATATYPE_TXT_EXT:
151
+ case ARES_DATATYPE_TXT_REPLY:
152
+ case ARES_DATATYPE_CAA_REPLY:
153
+ case ARES_DATATYPE_ADDR_NODE:
154
+ case ARES_DATATYPE_ADDR_PORT_NODE:
155
+ case ARES_DATATYPE_NAPTR_REPLY:
156
+ case ARES_DATATYPE_SOA_REPLY:
157
+ break;
158
+
159
+ default:
160
+ ares_free(ptr);
161
+ return NULL;
162
+ }
163
+
164
+ ptr->mark = ARES_DATATYPE_MARK;
165
+ ptr->type = type;
166
+
167
+ return &ptr->data;
168
+ }
@@ -0,0 +1,92 @@
1
+ /* MIT License
2
+ *
3
+ * Copyright (c) 2009 Daniel Stenberg
4
+ *
5
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ * of this software and associated documentation files (the "Software"), to deal
7
+ * in the Software without restriction, including without limitation the rights
8
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ * copies of the Software, and to permit persons to whom the Software is
10
+ * furnished to do so, subject to the following conditions:
11
+ *
12
+ * The above copyright notice and this permission notice (including the next
13
+ * paragraph) shall be included in all copies or substantial portions of the
14
+ * Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ * SOFTWARE.
23
+ *
24
+ * SPDX-License-Identifier: MIT
25
+ */
26
+ #ifndef __ARES_DATA_H
27
+ #define __ARES_DATA_H
28
+
29
+ typedef enum {
30
+ ARES_DATATYPE_UNKNOWN = 1, /* unknown data type - introduced in 1.7.0 */
31
+ ARES_DATATYPE_SRV_REPLY, /* struct ares_srv_reply - introduced in 1.7.0 */
32
+ ARES_DATATYPE_TXT_REPLY, /* struct ares_txt_reply - introduced in 1.7.0 */
33
+ ARES_DATATYPE_TXT_EXT, /* struct ares_txt_ext - introduced in 1.11.0 */
34
+ ARES_DATATYPE_ADDR_NODE, /* struct ares_addr_node - introduced in 1.7.1 */
35
+ ARES_DATATYPE_MX_REPLY, /* struct ares_mx_reply - introduced in 1.7.2 */
36
+ ARES_DATATYPE_NAPTR_REPLY, /* struct ares_naptr_reply - introduced in 1.7.6 */
37
+ ARES_DATATYPE_SOA_REPLY, /* struct ares_soa_reply - introduced in 1.9.0 */
38
+ ARES_DATATYPE_URI_REPLY, /* struct ares_uri_reply */
39
+ #if 0
40
+ ARES_DATATYPE_ADDR6TTL, /* struct ares_addrttl */
41
+ ARES_DATATYPE_ADDRTTL, /* struct ares_addr6ttl */
42
+ ARES_DATATYPE_HOSTENT, /* struct hostent */
43
+ ARES_DATATYPE_OPTIONS, /* struct ares_options */
44
+ #endif
45
+ ARES_DATATYPE_ADDR_PORT_NODE, /* struct ares_addr_port_node - introduced
46
+ in 1.11.0 */
47
+ ARES_DATATYPE_CAA_REPLY, /* struct ares_caa_reply - introduced in 1.17 */
48
+ ARES_DATATYPE_LAST /* not used - introduced in 1.7.0 */
49
+ } ares_datatype;
50
+
51
+ #define ARES_DATATYPE_MARK 0xbead
52
+
53
+ /*
54
+ * ares_data struct definition is internal to c-ares and shall not
55
+ * be exposed by the public API in order to allow future changes
56
+ * and extensions to it without breaking ABI. This will be used
57
+ * internally by c-ares as the container of multiple types of data
58
+ * dynamically allocated for which a reference will be returned
59
+ * to the calling application.
60
+ *
61
+ * c-ares API functions returning a pointer to c-ares internally
62
+ * allocated data will actually be returning an interior pointer
63
+ * into this ares_data struct.
64
+ *
65
+ * All this is 'invisible' to the calling application, the only
66
+ * requirement is that this kind of data must be free'ed by the
67
+ * calling application using ares_free_data() with the pointer
68
+ * it has received from a previous c-ares function call.
69
+ */
70
+
71
+ struct ares_data {
72
+ ares_datatype type; /* Actual data type identifier. */
73
+ unsigned int mark; /* Private ares_data signature. */
74
+
75
+ union {
76
+ struct ares_txt_reply txt_reply;
77
+ struct ares_txt_ext txt_ext;
78
+ struct ares_srv_reply srv_reply;
79
+ struct ares_addr_node addr_node;
80
+ struct ares_addr_port_node addr_port_node;
81
+ struct ares_mx_reply mx_reply;
82
+ struct ares_naptr_reply naptr_reply;
83
+ struct ares_soa_reply soa_reply;
84
+ struct ares_caa_reply caa_reply;
85
+ struct ares_uri_reply uri_reply;
86
+ } data;
87
+ };
88
+
89
+ void *ares_malloc_data(ares_datatype type);
90
+
91
+
92
+ #endif /* __ARES_DATA_H */
@@ -0,0 +1,159 @@
1
+ /* MIT License
2
+ *
3
+ * Copyright (c) 1998 Massachusetts Institute of Technology
4
+ * Copyright (c) 2004 Daniel Stenberg
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice (including the next
14
+ * paragraph) shall be included in all copies or substantial portions of the
15
+ * Software.
16
+ *
17
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
+ * SOFTWARE.
24
+ *
25
+ * SPDX-License-Identifier: MIT
26
+ */
27
+
28
+ #include "ares_private.h"
29
+ #include "event/ares_event.h"
30
+ #include <assert.h>
31
+
32
+ void ares_destroy(ares_channel_t *channel)
33
+ {
34
+ size_t i;
35
+ ares_llist_node_t *node = NULL;
36
+
37
+ if (channel == NULL) {
38
+ return;
39
+ }
40
+
41
+ /* Mark as being shutdown */
42
+ ares_channel_lock(channel);
43
+ channel->sys_up = ARES_FALSE;
44
+ ares_channel_unlock(channel);
45
+
46
+ /* Disable configuration change monitoring. We can't hold a lock because
47
+ * some cleanup routines, such as on Windows, are synchronous operations.
48
+ * What we've observed is a system config change event was triggered right
49
+ * at shutdown time and it tries to take the channel lock and the destruction
50
+ * waits for that event to complete before it continues so we get a channel
51
+ * lock deadlock at shutdown if we hold a lock during this process. */
52
+ if (channel->optmask & ARES_OPT_EVENT_THREAD) {
53
+ ares_event_thread_t *e = channel->sock_state_cb_data;
54
+ if (e && e->configchg) {
55
+ ares_event_configchg_destroy(e->configchg);
56
+ e->configchg = NULL;
57
+ }
58
+ }
59
+
60
+ /* Wait for reinit thread to exit if there was one pending, can't be
61
+ * holding a lock as the thread may take locks. */
62
+ if (channel->reinit_thread != NULL) {
63
+ void *rv;
64
+ ares_thread_join(channel->reinit_thread, &rv);
65
+ channel->reinit_thread = NULL;
66
+ }
67
+
68
+ /* Lock because callbacks will be triggered, and any system-generated
69
+ * callbacks need to hold a channel lock. */
70
+ ares_channel_lock(channel);
71
+
72
+ /* Destroy all queries */
73
+ node = ares_llist_node_first(channel->all_queries);
74
+ while (node != NULL) {
75
+ ares_llist_node_t *next = ares_llist_node_next(node);
76
+ ares_query_t *query = ares_llist_node_claim(node);
77
+
78
+ query->node_all_queries = NULL;
79
+ query->callback(query->arg, ARES_EDESTRUCTION, 0, NULL);
80
+ ares_free_query(query);
81
+
82
+ node = next;
83
+ }
84
+
85
+ ares_queue_notify_empty(channel);
86
+
87
+ #ifndef NDEBUG
88
+ /* Freeing the query should remove it from all the lists in which it sits,
89
+ * so all query lists should be empty now.
90
+ */
91
+ assert(ares_llist_len(channel->all_queries) == 0);
92
+ assert(ares_htable_szvp_num_keys(channel->queries_by_qid) == 0);
93
+ assert(ares_slist_len(channel->queries_by_timeout) == 0);
94
+ #endif
95
+
96
+ ares_destroy_servers_state(channel);
97
+
98
+ #ifndef NDEBUG
99
+ assert(ares_htable_asvp_num_keys(channel->connnode_by_socket) == 0);
100
+ #endif
101
+
102
+ /* No more callbacks will be triggered after this point, unlock */
103
+ ares_channel_unlock(channel);
104
+
105
+ /* Shut down the event thread */
106
+ if (channel->optmask & ARES_OPT_EVENT_THREAD) {
107
+ ares_event_thread_destroy(channel);
108
+ }
109
+
110
+ if (channel->domains) {
111
+ for (i = 0; i < channel->ndomains; i++) {
112
+ ares_free(channel->domains[i]);
113
+ }
114
+ ares_free(channel->domains);
115
+ }
116
+
117
+ ares_llist_destroy(channel->all_queries);
118
+ ares_slist_destroy(channel->queries_by_timeout);
119
+ ares_htable_szvp_destroy(channel->queries_by_qid);
120
+ ares_htable_asvp_destroy(channel->connnode_by_socket);
121
+
122
+ ares_free(channel->sortlist);
123
+ ares_free(channel->lookups);
124
+ ares_free(channel->resolvconf_path);
125
+ ares_free(channel->hosts_path);
126
+ ares_destroy_rand_state(channel->rand_state);
127
+
128
+ ares_hosts_file_destroy(channel->hf);
129
+
130
+ ares_qcache_destroy(channel->qcache);
131
+
132
+ ares_channel_threading_destroy(channel);
133
+
134
+ ares_free(channel);
135
+ }
136
+
137
+ void ares_destroy_server(ares_server_t *server)
138
+ {
139
+ if (server == NULL) {
140
+ return; /* LCOV_EXCL_LINE: DefensiveCoding */
141
+ }
142
+
143
+ ares_close_sockets(server);
144
+ ares_llist_destroy(server->connections);
145
+ ares_free(server);
146
+ }
147
+
148
+ void ares_destroy_servers_state(ares_channel_t *channel)
149
+ {
150
+ ares_slist_node_t *node;
151
+
152
+ while ((node = ares_slist_node_first(channel->servers)) != NULL) {
153
+ ares_server_t *server = ares_slist_node_claim(node);
154
+ ares_destroy_server(server);
155
+ }
156
+
157
+ ares_slist_destroy(channel->servers);
158
+ channel->servers = NULL;
159
+ }
@@ -0,0 +1,54 @@
1
+ /* MIT License
2
+ *
3
+ * Copyright (c) 1998 Massachusetts Institute of Technology
4
+ * Copyright (c) The c-ares project and its contributors
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice (including the next
14
+ * paragraph) shall be included in all copies or substantial portions of the
15
+ * Software.
16
+ *
17
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
+ * SOFTWARE.
24
+ *
25
+ * SPDX-License-Identifier: MIT
26
+ */
27
+ #include "ares_private.h"
28
+
29
+ #ifdef HAVE_NETDB_H
30
+ # include <netdb.h>
31
+ #endif
32
+
33
+ void ares_free_hostent(struct hostent *host)
34
+ {
35
+ char **p;
36
+
37
+ if (!host) {
38
+ return;
39
+ }
40
+
41
+ ares_free(host->h_name);
42
+ for (p = host->h_aliases; p && *p; p++) {
43
+ ares_free(*p);
44
+ }
45
+ ares_free(host->h_aliases);
46
+ if (host->h_addr_list) {
47
+ size_t i;
48
+ for (i=0; host->h_addr_list[i] != NULL; i++) {
49
+ ares_free(host->h_addr_list[i]);
50
+ }
51
+ ares_free(host->h_addr_list);
52
+ }
53
+ ares_free(host);
54
+ }
@@ -0,0 +1,33 @@
1
+ /* MIT License
2
+ *
3
+ * Copyright (c) 2000 Massachusetts Institute of Technology
4
+ * Copyright (c) The c-ares project and its contributors
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice (including the next
14
+ * paragraph) shall be included in all copies or substantial portions of the
15
+ * Software.
16
+ *
17
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
+ * SOFTWARE.
24
+ *
25
+ * SPDX-License-Identifier: MIT
26
+ */
27
+
28
+ #include "ares_private.h"
29
+
30
+ void ares_free_string(void *str)
31
+ {
32
+ ares_free(str);
33
+ }
@@ -0,0 +1,67 @@
1
+ /* MIT License
2
+ *
3
+ * Copyright (c) 1998 Massachusetts Institute of Technology
4
+ * Copyright (c) 2019 Andrew Selivanov
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice (including the next
14
+ * paragraph) shall be included in all copies or substantial portions of the
15
+ * Software.
16
+ *
17
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
+ * SOFTWARE.
24
+ *
25
+ * SPDX-License-Identifier: MIT
26
+ */
27
+
28
+ #include "ares_private.h"
29
+
30
+ #ifdef HAVE_NETDB_H
31
+ # include <netdb.h>
32
+ #endif
33
+
34
+ void ares_freeaddrinfo_cnames(struct ares_addrinfo_cname *head)
35
+ {
36
+ struct ares_addrinfo_cname *current;
37
+ while (head) {
38
+ current = head;
39
+ head = head->next;
40
+ ares_free(current->alias);
41
+ ares_free(current->name);
42
+ ares_free(current);
43
+ }
44
+ }
45
+
46
+ void ares_freeaddrinfo_nodes(struct ares_addrinfo_node *head)
47
+ {
48
+ struct ares_addrinfo_node *current;
49
+ while (head) {
50
+ current = head;
51
+ head = head->ai_next;
52
+ ares_free(current->ai_addr);
53
+ ares_free(current);
54
+ }
55
+ }
56
+
57
+ void ares_freeaddrinfo(struct ares_addrinfo *ai)
58
+ {
59
+ if (ai == NULL) {
60
+ return;
61
+ }
62
+ ares_freeaddrinfo_cnames(ai->cnames);
63
+ ares_freeaddrinfo_nodes(ai->nodes);
64
+
65
+ ares_free(ai->name);
66
+ ares_free(ai);
67
+ }