node-modules / address

Get current machine IP and MAC address.
Other
233 stars 32 forks source link

Only returns MAC address of server #4

Closed Jaspur closed 10 years ago

Jaspur commented 10 years ago

It returns the MAC-address of my server, not the MAC-address of the client that is visiting the page.

var http = require('http');
http.createServer(function (req, res) {
  res.writeHead(200, {'Content-Type': 'text/plain'});
  res.end('Hello Node.js\n');

    module.exports = require('./lib/address');

    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('Mac: '+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'
    });

    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'
    });

    address.interface('IPv4', 'eth1');

    address.dns(function (err, addrs) {
      console.log('DNS: '+addrs);

      res.writeHead(200, {'Content-Type': 'text/plain'});
      res.end(addrs);
      // ['10.13.2.1', '10.13.2.6']
    });

}).listen(8124, "192.168.2.42");
console.log('Server running at http://192.168.2.42:8124/');
fengmk2 commented 10 years ago

It can't got the client MAC address from this module.

Jaspur commented 10 years ago

So the script isn't for getting the clients mac address?

fengmk2 commented 10 years ago

It just work on the current machine.


@fengmk2 (https://twitter.com/fengmk2) @Python发烧友 (http://weibo.com/imk2/profile) http://fengmk2.github.com (http://fengmk2.github.com/)


记得当时年纪小/ 你爱谈天,我爱笑/ 有一回并肩坐在桃树下/ 风在林梢鸟儿在叫/ 我们不知怎样睡着了/ 梦里花落知多少

On Tuesday, September 24, 2013 at 5:32 PM, Jaspur wrote:

So the script isn't for getting the clients mac address?

— Reply to this email directly or view it on GitHub (https://github.com/fengmk2/address/issues/4#issuecomment-24988592).