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