summaryrefslogtreecommitdiff
path: root/vendor/github.com/miekg/dns/svcb.go
diff options
context:
space:
mode:
authorLibravatar dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>2023-12-11 10:09:26 +0000
committerLibravatar GitHub <noreply@github.com>2023-12-11 10:09:26 +0000
commit9b03840b428838ed5a8cbabd0e38640f847edcbe (patch)
tree7d4c74b57b2b8761b93c16e38adbe3da21954c10 /vendor/github.com/miekg/dns/svcb.go
parent[chore]: Bump golang.org/x/oauth2 from 0.13.0 to 0.15.0 (#2438) (diff)
downloadgotosocial-9b03840b428838ed5a8cbabd0e38640f847edcbe.tar.xz
[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>
Diffstat (limited to 'vendor/github.com/miekg/dns/svcb.go')
-rw-r--r--vendor/github.com/miekg/dns/svcb.go39
1 files changed, 25 insertions, 14 deletions
diff --git a/vendor/github.com/miekg/dns/svcb.go b/vendor/github.com/miekg/dns/svcb.go
index 6d496d74d..d38aa2f05 100644
--- a/vendor/github.com/miekg/dns/svcb.go
+++ b/vendor/github.com/miekg/dns/svcb.go
@@ -314,10 +314,11 @@ func (s *SVCBMandatory) unpack(b []byte) error {
}
func (s *SVCBMandatory) parse(b string) error {
- str := strings.Split(b, ",")
- codes := make([]SVCBKey, 0, len(str))
- for _, e := range str {
- codes = append(codes, svcbStringToKey(e))
+ codes := make([]SVCBKey, 0, strings.Count(b, ",")+1)
+ for len(b) > 0 {
+ var key string
+ key, b, _ = strings.Cut(b, ",")
+ codes = append(codes, svcbStringToKey(key))
}
s.Code = codes
return nil
@@ -613,19 +614,24 @@ func (s *SVCBIPv4Hint) String() string {
}
func (s *SVCBIPv4Hint) parse(b string) error {
+ if b == "" {
+ return errors.New("dns: svcbipv4hint: empty hint")
+ }
if strings.Contains(b, ":") {
return errors.New("dns: svcbipv4hint: expected ipv4, got ipv6")
}
- str := strings.Split(b, ",")
- dst := make([]net.IP, len(str))
- 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).To4()
if ip == nil {
return errors.New("dns: svcbipv4hint: bad ip")
}
- dst[i] = ip
+ hint = append(hint, ip)
}
- s.Hint = dst
+ s.Hint = hint
return nil
}
@@ -733,9 +739,14 @@ func (s *SVCBIPv6Hint) String() string {
}
func (s *SVCBIPv6Hint) parse(b string) error {
- str := strings.Split(b, ",")
- dst := make([]net.IP, len(str))
- for i, e := range str {
+ if b == "" {
+ return errors.New("dns: svcbipv6hint: empty hint")
+ }
+
+ 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)
if ip == nil {
return errors.New("dns: svcbipv6hint: bad ip")
@@ -743,9 +754,9 @@ func (s *SVCBIPv6Hint) parse(b string) error {
if ip.To4() != nil {
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
}