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,78 @@
1
+ /* MIT License
2
+ *
3
+ * Copyright (c) 2023 Brad House
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
+
29
+ static int ares_create_query_int(const char *name, int dnsclass, int type,
30
+ unsigned short id, int rd,
31
+ unsigned char **bufp, int *buflenp,
32
+ int max_udp_size)
33
+ {
34
+ ares_status_t status;
35
+ ares_dns_record_t *dnsrec = NULL;
36
+ size_t len;
37
+ ares_dns_flags_t rd_flag = rd ? ARES_FLAG_RD : 0;
38
+
39
+ if (name == NULL || bufp == NULL || buflenp == NULL) {
40
+ status = ARES_EFORMERR;
41
+ goto done;
42
+ }
43
+
44
+ *bufp = NULL;
45
+ *buflenp = 0;
46
+
47
+ status = ares_dns_record_create_query(
48
+ &dnsrec, name, (ares_dns_class_t)dnsclass, (ares_dns_rec_type_t)type, id,
49
+ rd_flag, (size_t)max_udp_size);
50
+ if (status != ARES_SUCCESS) {
51
+ goto done;
52
+ }
53
+
54
+ status = ares_dns_write(dnsrec, bufp, &len);
55
+ if (status != ARES_SUCCESS) {
56
+ goto done;
57
+ }
58
+
59
+ *buflenp = (int)len;
60
+
61
+ done:
62
+ ares_dns_record_destroy(dnsrec);
63
+ return (int)status;
64
+ }
65
+
66
+ int ares_create_query(const char *name, int dnsclass, int type,
67
+ unsigned short id, int rd, unsigned char **bufp,
68
+ int *buflenp, int max_udp_size)
69
+ {
70
+ return ares_create_query_int(name, dnsclass, type, id, rd, bufp, buflenp,
71
+ max_udp_size);
72
+ }
73
+
74
+ int ares_mkquery(const char *name, int dnsclass, int type, unsigned short id,
75
+ int rd, unsigned char **buf, int *buflen)
76
+ {
77
+ return ares_create_query_int(name, dnsclass, type, id, rd, buf, buflen, 0);
78
+ }
@@ -0,0 +1,99 @@
1
+ /* MIT License
2
+ *
3
+ * Copyright (c) 1998, 2011 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
+ #ifdef HAVE_NETINET_IN_H
31
+ # include <netinet/in.h>
32
+ #endif
33
+
34
+ #include "ares_nameser.h"
35
+
36
+ ares_status_t ares_expand_name_validated(const unsigned char *encoded,
37
+ const unsigned char *abuf, size_t alen,
38
+ char **s, size_t *enclen,
39
+ ares_bool_t is_hostname)
40
+ {
41
+ ares_status_t status;
42
+ ares_buf_t *buf = NULL;
43
+ size_t start_len;
44
+
45
+ if (encoded == NULL || abuf == NULL || alen == 0 || enclen == NULL) {
46
+ return ARES_EBADNAME; /* EFORMERR would be better */
47
+ }
48
+
49
+ if (encoded < abuf || encoded >= abuf + alen) {
50
+ return ARES_EBADNAME; /* EFORMERR would be better */
51
+ }
52
+
53
+ *enclen = 0;
54
+
55
+ /* NOTE: we allow 's' to be NULL to skip it */
56
+ if (s) {
57
+ *s = NULL;
58
+ }
59
+
60
+ buf = ares_buf_create_const(abuf, alen);
61
+
62
+ if (buf == NULL) {
63
+ return ARES_ENOMEM;
64
+ }
65
+
66
+ status = ares_buf_set_position(buf, (size_t)(encoded - abuf));
67
+ if (status != ARES_SUCCESS) {
68
+ goto done;
69
+ }
70
+
71
+ start_len = ares_buf_len(buf);
72
+ status = ares_dns_name_parse(buf, s, is_hostname, ARES_TRUE);
73
+ if (status != ARES_SUCCESS) {
74
+ goto done;
75
+ }
76
+
77
+ *enclen = start_len - ares_buf_len(buf);
78
+
79
+ done:
80
+ ares_buf_destroy(buf);
81
+ return status;
82
+ }
83
+
84
+ int ares_expand_name(const unsigned char *encoded, const unsigned char *abuf,
85
+ int alen, char **s, long *enclen)
86
+ {
87
+ /* Keep public API compatible */
88
+ size_t enclen_temp = 0;
89
+ ares_status_t status;
90
+
91
+ if (encoded == NULL || abuf == NULL || alen <= 0 || enclen == NULL) {
92
+ return ARES_EBADNAME;
93
+ }
94
+
95
+ status = ares_expand_name_validated(encoded, abuf, (size_t)alen, s,
96
+ &enclen_temp, ARES_FALSE);
97
+ *enclen = (long)enclen_temp;
98
+ return (int)status;
99
+ }
@@ -0,0 +1,107 @@
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
+
28
+ #include "ares_private.h"
29
+
30
+ #ifdef HAVE_NETINET_IN_H
31
+ # include <netinet/in.h>
32
+ #endif
33
+
34
+ #include "ares_nameser.h"
35
+
36
+ /* Simply decodes a length-encoded character string. The first byte of the
37
+ * input is the length of the string to be returned and the bytes thereafter
38
+ * are the characters of the string. The returned result will be NULL
39
+ * terminated.
40
+ */
41
+ ares_status_t ares_expand_string_ex(const unsigned char *encoded,
42
+ const unsigned char *abuf, size_t alen,
43
+ unsigned char **s, size_t *enclen)
44
+ {
45
+ ares_status_t status;
46
+ ares_buf_t *buf = NULL;
47
+ size_t start_len;
48
+ size_t len = 0;
49
+
50
+ if (encoded == NULL || abuf == NULL || alen == 0 || enclen == NULL) {
51
+ return ARES_EBADSTR; /* EFORMERR would be better */
52
+ }
53
+
54
+ if (encoded < abuf || encoded >= abuf + alen) {
55
+ return ARES_EBADSTR; /* EFORMERR would be better */
56
+ }
57
+
58
+ *enclen = 0;
59
+
60
+ /* NOTE: we allow 's' to be NULL to skip it */
61
+ if (s) {
62
+ *s = NULL;
63
+ }
64
+
65
+ buf = ares_buf_create_const(abuf, alen);
66
+
67
+ if (buf == NULL) {
68
+ return ARES_ENOMEM;
69
+ }
70
+
71
+ status = ares_buf_set_position(buf, (size_t)(encoded - abuf));
72
+ if (status != ARES_SUCCESS) {
73
+ goto done;
74
+ }
75
+
76
+ start_len = ares_buf_len(buf);
77
+ status = ares_buf_parse_dns_binstr(buf, ares_buf_len(buf), s, &len);
78
+ /* hrm, no way to pass back 'len' with the prototype */
79
+ if (status != ARES_SUCCESS) {
80
+ goto done;
81
+ }
82
+
83
+ *enclen = start_len - ares_buf_len(buf);
84
+
85
+ done:
86
+ ares_buf_destroy(buf);
87
+ if (status == ARES_EBADNAME || status == ARES_EBADRESP) {
88
+ status = ARES_EBADSTR;
89
+ }
90
+ return status;
91
+ }
92
+
93
+ int ares_expand_string(const unsigned char *encoded, const unsigned char *abuf,
94
+ int alen, unsigned char **s, long *enclen)
95
+ {
96
+ ares_status_t status;
97
+ size_t temp_enclen = 0;
98
+
99
+ if (encoded == NULL || abuf == NULL || alen <= 0 || enclen == NULL) {
100
+ return ARES_EBADRESP;
101
+ }
102
+
103
+ status = ares_expand_string_ex(encoded, abuf, (size_t)alen, s, &temp_enclen);
104
+
105
+ *enclen = (long)temp_enclen;
106
+ return (int)status;
107
+ }
@@ -0,0 +1,80 @@
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
+
28
+ #include "ares_private.h"
29
+
30
+ int ares_fds(const ares_channel_t *channel, fd_set *read_fds, fd_set *write_fds)
31
+ {
32
+ ares_socket_t nfds;
33
+ ares_slist_node_t *snode;
34
+ /* Are there any active queries? */
35
+ size_t active_queries;
36
+
37
+ if (channel == NULL || read_fds == NULL || write_fds == NULL) {
38
+ return 0;
39
+ }
40
+
41
+ ares_channel_lock(channel);
42
+
43
+ active_queries = ares_llist_len(channel->all_queries);
44
+
45
+ nfds = 0;
46
+ for (snode = ares_slist_node_first(channel->servers); snode != NULL;
47
+ snode = ares_slist_node_next(snode)) {
48
+ ares_server_t *server = ares_slist_node_val(snode);
49
+ ares_llist_node_t *node;
50
+
51
+ for (node = ares_llist_node_first(server->connections); node != NULL;
52
+ node = ares_llist_node_next(node)) {
53
+ const ares_conn_t *conn = ares_llist_node_val(node);
54
+
55
+ if (!active_queries && !(conn->flags & ARES_CONN_FLAG_TCP)) {
56
+ continue;
57
+ }
58
+
59
+ /* Silence coverity, shouldn't be possible */
60
+ if (conn->fd == ARES_SOCKET_BAD) {
61
+ continue;
62
+ }
63
+
64
+ /* Always wait on read */
65
+ FD_SET(conn->fd, read_fds);
66
+
67
+ if (conn->fd >= nfds) {
68
+ nfds = conn->fd + 1;
69
+ }
70
+
71
+ /* TCP only wait on write if we have the flag set */
72
+ if (conn->state_flags & ARES_CONN_STATE_WRITE) {
73
+ FD_SET(conn->fd, write_fds);
74
+ }
75
+ }
76
+ }
77
+
78
+ ares_channel_unlock(channel);
79
+ return (int)nfds;
80
+ }
@@ -0,0 +1,85 @@
1
+ /* MIT License
2
+ *
3
+ * Copyright (c) 2005 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
+
29
+ int ares_getsock(const ares_channel_t *channel, ares_socket_t *socks,
30
+ int numsocks) /* size of the 'socks' array */
31
+ {
32
+ ares_slist_node_t *snode;
33
+ size_t sockindex = 0;
34
+ unsigned int bitmap = 0;
35
+ unsigned int setbits = 0xffffffff;
36
+
37
+ /* Are there any active queries? */
38
+ size_t active_queries;
39
+
40
+ if (channel == NULL || numsocks <= 0) {
41
+ return 0;
42
+ }
43
+
44
+ ares_channel_lock(channel);
45
+
46
+ active_queries = ares_llist_len(channel->all_queries);
47
+
48
+ for (snode = ares_slist_node_first(channel->servers); snode != NULL;
49
+ snode = ares_slist_node_next(snode)) {
50
+ ares_server_t *server = ares_slist_node_val(snode);
51
+ ares_llist_node_t *node;
52
+
53
+ for (node = ares_llist_node_first(server->connections); node != NULL;
54
+ node = ares_llist_node_next(node)) {
55
+ const ares_conn_t *conn = ares_llist_node_val(node);
56
+
57
+ if (sockindex >= (size_t)numsocks || sockindex >= ARES_GETSOCK_MAXNUM) {
58
+ break;
59
+ }
60
+
61
+ /* We only need to register interest in UDP sockets if we have
62
+ * outstanding queries.
63
+ */
64
+ if (!active_queries && !(conn->flags & ARES_CONN_FLAG_TCP)) {
65
+ continue;
66
+ }
67
+
68
+ socks[sockindex] = conn->fd;
69
+
70
+ if (active_queries || conn->flags & ARES_CONN_FLAG_TCP) {
71
+ bitmap |= ARES_GETSOCK_READABLE(setbits, sockindex);
72
+ }
73
+
74
+ if (conn->state_flags & ARES_CONN_STATE_WRITE) {
75
+ /* then the tcp socket is also writable! */
76
+ bitmap |= ARES_GETSOCK_WRITABLE(setbits, sockindex);
77
+ }
78
+
79
+ sockindex++;
80
+ }
81
+ }
82
+
83
+ ares_channel_unlock(channel);
84
+ return (int)bitmap;
85
+ }
@@ -0,0 +1,107 @@
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_NETINET_IN_H
31
+ # include <netinet/in.h>
32
+ #endif
33
+ #ifdef HAVE_NETDB_H
34
+ # include <netdb.h>
35
+ #endif
36
+ #ifdef HAVE_ARPA_INET_H
37
+ # include <arpa/inet.h>
38
+ #endif
39
+
40
+ #ifdef HAVE_STRINGS_H
41
+ # include <strings.h>
42
+ #endif
43
+
44
+ #ifdef HAVE_LIMITS_H
45
+ # include <limits.h>
46
+ #endif
47
+
48
+ int ares_parse_a_reply(const unsigned char *abuf, int alen,
49
+ struct hostent **host, struct ares_addrttl *addrttls,
50
+ int *naddrttls)
51
+ {
52
+ struct ares_addrinfo ai;
53
+ char *question_hostname = NULL;
54
+ ares_status_t status;
55
+ size_t req_naddrttls = 0;
56
+ ares_dns_record_t *dnsrec = NULL;
57
+
58
+ if (alen < 0) {
59
+ return ARES_EBADRESP;
60
+ }
61
+
62
+ if (naddrttls) {
63
+ req_naddrttls = (size_t)*naddrttls;
64
+ *naddrttls = 0;
65
+ }
66
+
67
+ memset(&ai, 0, sizeof(ai));
68
+
69
+ status = ares_dns_parse(abuf, (size_t)alen, 0, &dnsrec);
70
+ if (status != ARES_SUCCESS) {
71
+ goto fail;
72
+ }
73
+
74
+ status = ares_parse_into_addrinfo(dnsrec, 0, 0, &ai);
75
+ if (status != ARES_SUCCESS && status != ARES_ENODATA) {
76
+ goto fail;
77
+ }
78
+
79
+ if (host != NULL) {
80
+ *host = NULL;
81
+ status = ares_addrinfo2hostent(&ai, AF_INET, host);
82
+ if (status != ARES_SUCCESS && status != ARES_ENODATA) {
83
+ goto fail; /* LCOV_EXCL_LINE: DefensiveCoding */
84
+ }
85
+ }
86
+
87
+ if (addrttls != NULL && req_naddrttls) {
88
+ size_t temp_naddrttls = 0;
89
+ ares_addrinfo2addrttl(&ai, AF_INET, req_naddrttls, addrttls, NULL,
90
+ &temp_naddrttls);
91
+ *naddrttls = (int)temp_naddrttls;
92
+ }
93
+
94
+
95
+ fail:
96
+ ares_freeaddrinfo_cnames(ai.cnames);
97
+ ares_freeaddrinfo_nodes(ai.nodes);
98
+ ares_free(ai.name);
99
+ ares_free(question_hostname);
100
+ ares_dns_record_destroy(dnsrec);
101
+
102
+ if (status == ARES_EBADNAME) {
103
+ status = ARES_EBADRESP;
104
+ }
105
+
106
+ return (int)status;
107
+ }
@@ -0,0 +1,109 @@
1
+ /* MIT License
2
+ *
3
+ * Copyright (c) 1998 Massachusetts Institute of Technology
4
+ * Copyright (c) 2005 Dominick Meglio
5
+ * Copyright (c) 2019 Andrew Selivanov
6
+ *
7
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ * of this software and associated documentation files (the "Software"), to deal
9
+ * in the Software without restriction, including without limitation the rights
10
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ * copies of the Software, and to permit persons to whom the Software is
12
+ * furnished to do so, subject to the following conditions:
13
+ *
14
+ * The above copyright notice and this permission notice (including the next
15
+ * paragraph) shall be included in all copies or substantial portions of the
16
+ * Software.
17
+ *
18
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24
+ * SOFTWARE.
25
+ *
26
+ * SPDX-License-Identifier: MIT
27
+ */
28
+
29
+ #include "ares_private.h"
30
+
31
+ #ifdef HAVE_NETINET_IN_H
32
+ # include <netinet/in.h>
33
+ #endif
34
+ #ifdef HAVE_NETDB_H
35
+ # include <netdb.h>
36
+ #endif
37
+ #ifdef HAVE_ARPA_INET_H
38
+ # include <arpa/inet.h>
39
+ #endif
40
+
41
+ #ifdef HAVE_STRINGS_H
42
+ # include <strings.h>
43
+ #endif
44
+
45
+ #ifdef HAVE_LIMITS_H
46
+ # include <limits.h>
47
+ #endif
48
+
49
+ #include "ares_inet_net_pton.h"
50
+
51
+ int ares_parse_aaaa_reply(const unsigned char *abuf, int alen,
52
+ struct hostent **host, struct ares_addr6ttl *addrttls,
53
+ int *naddrttls)
54
+ {
55
+ struct ares_addrinfo ai;
56
+ char *question_hostname = NULL;
57
+ ares_status_t status;
58
+ size_t req_naddrttls = 0;
59
+ ares_dns_record_t *dnsrec = NULL;
60
+
61
+ if (alen < 0) {
62
+ return ARES_EBADRESP;
63
+ }
64
+
65
+ if (naddrttls) {
66
+ req_naddrttls = (size_t)*naddrttls;
67
+ *naddrttls = 0;
68
+ }
69
+
70
+ memset(&ai, 0, sizeof(ai));
71
+
72
+ status = ares_dns_parse(abuf, (size_t)alen, 0, &dnsrec);
73
+ if (status != ARES_SUCCESS) {
74
+ goto fail;
75
+ }
76
+
77
+ status = ares_parse_into_addrinfo(dnsrec, 0, 0, &ai);
78
+ if (status != ARES_SUCCESS && status != ARES_ENODATA) {
79
+ goto fail;
80
+ }
81
+
82
+ if (host != NULL) {
83
+ *host = NULL;
84
+ status = ares_addrinfo2hostent(&ai, AF_INET6, host);
85
+ if (status != ARES_SUCCESS && status != ARES_ENODATA) {
86
+ goto fail; /* LCOV_EXCL_LINE: DefensiveCoding */
87
+ }
88
+ }
89
+
90
+ if (addrttls != NULL && req_naddrttls) {
91
+ size_t temp_naddrttls = 0;
92
+ ares_addrinfo2addrttl(&ai, AF_INET6, req_naddrttls, NULL, addrttls,
93
+ &temp_naddrttls);
94
+ *naddrttls = (int)temp_naddrttls;
95
+ }
96
+
97
+ fail:
98
+ ares_freeaddrinfo_cnames(ai.cnames);
99
+ ares_freeaddrinfo_nodes(ai.nodes);
100
+ ares_free(question_hostname);
101
+ ares_free(ai.name);
102
+ ares_dns_record_destroy(dnsrec);
103
+
104
+ if (status == ARES_EBADNAME) {
105
+ status = ARES_EBADRESP;
106
+ }
107
+
108
+ return (int)status;
109
+ }