/**
* 查询指定 DNS 服务器的 TXT 类型记录
*
* @param {String} domain 域名
* @param {String} dnsServer 指定 DNS 服务器
* @param {Number} timeout 超时时间(毫秒)
* @returns {[String]} TXT 记录数组
*/
function queryTxtDnsRecord(domain, dnsServer, timeout) {
// 参数验证
if (typeof domain !== 'string' || !domain) {
throw new Error("Invalid domain");
}
if (typeof dnsServer !== 'string' || !dnsServer) {
throw new Error("Invalid DNS server");
}
if (typeof timeout !== 'number' || timeout <= 0) {
throw new Error("Invalid timeout value");
}
function buildDnsQuery(domain) {
let query = [];
query[0] = 0x12; // Transaction ID
query[1] = 0x34;
query[2] = 0x01; // 标志位
query[3] = 0x00;
query[4] = 0x00; // 查询数量
query[5] = 0x01;
query[6] = 0x00; // Answer RRs
query[7] = 0x00;
Autojs Pro9.3.11-0 查询指定 DNS 服务器的 TXT 类型记录
于 2024-09-21 17:36:00 首次发布