UNPKG

hudada-cli

Version:

专为程序员准备的本地文档搜索,快捷开发工具

3 lines (2 loc) 671 B
#!/usr/bin/env node import o from"dns";import l from"chalk";import{promisify as e}from"util";e(o.lookup);const c=e(o.resolve4),r=e(o.resolve6);async function n(o){try{console.log(l.green(`正在查询域名 ${o} 的 DNS 信息...\n`));try{const e=await c(o);console.log(l.blue("IPv4 地址:")),e.forEach((o=>{console.log(l.yellow(` → ${o}`))}))}catch(o){console.log(l.yellow("未找到 IPv4 记录"))}try{const e=await r(o);console.log(l.blue("\nIPv6 地址:")),e.forEach((o=>{console.log(l.yellow(` → ${o}`))}))}catch(o){console.log(l.yellow("未找到 IPv6 记录"))}}catch(o){console.error(l.red(`DNS 查询失败: ${o.message}`))}}export{n as handleDNSLookup};