mirror of
https://github.com/denoland/deno.git
synced 2024-11-23 15:16:54 -05:00
d47147fb6a
This commit moves "deno_std/node" in "ext/node" crate. The code is transpiled and snapshotted during the build process. During the first pass a minimal amount of work was done to create the snapshot, a lot of code in "ext/node" depends on presence of "Deno" global. This code will be gradually fixed in the follow up PRs to migrate it to import relevant APIs from "internal:" modules. Currently the code from snapshot is not used in any way, and all Node/npm compatibility still uses code from "https://deno.land/std/node" (or from the location specified by "DENO_NODE_COMPAT_URL"). This will also be handled in a follow up PRs. --------- Co-authored-by: crowlkats <crowlkats@toaxl.com> Co-authored-by: Divy Srivastava <dj.srivastava23@gmail.com> Co-authored-by: Yoshiya Hinosawa <stibium121@gmail.com>
67 lines
2.4 KiB
TypeScript
67 lines
2.4 KiB
TypeScript
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
|
|
/* Copyright 1998 by the Massachusetts Institute of Technology.
|
|
*
|
|
* Permission to use, copy, modify, and distribute this
|
|
* software and its documentation for any purpose and without
|
|
* fee is hereby granted, provided that the above copyright
|
|
* notice appear in all copies and that both that copyright
|
|
* notice and this permission notice appear in supporting
|
|
* documentation, and that the name of M.I.T. not be used in
|
|
* advertising or publicity pertaining to distribution of the
|
|
* software without specific, written prior permission.
|
|
* M.I.T. makes no representations about the suitability of
|
|
* this software for any purpose. It is provided "as is"
|
|
* without express or implied warranty.
|
|
*/
|
|
|
|
// REF: https://github.com/nodejs/node/blob/master/deps/cares/include/ares.h#L190
|
|
|
|
export const ARES_AI_CANONNAME = 1 << 0;
|
|
export const ARES_AI_NUMERICHOST = 1 << 1;
|
|
export const ARES_AI_PASSIVE = 1 << 2;
|
|
export const ARES_AI_NUMERICSERV = 1 << 3;
|
|
export const AI_V4MAPPED = 1 << 4;
|
|
export const AI_ALL = 1 << 5;
|
|
export const AI_ADDRCONFIG = 1 << 6;
|
|
export const ARES_AI_NOSORT = 1 << 7;
|
|
export const ARES_AI_ENVHOSTS = 1 << 8;
|
|
|
|
// REF: https://github.com/nodejs/node/blob/master/deps/cares/src/lib/ares_strerror.c
|
|
|
|
// deno-lint-ignore camelcase
|
|
export function ares_strerror(code: number) {
|
|
/* Return a string literal from a table. */
|
|
const errorText = [
|
|
"Successful completion",
|
|
"DNS server returned answer with no data",
|
|
"DNS server claims query was misformatted",
|
|
"DNS server returned general failure",
|
|
"Domain name not found",
|
|
"DNS server does not implement requested operation",
|
|
"DNS server refused query",
|
|
"Misformatted DNS query",
|
|
"Misformatted domain name",
|
|
"Unsupported address family",
|
|
"Misformatted DNS reply",
|
|
"Could not contact DNS servers",
|
|
"Timeout while contacting DNS servers",
|
|
"End of file",
|
|
"Error reading file",
|
|
"Out of memory",
|
|
"Channel is being destroyed",
|
|
"Misformatted string",
|
|
"Illegal flags specified",
|
|
"Given hostname is not numeric",
|
|
"Illegal hints flags specified",
|
|
"c-ares library initialization not yet performed",
|
|
"Error loading iphlpapi.dll",
|
|
"Could not find GetNetworkParams function",
|
|
"DNS query cancelled",
|
|
];
|
|
|
|
if (code >= 0 && code < errorText.length) {
|
|
return errorText[code];
|
|
} else {
|
|
return "unknown";
|
|
}
|
|
}
|