address

2018-11-10 admin

address是什么

什么是address,Get current machine IP, MAC and DNS servers.

address使用教程帮助文档

address

NPM version build status Test coverage Gittip David deps npm download

Get current machine IP, MAC and DNS servers.

DNS servers receive from /etc/resolv.conf.

Install

$ npm install address

Usage

Get IP is sync and get MAC is async for now.

var address = require('address');

// default interface 'eth' on linux, 'en' on osx.
address.ip();   // '192.168.0.2'
address.ipv6(); // 'fe80::7aca:39ff:feb0:e67d'
address.mac(function (err, addr) {
  console.log(addr); // '78:ca:39:b0:e6:7d'
});

// local loopback
address.ip('lo'); // '127.0.0.1'

// vboxnet MAC
address.mac('vboxnet', function (err, addr) {
  console.log(addr); // '0a:00:27:00:00:00'
});

Get all addresses: IPv4, IPv6 and MAC

address(function (err, addrs) {
  console.log(addrs.ip, addrs.ipv6, addrs.mac);
  // '192.168.0.2', 'fe80::7aca:39ff:feb0:e67d', '78:ca:39:b0:e6:7d'
});

address('vboxnet', function (err, addrs) {
  console.log(addrs.ip, addrs.ipv6, addrs.mac);
  // '192.168.56.1', null, '0a:00:27:00:00:00'
});

Get an interface info with family

address.interface('IPv4', 'eth1');
// { address: '192.168.1.1', family: 'IPv4', mac: '78:ca:39:b0:e6:7d' }

Get DNS servers

address.dns(function (err, addrs) {
  console.log(addrs);
  // ['10.13.2.1', '10.13.2.6']
});

benchmark

run $ npm run benchmark

18,929 op/s » #ip
17,622 op/s » #ipv6
16,347 op/s » #mac
11,906 op/s » #dns

License

MIT

本站文章除注明转载外,均为本站原创或编译。欢迎任何形式的转载,但请务必注明出处。

转载请注明:文章转载自 JavaScript中文网 [https://www.javascriptcn.com]

本文地址:https://www.javascriptcn.com/read-45057.html

文章标题:address

相关文章
email-addresses
email-addresses是什么 什么是email-addresses,An email address parser based on rfc5322 email-addresses官网:官网 email-addresses源码仓库...
2018-09-29
Google Maps v3 API - Auto Complete (address)
Matt提出了一个问题:Google Maps v3 API - Auto Complete (address),或许与您遇到的问题类似。 回答者Matt给出了该问题的处理方式: Fixed. The autocomplete librar...
2018-04-13
Get the page file name from the address bar
DruzionBoardy提出了一个问题:Get the page file name from the address bar,或许与您遇到的问题类似。 回答者Juan Mendes给出了该问题的处理方式: https://develop...
2018-04-23
How to get client IP address using jQuery
hippietrailWondering提出了一个问题:How to get client IP address using jQuery,或许与您遇到的问题类似。 回答者samddCMS给出了该问题的处理方式: jQuery can ha...
2018-04-12
Is it possible to hide the address bar in iOS 7 Safari? [duplicate]
crowjonahDaimz提出了一个问题:Is it possible to hide the address bar in iOS 7 Safari? [duplicate],或许与您遇到的问题类似。 回答者valentinvieriu...
2018-04-27
How to change browser address bar without reloading page - HTML/Javascript [duplicate]
CommunityRadiantHex提出了一个问题:How to change browser address bar without reloading page - HTML/Javascript [duplicate],或许与您遇到...
2018-04-13
addressparser
addressparser是什么 什么是addressparser,Parse e-mail addresses addressparser官网:官网 addressparser源码仓库:源码仓库 addressparser下载地址:点此...
2019-02-19
HTML <address> 标签
&lt;h3&gt;实例&lt;/h3&gt; &lt;p&gt;Example.com 的联系信息:&lt;/p&gt; &lt;pre class=“prettyprint”&gt;&lt;code&gt;&lt;address&gt;...
2019-03-31
ip-address
ip-address是什么 什么是ip-address,A library for parsing IPv4 and IPv6 IP addresses in node and the browser. ip-address官网:官网 i...
2019-03-21
node-opcua-address-space
node-opcua-address-space是什么 什么是node-opcua-address-space,pure nodejs OPCUA SDK - module -address-space node-opcua-addres...
2019-05-17
回到顶部