[chore]: Bump github.com/miekg/dns from 1.1.56 to 1.1.57 (#2439)

Bumps [github.com/miekg/dns](https://github.com/miekg/dns) from 1.1.56 to 1.1.57.
- [Changelog](https://github.com/miekg/dns/blob/master/Makefile.release)
- [Commits](https://github.com/miekg/dns/compare/v1.1.56...v1.1.57)

---
updated-dependencies:
- dependency-name: github.com/miekg/dns
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
This commit is contained in:
dependabot[bot] 2023-12-11 10:09:26 +00:00 committed by GitHub
parent cdeba94015
commit 9b03840b42
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
18 changed files with 175 additions and 162 deletions

4
go.mod
View file

@ -36,7 +36,7 @@ require (
github.com/h2non/filetype v1.1.3 github.com/h2non/filetype v1.1.3
github.com/jackc/pgx/v5 v5.5.0 github.com/jackc/pgx/v5 v5.5.0
github.com/microcosm-cc/bluemonday v1.0.26 github.com/microcosm-cc/bluemonday v1.0.26
github.com/miekg/dns v1.1.56 github.com/miekg/dns v1.1.57
github.com/minio/minio-go/v7 v7.0.65 github.com/minio/minio-go/v7 v7.0.65
github.com/mitchellh/mapstructure v1.5.0 github.com/mitchellh/mapstructure v1.5.0
github.com/oklog/ulid v1.3.1 github.com/oklog/ulid v1.3.1
@ -172,7 +172,7 @@ require (
go.opentelemetry.io/proto/otlp v1.0.0 // indirect go.opentelemetry.io/proto/otlp v1.0.0 // indirect
golang.org/x/arch v0.5.0 // indirect golang.org/x/arch v0.5.0 // indirect
golang.org/x/mod v0.12.0 // indirect golang.org/x/mod v0.12.0 // indirect
golang.org/x/sync v0.3.0 // indirect golang.org/x/sync v0.4.0 // indirect
golang.org/x/sys v0.15.0 // indirect golang.org/x/sys v0.15.0 // indirect
golang.org/x/tools v0.13.0 // indirect golang.org/x/tools v0.13.0 // indirect
google.golang.org/appengine v1.6.8 // indirect google.golang.org/appengine v1.6.8 // indirect

8
go.sum
View file

@ -399,8 +399,8 @@ github.com/matttproud/golang_protobuf_extensions v1.0.4 h1:mmDVorXM7PCGKw94cs5zk
github.com/matttproud/golang_protobuf_extensions v1.0.4/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4= github.com/matttproud/golang_protobuf_extensions v1.0.4/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4=
github.com/microcosm-cc/bluemonday v1.0.26 h1:xbqSvqzQMeEHCqMi64VAs4d8uy6Mequs3rQ0k/Khz58= github.com/microcosm-cc/bluemonday v1.0.26 h1:xbqSvqzQMeEHCqMi64VAs4d8uy6Mequs3rQ0k/Khz58=
github.com/microcosm-cc/bluemonday v1.0.26/go.mod h1:JyzOCs9gkyQyjs+6h10UEVSe02CGwkhd72Xdqh78TWs= github.com/microcosm-cc/bluemonday v1.0.26/go.mod h1:JyzOCs9gkyQyjs+6h10UEVSe02CGwkhd72Xdqh78TWs=
github.com/miekg/dns v1.1.56 h1:5imZaSeoRNvpM9SzWNhEcP9QliKiz20/dA2QabIGVnE= github.com/miekg/dns v1.1.57 h1:Jzi7ApEIzwEPLHWRcafCN9LZSBbqQpxjt/wpgvg7wcM=
github.com/miekg/dns v1.1.56/go.mod h1:cRm6Oo2C8TY9ZS/TqsSrseAcncm74lfK5G+ikN2SWWY= github.com/miekg/dns v1.1.57/go.mod h1:uqRjCRUuEAA6qsOiJvDd+CFo/vW+y5WR6SNmHE55hZk=
github.com/minio/md5-simd v1.1.2 h1:Gdi1DZK69+ZVMoNHRXJyNcxrMA4dSxoYHZSQbirFg34= github.com/minio/md5-simd v1.1.2 h1:Gdi1DZK69+ZVMoNHRXJyNcxrMA4dSxoYHZSQbirFg34=
github.com/minio/md5-simd v1.1.2/go.mod h1:MzdKDxYpY2BT9XQFocsiZf/NKVtR7nkE4RoEpN+20RM= github.com/minio/md5-simd v1.1.2/go.mod h1:MzdKDxYpY2BT9XQFocsiZf/NKVtR7nkE4RoEpN+20RM=
github.com/minio/minio-go/v7 v7.0.65 h1:sOlB8T3nQK+TApTpuN3k4WD5KasvZIE3vVFzyyCa0go= github.com/minio/minio-go/v7 v7.0.65 h1:sOlB8T3nQK+TApTpuN3k4WD5KasvZIE3vVFzyyCa0go=
@ -740,8 +740,8 @@ golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJ
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.3.0 h1:ftCYgMx6zT/asHUrPw8BLLscYtGznsLAnjq5RH9P66E= golang.org/x/sync v0.4.0 h1:zxkM55ReGkDlKSM+Fu41A+zmbZuaPVbGMzvvdUPznYQ=
golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y= golang.org/x/sync v0.4.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y=
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=

View file

@ -10,8 +10,6 @@
// //
// * opcode isn't OpcodeQuery or OpcodeNotify // * opcode isn't OpcodeQuery or OpcodeNotify
// //
// * Zero bit isn't zero
//
// * does not have exactly 1 question in the question section // * does not have exactly 1 question in the question section
// //
// * has more than 1 RR in the Answer section // * has more than 1 RR in the Answer section

View file

@ -5,7 +5,6 @@
"net" "net"
"strconv" "strconv"
"strings" "strings"
"unicode"
) )
const hexDigit = "0123456789abcdef" const hexDigit = "0123456789abcdef"
@ -23,8 +22,7 @@ func (dns *Msg) SetReply(request *Msg) *Msg {
} }
dns.Rcode = RcodeSuccess dns.Rcode = RcodeSuccess
if len(request.Question) > 0 { if len(request.Question) > 0 {
dns.Question = make([]Question, 1) dns.Question = []Question{request.Question[0]}
dns.Question[0] = request.Question[0]
} }
return dns return dns
} }
@ -293,26 +291,19 @@ func IsFqdn(s string) bool {
return (len(s)-i)%2 != 0 return (len(s)-i)%2 != 0
} }
// IsRRset checks if a set of RRs is a valid RRset as defined by RFC 2181. // IsRRset reports whether a set of RRs is a valid RRset as defined by RFC 2181.
// This means the RRs need to have the same type, name, and class. Returns true // This means the RRs need to have the same type, name, and class.
// if the RR set is valid, otherwise false.
func IsRRset(rrset []RR) bool { func IsRRset(rrset []RR) bool {
if len(rrset) == 0 { if len(rrset) == 0 {
return false return false
} }
if len(rrset) == 1 {
return true
}
rrHeader := rrset[0].Header()
rrType := rrHeader.Rrtype
rrClass := rrHeader.Class
rrName := rrHeader.Name
baseH := rrset[0].Header()
for _, rr := range rrset[1:] { for _, rr := range rrset[1:] {
curRRHeader := rr.Header() curH := rr.Header()
if curRRHeader.Rrtype != rrType || curRRHeader.Class != rrClass || curRRHeader.Name != rrName { if curH.Rrtype != baseH.Rrtype || curH.Class != baseH.Class || curH.Name != baseH.Name {
// Mismatch between the records, so this is not a valid rrset for // Mismatch between the records, so this is not a valid rrset for
//signing/verifying // signing/verifying
return false return false
} }
} }
@ -330,19 +321,15 @@ func Fqdn(s string) string {
} }
// CanonicalName returns the domain name in canonical form. A name in canonical // CanonicalName returns the domain name in canonical form. A name in canonical
// form is lowercase and fully qualified. See Section 6.2 in RFC 4034. // form is lowercase and fully qualified. Only US-ASCII letters are affected. See
// According to the RFC all uppercase US-ASCII letters in the owner name of the // Section 6.2 in RFC 4034.
// RR areeplaced by the corresponding lowercase US-ASCII letters.
func CanonicalName(s string) string { func CanonicalName(s string) string {
var result strings.Builder return strings.Map(func(r rune) rune {
for _, ch := range s { if r >= 'A' && r <= 'Z' {
if unicode.IsUpper(ch) && (ch >= 0x00 && ch <= 0x7F) { r += 'a' - 'A'
result.WriteRune(unicode.ToLower(ch))
} else {
result.WriteRune(ch)
} }
} return r
return Fqdn(result.String()) }, Fqdn(s))
} }
// Copied from the official Go code. // Copied from the official Go code.

View file

@ -37,7 +37,8 @@ func (k *DNSKEY) ReadPrivateKey(q io.Reader, file string) (crypto.PrivateKey, er
return nil, ErrPrivKey return nil, ErrPrivKey
} }
// TODO(mg): check if the pubkey matches the private key // TODO(mg): check if the pubkey matches the private key
algo, err := strconv.ParseUint(strings.SplitN(m["algorithm"], " ", 2)[0], 10, 8) algoStr, _, _ := strings.Cut(m["algorithm"], " ")
algo, err := strconv.ParseUint(algoStr, 10, 8)
if err != nil { if err != nil {
return nil, ErrPrivKey return nil, ErrPrivKey
} }

View file

@ -185,7 +185,7 @@ func (rr *OPT) Do() bool {
// SetDo sets the DO (DNSSEC OK) bit. // SetDo sets the DO (DNSSEC OK) bit.
// If we pass an argument, set the DO bit to that value. // If we pass an argument, set the DO bit to that value.
// It is possible to pass 2 or more arguments. Any arguments after the 1st is silently ignored. // It is possible to pass 2 or more arguments, but they will be ignored.
func (rr *OPT) SetDo(do ...bool) { func (rr *OPT) SetDo(do ...bool) {
if len(do) == 1 { if len(do) == 1 {
if do[0] { if do[0] {
@ -508,6 +508,7 @@ func (e *EDNS0_LLQ) String() string {
" " + strconv.FormatUint(uint64(e.LeaseLife), 10) " " + strconv.FormatUint(uint64(e.LeaseLife), 10)
return s return s
} }
func (e *EDNS0_LLQ) copy() EDNS0 { func (e *EDNS0_LLQ) copy() EDNS0 {
return &EDNS0_LLQ{e.Code, e.Version, e.Opcode, e.Error, e.Id, e.LeaseLife} return &EDNS0_LLQ{e.Code, e.Version, e.Opcode, e.Error, e.Id, e.LeaseLife}
} }

View file

@ -35,17 +35,17 @@ func (zp *ZoneParser) generate(l lex) (RR, bool) {
token = token[:i] token = token[:i]
} }
sx := strings.SplitN(token, "-", 2) startStr, endStr, ok := strings.Cut(token, "-")
if len(sx) != 2 { if !ok {
return zp.setParseError("bad start-stop in $GENERATE range", l) return zp.setParseError("bad start-stop in $GENERATE range", l)
} }
start, err := strconv.ParseInt(sx[0], 10, 64) start, err := strconv.ParseInt(startStr, 10, 64)
if err != nil { if err != nil {
return zp.setParseError("bad start in $GENERATE range", l) return zp.setParseError("bad start in $GENERATE range", l)
} }
end, err := strconv.ParseInt(sx[1], 10, 64) end, err := strconv.ParseInt(endStr, 10, 64)
if err != nil { if err != nil {
return zp.setParseError("bad stop in $GENERATE range", l) return zp.setParseError("bad stop in $GENERATE range", l)
} }
@ -54,7 +54,7 @@ func (zp *ZoneParser) generate(l lex) (RR, bool) {
} }
// _BLANK // _BLANK
l, ok := zp.c.Next() l, ok = zp.c.Next()
if !ok || l.value != zBlank { if !ok || l.value != zBlank {
return zp.setParseError("garbage after $GENERATE range", l) return zp.setParseError("garbage after $GENERATE range", l)
} }
@ -211,15 +211,16 @@ func (r *generateReader) ReadByte() (byte, error) {
func modToPrintf(s string) (string, int64, string) { func modToPrintf(s string) (string, int64, string) {
// Modifier is { offset [ ,width [ ,base ] ] } - provide default // Modifier is { offset [ ,width [ ,base ] ] } - provide default
// values for optional width and type, if necessary. // values for optional width and type, if necessary.
var offStr, widthStr, base string offStr, s, ok0 := strings.Cut(s, ",")
switch xs := strings.Split(s, ","); len(xs) { widthStr, s, ok1 := strings.Cut(s, ",")
case 1: base, _, ok2 := strings.Cut(s, ",")
offStr, widthStr, base = xs[0], "0", "d" if !ok0 {
case 2: widthStr = "0"
offStr, widthStr, base = xs[0], xs[1], "d" }
case 3: if !ok1 {
offStr, widthStr, base = xs[0], xs[1], xs[2] base = "d"
default: }
if ok2 {
return "", 0, "bad modifier in $GENERATE" return "", 0, "bad modifier in $GENERATE"
} }
@ -234,8 +235,8 @@ func modToPrintf(s string) (string, int64, string) {
return "", 0, "bad offset in $GENERATE" return "", 0, "bad offset in $GENERATE"
} }
width, err := strconv.ParseInt(widthStr, 10, 64) width, err := strconv.ParseUint(widthStr, 10, 8)
if err != nil || width < 0 || width > 255 { if err != nil {
return "", 0, "bad width in $GENERATE" return "", 0, "bad width in $GENERATE"
} }

View file

@ -7,16 +7,18 @@
const supportsReusePort = false const supportsReusePort = false
func listenTCP(network, addr string, reuseport bool) (net.Listener, error) { func listenTCP(network, addr string, reuseport, reuseaddr bool) (net.Listener, error) {
if reuseport { if reuseport || reuseaddr {
// TODO(tmthrgd): return an error? // TODO(tmthrgd): return an error?
} }
return net.Listen(network, addr) return net.Listen(network, addr)
} }
func listenUDP(network, addr string, reuseport bool) (net.PacketConn, error) { const supportsReuseAddr = false
if reuseport {
func listenUDP(network, addr string, reuseport, reuseaddr bool) (net.PacketConn, error) {
if reuseport || reuseaddr {
// TODO(tmthrgd): return an error? // TODO(tmthrgd): return an error?
} }

View file

@ -25,19 +25,41 @@ func reuseportControl(network, address string, c syscall.RawConn) error {
return opErr return opErr
} }
func listenTCP(network, addr string, reuseport bool) (net.Listener, error) { const supportsReuseAddr = true
func reuseaddrControl(network, address string, c syscall.RawConn) error {
var opErr error
err := c.Control(func(fd uintptr) {
opErr = unix.SetsockoptInt(int(fd), unix.SOL_SOCKET, unix.SO_REUSEADDR, 1)
})
if err != nil {
return err
}
return opErr
}
func listenTCP(network, addr string, reuseport, reuseaddr bool) (net.Listener, error) {
var lc net.ListenConfig var lc net.ListenConfig
if reuseport { switch {
case reuseaddr && reuseport:
case reuseport:
lc.Control = reuseportControl lc.Control = reuseportControl
case reuseaddr:
lc.Control = reuseaddrControl
} }
return lc.Listen(context.Background(), network, addr) return lc.Listen(context.Background(), network, addr)
} }
func listenUDP(network, addr string, reuseport bool) (net.PacketConn, error) { func listenUDP(network, addr string, reuseport, reuseaddr bool) (net.PacketConn, error) {
var lc net.ListenConfig var lc net.ListenConfig
if reuseport { switch {
case reuseaddr && reuseport:
case reuseport:
lc.Control = reuseportControl lc.Control = reuseportControl
case reuseaddr:
lc.Control = reuseaddrControl
} }
return lc.ListenPacket(context.Background(), network, addr) return lc.ListenPacket(context.Background(), network, addr)

20
vendor/github.com/miekg/dns/msg.go generated vendored
View file

@ -501,30 +501,28 @@ func packTxtString(s string, msg []byte, offset int) (int, error) {
return offset, nil return offset, nil
} }
func packOctetString(s string, msg []byte, offset int, tmp []byte) (int, error) { func packOctetString(s string, msg []byte, offset int) (int, error) {
if offset >= len(msg) || len(s) > len(tmp) { if offset >= len(msg) || len(s) > 256*4+1 {
return offset, ErrBuf return offset, ErrBuf
} }
bs := tmp[:len(s)] for i := 0; i < len(s); i++ {
copy(bs, s)
for i := 0; i < len(bs); i++ {
if len(msg) <= offset { if len(msg) <= offset {
return offset, ErrBuf return offset, ErrBuf
} }
if bs[i] == '\\' { if s[i] == '\\' {
i++ i++
if i == len(bs) { if i == len(s) {
break break
} }
// check for \DDD // check for \DDD
if isDDD(bs[i:]) { if isDDD(s[i:]) {
msg[offset] = dddToByte(bs[i:]) msg[offset] = dddToByte(s[i:])
i += 2 i += 2
} else { } else {
msg[offset] = bs[i] msg[offset] = s[i]
} }
} else { } else {
msg[offset] = bs[i] msg[offset] = s[i]
} }
offset++ offset++
} }

View file

@ -20,9 +20,7 @@ func unpackDataA(msg []byte, off int) (net.IP, int, error) {
if off+net.IPv4len > len(msg) { if off+net.IPv4len > len(msg) {
return nil, len(msg), &Error{err: "overflow unpacking a"} return nil, len(msg), &Error{err: "overflow unpacking a"}
} }
a := append(make(net.IP, 0, net.IPv4len), msg[off:off+net.IPv4len]...) return cloneSlice(msg[off : off+net.IPv4len]), off + net.IPv4len, nil
off += net.IPv4len
return a, off, nil
} }
func packDataA(a net.IP, msg []byte, off int) (int, error) { func packDataA(a net.IP, msg []byte, off int) (int, error) {
@ -47,9 +45,7 @@ func unpackDataAAAA(msg []byte, off int) (net.IP, int, error) {
if off+net.IPv6len > len(msg) { if off+net.IPv6len > len(msg) {
return nil, len(msg), &Error{err: "overflow unpacking aaaa"} return nil, len(msg), &Error{err: "overflow unpacking aaaa"}
} }
aaaa := append(make(net.IP, 0, net.IPv6len), msg[off:off+net.IPv6len]...) return cloneSlice(msg[off : off+net.IPv6len]), off + net.IPv6len, nil
off += net.IPv6len
return aaaa, off, nil
} }
func packDataAAAA(aaaa net.IP, msg []byte, off int) (int, error) { func packDataAAAA(aaaa net.IP, msg []byte, off int) (int, error) {
@ -410,29 +406,24 @@ func packStringTxt(s []string, msg []byte, off int) (int, error) {
func unpackDataOpt(msg []byte, off int) ([]EDNS0, int, error) { func unpackDataOpt(msg []byte, off int) ([]EDNS0, int, error) {
var edns []EDNS0 var edns []EDNS0
Option: for off < len(msg) {
var code uint16 if off+4 > len(msg) {
if off+4 > len(msg) { return nil, len(msg), &Error{err: "overflow unpacking opt"}
return nil, len(msg), &Error{err: "overflow unpacking opt"} }
code := binary.BigEndian.Uint16(msg[off:])
off += 2
optlen := binary.BigEndian.Uint16(msg[off:])
off += 2
if off+int(optlen) > len(msg) {
return nil, len(msg), &Error{err: "overflow unpacking opt"}
}
opt := makeDataOpt(code)
if err := opt.unpack(msg[off : off+int(optlen)]); err != nil {
return nil, len(msg), err
}
edns = append(edns, opt)
off += int(optlen)
} }
code = binary.BigEndian.Uint16(msg[off:])
off += 2
optlen := binary.BigEndian.Uint16(msg[off:])
off += 2
if off+int(optlen) > len(msg) {
return nil, len(msg), &Error{err: "overflow unpacking opt"}
}
e := makeDataOpt(code)
if err := e.unpack(msg[off : off+int(optlen)]); err != nil {
return nil, len(msg), err
}
edns = append(edns, e)
off += int(optlen)
if off < len(msg) {
goto Option
}
return edns, off, nil return edns, off, nil
} }
@ -461,8 +452,7 @@ func unpackStringOctet(msg []byte, off int) (string, int, error) {
} }
func packStringOctet(s string, msg []byte, off int) (int, error) { func packStringOctet(s string, msg []byte, off int) (int, error) {
txtTmp := make([]byte, 256*4+1) off, err := packOctetString(s, msg, off)
off, err := packOctetString(s, msg, off, txtTmp)
if err != nil { if err != nil {
return len(msg), err return len(msg), err
} }

51
vendor/github.com/miekg/dns/scan.go generated vendored
View file

@ -605,8 +605,6 @@ func (zp *ZoneParser) Next() (RR, bool) {
if !isPrivate && zp.c.Peek().token == "" { if !isPrivate && zp.c.Peek().token == "" {
// This is a dynamic update rr. // This is a dynamic update rr.
// TODO(tmthrgd): Previously slurpRemainder was only called
// for certain RR types, which may have been important.
if err := slurpRemainder(zp.c); err != nil { if err := slurpRemainder(zp.c); err != nil {
return zp.setParseError(err.err, err.lex) return zp.setParseError(err.err, err.lex)
} }
@ -1216,42 +1214,34 @@ func stringToCm(token string) (e, m uint8, ok bool) {
if token[len(token)-1] == 'M' || token[len(token)-1] == 'm' { if token[len(token)-1] == 'M' || token[len(token)-1] == 'm' {
token = token[0 : len(token)-1] token = token[0 : len(token)-1]
} }
s := strings.SplitN(token, ".", 2)
var meters, cmeters, val int var (
var err error meters, cmeters, val int
switch len(s) { err error
case 2: )
if cmeters, err = strconv.Atoi(s[1]); err != nil { mStr, cmStr, hasCM := strings.Cut(token, ".")
return if hasCM {
}
// There's no point in having more than 2 digits in this part, and would rather make the implementation complicated ('123' should be treated as '12'). // There's no point in having more than 2 digits in this part, and would rather make the implementation complicated ('123' should be treated as '12').
// So we simply reject it. // So we simply reject it.
// We also make sure the first character is a digit to reject '+-' signs. // We also make sure the first character is a digit to reject '+-' signs.
if len(s[1]) > 2 || s[1][0] < '0' || s[1][0] > '9' { cmeters, err = strconv.Atoi(cmStr)
if err != nil || len(cmStr) > 2 || cmStr[0] < '0' || cmStr[0] > '9' {
return return
} }
if len(s[1]) == 1 { if len(cmStr) == 1 {
// 'nn.1' must be treated as 'nn-meters and 10cm, not 1cm. // 'nn.1' must be treated as 'nn-meters and 10cm, not 1cm.
cmeters *= 10 cmeters *= 10
} }
if s[0] == "" {
// This will allow omitting the 'meter' part, like .01 (meaning 0.01m = 1cm).
break
}
fallthrough
case 1:
if meters, err = strconv.Atoi(s[0]); err != nil {
return
}
// RFC1876 states the max value is 90000000.00. The latter two conditions enforce it.
if s[0][0] < '0' || s[0][0] > '9' || meters > 90000000 || (meters == 90000000 && cmeters != 0) {
return
}
case 0:
// huh?
return 0, 0, false
} }
ok = true // This slighly ugly condition will allow omitting the 'meter' part, like .01 (meaning 0.01m = 1cm).
if !hasCM || mStr != "" {
meters, err = strconv.Atoi(mStr)
// RFC1876 states the max value is 90000000.00. The latter two conditions enforce it.
if err != nil || mStr[0] < '0' || mStr[0] > '9' || meters > 90000000 || (meters == 90000000 && cmeters != 0) {
return
}
}
if meters > 0 { if meters > 0 {
e = 2 e = 2
val = meters val = meters
@ -1263,8 +1253,7 @@ func stringToCm(token string) (e, m uint8, ok bool) {
e++ e++
val /= 10 val /= 10
} }
m = uint8(val) return e, uint8(val), true
return
} }
func toAbsoluteName(name, origin string) (absolute string, ok bool) { func toAbsoluteName(name, origin string) (absolute string, ok bool) {

View file

@ -1,7 +1,6 @@
package dns package dns
import ( import (
"bytes"
"encoding/base64" "encoding/base64"
"errors" "errors"
"net" "net"
@ -12,15 +11,15 @@
// A remainder of the rdata with embedded spaces, return the parsed string (sans the spaces) // A remainder of the rdata with embedded spaces, return the parsed string (sans the spaces)
// or an error // or an error
func endingToString(c *zlexer, errstr string) (string, *ParseError) { func endingToString(c *zlexer, errstr string) (string, *ParseError) {
var buffer bytes.Buffer var s strings.Builder
l, _ := c.Next() // zString l, _ := c.Next() // zString
for l.value != zNewline && l.value != zEOF { for l.value != zNewline && l.value != zEOF {
if l.err { if l.err {
return buffer.String(), &ParseError{"", errstr, l} return s.String(), &ParseError{"", errstr, l}
} }
switch l.value { switch l.value {
case zString: case zString:
buffer.WriteString(l.token) s.WriteString(l.token)
case zBlank: // Ok case zBlank: // Ok
default: default:
return "", &ParseError{"", errstr, l} return "", &ParseError{"", errstr, l}
@ -28,7 +27,7 @@ func endingToString(c *zlexer, errstr string) (string, *ParseError) {
l, _ = c.Next() l, _ = c.Next()
} }
return buffer.String(), nil return s.String(), nil
} }
// A remainder of the rdata with embedded spaces, split on unquoted whitespace // A remainder of the rdata with embedded spaces, split on unquoted whitespace

View file

@ -226,6 +226,10 @@ type Server struct {
// Whether to set the SO_REUSEPORT socket option, allowing multiple listeners to be bound to a single address. // Whether to set the SO_REUSEPORT socket option, allowing multiple listeners to be bound to a single address.
// It is only supported on certain GOOSes and when using ListenAndServe. // It is only supported on certain GOOSes and when using ListenAndServe.
ReusePort bool ReusePort bool
// Whether to set the SO_REUSEADDR socket option, allowing multiple listeners to be bound to a single address.
// Crucially this allows binding when an existing server is listening on `0.0.0.0` or `::`.
// It is only supported on certain GOOSes and when using ListenAndServe.
ReuseAddr bool
// AcceptMsgFunc will check the incoming message and will reject it early in the process. // AcceptMsgFunc will check the incoming message and will reject it early in the process.
// By default DefaultMsgAcceptFunc will be used. // By default DefaultMsgAcceptFunc will be used.
MsgAcceptFunc MsgAcceptFunc MsgAcceptFunc MsgAcceptFunc
@ -304,7 +308,7 @@ func (srv *Server) ListenAndServe() error {
switch srv.Net { switch srv.Net {
case "tcp", "tcp4", "tcp6": case "tcp", "tcp4", "tcp6":
l, err := listenTCP(srv.Net, addr, srv.ReusePort) l, err := listenTCP(srv.Net, addr, srv.ReusePort, srv.ReuseAddr)
if err != nil { if err != nil {
return err return err
} }
@ -317,7 +321,7 @@ func (srv *Server) ListenAndServe() error {
return errors.New("dns: neither Certificates nor GetCertificate set in Config") return errors.New("dns: neither Certificates nor GetCertificate set in Config")
} }
network := strings.TrimSuffix(srv.Net, "-tls") network := strings.TrimSuffix(srv.Net, "-tls")
l, err := listenTCP(network, addr, srv.ReusePort) l, err := listenTCP(network, addr, srv.ReusePort, srv.ReuseAddr)
if err != nil { if err != nil {
return err return err
} }
@ -327,7 +331,7 @@ func (srv *Server) ListenAndServe() error {
unlock() unlock()
return srv.serveTCP(l) return srv.serveTCP(l)
case "udp", "udp4", "udp6": case "udp", "udp4", "udp6":
l, err := listenUDP(srv.Net, addr, srv.ReusePort) l, err := listenUDP(srv.Net, addr, srv.ReusePort, srv.ReuseAddr)
if err != nil { if err != nil {
return err return err
} }

39
vendor/github.com/miekg/dns/svcb.go generated vendored
View file

@ -314,10 +314,11 @@ func (s *SVCBMandatory) unpack(b []byte) error {
} }
func (s *SVCBMandatory) parse(b string) error { func (s *SVCBMandatory) parse(b string) error {
str := strings.Split(b, ",") codes := make([]SVCBKey, 0, strings.Count(b, ",")+1)
codes := make([]SVCBKey, 0, len(str)) for len(b) > 0 {
for _, e := range str { var key string
codes = append(codes, svcbStringToKey(e)) key, b, _ = strings.Cut(b, ",")
codes = append(codes, svcbStringToKey(key))
} }
s.Code = codes s.Code = codes
return nil return nil
@ -613,19 +614,24 @@ func (s *SVCBIPv4Hint) String() string {
} }
func (s *SVCBIPv4Hint) parse(b string) error { func (s *SVCBIPv4Hint) parse(b string) error {
if b == "" {
return errors.New("dns: svcbipv4hint: empty hint")
}
if strings.Contains(b, ":") { if strings.Contains(b, ":") {
return errors.New("dns: svcbipv4hint: expected ipv4, got ipv6") return errors.New("dns: svcbipv4hint: expected ipv4, got ipv6")
} }
str := strings.Split(b, ",")
dst := make([]net.IP, len(str)) hint := make([]net.IP, 0, strings.Count(b, ",")+1)
for i, e := range str { for len(b) > 0 {
var e string
e, b, _ = strings.Cut(b, ",")
ip := net.ParseIP(e).To4() ip := net.ParseIP(e).To4()
if ip == nil { if ip == nil {
return errors.New("dns: svcbipv4hint: bad ip") return errors.New("dns: svcbipv4hint: bad ip")
} }
dst[i] = ip hint = append(hint, ip)
} }
s.Hint = dst s.Hint = hint
return nil return nil
} }
@ -733,9 +739,14 @@ func (s *SVCBIPv6Hint) String() string {
} }
func (s *SVCBIPv6Hint) parse(b string) error { func (s *SVCBIPv6Hint) parse(b string) error {
str := strings.Split(b, ",") if b == "" {
dst := make([]net.IP, len(str)) return errors.New("dns: svcbipv6hint: empty hint")
for i, e := range str { }
hint := make([]net.IP, 0, strings.Count(b, ",")+1)
for len(b) > 0 {
var e string
e, b, _ = strings.Cut(b, ",")
ip := net.ParseIP(e) ip := net.ParseIP(e)
if ip == nil { if ip == nil {
return errors.New("dns: svcbipv6hint: bad ip") return errors.New("dns: svcbipv6hint: bad ip")
@ -743,9 +754,9 @@ func (s *SVCBIPv6Hint) parse(b string) error {
if ip.To4() != nil { if ip.To4() != nil {
return errors.New("dns: svcbipv6hint: expected ipv6, got ipv4-mapped-ipv6") return errors.New("dns: svcbipv6hint: expected ipv6, got ipv4-mapped-ipv6")
} }
dst[i] = ip hint = append(hint, ip)
} }
s.Hint = dst s.Hint = hint
return nil return nil
} }

View file

@ -3,7 +3,7 @@
import "fmt" import "fmt"
// Version is current version of this library. // Version is current version of this library.
var Version = v{1, 1, 56} var Version = v{1, 1, 57}
// v holds the version of this library. // v holds the version of this library.
type v struct { type v struct {

18
vendor/github.com/miekg/dns/xfr.go generated vendored
View file

@ -80,8 +80,13 @@ func (t *Transfer) In(q *Msg, a string) (env chan *Envelope, err error) {
func (t *Transfer) inAxfr(q *Msg, c chan *Envelope) { func (t *Transfer) inAxfr(q *Msg, c chan *Envelope) {
first := true first := true
defer t.Close() defer func() {
defer close(c) // First close the connection, then the channel. This allows functions blocked on
// the channel to assume that the connection is closed and no further operations are
// pending when they resume.
t.Close()
close(c)
}()
timeout := dnsTimeout timeout := dnsTimeout
if t.ReadTimeout != 0 { if t.ReadTimeout != 0 {
timeout = t.ReadTimeout timeout = t.ReadTimeout
@ -131,8 +136,13 @@ func (t *Transfer) inIxfr(q *Msg, c chan *Envelope) {
axfr := true axfr := true
n := 0 n := 0
qser := q.Ns[0].(*SOA).Serial qser := q.Ns[0].(*SOA).Serial
defer t.Close() defer func() {
defer close(c) // First close the connection, then the channel. This allows functions blocked on
// the channel to assume that the connection is closed and no further operations are
// pending when they resume.
t.Close()
close(c)
}()
timeout := dnsTimeout timeout := dnsTimeout
if t.ReadTimeout != 0 { if t.ReadTimeout != 0 {
timeout = t.ReadTimeout timeout = t.ReadTimeout

4
vendor/modules.txt vendored
View file

@ -376,7 +376,7 @@ github.com/matttproud/golang_protobuf_extensions/pbutil
## explicit; go 1.21 ## explicit; go 1.21
github.com/microcosm-cc/bluemonday github.com/microcosm-cc/bluemonday
github.com/microcosm-cc/bluemonday/css github.com/microcosm-cc/bluemonday/css
# github.com/miekg/dns v1.1.56 # github.com/miekg/dns v1.1.57
## explicit; go 1.19 ## explicit; go 1.19
github.com/miekg/dns github.com/miekg/dns
# github.com/minio/md5-simd v1.1.2 # github.com/minio/md5-simd v1.1.2
@ -905,7 +905,7 @@ golang.org/x/net/trace
## explicit; go 1.18 ## explicit; go 1.18
golang.org/x/oauth2 golang.org/x/oauth2
golang.org/x/oauth2/internal golang.org/x/oauth2/internal
# golang.org/x/sync v0.3.0 # golang.org/x/sync v0.4.0
## explicit; go 1.17 ## explicit; go 1.17
golang.org/x/sync/semaphore golang.org/x/sync/semaphore
# golang.org/x/sys v0.15.0 # golang.org/x/sys v0.15.0