diff --git a/index.js b/index.js index 004a544..515df38 100644 --- a/index.js +++ b/index.js @@ -1,6 +1,6 @@ 'use strict'; -const fetch = require('nodemailer/lib/fetch'); +const fetchUrl = require('nodemailer/lib/fetch'); const packageData = require('./package.json'); const dns = require('dns').promises; const os = require('os'); @@ -101,9 +101,15 @@ function getPublicInterfaces() { let publicInterfaces = { IPv4: [], IPv6: [] }; Object.keys(interfaces) .flatMap(iface => interfaces[iface].filter(entry => !entry.internal).map(entry => Object.assign({ iface }, entry))) - .forEach(entry => { - if (Array.isArray(publicInterfaces[entry.family])) { - publicInterfaces[entry.family].push(entry); + .forEach(originalEntry => { + let entry = Object.assign({}, originalEntry); + + let family = typeof entry.family === 'number' ? `IPv${entry.family}` : entry.family; + if (entry.family !== family) { + entry.family = family; + } + if (Array.isArray(publicInterfaces[family])) { + publicInterfaces[family].push(entry); } }); return publicInterfaces; @@ -124,7 +130,7 @@ async function timedFunction(prom, timeout, localAddress) { async function resolveIP(localAddress, family) { let data = await new Promise((resolve, reject) => { - let req = fetch(RESOLV_URL, { + let req = fetchUrl(RESOLV_URL, { userAgent: `${packageData.name}/${packageData.version}`, tls: { host: DNS_CACHE[family] && DNS_CACHE[family].host, diff --git a/package.json b/package.json index 4ac1cbf..286db05 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "pubface", - "version": "1.0.2", + "version": "1.0.3", "description": "Resolve public network interfaces for current machine", "main": "index.js", "scripts": { @@ -19,10 +19,10 @@ }, "dependencies": { "ipaddr.js": "2.0.1", - "nodemailer": "6.7.1" + "nodemailer": "6.7.5" }, "devDependencies": { - "pkg": "5.4.1" + "pkg": "5.7.0" }, "pkg": { "assets": [