[Issue #1] - Added configurable NTPServer option in config.go; also added DNS name resolution so you don't have to use IPs
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/tag/woodpecker Pipeline was successful

This commit is contained in:
2026-09-11 00:39:54 -04:00
parent 5e00c5c8ed
commit d09369c394
3 changed files with 53 additions and 10 deletions
+21 -10
View File
@@ -109,16 +109,27 @@ func main() {
// Extract IP string from the returned NetworkStack
ipStr := netStack.localIP.String()
// Sync wall time using public NTP (e.g. Cloudflare: 162.159.200.1 / time.cloudflare.com)
println("Synchronizing clock via NTP...")
oled.ClearBuffer()
tinyfont.WriteLine(oled, defaultFont, 0, 32, "Syncing NTP...", white)
oled.Display()
ntpServer := netip.MustParseAddr("162.159.200.1")
timeOffset, err := syncNTP(netStack, ntpServer, 5*time.Second)
if err != nil {
panicErr("NTP sync failed", err)
}
println("Resolving NTP server:", NTPServer)
oled.ClearBuffer()
tinyfont.WriteLine(oled, defaultFont, 0, 32, "Resolving NTP...", white)
oled.Display()
ntpServer, err := resolveHostToIP(netStack, NTPServer, 5*time.Second)
if err != nil {
panicErr("NTP DNS lookup failed", err)
}
println("NTP server IP: ", ntpServer.String())
time.Sleep(1 * time.Second)
println("Synchronizing clock via NTP...")
oled.ClearBuffer()
tinyfont.WriteLine(oled, defaultFont, 0, 32, "Syncing NTP...", white)
oled.Display()
timeOffset, err := syncNTP(netStack, ntpServer, 5*time.Second)
if err != nil {
panicErr("NTP sync failed", err)
}
println("NTP synced successfully!")
oled.ClearBuffer()