Node.js – dns.resolveNaptr() 方法
dns.resolveNaptr() 方法使用 DNS 协议来解析主机名的基于正则表达式的单词(NAPTR 记录)。传递给回调函数的地址参数将包含一个对象数组,这些对象具有以下属性:-
标志
服务
正则表达式
置换
顺序
优先级
语法
dns.resolveNaptr(hostname, callback)
参数
hostname – 此参数获取要解析的主机名的输入。
callback – 此函数将捕获错误(如果有)。
记录 – 返回主机名的 NAPTR 记录。
示例 1
创建一个文件 "resolveNaptr.js" 并复制以下代码段。创建文件后,使用命令 "node resolveNaptr.js" 来运行此代码。
// dns.resolveNaptr() Demo Example
// Importing the dns module
const dns = require('dns');
// Passing the argument below
dns.resolveNaptr('tutorialspoint.com', (err, records) => console.log('NAPTR Records: %j', records));输出
QueryReqWrap {
bindingName: 'queryNaptr',
callback: [Function],
hostname: 'tutorialspoint.com',
oncomplete: [Function: onresolve],
ttl: false,
channel: ChannelWrap {} }
NAPTR Records: undefined示例 2
// dns.resolveNaptr() Demo Example
// Importing the dns module
const dns = require('dns');
// Passing the argument below
dns.resolveNaptr('google.com', (err, records) => console.log('NAPTR Records: %j', records));输出
NAPTR Records: undefined
广告
数据结构
网络
RDBMS
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP