fix: accept bare Pi-hole IPv4 addresses

This commit is contained in:
admin committed 2026-08-14 23:38:49 +02:00
1 parent 42fa6efc84
commit 2082b68794
5 files changed
+15 -7

No files matched your search

+5 -1
View File
@@ -71,7 +71,11 @@ func New(rawURL string, insecureTLS bool) (*Client, error) {
}
func normalizeBaseURL(raw string) (string, error) {
parsed, err := url.Parse(strings.TrimSpace(raw))
raw = strings.TrimSpace(raw)
if address := net.ParseIP(raw); address != nil && address.To4() != nil {
raw = "http://" + raw
}
parsed, err := url.Parse(raw)
if err != nil || parsed.Host == "" || (parsed.Scheme != "http" && parsed.Scheme != "https") {
return "", errors.New("Pi-hole-Adresse muss eine vollständige HTTP- oder HTTPS-URL sein")
}