mirror of
https://github.com/NginxProxyManager/nginx-proxy-manager.git
synced 2025-04-29 10:32:28 +00:00
Update configs for active hosts only on ddns update
Other changes: - Fixed null property read error on clients (when switching to public access) - Use separate `resolvedAddress` field for resolved IP instead of overwriting address - Reduced ddns log verbosity
This commit is contained in:
parent
743cdd8b0b
commit
7b09fefd17
@ -139,12 +139,13 @@ const internalNginx = {
|
||||
*/
|
||||
resolveDDNSAddresses: (host) => {
|
||||
const promises = [];
|
||||
if (typeof host.access_list !== 'undefined' && typeof host.access_list.clients !== 'undefined') {
|
||||
if (typeof host.access_list !== 'undefined' && host.access_list && typeof host.access_list.clients !== 'undefined' && host.access_list.clients) {
|
||||
for (const client of host.access_list.clients) {
|
||||
if (ddnsResolver.requiresResolution(client.address)) {
|
||||
const p = ddnsResolver.resolveAddress(client.address)
|
||||
const address = client.address;
|
||||
if (ddnsResolver.requiresResolution(address)) {
|
||||
const p = ddnsResolver.resolveAddress(address)
|
||||
.then((resolvedIP) => {
|
||||
client.address = `${resolvedIP}; # ${client.address}`;
|
||||
Object.defineProperty(client, 'resolvedAddress', {value: resolvedIP});
|
||||
return Promise.resolve();
|
||||
});
|
||||
promises.push(p);
|
||||
|
@ -64,15 +64,13 @@ const ddnsResolver = {
|
||||
* @returns {Promise}
|
||||
*/
|
||||
_queryHost: (host) => {
|
||||
logger.info('Looking up IP for ', host);
|
||||
return utils.execSafe('getent', ['hosts', host])
|
||||
.then((result) => {
|
||||
if (result.length < 8) {
|
||||
logger.error('IP lookup returned invalid output: ', result);
|
||||
logger.error(`IP lookup for ${host} returned invalid output: ${result}`);
|
||||
throw error.ValidationError('Invalid output from getent hosts');
|
||||
}
|
||||
const out = result.split(/\s+/);
|
||||
logger.info(`Resolved ${host} to ${out[0]}`);
|
||||
return out[0];
|
||||
},
|
||||
(error) => {
|
||||
|
@ -113,7 +113,11 @@ const ddnsUpdater = {
|
||||
for (const row of rows) {
|
||||
if (!updatedRows.has(row.id)) {
|
||||
updatedRows.set(row.id, 1);
|
||||
proxy_hosts.push(...row.proxy_hosts);
|
||||
for (const host of row.proxy_hosts) {
|
||||
if (host.enabled) {
|
||||
proxy_hosts.push(host);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -128,6 +128,9 @@ module.exports = {
|
||||
*/
|
||||
renderEngine.registerFilter('nginxAccessRule', (v) => {
|
||||
if (typeof v.directive !== 'undefined' && typeof v.address !== 'undefined' && v.directive && v.address) {
|
||||
if (typeof v.resolvedAddress !== 'undefined' && v.resolvedAddress) {
|
||||
return `${v.directive} ${v.resolvedAddress}; # ${v.address}`;
|
||||
}
|
||||
return `${v.directive} ${v.address};`;
|
||||
}
|
||||
return '';
|
||||
|
Loading…
x
Reference in New Issue
Block a user