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.
- package/README.md +12 -4
- package/THIRD_PARTY_LICENSES +31 -1
- package/cli.js +3745 -890
- package/node/include/js_node.h +12 -1
- package/node/prelude/_http_common.js +29 -0
- package/node/prelude/async_hooks.js +50 -11
- package/node/prelude/child_process.js +31 -4
- package/node/prelude/console.js +311 -143
- package/node/prelude/crypto.js +6 -4
- package/node/prelude/dgram.js +1169 -0
- package/node/prelude/diagnostics_channel.js +3 -1
- package/node/prelude/dns.js +250 -45
- package/node/prelude/dns_promises.js +8 -2
- package/node/prelude/fs_promises.js +9 -1
- package/node/prelude/http.js +405 -94
- package/node/prelude/https.js +13 -4
- package/node/prelude/internal/console_class.js +7 -0
- package/node/prelude/internal/console_global.js +25 -0
- package/node/prelude/internal/crypto/key_encryption.js +217 -0
- package/node/prelude/internal/crypto/keys.js +161 -26
- package/node/prelude/internal/crypto/random.js +24 -0
- package/node/prelude/internal/crypto/util.js +2 -1
- package/node/prelude/internal/crypto_x509.js +161 -0
- package/node/prelude/internal/dns_classes.js +6 -0
- package/node/prelude/internal/dns_resolver.js +371 -0
- package/node/prelude/internal/errors.js +9 -0
- package/node/prelude/internal/events_on.js +82 -37
- package/node/prelude/internal/features.js +8 -4
- package/node/prelude/internal/fs_filehandle.js +10 -4
- package/node/prelude/internal/http_chars.ts +22 -0
- package/node/prelude/internal/perf_histogram.js +1 -1
- package/node/prelude/internal/process_more.js +32 -17
- package/node/prelude/internal/process_signals.js +8 -2
- package/node/prelude/internal/punycode.ts +163 -0
- package/node/prelude/internal/readline.js +648 -274
- package/node/prelude/internal/readline_editor.js +1240 -0
- package/node/prelude/internal/string_width.js +43 -0
- package/node/prelude/internal/tls/common.js +145 -33
- package/node/prelude/internal/tls/wrap.js +182 -49
- package/node/prelude/internal/tls/x509.js +4 -1
- package/node/prelude/internal/udp.js +177 -0
- package/node/prelude/net.js +30 -14
- package/node/prelude/os.js +24 -6
- package/node/prelude/perf_hooks.js +37 -2
- package/node/prelude/punycode.js +2 -130
- package/node/prelude/readline.js +113 -4
- package/node/prelude/readline_promises.js +56 -32
- package/node/prelude/tls.js +21 -4
- package/node/prelude/util.js +3 -16
- package/node/src/host_dns.c +623 -0
- package/node/src/host_http.c +12 -0
- package/node/src/host_net.c +46 -0
- package/node/src/host_os.c +1 -6
- package/node/src/host_sys.c +79 -0
- package/node/src/host_udp.c +418 -0
- package/node/third_party/c-ares/LICENSE.md +24 -0
- package/node/third_party/c-ares/config/darwin/ares_config.h +573 -0
- package/node/third_party/c-ares/config/freebsd/ares_config.h +573 -0
- package/node/third_party/c-ares/config/linux/ares_config.h +573 -0
- package/node/third_party/c-ares/config/openbsd/ares_config.h +583 -0
- package/node/third_party/c-ares/include/ares.h +1237 -0
- package/node/third_party/c-ares/include/ares_build.h +202 -0
- package/node/third_party/c-ares/include/ares_dns.h +127 -0
- package/node/third_party/c-ares/include/ares_dns_record.h +1119 -0
- package/node/third_party/c-ares/include/ares_nameser.h +510 -0
- package/node/third_party/c-ares/include/ares_version.h +47 -0
- package/node/third_party/c-ares/src/lib/ares_addrinfo2hostent.c +305 -0
- package/node/third_party/c-ares/src/lib/ares_addrinfo_localhost.c +245 -0
- package/node/third_party/c-ares/src/lib/ares_android.c +496 -0
- package/node/third_party/c-ares/src/lib/ares_android.h +38 -0
- package/node/third_party/c-ares/src/lib/ares_cancel.c +87 -0
- package/node/third_party/c-ares/src/lib/ares_close_sockets.c +137 -0
- package/node/third_party/c-ares/src/lib/ares_conn.c +511 -0
- package/node/third_party/c-ares/src/lib/ares_conn.h +202 -0
- package/node/third_party/c-ares/src/lib/ares_cookie.c +461 -0
- package/node/third_party/c-ares/src/lib/ares_data.c +168 -0
- package/node/third_party/c-ares/src/lib/ares_data.h +92 -0
- package/node/third_party/c-ares/src/lib/ares_destroy.c +159 -0
- package/node/third_party/c-ares/src/lib/ares_free_hostent.c +54 -0
- package/node/third_party/c-ares/src/lib/ares_free_string.c +33 -0
- package/node/third_party/c-ares/src/lib/ares_freeaddrinfo.c +67 -0
- package/node/third_party/c-ares/src/lib/ares_getaddrinfo.c +806 -0
- package/node/third_party/c-ares/src/lib/ares_getenv.c +38 -0
- package/node/third_party/c-ares/src/lib/ares_getenv.h +34 -0
- package/node/third_party/c-ares/src/lib/ares_gethostbyaddr.c +229 -0
- package/node/third_party/c-ares/src/lib/ares_gethostbyname.c +341 -0
- package/node/third_party/c-ares/src/lib/ares_getnameinfo.c +437 -0
- package/node/third_party/c-ares/src/lib/ares_hosts_file.c +960 -0
- package/node/third_party/c-ares/src/lib/ares_inet_net_pton.h +31 -0
- package/node/third_party/c-ares/src/lib/ares_init.c +631 -0
- package/node/third_party/c-ares/src/lib/ares_ipv6.h +115 -0
- package/node/third_party/c-ares/src/lib/ares_library_init.c +190 -0
- package/node/third_party/c-ares/src/lib/ares_metrics.c +261 -0
- package/node/third_party/c-ares/src/lib/ares_options.c +492 -0
- package/node/third_party/c-ares/src/lib/ares_parse_into_addrinfo.c +179 -0
- package/node/third_party/c-ares/src/lib/ares_private.h +648 -0
- package/node/third_party/c-ares/src/lib/ares_process.c +1649 -0
- package/node/third_party/c-ares/src/lib/ares_qcache.c +442 -0
- package/node/third_party/c-ares/src/lib/ares_query.c +151 -0
- package/node/third_party/c-ares/src/lib/ares_search.c +623 -0
- package/node/third_party/c-ares/src/lib/ares_send.c +300 -0
- package/node/third_party/c-ares/src/lib/ares_set_socket_functions.c +590 -0
- package/node/third_party/c-ares/src/lib/ares_setup.h +224 -0
- package/node/third_party/c-ares/src/lib/ares_socket.c +427 -0
- package/node/third_party/c-ares/src/lib/ares_socket.h +163 -0
- package/node/third_party/c-ares/src/lib/ares_sortaddrinfo.c +447 -0
- package/node/third_party/c-ares/src/lib/ares_strerror.c +91 -0
- package/node/third_party/c-ares/src/lib/ares_sysconfig.c +642 -0
- package/node/third_party/c-ares/src/lib/ares_sysconfig_files.c +851 -0
- package/node/third_party/c-ares/src/lib/ares_sysconfig_mac.c +373 -0
- package/node/third_party/c-ares/src/lib/ares_sysconfig_win.c +673 -0
- package/node/third_party/c-ares/src/lib/ares_timeout.c +162 -0
- package/node/third_party/c-ares/src/lib/ares_update_servers.c +1376 -0
- package/node/third_party/c-ares/src/lib/ares_version.c +36 -0
- package/node/third_party/c-ares/src/lib/config-dos.h +114 -0
- package/node/third_party/c-ares/src/lib/config-win32.h +396 -0
- package/node/third_party/c-ares/src/lib/dsa/ares_array.c +409 -0
- package/node/third_party/c-ares/src/lib/dsa/ares_htable.c +451 -0
- package/node/third_party/c-ares/src/lib/dsa/ares_htable.h +174 -0
- package/node/third_party/c-ares/src/lib/dsa/ares_htable_asvp.c +224 -0
- package/node/third_party/c-ares/src/lib/dsa/ares_htable_dict.c +230 -0
- package/node/third_party/c-ares/src/lib/dsa/ares_htable_strvp.c +210 -0
- package/node/third_party/c-ares/src/lib/dsa/ares_htable_szvp.c +188 -0
- package/node/third_party/c-ares/src/lib/dsa/ares_htable_vpstr.c +186 -0
- package/node/third_party/c-ares/src/lib/dsa/ares_htable_vpvp.c +194 -0
- package/node/third_party/c-ares/src/lib/dsa/ares_llist.c +385 -0
- package/node/third_party/c-ares/src/lib/dsa/ares_slist.c +479 -0
- package/node/third_party/c-ares/src/lib/dsa/ares_slist.h +207 -0
- package/node/third_party/c-ares/src/lib/event/ares_event.h +191 -0
- package/node/third_party/c-ares/src/lib/event/ares_event_configchg.c +746 -0
- package/node/third_party/c-ares/src/lib/event/ares_event_epoll.c +192 -0
- package/node/third_party/c-ares/src/lib/event/ares_event_kqueue.c +248 -0
- package/node/third_party/c-ares/src/lib/event/ares_event_poll.c +140 -0
- package/node/third_party/c-ares/src/lib/event/ares_event_select.c +159 -0
- package/node/third_party/c-ares/src/lib/event/ares_event_thread.c +575 -0
- package/node/third_party/c-ares/src/lib/event/ares_event_wake_pipe.c +172 -0
- package/node/third_party/c-ares/src/lib/event/ares_event_win32.c +981 -0
- package/node/third_party/c-ares/src/lib/event/ares_event_win32.h +161 -0
- package/node/third_party/c-ares/src/lib/include/ares_array.h +276 -0
- package/node/third_party/c-ares/src/lib/include/ares_buf.h +732 -0
- package/node/third_party/c-ares/src/lib/include/ares_htable_asvp.h +130 -0
- package/node/third_party/c-ares/src/lib/include/ares_htable_dict.h +123 -0
- package/node/third_party/c-ares/src/lib/include/ares_htable_strvp.h +130 -0
- package/node/third_party/c-ares/src/lib/include/ares_htable_szvp.h +118 -0
- package/node/third_party/c-ares/src/lib/include/ares_htable_vpstr.h +111 -0
- package/node/third_party/c-ares/src/lib/include/ares_htable_vpvp.h +128 -0
- package/node/third_party/c-ares/src/lib/include/ares_llist.h +239 -0
- package/node/third_party/c-ares/src/lib/include/ares_mem.h +41 -0
- package/node/third_party/c-ares/src/lib/include/ares_str.h +261 -0
- package/node/third_party/c-ares/src/lib/inet_net_pton.c +451 -0
- package/node/third_party/c-ares/src/lib/inet_ntop.c +219 -0
- package/node/third_party/c-ares/src/lib/legacy/ares_create_query.c +78 -0
- package/node/third_party/c-ares/src/lib/legacy/ares_expand_name.c +99 -0
- package/node/third_party/c-ares/src/lib/legacy/ares_expand_string.c +107 -0
- package/node/third_party/c-ares/src/lib/legacy/ares_fds.c +80 -0
- package/node/third_party/c-ares/src/lib/legacy/ares_getsock.c +85 -0
- package/node/third_party/c-ares/src/lib/legacy/ares_parse_a_reply.c +107 -0
- package/node/third_party/c-ares/src/lib/legacy/ares_parse_aaaa_reply.c +109 -0
- package/node/third_party/c-ares/src/lib/legacy/ares_parse_caa_reply.c +137 -0
- package/node/third_party/c-ares/src/lib/legacy/ares_parse_mx_reply.c +110 -0
- package/node/third_party/c-ares/src/lib/legacy/ares_parse_naptr_reply.c +132 -0
- package/node/third_party/c-ares/src/lib/legacy/ares_parse_ns_reply.c +154 -0
- package/node/third_party/c-ares/src/lib/legacy/ares_parse_ptr_reply.c +213 -0
- package/node/third_party/c-ares/src/lib/legacy/ares_parse_soa_reply.c +115 -0
- package/node/third_party/c-ares/src/lib/legacy/ares_parse_srv_reply.c +114 -0
- package/node/third_party/c-ares/src/lib/legacy/ares_parse_txt_reply.c +144 -0
- package/node/third_party/c-ares/src/lib/legacy/ares_parse_uri_reply.c +113 -0
- package/node/third_party/c-ares/src/lib/record/ares_dns_mapping.c +982 -0
- package/node/third_party/c-ares/src/lib/record/ares_dns_multistring.c +309 -0
- package/node/third_party/c-ares/src/lib/record/ares_dns_multistring.h +72 -0
- package/node/third_party/c-ares/src/lib/record/ares_dns_name.c +736 -0
- package/node/third_party/c-ares/src/lib/record/ares_dns_parse.c +1360 -0
- package/node/third_party/c-ares/src/lib/record/ares_dns_private.h +273 -0
- package/node/third_party/c-ares/src/lib/record/ares_dns_record.c +1701 -0
- package/node/third_party/c-ares/src/lib/record/ares_dns_write.c +1229 -0
- package/node/third_party/c-ares/src/lib/str/ares_buf.c +1510 -0
- package/node/third_party/c-ares/src/lib/str/ares_str.c +562 -0
- package/node/third_party/c-ares/src/lib/str/ares_strsplit.c +90 -0
- package/node/third_party/c-ares/src/lib/str/ares_strsplit.h +51 -0
- package/node/third_party/c-ares/src/lib/thirdparty/apple/dnsinfo.h +122 -0
- package/node/third_party/c-ares/src/lib/util/ares_iface_ips.c +640 -0
- package/node/third_party/c-ares/src/lib/util/ares_iface_ips.h +140 -0
- package/node/third_party/c-ares/src/lib/util/ares_math.c +167 -0
- package/node/third_party/c-ares/src/lib/util/ares_math.h +58 -0
- package/node/third_party/c-ares/src/lib/util/ares_rand.c +389 -0
- package/node/third_party/c-ares/src/lib/util/ares_rand.h +36 -0
- package/node/third_party/c-ares/src/lib/util/ares_threads.c +613 -0
- package/node/third_party/c-ares/src/lib/util/ares_threads.h +60 -0
- package/node/third_party/c-ares/src/lib/util/ares_time.h +49 -0
- package/node/third_party/c-ares/src/lib/util/ares_timeval.c +95 -0
- package/node/third_party/c-ares/src/lib/util/ares_uri.c +1627 -0
- package/node/third_party/c-ares/src/lib/util/ares_uri.h +252 -0
- package/node/third_party/c-ares/src/lib/windows_port.c +29 -0
- package/package.json +1 -1
- package/prebuilt/darwin-arm64/cares-a6286c65ca9374a3.a +0 -0
- package/prebuilt/darwin-x64/cares-a6286c65ca9374a3.a +0 -0
- package/prebuilt/linux-arm64/cares-4ba05ac8e948af8e.a +0 -0
- package/prebuilt/linux-arm64-musl/cares-4ba05ac8e948af8e.a +0 -0
- package/prebuilt/linux-x64/cares-4ba05ac8e948af8e.a +0 -0
- package/prebuilt/linux-x64-musl/cares-4ba05ac8e948af8e.a +0 -0
- package/prebuilt/win32-x64/boringssl-ce573858472b7fc9.a +0 -0
- package/prebuilt/win32-x64/brotli-20d86a61f30baeb3.a +0 -0
- package/prebuilt/win32-x64/cares-49c9ec95162b912d.a +0 -0
- package/prebuilt/win32-x64/uv-b11bae65d7fced82.a +0 -0
- package/prebuilt/win32-x64/zlib-4ce2317a4c3f5fb5.a +0 -0
- package/prebuilt/win32-x64/zstd-015315ac7c784c73.a +0 -0
- package/runtime/include/js_buffer.h +185 -0
- package/runtime/include/js_builtins.h +58 -0
- package/runtime/include/js_crypto.h +11 -0
- package/runtime/include/js_exception.h +3 -0
- package/runtime/include/js_function.h +1 -1
- package/runtime/include/js_gc.h +13 -10
- package/runtime/include/js_jobs.h +2 -0
- package/runtime/include/js_object.h +79 -3
- package/runtime/include/js_ops.h +27 -0
- package/runtime/include/js_runtime.h +1 -0
- package/runtime/include/js_web.h +0 -3
- package/runtime/include/jscontext.h +8 -0
- package/runtime/src/builtins.c +17 -4
- package/runtime/src/crypto_internal.h +1 -0
- package/runtime/src/crypto_subtle.c +66 -7
- package/runtime/src/crypto_tls.c +265 -19
- package/runtime/src/function.c +37 -10
- package/runtime/src/gc.c +76 -93
- package/runtime/src/inspect.c +18 -1
- package/runtime/src/iterator.c +5 -1
- package/runtime/src/jobs.c +37 -22
- package/runtime/src/object.c +91 -8
- package/runtime/src/os.c +16 -6
- package/runtime/src/os.h +2 -0
- package/runtime/src/process.c +97 -10
- package/runtime/src/typedarray.c +23 -0
|
@@ -0,0 +1,31 @@
|
|
|
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
|
+
#ifndef HEADER_CARES_INET_NET_PTON_H
|
|
27
|
+
#define HEADER_CARES_INET_NET_PTON_H
|
|
28
|
+
|
|
29
|
+
int ares_inet_net_pton(int af, const char *src, void *dst, size_t size);
|
|
30
|
+
|
|
31
|
+
#endif /* HEADER_CARES_INET_NET_PTON_H */
|
|
@@ -0,0 +1,631 @@
|
|
|
1
|
+
/* MIT License
|
|
2
|
+
*
|
|
3
|
+
* Copyright (c) 1998 Massachusetts Institute of Technology
|
|
4
|
+
* Copyright (c) 2007 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
|
+
|
|
30
|
+
#ifdef HAVE_SYS_PARAM_H
|
|
31
|
+
# include <sys/param.h>
|
|
32
|
+
#endif
|
|
33
|
+
|
|
34
|
+
#ifdef HAVE_NETINET_IN_H
|
|
35
|
+
# include <netinet/in.h>
|
|
36
|
+
#endif
|
|
37
|
+
|
|
38
|
+
#ifdef HAVE_NETDB_H
|
|
39
|
+
# include <netdb.h>
|
|
40
|
+
#endif
|
|
41
|
+
|
|
42
|
+
#ifdef HAVE_ARPA_INET_H
|
|
43
|
+
# include <arpa/inet.h>
|
|
44
|
+
#endif
|
|
45
|
+
|
|
46
|
+
#include "ares_nameser.h"
|
|
47
|
+
|
|
48
|
+
#if defined(ANDROID) || defined(__ANDROID__)
|
|
49
|
+
# include <sys/system_properties.h>
|
|
50
|
+
# include "ares_android.h"
|
|
51
|
+
/* From the Bionic sources */
|
|
52
|
+
# define DNS_PROP_NAME_PREFIX "net.dns"
|
|
53
|
+
# define MAX_DNS_PROPERTIES 8
|
|
54
|
+
#endif
|
|
55
|
+
|
|
56
|
+
#if defined(CARES_USE_LIBRESOLV)
|
|
57
|
+
# include <resolv.h>
|
|
58
|
+
#endif
|
|
59
|
+
|
|
60
|
+
#if defined(USE_WINSOCK) && defined(HAVE_IPHLPAPI_H)
|
|
61
|
+
# include <iphlpapi.h>
|
|
62
|
+
#endif
|
|
63
|
+
|
|
64
|
+
#include "ares_inet_net_pton.h"
|
|
65
|
+
#include "event/ares_event.h"
|
|
66
|
+
|
|
67
|
+
int ares_init(ares_channel_t **channelptr)
|
|
68
|
+
{
|
|
69
|
+
return ares_init_options(channelptr, NULL, 0);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
static int ares_query_timeout_cmp_cb(const void *arg1, const void *arg2)
|
|
73
|
+
{
|
|
74
|
+
const ares_query_t *q1 = arg1;
|
|
75
|
+
const ares_query_t *q2 = arg2;
|
|
76
|
+
|
|
77
|
+
if (q1->timeout.sec > q2->timeout.sec) {
|
|
78
|
+
return 1;
|
|
79
|
+
}
|
|
80
|
+
if (q1->timeout.sec < q2->timeout.sec) {
|
|
81
|
+
return -1;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
if (q1->timeout.usec > q2->timeout.usec) {
|
|
85
|
+
return 1;
|
|
86
|
+
}
|
|
87
|
+
if (q1->timeout.usec < q2->timeout.usec) {
|
|
88
|
+
return -1;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
return 0;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
static int server_sort_cb(const void *data1, const void *data2)
|
|
95
|
+
{
|
|
96
|
+
const ares_server_t *s1 = data1;
|
|
97
|
+
const ares_server_t *s2 = data2;
|
|
98
|
+
|
|
99
|
+
if (s1->consec_failures < s2->consec_failures) {
|
|
100
|
+
return -1;
|
|
101
|
+
}
|
|
102
|
+
if (s1->consec_failures > s2->consec_failures) {
|
|
103
|
+
return 1;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/* Among servers with the same failure count, prefer the one that failed
|
|
107
|
+
* least recently so that a server that went down long ago (and may have
|
|
108
|
+
* since recovered) is tried before one that just failed. This also keeps
|
|
109
|
+
* retries rotating across servers once the failure counts saturate at
|
|
110
|
+
* SERVER_CONSEC_FAILURES_CAP. Healthy servers all have a zeroed retry
|
|
111
|
+
* time and fall through to configuration order. */
|
|
112
|
+
if (s1->next_retry_time.sec != s2->next_retry_time.sec) {
|
|
113
|
+
return s1->next_retry_time.sec < s2->next_retry_time.sec ? -1 : 1;
|
|
114
|
+
}
|
|
115
|
+
if (s1->next_retry_time.usec != s2->next_retry_time.usec) {
|
|
116
|
+
return s1->next_retry_time.usec < s2->next_retry_time.usec ? -1 : 1;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
if (s1->idx < s2->idx) {
|
|
120
|
+
return -1;
|
|
121
|
+
}
|
|
122
|
+
if (s1->idx > s2->idx) {
|
|
123
|
+
return 1;
|
|
124
|
+
}
|
|
125
|
+
return 0;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
static void server_destroy_cb(void *data)
|
|
129
|
+
{
|
|
130
|
+
if (data == NULL) {
|
|
131
|
+
return; /* LCOV_EXCL_LINE: DefensiveCoding */
|
|
132
|
+
}
|
|
133
|
+
ares_destroy_server(data);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
static ares_status_t init_by_defaults(ares_channel_t *channel)
|
|
137
|
+
{
|
|
138
|
+
char *hostname = NULL;
|
|
139
|
+
ares_status_t rc = ARES_SUCCESS;
|
|
140
|
+
#ifdef HAVE_GETHOSTNAME
|
|
141
|
+
const char *dot;
|
|
142
|
+
#endif
|
|
143
|
+
struct ares_addr addr;
|
|
144
|
+
ares_llist_t *sconfig = NULL;
|
|
145
|
+
|
|
146
|
+
/* Enable EDNS by default */
|
|
147
|
+
if (!(channel->optmask & ARES_OPT_FLAGS)) {
|
|
148
|
+
channel->flags = ARES_FLAG_EDNS;
|
|
149
|
+
}
|
|
150
|
+
if (channel->ednspsz == 0) {
|
|
151
|
+
channel->ednspsz = EDNSPACKETSZ;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
if (channel->timeout == 0) {
|
|
155
|
+
channel->timeout = DEFAULT_TIMEOUT;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
if (channel->tries == 0) {
|
|
159
|
+
channel->tries = DEFAULT_TRIES;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
if (ares_slist_len(channel->servers) == 0) {
|
|
163
|
+
/* Add a default local named server to the channel unless configured not
|
|
164
|
+
* to (in which case return an error).
|
|
165
|
+
*/
|
|
166
|
+
if (channel->flags & ARES_FLAG_NO_DFLT_SVR) {
|
|
167
|
+
rc = ARES_ENOSERVER;
|
|
168
|
+
goto error;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
addr.family = AF_INET;
|
|
172
|
+
addr.addr.addr4.s_addr = htonl(INADDR_LOOPBACK);
|
|
173
|
+
|
|
174
|
+
rc = ares_sconfig_append(channel, &sconfig, &addr, 0, 0, NULL);
|
|
175
|
+
if (rc != ARES_SUCCESS) {
|
|
176
|
+
goto error; /* LCOV_EXCL_LINE: OutOfMemory */
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
rc = ares_servers_update(channel, sconfig, ARES_FALSE);
|
|
180
|
+
ares_llist_destroy(sconfig);
|
|
181
|
+
|
|
182
|
+
if (rc != ARES_SUCCESS) {
|
|
183
|
+
goto error;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
if (channel->ndomains == 0) {
|
|
188
|
+
/* Derive a default domain search list from the kernel hostname,
|
|
189
|
+
* or set it to empty if the hostname isn't helpful.
|
|
190
|
+
*/
|
|
191
|
+
#ifndef HAVE_GETHOSTNAME
|
|
192
|
+
channel->ndomains = 0; /* default to none */
|
|
193
|
+
#else
|
|
194
|
+
size_t len = 256;
|
|
195
|
+
channel->ndomains = 0; /* default to none */
|
|
196
|
+
|
|
197
|
+
hostname = ares_malloc(len);
|
|
198
|
+
if (!hostname) {
|
|
199
|
+
rc = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */
|
|
200
|
+
goto error; /* LCOV_EXCL_LINE: OutOfMemory */
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
if (gethostname(hostname, (GETHOSTNAME_TYPE_ARG2)len) != 0) {
|
|
204
|
+
/* Lets not treat a gethostname failure as critical, since we
|
|
205
|
+
* are ok if gethostname doesn't even exist */
|
|
206
|
+
*hostname = '\0';
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
dot = strchr(hostname, '.');
|
|
210
|
+
if (dot) {
|
|
211
|
+
/* a dot was found */
|
|
212
|
+
channel->domains = ares_malloc(sizeof(char *));
|
|
213
|
+
if (!channel->domains) {
|
|
214
|
+
rc = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */
|
|
215
|
+
goto error; /* LCOV_EXCL_LINE: OutOfMemory */
|
|
216
|
+
}
|
|
217
|
+
channel->domains[0] = ares_strdup(dot + 1);
|
|
218
|
+
if (!channel->domains[0]) {
|
|
219
|
+
rc = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */
|
|
220
|
+
goto error; /* LCOV_EXCL_LINE: OutOfMemory */
|
|
221
|
+
}
|
|
222
|
+
channel->ndomains = 1;
|
|
223
|
+
}
|
|
224
|
+
#endif
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
if (channel->nsort == 0) {
|
|
228
|
+
channel->sortlist = NULL;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
if (!channel->lookups) {
|
|
232
|
+
channel->lookups = ares_strdup("fb");
|
|
233
|
+
if (!channel->lookups) {
|
|
234
|
+
rc = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
/* Set default fields for server failover behavior */
|
|
239
|
+
if (!(channel->optmask & ARES_OPT_SERVER_FAILOVER)) {
|
|
240
|
+
channel->server_retry_chance = DEFAULT_SERVER_RETRY_CHANCE;
|
|
241
|
+
channel->server_retry_delay = DEFAULT_SERVER_RETRY_DELAY;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
error:
|
|
245
|
+
if (hostname) {
|
|
246
|
+
ares_free(hostname);
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
return rc;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
int ares_init_options(ares_channel_t **channelptr,
|
|
253
|
+
const struct ares_options *options, int optmask)
|
|
254
|
+
{
|
|
255
|
+
ares_channel_t *channel;
|
|
256
|
+
ares_status_t status = ARES_SUCCESS;
|
|
257
|
+
|
|
258
|
+
if (ares_library_initialized() != ARES_SUCCESS) {
|
|
259
|
+
return ARES_ENOTINITIALIZED; /* LCOV_EXCL_LINE: n/a on non-WinSock */
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
channel = ares_malloc_zero(sizeof(*channel));
|
|
263
|
+
if (!channel) {
|
|
264
|
+
*channelptr = NULL;
|
|
265
|
+
return ARES_ENOMEM;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
/* We are in a good state */
|
|
269
|
+
channel->sys_up = ARES_TRUE;
|
|
270
|
+
|
|
271
|
+
/* One option where zero is valid, so set default value here */
|
|
272
|
+
channel->ndots = 1;
|
|
273
|
+
|
|
274
|
+
status = ares_channel_threading_init(channel);
|
|
275
|
+
if (status != ARES_SUCCESS) {
|
|
276
|
+
goto done;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
/* Generate random key */
|
|
280
|
+
channel->rand_state = ares_init_rand_state();
|
|
281
|
+
if (channel->rand_state == NULL) {
|
|
282
|
+
status = ARES_ENOMEM;
|
|
283
|
+
DEBUGF(fprintf(stderr, "Error: init_id_key failed: %s\n",
|
|
284
|
+
ares_strerror(status)));
|
|
285
|
+
goto done;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
ares_set_socket_functions_def(channel);
|
|
289
|
+
|
|
290
|
+
/* Initialize Server List */
|
|
291
|
+
channel->servers =
|
|
292
|
+
ares_slist_create(channel->rand_state, server_sort_cb, server_destroy_cb);
|
|
293
|
+
if (channel->servers == NULL) {
|
|
294
|
+
status = ARES_ENOMEM;
|
|
295
|
+
goto done;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
/* Initialize our lists of queries */
|
|
299
|
+
channel->all_queries = ares_llist_create(NULL);
|
|
300
|
+
if (channel->all_queries == NULL) {
|
|
301
|
+
status = ARES_ENOMEM;
|
|
302
|
+
goto done;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
channel->queries_by_qid = ares_htable_szvp_create(NULL);
|
|
306
|
+
if (channel->queries_by_qid == NULL) {
|
|
307
|
+
status = ARES_ENOMEM;
|
|
308
|
+
goto done;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
channel->queries_by_timeout =
|
|
312
|
+
ares_slist_create(channel->rand_state, ares_query_timeout_cmp_cb, NULL);
|
|
313
|
+
if (channel->queries_by_timeout == NULL) {
|
|
314
|
+
status = ARES_ENOMEM;
|
|
315
|
+
goto done;
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
channel->connnode_by_socket = ares_htable_asvp_create(NULL);
|
|
319
|
+
if (channel->connnode_by_socket == NULL) {
|
|
320
|
+
status = ARES_ENOMEM;
|
|
321
|
+
goto done;
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
/* Initialize configuration by each of the four sources, from highest
|
|
325
|
+
* precedence to lowest.
|
|
326
|
+
*/
|
|
327
|
+
|
|
328
|
+
status = ares_init_by_options(channel, options, optmask);
|
|
329
|
+
if (status != ARES_SUCCESS) {
|
|
330
|
+
DEBUGF(fprintf(stderr, "Error: init_by_options failed: %s\n",
|
|
331
|
+
ares_strerror(status)));
|
|
332
|
+
/* If we fail to apply user-specified options, fail the whole init process
|
|
333
|
+
*/
|
|
334
|
+
goto done;
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
/* Go ahead and let it initialize the query cache even if the ttl is 0 and
|
|
338
|
+
* completely unused. This reduces the number of different code paths that
|
|
339
|
+
* might be followed even if there is a minor performance hit. */
|
|
340
|
+
status = ares_qcache_create(channel->rand_state, channel->qcache_max_ttl,
|
|
341
|
+
&channel->qcache);
|
|
342
|
+
if (status != ARES_SUCCESS) {
|
|
343
|
+
goto done; /* LCOV_EXCL_LINE: OutOfMemory */
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
if (status == ARES_SUCCESS) {
|
|
347
|
+
status = ares_init_by_sysconfig(channel);
|
|
348
|
+
if (status != ARES_SUCCESS) {
|
|
349
|
+
DEBUGF(fprintf(stderr, "Error: init_by_sysconfig failed: %s\n",
|
|
350
|
+
ares_strerror(status)));
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
/*
|
|
355
|
+
* No matter what failed or succeeded, seed defaults to provide
|
|
356
|
+
* useful behavior for things that we missed.
|
|
357
|
+
*/
|
|
358
|
+
status = init_by_defaults(channel);
|
|
359
|
+
if (status != ARES_SUCCESS) {
|
|
360
|
+
DEBUGF(fprintf(stderr, "Error: init_by_defaults failed: %s\n",
|
|
361
|
+
ares_strerror(status)));
|
|
362
|
+
goto done;
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
/* Initialize the event thread */
|
|
366
|
+
if (channel->optmask & ARES_OPT_EVENT_THREAD) {
|
|
367
|
+
ares_event_thread_t *e = NULL;
|
|
368
|
+
|
|
369
|
+
status = ares_event_thread_init(channel);
|
|
370
|
+
if (status != ARES_SUCCESS) {
|
|
371
|
+
goto done; /* LCOV_EXCL_LINE: UntestablePath */
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
/* Initialize monitor for configuration changes. In some rare cases,
|
|
375
|
+
* ARES_ENOTIMP may occur (OpenWatcom), ignore this. */
|
|
376
|
+
e = channel->sock_state_cb_data;
|
|
377
|
+
status = ares_event_configchg_init(&e->configchg, e);
|
|
378
|
+
if (status != ARES_SUCCESS && status != ARES_ENOTIMP) {
|
|
379
|
+
DEBUGF(fprintf(stderr, "Error: ares_event_configchg_init failed: %s\n",
|
|
380
|
+
ares_strerror(status)));
|
|
381
|
+
}
|
|
382
|
+
status = ARES_SUCCESS;
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
done:
|
|
386
|
+
if (status != ARES_SUCCESS) {
|
|
387
|
+
ares_destroy(channel);
|
|
388
|
+
return (int)status;
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
*channelptr = channel;
|
|
392
|
+
return ARES_SUCCESS;
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
static void *ares_reinit_thread(void *arg)
|
|
396
|
+
{
|
|
397
|
+
ares_channel_t *channel = arg;
|
|
398
|
+
ares_status_t status;
|
|
399
|
+
|
|
400
|
+
/* ares_init_by_sysconfig() will lock when applying the config, but not
|
|
401
|
+
* when retrieving. */
|
|
402
|
+
status = ares_init_by_sysconfig(channel);
|
|
403
|
+
if (status != ARES_SUCCESS) {
|
|
404
|
+
DEBUGF(fprintf(stderr, "Error: init_by_sysconfig failed: %s\n",
|
|
405
|
+
ares_strerror(status)));
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
ares_channel_lock(channel);
|
|
409
|
+
|
|
410
|
+
/* Flush cached queries on reinit */
|
|
411
|
+
if (status == ARES_SUCCESS && channel->qcache) {
|
|
412
|
+
ares_qcache_flush(channel->qcache);
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
channel->reinit_pending = ARES_FALSE;
|
|
416
|
+
ares_channel_unlock(channel);
|
|
417
|
+
|
|
418
|
+
return NULL;
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
ares_status_t ares_reinit(ares_channel_t *channel)
|
|
422
|
+
{
|
|
423
|
+
ares_status_t status = ARES_SUCCESS;
|
|
424
|
+
|
|
425
|
+
if (channel == NULL) {
|
|
426
|
+
return ARES_EFORMERR;
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
ares_channel_lock(channel);
|
|
430
|
+
|
|
431
|
+
/* If a reinit is already in process, lets not do it again. Or if we are
|
|
432
|
+
* shutting down, skip. */
|
|
433
|
+
if (!channel->sys_up || channel->reinit_pending) {
|
|
434
|
+
ares_channel_unlock(channel);
|
|
435
|
+
return ARES_SUCCESS;
|
|
436
|
+
}
|
|
437
|
+
channel->reinit_pending = ARES_TRUE;
|
|
438
|
+
ares_channel_unlock(channel);
|
|
439
|
+
|
|
440
|
+
if (ares_threadsafety()) {
|
|
441
|
+
/* clean up the prior reinit process's thread. We know the thread isn't
|
|
442
|
+
* running since reinit_pending was false */
|
|
443
|
+
if (channel->reinit_thread != NULL) {
|
|
444
|
+
void *rv;
|
|
445
|
+
ares_thread_join(channel->reinit_thread, &rv);
|
|
446
|
+
channel->reinit_thread = NULL;
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
/* Spawn a new thread */
|
|
450
|
+
status =
|
|
451
|
+
ares_thread_create(&channel->reinit_thread, ares_reinit_thread, channel);
|
|
452
|
+
if (status != ARES_SUCCESS) {
|
|
453
|
+
/* LCOV_EXCL_START: UntestablePath */
|
|
454
|
+
ares_channel_lock(channel);
|
|
455
|
+
channel->reinit_pending = ARES_FALSE;
|
|
456
|
+
ares_channel_unlock(channel);
|
|
457
|
+
/* LCOV_EXCL_STOP */
|
|
458
|
+
}
|
|
459
|
+
} else {
|
|
460
|
+
/* Threading support not available, call directly */
|
|
461
|
+
ares_reinit_thread(channel);
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
return status;
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
/* ares_dup() duplicates a channel handle with all its options and returns a
|
|
468
|
+
new channel handle */
|
|
469
|
+
int ares_dup(ares_channel_t **dest, const ares_channel_t *src)
|
|
470
|
+
{
|
|
471
|
+
struct ares_options opts;
|
|
472
|
+
ares_status_t rc;
|
|
473
|
+
int optmask;
|
|
474
|
+
|
|
475
|
+
if (dest == NULL || src == NULL) {
|
|
476
|
+
return ARES_EFORMERR;
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
*dest = NULL; /* in case of failure return NULL explicitly */
|
|
480
|
+
|
|
481
|
+
/* First get the options supported by the old ares_save_options() function,
|
|
482
|
+
which is most of them */
|
|
483
|
+
rc = (ares_status_t)ares_save_options(src, &opts, &optmask);
|
|
484
|
+
if (rc != ARES_SUCCESS) {
|
|
485
|
+
ares_destroy_options(&opts);
|
|
486
|
+
goto done;
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
/* Then create the new channel with those options */
|
|
490
|
+
rc = (ares_status_t)ares_init_options(dest, &opts, optmask);
|
|
491
|
+
|
|
492
|
+
/* destroy the options copy to not leak any memory */
|
|
493
|
+
ares_destroy_options(&opts);
|
|
494
|
+
|
|
495
|
+
if (rc != ARES_SUCCESS) {
|
|
496
|
+
goto done;
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
ares_channel_lock(src);
|
|
500
|
+
/* Now clone the options that ares_save_options() doesn't support, but are
|
|
501
|
+
* user-provided */
|
|
502
|
+
(*dest)->sock_create_cb = src->sock_create_cb;
|
|
503
|
+
(*dest)->sock_create_cb_data = src->sock_create_cb_data;
|
|
504
|
+
(*dest)->sock_config_cb = src->sock_config_cb;
|
|
505
|
+
(*dest)->sock_config_cb_data = src->sock_config_cb_data;
|
|
506
|
+
memcpy(&(*dest)->sock_funcs, &(src->sock_funcs), sizeof((*dest)->sock_funcs));
|
|
507
|
+
(*dest)->sock_func_cb_data = src->sock_func_cb_data;
|
|
508
|
+
(*dest)->legacy_sock_funcs = src->legacy_sock_funcs;
|
|
509
|
+
(*dest)->legacy_sock_funcs_cb_data = src->legacy_sock_funcs_cb_data;
|
|
510
|
+
(*dest)->server_state_cb = src->server_state_cb;
|
|
511
|
+
(*dest)->server_state_cb_data = src->server_state_cb_data;
|
|
512
|
+
(*dest)->notify_pending_write_cb = src->notify_pending_write_cb;
|
|
513
|
+
(*dest)->notify_pending_write_cb_data = src->notify_pending_write_cb_data;
|
|
514
|
+
(*dest)->query_enqueue_cb = src->query_enqueue_cb;
|
|
515
|
+
(*dest)->query_enqueue_cb_data = src->query_enqueue_cb_data;
|
|
516
|
+
|
|
517
|
+
ares_strcpy((*dest)->local_dev_name, src->local_dev_name,
|
|
518
|
+
sizeof((*dest)->local_dev_name));
|
|
519
|
+
(*dest)->local_ip4 = src->local_ip4;
|
|
520
|
+
memcpy((*dest)->local_ip6, src->local_ip6, sizeof(src->local_ip6));
|
|
521
|
+
ares_channel_unlock(src);
|
|
522
|
+
|
|
523
|
+
/* Servers are a bit unique as ares_init_options() only allows ipv4 servers
|
|
524
|
+
* and not a port per server, but there are other user specified ways, that
|
|
525
|
+
* too will toggle the optmask ARES_OPT_SERVERS to let us know. If that's
|
|
526
|
+
* the case, pull them in.
|
|
527
|
+
*
|
|
528
|
+
* We don't want to clone system-configuration servers though.
|
|
529
|
+
*
|
|
530
|
+
* We must use the "csv" format to get things like link-local address support
|
|
531
|
+
*/
|
|
532
|
+
|
|
533
|
+
if (optmask & ARES_OPT_SERVERS) {
|
|
534
|
+
char *csv = ares_get_servers_csv(src);
|
|
535
|
+
if (csv == NULL) {
|
|
536
|
+
/* LCOV_EXCL_START: OutOfMemory */
|
|
537
|
+
ares_destroy(*dest);
|
|
538
|
+
*dest = NULL;
|
|
539
|
+
rc = ARES_ENOMEM;
|
|
540
|
+
goto done;
|
|
541
|
+
/* LCOV_EXCL_STOP */
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
rc = (ares_status_t)ares_set_servers_ports_csv(*dest, csv);
|
|
545
|
+
ares_free_string(csv);
|
|
546
|
+
if (rc != ARES_SUCCESS) {
|
|
547
|
+
/* LCOV_EXCL_START: OutOfMemory */
|
|
548
|
+
ares_destroy(*dest);
|
|
549
|
+
*dest = NULL;
|
|
550
|
+
goto done;
|
|
551
|
+
/* LCOV_EXCL_STOP */
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
rc = ARES_SUCCESS;
|
|
556
|
+
done:
|
|
557
|
+
return (int)rc; /* everything went fine */
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
void ares_set_local_ip4(ares_channel_t *channel, unsigned int local_ip)
|
|
561
|
+
{
|
|
562
|
+
if (channel == NULL) {
|
|
563
|
+
return;
|
|
564
|
+
}
|
|
565
|
+
ares_channel_lock(channel);
|
|
566
|
+
channel->local_ip4 = local_ip;
|
|
567
|
+
ares_channel_unlock(channel);
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
/* local_ip6 should be 16 bytes in length */
|
|
571
|
+
void ares_set_local_ip6(ares_channel_t *channel, const unsigned char *local_ip6)
|
|
572
|
+
{
|
|
573
|
+
if (channel == NULL) {
|
|
574
|
+
return;
|
|
575
|
+
}
|
|
576
|
+
ares_channel_lock(channel);
|
|
577
|
+
memcpy(&channel->local_ip6, local_ip6, sizeof(channel->local_ip6));
|
|
578
|
+
ares_channel_unlock(channel);
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
/* local_dev_name should be null terminated. */
|
|
582
|
+
void ares_set_local_dev(ares_channel_t *channel, const char *local_dev_name)
|
|
583
|
+
{
|
|
584
|
+
if (channel == NULL) {
|
|
585
|
+
return;
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
ares_channel_lock(channel);
|
|
589
|
+
ares_strcpy(channel->local_dev_name, local_dev_name,
|
|
590
|
+
sizeof(channel->local_dev_name));
|
|
591
|
+
channel->local_dev_name[sizeof(channel->local_dev_name) - 1] = 0;
|
|
592
|
+
ares_channel_unlock(channel);
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
int ares_set_sortlist(ares_channel_t *channel, const char *sortstr)
|
|
596
|
+
{
|
|
597
|
+
size_t nsort = 0;
|
|
598
|
+
struct apattern *sortlist = NULL;
|
|
599
|
+
ares_status_t status;
|
|
600
|
+
|
|
601
|
+
if (!channel) {
|
|
602
|
+
return ARES_ENODATA;
|
|
603
|
+
}
|
|
604
|
+
ares_channel_lock(channel);
|
|
605
|
+
|
|
606
|
+
status = ares_parse_sortlist(&sortlist, &nsort, sortstr);
|
|
607
|
+
if (status == ARES_SUCCESS && sortlist) {
|
|
608
|
+
if (channel->sortlist) {
|
|
609
|
+
ares_free(channel->sortlist);
|
|
610
|
+
}
|
|
611
|
+
channel->sortlist = sortlist;
|
|
612
|
+
channel->nsort = nsort;
|
|
613
|
+
|
|
614
|
+
/* Save sortlist as if it was passed in as an option */
|
|
615
|
+
channel->optmask |= ARES_OPT_SORTLIST;
|
|
616
|
+
}
|
|
617
|
+
ares_channel_unlock(channel);
|
|
618
|
+
return (int)status;
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
void ares_set_query_enqueue_cb(ares_channel_t *channel,
|
|
622
|
+
ares_query_enqueue_cb callback,
|
|
623
|
+
void *user_data)
|
|
624
|
+
{
|
|
625
|
+
if (channel == NULL) {
|
|
626
|
+
return;
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
channel->query_enqueue_cb = callback;
|
|
630
|
+
channel->query_enqueue_cb_data = user_data;
|
|
631
|
+
}
|