aboutsummaryrefslogtreecommitdiff
path: root/middleware/file/tree/less.go
diff options
context:
space:
mode:
authorGravatar Miek Gieben <miek@miek.nl> 2017-09-14 09:36:06 +0100
committerGravatar GitHub <noreply@github.com> 2017-09-14 09:36:06 +0100
commitd8714e64e400ef873c2adc4d929a07d7890727b9 (patch)
treec9fa4c157e6af12eb1517654f8d23ca5d5619513 /middleware/file/tree/less.go
parentb984aa45595dc95253b91191afe7d3ee29e71b48 (diff)
downloadcoredns-d8714e64e400ef873c2adc4d929a07d7890727b9.tar.gz
coredns-d8714e64e400ef873c2adc4d929a07d7890727b9.tar.zst
coredns-d8714e64e400ef873c2adc4d929a07d7890727b9.zip
Remove the word middleware (#1067)
* Rename middleware to plugin first pass; mostly used 'sed', few spots where I manually changed text. This still builds a coredns binary. * fmt error * Rename AddMiddleware to AddPlugin * Readd AddMiddleware to remain backwards compat
Diffstat (limited to 'middleware/file/tree/less.go')
-rw-r--r--middleware/file/tree/less.go59
1 files changed, 0 insertions, 59 deletions
diff --git a/middleware/file/tree/less.go b/middleware/file/tree/less.go
deleted file mode 100644
index 3b8340088..000000000
--- a/middleware/file/tree/less.go
+++ /dev/null
@@ -1,59 +0,0 @@
-package tree
-
-import (
- "bytes"
-
- "github.com/miekg/dns"
-)
-
-// less returns <0 when a is less than b, 0 when they are equal and
-// >0 when a is larger than b.
-// The function orders names in DNSSEC canonical order: RFC 4034s section-6.1
-//
-// See http://bert-hubert.blogspot.co.uk/2015/10/how-to-do-fast-canonical-ordering-of.html
-// for a blog article on this implementation, although here we still go label by label.
-//
-// The values of a and b are *not* lowercased before the comparison!
-func less(a, b string) int {
- i := 1
- aj := len(a)
- bj := len(b)
- for {
- ai, oka := dns.PrevLabel(a, i)
- bi, okb := dns.PrevLabel(b, i)
- if oka && okb {
- return 0
- }
-
- // sadly this []byte will allocate... TODO(miek): check if this is needed
- // for a name, otherwise compare the strings.
- ab := []byte(a[ai:aj])
- bb := []byte(b[bi:bj])
- doDDD(ab)
- doDDD(bb)
-
- res := bytes.Compare(ab, bb)
- if res != 0 {
- return res
- }
-
- i++
- aj, bj = ai, bi
- }
-}
-
-func doDDD(b []byte) {
- lb := len(b)
- for i := 0; i < lb; i++ {
- if i+3 < lb && b[i] == '\\' && isDigit(b[i+1]) && isDigit(b[i+2]) && isDigit(b[i+3]) {
- b[i] = dddToByte(b[i:])
- for j := i + 1; j < lb-3; j++ {
- b[j] = b[j+3]
- }
- lb -= 3
- }
- }
-}
-
-func isDigit(b byte) bool { return b >= '0' && b <= '9' }
-func dddToByte(s []byte) byte { return (s[1]-'0')*100 + (s[2]-'0')*10 + (s[3] - '0') }