TimothyYe / godns

A dynamic DNS client tool that supports AliDNS, Cloudflare, Google Domains, DNSPod, HE.net & DuckDNS & DreamHost, etc, written in Go.
https://timothyye.github.io/godns/
Apache License 2.0
1.5k stars 221 forks source link

No IP cache used if IP is not mismatched when godns is started #136

Open demifiend9 opened 2 years ago

demifiend9 commented 2 years ago

Describe the bug

If the domain IP is same as current IP, godns keeps quering the api repeatedly even though IP update is not needed.

time="2022-03-08T16:32:01+05:30" level=info msg="GoDNS started, entering main loop..."
time="2022-03-08T16:32:01+05:30" level=info msg="Creating DNS handler with provider:Cloudflare"
time="2022-03-08T16:32:01+05:30" level=info msg="Checking IP for domain example.com"
time="2022-03-08T16:32:02+05:30" level=info msg="Querying records with type:AAAA"
time="2022-03-08T16:32:03+05:30" level=info msg="Record OK: gg.example.com - 2401:4900:xxxxxxxxxxxxxxxxxxxxxxx\r\n"
time="2022-03-08T16:32:03+05:30" level=info msg="Record OK: ff.example.com - 2401:4900:xxxxxxxxxxxxxxxxxxxxxxx\r\n"
time="2022-03-08T16:38:16+05:30" level=info msg="Checking IP for domain example.com"
time="2022-03-08T16:38:17+05:30" level=info msg="Querying records with type:AAAA"
time="2022-03-08T16:38:18+05:30" level=info msg="Record OK: gg.example.com - 2401:4900:xxxxxxxxxxxxxxxxxxxxxxx\r\n"
time="2022-03-08T16:38:18+05:30" level=info msg="Record OK: ff.example.com - 2401:4900:xxxxxxxxxxxxxxxxxxxxxxx\r\n"
time="2022-03-08T16:39:18+05:30" level=info msg="Checking IP for domain example.com"
time="2022-03-08T16:39:19+05:30" level=info msg="Querying records with type:AAAA"
time="2022-03-08T16:39:20+05:30" level=info msg="Record OK: gg.example.com - 2401:4900:xxxxxxxxxxxxxxxxxxxxxxx\r\n"
time="2022-03-08T16:39:20+05:30" level=info msg="Record OK: ff.example.com - 2401:4900:xxxxxxxxxxxxxxxxxxxxxxx\r\n"
time="2022-03-08T16:40:20+05:30" level=info msg="Checking IP for domain example.com"
time="2022-03-08T16:40:22+05:30" level=info msg="Querying records with type:AAAA"
time="2022-03-08T16:40:23+05:30" level=info msg="Record OK: gg.example.com - 2401:4900:xxxxxxxxxxxxxxxxxxxxxxx\r\n"
time="2022-03-08T16:40:23+05:30" level=info msg="Record OK: ff.example.com - 2401:4900:xxxxxxxxxxxxxxxxxxxxxxx\r\n"
time="2022-03-08T16:41:23+05:30" level=info msg="Checking IP for domain example.com"
time="2022-03-08T16:41:24+05:30" level=info msg="Querying records with type:AAAA"
time="2022-03-08T16:41:25+05:30" level=info msg="Record OK: gg.example.com - 2401:4900:xxxxxxxxxxxxxxxxxxxxxxx\r\n"
time="2022-03-08T16:41:25+05:30" level=info msg="Record OK: ff.example.com - 2401:4900:xxxxxxxxxxxxxxxxxxxxxxx\r\n"

Cache is made only after IP is updated once

time="2022-03-08T17:25:11+05:30" level=info msg="IP mismatch: Current(2401:4900:xxxxxxxxxxxxxxxxxxxxxxx) vs Cloudflare(2401:4900:xxxxxxxxxxxxxxxxxxxxxxx)\r\n"
time="2022-03-08T17:25:13+05:30" level=info msg="Record updated: gg.example.com - 2401:4900:xxxxxxxxxxxxxxxxxxxxxxx"
time="2022-03-08T17:25:13+05:30" level=info msg="IP mismatch: Current(2401:4900:xxxxxxxxxxxxxxxxxxxxxxx) vs Cloudflare(2401:4900:xxxxxxxxxxxxxxxxxxxxxxx)\r\n"
time="2022-03-08T17:25:14+05:30" level=info msg="Record updated: ff.example.com - 2401:4900:xxxxxxxxxxxxxxxxxxxxxxx"
time="2022-03-08T17:35:14+05:30" level=info msg="IP is the same as cached one (2401:4900:xxxxxxxxxxxxxxxxxxxxxxx). Skip update.\n"
time="2022-03-08T17:36:14+05:30" level=info msg="IP is the same as cached one (2401:4900:xxxxxxxxxxxxxxxxxxxxxxx). Skip update.\n"
time="2022-03-08T17:37:14+05:30" level=info msg="IP is the same as cached one (2401:4900:xxxxxxxxxxxxxxxxxxxxxxx). Skip update.\n"
time="2022-03-08T17:38:14+05:30" level=info msg="IP is the same as cached one (2401:4900:xxxxxxxxxxxxxxxxxxxxxxx). Skip update.\n"
time="2022-03-08T17:39:14+05:30" level=info msg="IP is the same as cached one (2401:4900:xxxxxxxxxxxxxxxxxxxxxxx). Skip update.\n"
time="2022-03-08T17:40:14+05:30" level=info msg="IP is the same as cached one (2401:4900:xxxxxxxxxxxxxxxxxxxxxxx). Skip update.\n"
time="2022-03-08T17:41:14+05:30" level=info msg="IP is the same as cached one (2401:4900:xxxxxxxxxxxxxxxxxxxxxxx). Skip update.\n"
time="2022-03-08T17:42:14+05:30" level=info msg="IP is the same as cached one (2401:4900:xxxxxxxxxxxxxxxxxxxxxxx). Skip update.\n"

The frequency of this issue

Steps to Reproduce
Start godns when no ip update is needed

Expected behavior
Even if IP update is not needed when godns is started, IP cache should be made and used, to minimise the amount of api calls done.

Environment (please complete the following information):

TimothyYe commented 2 years ago

Thanks, I'll try to reproduce it.