chore(all): replace net.IP with netip.Addr

This commit is contained in:
Quentin McGaw
2023-05-20 19:58:18 +00:00
parent 00ee6ff9a7
commit 0a29337c3b
91 changed files with 525 additions and 590 deletions

View File

@@ -2,7 +2,7 @@ package env
import (
"fmt"
"net"
"net/netip"
"github.com/qdm12/gluetun/internal/configuration/settings"
)
@@ -26,19 +26,19 @@ func (s *Source) readDNS() (dns settings.DNS, err error) {
return dns, nil
}
func (s *Source) readDNSServerAddress() (address net.IP, err error) {
func (s *Source) readDNSServerAddress() (address netip.Addr, err error) {
key, value := s.getEnvWithRetro("DNS_ADDRESS", "DNS_PLAINTEXT_ADDRESS")
if value == "" {
return nil, nil
return address, nil
}
address = net.ParseIP(value)
if address == nil {
return nil, fmt.Errorf("environment variable %s: %w: %s", key, ErrIPAddressParse, value)
address, err = netip.ParseAddr(value)
if err != nil {
return address, fmt.Errorf("environment variable %s: %w", key, err)
}
// TODO remove in v4
if !address.Equal(net.IPv4(127, 0, 0, 1)) { //nolint:gomnd
if address.Unmap().Compare(netip.AddrFrom4([4]byte{127, 0, 0, 1})) != 0 {
s.warner.Warn(key + " is set to " + value +
" so the DNS over TLS (DoT) server will not be used." +
" The default value changed to 127.0.0.1 so it uses the internal DoT serves." +