mirror of
https://github.com/jason5ng32/MyIP.git
synced 2026-11-04 08:55:47 +00:00
Chore(dns): align resolver diagnostics with runtime usage
Keep resolver health checks on demand and surface actionable runtime availability failures through the shared logger. Remove the GitHub Actions workflow so transient resolver connectivity does not affect code CI. Co-authored-by: OpenAI Codex <codex@openai.com>
This commit is contained in:
6 files changed
+128
-55
No files matched your search
@@ -18,6 +18,17 @@ const DIG_ARGUMENTS = ['+noall', '+comments', '+answer'];
|
||||
|
||||
const sleep = (delayMs) => new Promise((resolve) => setTimeout(resolve, delayMs));
|
||||
|
||||
export const ensureDigAvailable = async (exec = execFileAsync) => {
|
||||
try {
|
||||
await exec('dig', ['-v'], { timeout: 5000, maxBuffer: 64 * 1024 });
|
||||
} catch (error) {
|
||||
if (error?.code === 'ENOENT') {
|
||||
throw new Error('The `dig` executable is required for DNS resolver checks; install dnsutils (Debian/Ubuntu) or bind (macOS).');
|
||||
}
|
||||
throw new Error(`Unable to run \'dig\': ${error instanceof Error ? error.message : String(error)}`);
|
||||
}
|
||||
};
|
||||
|
||||
const parseAttempts = (value) => {
|
||||
const attempts = Number.parseInt(value, 10);
|
||||
if (!Number.isInteger(attempts) || attempts < 1) {
|
||||
@@ -237,6 +248,7 @@ export const formatMarkdown = (report) => {
|
||||
|
||||
const main = async () => {
|
||||
const options = parseCliArgs(process.argv.slice(2));
|
||||
await ensureDigAvailable();
|
||||
const report = await checkDnsResolvers(DNS_RESOLVERS, { attempts: options.attempts });
|
||||
const output = options.json ? { ...report, markdown: formatMarkdown(report) } : formatMarkdown(report);
|
||||
process.stdout.write(`${options.json ? JSON.stringify(output, null, 2) : output}\n`);
|
||||
|
||||
Reference in new issue
Block a user