Add round-robin implementation (#66)

* add handler.encapsulateNode

* implement round robin handler approach

* simplify round robin implementation

* leave TODO

* internet.node touch up

* fix conflict resolve f-up

* replace certain ErrShortBuffer with ErrTruncatedFrame error
This commit is contained in:
Pat Whittingslow
2026-04-09 09:36:17 -03:00
committed by GitHub
parent ec44889896
commit 63f7870fe5
21 changed files with 104 additions and 70 deletions
+5 -6
View File
@@ -16,7 +16,6 @@ var (
errNoNullTerm = errors.New("DNS name missing null terminator")
errCalcLen = errors.New("DNS calculated name label length exceeds remaining buffer length")
errCantAddLabel = errors.New("long/empty/zterm/escape DNS label or not enough space")
errBaseLen = lneto.ErrShortBuffer
errReserved = errors.New("segment prefix is reserved")
errTooManyPtr = errors.New("too many pointers (>10)")
errInvalidPtr = errors.New("invalid pointer")
@@ -27,10 +26,10 @@ var (
errZeroSegLen = errors.New("zero length segment")
errResTooLong = errors.New("resource length too long")
errTooManyQuestions = lneto.ErrBufferFull
errTooManyAnswers = lneto.ErrBufferFull
errTooManyAuthorities = lneto.ErrBufferFull
errTooManyAdditionals = lneto.ErrBufferFull
errTooManyQuestions = lneto.ErrExhausted
errTooManyAnswers = lneto.ErrExhausted
errTooManyAuthorities = lneto.ErrExhausted
errTooManyAdditionals = lneto.ErrExhausted
errNonCanonicalName = errors.New("name is not in canonical format (it must end with a .)")
errStringTooLong = errors.New("character string exceeds maximum length (255)")
@@ -49,7 +48,7 @@ type Frame struct {
func NewFrame(buf []byte) (Frame, error) {
if len(buf) < SizeHeader {
return Frame{}, errBaseLen
return Frame{}, lneto.ErrTruncatedFrame
}
return Frame{buf: buf}, nil
}
+4 -3
View File
@@ -8,6 +8,7 @@ import (
"strconv"
"strings"
"github.com/soypat/lneto"
"github.com/soypat/lneto/internal"
)
@@ -196,7 +197,7 @@ func skipQuestion(msg []byte, off uint16) (_ uint16, err error) {
return off, err
}
if off+4 > uint16(len(msg)) {
return off, errBaseLen
return off, lneto.ErrTruncatedFrame
}
return off + 4, nil
}
@@ -210,7 +211,7 @@ func skipResource(msg []byte, off uint16) (_ uint16, err error) {
datalen := binary.BigEndian.Uint16(msg[off+8:])
off += datalen + 10
if off > uint16(len(msg)) {
return off, errBaseLen
return off, lneto.ErrTruncatedFrame
}
return off, nil
}
@@ -610,7 +611,7 @@ func visitAllLabels(msg []byte, off uint16, fn func(b []byte), allowCompression
LOOP:
for {
if currOff >= uint16(len(msg)) {
return off, errBaseLen
return off, lneto.ErrTruncatedFrame
}
c := uint16(msg[currOff])
currOff++