Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: miekg/dns
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v1.1.56
Choose a base ref
...
head repository: miekg/dns
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v1.1.57
Choose a head ref
  • 18 commits
  • 22 files changed
  • 10 contributors

Commits on Sep 15, 2023

  1. up go version for testing (#1482)

    Signed-off-by: Miek Gieben <miek@miek.nl>
    miekg authored Sep 15, 2023

    Verified

    This commit was signed with the committer’s verified signature. The key has expired.
    Jikoo Adam
    Copy the full SHA
    0f1051c View commit details

Commits on Sep 19, 2023

  1. Enable dependabot (#1483)

    Update Go module dependencies monthly.
    
    Signed-off-by: SuperQ <superq@gmail.com>
    SuperQ authored Sep 19, 2023

    Verified

    This commit was signed with the committer’s verified signature. The key has expired.
    Jikoo Adam
    Copy the full SHA
    4d3b87f View commit details

Commits on Oct 10, 2023

  1. tweak SetDo doc (#1488)

    EugeneOne1 authored Oct 10, 2023

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    0d504a6 View commit details

Commits on Nov 2, 2023

  1. Remove comment about checking zero bit. (#1491)

    The check was removed in #975.
    tangrs authored Nov 2, 2023
    Copy the full SHA
    52f175a View commit details
  2. Simplify CanonicalName (#1494)

    This function was previously changed from using strings.ToLower to a
    custom loop to ensure it only lowercases ASCII characters. This was
    more complicated than it needed to be and introduced more allocations
    than is necessary.
    
    Instead of that approach we call strings.Map with a simple ASCII
    lowercase mapping function. Sadly we still use the nice ASCII-only fast
    path that strings.ToLower had, but it's unlikely to be worth all the
    extra code.
    tmthrgd authored Nov 2, 2023
    Copy the full SHA
    8a3ef11 View commit details
  3. Copy the full SHA
    24995b9 View commit details
  4. Bump golang.org/x/sync from 0.3.0 to 0.4.0 (#1495)

    Bumps [golang.org/x/sync](https://github.com/golang/sync) from 0.3.0 to 0.4.0.
    - [Commits](golang/sync@v0.3.0...v0.4.0)
    
    ---
    updated-dependencies:
    - dependency-name: golang.org/x/sync
      dependency-type: direct:production
      update-type: version-update:semver-minor
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    dependabot[bot] authored Nov 2, 2023
    Copy the full SHA
    cc15719 View commit details
  5. Bump golang.org/x/net from 0.15.0 to 0.17.0 (#1498)

    Bumps [golang.org/x/net](https://github.com/golang/net) from 0.15.0 to 0.17.0.
    - [Commits](golang/net@v0.15.0...v0.17.0)
    
    ---
    updated-dependencies:
    - dependency-name: golang.org/x/net
      dependency-type: direct:production
      update-type: version-update:semver-minor
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    dependabot[bot] authored Nov 2, 2023
    Copy the full SHA
    b18c05c View commit details

Commits on Nov 6, 2023

  1. Avoid using strings.Split (#1501)

    * Avoid using strings.Split
    
    strings.Split has to allocate for the return slice. This allocation
    was wasteful in ever case it was used in this library.
    
    Instead we use the new strings.Cut and other string manipulation where
    appropriate. This tends to lead to cleaner and more readable code in
    addition to the benefits this has on the garbage collector.
    
    * Further simplify structTag in the msg_generate.go
    
    This doesn't need to call strings.TrimPrefix twice.
    tmthrgd authored Nov 6, 2023
    Copy the full SHA
    02e9e72 View commit details
  2. Cleanup IsRRSet (#1502)

    This is a very minor change that simply neatens up this function.
    tmthrgd authored Nov 6, 2023
    Copy the full SHA
    9657fe6 View commit details
  3. Eliminate tmp buffer from packOctetString (#1503)

    This is exactly the same change as #1429 but for packOctetString.
    
    I have no idea how I missed this given it's the very next function.
    
    Updates #1429
    tmthrgd authored Nov 6, 2023
    Copy the full SHA
    6836ba8 View commit details
  4. Use cloneSlice in unpackDataA and unpackDataAAAA (#1504)

    I missed this pattern in #1432. These seem to be the only two
    occurrences.
    
    Updates #1432
    tmthrgd authored Nov 6, 2023
    Copy the full SHA
    1c418a3 View commit details
  5. Avoid using a goto loop in unpackDataOpt (#1505)

    We definitely shouldn't be using goto for a simple loop.
    
    This is technically a behaviour change when off == len(msg), but we're
    always called with off < len(msg) so this is unobservable.
    tmthrgd authored Nov 6, 2023
    Copy the full SHA
    3996b17 View commit details
  6. Use strings.Builder in endingToString (#1506)

    This will cause one less allocation as String allocates on a
    bytes.Buffer but not on a strings.Builder.
    tmthrgd authored Nov 6, 2023
    Copy the full SHA
    a16092f View commit details

Commits on Nov 7, 2023

  1. Remove slurpRemainder TODO from (*ZoneParser).Next (#1508)

    No one has complained about this in the four years it's been here. I
    think we can safely accept this new behaviour.
    tmthrgd authored Nov 7, 2023
    Copy the full SHA
    5d3f81b View commit details

Commits on Nov 13, 2023

  1. Swap closing order in inAxfr and inIxfr (#1511)

    * Fix closing order
    
    * Comment to make clear that the close order is deliberate
    
    ---------
    
    Co-authored-by: Tim Scheuermann <tscheuermann@anexia-it.com>
    noxer and Tim Scheuermann authored Nov 13, 2023
    Copy the full SHA
    3d593a6 View commit details

Commits on Nov 15, 2023

  1. feat: add support for ReuseAddr (#1510)

    * feat: add support for ReuseAddr
    
    * Update listen_reuseport.go
    
    * Update listen_reuseport.go
    
    * fixup! feat: add support for ReuseAddr
    
    ---------
    
    Co-authored-by: Miek Gieben <miek@miek.nl>
    jimlambrt and miekg authored Nov 15, 2023
    Copy the full SHA
    257e89e View commit details
  2. Release 1.1.57

    miekg committed Nov 15, 2023
    Copy the full SHA
    836bea2 View commit details
Showing with 358 additions and 179 deletions.
  1. +6 −0 .github/dependabot.yml
  2. +1 −1 .github/workflows/go.yml
  3. +0 −2 acceptfunc.go
  4. +14 −27 defaults.go
  5. +2 −1 dnssec_keyscan.go
  6. +2 −1 edns.go
  7. +17 −16 generate.go
  8. +3 −3 go.mod
  9. +6 −6 go.sum
  10. +6 −4 listen_no_reuseport.go
  11. +26 −4 listen_reuseport.go
  12. +9 −11 msg.go
  13. +5 −15 msg_generate.go
  14. +20 −30 msg_helpers.go
  15. +17 −28 scan.go
  16. +4 −5 scan_rr.go
  17. +7 −3 server.go
  18. +171 −0 server_test.go
  19. +25 −14 svcb.go
  20. +2 −3 types_generate.go
  21. +1 −1 version.go
  22. +14 −4 xfr.go
6 changes: 6 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version: 2
updates:
- package-ecosystem: "gomod"
directory: "/"
schedule:
interval: "monthly"
2 changes: 1 addition & 1 deletion .github/workflows/go.yml
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
go: [ 1.19.x, 1.20.x ]
go: [ 1.20.x, 1.21.x ]
steps:

- name: Set up Go
2 changes: 0 additions & 2 deletions acceptfunc.go
Original file line number Diff line number Diff line change
@@ -10,8 +10,6 @@ type MsgAcceptFunc func(dh Header) MsgAcceptAction
//
// * opcode isn't OpcodeQuery or OpcodeNotify
//
// * Zero bit isn't zero
//
// * does not have exactly 1 question in the question section
//
// * has more than 1 RR in the Answer section
41 changes: 14 additions & 27 deletions defaults.go
Original file line number Diff line number Diff line change
@@ -5,7 +5,6 @@ import (
"net"
"strconv"
"strings"
"unicode"
)

const hexDigit = "0123456789abcdef"
@@ -23,8 +22,7 @@ func (dns *Msg) SetReply(request *Msg) *Msg {
}
dns.Rcode = RcodeSuccess
if len(request.Question) > 0 {
dns.Question = make([]Question, 1)
dns.Question[0] = request.Question[0]
dns.Question = []Question{request.Question[0]}
}
return dns
}
@@ -293,26 +291,19 @@ func IsFqdn(s string) bool {
return (len(s)-i)%2 != 0
}

// IsRRset checks if 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
// if the RR set is valid, otherwise false.
// 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.
func IsRRset(rrset []RR) bool {
if len(rrset) == 0 {
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:] {
curRRHeader := rr.Header()
if curRRHeader.Rrtype != rrType || curRRHeader.Class != rrClass || curRRHeader.Name != rrName {
curH := rr.Header()
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
//signing/verifying
// signing/verifying
return false
}
}
@@ -330,19 +321,15 @@ func Fqdn(s string) string {
}

// 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.
// According to the RFC all uppercase US-ASCII letters in the owner name of the
// RR areeplaced by the corresponding lowercase US-ASCII letters.
// form is lowercase and fully qualified. Only US-ASCII letters are affected. See
// Section 6.2 in RFC 4034.
func CanonicalName(s string) string {
var result strings.Builder
for _, ch := range s {
if unicode.IsUpper(ch) && (ch >= 0x00 && ch <= 0x7F) {
result.WriteRune(unicode.ToLower(ch))
} else {
result.WriteRune(ch)
return strings.Map(func(r rune) rune {
if r >= 'A' && r <= 'Z' {
r += 'a' - 'A'
}
}
return Fqdn(result.String())
return r
}, Fqdn(s))
}

// Copied from the official Go code.
3 changes: 2 additions & 1 deletion dnssec_keyscan.go
Original file line number Diff line number Diff line change
@@ -37,7 +37,8 @@ func (k *DNSKEY) ReadPrivateKey(q io.Reader, file string) (crypto.PrivateKey, er
return nil, ErrPrivKey
}
// 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 {
return nil, ErrPrivKey
}
3 changes: 2 additions & 1 deletion edns.go
Original file line number Diff line number Diff line change
@@ -185,7 +185,7 @@ func (rr *OPT) Do() bool {

// SetDo sets the DO (DNSSEC OK) bit.
// 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) {
if len(do) == 1 {
if do[0] {
@@ -508,6 +508,7 @@ func (e *EDNS0_LLQ) String() string {
" " + strconv.FormatUint(uint64(e.LeaseLife), 10)
return s
}

func (e *EDNS0_LLQ) copy() EDNS0 {
return &EDNS0_LLQ{e.Code, e.Version, e.Opcode, e.Error, e.Id, e.LeaseLife}
}
33 changes: 17 additions & 16 deletions generate.go
Original file line number Diff line number Diff line change
@@ -35,17 +35,17 @@ func (zp *ZoneParser) generate(l lex) (RR, bool) {
token = token[:i]
}

sx := strings.SplitN(token, "-", 2)
if len(sx) != 2 {
startStr, endStr, ok := strings.Cut(token, "-")
if !ok {
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 {
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 {
return zp.setParseError("bad stop in $GENERATE range", l)
}
@@ -54,7 +54,7 @@ func (zp *ZoneParser) generate(l lex) (RR, bool) {
}

// _BLANK
l, ok := zp.c.Next()
l, ok = zp.c.Next()
if !ok || l.value != zBlank {
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) {
// Modifier is { offset [ ,width [ ,base ] ] } - provide default
// values for optional width and type, if necessary.
var offStr, widthStr, base string
switch xs := strings.Split(s, ","); len(xs) {
case 1:
offStr, widthStr, base = xs[0], "0", "d"
case 2:
offStr, widthStr, base = xs[0], xs[1], "d"
case 3:
offStr, widthStr, base = xs[0], xs[1], xs[2]
default:
offStr, s, ok0 := strings.Cut(s, ",")
widthStr, s, ok1 := strings.Cut(s, ",")
base, _, ok2 := strings.Cut(s, ",")
if !ok0 {
widthStr = "0"
}
if !ok1 {
base = "d"
}
if ok2 {
return "", 0, "bad modifier in $GENERATE"
}

@@ -234,8 +235,8 @@ func modToPrintf(s string) (string, int64, string) {
return "", 0, "bad offset in $GENERATE"
}

width, err := strconv.ParseInt(widthStr, 10, 64)
if err != nil || width < 0 || width > 255 {
width, err := strconv.ParseUint(widthStr, 10, 8)
if err != nil {
return "", 0, "bad width in $GENERATE"
}

6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
@@ -3,9 +3,9 @@ module github.com/miekg/dns
go 1.19

require (
golang.org/x/net v0.15.0
golang.org/x/sync v0.3.0
golang.org/x/sys v0.12.0
golang.org/x/net v0.17.0
golang.org/x/sync v0.4.0
golang.org/x/sys v0.13.0
golang.org/x/tools v0.13.0
)

12 changes: 6 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
golang.org/x/mod v0.12.0 h1:rmsUpXtvNzj340zd98LZ4KntptpfRHwpFOHG188oHXc=
golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/net v0.15.0 h1:ugBLEUaxABaB5AJqW9enI0ACdci2RUd4eP51NTBvuJ8=
golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk=
golang.org/x/sync v0.3.0 h1:ftCYgMx6zT/asHUrPw8BLLscYtGznsLAnjq5RH9P66E=
golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y=
golang.org/x/sys v0.12.0 h1:CM0HF96J0hcLAwsHPJZjfdNzs0gftsLfgKt57wWHJ0o=
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM=
golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE=
golang.org/x/sync v0.4.0 h1:zxkM55ReGkDlKSM+Fu41A+zmbZuaPVbGMzvvdUPznYQ=
golang.org/x/sync v0.4.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y=
golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE=
golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/tools v0.13.0 h1:Iey4qkscZuv0VvIt8E0neZjtPVQFSc870HQ448QgEmQ=
golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58=
10 changes: 6 additions & 4 deletions listen_no_reuseport.go
Original file line number Diff line number Diff line change
@@ -7,16 +7,18 @@ import "net"

const supportsReusePort = false

func listenTCP(network, addr string, reuseport bool) (net.Listener, error) {
if reuseport {
func listenTCP(network, addr string, reuseport, reuseaddr bool) (net.Listener, error) {
if reuseport || reuseaddr {
// TODO(tmthrgd): return an error?
}

return net.Listen(network, addr)
}

func listenUDP(network, addr string, reuseport bool) (net.PacketConn, error) {
if reuseport {
const supportsReuseAddr = false

func listenUDP(network, addr string, reuseport, reuseaddr bool) (net.PacketConn, error) {
if reuseport || reuseaddr {
// TODO(tmthrgd): return an error?
}

30 changes: 26 additions & 4 deletions listen_reuseport.go
Original file line number Diff line number Diff line change
@@ -25,19 +25,41 @@ func reuseportControl(network, address string, c syscall.RawConn) error {
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
if reuseport {
switch {
case reuseaddr && reuseport:
case reuseport:
lc.Control = reuseportControl
case reuseaddr:
lc.Control = reuseaddrControl
}

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
if reuseport {
switch {
case reuseaddr && reuseport:
case reuseport:
lc.Control = reuseportControl
case reuseaddr:
lc.Control = reuseaddrControl
}

return lc.ListenPacket(context.Background(), network, addr)
20 changes: 9 additions & 11 deletions msg.go
Original file line number Diff line number Diff line change
@@ -501,30 +501,28 @@ func packTxtString(s string, msg []byte, offset int) (int, error) {
return offset, nil
}

func packOctetString(s string, msg []byte, offset int, tmp []byte) (int, error) {
if offset >= len(msg) || len(s) > len(tmp) {
func packOctetString(s string, msg []byte, offset int) (int, error) {
if offset >= len(msg) || len(s) > 256*4+1 {
return offset, ErrBuf
}
bs := tmp[:len(s)]
copy(bs, s)
for i := 0; i < len(bs); i++ {
for i := 0; i < len(s); i++ {
if len(msg) <= offset {
return offset, ErrBuf
}
if bs[i] == '\\' {
if s[i] == '\\' {
i++
if i == len(bs) {
if i == len(s) {
break
}
// check for \DDD
if isDDD(bs[i:]) {
msg[offset] = dddToByte(bs[i:])
if isDDD(s[i:]) {
msg[offset] = dddToByte(s[i:])
i += 2
} else {
msg[offset] = bs[i]
msg[offset] = s[i]
}
} else {
msg[offset] = bs[i]
msg[offset] = s[i]
}
offset++
}
20 changes: 5 additions & 15 deletions msg_generate.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading