Skip to content

Commit ccdbeae

Browse files
committed
fix: fixed ip check ordering
1 parent 9805dd1 commit ccdbeae

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

index.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,10 @@ import('private-ip').then((obj) => {
4343

4444
// <https://github.com/szmarczak/cacheable-lookup/pull/76>
4545
class Tangerine extends dns.promises.Resolver {
46-
static HOSTFILE = hostile.get(true).join('\n');
46+
static HOSTFILE = hostile
47+
.get(true)
48+
.map((s) => (Array.isArray(s) ? s.join(' ') : s))
49+
.join('\n');
4750

4851
static HOSTS = new Hosts(
4952
hostile
@@ -927,8 +930,6 @@ class Tangerine extends dns.promises.Resolver {
927930
// edge case where localhost IP returns matches
928931
if (!isPrivateIP) await pWaitFor(() => Boolean(isPrivateIP));
929932

930-
if (ip === '::1' || ip === '127.0.0.1') return [];
931-
932933
const answers = [];
933934
const matches = [];
934935

@@ -946,6 +947,9 @@ class Tangerine extends dns.promises.Resolver {
946947
// if (answers.length > 0 || (matches.includes(ip) && isPrivateIP(ip)))
947948
if (answers.length > 0 || matches.includes(ip)) return answers;
948949

950+
// NOTE: we can prob remove this (?)
951+
if (ip === '::1' || ip === '127.0.0.1') return [];
952+
949953
// reverse the IP address
950954
if (!dohdec) await pWaitFor(() => Boolean(dohdec));
951955

0 commit comments

Comments
 (0)