Skip to content

Commit f736815

Browse files
committed
update command parsing to pull first ipv4 address from result of getent command
1 parent 1f6fa75 commit f736815

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

backend/lib/ddns_resolver/ddns_resolver.js

+6-3
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,15 @@ const ddnsResolver = {
5050
_queryHost: (host) => {
5151
return utils.execSafe('getent', ['ahostsv4', host])
5252
.then((result) => {
53-
if (result.length < 8 || !/^(\d{1,3}\.){3}\d{1,3}$/.test(result)) {
53+
const ipv4Regex = /(\d{1,3}\.){3}\d{1,3}/;
54+
const match = result.match(ipv4Regex);
55+
56+
if (!match) {
5457
logger.error(`IPV4 lookup for ${host} returned invalid output: ${result}`);
5558
throw error.ValidationError('Invalid output from getent hosts');
5659
}
57-
const out = result.split(/\s+/);
58-
return out[0];
60+
61+
return match[0];
5962
},
6063
(error) => {
6164
logger.error('Error looking up IP for ' + host + ': ', error);

0 commit comments

Comments
 (0)