Skip to content

Commit

Permalink
Refactor DNS setup and synchronization
Browse files Browse the repository at this point in the history
  • Loading branch information
FLYBYME committed Dec 7, 2023
1 parent 6f62db3 commit 81c6c07
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions services/ddns.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -897,9 +897,9 @@ module.exports = {
async setup() {
let parentCtx = new Context(this.broker);

await this.actions.createRecord({ fqdn: 'dns.google', type: 'A', data: '8.8.8.8' }, { parentCtx })
await this.actions.createRecord({ fqdn: 'cloudflare-dns.com', type: 'A', data: '104.16.249.249' }, { parentCtx })
await this.actions.createRecord({ fqdn: 'cloudflare-dns.com', type: 'A', data: '104.16.248.249' }, { parentCtx })
await this.actions.createRecord({ fqdn: 'dns.google', type: 'A', data: '8.8.8.8' })
await this.actions.createRecord({ fqdn: 'cloudflare-dns.com', type: 'A', data: '104.16.249.249' })
await this.actions.createRecord({ fqdn: 'cloudflare-dns.com', type: 'A', data: '104.16.248.249' })
await this.setupTimers();
},
async setupTimers() {
Expand Down Expand Up @@ -952,7 +952,7 @@ module.exports = {
}, interval);

this.timeout = setTimeout(async () => {
const list = await this.findEntities(parentCtx, {});
const list = await this.findEntities(null, {});
if (list) {
for (let index = 0; index < list.length; index++) {
const element = list[index];
Expand All @@ -966,8 +966,8 @@ module.exports = {
const address = require('os').networkInterfaces()[process.env.AGENT_INTERFACE].shift().address
await this.createUDPServer('udp4', 53, address, process.env.AGENT_INTERFACE_PROXY);
}
await this.actions.sync({}, { parentCtx });
parentCtx.emit('ddns.agent.online');
await this.actions.sync({});
this.broker.emit('ddns.agent.online');
}, 100);
},
},
Expand Down

0 comments on commit 81c6c07

Please sign in to comment.