|
|
|
@ -6,6 +6,8 @@ import { lookup as clookup } from 'dns' |
|
|
|
|
import { promisify } from 'util' |
|
|
|
|
const lookup = promisify(clookup) |
|
|
|
|
import { CronJob } from 'cron' |
|
|
|
|
import to from 'await-to-js' |
|
|
|
|
import { info } from 'console' |
|
|
|
|
|
|
|
|
|
const rname = process.argv[2] || opts.domain |
|
|
|
|
if (!rname) { |
|
|
|
@ -52,6 +54,7 @@ async function checkIP () { |
|
|
|
|
let ip = curr.split('.') |
|
|
|
|
ip[0] = ip[0] - Math.floor(Math.random() * 10) |
|
|
|
|
curr = ip.join('.') |
|
|
|
|
console.log('development run: generated dummy current ip', curr) |
|
|
|
|
} |
|
|
|
|
const saved = await route53.getZoneRecordValue(rname) |
|
|
|
|
if (opts.debug) notify('checking for change in public ip',timestamp()) |
|
|
|
@ -69,7 +72,15 @@ async function checkIP () { |
|
|
|
|
notify(msg) |
|
|
|
|
},timeout*1000*(opts.debug ? 10 : 60)) |
|
|
|
|
const check = setInterval(async ()=>{ |
|
|
|
|
if (curr === (await lookup(rname)).address) { |
|
|
|
|
let [err,info] = await to(lookup(rname)) |
|
|
|
|
if (err) { |
|
|
|
|
clearInterval(check) |
|
|
|
|
clearTimeout(fail) |
|
|
|
|
msg=`FATAL Error in lookup of' ${rname}, ${err}, aborting check, human intervention required` |
|
|
|
|
console.log(msg) |
|
|
|
|
notify(msg) |
|
|
|
|
} else { |
|
|
|
|
if (curr === info.address) { |
|
|
|
|
msg=`Update Succeeded, lookup of ${rname} is now ${curr}` |
|
|
|
|
clearInterval(check) |
|
|
|
|
clearTimeout(fail) |
|
|
|
@ -82,6 +93,7 @@ async function checkIP () { |
|
|
|
|
console.log(msg) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
,interval*1000) |
|
|
|
|
|
|
|
|
|