Skip to content

Commit d70661c

Browse files
committed
resolve ddns after list is created or updated
1 parent 6b5dcad commit d70661c

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

backend/internal/access-list.js

+9
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ const _ = require('lodash');
22
const fs = require('fs');
33
const batchflow = require('batchflow');
44
const logger = require('../logger').access;
5+
const ddnsResolver = require('../lib/ddns_resolver/ddns_resolver');
56
const error = require('../lib/error');
67
const utils = require('../lib/utils');
78
const accessListModel = require('../models/access_list');
@@ -97,6 +98,10 @@ const internalAccessList = {
9798
.then(() => {
9899
return internalAccessList.maskItems(row);
99100
});
101+
})
102+
.then((result) => {
103+
// Call the DDNS updater after the access list update process is complete
104+
return ddnsResolver.updateDynamicDnsRecords().then(() => result);
100105
});
101106
},
102107

@@ -230,6 +235,10 @@ const internalAccessList = {
230235
.then(() => {
231236
return internalAccessList.maskItems(row);
232237
});
238+
})
239+
.then((result) => {
240+
// Call the DDNS updater after the access list update process is complete
241+
return ddnsResolver.updateDynamicDnsRecords().then(() => result);
233242
});
234243
},
235244

backend/lib/ddns_resolver/ddns_updater.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,16 @@ const ddnsUpdater = {
99
*/
1010
initTimer: () => {
1111
ddnsUpdater._initialize();
12-
ddnsUpdater._interval = setInterval(ddnsUpdater._checkForDDNSUpdates, ddnsUpdater._updateIntervalMs);
12+
ddnsUpdater._interval = setInterval(ddnsUpdater.updateDynamicDnsRecords, ddnsUpdater._updateIntervalMs);
1313
logger.info(`DDNS Update Timer initialized (interval: ${Math.floor(ddnsUpdater._updateIntervalMs / 1000)}s)`);
1414
// Trigger a run so that initial cache is populated and hosts can be updated - delay by 10s to give server time to boot up
15-
setTimeout(ddnsUpdater._checkForDDNSUpdates, 10 * 1000);
15+
setTimeout(ddnsUpdater.updateDynamicDnsRecords, 10 * 1000);
1616
},
1717

1818
/** Private **/
1919
// Properties
2020
_initialized: false,
21-
_updateIntervalMs: 60 * 60 * 1000, // 1 hr default (overriden with $DDNS_UPDATE_INTERVAL env var)
21+
_updateIntervalMs: 60 * 60 * 1000, // 1 hr default (overridden with $DDNS_UPDATE_INTERVAL env var)
2222
_interval: null, // reference to created interval id
2323
_processingDDNSUpdate: false,
2424

@@ -45,7 +45,7 @@ const ddnsUpdater = {
4545
/**
4646
* Triggered by a timer, will check for and update ddns hosts in access list clients
4747
*/
48-
_checkForDDNSUpdates: () => {
48+
updateDynamicDnsRecords: () => {
4949
logger.info('Checking for DDNS updates...');
5050
if (!ddnsUpdater._processingDDNSUpdate) {
5151
ddnsUpdater._processingDDNSUpdate = true;

0 commit comments

Comments
 (0)