CNode

nslookup:用于 dns 查询的库

分享
Aalsotang发布于11 年前最后回复11 年前3 回复6307 浏览0 收藏

nodejs 官方的 dns 库,连指定 dns 解析服务器都做不到啊。

github 地址:https://github.com/alsotang/nslookup

nslookup

Build Status

install

npm install nslookup

quick example

nslookup('fxck.it')
  .server('8.8.8.8') // default is 8.8.8.8
  .type('mx') // default is 'a'
  .timeout(10 * 1000) // default is 3 * 1000 ms
  .end(function (err, addrs) {
    console.log(addrs); // => ['66.6.44.4']
  });

API

nslookup

nslookup(domain) and chain with methods

nslookup(domain, function (err, addrs)). Simply query a type and use 8.8.8.8.

.server(server)

String or Object

String: .server(8.8.8.8)

Object: .server({ address: '8.8.8.8', port: 53, type: 'udp' })

.type(type)

here can be mx or a or ns

e.g.: .type('ns')

.timeout(timeout)

default is 3 * 1000 ms.

if timeout, then the NSLookupTimeoutError error would be callback.

.timeout(3 * 1000)

.end(callback)

callback = function (err, addrs)

addrs is an Array

TODO

查看回复

回复 (3)

I
i5ting#1·11 年前

哇,好厉害啊好厉害

L
leapon#2·11 年前

这个会有用。赞

T
tengrommel#3·11 年前

不错的链式调用 越来越喜欢这种风格了

参与回复
登录后即可参与回复。登录