summaryrefslogtreecommitdiff
path: root/caddyconfig/httpcaddyfile
diff options
context:
space:
mode:
authorWilczyƄskiT <102859171+WilczynskiT@users.noreply.github.com>2022-08-18 00:10:57 +0200
committerGitHub <noreply@github.com>2022-08-17 16:10:57 -0600
commitc7772588bd44ceffcc0ba4817e4d43c826675379 (patch)
tree8a5f538b2b5a170460e6ca21fb159d37a9e6a335 /caddyconfig/httpcaddyfile
parenta944de4ab7acfdd114d11a2ca0d267110ba9c152 (diff)
core: Change net.IP to netip.Addr; use netip.Prefix (#4966)
Co-authored-by: Matt Holt <mholt@users.noreply.github.com>
Diffstat (limited to 'caddyconfig/httpcaddyfile')
-rw-r--r--caddyconfig/httpcaddyfile/addresses.go7
1 files changed, 4 insertions, 3 deletions
diff --git a/caddyconfig/httpcaddyfile/addresses.go b/caddyconfig/httpcaddyfile/addresses.go
index 0553c08..e7a7cdb 100644
--- a/caddyconfig/httpcaddyfile/addresses.go
+++ b/caddyconfig/httpcaddyfile/addresses.go
@@ -17,6 +17,7 @@ package httpcaddyfile
import (
"fmt"
"net"
+ "net/netip"
"reflect"
"sort"
"strconv"
@@ -354,9 +355,9 @@ func (a Address) Normalize() Address {
// ensure host is normalized if it's an IP address
host := strings.TrimSpace(a.Host)
- if ip := net.ParseIP(host); ip != nil {
- if ipv6 := ip.To16(); ipv6 != nil && ipv6.DefaultMask() == nil {
- host = ipv6.String()
+ if ip, err := netip.ParseAddr(host); err == nil {
+ if ip.Is6() && !ip.Is4() && !ip.Is4In6() {
+ host = ip.String()
}
}