项目作者: StephanGeorg

项目描述 :
Use dig command (domain information grope) for DNS queries in node
高级语言: JavaScript
项目地址: git://github.com/StephanGeorg/node-dig-dns.git
创建时间: 2017-10-09T20:34:50Z
项目社区:https://github.com/StephanGeorg/node-dig-dns

开源协议:

下载


node-dig-dns npm version

Using native node dns to query complex DNS is a hustle. This is a simple wrapper for the unix/linux/macos dig command (domain information grope). Output is parsed to JSON.

Install

  1. npm i node-dig-dns -S

Usage

  1. dig([args], (options))

You can add all args from dig to the args array.

Examples

  1. dig(['google.com', 'ANY'])
  2. .then((result) => {
  3. console.log(result)
  4. })
  5. .catch((err) => {
  6. console.log('Error:', err);
  7. });

Set custom DNS server:

  1. dig(['@8.8.8.4','google.com', 'ANY'])
  2. .then((result) => {
  3. console.log(result)
  4. })
  5. .catch((err) => {
  6. console.log('Error:', err);
  7. });

Options

Optional parameters:

  • raw: Get the raw output as string. If +short option, raw output is default
  • dig: Manually set the dig command (/my/custum/path/to/dig)

Result

The dig result is parsed and return in JSON:

  1. { question: [ [ ';google.com.', 'IN', 'ANY' ] ],
  2. answer:
  3. [ { domain: 'google.com.',
  4. type: 'A',
  5. ttl: '268',
  6. class: 'IN',
  7. value: '216.58.211.110' },
  8. { domain: 'google.com.',
  9. type: 'AAAA',
  10. ttl: '268',
  11. class: 'IN',
  12. value: '2a00:1450:400e:809::200e' },
  13. { domain: 'google.com.',
  14. type: 'MX',
  15. ttl: '568',
  16. class: 'IN',
  17. value: '30 alt2.aspmx.l.google.com.' },
  18. ...
  19. ],
  20. time: 41,
  21. server: '8.8.8.8#53(8.8.8.8)',
  22. datetime: 'Mon Oct 9 23:56:37 2017',
  23. size: 373 }