mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2025-02-21 02:01:35 +00:00
Try MDNS lookup only if regular DNS lookup fails
This is meant to allow users to configure their device to resolve `.local` queries via dnsmasq by modifying config.json, e.g. `dnsServers": "/bob.local/172.17.0.33`. This would fail before as MDNS lookups would always come first Change-type: minor
This commit is contained in:
parent
7a39da92b7
commit
dec39a35d4
21
src/app.ts
21
src/app.ts
@ -119,11 +119,24 @@ async function mdnsLookup(
|
||||
return lookup(name, { verbatim: true }, opts);
|
||||
}
|
||||
|
||||
if (name && name.endsWith('.local')) {
|
||||
return mdnsLookup(name, opts, cb);
|
||||
}
|
||||
// Try a regular dns lookup first
|
||||
return lookup(
|
||||
name,
|
||||
Object.assign({ verbatim: true }, opts),
|
||||
(error: any, address: string, family: number) => {
|
||||
if (error == null) {
|
||||
return cb(null, address, family);
|
||||
}
|
||||
|
||||
return lookup(name, Object.assign({ verbatim: true }, opts), cb);
|
||||
// If the regular lookup fails, we perform a mdns lookup if the
|
||||
// name ends with .local
|
||||
if (name && name.endsWith('.local')) {
|
||||
return mdnsLookup(name, opts, cb);
|
||||
}
|
||||
|
||||
return cb(error);
|
||||
},
|
||||
);
|
||||
};
|
||||
})();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user