[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
+31
View File
@@ -225,3 +225,34 @@ func tcpBackoff(consecutiveBackoffs uint) time.Duration {
wait := min(shifted, maxWait)
return time.Duration(wait)
}
// resolveHostToIP checks if host is already an IP literal, or queries the DNS server.
func resolveHostToIP(stack *NetworkStack, host string, timeout time.Duration) (netip.Addr, error) {
// 1. If it's already an IP string (e.g. "162.159.200.1"), parse and return directly
if ip, err := netip.ParseAddr(host); err == nil {
return ip, nil
}
// 2. Start asynchronous DNS A-record query
if err := stack.stack.StartLookupIP(host); err != nil {
return netip.Addr{}, fmt.Errorf("start DNS lookup: %w", err)
}
// 3. Poll ResultLookupIP until done or timed out
deadline := time.Now().Add(timeout)
for time.Now().Before(deadline) {
addrs, done, err := stack.stack.ResultLookupIP(host)
if done {
if err != nil {
return netip.Addr{}, fmt.Errorf("DNS lookup error: %w", err)
}
if len(addrs) == 0 {
return netip.Addr{}, fmt.Errorf("no addresses returned for %s", host)
}
return addrs[0], nil
}
time.Sleep(50 * time.Millisecond)
}
return netip.Addr{}, fmt.Errorf("DNS lookup timed out for %s", host)
}