This commit is contained in:
2022-10-20 15:18:57 +02:00
committed by GitHub
parent fb7416dbec
commit a1af82501c
15 changed files with 429 additions and 768 deletions

18
src/runner.ts Normal file
View File

@@ -0,0 +1,18 @@
import { update } from './cloudflare.js'
import { checkIfUpdateIsRequired, getCurrentIp } from './ip.js'
import { logger } from './logger.js'
export async function loop() {
const ip = await getCurrentIp()
const changed = checkIfUpdateIsRequired(ip)
logger.info(`Running. Update required: ${!!changed}`)
if (changed) {
try {
await update(ip)
logger.info('Successfully updated DNS record')
} catch (e) {
logger.error(e)
logger.error('Failed to update DNS record')
}
}
}