1.0.0 • Published 1 year ago

get-fqdn v1.0.0

Weekly downloads
1,297
License
MIT
Repository
github
Last release
1 year ago

get-fqdn

build status code style styled with prettier made with lass license npm downloads

Lookup the fully qualified domain name ("FQDN") of the current server's IP (default) or a custom IP. 90x faster than hostname -f and works with Node v14+.

Table of Contents

Install

npm:

npm install get-fqdn

Usage

const getFQDN = require('get-fqdn');

// async/await usage
(async () => {
  try {
    const fqdn = await getFQDN();
    console.log('fqdn', fqdn);
  } catch (err) {
    console.error(err);
  }
});

// then/catch usage
getFQDN().then(fqdn => console.log('fqdn', fqdn)).catch(console.error);

Note that you can also pass a custom IP:

const fqdn = await getFQDN('1.1.1.1');
console.log('fqdn', fqdn);

Performance

This package runs approximately 90x faster than the alternative of using hostname -f.

It was built to ensure that ForwardEmail.net is as optimized as possible.

Others packages were written in CoffeeScript, used deasync, or used the hostname -f approach (also see the fqdn package that uses the wrong approach too).

Contributors

NameWebsite
Nick Baughhttp://niftylettuce.com/

License

MIT © Nick Baugh