Node.js – dnsPromises.resolveSoa() 方法
dnsPromises.resolveSoa() 方法使用 DNS 协议来解析主机名的权威记录(SOA 记录)。如果解析成功,则使用以下属性解析承诺
nsname
hostmaster
serial
refresh
retry
expire
minttl
语法
dnsPromises.resolveSoa( hostname )
参数
hostname - 此参数获取要解析的主机名输入。
示例 1
创建一个名为 "resolveSoa.js" 的文件,并复制以下代码。创建文件后,使用命令 "node resolveSoa.js" 运行此代码,如下例所示
// dns.resolveSoa() Demo Example
// Importing the dns module
const dns = require('dns');
const dnsPromises = dns.promises;
// Passing IP to find the hostname TXT records
dnsPromises.resolveSoa('tutorialspoint.com').then((response) => {
console.log("SOA Records: ", response);
})输出
它将生成以下输出 -
C:\home
ode>> node resolveSoa.js SOA Records: { nsname: 'pdns13.domaincontrol.com', hostmaster: 'dns.jomax.net', serial: 2021051700, refresh: 28800, retry: 7200, expire: 604800, minttl: 600 }
示例 2
我们来看另一个示例 -
// dns.resolveSoa() Demo Example
// Importing the dns module
const dns = require('dns');
const dnsPromises = dns.promises;
// Setting ttl as true
const options={
ttl:true,
};
// Calling dnsPromises.resolveSoa() method asynchronously
(async function() {
const records = await dnsPromises.resolveSoa( 'google.com', options);
// Printing records
console.log("SOA Records: ", records);
})();输出
它将生成以下输出 -
C:\home
ode>> node resolveSoa.js SOA Records: { nsname: 'ns1.google.com', hostmaster: 'dns-admin.google.com', serial: 379680302, refresh: 900, retry: 900, expire: 1800, minttl: 60 }
广告
数据结构
网络
RDBMS
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP