diff --git a/Gopkg.lock b/Gopkg.lock index e832ac61..6321b1c4 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -26,6 +26,7 @@ version = "2018.01.18" [[projects]] + branch = "master" name = "github.com/coredns/coredns" packages = [ "core/dnsserver", @@ -40,6 +41,7 @@ "plugin/pkg/cache", "plugin/pkg/dnstest", "plugin/pkg/dnsutil", + "plugin/pkg/doh", "plugin/pkg/edns", "plugin/pkg/fuzz", "plugin/pkg/log", @@ -48,11 +50,11 @@ "plugin/pkg/response", "plugin/pkg/trace", "plugin/pkg/uniq", + "plugin/pkg/watch", "plugin/test", "request" ] - revision = "f78f30231df90da6184d5f811ecf9c06b0160c2b" - version = "v1.1.4" + revision = "992e7928c7c258628d2b13b769acc86781b9faea" [[projects]] name = "github.com/coreos/go-systemd" @@ -398,6 +400,6 @@ [solve-meta] analyzer-name = "dep" analyzer-version = 1 - inputs-digest = "42fdf43f93aac410675bb8134097b51c90c110dc4c77595b8d2fb7c7876bd3d2" + inputs-digest = "a2d109989dfc76050eeb638546c012e192b5dc71d248c9d27cfa3f3282927966" solver-name = "gps-cdcl" solver-version = 1 diff --git a/Gopkg.toml b/Gopkg.toml index 52e227ea..8c58549e 100644 --- a/Gopkg.toml +++ b/Gopkg.toml @@ -1,3 +1,7 @@ +[prune] + go-tests = true + unused-packages = true + [[constraint]] name = "github.com/facebookgo/grace" branch = "master" @@ -43,3 +47,6 @@ name = "github.com/gorilla/websocket" version = "1.2.0" +[[constraint]] + name = "github.com/coredns/coredns" + branch = "master" diff --git a/cmd/cloudflared/hello_test.go b/cmd/cloudflared/hello_test.go deleted file mode 100644 index f6e8842a..00000000 --- a/cmd/cloudflared/hello_test.go +++ /dev/null @@ -1,35 +0,0 @@ -package main - -import ( - "testing" -) - -func TestCreateListenerHostAndPortSuccess(t *testing.T) { - listener, err := createListener("localhost:1234") - if err != nil { - t.Fatal(err) - } - if listener.Addr().String() == "" { - t.Fatal("Fail to find available port") - } -} - -func TestCreateListenerOnlyHostSuccess(t *testing.T) { - listener, err := createListener("localhost:") - if err != nil { - t.Fatal(err) - } - if listener.Addr().String() == "" { - t.Fatal("Fail to find available port") - } -} - -func TestCreateListenerOnlyPortSuccess(t *testing.T) { - listener, err := createListener(":8888") - if err != nil { - t.Fatal(err) - } - if listener.Addr().String() == "" { - t.Fatal("Fail to find available port") - } -} diff --git a/h2mux/h2_compressor_brotli.go b/h2mux/h2_compressor_brotli.go index 8a250fd0..ed0b85b7 100644 --- a/h2mux/h2_compressor_brotli.go +++ b/h2mux/h2_compressor_brotli.go @@ -5,7 +5,7 @@ package h2mux import ( "io" - "code.cfops.it/go/brotli" + "github.com/cloudflare/brotli-go" ) func CompressionIsSupported() bool { diff --git a/vendor/github.com/BurntSushi/toml/_examples/example.go b/vendor/github.com/BurntSushi/toml/_examples/example.go deleted file mode 100644 index 79f31f27..00000000 --- a/vendor/github.com/BurntSushi/toml/_examples/example.go +++ /dev/null @@ -1,61 +0,0 @@ -package main - -import ( - "fmt" - "time" - - "github.com/BurntSushi/toml" -) - -type tomlConfig struct { - Title string - Owner ownerInfo - DB database `toml:"database"` - Servers map[string]server - Clients clients -} - -type ownerInfo struct { - Name string - Org string `toml:"organization"` - Bio string - DOB time.Time -} - -type database struct { - Server string - Ports []int - ConnMax int `toml:"connection_max"` - Enabled bool -} - -type server struct { - IP string - DC string -} - -type clients struct { - Data [][]interface{} - Hosts []string -} - -func main() { - var config tomlConfig - if _, err := toml.DecodeFile("example.toml", &config); err != nil { - fmt.Println(err) - return - } - - fmt.Printf("Title: %s\n", config.Title) - fmt.Printf("Owner: %s (%s, %s), Born: %s\n", - config.Owner.Name, config.Owner.Org, config.Owner.Bio, - config.Owner.DOB) - fmt.Printf("Database: %s %v (Max conn. %d), Enabled? %v\n", - config.DB.Server, config.DB.Ports, config.DB.ConnMax, - config.DB.Enabled) - for serverName, server := range config.Servers { - fmt.Printf("Server: %s (%s, %s)\n", serverName, server.IP, server.DC) - } - fmt.Printf("Client data: %v\n", config.Clients.Data) - fmt.Printf("Client hosts: %v\n", config.Clients.Hosts) -} diff --git a/vendor/github.com/BurntSushi/toml/_examples/example.toml b/vendor/github.com/BurntSushi/toml/_examples/example.toml deleted file mode 100644 index 32c7a4fa..00000000 --- a/vendor/github.com/BurntSushi/toml/_examples/example.toml +++ /dev/null @@ -1,35 +0,0 @@ -# This is a TOML document. Boom. - -title = "TOML Example" - -[owner] -name = "Tom Preston-Werner" -organization = "GitHub" -bio = "GitHub Cofounder & CEO\nLikes tater tots and beer." -dob = 1979-05-27T07:32:00Z # First class dates? Why not? - -[database] -server = "192.168.1.1" -ports = [ 8001, 8001, 8002 ] -connection_max = 5000 -enabled = true - -[servers] - - # You can indent as you please. Tabs or spaces. TOML don't care. - [servers.alpha] - ip = "10.0.0.1" - dc = "eqdc10" - - [servers.beta] - ip = "10.0.0.2" - dc = "eqdc10" - -[clients] -data = [ ["gamma", "delta"], [1, 2] ] # just an update to make sure parsers support it - -# Line breaks are OK when inside arrays -hosts = [ - "alpha", - "omega" -] diff --git a/vendor/github.com/BurntSushi/toml/_examples/hard.toml b/vendor/github.com/BurntSushi/toml/_examples/hard.toml deleted file mode 100644 index 26145d2b..00000000 --- a/vendor/github.com/BurntSushi/toml/_examples/hard.toml +++ /dev/null @@ -1,22 +0,0 @@ -# Test file for TOML -# Only this one tries to emulate a TOML file written by a user of the kind of parser writers probably hate -# This part you'll really hate - -[the] -test_string = "You'll hate me after this - #" # " Annoying, isn't it? - - [the.hard] - test_array = [ "] ", " # "] # ] There you go, parse this! - test_array2 = [ "Test #11 ]proved that", "Experiment #9 was a success" ] - # You didn't think it'd as easy as chucking out the last #, did you? - another_test_string = " Same thing, but with a string #" - harder_test_string = " And when \"'s are in the string, along with # \"" # "and comments are there too" - # Things will get harder - - [the.hard.bit#] - what? = "You don't think some user won't do that?" - multi_line_array = [ - "]", - # ] Oh yes I did - ] - diff --git a/vendor/github.com/BurntSushi/toml/_examples/implicit.toml b/vendor/github.com/BurntSushi/toml/_examples/implicit.toml deleted file mode 100644 index 1dea5ceb..00000000 --- a/vendor/github.com/BurntSushi/toml/_examples/implicit.toml +++ /dev/null @@ -1,4 +0,0 @@ -# [x] you -# [x.y] don't -# [x.y.z] need these -[x.y.z.w] # for this to work diff --git a/vendor/github.com/BurntSushi/toml/_examples/invalid-apples.toml b/vendor/github.com/BurntSushi/toml/_examples/invalid-apples.toml deleted file mode 100644 index 74e9e337..00000000 --- a/vendor/github.com/BurntSushi/toml/_examples/invalid-apples.toml +++ /dev/null @@ -1,6 +0,0 @@ -# DO NOT WANT -[fruit] -type = "apple" - -[fruit.type] -apple = "yes" diff --git a/vendor/github.com/BurntSushi/toml/_examples/invalid.toml b/vendor/github.com/BurntSushi/toml/_examples/invalid.toml deleted file mode 100644 index beb1dba5..00000000 --- a/vendor/github.com/BurntSushi/toml/_examples/invalid.toml +++ /dev/null @@ -1,35 +0,0 @@ -# This is an INVALID TOML document. Boom. -# Can you spot the error without help? - -title = "TOML Example" - -[owner] -name = "Tom Preston-Werner" -organization = "GitHub" -bio = "GitHub Cofounder & CEO\nLikes tater tots and beer." -dob = 1979-05-27T7:32:00Z # First class dates? Why not? - -[database] -server = "192.168.1.1" -ports = [ 8001, 8001, 8002 ] -connection_max = 5000 -enabled = true - -[servers] - # You can indent as you please. Tabs or spaces. TOML don't care. - [servers.alpha] - ip = "10.0.0.1" - dc = "eqdc10" - - [servers.beta] - ip = "10.0.0.2" - dc = "eqdc10" - -[clients] -data = [ ["gamma", "delta"], [1, 2] ] # just an update to make sure parsers support it - -# Line breaks are OK when inside arrays -hosts = [ - "alpha", - "omega" -] diff --git a/vendor/github.com/BurntSushi/toml/_examples/readme1.toml b/vendor/github.com/BurntSushi/toml/_examples/readme1.toml deleted file mode 100644 index 3e1261d4..00000000 --- a/vendor/github.com/BurntSushi/toml/_examples/readme1.toml +++ /dev/null @@ -1,5 +0,0 @@ -Age = 25 -Cats = [ "Cauchy", "Plato" ] -Pi = 3.14 -Perfection = [ 6, 28, 496, 8128 ] -DOB = 1987-07-05T05:45:00Z diff --git a/vendor/github.com/BurntSushi/toml/_examples/readme2.toml b/vendor/github.com/BurntSushi/toml/_examples/readme2.toml deleted file mode 100644 index b51cd934..00000000 --- a/vendor/github.com/BurntSushi/toml/_examples/readme2.toml +++ /dev/null @@ -1 +0,0 @@ -some_key_NAME = "wat" diff --git a/vendor/github.com/BurntSushi/toml/cmd/toml-test-decoder/README.md b/vendor/github.com/BurntSushi/toml/cmd/toml-test-decoder/README.md deleted file mode 100644 index 93f4e3a0..00000000 --- a/vendor/github.com/BurntSushi/toml/cmd/toml-test-decoder/README.md +++ /dev/null @@ -1,13 +0,0 @@ -# Implements the TOML test suite interface - -This is an implementation of the interface expected by -[toml-test](https://github.com/BurntSushi/toml-test) for my -[toml parser written in Go](https://github.com/BurntSushi/toml). -In particular, it maps TOML data on `stdin` to a JSON format on `stdout`. - - -Compatible with TOML version -[v0.4.0](https://github.com/toml-lang/toml/blob/master/versions/en/toml-v0.4.0.md) - -Compatible with `toml-test` version -[v0.2.0](https://github.com/BurntSushi/toml-test/tree/v0.2.0) diff --git a/vendor/github.com/BurntSushi/toml/cmd/toml-test-decoder/main.go b/vendor/github.com/BurntSushi/toml/cmd/toml-test-decoder/main.go deleted file mode 100644 index 14e75570..00000000 --- a/vendor/github.com/BurntSushi/toml/cmd/toml-test-decoder/main.go +++ /dev/null @@ -1,90 +0,0 @@ -// Command toml-test-decoder satisfies the toml-test interface for testing -// TOML decoders. Namely, it accepts TOML on stdin and outputs JSON on stdout. -package main - -import ( - "encoding/json" - "flag" - "fmt" - "log" - "os" - "path" - "time" - - "github.com/BurntSushi/toml" -) - -func init() { - log.SetFlags(0) - - flag.Usage = usage - flag.Parse() -} - -func usage() { - log.Printf("Usage: %s < toml-file\n", path.Base(os.Args[0])) - flag.PrintDefaults() - - os.Exit(1) -} - -func main() { - if flag.NArg() != 0 { - flag.Usage() - } - - var tmp interface{} - if _, err := toml.DecodeReader(os.Stdin, &tmp); err != nil { - log.Fatalf("Error decoding TOML: %s", err) - } - - typedTmp := translate(tmp) - if err := json.NewEncoder(os.Stdout).Encode(typedTmp); err != nil { - log.Fatalf("Error encoding JSON: %s", err) - } -} - -func translate(tomlData interface{}) interface{} { - switch orig := tomlData.(type) { - case map[string]interface{}: - typed := make(map[string]interface{}, len(orig)) - for k, v := range orig { - typed[k] = translate(v) - } - return typed - case []map[string]interface{}: - typed := make([]map[string]interface{}, len(orig)) - for i, v := range orig { - typed[i] = translate(v).(map[string]interface{}) - } - return typed - case []interface{}: - typed := make([]interface{}, len(orig)) - for i, v := range orig { - typed[i] = translate(v) - } - - // We don't really need to tag arrays, but let's be future proof. - // (If TOML ever supports tuples, we'll need this.) - return tag("array", typed) - case time.Time: - return tag("datetime", orig.Format("2006-01-02T15:04:05Z")) - case bool: - return tag("bool", fmt.Sprintf("%v", orig)) - case int64: - return tag("integer", fmt.Sprintf("%d", orig)) - case float64: - return tag("float", fmt.Sprintf("%v", orig)) - case string: - return tag("string", orig) - } - - panic(fmt.Sprintf("Unknown type: %T", tomlData)) -} - -func tag(typeName string, data interface{}) map[string]interface{} { - return map[string]interface{}{ - "type": typeName, - "value": data, - } -} diff --git a/vendor/github.com/BurntSushi/toml/cmd/toml-test-encoder/README.md b/vendor/github.com/BurntSushi/toml/cmd/toml-test-encoder/README.md deleted file mode 100644 index a45bd4da..00000000 --- a/vendor/github.com/BurntSushi/toml/cmd/toml-test-encoder/README.md +++ /dev/null @@ -1,13 +0,0 @@ -# Implements the TOML test suite interface for TOML encoders - -This is an implementation of the interface expected by -[toml-test](https://github.com/BurntSushi/toml-test) for the -[TOML encoder](https://github.com/BurntSushi/toml). -In particular, it maps JSON data on `stdin` to a TOML format on `stdout`. - - -Compatible with TOML version -[v0.4.0](https://github.com/toml-lang/toml/blob/master/versions/en/toml-v0.4.0.md) - -Compatible with `toml-test` version -[v0.2.0](https://github.com/BurntSushi/toml-test/tree/v0.2.0) diff --git a/vendor/github.com/BurntSushi/toml/cmd/toml-test-encoder/main.go b/vendor/github.com/BurntSushi/toml/cmd/toml-test-encoder/main.go deleted file mode 100644 index 092cc684..00000000 --- a/vendor/github.com/BurntSushi/toml/cmd/toml-test-encoder/main.go +++ /dev/null @@ -1,131 +0,0 @@ -// Command toml-test-encoder satisfies the toml-test interface for testing -// TOML encoders. Namely, it accepts JSON on stdin and outputs TOML on stdout. -package main - -import ( - "encoding/json" - "flag" - "log" - "os" - "path" - "strconv" - "time" - - "github.com/BurntSushi/toml" -) - -func init() { - log.SetFlags(0) - - flag.Usage = usage - flag.Parse() -} - -func usage() { - log.Printf("Usage: %s < json-file\n", path.Base(os.Args[0])) - flag.PrintDefaults() - - os.Exit(1) -} - -func main() { - if flag.NArg() != 0 { - flag.Usage() - } - - var tmp interface{} - if err := json.NewDecoder(os.Stdin).Decode(&tmp); err != nil { - log.Fatalf("Error decoding JSON: %s", err) - } - - tomlData := translate(tmp) - if err := toml.NewEncoder(os.Stdout).Encode(tomlData); err != nil { - log.Fatalf("Error encoding TOML: %s", err) - } -} - -func translate(typedJson interface{}) interface{} { - switch v := typedJson.(type) { - case map[string]interface{}: - if len(v) == 2 && in("type", v) && in("value", v) { - return untag(v) - } - m := make(map[string]interface{}, len(v)) - for k, v2 := range v { - m[k] = translate(v2) - } - return m - case []interface{}: - tabArray := make([]map[string]interface{}, len(v)) - for i := range v { - if m, ok := translate(v[i]).(map[string]interface{}); ok { - tabArray[i] = m - } else { - log.Fatalf("JSON arrays may only contain objects. This " + - "corresponds to only tables being allowed in " + - "TOML table arrays.") - } - } - return tabArray - } - log.Fatalf("Unrecognized JSON format '%T'.", typedJson) - panic("unreachable") -} - -func untag(typed map[string]interface{}) interface{} { - t := typed["type"].(string) - v := typed["value"] - switch t { - case "string": - return v.(string) - case "integer": - v := v.(string) - n, err := strconv.Atoi(v) - if err != nil { - log.Fatalf("Could not parse '%s' as integer: %s", v, err) - } - return n - case "float": - v := v.(string) - f, err := strconv.ParseFloat(v, 64) - if err != nil { - log.Fatalf("Could not parse '%s' as float64: %s", v, err) - } - return f - case "datetime": - v := v.(string) - t, err := time.Parse("2006-01-02T15:04:05Z", v) - if err != nil { - log.Fatalf("Could not parse '%s' as a datetime: %s", v, err) - } - return t - case "bool": - v := v.(string) - switch v { - case "true": - return true - case "false": - return false - } - log.Fatalf("Could not parse '%s' as a boolean.", v) - case "array": - v := v.([]interface{}) - array := make([]interface{}, len(v)) - for i := range v { - if m, ok := v[i].(map[string]interface{}); ok { - array[i] = untag(m) - } else { - log.Fatalf("Arrays may only contain other arrays or "+ - "primitive values, but found a '%T'.", m) - } - } - return array - } - log.Fatalf("Unrecognized tag type '%s'.", t) - panic("unreachable") -} - -func in(key string, m map[string]interface{}) bool { - _, ok := m[key] - return ok -} diff --git a/vendor/github.com/BurntSushi/toml/cmd/tomlv/README.md b/vendor/github.com/BurntSushi/toml/cmd/tomlv/README.md deleted file mode 100644 index 51231e29..00000000 --- a/vendor/github.com/BurntSushi/toml/cmd/tomlv/README.md +++ /dev/null @@ -1,21 +0,0 @@ -# TOML Validator - -If Go is installed, it's simple to try it out: - -```bash -go get github.com/BurntSushi/toml/cmd/tomlv -tomlv some-toml-file.toml -``` - -You can see the types of every key in a TOML file with: - -```bash -tomlv -types some-toml-file.toml -``` - -At the moment, only one error message is reported at a time. Error messages -include line numbers. No output means that the files given are valid TOML, or -there is a bug in `tomlv`. - -Compatible with TOML version -[v0.4.0](https://github.com/toml-lang/toml/blob/master/versions/en/toml-v0.4.0.md) diff --git a/vendor/github.com/BurntSushi/toml/cmd/tomlv/main.go b/vendor/github.com/BurntSushi/toml/cmd/tomlv/main.go deleted file mode 100644 index c7d689a7..00000000 --- a/vendor/github.com/BurntSushi/toml/cmd/tomlv/main.go +++ /dev/null @@ -1,61 +0,0 @@ -// Command tomlv validates TOML documents and prints each key's type. -package main - -import ( - "flag" - "fmt" - "log" - "os" - "path" - "strings" - "text/tabwriter" - - "github.com/BurntSushi/toml" -) - -var ( - flagTypes = false -) - -func init() { - log.SetFlags(0) - - flag.BoolVar(&flagTypes, "types", flagTypes, - "When set, the types of every defined key will be shown.") - - flag.Usage = usage - flag.Parse() -} - -func usage() { - log.Printf("Usage: %s toml-file [ toml-file ... ]\n", - path.Base(os.Args[0])) - flag.PrintDefaults() - - os.Exit(1) -} - -func main() { - if flag.NArg() < 1 { - flag.Usage() - } - for _, f := range flag.Args() { - var tmp interface{} - md, err := toml.DecodeFile(f, &tmp) - if err != nil { - log.Fatalf("Error in '%s': %s", f, err) - } - if flagTypes { - printTypes(md) - } - } -} - -func printTypes(md toml.MetaData) { - tabw := tabwriter.NewWriter(os.Stdout, 0, 0, 2, ' ', 0) - for _, key := range md.Keys() { - fmt.Fprintf(tabw, "%s%s\t%s\n", - strings.Repeat(" ", len(key)-1), key, md.Type(key...)) - } - tabw.Flush() -} diff --git a/vendor/github.com/BurntSushi/toml/decode_test.go b/vendor/github.com/BurntSushi/toml/decode_test.go deleted file mode 100644 index 0c36b33e..00000000 --- a/vendor/github.com/BurntSushi/toml/decode_test.go +++ /dev/null @@ -1,1447 +0,0 @@ -package toml - -import ( - "fmt" - "log" - "math" - "reflect" - "strings" - "testing" - "time" -) - -func TestDecodeSimple(t *testing.T) { - var testSimple = ` -age = 250 -andrew = "gallant" -kait = "brady" -now = 1987-07-05T05:45:00Z -yesOrNo = true -pi = 3.14 -colors = [ - ["red", "green", "blue"], - ["cyan", "magenta", "yellow", "black"], -] - -[My.Cats] -plato = "cat 1" -cauchy = "cat 2" -` - - type cats struct { - Plato string - Cauchy string - } - type simple struct { - Age int - Colors [][]string - Pi float64 - YesOrNo bool - Now time.Time - Andrew string - Kait string - My map[string]cats - } - - var val simple - _, err := Decode(testSimple, &val) - if err != nil { - t.Fatal(err) - } - - now, err := time.Parse("2006-01-02T15:04:05", "1987-07-05T05:45:00") - if err != nil { - panic(err) - } - var answer = simple{ - Age: 250, - Andrew: "gallant", - Kait: "brady", - Now: now, - YesOrNo: true, - Pi: 3.14, - Colors: [][]string{ - {"red", "green", "blue"}, - {"cyan", "magenta", "yellow", "black"}, - }, - My: map[string]cats{ - "Cats": {Plato: "cat 1", Cauchy: "cat 2"}, - }, - } - if !reflect.DeepEqual(val, answer) { - t.Fatalf("Expected\n-----\n%#v\n-----\nbut got\n-----\n%#v\n", - answer, val) - } -} - -func TestDecodeEmbedded(t *testing.T) { - type Dog struct{ Name string } - type Age int - type cat struct{ Name string } - - for _, test := range []struct { - label string - input string - decodeInto interface{} - wantDecoded interface{} - }{ - { - label: "embedded struct", - input: `Name = "milton"`, - decodeInto: &struct{ Dog }{}, - wantDecoded: &struct{ Dog }{Dog{"milton"}}, - }, - { - label: "embedded non-nil pointer to struct", - input: `Name = "milton"`, - decodeInto: &struct{ *Dog }{}, - wantDecoded: &struct{ *Dog }{&Dog{"milton"}}, - }, - { - label: "embedded nil pointer to struct", - input: ``, - decodeInto: &struct{ *Dog }{}, - wantDecoded: &struct{ *Dog }{nil}, - }, - { - label: "unexported embedded struct", - input: `Name = "socks"`, - decodeInto: &struct{ cat }{}, - wantDecoded: &struct{ cat }{cat{"socks"}}, - }, - { - label: "embedded int", - input: `Age = -5`, - decodeInto: &struct{ Age }{}, - wantDecoded: &struct{ Age }{-5}, - }, - } { - _, err := Decode(test.input, test.decodeInto) - if err != nil { - t.Fatal(err) - } - if !reflect.DeepEqual(test.wantDecoded, test.decodeInto) { - t.Errorf("%s: want decoded == %+v, got %+v", - test.label, test.wantDecoded, test.decodeInto) - } - } -} - -func TestDecodeIgnoredFields(t *testing.T) { - type simple struct { - Number int `toml:"-"` - } - const input = ` -Number = 123 -- = 234 -` - var s simple - if _, err := Decode(input, &s); err != nil { - t.Fatal(err) - } - if s.Number != 0 { - t.Errorf("got: %d; want 0", s.Number) - } -} - -func TestTableArrays(t *testing.T) { - var tomlTableArrays = ` -[[albums]] -name = "Born to Run" - - [[albums.songs]] - name = "Jungleland" - - [[albums.songs]] - name = "Meeting Across the River" - -[[albums]] -name = "Born in the USA" - - [[albums.songs]] - name = "Glory Days" - - [[albums.songs]] - name = "Dancing in the Dark" -` - - type Song struct { - Name string - } - - type Album struct { - Name string - Songs []Song - } - - type Music struct { - Albums []Album - } - - expected := Music{[]Album{ - {"Born to Run", []Song{{"Jungleland"}, {"Meeting Across the River"}}}, - {"Born in the USA", []Song{{"Glory Days"}, {"Dancing in the Dark"}}}, - }} - var got Music - if _, err := Decode(tomlTableArrays, &got); err != nil { - t.Fatal(err) - } - if !reflect.DeepEqual(expected, got) { - t.Fatalf("\n%#v\n!=\n%#v\n", expected, got) - } -} - -func TestTableNesting(t *testing.T) { - for _, tt := range []struct { - t string - want []string - }{ - {"[a.b.c]", []string{"a", "b", "c"}}, - {`[a."b.c"]`, []string{"a", "b.c"}}, - {`[a.'b.c']`, []string{"a", "b.c"}}, - {`[a.' b ']`, []string{"a", " b "}}, - {"[ d.e.f ]", []string{"d", "e", "f"}}, - {"[ g . h . i ]", []string{"g", "h", "i"}}, - {`[ j . "ʞ" . 'l' ]`, []string{"j", "ʞ", "l"}}, - } { - var m map[string]interface{} - if _, err := Decode(tt.t, &m); err != nil { - t.Errorf("Decode(%q): got error: %s", tt.t, err) - continue - } - if keys := extractNestedKeys(m); !reflect.DeepEqual(keys, tt.want) { - t.Errorf("Decode(%q): got nested keys %#v; want %#v", - tt.t, keys, tt.want) - } - } -} - -func extractNestedKeys(v map[string]interface{}) []string { - var result []string - for { - if len(v) != 1 { - return result - } - for k, m := range v { - result = append(result, k) - var ok bool - v, ok = m.(map[string]interface{}) - if !ok { - return result - } - } - - } -} - -// Case insensitive matching tests. -// A bit more comprehensive than needed given the current implementation, -// but implementations change. -// Probably still missing demonstrations of some ugly corner cases regarding -// case insensitive matching and multiple fields. -func TestCase(t *testing.T) { - var caseToml = ` -tOpString = "string" -tOpInt = 1 -tOpFloat = 1.1 -tOpBool = true -tOpdate = 2006-01-02T15:04:05Z -tOparray = [ "array" ] -Match = "i should be in Match only" -MatcH = "i should be in MatcH only" -once = "just once" -[nEst.eD] -nEstedString = "another string" -` - - type InsensitiveEd struct { - NestedString string - } - - type InsensitiveNest struct { - Ed InsensitiveEd - } - - type Insensitive struct { - TopString string - TopInt int - TopFloat float64 - TopBool bool - TopDate time.Time - TopArray []string - Match string - MatcH string - Once string - OncE string - Nest InsensitiveNest - } - - tme, err := time.Parse(time.RFC3339, time.RFC3339[:len(time.RFC3339)-5]) - if err != nil { - panic(err) - } - expected := Insensitive{ - TopString: "string", - TopInt: 1, - TopFloat: 1.1, - TopBool: true, - TopDate: tme, - TopArray: []string{"array"}, - MatcH: "i should be in MatcH only", - Match: "i should be in Match only", - Once: "just once", - OncE: "", - Nest: InsensitiveNest{ - Ed: InsensitiveEd{NestedString: "another string"}, - }, - } - var got Insensitive - if _, err := Decode(caseToml, &got); err != nil { - t.Fatal(err) - } - if !reflect.DeepEqual(expected, got) { - t.Fatalf("\n%#v\n!=\n%#v\n", expected, got) - } -} - -func TestPointers(t *testing.T) { - type Object struct { - Type string - Description string - } - - type Dict struct { - NamedObject map[string]*Object - BaseObject *Object - Strptr *string - Strptrs []*string - } - s1, s2, s3 := "blah", "abc", "def" - expected := &Dict{ - Strptr: &s1, - Strptrs: []*string{&s2, &s3}, - NamedObject: map[string]*Object{ - "foo": {"FOO", "fooooo!!!"}, - "bar": {"BAR", "ba-ba-ba-ba-barrrr!!!"}, - }, - BaseObject: &Object{"BASE", "da base"}, - } - - ex1 := ` -Strptr = "blah" -Strptrs = ["abc", "def"] - -[NamedObject.foo] -Type = "FOO" -Description = "fooooo!!!" - -[NamedObject.bar] -Type = "BAR" -Description = "ba-ba-ba-ba-barrrr!!!" - -[BaseObject] -Type = "BASE" -Description = "da base" -` - dict := new(Dict) - _, err := Decode(ex1, dict) - if err != nil { - t.Errorf("Decode error: %v", err) - } - if !reflect.DeepEqual(expected, dict) { - t.Fatalf("\n%#v\n!=\n%#v\n", expected, dict) - } -} - -func TestDecodeDatetime(t *testing.T) { - const noTimestamp = "2006-01-02T15:04:05" - for _, tt := range []struct { - s string - t string - format string - }{ - {"1979-05-27T07:32:00Z", "1979-05-27T07:32:00Z", time.RFC3339}, - {"1979-05-27T00:32:00-07:00", "1979-05-27T00:32:00-07:00", time.RFC3339}, - { - "1979-05-27T00:32:00.999999-07:00", - "1979-05-27T00:32:00.999999-07:00", - time.RFC3339, - }, - {"1979-05-27T07:32:00", "1979-05-27T07:32:00", noTimestamp}, - { - "1979-05-27T00:32:00.999999", - "1979-05-27T00:32:00.999999", - noTimestamp, - }, - {"1979-05-27", "1979-05-27T00:00:00", noTimestamp}, - } { - var x struct{ D time.Time } - input := "d = " + tt.s - if _, err := Decode(input, &x); err != nil { - t.Errorf("Decode(%q): got error: %s", input, err) - continue - } - want, err := time.ParseInLocation(tt.format, tt.t, time.Local) - if err != nil { - panic(err) - } - if !x.D.Equal(want) { - t.Errorf("Decode(%q): got %s; want %s", input, x.D, want) - } - } -} - -func TestDecodeBadDatetime(t *testing.T) { - var x struct{ T time.Time } - for _, s := range []string{ - "123", - "2006-01-50T00:00:00Z", - "2006-01-30T00:00", - "2006-01-30T", - } { - input := "T = " + s - if _, err := Decode(input, &x); err == nil { - t.Errorf("Expected invalid DateTime error for %q", s) - } - } -} - -func TestDecodeMultilineStrings(t *testing.T) { - var x struct { - S string - } - const s0 = `s = """ -a b \n c -d e f -"""` - if _, err := Decode(s0, &x); err != nil { - t.Fatal(err) - } - if want := "a b \n c\nd e f\n"; x.S != want { - t.Errorf("got: %q; want: %q", x.S, want) - } - const s1 = `s = """a b c\ -"""` - if _, err := Decode(s1, &x); err != nil { - t.Fatal(err) - } - if want := "a b c"; x.S != want { - t.Errorf("got: %q; want: %q", x.S, want) - } -} - -type sphere struct { - Center [3]float64 - Radius float64 -} - -func TestDecodeSimpleArray(t *testing.T) { - var s1 sphere - if _, err := Decode(`center = [0.0, 1.5, 0.0]`, &s1); err != nil { - t.Fatal(err) - } -} - -func TestDecodeArrayWrongSize(t *testing.T) { - var s1 sphere - if _, err := Decode(`center = [0.1, 2.3]`, &s1); err == nil { - t.Fatal("Expected array type mismatch error") - } -} - -func TestDecodeLargeIntoSmallInt(t *testing.T) { - type table struct { - Value int8 - } - var tab table - if _, err := Decode(`value = 500`, &tab); err == nil { - t.Fatal("Expected integer out-of-bounds error.") - } -} - -func TestDecodeSizedInts(t *testing.T) { - type table struct { - U8 uint8 - U16 uint16 - U32 uint32 - U64 uint64 - U uint - I8 int8 - I16 int16 - I32 int32 - I64 int64 - I int - } - answer := table{1, 1, 1, 1, 1, -1, -1, -1, -1, -1} - toml := ` - u8 = 1 - u16 = 1 - u32 = 1 - u64 = 1 - u = 1 - i8 = -1 - i16 = -1 - i32 = -1 - i64 = -1 - i = -1 - ` - var tab table - if _, err := Decode(toml, &tab); err != nil { - t.Fatal(err.Error()) - } - if answer != tab { - t.Fatalf("Expected %#v but got %#v", answer, tab) - } -} - -func TestDecodeInts(t *testing.T) { - for _, tt := range []struct { - s string - want int64 - }{ - {"0", 0}, - {"+99", 99}, - {"-10", -10}, - {"1_234_567", 1234567}, - {"1_2_3_4", 1234}, - {"-9_223_372_036_854_775_808", math.MinInt64}, - {"9_223_372_036_854_775_807", math.MaxInt64}, - } { - var x struct{ N int64 } - input := "n = " + tt.s - if _, err := Decode(input, &x); err != nil { - t.Errorf("Decode(%q): got error: %s", input, err) - continue - } - if x.N != tt.want { - t.Errorf("Decode(%q): got %d; want %d", input, x.N, tt.want) - } - } -} - -func TestDecodeFloats(t *testing.T) { - for _, tt := range []struct { - s string - want float64 - }{ - {"+1.0", 1}, - {"3.1415", 3.1415}, - {"-0.01", -0.01}, - {"5e+22", 5e22}, - {"1e6", 1e6}, - {"-2E-2", -2e-2}, - {"6.626e-34", 6.626e-34}, - {"9_224_617.445_991_228_313", 9224617.445991228313}, - {"9_876.54_32e1_0", 9876.5432e10}, - } { - var x struct{ N float64 } - input := "n = " + tt.s - if _, err := Decode(input, &x); err != nil { - t.Errorf("Decode(%q): got error: %s", input, err) - continue - } - if x.N != tt.want { - t.Errorf("Decode(%q): got %f; want %f", input, x.N, tt.want) - } - } -} - -func TestDecodeMalformedNumbers(t *testing.T) { - for _, tt := range []struct { - s string - want string - }{ - {"++99", "expected a digit"}, - {"0..1", "must be followed by one or more digits"}, - {"0.1.2", "Invalid float value"}, - {"1e2.3", "Invalid float value"}, - {"1e2e3", "Invalid float value"}, - {"_123", "expected value"}, - {"123_", "surrounded by digits"}, - {"1._23", "surrounded by digits"}, - {"1e__23", "surrounded by digits"}, - {"123.", "must be followed by one or more digits"}, - {"1.e2", "must be followed by one or more digits"}, - } { - var x struct{ N interface{} } - input := "n = " + tt.s - _, err := Decode(input, &x) - if err == nil { - t.Errorf("Decode(%q): got nil, want error containing %q", - input, tt.want) - continue - } - if !strings.Contains(err.Error(), tt.want) { - t.Errorf("Decode(%q): got %q, want error containing %q", - input, err, tt.want) - } - } -} - -func TestDecodeBadValues(t *testing.T) { - for _, tt := range []struct { - v interface{} - want string - }{ - {3, "non-pointer int"}, - {(*int)(nil), "nil"}, - } { - _, err := Decode(`x = 3`, tt.v) - if err == nil { - t.Errorf("Decode(%v): got nil; want error containing %q", - tt.v, tt.want) - continue - } - if !strings.Contains(err.Error(), tt.want) { - t.Errorf("Decode(%v): got %q; want error containing %q", - tt.v, err, tt.want) - } - } -} - -func TestUnmarshaler(t *testing.T) { - - var tomlBlob = ` -[dishes.hamboogie] -name = "Hamboogie with fries" -price = 10.99 - -[[dishes.hamboogie.ingredients]] -name = "Bread Bun" - -[[dishes.hamboogie.ingredients]] -name = "Lettuce" - -[[dishes.hamboogie.ingredients]] -name = "Real Beef Patty" - -[[dishes.hamboogie.ingredients]] -name = "Tomato" - -[dishes.eggsalad] -name = "Egg Salad with rice" -price = 3.99 - -[[dishes.eggsalad.ingredients]] -name = "Egg" - -[[dishes.eggsalad.ingredients]] -name = "Mayo" - -[[dishes.eggsalad.ingredients]] -name = "Rice" -` - m := &menu{} - if _, err := Decode(tomlBlob, m); err != nil { - t.Fatal(err) - } - - if len(m.Dishes) != 2 { - t.Log("two dishes should be loaded with UnmarshalTOML()") - t.Errorf("expected %d but got %d", 2, len(m.Dishes)) - } - - eggSalad := m.Dishes["eggsalad"] - if _, ok := interface{}(eggSalad).(dish); !ok { - t.Errorf("expected a dish") - } - - if eggSalad.Name != "Egg Salad with rice" { - t.Errorf("expected the dish to be named 'Egg Salad with rice'") - } - - if len(eggSalad.Ingredients) != 3 { - t.Log("dish should be loaded with UnmarshalTOML()") - t.Errorf("expected %d but got %d", 3, len(eggSalad.Ingredients)) - } - - found := false - for _, i := range eggSalad.Ingredients { - if i.Name == "Rice" { - found = true - break - } - } - if !found { - t.Error("Rice was not loaded in UnmarshalTOML()") - } - - // test on a value - must be passed as * - o := menu{} - if _, err := Decode(tomlBlob, &o); err != nil { - t.Fatal(err) - } - -} - -func TestDecodeInlineTable(t *testing.T) { - input := ` -[CookieJar] -Types = {Chocolate = "yummy", Oatmeal = "best ever"} - -[Seasons] -Locations = {NY = {Temp = "not cold", Rating = 4}, MI = {Temp = "freezing", Rating = 9}} -` - type cookieJar struct { - Types map[string]string - } - type properties struct { - Temp string - Rating int - } - type seasons struct { - Locations map[string]properties - } - type wrapper struct { - CookieJar cookieJar - Seasons seasons - } - var got wrapper - - meta, err := Decode(input, &got) - if err != nil { - t.Fatal(err) - } - want := wrapper{ - CookieJar: cookieJar{ - Types: map[string]string{ - "Chocolate": "yummy", - "Oatmeal": "best ever", - }, - }, - Seasons: seasons{ - Locations: map[string]properties{ - "NY": { - Temp: "not cold", - Rating: 4, - }, - "MI": { - Temp: "freezing", - Rating: 9, - }, - }, - }, - } - if !reflect.DeepEqual(got, want) { - t.Fatalf("after decode, got:\n\n%#v\n\nwant:\n\n%#v", got, want) - } - if len(meta.keys) != 12 { - t.Errorf("after decode, got %d meta keys; want 12", len(meta.keys)) - } - if len(meta.types) != 12 { - t.Errorf("after decode, got %d meta types; want 12", len(meta.types)) - } -} - -func TestDecodeInlineTableArray(t *testing.T) { - type point struct { - X, Y, Z int - } - var got struct { - Points []point - } - // Example inline table array from the spec. - const in = ` -points = [ { x = 1, y = 2, z = 3 }, - { x = 7, y = 8, z = 9 }, - { x = 2, y = 4, z = 8 } ] - -` - if _, err := Decode(in, &got); err != nil { - t.Fatal(err) - } - want := []point{ - {X: 1, Y: 2, Z: 3}, - {X: 7, Y: 8, Z: 9}, - {X: 2, Y: 4, Z: 8}, - } - if !reflect.DeepEqual(got.Points, want) { - t.Errorf("got %#v; want %#v", got.Points, want) - } -} - -func TestDecodeMalformedInlineTable(t *testing.T) { - for _, tt := range []struct { - s string - want string - }{ - {"{,}", "unexpected comma"}, - {"{x = 3 y = 4}", "expected a comma or an inline table terminator"}, - {"{x=3,,y=4}", "unexpected comma"}, - {"{x=3,\ny=4}", "newlines not allowed"}, - {"{x=3\n,y=4}", "newlines not allowed"}, - } { - var x struct{ A map[string]int } - input := "a = " + tt.s - _, err := Decode(input, &x) - if err == nil { - t.Errorf("Decode(%q): got nil, want error containing %q", - input, tt.want) - continue - } - if !strings.Contains(err.Error(), tt.want) { - t.Errorf("Decode(%q): got %q, want error containing %q", - input, err, tt.want) - } - } -} - -type menu struct { - Dishes map[string]dish -} - -func (m *menu) UnmarshalTOML(p interface{}) error { - m.Dishes = make(map[string]dish) - data, _ := p.(map[string]interface{}) - dishes := data["dishes"].(map[string]interface{}) - for n, v := range dishes { - if d, ok := v.(map[string]interface{}); ok { - nd := dish{} - nd.UnmarshalTOML(d) - m.Dishes[n] = nd - } else { - return fmt.Errorf("not a dish") - } - } - return nil -} - -type dish struct { - Name string - Price float32 - Ingredients []ingredient -} - -func (d *dish) UnmarshalTOML(p interface{}) error { - data, _ := p.(map[string]interface{}) - d.Name, _ = data["name"].(string) - d.Price, _ = data["price"].(float32) - ingredients, _ := data["ingredients"].([]map[string]interface{}) - for _, e := range ingredients { - n, _ := interface{}(e).(map[string]interface{}) - name, _ := n["name"].(string) - i := ingredient{name} - d.Ingredients = append(d.Ingredients, i) - } - return nil -} - -type ingredient struct { - Name string -} - -func TestDecodeSlices(t *testing.T) { - type T struct { - S []string - } - for i, tt := range []struct { - v T - input string - want T - }{ - {T{}, "", T{}}, - {T{[]string{}}, "", T{[]string{}}}, - {T{[]string{"a", "b"}}, "", T{[]string{"a", "b"}}}, - {T{}, "S = []", T{[]string{}}}, - {T{[]string{}}, "S = []", T{[]string{}}}, - {T{[]string{"a", "b"}}, "S = []", T{[]string{}}}, - {T{}, `S = ["x"]`, T{[]string{"x"}}}, - {T{[]string{}}, `S = ["x"]`, T{[]string{"x"}}}, - {T{[]string{"a", "b"}}, `S = ["x"]`, T{[]string{"x"}}}, - } { - if _, err := Decode(tt.input, &tt.v); err != nil { - t.Errorf("[%d] %s", i, err) - continue - } - if !reflect.DeepEqual(tt.v, tt.want) { - t.Errorf("[%d] got %#v; want %#v", i, tt.v, tt.want) - } - } -} - -func TestDecodePrimitive(t *testing.T) { - type S struct { - P Primitive - } - type T struct { - S []int - } - slicep := func(s []int) *[]int { return &s } - arrayp := func(a [2]int) *[2]int { return &a } - mapp := func(m map[string]int) *map[string]int { return &m } - for i, tt := range []struct { - v interface{} - input string - want interface{} - }{ - // slices - {slicep(nil), "", slicep(nil)}, - {slicep([]int{}), "", slicep([]int{})}, - {slicep([]int{1, 2, 3}), "", slicep([]int{1, 2, 3})}, - {slicep(nil), "P = [1,2]", slicep([]int{1, 2})}, - {slicep([]int{}), "P = [1,2]", slicep([]int{1, 2})}, - {slicep([]int{1, 2, 3}), "P = [1,2]", slicep([]int{1, 2})}, - - // arrays - {arrayp([2]int{2, 3}), "", arrayp([2]int{2, 3})}, - {arrayp([2]int{2, 3}), "P = [3,4]", arrayp([2]int{3, 4})}, - - // maps - {mapp(nil), "", mapp(nil)}, - {mapp(map[string]int{}), "", mapp(map[string]int{})}, - {mapp(map[string]int{"a": 1}), "", mapp(map[string]int{"a": 1})}, - {mapp(nil), "[P]\na = 2", mapp(map[string]int{"a": 2})}, - {mapp(map[string]int{}), "[P]\na = 2", mapp(map[string]int{"a": 2})}, - {mapp(map[string]int{"a": 1, "b": 3}), "[P]\na = 2", mapp(map[string]int{"a": 2, "b": 3})}, - - // structs - {&T{nil}, "[P]", &T{nil}}, - {&T{[]int{}}, "[P]", &T{[]int{}}}, - {&T{[]int{1, 2, 3}}, "[P]", &T{[]int{1, 2, 3}}}, - {&T{nil}, "[P]\nS = [1,2]", &T{[]int{1, 2}}}, - {&T{[]int{}}, "[P]\nS = [1,2]", &T{[]int{1, 2}}}, - {&T{[]int{1, 2, 3}}, "[P]\nS = [1,2]", &T{[]int{1, 2}}}, - } { - var s S - md, err := Decode(tt.input, &s) - if err != nil { - t.Errorf("[%d] Decode error: %s", i, err) - continue - } - if err := md.PrimitiveDecode(s.P, tt.v); err != nil { - t.Errorf("[%d] PrimitiveDecode error: %s", i, err) - continue - } - if !reflect.DeepEqual(tt.v, tt.want) { - t.Errorf("[%d] got %#v; want %#v", i, tt.v, tt.want) - } - } -} - -func TestDecodeErrors(t *testing.T) { - for _, s := range []string{ - `x="`, - `x='`, - `x='''`, - - // Cases found by fuzzing in - // https://github.com/BurntSushi/toml/issues/155. - `""�`, // used to panic with index out of range - `e="""`, // used to hang - } { - var x struct{} - _, err := Decode(s, &x) - if err == nil { - t.Errorf("Decode(%q): got nil error", s) - } - } -} - -// Test for https://github.com/BurntSushi/toml/pull/166. -func TestDecodeBoolArray(t *testing.T) { - for _, tt := range []struct { - s string - got interface{} - want interface{} - }{ - { - "a = [true, false]", - &struct{ A []bool }{}, - &struct{ A []bool }{[]bool{true, false}}, - }, - { - "a = {a = true, b = false}", - &struct{ A map[string]bool }{}, - &struct{ A map[string]bool }{map[string]bool{"a": true, "b": false}}, - }, - } { - if _, err := Decode(tt.s, tt.got); err != nil { - t.Errorf("Decode(%q): %s", tt.s, err) - continue - } - if !reflect.DeepEqual(tt.got, tt.want) { - t.Errorf("Decode(%q): got %#v; want %#v", tt.s, tt.got, tt.want) - } - } -} - -func ExampleMetaData_PrimitiveDecode() { - var md MetaData - var err error - - var tomlBlob = ` -ranking = ["Springsteen", "J Geils"] - -[bands.Springsteen] -started = 1973 -albums = ["Greetings", "WIESS", "Born to Run", "Darkness"] - -[bands."J Geils"] -started = 1970 -albums = ["The J. Geils Band", "Full House", "Blow Your Face Out"] -` - - type band struct { - Started int - Albums []string - } - type classics struct { - Ranking []string - Bands map[string]Primitive - } - - // Do the initial decode. Reflection is delayed on Primitive values. - var music classics - if md, err = Decode(tomlBlob, &music); err != nil { - log.Fatal(err) - } - - // MetaData still includes information on Primitive values. - fmt.Printf("Is `bands.Springsteen` defined? %v\n", - md.IsDefined("bands", "Springsteen")) - - // Decode primitive data into Go values. - for _, artist := range music.Ranking { - // A band is a primitive value, so we need to decode it to get a - // real `band` value. - primValue := music.Bands[artist] - - var aBand band - if err = md.PrimitiveDecode(primValue, &aBand); err != nil { - log.Fatal(err) - } - fmt.Printf("%s started in %d.\n", artist, aBand.Started) - } - // Check to see if there were any fields left undecoded. - // Note that this won't be empty before decoding the Primitive value! - fmt.Printf("Undecoded: %q\n", md.Undecoded()) - - // Output: - // Is `bands.Springsteen` defined? true - // Springsteen started in 1973. - // J Geils started in 1970. - // Undecoded: [] -} - -func ExampleDecode() { - var tomlBlob = ` -# Some comments. -[alpha] -ip = "10.0.0.1" - - [alpha.config] - Ports = [ 8001, 8002 ] - Location = "Toronto" - Created = 1987-07-05T05:45:00Z - -[beta] -ip = "10.0.0.2" - - [beta.config] - Ports = [ 9001, 9002 ] - Location = "New Jersey" - Created = 1887-01-05T05:55:00Z -` - - type serverConfig struct { - Ports []int - Location string - Created time.Time - } - - type server struct { - IP string `toml:"ip,omitempty"` - Config serverConfig `toml:"config"` - } - - type servers map[string]server - - var config servers - if _, err := Decode(tomlBlob, &config); err != nil { - log.Fatal(err) - } - - for _, name := range []string{"alpha", "beta"} { - s := config[name] - fmt.Printf("Server: %s (ip: %s) in %s created on %s\n", - name, s.IP, s.Config.Location, - s.Config.Created.Format("2006-01-02")) - fmt.Printf("Ports: %v\n", s.Config.Ports) - } - - // Output: - // Server: alpha (ip: 10.0.0.1) in Toronto created on 1987-07-05 - // Ports: [8001 8002] - // Server: beta (ip: 10.0.0.2) in New Jersey created on 1887-01-05 - // Ports: [9001 9002] -} - -type duration struct { - time.Duration -} - -func (d *duration) UnmarshalText(text []byte) error { - var err error - d.Duration, err = time.ParseDuration(string(text)) - return err -} - -// Example Unmarshaler shows how to decode TOML strings into your own -// custom data type. -func Example_unmarshaler() { - blob := ` -[[song]] -name = "Thunder Road" -duration = "4m49s" - -[[song]] -name = "Stairway to Heaven" -duration = "8m03s" -` - type song struct { - Name string - Duration duration - } - type songs struct { - Song []song - } - var favorites songs - if _, err := Decode(blob, &favorites); err != nil { - log.Fatal(err) - } - - // Code to implement the TextUnmarshaler interface for `duration`: - // - // type duration struct { - // time.Duration - // } - // - // func (d *duration) UnmarshalText(text []byte) error { - // var err error - // d.Duration, err = time.ParseDuration(string(text)) - // return err - // } - - for _, s := range favorites.Song { - fmt.Printf("%s (%s)\n", s.Name, s.Duration) - } - // Output: - // Thunder Road (4m49s) - // Stairway to Heaven (8m3s) -} - -// Example StrictDecoding shows how to detect whether there are keys in the -// TOML document that weren't decoded into the value given. This is useful -// for returning an error to the user if they've included extraneous fields -// in their configuration. -func Example_strictDecoding() { - var blob = ` -key1 = "value1" -key2 = "value2" -key3 = "value3" -` - type config struct { - Key1 string - Key3 string - } - - var conf config - md, err := Decode(blob, &conf) - if err != nil { - log.Fatal(err) - } - fmt.Printf("Undecoded keys: %q\n", md.Undecoded()) - // Output: - // Undecoded keys: ["key2"] -} - -// Example UnmarshalTOML shows how to implement a struct type that knows how to -// unmarshal itself. The struct must take full responsibility for mapping the -// values passed into the struct. The method may be used with interfaces in a -// struct in cases where the actual type is not known until the data is -// examined. -func Example_unmarshalTOML() { - - var blob = ` -[[parts]] -type = "valve" -id = "valve-1" -size = 1.2 -rating = 4 - -[[parts]] -type = "valve" -id = "valve-2" -size = 2.1 -rating = 5 - -[[parts]] -type = "pipe" -id = "pipe-1" -length = 2.1 -diameter = 12 - -[[parts]] -type = "cable" -id = "cable-1" -length = 12 -rating = 3.1 -` - o := &order{} - err := Unmarshal([]byte(blob), o) - if err != nil { - log.Fatal(err) - } - - fmt.Println(len(o.parts)) - - for _, part := range o.parts { - fmt.Println(part.Name()) - } - - // Code to implement UmarshalJSON. - - // type order struct { - // // NOTE `order.parts` is a private slice of type `part` which is an - // // interface and may only be loaded from toml using the - // // UnmarshalTOML() method of the Umarshaler interface. - // parts parts - // } - - // func (o *order) UnmarshalTOML(data interface{}) error { - - // // NOTE the example below contains detailed type casting to show how - // // the 'data' is retrieved. In operational use, a type cast wrapper - // // may be preferred e.g. - // // - // // func AsMap(v interface{}) (map[string]interface{}, error) { - // // return v.(map[string]interface{}) - // // } - // // - // // resulting in: - // // d, _ := AsMap(data) - // // - - // d, _ := data.(map[string]interface{}) - // parts, _ := d["parts"].([]map[string]interface{}) - - // for _, p := range parts { - - // typ, _ := p["type"].(string) - // id, _ := p["id"].(string) - - // // detect the type of part and handle each case - // switch p["type"] { - // case "valve": - - // size := float32(p["size"].(float64)) - // rating := int(p["rating"].(int64)) - - // valve := &valve{ - // Type: typ, - // ID: id, - // Size: size, - // Rating: rating, - // } - - // o.parts = append(o.parts, valve) - - // case "pipe": - - // length := float32(p["length"].(float64)) - // diameter := int(p["diameter"].(int64)) - - // pipe := &pipe{ - // Type: typ, - // ID: id, - // Length: length, - // Diameter: diameter, - // } - - // o.parts = append(o.parts, pipe) - - // case "cable": - - // length := int(p["length"].(int64)) - // rating := float32(p["rating"].(float64)) - - // cable := &cable{ - // Type: typ, - // ID: id, - // Length: length, - // Rating: rating, - // } - - // o.parts = append(o.parts, cable) - - // } - // } - - // return nil - // } - - // type parts []part - - // type part interface { - // Name() string - // } - - // type valve struct { - // Type string - // ID string - // Size float32 - // Rating int - // } - - // func (v *valve) Name() string { - // return fmt.Sprintf("VALVE: %s", v.ID) - // } - - // type pipe struct { - // Type string - // ID string - // Length float32 - // Diameter int - // } - - // func (p *pipe) Name() string { - // return fmt.Sprintf("PIPE: %s", p.ID) - // } - - // type cable struct { - // Type string - // ID string - // Length int - // Rating float32 - // } - - // func (c *cable) Name() string { - // return fmt.Sprintf("CABLE: %s", c.ID) - // } - - // Output: - // 4 - // VALVE: valve-1 - // VALVE: valve-2 - // PIPE: pipe-1 - // CABLE: cable-1 - -} - -type order struct { - // NOTE `order.parts` is a private slice of type `part` which is an - // interface and may only be loaded from toml using the UnmarshalTOML() - // method of the Umarshaler interface. - parts parts -} - -func (o *order) UnmarshalTOML(data interface{}) error { - - // NOTE the example below contains detailed type casting to show how - // the 'data' is retrieved. In operational use, a type cast wrapper - // may be preferred e.g. - // - // func AsMap(v interface{}) (map[string]interface{}, error) { - // return v.(map[string]interface{}) - // } - // - // resulting in: - // d, _ := AsMap(data) - // - - d, _ := data.(map[string]interface{}) - parts, _ := d["parts"].([]map[string]interface{}) - - for _, p := range parts { - - typ, _ := p["type"].(string) - id, _ := p["id"].(string) - - // detect the type of part and handle each case - switch p["type"] { - case "valve": - - size := float32(p["size"].(float64)) - rating := int(p["rating"].(int64)) - - valve := &valve{ - Type: typ, - ID: id, - Size: size, - Rating: rating, - } - - o.parts = append(o.parts, valve) - - case "pipe": - - length := float32(p["length"].(float64)) - diameter := int(p["diameter"].(int64)) - - pipe := &pipe{ - Type: typ, - ID: id, - Length: length, - Diameter: diameter, - } - - o.parts = append(o.parts, pipe) - - case "cable": - - length := int(p["length"].(int64)) - rating := float32(p["rating"].(float64)) - - cable := &cable{ - Type: typ, - ID: id, - Length: length, - Rating: rating, - } - - o.parts = append(o.parts, cable) - - } - } - - return nil -} - -type parts []part - -type part interface { - Name() string -} - -type valve struct { - Type string - ID string - Size float32 - Rating int -} - -func (v *valve) Name() string { - return fmt.Sprintf("VALVE: %s", v.ID) -} - -type pipe struct { - Type string - ID string - Length float32 - Diameter int -} - -func (p *pipe) Name() string { - return fmt.Sprintf("PIPE: %s", p.ID) -} - -type cable struct { - Type string - ID string - Length int - Rating float32 -} - -func (c *cable) Name() string { - return fmt.Sprintf("CABLE: %s", c.ID) -} diff --git a/vendor/github.com/BurntSushi/toml/encode_test.go b/vendor/github.com/BurntSushi/toml/encode_test.go deleted file mode 100644 index 673b7b00..00000000 --- a/vendor/github.com/BurntSushi/toml/encode_test.go +++ /dev/null @@ -1,615 +0,0 @@ -package toml - -import ( - "bytes" - "fmt" - "log" - "net" - "testing" - "time" -) - -func TestEncodeRoundTrip(t *testing.T) { - type Config struct { - Age int - Cats []string - Pi float64 - Perfection []int - DOB time.Time - Ipaddress net.IP - } - - var inputs = Config{ - 13, - []string{"one", "two", "three"}, - 3.145, - []int{11, 2, 3, 4}, - time.Now(), - net.ParseIP("192.168.59.254"), - } - - var firstBuffer bytes.Buffer - e := NewEncoder(&firstBuffer) - err := e.Encode(inputs) - if err != nil { - t.Fatal(err) - } - var outputs Config - if _, err := Decode(firstBuffer.String(), &outputs); err != nil { - t.Logf("Could not decode:\n-----\n%s\n-----\n", - firstBuffer.String()) - t.Fatal(err) - } - - // could test each value individually, but I'm lazy - var secondBuffer bytes.Buffer - e2 := NewEncoder(&secondBuffer) - err = e2.Encode(outputs) - if err != nil { - t.Fatal(err) - } - if firstBuffer.String() != secondBuffer.String() { - t.Error( - firstBuffer.String(), - "\n\n is not identical to\n\n", - secondBuffer.String()) - } -} - -// XXX(burntsushi) -// I think these tests probably should be removed. They are good, but they -// ought to be obsolete by toml-test. -func TestEncode(t *testing.T) { - type Embedded struct { - Int int `toml:"_int"` - } - type NonStruct int - - date := time.Date(2014, 5, 11, 20, 30, 40, 0, time.FixedZone("IST", 3600)) - dateStr := "2014-05-11T19:30:40Z" - - tests := map[string]struct { - input interface{} - wantOutput string - wantError error - }{ - "bool field": { - input: struct { - BoolTrue bool - BoolFalse bool - }{true, false}, - wantOutput: "BoolTrue = true\nBoolFalse = false\n", - }, - "int fields": { - input: struct { - Int int - Int8 int8 - Int16 int16 - Int32 int32 - Int64 int64 - }{1, 2, 3, 4, 5}, - wantOutput: "Int = 1\nInt8 = 2\nInt16 = 3\nInt32 = 4\nInt64 = 5\n", - }, - "uint fields": { - input: struct { - Uint uint - Uint8 uint8 - Uint16 uint16 - Uint32 uint32 - Uint64 uint64 - }{1, 2, 3, 4, 5}, - wantOutput: "Uint = 1\nUint8 = 2\nUint16 = 3\nUint32 = 4" + - "\nUint64 = 5\n", - }, - "float fields": { - input: struct { - Float32 float32 - Float64 float64 - }{1.5, 2.5}, - wantOutput: "Float32 = 1.5\nFloat64 = 2.5\n", - }, - "string field": { - input: struct{ String string }{"foo"}, - wantOutput: "String = \"foo\"\n", - }, - "string field and unexported field": { - input: struct { - String string - unexported int - }{"foo", 0}, - wantOutput: "String = \"foo\"\n", - }, - "datetime field in UTC": { - input: struct{ Date time.Time }{date}, - wantOutput: fmt.Sprintf("Date = %s\n", dateStr), - }, - "datetime field as primitive": { - // Using a map here to fail if isStructOrMap() returns true for - // time.Time. - input: map[string]interface{}{ - "Date": date, - "Int": 1, - }, - wantOutput: fmt.Sprintf("Date = %s\nInt = 1\n", dateStr), - }, - "array fields": { - input: struct { - IntArray0 [0]int - IntArray3 [3]int - }{[0]int{}, [3]int{1, 2, 3}}, - wantOutput: "IntArray0 = []\nIntArray3 = [1, 2, 3]\n", - }, - "slice fields": { - input: struct{ IntSliceNil, IntSlice0, IntSlice3 []int }{ - nil, []int{}, []int{1, 2, 3}, - }, - wantOutput: "IntSlice0 = []\nIntSlice3 = [1, 2, 3]\n", - }, - "datetime slices": { - input: struct{ DatetimeSlice []time.Time }{ - []time.Time{date, date}, - }, - wantOutput: fmt.Sprintf("DatetimeSlice = [%s, %s]\n", - dateStr, dateStr), - }, - "nested arrays and slices": { - input: struct { - SliceOfArrays [][2]int - ArrayOfSlices [2][]int - SliceOfArraysOfSlices [][2][]int - ArrayOfSlicesOfArrays [2][][2]int - SliceOfMixedArrays [][2]interface{} - ArrayOfMixedSlices [2][]interface{} - }{ - [][2]int{{1, 2}, {3, 4}}, - [2][]int{{1, 2}, {3, 4}}, - [][2][]int{ - { - {1, 2}, {3, 4}, - }, - { - {5, 6}, {7, 8}, - }, - }, - [2][][2]int{ - { - {1, 2}, {3, 4}, - }, - { - {5, 6}, {7, 8}, - }, - }, - [][2]interface{}{ - {1, 2}, {"a", "b"}, - }, - [2][]interface{}{ - {1, 2}, {"a", "b"}, - }, - }, - wantOutput: `SliceOfArrays = [[1, 2], [3, 4]] -ArrayOfSlices = [[1, 2], [3, 4]] -SliceOfArraysOfSlices = [[[1, 2], [3, 4]], [[5, 6], [7, 8]]] -ArrayOfSlicesOfArrays = [[[1, 2], [3, 4]], [[5, 6], [7, 8]]] -SliceOfMixedArrays = [[1, 2], ["a", "b"]] -ArrayOfMixedSlices = [[1, 2], ["a", "b"]] -`, - }, - "empty slice": { - input: struct{ Empty []interface{} }{[]interface{}{}}, - wantOutput: "Empty = []\n", - }, - "(error) slice with element type mismatch (string and integer)": { - input: struct{ Mixed []interface{} }{[]interface{}{1, "a"}}, - wantError: errArrayMixedElementTypes, - }, - "(error) slice with element type mismatch (integer and float)": { - input: struct{ Mixed []interface{} }{[]interface{}{1, 2.5}}, - wantError: errArrayMixedElementTypes, - }, - "slice with elems of differing Go types, same TOML types": { - input: struct { - MixedInts []interface{} - MixedFloats []interface{} - }{ - []interface{}{ - int(1), int8(2), int16(3), int32(4), int64(5), - uint(1), uint8(2), uint16(3), uint32(4), uint64(5), - }, - []interface{}{float32(1.5), float64(2.5)}, - }, - wantOutput: "MixedInts = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5]\n" + - "MixedFloats = [1.5, 2.5]\n", - }, - "(error) slice w/ element type mismatch (one is nested array)": { - input: struct{ Mixed []interface{} }{ - []interface{}{1, []interface{}{2}}, - }, - wantError: errArrayMixedElementTypes, - }, - "(error) slice with 1 nil element": { - input: struct{ NilElement1 []interface{} }{[]interface{}{nil}}, - wantError: errArrayNilElement, - }, - "(error) slice with 1 nil element (and other non-nil elements)": { - input: struct{ NilElement []interface{} }{ - []interface{}{1, nil}, - }, - wantError: errArrayNilElement, - }, - "simple map": { - input: map[string]int{"a": 1, "b": 2}, - wantOutput: "a = 1\nb = 2\n", - }, - "map with interface{} value type": { - input: map[string]interface{}{"a": 1, "b": "c"}, - wantOutput: "a = 1\nb = \"c\"\n", - }, - "map with interface{} value type, some of which are structs": { - input: map[string]interface{}{ - "a": struct{ Int int }{2}, - "b": 1, - }, - wantOutput: "b = 1\n\n[a]\n Int = 2\n", - }, - "nested map": { - input: map[string]map[string]int{ - "a": {"b": 1}, - "c": {"d": 2}, - }, - wantOutput: "[a]\n b = 1\n\n[c]\n d = 2\n", - }, - "nested struct": { - input: struct{ Struct struct{ Int int } }{ - struct{ Int int }{1}, - }, - wantOutput: "[Struct]\n Int = 1\n", - }, - "nested struct and non-struct field": { - input: struct { - Struct struct{ Int int } - Bool bool - }{struct{ Int int }{1}, true}, - wantOutput: "Bool = true\n\n[Struct]\n Int = 1\n", - }, - "2 nested structs": { - input: struct{ Struct1, Struct2 struct{ Int int } }{ - struct{ Int int }{1}, struct{ Int int }{2}, - }, - wantOutput: "[Struct1]\n Int = 1\n\n[Struct2]\n Int = 2\n", - }, - "deeply nested structs": { - input: struct { - Struct1, Struct2 struct{ Struct3 *struct{ Int int } } - }{ - struct{ Struct3 *struct{ Int int } }{&struct{ Int int }{1}}, - struct{ Struct3 *struct{ Int int } }{nil}, - }, - wantOutput: "[Struct1]\n [Struct1.Struct3]\n Int = 1" + - "\n\n[Struct2]\n", - }, - "nested struct with nil struct elem": { - input: struct { - Struct struct{ Inner *struct{ Int int } } - }{ - struct{ Inner *struct{ Int int } }{nil}, - }, - wantOutput: "[Struct]\n", - }, - "nested struct with no fields": { - input: struct { - Struct struct{ Inner struct{} } - }{ - struct{ Inner struct{} }{struct{}{}}, - }, - wantOutput: "[Struct]\n [Struct.Inner]\n", - }, - "struct with tags": { - input: struct { - Struct struct { - Int int `toml:"_int"` - } `toml:"_struct"` - Bool bool `toml:"_bool"` - }{ - struct { - Int int `toml:"_int"` - }{1}, true, - }, - wantOutput: "_bool = true\n\n[_struct]\n _int = 1\n", - }, - "embedded struct": { - input: struct{ Embedded }{Embedded{1}}, - wantOutput: "_int = 1\n", - }, - "embedded *struct": { - input: struct{ *Embedded }{&Embedded{1}}, - wantOutput: "_int = 1\n", - }, - "nested embedded struct": { - input: struct { - Struct struct{ Embedded } `toml:"_struct"` - }{struct{ Embedded }{Embedded{1}}}, - wantOutput: "[_struct]\n _int = 1\n", - }, - "nested embedded *struct": { - input: struct { - Struct struct{ *Embedded } `toml:"_struct"` - }{struct{ *Embedded }{&Embedded{1}}}, - wantOutput: "[_struct]\n _int = 1\n", - }, - "embedded non-struct": { - input: struct{ NonStruct }{5}, - wantOutput: "NonStruct = 5\n", - }, - "array of tables": { - input: struct { - Structs []*struct{ Int int } `toml:"struct"` - }{ - []*struct{ Int int }{{1}, {3}}, - }, - wantOutput: "[[struct]]\n Int = 1\n\n[[struct]]\n Int = 3\n", - }, - "array of tables order": { - input: map[string]interface{}{ - "map": map[string]interface{}{ - "zero": 5, - "arr": []map[string]int{ - { - "friend": 5, - }, - }, - }, - }, - wantOutput: "[map]\n zero = 5\n\n [[map.arr]]\n friend = 5\n", - }, - "(error) top-level slice": { - input: []struct{ Int int }{{1}, {2}, {3}}, - wantError: errNoKey, - }, - "(error) slice of slice": { - input: struct { - Slices [][]struct{ Int int } - }{ - [][]struct{ Int int }{{{1}}, {{2}}, {{3}}}, - }, - wantError: errArrayNoTable, - }, - "(error) map no string key": { - input: map[int]string{1: ""}, - wantError: errNonString, - }, - "(error) empty key name": { - input: map[string]int{"": 1}, - wantError: errAnything, - }, - "(error) empty map name": { - input: map[string]interface{}{ - "": map[string]int{"v": 1}, - }, - wantError: errAnything, - }, - } - for label, test := range tests { - encodeExpected(t, label, test.input, test.wantOutput, test.wantError) - } -} - -func TestEncodeNestedTableArrays(t *testing.T) { - type song struct { - Name string `toml:"name"` - } - type album struct { - Name string `toml:"name"` - Songs []song `toml:"songs"` - } - type springsteen struct { - Albums []album `toml:"albums"` - } - value := springsteen{ - []album{ - {"Born to Run", - []song{{"Jungleland"}, {"Meeting Across the River"}}}, - {"Born in the USA", - []song{{"Glory Days"}, {"Dancing in the Dark"}}}, - }, - } - expected := `[[albums]] - name = "Born to Run" - - [[albums.songs]] - name = "Jungleland" - - [[albums.songs]] - name = "Meeting Across the River" - -[[albums]] - name = "Born in the USA" - - [[albums.songs]] - name = "Glory Days" - - [[albums.songs]] - name = "Dancing in the Dark" -` - encodeExpected(t, "nested table arrays", value, expected, nil) -} - -func TestEncodeArrayHashWithNormalHashOrder(t *testing.T) { - type Alpha struct { - V int - } - type Beta struct { - V int - } - type Conf struct { - V int - A Alpha - B []Beta - } - - val := Conf{ - V: 1, - A: Alpha{2}, - B: []Beta{{3}}, - } - expected := "V = 1\n\n[A]\n V = 2\n\n[[B]]\n V = 3\n" - encodeExpected(t, "array hash with normal hash order", val, expected, nil) -} - -func TestEncodeWithOmitEmpty(t *testing.T) { - type simple struct { - Bool bool `toml:"bool,omitempty"` - String string `toml:"string,omitempty"` - Array [0]byte `toml:"array,omitempty"` - Slice []int `toml:"slice,omitempty"` - Map map[string]string `toml:"map,omitempty"` - } - - var v simple - encodeExpected(t, "fields with omitempty are omitted when empty", v, "", nil) - v = simple{ - Bool: true, - String: " ", - Slice: []int{2, 3, 4}, - Map: map[string]string{"foo": "bar"}, - } - expected := `bool = true -string = " " -slice = [2, 3, 4] - -[map] - foo = "bar" -` - encodeExpected(t, "fields with omitempty are not omitted when non-empty", - v, expected, nil) -} - -func TestEncodeWithOmitZero(t *testing.T) { - type simple struct { - Number int `toml:"number,omitzero"` - Real float64 `toml:"real,omitzero"` - Unsigned uint `toml:"unsigned,omitzero"` - } - - value := simple{0, 0.0, uint(0)} - expected := "" - - encodeExpected(t, "simple with omitzero, all zero", value, expected, nil) - - value.Number = 10 - value.Real = 20 - value.Unsigned = 5 - expected = `number = 10 -real = 20.0 -unsigned = 5 -` - encodeExpected(t, "simple with omitzero, non-zero", value, expected, nil) -} - -func TestEncodeOmitemptyWithEmptyName(t *testing.T) { - type simple struct { - S []int `toml:",omitempty"` - } - v := simple{[]int{1, 2, 3}} - expected := "S = [1, 2, 3]\n" - encodeExpected(t, "simple with omitempty, no name, non-empty field", - v, expected, nil) -} - -func TestEncodeAnonymousStruct(t *testing.T) { - type Inner struct{ N int } - type Outer0 struct{ Inner } - type Outer1 struct { - Inner `toml:"inner"` - } - - v0 := Outer0{Inner{3}} - expected := "N = 3\n" - encodeExpected(t, "embedded anonymous untagged struct", v0, expected, nil) - - v1 := Outer1{Inner{3}} - expected = "[inner]\n N = 3\n" - encodeExpected(t, "embedded anonymous tagged struct", v1, expected, nil) -} - -func TestEncodeAnonymousStructPointerField(t *testing.T) { - type Inner struct{ N int } - type Outer0 struct{ *Inner } - type Outer1 struct { - *Inner `toml:"inner"` - } - - v0 := Outer0{} - expected := "" - encodeExpected(t, "nil anonymous untagged struct pointer field", v0, expected, nil) - - v0 = Outer0{&Inner{3}} - expected = "N = 3\n" - encodeExpected(t, "non-nil anonymous untagged struct pointer field", v0, expected, nil) - - v1 := Outer1{} - expected = "" - encodeExpected(t, "nil anonymous tagged struct pointer field", v1, expected, nil) - - v1 = Outer1{&Inner{3}} - expected = "[inner]\n N = 3\n" - encodeExpected(t, "non-nil anonymous tagged struct pointer field", v1, expected, nil) -} - -func TestEncodeIgnoredFields(t *testing.T) { - type simple struct { - Number int `toml:"-"` - } - value := simple{} - expected := "" - encodeExpected(t, "ignored field", value, expected, nil) -} - -func encodeExpected( - t *testing.T, label string, val interface{}, wantStr string, wantErr error, -) { - var buf bytes.Buffer - enc := NewEncoder(&buf) - err := enc.Encode(val) - if err != wantErr { - if wantErr != nil { - if wantErr == errAnything && err != nil { - return - } - t.Errorf("%s: want Encode error %v, got %v", label, wantErr, err) - } else { - t.Errorf("%s: Encode failed: %s", label, err) - } - } - if err != nil { - return - } - if got := buf.String(); wantStr != got { - t.Errorf("%s: want\n-----\n%q\n-----\nbut got\n-----\n%q\n-----\n", - label, wantStr, got) - } -} - -func ExampleEncoder_Encode() { - date, _ := time.Parse(time.RFC822, "14 Mar 10 18:00 UTC") - var config = map[string]interface{}{ - "date": date, - "counts": []int{1, 1, 2, 3, 5, 8}, - "hash": map[string]string{ - "key1": "val1", - "key2": "val2", - }, - } - buf := new(bytes.Buffer) - if err := NewEncoder(buf).Encode(config); err != nil { - log.Fatal(err) - } - fmt.Println(buf.String()) - - // Output: - // counts = [1, 1, 2, 3, 5, 8] - // date = 2010-03-14T18:00:00Z - // - // [hash] - // key1 = "val1" - // key2 = "val2" -} diff --git a/vendor/github.com/beorn7/perks/.gitignore b/vendor/github.com/beorn7/perks/.gitignore deleted file mode 100644 index 1bd9209a..00000000 --- a/vendor/github.com/beorn7/perks/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -*.test -*.prof diff --git a/vendor/github.com/beorn7/perks/README.md b/vendor/github.com/beorn7/perks/README.md deleted file mode 100644 index fc057777..00000000 --- a/vendor/github.com/beorn7/perks/README.md +++ /dev/null @@ -1,31 +0,0 @@ -# Perks for Go (golang.org) - -Perks contains the Go package quantile that computes approximate quantiles over -an unbounded data stream within low memory and CPU bounds. - -For more information and examples, see: -http://godoc.org/github.com/bmizerany/perks - -A very special thank you and shout out to Graham Cormode (Rutgers University), -Flip Korn (AT&T Labs–Research), S. Muthukrishnan (Rutgers University), and -Divesh Srivastava (AT&T Labs–Research) for their research and publication of -[Effective Computation of Biased Quantiles over Data Streams](http://www.cs.rutgers.edu/~muthu/bquant.pdf) - -Thank you, also: -* Armon Dadgar (@armon) -* Andrew Gerrand (@nf) -* Brad Fitzpatrick (@bradfitz) -* Keith Rarick (@kr) - -FAQ: - -Q: Why not move the quantile package into the project root? -A: I want to add more packages to perks later. - -Copyright (C) 2013 Blake Mizerany - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/vendor/github.com/beorn7/perks/histogram/bench_test.go b/vendor/github.com/beorn7/perks/histogram/bench_test.go deleted file mode 100644 index 56c7e551..00000000 --- a/vendor/github.com/beorn7/perks/histogram/bench_test.go +++ /dev/null @@ -1,26 +0,0 @@ -package histogram - -import ( - "math/rand" - "testing" -) - -func BenchmarkInsert10Bins(b *testing.B) { - b.StopTimer() - h := New(10) - b.StartTimer() - for i := 0; i < b.N; i++ { - f := rand.ExpFloat64() - h.Insert(f) - } -} - -func BenchmarkInsert100Bins(b *testing.B) { - b.StopTimer() - h := New(100) - b.StartTimer() - for i := 0; i < b.N; i++ { - f := rand.ExpFloat64() - h.Insert(f) - } -} diff --git a/vendor/github.com/beorn7/perks/histogram/histogram.go b/vendor/github.com/beorn7/perks/histogram/histogram.go deleted file mode 100644 index bef05c70..00000000 --- a/vendor/github.com/beorn7/perks/histogram/histogram.go +++ /dev/null @@ -1,108 +0,0 @@ -// Package histogram provides a Go implementation of BigML's histogram package -// for Clojure/Java. It is currently experimental. -package histogram - -import ( - "container/heap" - "math" - "sort" -) - -type Bin struct { - Count int - Sum float64 -} - -func (b *Bin) Update(x *Bin) { - b.Count += x.Count - b.Sum += x.Sum -} - -func (b *Bin) Mean() float64 { - return b.Sum / float64(b.Count) -} - -type Bins []*Bin - -func (bs Bins) Len() int { return len(bs) } -func (bs Bins) Less(i, j int) bool { return bs[i].Mean() < bs[j].Mean() } -func (bs Bins) Swap(i, j int) { bs[i], bs[j] = bs[j], bs[i] } - -func (bs *Bins) Push(x interface{}) { - *bs = append(*bs, x.(*Bin)) -} - -func (bs *Bins) Pop() interface{} { - return bs.remove(len(*bs) - 1) -} - -func (bs *Bins) remove(n int) *Bin { - if n < 0 || len(*bs) < n { - return nil - } - x := (*bs)[n] - *bs = append((*bs)[:n], (*bs)[n+1:]...) - return x -} - -type Histogram struct { - res *reservoir -} - -func New(maxBins int) *Histogram { - return &Histogram{res: newReservoir(maxBins)} -} - -func (h *Histogram) Insert(f float64) { - h.res.insert(&Bin{1, f}) - h.res.compress() -} - -func (h *Histogram) Bins() Bins { - return h.res.bins -} - -type reservoir struct { - n int - maxBins int - bins Bins -} - -func newReservoir(maxBins int) *reservoir { - return &reservoir{maxBins: maxBins} -} - -func (r *reservoir) insert(bin *Bin) { - r.n += bin.Count - i := sort.Search(len(r.bins), func(i int) bool { - return r.bins[i].Mean() >= bin.Mean() - }) - if i < 0 || i == r.bins.Len() { - // TODO(blake): Maybe use an .insert(i, bin) instead of - // performing the extra work of a heap.Push. - heap.Push(&r.bins, bin) - return - } - r.bins[i].Update(bin) -} - -func (r *reservoir) compress() { - for r.bins.Len() > r.maxBins { - minGapIndex := -1 - minGap := math.MaxFloat64 - for i := 0; i < r.bins.Len()-1; i++ { - gap := gapWeight(r.bins[i], r.bins[i+1]) - if minGap > gap { - minGap = gap - minGapIndex = i - } - } - prev := r.bins[minGapIndex] - next := r.bins.remove(minGapIndex + 1) - prev.Update(next) - } -} - -func gapWeight(prev, next *Bin) float64 { - return next.Mean() - prev.Mean() -} diff --git a/vendor/github.com/beorn7/perks/histogram/histogram_test.go b/vendor/github.com/beorn7/perks/histogram/histogram_test.go deleted file mode 100644 index 0575ebee..00000000 --- a/vendor/github.com/beorn7/perks/histogram/histogram_test.go +++ /dev/null @@ -1,38 +0,0 @@ -package histogram - -import ( - "math/rand" - "testing" -) - -func TestHistogram(t *testing.T) { - const numPoints = 1e6 - const maxBins = 3 - - h := New(maxBins) - for i := 0; i < numPoints; i++ { - f := rand.ExpFloat64() - h.Insert(f) - } - - bins := h.Bins() - if g := len(bins); g > maxBins { - t.Fatalf("got %d bins, wanted <= %d", g, maxBins) - } - - for _, b := range bins { - t.Logf("%+v", b) - } - - if g := count(h.Bins()); g != numPoints { - t.Fatalf("binned %d points, wanted %d", g, numPoints) - } -} - -func count(bins Bins) int { - binCounts := 0 - for _, b := range bins { - binCounts += b.Count - } - return binCounts -} diff --git a/vendor/github.com/beorn7/perks/quantile/bench_test.go b/vendor/github.com/beorn7/perks/quantile/bench_test.go deleted file mode 100644 index 0bd0e4e7..00000000 --- a/vendor/github.com/beorn7/perks/quantile/bench_test.go +++ /dev/null @@ -1,63 +0,0 @@ -package quantile - -import ( - "testing" -) - -func BenchmarkInsertTargeted(b *testing.B) { - b.ReportAllocs() - - s := NewTargeted(Targets) - b.ResetTimer() - for i := float64(0); i < float64(b.N); i++ { - s.Insert(i) - } -} - -func BenchmarkInsertTargetedSmallEpsilon(b *testing.B) { - s := NewTargeted(TargetsSmallEpsilon) - b.ResetTimer() - for i := float64(0); i < float64(b.N); i++ { - s.Insert(i) - } -} - -func BenchmarkInsertBiased(b *testing.B) { - s := NewLowBiased(0.01) - b.ResetTimer() - for i := float64(0); i < float64(b.N); i++ { - s.Insert(i) - } -} - -func BenchmarkInsertBiasedSmallEpsilon(b *testing.B) { - s := NewLowBiased(0.0001) - b.ResetTimer() - for i := float64(0); i < float64(b.N); i++ { - s.Insert(i) - } -} - -func BenchmarkQuery(b *testing.B) { - s := NewTargeted(Targets) - for i := float64(0); i < 1e6; i++ { - s.Insert(i) - } - b.ResetTimer() - n := float64(b.N) - for i := float64(0); i < n; i++ { - s.Query(i / n) - } -} - -func BenchmarkQuerySmallEpsilon(b *testing.B) { - s := NewTargeted(TargetsSmallEpsilon) - for i := float64(0); i < 1e6; i++ { - s.Insert(i) - } - b.ResetTimer() - n := float64(b.N) - for i := float64(0); i < n; i++ { - s.Query(i / n) - } -} diff --git a/vendor/github.com/beorn7/perks/quantile/example_test.go b/vendor/github.com/beorn7/perks/quantile/example_test.go deleted file mode 100644 index ab3293aa..00000000 --- a/vendor/github.com/beorn7/perks/quantile/example_test.go +++ /dev/null @@ -1,121 +0,0 @@ -// +build go1.1 - -package quantile_test - -import ( - "bufio" - "fmt" - "log" - "os" - "strconv" - "time" - - "github.com/beorn7/perks/quantile" -) - -func Example_simple() { - ch := make(chan float64) - go sendFloats(ch) - - // Compute the 50th, 90th, and 99th percentile. - q := quantile.NewTargeted(map[float64]float64{ - 0.50: 0.005, - 0.90: 0.001, - 0.99: 0.0001, - }) - for v := range ch { - q.Insert(v) - } - - fmt.Println("perc50:", q.Query(0.50)) - fmt.Println("perc90:", q.Query(0.90)) - fmt.Println("perc99:", q.Query(0.99)) - fmt.Println("count:", q.Count()) - // Output: - // perc50: 5 - // perc90: 16 - // perc99: 223 - // count: 2388 -} - -func Example_mergeMultipleStreams() { - // Scenario: - // We have multiple database shards. On each shard, there is a process - // collecting query response times from the database logs and inserting - // them into a Stream (created via NewTargeted(0.90)), much like the - // Simple example. These processes expose a network interface for us to - // ask them to serialize and send us the results of their - // Stream.Samples so we may Merge and Query them. - // - // NOTES: - // * These sample sets are small, allowing us to get them - // across the network much faster than sending the entire list of data - // points. - // - // * For this to work correctly, we must supply the same quantiles - // a priori the process collecting the samples supplied to NewTargeted, - // even if we do not plan to query them all here. - ch := make(chan quantile.Samples) - getDBQuerySamples(ch) - q := quantile.NewTargeted(map[float64]float64{0.90: 0.001}) - for samples := range ch { - q.Merge(samples) - } - fmt.Println("perc90:", q.Query(0.90)) -} - -func Example_window() { - // Scenario: We want the 90th, 95th, and 99th percentiles for each - // minute. - - ch := make(chan float64) - go sendStreamValues(ch) - - tick := time.NewTicker(1 * time.Minute) - q := quantile.NewTargeted(map[float64]float64{ - 0.90: 0.001, - 0.95: 0.0005, - 0.99: 0.0001, - }) - for { - select { - case t := <-tick.C: - flushToDB(t, q.Samples()) - q.Reset() - case v := <-ch: - q.Insert(v) - } - } -} - -func sendStreamValues(ch chan float64) { - // Use your imagination -} - -func flushToDB(t time.Time, samples quantile.Samples) { - // Use your imagination -} - -// This is a stub for the above example. In reality this would hit the remote -// servers via http or something like it. -func getDBQuerySamples(ch chan quantile.Samples) {} - -func sendFloats(ch chan<- float64) { - f, err := os.Open("exampledata.txt") - if err != nil { - log.Fatal(err) - } - sc := bufio.NewScanner(f) - for sc.Scan() { - b := sc.Bytes() - v, err := strconv.ParseFloat(string(b), 64) - if err != nil { - log.Fatal(err) - } - ch <- v - } - if sc.Err() != nil { - log.Fatal(sc.Err()) - } - close(ch) -} diff --git a/vendor/github.com/beorn7/perks/quantile/stream_test.go b/vendor/github.com/beorn7/perks/quantile/stream_test.go deleted file mode 100644 index 85519509..00000000 --- a/vendor/github.com/beorn7/perks/quantile/stream_test.go +++ /dev/null @@ -1,215 +0,0 @@ -package quantile - -import ( - "math" - "math/rand" - "sort" - "testing" -) - -var ( - Targets = map[float64]float64{ - 0.01: 0.001, - 0.10: 0.01, - 0.50: 0.05, - 0.90: 0.01, - 0.99: 0.001, - } - TargetsSmallEpsilon = map[float64]float64{ - 0.01: 0.0001, - 0.10: 0.001, - 0.50: 0.005, - 0.90: 0.001, - 0.99: 0.0001, - } - LowQuantiles = []float64{0.01, 0.1, 0.5} - HighQuantiles = []float64{0.99, 0.9, 0.5} -) - -const RelativeEpsilon = 0.01 - -func verifyPercsWithAbsoluteEpsilon(t *testing.T, a []float64, s *Stream) { - sort.Float64s(a) - for quantile, epsilon := range Targets { - n := float64(len(a)) - k := int(quantile * n) - if k < 1 { - k = 1 - } - lower := int((quantile - epsilon) * n) - if lower < 1 { - lower = 1 - } - upper := int(math.Ceil((quantile + epsilon) * n)) - if upper > len(a) { - upper = len(a) - } - w, min, max := a[k-1], a[lower-1], a[upper-1] - if g := s.Query(quantile); g < min || g > max { - t.Errorf("q=%f: want %v [%f,%f], got %v", quantile, w, min, max, g) - } - } -} - -func verifyLowPercsWithRelativeEpsilon(t *testing.T, a []float64, s *Stream) { - sort.Float64s(a) - for _, qu := range LowQuantiles { - n := float64(len(a)) - k := int(qu * n) - - lowerRank := int((1 - RelativeEpsilon) * qu * n) - upperRank := int(math.Ceil((1 + RelativeEpsilon) * qu * n)) - w, min, max := a[k-1], a[lowerRank-1], a[upperRank-1] - if g := s.Query(qu); g < min || g > max { - t.Errorf("q=%f: want %v [%f,%f], got %v", qu, w, min, max, g) - } - } -} - -func verifyHighPercsWithRelativeEpsilon(t *testing.T, a []float64, s *Stream) { - sort.Float64s(a) - for _, qu := range HighQuantiles { - n := float64(len(a)) - k := int(qu * n) - - lowerRank := int((1 - (1+RelativeEpsilon)*(1-qu)) * n) - upperRank := int(math.Ceil((1 - (1-RelativeEpsilon)*(1-qu)) * n)) - w, min, max := a[k-1], a[lowerRank-1], a[upperRank-1] - if g := s.Query(qu); g < min || g > max { - t.Errorf("q=%f: want %v [%f,%f], got %v", qu, w, min, max, g) - } - } -} - -func populateStream(s *Stream) []float64 { - a := make([]float64, 0, 1e5+100) - for i := 0; i < cap(a); i++ { - v := rand.NormFloat64() - // Add 5% asymmetric outliers. - if i%20 == 0 { - v = v*v + 1 - } - s.Insert(v) - a = append(a, v) - } - return a -} - -func TestTargetedQuery(t *testing.T) { - rand.Seed(42) - s := NewTargeted(Targets) - a := populateStream(s) - verifyPercsWithAbsoluteEpsilon(t, a, s) -} - -func TestTargetedQuerySmallSampleSize(t *testing.T) { - rand.Seed(42) - s := NewTargeted(TargetsSmallEpsilon) - a := []float64{1, 2, 3, 4, 5} - for _, v := range a { - s.Insert(v) - } - verifyPercsWithAbsoluteEpsilon(t, a, s) - // If not yet flushed, results should be precise: - if !s.flushed() { - for φ, want := range map[float64]float64{ - 0.01: 1, - 0.10: 1, - 0.50: 3, - 0.90: 5, - 0.99: 5, - } { - if got := s.Query(φ); got != want { - t.Errorf("want %f for φ=%f, got %f", want, φ, got) - } - } - } -} - -func TestLowBiasedQuery(t *testing.T) { - rand.Seed(42) - s := NewLowBiased(RelativeEpsilon) - a := populateStream(s) - verifyLowPercsWithRelativeEpsilon(t, a, s) -} - -func TestHighBiasedQuery(t *testing.T) { - rand.Seed(42) - s := NewHighBiased(RelativeEpsilon) - a := populateStream(s) - verifyHighPercsWithRelativeEpsilon(t, a, s) -} - -// BrokenTestTargetedMerge is broken, see Merge doc comment. -func BrokenTestTargetedMerge(t *testing.T) { - rand.Seed(42) - s1 := NewTargeted(Targets) - s2 := NewTargeted(Targets) - a := populateStream(s1) - a = append(a, populateStream(s2)...) - s1.Merge(s2.Samples()) - verifyPercsWithAbsoluteEpsilon(t, a, s1) -} - -// BrokenTestLowBiasedMerge is broken, see Merge doc comment. -func BrokenTestLowBiasedMerge(t *testing.T) { - rand.Seed(42) - s1 := NewLowBiased(RelativeEpsilon) - s2 := NewLowBiased(RelativeEpsilon) - a := populateStream(s1) - a = append(a, populateStream(s2)...) - s1.Merge(s2.Samples()) - verifyLowPercsWithRelativeEpsilon(t, a, s2) -} - -// BrokenTestHighBiasedMerge is broken, see Merge doc comment. -func BrokenTestHighBiasedMerge(t *testing.T) { - rand.Seed(42) - s1 := NewHighBiased(RelativeEpsilon) - s2 := NewHighBiased(RelativeEpsilon) - a := populateStream(s1) - a = append(a, populateStream(s2)...) - s1.Merge(s2.Samples()) - verifyHighPercsWithRelativeEpsilon(t, a, s2) -} - -func TestUncompressed(t *testing.T) { - q := NewTargeted(Targets) - for i := 100; i > 0; i-- { - q.Insert(float64(i)) - } - if g := q.Count(); g != 100 { - t.Errorf("want count 100, got %d", g) - } - // Before compression, Query should have 100% accuracy. - for quantile := range Targets { - w := quantile * 100 - if g := q.Query(quantile); g != w { - t.Errorf("want %f, got %f", w, g) - } - } -} - -func TestUncompressedSamples(t *testing.T) { - q := NewTargeted(map[float64]float64{0.99: 0.001}) - for i := 1; i <= 100; i++ { - q.Insert(float64(i)) - } - if g := q.Samples().Len(); g != 100 { - t.Errorf("want count 100, got %d", g) - } -} - -func TestUncompressedOne(t *testing.T) { - q := NewTargeted(map[float64]float64{0.99: 0.01}) - q.Insert(3.14) - if g := q.Query(0.90); g != 3.14 { - t.Error("want PI, got", g) - } -} - -func TestDefaults(t *testing.T) { - if g := NewTargeted(map[float64]float64{0.99: 0.001}).Query(0.99); g != 0 { - t.Errorf("want 0, got %f", g) - } -} diff --git a/vendor/github.com/beorn7/perks/topk/topk.go b/vendor/github.com/beorn7/perks/topk/topk.go deleted file mode 100644 index 5ac3d990..00000000 --- a/vendor/github.com/beorn7/perks/topk/topk.go +++ /dev/null @@ -1,90 +0,0 @@ -package topk - -import ( - "sort" -) - -// http://www.cs.ucsb.edu/research/tech_reports/reports/2005-23.pdf - -type Element struct { - Value string - Count int -} - -type Samples []*Element - -func (sm Samples) Len() int { - return len(sm) -} - -func (sm Samples) Less(i, j int) bool { - return sm[i].Count < sm[j].Count -} - -func (sm Samples) Swap(i, j int) { - sm[i], sm[j] = sm[j], sm[i] -} - -type Stream struct { - k int - mon map[string]*Element - - // the minimum Element - min *Element -} - -func New(k int) *Stream { - s := new(Stream) - s.k = k - s.mon = make(map[string]*Element) - s.min = &Element{} - - // Track k+1 so that less frequenet items contended for that spot, - // resulting in k being more accurate. - return s -} - -func (s *Stream) Insert(x string) { - s.insert(&Element{x, 1}) -} - -func (s *Stream) Merge(sm Samples) { - for _, e := range sm { - s.insert(e) - } -} - -func (s *Stream) insert(in *Element) { - e := s.mon[in.Value] - if e != nil { - e.Count++ - } else { - if len(s.mon) < s.k+1 { - e = &Element{in.Value, in.Count} - s.mon[in.Value] = e - } else { - e = s.min - delete(s.mon, e.Value) - e.Value = in.Value - e.Count += in.Count - s.min = e - } - } - if e.Count < s.min.Count { - s.min = e - } -} - -func (s *Stream) Query() Samples { - var sm Samples - for _, e := range s.mon { - sm = append(sm, e) - } - sort.Sort(sort.Reverse(sm)) - - if len(sm) < s.k { - return sm - } - - return sm[:s.k] -} diff --git a/vendor/github.com/beorn7/perks/topk/topk_test.go b/vendor/github.com/beorn7/perks/topk/topk_test.go deleted file mode 100644 index c24f0f72..00000000 --- a/vendor/github.com/beorn7/perks/topk/topk_test.go +++ /dev/null @@ -1,57 +0,0 @@ -package topk - -import ( - "fmt" - "math/rand" - "sort" - "testing" -) - -func TestTopK(t *testing.T) { - stream := New(10) - ss := []*Stream{New(10), New(10), New(10)} - m := make(map[string]int) - for _, s := range ss { - for i := 0; i < 1e6; i++ { - v := fmt.Sprintf("%x", int8(rand.ExpFloat64())) - s.Insert(v) - m[v]++ - } - stream.Merge(s.Query()) - } - - var sm Samples - for x, s := range m { - sm = append(sm, &Element{x, s}) - } - sort.Sort(sort.Reverse(sm)) - - g := stream.Query() - if len(g) != 10 { - t.Fatalf("got %d, want 10", len(g)) - } - for i, e := range g { - if sm[i].Value != e.Value { - t.Errorf("at %d: want %q, got %q", i, sm[i].Value, e.Value) - } - } -} - -func TestQuery(t *testing.T) { - queryTests := []struct { - value string - expected int - }{ - {"a", 1}, - {"b", 2}, - {"c", 2}, - } - - stream := New(2) - for _, tt := range queryTests { - stream.Insert(tt.value) - if n := len(stream.Query()); n != tt.expected { - t.Errorf("want %d, got %d", tt.expected, n) - } - } -} diff --git a/vendor/github.com/certifi/gocertifi/certifi_test.go b/vendor/github.com/certifi/gocertifi/certifi_test.go deleted file mode 100644 index a071ad86..00000000 --- a/vendor/github.com/certifi/gocertifi/certifi_test.go +++ /dev/null @@ -1,10 +0,0 @@ -package gocertifi - -import "testing" - -func TestGetCerts(t *testing.T) { - cert_pool, err := CACerts() - if (cert_pool == nil) || (err != nil) { - t.Errorf("Failed to return the certificates.") - } -} diff --git a/vendor/code.cfops.it/go/brotli/backward_references.c b/vendor/github.com/cloudflare/brotli-go/backward_references.c similarity index 100% rename from vendor/code.cfops.it/go/brotli/backward_references.c rename to vendor/github.com/cloudflare/brotli-go/backward_references.c diff --git a/vendor/code.cfops.it/go/brotli/backward_references_hq.c b/vendor/github.com/cloudflare/brotli-go/backward_references_hq.c similarity index 100% rename from vendor/code.cfops.it/go/brotli/backward_references_hq.c rename to vendor/github.com/cloudflare/brotli-go/backward_references_hq.c diff --git a/vendor/code.cfops.it/go/brotli/bit_cost.c b/vendor/github.com/cloudflare/brotli-go/bit_cost.c similarity index 100% rename from vendor/code.cfops.it/go/brotli/bit_cost.c rename to vendor/github.com/cloudflare/brotli-go/bit_cost.c diff --git a/vendor/code.cfops.it/go/brotli/bit_reader.c b/vendor/github.com/cloudflare/brotli-go/bit_reader.c similarity index 100% rename from vendor/code.cfops.it/go/brotli/bit_reader.c rename to vendor/github.com/cloudflare/brotli-go/bit_reader.c diff --git a/vendor/code.cfops.it/go/brotli/block_splitter.c b/vendor/github.com/cloudflare/brotli-go/block_splitter.c similarity index 100% rename from vendor/code.cfops.it/go/brotli/block_splitter.c rename to vendor/github.com/cloudflare/brotli-go/block_splitter.c diff --git a/vendor/code.cfops.it/go/brotli/brotli/decode.h b/vendor/github.com/cloudflare/brotli-go/brotli/decode.h similarity index 100% rename from vendor/code.cfops.it/go/brotli/brotli/decode.h rename to vendor/github.com/cloudflare/brotli-go/brotli/decode.h diff --git a/vendor/code.cfops.it/go/brotli/brotli/encode.h b/vendor/github.com/cloudflare/brotli-go/brotli/encode.h similarity index 100% rename from vendor/code.cfops.it/go/brotli/brotli/encode.h rename to vendor/github.com/cloudflare/brotli-go/brotli/encode.h diff --git a/vendor/code.cfops.it/go/brotli/brotli/port.h b/vendor/github.com/cloudflare/brotli-go/brotli/port.h similarity index 100% rename from vendor/code.cfops.it/go/brotli/brotli/port.h rename to vendor/github.com/cloudflare/brotli-go/brotli/port.h diff --git a/vendor/code.cfops.it/go/brotli/brotli/types.h b/vendor/github.com/cloudflare/brotli-go/brotli/types.h similarity index 100% rename from vendor/code.cfops.it/go/brotli/brotli/types.h rename to vendor/github.com/cloudflare/brotli-go/brotli/types.h diff --git a/vendor/code.cfops.it/go/brotli/brotli_bit_stream.c b/vendor/github.com/cloudflare/brotli-go/brotli_bit_stream.c similarity index 100% rename from vendor/code.cfops.it/go/brotli/brotli_bit_stream.c rename to vendor/github.com/cloudflare/brotli-go/brotli_bit_stream.c diff --git a/vendor/code.cfops.it/go/brotli/cbrotli_test.go b/vendor/github.com/cloudflare/brotli-go/cbrotli_test.go similarity index 100% rename from vendor/code.cfops.it/go/brotli/cbrotli_test.go rename to vendor/github.com/cloudflare/brotli-go/cbrotli_test.go diff --git a/vendor/code.cfops.it/go/brotli/cgo.go b/vendor/github.com/cloudflare/brotli-go/cgo.go similarity index 100% rename from vendor/code.cfops.it/go/brotli/cgo.go rename to vendor/github.com/cloudflare/brotli-go/cgo.go diff --git a/vendor/code.cfops.it/go/brotli/cluster.c b/vendor/github.com/cloudflare/brotli-go/cluster.c similarity index 100% rename from vendor/code.cfops.it/go/brotli/cluster.c rename to vendor/github.com/cloudflare/brotli-go/cluster.c diff --git a/vendor/code.cfops.it/go/brotli/common/constants.h b/vendor/github.com/cloudflare/brotli-go/common/constants.h similarity index 100% rename from vendor/code.cfops.it/go/brotli/common/constants.h rename to vendor/github.com/cloudflare/brotli-go/common/constants.h diff --git a/vendor/code.cfops.it/go/brotli/common/dictionary.h b/vendor/github.com/cloudflare/brotli-go/common/dictionary.h similarity index 100% rename from vendor/code.cfops.it/go/brotli/common/dictionary.h rename to vendor/github.com/cloudflare/brotli-go/common/dictionary.h diff --git a/vendor/code.cfops.it/go/brotli/common/version.h b/vendor/github.com/cloudflare/brotli-go/common/version.h similarity index 100% rename from vendor/code.cfops.it/go/brotli/common/version.h rename to vendor/github.com/cloudflare/brotli-go/common/version.h diff --git a/vendor/code.cfops.it/go/brotli/compress_fragment.c b/vendor/github.com/cloudflare/brotli-go/compress_fragment.c similarity index 100% rename from vendor/code.cfops.it/go/brotli/compress_fragment.c rename to vendor/github.com/cloudflare/brotli-go/compress_fragment.c diff --git a/vendor/code.cfops.it/go/brotli/compress_fragment_two_pass.c b/vendor/github.com/cloudflare/brotli-go/compress_fragment_two_pass.c similarity index 100% rename from vendor/code.cfops.it/go/brotli/compress_fragment_two_pass.c rename to vendor/github.com/cloudflare/brotli-go/compress_fragment_two_pass.c diff --git a/vendor/code.cfops.it/go/brotli/dec/bit_reader.h b/vendor/github.com/cloudflare/brotli-go/dec/bit_reader.h similarity index 100% rename from vendor/code.cfops.it/go/brotli/dec/bit_reader.h rename to vendor/github.com/cloudflare/brotli-go/dec/bit_reader.h diff --git a/vendor/code.cfops.it/go/brotli/dec/context.h b/vendor/github.com/cloudflare/brotli-go/dec/context.h similarity index 100% rename from vendor/code.cfops.it/go/brotli/dec/context.h rename to vendor/github.com/cloudflare/brotli-go/dec/context.h diff --git a/vendor/code.cfops.it/go/brotli/dec/huffman.h b/vendor/github.com/cloudflare/brotli-go/dec/huffman.h similarity index 100% rename from vendor/code.cfops.it/go/brotli/dec/huffman.h rename to vendor/github.com/cloudflare/brotli-go/dec/huffman.h diff --git a/vendor/code.cfops.it/go/brotli/dec/port.h b/vendor/github.com/cloudflare/brotli-go/dec/port.h similarity index 100% rename from vendor/code.cfops.it/go/brotli/dec/port.h rename to vendor/github.com/cloudflare/brotli-go/dec/port.h diff --git a/vendor/code.cfops.it/go/brotli/dec/prefix.h b/vendor/github.com/cloudflare/brotli-go/dec/prefix.h similarity index 100% rename from vendor/code.cfops.it/go/brotli/dec/prefix.h rename to vendor/github.com/cloudflare/brotli-go/dec/prefix.h diff --git a/vendor/code.cfops.it/go/brotli/dec/state.h b/vendor/github.com/cloudflare/brotli-go/dec/state.h similarity index 100% rename from vendor/code.cfops.it/go/brotli/dec/state.h rename to vendor/github.com/cloudflare/brotli-go/dec/state.h diff --git a/vendor/code.cfops.it/go/brotli/dec/transform.h b/vendor/github.com/cloudflare/brotli-go/dec/transform.h similarity index 100% rename from vendor/code.cfops.it/go/brotli/dec/transform.h rename to vendor/github.com/cloudflare/brotli-go/dec/transform.h diff --git a/vendor/code.cfops.it/go/brotli/decode.c b/vendor/github.com/cloudflare/brotli-go/decode.c similarity index 100% rename from vendor/code.cfops.it/go/brotli/decode.c rename to vendor/github.com/cloudflare/brotli-go/decode.c diff --git a/vendor/code.cfops.it/go/brotli/dictionary.c b/vendor/github.com/cloudflare/brotli-go/dictionary.c similarity index 100% rename from vendor/code.cfops.it/go/brotli/dictionary.c rename to vendor/github.com/cloudflare/brotli-go/dictionary.c diff --git a/vendor/code.cfops.it/go/brotli/dictionary_hash.c b/vendor/github.com/cloudflare/brotli-go/dictionary_hash.c similarity index 100% rename from vendor/code.cfops.it/go/brotli/dictionary_hash.c rename to vendor/github.com/cloudflare/brotli-go/dictionary_hash.c diff --git a/vendor/code.cfops.it/go/brotli/enc/backward_references.h b/vendor/github.com/cloudflare/brotli-go/enc/backward_references.h similarity index 100% rename from vendor/code.cfops.it/go/brotli/enc/backward_references.h rename to vendor/github.com/cloudflare/brotli-go/enc/backward_references.h diff --git a/vendor/code.cfops.it/go/brotli/enc/backward_references_hq.h b/vendor/github.com/cloudflare/brotli-go/enc/backward_references_hq.h similarity index 100% rename from vendor/code.cfops.it/go/brotli/enc/backward_references_hq.h rename to vendor/github.com/cloudflare/brotli-go/enc/backward_references_hq.h diff --git a/vendor/code.cfops.it/go/brotli/enc/backward_references_inc.h b/vendor/github.com/cloudflare/brotli-go/enc/backward_references_inc.h similarity index 100% rename from vendor/code.cfops.it/go/brotli/enc/backward_references_inc.h rename to vendor/github.com/cloudflare/brotli-go/enc/backward_references_inc.h diff --git a/vendor/code.cfops.it/go/brotli/enc/bit_cost.h b/vendor/github.com/cloudflare/brotli-go/enc/bit_cost.h similarity index 100% rename from vendor/code.cfops.it/go/brotli/enc/bit_cost.h rename to vendor/github.com/cloudflare/brotli-go/enc/bit_cost.h diff --git a/vendor/code.cfops.it/go/brotli/enc/bit_cost_inc.h b/vendor/github.com/cloudflare/brotli-go/enc/bit_cost_inc.h similarity index 100% rename from vendor/code.cfops.it/go/brotli/enc/bit_cost_inc.h rename to vendor/github.com/cloudflare/brotli-go/enc/bit_cost_inc.h diff --git a/vendor/code.cfops.it/go/brotli/enc/block_encoder_inc.h b/vendor/github.com/cloudflare/brotli-go/enc/block_encoder_inc.h similarity index 100% rename from vendor/code.cfops.it/go/brotli/enc/block_encoder_inc.h rename to vendor/github.com/cloudflare/brotli-go/enc/block_encoder_inc.h diff --git a/vendor/code.cfops.it/go/brotli/enc/block_splitter.h b/vendor/github.com/cloudflare/brotli-go/enc/block_splitter.h similarity index 100% rename from vendor/code.cfops.it/go/brotli/enc/block_splitter.h rename to vendor/github.com/cloudflare/brotli-go/enc/block_splitter.h diff --git a/vendor/code.cfops.it/go/brotli/enc/block_splitter_inc.h b/vendor/github.com/cloudflare/brotli-go/enc/block_splitter_inc.h similarity index 100% rename from vendor/code.cfops.it/go/brotli/enc/block_splitter_inc.h rename to vendor/github.com/cloudflare/brotli-go/enc/block_splitter_inc.h diff --git a/vendor/code.cfops.it/go/brotli/enc/brotli_bit_stream.h b/vendor/github.com/cloudflare/brotli-go/enc/brotli_bit_stream.h similarity index 100% rename from vendor/code.cfops.it/go/brotli/enc/brotli_bit_stream.h rename to vendor/github.com/cloudflare/brotli-go/enc/brotli_bit_stream.h diff --git a/vendor/code.cfops.it/go/brotli/enc/cluster.h b/vendor/github.com/cloudflare/brotli-go/enc/cluster.h similarity index 100% rename from vendor/code.cfops.it/go/brotli/enc/cluster.h rename to vendor/github.com/cloudflare/brotli-go/enc/cluster.h diff --git a/vendor/code.cfops.it/go/brotli/enc/cluster_inc.h b/vendor/github.com/cloudflare/brotli-go/enc/cluster_inc.h similarity index 100% rename from vendor/code.cfops.it/go/brotli/enc/cluster_inc.h rename to vendor/github.com/cloudflare/brotli-go/enc/cluster_inc.h diff --git a/vendor/code.cfops.it/go/brotli/enc/command.h b/vendor/github.com/cloudflare/brotli-go/enc/command.h similarity index 100% rename from vendor/code.cfops.it/go/brotli/enc/command.h rename to vendor/github.com/cloudflare/brotli-go/enc/command.h diff --git a/vendor/code.cfops.it/go/brotli/enc/compress_fragment.h b/vendor/github.com/cloudflare/brotli-go/enc/compress_fragment.h similarity index 100% rename from vendor/code.cfops.it/go/brotli/enc/compress_fragment.h rename to vendor/github.com/cloudflare/brotli-go/enc/compress_fragment.h diff --git a/vendor/code.cfops.it/go/brotli/enc/compress_fragment_two_pass.h b/vendor/github.com/cloudflare/brotli-go/enc/compress_fragment_two_pass.h similarity index 100% rename from vendor/code.cfops.it/go/brotli/enc/compress_fragment_two_pass.h rename to vendor/github.com/cloudflare/brotli-go/enc/compress_fragment_two_pass.h diff --git a/vendor/code.cfops.it/go/brotli/enc/context.h b/vendor/github.com/cloudflare/brotli-go/enc/context.h similarity index 100% rename from vendor/code.cfops.it/go/brotli/enc/context.h rename to vendor/github.com/cloudflare/brotli-go/enc/context.h diff --git a/vendor/code.cfops.it/go/brotli/enc/dictionary_hash.h b/vendor/github.com/cloudflare/brotli-go/enc/dictionary_hash.h similarity index 100% rename from vendor/code.cfops.it/go/brotli/enc/dictionary_hash.h rename to vendor/github.com/cloudflare/brotli-go/enc/dictionary_hash.h diff --git a/vendor/code.cfops.it/go/brotli/enc/entropy_encode.h b/vendor/github.com/cloudflare/brotli-go/enc/entropy_encode.h similarity index 100% rename from vendor/code.cfops.it/go/brotli/enc/entropy_encode.h rename to vendor/github.com/cloudflare/brotli-go/enc/entropy_encode.h diff --git a/vendor/code.cfops.it/go/brotli/enc/entropy_encode_static.h b/vendor/github.com/cloudflare/brotli-go/enc/entropy_encode_static.h similarity index 100% rename from vendor/code.cfops.it/go/brotli/enc/entropy_encode_static.h rename to vendor/github.com/cloudflare/brotli-go/enc/entropy_encode_static.h diff --git a/vendor/code.cfops.it/go/brotli/enc/fast_log.h b/vendor/github.com/cloudflare/brotli-go/enc/fast_log.h similarity index 100% rename from vendor/code.cfops.it/go/brotli/enc/fast_log.h rename to vendor/github.com/cloudflare/brotli-go/enc/fast_log.h diff --git a/vendor/code.cfops.it/go/brotli/enc/find_match_length.h b/vendor/github.com/cloudflare/brotli-go/enc/find_match_length.h similarity index 100% rename from vendor/code.cfops.it/go/brotli/enc/find_match_length.h rename to vendor/github.com/cloudflare/brotli-go/enc/find_match_length.h diff --git a/vendor/code.cfops.it/go/brotli/enc/hash.h b/vendor/github.com/cloudflare/brotli-go/enc/hash.h similarity index 100% rename from vendor/code.cfops.it/go/brotli/enc/hash.h rename to vendor/github.com/cloudflare/brotli-go/enc/hash.h diff --git a/vendor/code.cfops.it/go/brotli/enc/hash_forgetful_chain_inc.h b/vendor/github.com/cloudflare/brotli-go/enc/hash_forgetful_chain_inc.h similarity index 100% rename from vendor/code.cfops.it/go/brotli/enc/hash_forgetful_chain_inc.h rename to vendor/github.com/cloudflare/brotli-go/enc/hash_forgetful_chain_inc.h diff --git a/vendor/code.cfops.it/go/brotli/enc/hash_longest_match64_inc.h b/vendor/github.com/cloudflare/brotli-go/enc/hash_longest_match64_inc.h similarity index 100% rename from vendor/code.cfops.it/go/brotli/enc/hash_longest_match64_inc.h rename to vendor/github.com/cloudflare/brotli-go/enc/hash_longest_match64_inc.h diff --git a/vendor/code.cfops.it/go/brotli/enc/hash_longest_match_inc.h b/vendor/github.com/cloudflare/brotli-go/enc/hash_longest_match_inc.h similarity index 100% rename from vendor/code.cfops.it/go/brotli/enc/hash_longest_match_inc.h rename to vendor/github.com/cloudflare/brotli-go/enc/hash_longest_match_inc.h diff --git a/vendor/code.cfops.it/go/brotli/enc/hash_longest_match_quickly_inc.h b/vendor/github.com/cloudflare/brotli-go/enc/hash_longest_match_quickly_inc.h similarity index 100% rename from vendor/code.cfops.it/go/brotli/enc/hash_longest_match_quickly_inc.h rename to vendor/github.com/cloudflare/brotli-go/enc/hash_longest_match_quickly_inc.h diff --git a/vendor/code.cfops.it/go/brotli/enc/hash_to_binary_tree_inc.h b/vendor/github.com/cloudflare/brotli-go/enc/hash_to_binary_tree_inc.h similarity index 100% rename from vendor/code.cfops.it/go/brotli/enc/hash_to_binary_tree_inc.h rename to vendor/github.com/cloudflare/brotli-go/enc/hash_to_binary_tree_inc.h diff --git a/vendor/code.cfops.it/go/brotli/enc/histogram.h b/vendor/github.com/cloudflare/brotli-go/enc/histogram.h similarity index 100% rename from vendor/code.cfops.it/go/brotli/enc/histogram.h rename to vendor/github.com/cloudflare/brotli-go/enc/histogram.h diff --git a/vendor/code.cfops.it/go/brotli/enc/histogram_inc.h b/vendor/github.com/cloudflare/brotli-go/enc/histogram_inc.h similarity index 100% rename from vendor/code.cfops.it/go/brotli/enc/histogram_inc.h rename to vendor/github.com/cloudflare/brotli-go/enc/histogram_inc.h diff --git a/vendor/code.cfops.it/go/brotli/enc/literal_cost.h b/vendor/github.com/cloudflare/brotli-go/enc/literal_cost.h similarity index 100% rename from vendor/code.cfops.it/go/brotli/enc/literal_cost.h rename to vendor/github.com/cloudflare/brotli-go/enc/literal_cost.h diff --git a/vendor/code.cfops.it/go/brotli/enc/memory.h b/vendor/github.com/cloudflare/brotli-go/enc/memory.h similarity index 100% rename from vendor/code.cfops.it/go/brotli/enc/memory.h rename to vendor/github.com/cloudflare/brotli-go/enc/memory.h diff --git a/vendor/code.cfops.it/go/brotli/enc/metablock.h b/vendor/github.com/cloudflare/brotli-go/enc/metablock.h similarity index 100% rename from vendor/code.cfops.it/go/brotli/enc/metablock.h rename to vendor/github.com/cloudflare/brotli-go/enc/metablock.h diff --git a/vendor/code.cfops.it/go/brotli/enc/metablock_inc.h b/vendor/github.com/cloudflare/brotli-go/enc/metablock_inc.h similarity index 100% rename from vendor/code.cfops.it/go/brotli/enc/metablock_inc.h rename to vendor/github.com/cloudflare/brotli-go/enc/metablock_inc.h diff --git a/vendor/code.cfops.it/go/brotli/enc/port.h b/vendor/github.com/cloudflare/brotli-go/enc/port.h similarity index 100% rename from vendor/code.cfops.it/go/brotli/enc/port.h rename to vendor/github.com/cloudflare/brotli-go/enc/port.h diff --git a/vendor/code.cfops.it/go/brotli/enc/prefix.h b/vendor/github.com/cloudflare/brotli-go/enc/prefix.h similarity index 100% rename from vendor/code.cfops.it/go/brotli/enc/prefix.h rename to vendor/github.com/cloudflare/brotli-go/enc/prefix.h diff --git a/vendor/code.cfops.it/go/brotli/enc/quality.h b/vendor/github.com/cloudflare/brotli-go/enc/quality.h similarity index 100% rename from vendor/code.cfops.it/go/brotli/enc/quality.h rename to vendor/github.com/cloudflare/brotli-go/enc/quality.h diff --git a/vendor/code.cfops.it/go/brotli/enc/ringbuffer.h b/vendor/github.com/cloudflare/brotli-go/enc/ringbuffer.h similarity index 100% rename from vendor/code.cfops.it/go/brotli/enc/ringbuffer.h rename to vendor/github.com/cloudflare/brotli-go/enc/ringbuffer.h diff --git a/vendor/code.cfops.it/go/brotli/enc/static_dict.h b/vendor/github.com/cloudflare/brotli-go/enc/static_dict.h similarity index 100% rename from vendor/code.cfops.it/go/brotli/enc/static_dict.h rename to vendor/github.com/cloudflare/brotli-go/enc/static_dict.h diff --git a/vendor/code.cfops.it/go/brotli/enc/static_dict_lut.h b/vendor/github.com/cloudflare/brotli-go/enc/static_dict_lut.h similarity index 100% rename from vendor/code.cfops.it/go/brotli/enc/static_dict_lut.h rename to vendor/github.com/cloudflare/brotli-go/enc/static_dict_lut.h diff --git a/vendor/code.cfops.it/go/brotli/enc/utf8_util.h b/vendor/github.com/cloudflare/brotli-go/enc/utf8_util.h similarity index 100% rename from vendor/code.cfops.it/go/brotli/enc/utf8_util.h rename to vendor/github.com/cloudflare/brotli-go/enc/utf8_util.h diff --git a/vendor/code.cfops.it/go/brotli/enc/write_bits.h b/vendor/github.com/cloudflare/brotli-go/enc/write_bits.h similarity index 100% rename from vendor/code.cfops.it/go/brotli/enc/write_bits.h rename to vendor/github.com/cloudflare/brotli-go/enc/write_bits.h diff --git a/vendor/code.cfops.it/go/brotli/encode.c b/vendor/github.com/cloudflare/brotli-go/encode.c similarity index 100% rename from vendor/code.cfops.it/go/brotli/encode.c rename to vendor/github.com/cloudflare/brotli-go/encode.c diff --git a/vendor/code.cfops.it/go/brotli/entropy_encode.c b/vendor/github.com/cloudflare/brotli-go/entropy_encode.c similarity index 100% rename from vendor/code.cfops.it/go/brotli/entropy_encode.c rename to vendor/github.com/cloudflare/brotli-go/entropy_encode.c diff --git a/vendor/code.cfops.it/go/brotli/histogram.c b/vendor/github.com/cloudflare/brotli-go/histogram.c similarity index 100% rename from vendor/code.cfops.it/go/brotli/histogram.c rename to vendor/github.com/cloudflare/brotli-go/histogram.c diff --git a/vendor/code.cfops.it/go/brotli/huffman.c b/vendor/github.com/cloudflare/brotli-go/huffman.c similarity index 100% rename from vendor/code.cfops.it/go/brotli/huffman.c rename to vendor/github.com/cloudflare/brotli-go/huffman.c diff --git a/vendor/code.cfops.it/go/brotli/literal_cost.c b/vendor/github.com/cloudflare/brotli-go/literal_cost.c similarity index 100% rename from vendor/code.cfops.it/go/brotli/literal_cost.c rename to vendor/github.com/cloudflare/brotli-go/literal_cost.c diff --git a/vendor/code.cfops.it/go/brotli/memory.c b/vendor/github.com/cloudflare/brotli-go/memory.c similarity index 100% rename from vendor/code.cfops.it/go/brotli/memory.c rename to vendor/github.com/cloudflare/brotli-go/memory.c diff --git a/vendor/code.cfops.it/go/brotli/metablock.c b/vendor/github.com/cloudflare/brotli-go/metablock.c similarity index 100% rename from vendor/code.cfops.it/go/brotli/metablock.c rename to vendor/github.com/cloudflare/brotli-go/metablock.c diff --git a/vendor/code.cfops.it/go/brotli/reader.go b/vendor/github.com/cloudflare/brotli-go/reader.go similarity index 100% rename from vendor/code.cfops.it/go/brotli/reader.go rename to vendor/github.com/cloudflare/brotli-go/reader.go diff --git a/vendor/code.cfops.it/go/brotli/state.c b/vendor/github.com/cloudflare/brotli-go/state.c similarity index 100% rename from vendor/code.cfops.it/go/brotli/state.c rename to vendor/github.com/cloudflare/brotli-go/state.c diff --git a/vendor/code.cfops.it/go/brotli/static_dict.c b/vendor/github.com/cloudflare/brotli-go/static_dict.c similarity index 100% rename from vendor/code.cfops.it/go/brotli/static_dict.c rename to vendor/github.com/cloudflare/brotli-go/static_dict.c diff --git a/vendor/code.cfops.it/go/brotli/utf8_util.c b/vendor/github.com/cloudflare/brotli-go/utf8_util.c similarity index 100% rename from vendor/code.cfops.it/go/brotli/utf8_util.c rename to vendor/github.com/cloudflare/brotli-go/utf8_util.c diff --git a/vendor/code.cfops.it/go/brotli/writer.go b/vendor/github.com/cloudflare/brotli-go/writer.go similarity index 100% rename from vendor/code.cfops.it/go/brotli/writer.go rename to vendor/github.com/cloudflare/brotli-go/writer.go diff --git a/vendor/github.com/coredns/coredns/.codecov.yml b/vendor/github.com/coredns/coredns/.codecov.yml deleted file mode 100644 index 167f5636..00000000 --- a/vendor/github.com/coredns/coredns/.codecov.yml +++ /dev/null @@ -1,8 +0,0 @@ -coverage: - status: - project: - default: - target: 50% - threshold: null - patch: false - changes: false diff --git a/vendor/github.com/coredns/coredns/.dockerignore b/vendor/github.com/coredns/coredns/.dockerignore deleted file mode 100644 index 98e5cfe1..00000000 --- a/vendor/github.com/coredns/coredns/.dockerignore +++ /dev/null @@ -1,12 +0,0 @@ -.git/* -core/* -coremain/* -hooks/* -man/* -pb/* -plugin/* -request/* -test/* -vendor/* -build/* -release/* diff --git a/vendor/github.com/coredns/coredns/.github/PULL_REQUEST_TEMPLATE.md b/vendor/github.com/coredns/coredns/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 7c72c698..00000000 --- a/vendor/github.com/coredns/coredns/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,10 +0,0 @@ - - -### 1. Why is this pull request needed and what does it do? - -### 2. Which issues (if any) are related? - -### 3. Which documentation changes (if any) need to be made? diff --git a/vendor/github.com/coredns/coredns/.github/stale.yml b/vendor/github.com/coredns/coredns/.github/stale.yml deleted file mode 100644 index ebcc73a5..00000000 --- a/vendor/github.com/coredns/coredns/.github/stale.yml +++ /dev/null @@ -1,19 +0,0 @@ -# Number of days of inactivity before an issue becomes stale -daysUntilStale: 100 -# Number of days of inactivity before a stale issue is closed -daysUntilClose: 21 -# Issues with these labels will never be considered stale -exemptLabels: - - pinned - - security - - later - - bug -# Label to use when marking an issue as stale -staleLabel: wontfix-stalebot -# Comment to post when marking an issue as stale. Set to `false` to disable -markComment: > - This issue has been automatically marked as stale because it has not had - recent activity. It will be closed if no further activity occurs. Thank you - for your contributions. -# Comment to post when closing a stale issue. Set to `false` to disable -closeComment: false diff --git a/vendor/github.com/coredns/coredns/.gitignore b/vendor/github.com/coredns/coredns/.gitignore deleted file mode 100644 index ca7623eb..00000000 --- a/vendor/github.com/coredns/coredns/.gitignore +++ /dev/null @@ -1,12 +0,0 @@ -query.log -Corefile -*.swp -coredns -coredns.exe -coredns.exe~ -debug -debug.test -kubectl -go-test-tmpfile* -coverage.txt -.idea diff --git a/vendor/github.com/coredns/coredns/.presubmit/context b/vendor/github.com/coredns/coredns/.presubmit/context deleted file mode 100755 index b7d6ef97..00000000 --- a/vendor/github.com/coredns/coredns/.presubmit/context +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/bash - -echo "** presubmit/$(basename $0)" - -if grep -lr "golang.org/x/net/context" "$@"; then - echo "** presubmit/$(basename $0): please use std lib's 'context' instead" - exit 1 -fi diff --git a/vendor/github.com/coredns/coredns/.presubmit/filename-hyphen b/vendor/github.com/coredns/coredns/.presubmit/filename-hyphen deleted file mode 100755 index 927ac1ff..00000000 --- a/vendor/github.com/coredns/coredns/.presubmit/filename-hyphen +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/bash - -echo "** presubmit/$(basename $0)" - -for dir in "$@"; do - if find $dir | grep '-'; then - echo "** presubmit/$(basename $0): please use an underscore in filenames instead of a hyphen" - fi -done diff --git a/vendor/github.com/coredns/coredns/.presubmit/test-lowercase b/vendor/github.com/coredns/coredns/.presubmit/test-lowercase deleted file mode 100755 index 70522888..00000000 --- a/vendor/github.com/coredns/coredns/.presubmit/test-lowercase +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/bash - -echo "** presubmit/$(basename $0)" - -# Get the tests that call t.* without capitalizing the first char - seems we standardized on that. -if egrep -r '\bt\.Fatal.?\("[a-z]' "$@"; then - echo "** presubmit/$(basename $0): please start with an upper case letter when using t.Fatal*()" - exit 1 -fi - -if egrep -r '\bt\.Error.?\("[a-z]' "$@"; then - echo "** presubmit/$(basename $0): please start with an upper case letter when using t.Error*()" - exit 1 -fi - -if egrep -r '\bt\.Log.?\("[a-z]' "$@"; then - echo "** presubmit/$(basename $0): please start with an upper case letter when using t.Log*()" - exit 1 -fi diff --git a/vendor/github.com/coredns/coredns/.travis.yml b/vendor/github.com/coredns/coredns/.travis.yml deleted file mode 100644 index ec2afbe7..00000000 --- a/vendor/github.com/coredns/coredns/.travis.yml +++ /dev/null @@ -1,44 +0,0 @@ -sudo: required -# Trusty distribution is much faster when sudo is required -dist: trusty - -services: - - docker - -language: go -go: - - "1.10.x" - -go_import_path: github.com/coredns/coredns - -git: - depth: 3 - -env: - - TEST_TYPE=coverage ETCD_VERSION=2.3.1 - - TEST_TYPE=integration ETCD_VERSION=2.3.1 - - TEST_TYPE=core ETCD_VERSION=2.3.1 - - TEST_TYPE=plugin ETCD_VERSION=2.3.1 - -# In the Travis VM-based build environment, IPv6 networking is not -# enabled by default. The sysctl operations below enable IPv6. -# IPv6 is needed by some of the CoreDNS test cases. The VM environment -# is needed to have access to sudo in the test environment. Sudo is -# needed to have docker in the test environment. - -before_install: - - cat /proc/net/if_inet6 - - uname -a - - sudo bash -c 'if [ `cat /proc/net/if_inet6 | wc -l` = "0" ]; then echo "Enabling IPv6" ; sysctl net.ipv6.conf.all.disable_ipv6=0 ; sysctl net.ipv6.conf.default.disable_ipv6=0 ; sysctl net.ipv6.conf.lo.disable_ipv6=0 ; fi' - - cat /proc/net/if_inet6 - - env - -before_script: - - docker run -d --net=host --name=etcd quay.io/coreos/etcd:v$ETCD_VERSION - -script: - - make TEST_TYPE=$TEST_TYPE travis - - -after_success: - - bash <(curl -s https://codecov.io/bash) diff --git a/vendor/github.com/coredns/coredns/ADOPTERS.md b/vendor/github.com/coredns/coredns/ADOPTERS.md deleted file mode 100644 index 497d94af..00000000 --- a/vendor/github.com/coredns/coredns/ADOPTERS.md +++ /dev/null @@ -1,9 +0,0 @@ -* [Infoblox](https://www.infoblox.com) uses CoreDNS in its Active Trust Cloud SaaS service, as well as for Kubernetes cluster DNS. -* [Sky Betting & Gaming](http://engineering.skybettingandgaming.com) uses CoreDNS for Kubernetes cluster DNS. -* [Kismia](https://kismia.com) uses CoreDNS for Kubernetes cluster DNS. -* [Admiral](https://getadmiral.com) uses CoreDNS to handle geographic DNS requests for our public-facing microservices. -* [Qunar](https://qunar.com) uses CoreDNS for service discovery of its GPU machine learning cloud with TensorFlow and Kubernetes. -* [seansean2](https://web.mit.edu) uses CoreDNS in production at MIT for DNS. -* [Tradeshift](https://tradeshift.com/) uses CoreDNS to look up company identifiers across multiple shards/regions/zones -* [SoundCloud](https://soundcloud.com/) uses CoreDNS as internal cache+proxy in Kubernetes clusters to handle hundreds of thousands DNS service discovery requests per second. -* [Z Lab](https://zlab.co.jp) uses CoreDNS in production combination with Consul and Kuberenetes Clusters. diff --git a/vendor/github.com/coredns/coredns/CODE-OF-CONDUCT.md b/vendor/github.com/coredns/coredns/CODE-OF-CONDUCT.md deleted file mode 100644 index 26a2b367..00000000 --- a/vendor/github.com/coredns/coredns/CODE-OF-CONDUCT.md +++ /dev/null @@ -1,43 +0,0 @@ -CNCF Community Code of Conduct - -### Contributor Code of Conduct - -As contributors and maintainers of this project, and in the interest of fostering -an open and welcoming community, we pledge to respect all people who contribute -through reporting issues, posting feature requests, updating documentation, -submitting pull requests or patches, and other activities. - -We are committed to making participation in this project a harassment-free experience for -everyone, regardless of level of experience, gender, gender identity and expression, -sexual orientation, disability, personal appearance, body size, race, ethnicity, age, -religion, or nationality. - -Examples of unacceptable behavior by participants include: - -* The use of sexualized language or imagery -* Personal attacks -* Trolling or insulting/derogatory comments -* Public or private harassment -* Publishing other's private information, such as physical or electronic addresses, - without explicit permission -* Other unethical or unprofessional conduct. - -Project maintainers have the right and responsibility to remove, edit, or reject -comments, commits, code, wiki edits, issues, and other contributions that are not -aligned to this Code of Conduct. By adopting this Code of Conduct, project maintainers -commit themselves to fairly and consistently applying these principles to every aspect -of managing this project. Project maintainers who do not follow or enforce the Code of -Conduct may be permanently removed from the project team. - -This code of conduct applies both within project spaces and in public spaces -when an individual is representing the project or its community. - -Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting a CNCF project maintainer, Sarah Novotny , and/or Dan Kohn . - -This Code of Conduct is adapted from the Contributor Covenant -(http://contributor-covenant.org), version 1.2.0, available at -http://contributor-covenant.org/version/1/2/0/ - -### CNCF Events Code of Conduct - -CNCF events are governed by the Linux Foundation [Code of Conduct](http://events.linuxfoundation.org/events/cloudnativecon/attend/code-of-conduct) available on the event page. This is designed to be compatible with the above policy and also includes more details on responding to incidents. diff --git a/vendor/github.com/coredns/coredns/CONTRIBUTING.md b/vendor/github.com/coredns/coredns/CONTRIBUTING.md deleted file mode 100644 index c44b85f9..00000000 --- a/vendor/github.com/coredns/coredns/CONTRIBUTING.md +++ /dev/null @@ -1,116 +0,0 @@ -# Contributing to CoreDNS - -Welcome! Our community focuses on helping others and making CoreDNS the best it -can be. We gladly accept contributions and encourage you to get involved! - -## Bug reports - -First, please [search this repository](https://github.com/coredns/coredns/search?q=&type=Issues&utf8=%E2%9C%93) -with a variety of keywords to ensure your bug is not already reported. - -If not, [open an issue](https://github.com/coredns/coredns/issues) and answer the -questions so we can understand and reproduce the problematic behavior. - -The burden is on you to convince us that it is actually a bug in CoreDNS. This is -easiest to do when you write clear, concise instructions so we can reproduce -the behavior (even if it seems obvious). The more detailed and specific you are, -the faster we will be able to help you. Check out -[How to Report Bugs Effectively](http://www.chiark.greenend.org.uk/~sgtatham/bugs.html). - -Please be kind. :smile: Remember that CoreDNS comes at no cost to you, and you're -getting free help. - -We are using [Stable Bot](https://github.com/probot/stale) to close inactive issues. If you feel an -issue should not be closed you can add the "pinned" label to it or just update the bug every now and -then. - -## Minor improvements and new tests - -Submit [pull requests](https://github.com/coredns/coredns/pulls) at any time. Make -sure to write tests to assert your change is working properly and is thoroughly -covered. - - -## Proposals, suggestions, ideas, new features - -First, please [search](https://github.com/coredns/coredns/search?q=&type=Issues&utf8=%E2%9C%93) -with a variety of keywords to ensure your suggestion/proposal is new. - -If so, you may open either an issue or a pull request for discussion and -feedback. - -The advantage of issues is that you don't have to spend time actually -implementing your idea, but you should still describe it thoroughly. The -advantage of a pull request is that we can immediately see the impact the change -will have on the project, what the code will look like, and how to improve it. -The disadvantage of pull requests is that they are unlikely to get accepted -without significant changes, or it may be rejected entirely. Don't worry, that -won't happen without an open discussion first. - -If you are going to spend significant time implementing code for a pull request, -best to open an issue first and "claim" it and get feedback before you invest -a lot of time. - -## Vulnerabilities - -If you've found a vulnerability that is serious, please email: . -If it's not a big deal, a pull request will probably be faster. - -## Git Hook - -We use `golint` and `go vet` as tools to warn use about things (noted golint is obnoxious sometimes, -but still helpful). Add the following script as a git `post-commit` in `.git/hooks/post-commit` and -make it executable. - -~~~ sh -#!/bin/bash - -# : -# The script takes no parameters and its exit status does not affect the commit in any way. You can -# use git # rev-parse HEAD to get the new commit’s SHA1 hash, or you can use git log -l HEAD to get -# all of its # information. - -for d in *; do - if [[ "$d" == "vendor" ]]; then - continue - fi - if [[ "$d" == "logo" ]]; then - continue - fi - if [[ ! -d "$d" ]]; then - continue - fi - golint "$d"/... -done -~~~ - -## Updating Dependencies - -We use Golang's [`dep`](https://github.com/golang/dep) as the tool to manage vendor dependencies. -The tool could be obtained through: - -```sh -$ go get -u github.com/golang/dep/cmd/dep -``` - -Use the following to update the locked versions of all dependencies -```sh -$ dep ensure -update -``` - -To add a dependency to the project, you might run -```sh -$ dep ensure github.com/pkg/errors -``` - -After the dependencies have been updated or added, you might run the following to -prune vendored packages: -```sh -$ dep prune -``` - -Please refer to Golang's [`dep`](https://github.com/golang/dep) for more details. - -# Thank you - -Thanks for your help! CoreDNS would not be what it is today without your contributions. diff --git a/vendor/github.com/coredns/coredns/Dockerfile b/vendor/github.com/coredns/coredns/Dockerfile deleted file mode 100644 index 9c460858..00000000 --- a/vendor/github.com/coredns/coredns/Dockerfile +++ /dev/null @@ -1,12 +0,0 @@ -FROM debian:stable-slim - -RUN apt-get update && apt-get -uy upgrade -RUN apt-get -y install ca-certificates && update-ca-certificates - -FROM scratch - -COPY --from=0 /etc/ssl/certs /etc/ssl/certs -ADD coredns /coredns - -EXPOSE 53 53/udp -ENTRYPOINT ["/coredns"] diff --git a/vendor/github.com/coredns/coredns/Gopkg.lock b/vendor/github.com/coredns/coredns/Gopkg.lock deleted file mode 100644 index 87e276b1..00000000 --- a/vendor/github.com/coredns/coredns/Gopkg.lock +++ /dev/null @@ -1,565 +0,0 @@ -# This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'. - - -[[projects]] - name = "github.com/DataDog/dd-trace-go" - packages = [ - "opentracing", - "tracer", - "tracer/ext" - ] - revision = "27617015d45e6cd550b9a7ac7715c37cc2f7d020" - version = "v0.6.1" - -[[projects]] - name = "github.com/Shopify/sarama" - packages = ["."] - revision = "f7be6aa2bc7b2e38edf816b08b582782194a1c02" - version = "v1.16.0" - -[[projects]] - name = "github.com/apache/thrift" - packages = ["lib/go/thrift"] - revision = "e59b73d3c2bf1c328ccb78e683c0462fa1a473c7" - -[[projects]] - name = "github.com/aws/aws-sdk-go" - packages = [ - "aws", - "aws/awserr", - "aws/awsutil", - "aws/client", - "aws/client/metadata", - "aws/corehandlers", - "aws/credentials", - "aws/credentials/ec2rolecreds", - "aws/credentials/endpointcreds", - "aws/credentials/stscreds", - "aws/defaults", - "aws/ec2metadata", - "aws/endpoints", - "aws/request", - "aws/session", - "aws/signer/v4", - "internal/sdkio", - "internal/sdkrand", - "internal/shareddefaults", - "private/protocol", - "private/protocol/query", - "private/protocol/query/queryutil", - "private/protocol/rest", - "private/protocol/restxml", - "private/protocol/xml/xmlutil", - "service/route53", - "service/route53/route53iface", - "service/sts" - ] - revision = "ee7b4b1162937cba700de23bd90acb742982e626" - version = "v1.13.50" - -[[projects]] - name = "github.com/coreos/etcd" - packages = [ - "client", - "pkg/pathutil", - "pkg/srv", - "pkg/types", - "version" - ] - revision = "70c8726202dd91e482fb4029fd14af1d4ed1d5af" - version = "v3.3.5" - -[[projects]] - name = "github.com/coreos/go-semver" - packages = ["semver"] - revision = "8ab6407b697782a06568d4b7f1db25550ec2e4c6" - version = "v0.2.0" - -[[projects]] - name = "github.com/davecgh/go-spew" - packages = ["spew"] - revision = "346938d642f2ec3594ed81d874461961cd0faa76" - version = "v1.1.0" - -[[projects]] - branch = "master" - name = "github.com/dnstap/golang-dnstap" - packages = ["."] - revision = "2cf77a2b5e11ac8d0ba3892772ac8e1f7b528344" - -[[projects]] - name = "github.com/eapache/go-resiliency" - packages = ["breaker"] - revision = "ea41b0fad31007accc7f806884dcdf3da98b79ce" - version = "v1.1.0" - -[[projects]] - branch = "master" - name = "github.com/eapache/go-xerial-snappy" - packages = ["."] - revision = "bb955e01b9346ac19dc29eb16586c90ded99a98c" - -[[projects]] - name = "github.com/eapache/queue" - packages = ["."] - revision = "44cc805cf13205b55f69e14bcb69867d1ae92f98" - version = "v1.1.0" - -[[projects]] - branch = "master" - name = "github.com/farsightsec/golang-framestream" - packages = ["."] - revision = "c06a5734334d9629b3db143d74b47eb94ea68612" - -[[projects]] - name = "github.com/ghodss/yaml" - packages = ["."] - revision = "0ca9ea5df5451ffdf184b4428c902747c2c11cd7" - version = "v1.0.0" - -[[projects]] - name = "github.com/go-ini/ini" - packages = ["."] - revision = "6529cf7c58879c08d927016dde4477f18a0634cb" - version = "v1.36.0" - -[[projects]] - name = "github.com/go-logfmt/logfmt" - packages = ["."] - revision = "390ab7935ee28ec6b286364bba9b4dd6410cb3d5" - version = "v0.3.0" - -[[projects]] - name = "github.com/gogo/protobuf" - packages = [ - "proto", - "sortkeys" - ] - revision = "1adfc126b41513cc696b209667c8656ea7aac67c" - version = "v1.0.0" - -[[projects]] - branch = "master" - name = "github.com/golang/glog" - packages = ["."] - revision = "23def4e6c14b4da8ac2ed8007337bc5eb5007998" - -[[projects]] - name = "github.com/golang/protobuf" - packages = [ - "proto", - "ptypes", - "ptypes/any", - "ptypes/duration", - "ptypes/timestamp" - ] - revision = "b4deda0973fb4c70b50d226b1af49f3da59f5265" - version = "v1.1.0" - -[[projects]] - branch = "master" - name = "github.com/golang/snappy" - packages = ["."] - revision = "553a641470496b2327abcac10b36396bd98e45c9" - -[[projects]] - branch = "master" - name = "github.com/google/gofuzz" - packages = ["."] - revision = "24818f796faf91cd76ec7bddd72458fbced7a6c1" - -[[projects]] - name = "github.com/googleapis/gnostic" - packages = [ - "OpenAPIv2", - "compiler", - "extensions" - ] - revision = "ee43cbb60db7bd22502942cccbc39059117352ab" - version = "v0.1.0" - -[[projects]] - branch = "master" - name = "github.com/grpc-ecosystem/grpc-opentracing" - packages = ["go/otgrpc"] - revision = "8e809c8a86450a29b90dcc9efbf062d0fe6d9746" - -[[projects]] - branch = "master" - name = "github.com/hashicorp/golang-lru" - packages = [ - ".", - "simplelru" - ] - revision = "0fb14efe8c47ae851c0034ed7a448854d3d34cf3" - -[[projects]] - branch = "master" - name = "github.com/howeyc/gopass" - packages = ["."] - revision = "bf9dde6d0d2c004a008c27aaee91170c786f6db8" - -[[projects]] - name = "github.com/imdario/mergo" - packages = ["."] - revision = "9d5f1277e9a8ed20c3684bda8fde67c05628518c" - version = "v0.3.4" - -[[projects]] - name = "github.com/jmespath/go-jmespath" - packages = ["."] - revision = "0b12d6b5" - -[[projects]] - name = "github.com/json-iterator/go" - packages = ["."] - revision = "ca39e5af3ece67bbcda3d0f4f56a8e24d9f2dad4" - version = "1.1.3" - -[[projects]] - branch = "master" - name = "github.com/kr/logfmt" - packages = ["."] - revision = "b84e30acd515aadc4b783ad4ff83aff3299bdfe0" - -[[projects]] - name = "github.com/matttproud/golang_protobuf_extensions" - packages = ["pbutil"] - revision = "3247c84500bff8d9fb6d579d800f20b3e091582c" - version = "v1.0.0" - -[[projects]] - name = "github.com/modern-go/concurrent" - packages = ["."] - revision = "bacd9c7ef1dd9b15be4a9909b8ac7a4e313eec94" - version = "1.0.3" - -[[projects]] - name = "github.com/modern-go/reflect2" - packages = ["."] - revision = "1df9eeb2bb81f327b96228865c5687bc2194af3f" - version = "1.0.0" - -[[projects]] - branch = "master" - name = "github.com/opentracing-contrib/go-observer" - packages = ["."] - revision = "a52f2342449246d5bcc273e65cbdcfa5f7d6c63c" - -[[projects]] - name = "github.com/opentracing/opentracing-go" - packages = [ - ".", - "ext", - "log" - ] - revision = "1949ddbfd147afd4d964a9f00b24eb291e0e7c38" - version = "v1.0.2" - -[[projects]] - name = "github.com/openzipkin/zipkin-go-opentracing" - packages = [ - ".", - "flag", - "thrift/gen-go/scribe", - "thrift/gen-go/zipkincore", - "types", - "wire" - ] - revision = "26cf9707480e6b90e5eff22cf0bbf05319154232" - version = "v0.3.4" - -[[projects]] - name = "github.com/pierrec/lz4" - packages = ["."] - revision = "2fcda4cb7018ce05a25959d2fe08c83e3329f169" - version = "v1.1" - -[[projects]] - name = "github.com/pierrec/xxHash" - packages = ["xxHash32"] - revision = "f051bb7f1d1aaf1b5a665d74fb6b0217712c69f7" - version = "v0.1.1" - -[[projects]] - branch = "master" - name = "github.com/prometheus/client_model" - packages = ["go"] - revision = "99fa1f4be8e564e8a6b613da7fa6f46c9edafc6c" - -[[projects]] - branch = "master" - name = "github.com/prometheus/common" - packages = [ - "expfmt", - "internal/bitbucket.org/ww/goautoneg", - "model" - ] - revision = "d811d2e9bf898806ecfb6ef6296774b13ffc314c" - -[[projects]] - branch = "master" - name = "github.com/rcrowley/go-metrics" - packages = ["."] - revision = "e2704e165165ec55d062f5919b4b29494e9fa790" - -[[projects]] - name = "github.com/spf13/pflag" - packages = ["."] - revision = "583c0c0531f06d5278b7d917446061adc344b5cd" - version = "v1.0.1" - -[[projects]] - name = "github.com/ugorji/go" - packages = ["codec"] - revision = "f3cacc17c85ecb7f1b6a9e373ee85d1480919868" - -[[projects]] - branch = "master" - name = "golang.org/x/crypto" - packages = ["ssh/terminal"] - revision = "1a580b3eff7814fc9b40602fd35256c63b50f491" - -[[projects]] - branch = "master" - name = "golang.org/x/net" - packages = [ - "context", - "http/httpguts", - "http2", - "http2/hpack", - "idna", - "internal/timeseries", - "trace" - ] - revision = "2491c5de3490fced2f6cff376127c667efeed857" - -[[projects]] - branch = "master" - name = "golang.org/x/sys" - packages = [ - "unix", - "windows" - ] - revision = "7c87d13f8e835d2fb3a70a2912c811ed0c1d241b" - -[[projects]] - name = "golang.org/x/text" - packages = [ - "collate", - "collate/build", - "internal/colltab", - "internal/gen", - "internal/tag", - "internal/triegen", - "internal/ucd", - "language", - "secure/bidirule", - "transform", - "unicode/bidi", - "unicode/cldr", - "unicode/norm", - "unicode/rangetable" - ] - revision = "f21a4dfb5e38f5895301dc265a8def02365cc3d0" - version = "v0.3.0" - -[[projects]] - branch = "master" - name = "golang.org/x/time" - packages = ["rate"] - revision = "fbb02b2291d28baffd63558aa44b4b56f178d650" - -[[projects]] - branch = "master" - name = "google.golang.org/genproto" - packages = ["googleapis/rpc/status"] - revision = "7bb2a897381c9c5ab2aeb8614f758d7766af68ff" - -[[projects]] - name = "google.golang.org/grpc" - packages = [ - ".", - "balancer", - "balancer/base", - "balancer/roundrobin", - "channelz", - "codes", - "connectivity", - "credentials", - "encoding", - "encoding/proto", - "grpclb/grpc_lb_v1/messages", - "grpclog", - "internal", - "keepalive", - "metadata", - "naming", - "peer", - "resolver", - "resolver/dns", - "resolver/passthrough", - "stats", - "status", - "tap", - "transport" - ] - revision = "41344da2231b913fa3d983840a57a6b1b7b631a1" - version = "v1.12.0" - -[[projects]] - name = "gopkg.in/inf.v0" - packages = ["."] - revision = "d2d2541c53f18d2a059457998ce2876cc8e67cbf" - version = "v0.9.1" - -[[projects]] - name = "gopkg.in/yaml.v2" - packages = ["."] - revision = "5420a8b6744d3b0345ab293f6fcba19c978f1183" - version = "v2.2.1" - -[[projects]] - name = "k8s.io/api" - packages = [ - "admissionregistration/v1alpha1", - "admissionregistration/v1beta1", - "apps/v1", - "apps/v1beta1", - "apps/v1beta2", - "authentication/v1", - "authentication/v1beta1", - "authorization/v1", - "authorization/v1beta1", - "autoscaling/v1", - "autoscaling/v2beta1", - "batch/v1", - "batch/v1beta1", - "batch/v2alpha1", - "certificates/v1beta1", - "core/v1", - "events/v1beta1", - "extensions/v1beta1", - "networking/v1", - "policy/v1beta1", - "rbac/v1", - "rbac/v1alpha1", - "rbac/v1beta1", - "scheduling/v1alpha1", - "settings/v1alpha1", - "storage/v1", - "storage/v1alpha1", - "storage/v1beta1" - ] - revision = "73d903622b7391f3312dcbac6483fed484e185f8" - -[[projects]] - name = "k8s.io/apimachinery" - packages = [ - "pkg/api/errors", - "pkg/api/meta", - "pkg/api/resource", - "pkg/apis/meta/internalversion", - "pkg/apis/meta/v1", - "pkg/apis/meta/v1/unstructured", - "pkg/apis/meta/v1beta1", - "pkg/conversion", - "pkg/conversion/queryparams", - "pkg/fields", - "pkg/labels", - "pkg/runtime", - "pkg/runtime/schema", - "pkg/runtime/serializer", - "pkg/runtime/serializer/json", - "pkg/runtime/serializer/protobuf", - "pkg/runtime/serializer/recognizer", - "pkg/runtime/serializer/streaming", - "pkg/runtime/serializer/versioning", - "pkg/selection", - "pkg/types", - "pkg/util/cache", - "pkg/util/clock", - "pkg/util/diff", - "pkg/util/errors", - "pkg/util/framer", - "pkg/util/intstr", - "pkg/util/json", - "pkg/util/net", - "pkg/util/runtime", - "pkg/util/sets", - "pkg/util/validation", - "pkg/util/validation/field", - "pkg/util/wait", - "pkg/util/yaml", - "pkg/version", - "pkg/watch", - "third_party/forked/golang/reflect" - ] - revision = "302974c03f7e50f16561ba237db776ab93594ef6" - -[[projects]] - name = "k8s.io/client-go" - packages = [ - "discovery", - "kubernetes", - "kubernetes/scheme", - "kubernetes/typed/admissionregistration/v1alpha1", - "kubernetes/typed/admissionregistration/v1beta1", - "kubernetes/typed/apps/v1", - "kubernetes/typed/apps/v1beta1", - "kubernetes/typed/apps/v1beta2", - "kubernetes/typed/authentication/v1", - "kubernetes/typed/authentication/v1beta1", - "kubernetes/typed/authorization/v1", - "kubernetes/typed/authorization/v1beta1", - "kubernetes/typed/autoscaling/v1", - "kubernetes/typed/autoscaling/v2beta1", - "kubernetes/typed/batch/v1", - "kubernetes/typed/batch/v1beta1", - "kubernetes/typed/batch/v2alpha1", - "kubernetes/typed/certificates/v1beta1", - "kubernetes/typed/core/v1", - "kubernetes/typed/events/v1beta1", - "kubernetes/typed/extensions/v1beta1", - "kubernetes/typed/networking/v1", - "kubernetes/typed/policy/v1beta1", - "kubernetes/typed/rbac/v1", - "kubernetes/typed/rbac/v1alpha1", - "kubernetes/typed/rbac/v1beta1", - "kubernetes/typed/scheduling/v1alpha1", - "kubernetes/typed/settings/v1alpha1", - "kubernetes/typed/storage/v1", - "kubernetes/typed/storage/v1alpha1", - "kubernetes/typed/storage/v1beta1", - "pkg/apis/clientauthentication", - "pkg/apis/clientauthentication/v1alpha1", - "pkg/version", - "plugin/pkg/client/auth/exec", - "rest", - "rest/watch", - "tools/auth", - "tools/cache", - "tools/clientcmd", - "tools/clientcmd/api", - "tools/clientcmd/api/latest", - "tools/clientcmd/api/v1", - "tools/metrics", - "tools/pager", - "tools/reference", - "transport", - "util/buffer", - "util/cert", - "util/flowcontrol", - "util/homedir", - "util/integer", - "util/retry" - ] - revision = "23781f4d6632d88e869066eaebb743857aa1ef9b" - version = "v7.0.0" - -[solve-meta] - analyzer-name = "dep" - analyzer-version = 1 - inputs-digest = "dbbdcbcd4c0e11f040230e43a145f113ed7e67ff2c52b2a5830e117c16a23630" - solver-name = "gps-cdcl" - solver-version = 1 diff --git a/vendor/github.com/coredns/coredns/Gopkg.toml b/vendor/github.com/coredns/coredns/Gopkg.toml deleted file mode 100644 index 5f0b19e6..00000000 --- a/vendor/github.com/coredns/coredns/Gopkg.toml +++ /dev/null @@ -1,28 +0,0 @@ -ignored = [ - "github.com/mholt/caddy", - "github.com/mholt/caddy/caddyfile", - "github.com/mholt/caddy/startupshutdown", - "github.com/mholt/caddy/onevent", - "github.com/miekg/dns", - "github.com/prometheus/client_golang/prometheus", - "github.com/prometheus/client_golang/prometheus/promhttp", -] - -# client-go 6.0.0 uses apimachinery 180eddb345a5be3a157cea1c624700ad5bd27b8f -# and api 11147472b7c934c474a2c484af3c0c5210b7a3af (see Godep.json). go dep -# is unable to match Godep.json automatically so have to specify here. -[[constraint]] - name = "k8s.io/client-go" - version = "v7.0.0" -[[override]] - name = "k8s.io/apimachinery" - revision = "302974c03f7e50f16561ba237db776ab93594ef6" -[[override]] - name = "k8s.io/api" - revision = "73d903622b7391f3312dcbac6483fed484e185f8" -[[override]] - name = "github.com/apache/thrift" - revision = "e59b73d3c2bf1c328ccb78e683c0462fa1a473c7" -[[override]] - name = "github.com/ugorji/go" - revision = "f3cacc17c85ecb7f1b6a9e373ee85d1480919868" diff --git a/vendor/github.com/coredns/coredns/Makefile b/vendor/github.com/coredns/coredns/Makefile deleted file mode 100644 index e7b09895..00000000 --- a/vendor/github.com/coredns/coredns/Makefile +++ /dev/null @@ -1,100 +0,0 @@ -# Makefile for building CoreDNS -GITCOMMIT:=$(shell git describe --dirty --always) -BINARY:=coredns -SYSTEM:= -CHECKS:=check godeps -VERBOSE:=-v -GOPATH?=$(HOME)/go -PRESUBMIT:=core coremain plugin test request - -all: coredns - -.PHONY: coredns -coredns: $(CHECKS) - CGO_ENABLED=0 $(SYSTEM) go build $(VERBOSE) -ldflags="-s -w -X github.com/coredns/coredns/coremain.GitCommit=$(GITCOMMIT)" -o $(BINARY) - -.PHONY: check -check: presubmit goimports core/zplugin.go core/dnsserver/zdirectives.go godeps linter - -.PHONY: test -test: check - go test -race $(VERBOSE) ./test ./plugin/... - -.PHONY: testk8s -testk8s: check - go test -race $(VERBOSE) -tags=k8s -run 'TestKubernetes' ./test ./plugin/kubernetes/... - -.PHONY: godeps -godeps: - # Not vendored so external plugin compile, avoiding: - # cannot use c (type *"github.com/mholt/caddy".Controller) as type - # *"github.com/coredns/coredns/vendor/github.com/mholt/caddy".Controller like errors. - (cd $(GOPATH)/src/github.com/mholt/caddy 2>/dev/null && git checkout -q master 2>/dev/null || true) - (cd $(GOPATH)/src/github.com/miekg/dns 2>/dev/null && git checkout -q master 2>/dev/null || true) - (cd $(GOPATH)/src/github.com/prometheus/client_golang 2>/dev/null && git checkout -q master 2>/dev/null || true) - go get -u github.com/mholt/caddy - go get -u github.com/miekg/dns - go get -u github.com/prometheus/client_golang/prometheus/promhttp - go get -u github.com/prometheus/client_golang/prometheus - (cd $(GOPATH)/src/github.com/mholt/caddy && git checkout -q v0.10.11) - (cd $(GOPATH)/src/github.com/miekg/dns && git checkout -q v1.0.8) - (cd $(GOPATH)/src/github.com/prometheus/client_golang && git checkout -q v0.8.0) - -.PHONY: travis -travis: check -ifeq ($(TEST_TYPE),core) - ( cd request ; go test -v -tags 'etcd' -race ./... ) - ( cd core ; go test -v -tags 'etcd' -race ./... ) - ( cd coremain go test -v -tags 'etcd' -race ./... ) -endif -ifeq ($(TEST_TYPE),integration) - ( cd test ; go test -v -tags 'etcd' -race ./... ) -endif -ifeq ($(TEST_TYPE),plugin) - ( cd plugin ; go test -v -tags 'etcd' -race ./... ) -endif -ifeq ($(TEST_TYPE),coverage) - for d in `go list ./... | grep -v vendor`; do \ - t=$$(date +%s); \ - go test -i -tags 'etcd' -coverprofile=cover.out -covermode=atomic $$d || exit 1; \ - go test -v -tags 'etcd' -coverprofile=cover.out -covermode=atomic $$d || exit 1; \ - echo "Coverage test $$d took $$(($$(date +%s)-t)) seconds"; \ - if [ -f cover.out ]; then \ - cat cover.out >> coverage.txt; \ - rm cover.out; \ - fi; \ - done -endif - -core/zplugin.go core/dnsserver/zdirectives.go: plugin.cfg - go generate coredns.go - -.PHONY: gen -gen: - go generate coredns.go - -.PHONY: pb -pb: - $(MAKE) -C pb - -.PHONY: linter -linter: - go get -u github.com/alecthomas/gometalinter - gometalinter --install golint - gometalinter --deadline=2m --disable-all --enable=gofmt --enable=golint --enable=vet --vendor --exclude=^pb/ ./... - -.PHONY: goimports -goimports: - go get -u github.com/alecthomas/gometalinter - gometalinter --install goimports - ( gometalinter --deadline=2m --disable-all --enable=goimports --vendor --exclude=^pb/ ./... || true ) - -# Presubmit runs all scripts in .presubmit; any non 0 exit code will fail the build. -.PHONY: presubmit -presubmit: - @for pre in $(PWD)/.presubmit/* ; do "$$pre" $(PRESUBMIT); done - -.PHONY: clean -clean: - go clean - rm -f coredns diff --git a/vendor/github.com/coredns/coredns/Makefile.doc b/vendor/github.com/coredns/coredns/Makefile.doc deleted file mode 100644 index dd2aac58..00000000 --- a/vendor/github.com/coredns/coredns/Makefile.doc +++ /dev/null @@ -1,41 +0,0 @@ -ORG:=organization=CoreDNS -RONN:=ronn -r -PLUGINS:=$(wildcard plugin/*/README.md) -READMES:=$(subst plugin/,,$(PLUGINS)) -READMES:=$(subst /README.md,,$(READMES)) -PLUGINS:=$(subst plugin/,coredns-,$(PLUGINS)) -PLUGINS:=$(subst /README.md,(7),$(PLUGINS)) - -ifeq (, $(shell which ronn)) - $(warning "No ronn in $$PATH, exiting") -all: - @echo "noop" -else -all: man/coredns.1 man/corefile.5 plugins -endif - -man/coredns.1: coredns.1.md - sed -e 's/^\(#.*\)/\U\1/' $< > $@.md - sed -i -e "s/@@PLUGINS@@/$(PLUGINS)/" $@.md - $(RONN) --$(ORG) --manual='CoreDNS' $@.md - rm $@.md - -man/corefile.5: corefile.5.md - sed -e 's/^\(#.*\)/\U\1/' $< > $@.md - $(RONN) --$(ORG) --manual='CoreDNS' $@.md - rm $@.md - -.PHONY: plugins -plugins: - for README in $(READMES); do \ - $(MAKE) -f Makefile.doc man/coredns-$$README.7; \ - done - -man/coredns-%.7: plugin/%/README.md - sed -e 's/^\(#.*\)/\U\1/' $< > $@.md - $(RONN) --$(ORG) --manual='CoreDNS plugins' $@.md - rm $@.md - -PHONY: clean -clean: - rm -f man/* diff --git a/vendor/github.com/coredns/coredns/Makefile.fuzz b/vendor/github.com/coredns/coredns/Makefile.fuzz deleted file mode 100644 index 2a97d67f..00000000 --- a/vendor/github.com/coredns/coredns/Makefile.fuzz +++ /dev/null @@ -1,33 +0,0 @@ -# Makefile for fuzzing -# -# Use go-fuzz and needs the tools installed. For each fuzz.go in a plugin's directory -# you can start the fuzzing with: make -f Makefile.fuzz -# e.g. -# -# make -f Makefile.fuzz proxy -# -# Each plugin that wants to join the fuzzing fray only needs to add a fuzz.go that calls -# the plugins's ServeDNS and used the plugin/pkg/fuzz for the Do function. -# -# Installing go-fuzz -#$ go get github.com/dvyukov/go-fuzz/go-fuzz -#$ go get github.com/dvyukov/go-fuzz/go-fuzz-build - -REPO:="github.com/coredns/coredns/plugin" - -FUZZ:=$(dir $(wildcard plugin/*/fuzz.go)) # plugin/cache/ -PLUGINS:=$(foreach f,$(FUZZ),$(subst plugin, ,$(f:/=))) # > /cache -PLUGINS:=$(foreach f,$(PLUGINS),$(subst /, ,$(f))) # > cache - -.PHONY: echo -echo: - @echo fuzz targets: $(PLUGINS) - -.PHONY: $(PLUGINS) -$(PLUGINS): echo - go-fuzz-build -tags fuzz $(REPO)/$(@) - go-fuzz -bin=./$(@)-fuzz.zip -workdir=fuzz/$(@) - -.PHONY: clean -clean: - rm *-fuzz.zip diff --git a/vendor/github.com/coredns/coredns/Makefile.release b/vendor/github.com/coredns/coredns/Makefile.release deleted file mode 100644 index e046c379..00000000 --- a/vendor/github.com/coredns/coredns/Makefile.release +++ /dev/null @@ -1,151 +0,0 @@ -# Makefile for releasing CoreDNS -# -# The release is controlled from coremain/version.go. The version found there is -# used to tag the git repo and to build the assets that are uploaded to github -# (after some sanity checks). -# -# The release should be accompanied by release notes published on coredns.io. -# For example: https://coredns.io/2016/09/18/coredns-001-release/ Also send an -# email to coredns-discuss@ to announce the new version. -# -# We use https://github.com/progrium/gh-release to automate github stuff be sure -# to have that binary in your path. -# -# Get a list of authors for this release with: -# -# git log --pretty=format:'%an' v001..master | sort -u (where v001 is the -# previous release, obviously you'll need to adjust this) -# -# Steps: -# -# * Get an access token: https://help.github.com/articles/creating-an-access-token-for-command-line-use/ -# * export GITHUB_ACCESS_TOKEN= -# * Up the version in coremain/version.go -# * Run: make DOCKER=coredns -f Makefile.release release -# * runs make -f Makefile.doc -# * this is a noop if ronn can't be found -# * perform a go generate -# * will *commit* your change(s) with 'Release $VERSION' -# * push to github -# * build the release and do all that fluff. -# -# Steps for docker: -# -# * Login into docker: docker login (should have push creds for coredns registry) -# * We use the manifest-tool from https://github.com/estesp/manifest-tool to build the manifest list -# * Make sure you have the binary in your path. -# -# * Run: make DOCKER=coredns -f Makefile.release docker -# -# Docker push should happen after you make the new release and uploaded it to Github. -# -# If you want to push to a personal registry, point DOCKER to something else, i.e. -# -# * make DOCKER=miek -f Makefile.release docker -EMPTY:= -SPACE:=$(EMPTY) $(EMPTY) -COMMA:=$(EMPTY),$(EMPTY) - -ifeq (, $(shell which gh-release)) - $(error "No gh-release in $$PATH, install with: go get github.com/progrium/gh-release") -endif - -ifeq (, $(shell which manifest-tool)) - $(error "No manifest-tool in $$PATH, install with: go get github.com/estesp/manifest-tool") -endif - -DOCKER:= -NAME:=coredns -VERSION:=$(shell grep 'CoreVersion' coremain/version.go | awk '{ print $$3 }' | tr -d '"') -GITHUB:=coredns -DOCKER_IMAGE_NAME:=$(DOCKER)/$(NAME) -GITCOMMIT:=$(shell git describe --dirty --always) -LINUX_ARCH:=amd64 arm arm64 ppc64le s390x -PLATFORMS:=$(subst $(SPACE),$(COMMA),$(foreach arch,$(LINUX_ARCH),linux/$(arch))) - -ifeq ($(DOCKER),) - $(error "Please specify Docker registry to use. Use DOCKER=coredns for releases") -endif - -all: - @echo Use the 'release' target to start a release - -release: pre commit push build tar upload - -docker: docker-build docker-push - -.PHONY: pre -pre: - go generate - $(MAKE) -f Makefile.doc - -.PHONY: push -push: - @echo Pushing release to master - git push - -.PHONY: commit -commit: - @echo Committing - git commit -am"Release $(VERSION)" - -.PHONY: build -build: - @echo Cleaning old builds - @rm -rf build && mkdir build - @echo Building: darwin $(VERSION) - mkdir -p build/darwin/amd64 && $(MAKE) coredns BINARY=build/darwin/amd64/$(NAME) SYSTEM="GOOS=darwin GOARCH=amd64" CHECKS="godeps" VERBOSE="" - @echo Building: windows $(VERSION) - mkdir -p build/windows/amd64 && $(MAKE) coredns BINARY=build/windows/amd64/$(NAME) SYSTEM="GOOS=windows GOARCH=amd64" CHECKS="godeps" VERBOSE="" - @echo Building: linux/$(LINUX_ARCH) $(VERSION) ;\ - for arch in $(LINUX_ARCH); do \ - mkdir -p build/linux/$$arch && $(MAKE) coredns BINARY=build/linux/$$arch/$(NAME) SYSTEM="GOOS=linux GOARCH=$$arch" CHECKS="godeps" VERBOSE="" ;\ - done - -.PHONY: tar -tar: - @echo Cleaning old releases - @rm -rf release && mkdir release - tar -zcf release/$(NAME)_$(VERSION)_darwin_amd64.tgz -C build/darwin/amd64 $(NAME) - tar -zcf release/$(NAME)_$(VERSION)_windows_amd64.tgz -C build/windows/amd64 $(NAME) - for arch in $(LINUX_ARCH); do \ - tar -zcf release/$(NAME)_$(VERSION)_linux_$$arch.tgz -C build/linux/$$arch $(NAME) ;\ - done - -.PHONY: upload -upload: - @echo Releasing: $(VERSION) - gh-release create $(GITHUB)/$(NAME) $(VERSION) - -.PHONY: docker-build -docker-build: tar - # Steps: - # 1. Copy appropriate coredns binary to build/docker/linux/ - # 2. Copy Dockerfile to build/docker/linux/ - # 3. Replace base image from alpine:latest to /alpine:latest - # 4. Comment RUN in Dockerfile - # : - # arm: arm32v6 - # arm64: arm64v8 - rm -rf build/docker - for arch in $(LINUX_ARCH); do \ - mkdir -p build/docker/linux/$$arch ;\ - tar -xzf release/$(NAME)_$(VERSION)_linux_$$arch.tgz -C build/docker/linux/$$arch ;\ - cp Dockerfile build/docker/linux/$$arch ;\ - docker build -t coredns build/docker/linux/$$arch ;\ - docker tag coredns $(DOCKER_IMAGE_NAME):coredns-$$arch ;\ - done - -.PHONY: docker-push -docker-push: - @echo Pushing: $(VERSION) to $(DOCKER_IMAGE_NAME) - for arch in $(LINUX_ARCH); do \ - docker push $(DOCKER_IMAGE_NAME):coredns-$$arch ;\ - done - manifest-tool push from-args --platforms $(PLATFORMS) --template $(DOCKER_IMAGE_NAME):coredns-ARCH --target $(DOCKER_IMAGE_NAME):$(VERSION) - manifest-tool push from-args --platforms $(PLATFORMS) --template $(DOCKER_IMAGE_NAME):coredns-ARCH --target $(DOCKER_IMAGE_NAME):latest - -.PHONY: clean -clean: - rm -rf release - rm -rf build diff --git a/vendor/github.com/coredns/coredns/OWNERS b/vendor/github.com/coredns/coredns/OWNERS deleted file mode 100644 index 24c52b0f..00000000 --- a/vendor/github.com/coredns/coredns/OWNERS +++ /dev/null @@ -1,33 +0,0 @@ -reviewers: - - bradbeam - - chrisohaver - - fastest963 - - fturib - - greenpau - - grobie - - isolus - - johnbelamaric - - miekg - - pmoroney - - rajansandeep - - stp-ip - - superq - - varyoo - - yongtang - -approvers: - - chrisohaver - - johnbelamaric - - miekg - - yongtang - -features: - - comments - - reviewers - - aliases - - branches - -aliases: - - | - /plugin: (.*) -> /label add: plugin/$1 - diff --git a/vendor/github.com/coredns/coredns/README.md b/vendor/github.com/coredns/coredns/README.md deleted file mode 100644 index 21781acf..00000000 --- a/vendor/github.com/coredns/coredns/README.md +++ /dev/null @@ -1,200 +0,0 @@ -[![CoreDNS](https://coredns.io/images/CoreDNS_Colour_Horizontal.png)](https://coredns.io) - -[![Documentation](https://img.shields.io/badge/godoc-reference-blue.svg)](https://godoc.org/github.com/coredns/coredns) -[![Build Status](https://img.shields.io/travis/coredns/coredns/master.svg?label=build)](https://travis-ci.org/coredns/coredns) -[![Code Coverage](https://img.shields.io/codecov/c/github/coredns/coredns/master.svg)](https://codecov.io/github/coredns/coredns?branch=master) -[![Docker Pulls](https://img.shields.io/docker/pulls/coredns/coredns.svg)](https://hub.docker.com/r/coredns/coredns) -[![Go Report Card](https://goreportcard.com/badge/github.com/coredns/coredns)](https://goreportcard.com/report/coredns/coredns) -[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bhttps%3A%2F%2Fgithub.com%2Fcoredns%2Fcoredns.svg?type=shield)](https://app.fossa.io/projects/git%2Bhttps%3A%2F%2Fgithub.com%2Fcoredns%2Fcoredns?ref=badge_shield) -[![CII Best Practices](https://bestpractices.coreinfrastructure.org/projects/1250/badge)](https://bestpractices.coreinfrastructure.org/projects/1250) - -CoreDNS (written in Go) chains [plugins](https://coredns.io/plugins). Each plugin performs a DNS -function. - -CoreDNS is a [Cloud Native Computing Foundation](https://cncf.io) incubating level project. - -CoreDNS is a fast and flexible DNS server. The keyword here is *flexible*: with CoreDNS you -are able to do what you want with your DNS data by utilizing plugins. If some functionality is not -provided out of the box you can add it by [writing a plugin](https://coredns.io/explugins). - -CoreDNS can listen for DNS request coming in over UDP/TCP (go'old DNS), TLS ([RFC -7858](https://tools.ietf.org/html/rfc7858)) and [gRPC](https://grpc.io) (not a standard). - -Currently CoreDNS is able to: - -* Serve zone data from a file; both DNSSEC (NSEC only) and DNS are supported (*file*). -* Retrieve zone data from primaries, i.e., act as a secondary server (AXFR only) (*secondary*). -* Sign zone data on-the-fly (*dnssec*). -* Load balancing of responses (*loadbalance*). -* Allow for zone transfers, i.e., act as a primary server (*file*). -* Automatically load zone files from disk (*auto*). -* Caching (*cache*). -* Use etcd as a backend (replace [SkyDNS](https://github.com/skynetservices/skydns)) (*etcd*). -* Use k8s (kubernetes) as a backend (*kubernetes*). -* Serve as a proxy to forward queries to some other (recursive) nameserver (*proxy*, and *forward*). -* Provide metrics (by using Prometheus) (*metrics*). -* Provide query (*log*) and error (*error*) logging. -* Support the CH class: `version.bind` and friends (*chaos*). -* Support the RFC 5001 DNS name server identifier (NSID) option (*nsid*). -* Profiling support (*pprof*). -* Rewrite queries (qtype, qclass and qname) (*rewrite* and *template*). - -And more. Each of the plugins is documented. See [coredns.io/plugins](https://coredns.io/plugins) -for all in-tree plugins, and [coredns.io/explugins](https://coredns.io/explugins) for all -out-of-tree plugins. - -## Compilation from Source - -Check out the project and do dependency resolution with: - -~~~ -% go get github.com/coredns/coredns -~~~ - -Some of the dependencies require Go version 1.9 or later. - -We vendor most (not all!) packages. Building from scratch is easiest, by just using `make`: - -~~~ -% make -~~~ - -This should yield a `coredns` binary. - -## Compilation with Docker - -CoreDNS requires Go to compile. However, if you already have docker installed and prefer not to setup -a Go environment, you could build CoreDNS easily: - -``` -$ docker run --rm -i -t -v $PWD:/go/src/github.com/coredns/coredns \ - -w /go/src/github.com/coredns/coredns golang:1.10 make -``` - -The above command alone will have `coredns` binary generated. - -## Examples - -When starting CoreDNS without any configuration, it loads the -[*whoami*](https://coredns.io/plugins/whoami) plugin and starts listening on port 53 (override with -`-dns.port`), it should show the following: - -~~~ txt -.:53 -2016/09/18 09:20:50 [INFO] CoreDNS-001 -CoreDNS-001 -~~~ - -Any query send to port 53 should return some information; your sending address, port and protocol -used. - -If you have a Corefile without a port number specified it will, by default, use port 53, but you -can override the port with the `-dns.port` flag: - -`./coredns -dns.port 1053`, runs the server on port 1053. - -Start a simple proxy, you'll need to be root to start listening on port 53. - -`Corefile` contains: - -~~~ corefile -.:53 { - forward . 8.8.8.8:53 - log -} -~~~ - -Just start CoreDNS: `./coredns`. Then just query on that port (53). The query should be forwarded to -8.8.8.8 and the response will be returned. Each query should also show up in the log which is -printed on standard output. - -Serve the (NSEC) DNSSEC-signed `example.org` on port 1053, with errors and logging sent to standard -output. Allow zone transfers to everybody, but specifically mention 1 IP address so that CoreDNS can -send notifies to it. - -~~~ txt -example.org:1053 { - file /var/lib/coredns/example.org.signed { - transfer to * - transfer to 2001:500:8f::53 - } - errors - log -} -~~~ - -Serve `example.org` on port 1053, but forward everything that does *not* match `example.org` to a recursive -nameserver *and* rewrite ANY queries to HINFO. - -~~~ txt -.:1053 { - rewrite ANY HINFO - forward . 8.8.8.8:53 - - file /var/lib/coredns/example.org.signed example.org { - transfer to * - transfer to 2001:500:8f::53 - } - errors - log -} -~~~ - -IP addresses are also allowed. They are automatically converted to reverse zones: - -~~~ corefile -10.0.0.0/24 { - whoami -} -~~~ -Means you are authoritative for `0.0.10.in-addr.arpa.`. - -This also works for IPv6 addresses. If for some reason you want to serve a zone named `10.0.0.0/24` -add the closing dot: `10.0.0.0/24.` as this also stops the conversion. - -This even works for CIDR (See RFC 1518 and 1519) addressing, i.e. `10.0.0.0/25`, CoreDNS will then -check if the `in-addr` request falls in the correct range. - -Listening on TLS and for gRPC? Use: - -~~~ corefile -tls://example.org grpc://example.org { - whoami -} -~~~ - -Specifying ports works in the same way: - -~~~ txt -grpc://example.org:1443 { - # ... -} -~~~ - -When no transport protocol is specified the default `dns://` is assumed. - -## Community - -We're most active on Slack (and Github): - -- Slack: #coredns on -- Github: - -More resources can be found: - -- Website: -- Blog: -- Twitter: [@corednsio](https://twitter.com/corednsio) -- Mailing list/group: - -## Deployment - -Examples for deployment via systemd and other use cases can be found in the -[deployment repository](https://github.com/coredns/deployment). - -## Security - -If you find a security vulnerability or any security related issues, -please DO NOT file a public issue, instead send your report privately to -`security@coredns.io`. Security reports are greatly appreciated and we -will publicly thank you for it. diff --git a/vendor/github.com/coredns/coredns/core/coredns.go b/vendor/github.com/coredns/coredns/core/coredns.go deleted file mode 100644 index 0ff1dc95..00000000 --- a/vendor/github.com/coredns/coredns/core/coredns.go +++ /dev/null @@ -1,7 +0,0 @@ -// Package core registers the server and all plugins we support. -package core - -import ( - // plug in the server - _ "github.com/coredns/coredns/core/dnsserver" -) diff --git a/vendor/github.com/coredns/coredns/core/dnsserver/address_test.go b/vendor/github.com/coredns/coredns/core/dnsserver/address_test.go deleted file mode 100644 index 137bc8e4..00000000 --- a/vendor/github.com/coredns/coredns/core/dnsserver/address_test.go +++ /dev/null @@ -1,179 +0,0 @@ -package dnsserver - -import "testing" - -func TestNormalizeZone(t *testing.T) { - for i, test := range []struct { - input string - expected string - shouldErr bool - }{ - {".", "dns://.:53", false}, - {".:54", "dns://.:54", false}, - {"..", "://:", true}, - {"..", "://:", true}, - {".:", "://:", true}, - } { - addr, err := normalizeZone(test.input) - actual := addr.String() - if test.shouldErr && err == nil { - t.Errorf("Test %d: Expected error, but there wasn't any", i) - } - if !test.shouldErr && err != nil { - t.Errorf("Test %d: Expected no error, but there was one: %v", i, err) - } - if actual != test.expected { - t.Errorf("Test %d: Expected %s but got %s", i, test.expected, actual) - } - } -} - -func TestNormalizeZoneReverse(t *testing.T) { - for i, test := range []struct { - input string - expected string - shouldErr bool - }{ - {"2003::1/64", "dns://0.0.0.0.0.0.0.0.0.0.0.0.3.0.0.2.ip6.arpa.:53", false}, - {"2003::1/64.", "dns://2003::1/64.:53", false}, // OK, with closing dot the parse will fail. - {"2003::1/64:53", "dns://0.0.0.0.0.0.0.0.0.0.0.0.3.0.0.2.ip6.arpa.:53", false}, - {"2003::1/64.:53", "dns://2003::1/64.:53", false}, - - {"10.0.0.0/24", "dns://0.0.10.in-addr.arpa.:53", false}, - {"10.0.0.0/24.", "dns://10.0.0.0/24.:53", false}, - {"10.0.0.0/24:53", "dns://0.0.10.in-addr.arpa.:53", false}, - {"10.0.0.0/24.:53", "dns://10.0.0.0/24.:53", false}, - - // non %8==0 netmasks - {"2003::53/67", "dns://0.0.0.0.0.0.0.0.0.0.0.0.0.3.0.0.2.ip6.arpa.:53", false}, - {"10.0.0.0/25.", "dns://10.0.0.0/25.:53", false}, // has dot - {"10.0.0.0/25", "dns://0.0.10.in-addr.arpa.:53", false}, - {"fd00:77:30::0/110", "dns://0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.3.0.0.7.7.0.0.0.0.d.f.ip6.arpa.:53", false}, - } { - addr, err := normalizeZone(test.input) - actual := addr.String() - if test.shouldErr && err == nil { - t.Errorf("Test %d: Expected error, but there wasn't any", i) - } - if !test.shouldErr && err != nil { - t.Errorf("Test %d: Expected no error, but there was one: %v", i, err) - } - if actual != test.expected { - t.Errorf("Test %d: Expected %s but got %s", i, test.expected, actual) - } - } -} - -func TestSplitProtocolHostPort(t *testing.T) { - for i, test := range []struct { - input string - proto string - ip string - port string - shouldErr bool - }{ - {"dns://:53", "dns", "", "53", false}, - {"dns://127.0.0.1:4005", "dns", "127.0.0.1", "4005", false}, - {"[ffe0:34ab:1]:4005", "", "ffe0:34ab:1", "4005", false}, - - // port part is mandatory - {"dns://", "dns", "", "", true}, - {"dns://127.0.0.1", "dns", "127.0.0.1", "", true}, - // cannot be empty - {"", "", "", "", true}, - // invalid format with twice :// - {"dns://127.0.0.1://53", "", "", "", true}, - } { - proto, ip, port, err := SplitProtocolHostPort(test.input) - if test.shouldErr && err == nil { - t.Errorf("Test %d: (address = %s) expected error, but there wasn't any", i, test.input) - continue - } - if !test.shouldErr && err != nil { - t.Errorf("Test %d: (address = %s) expected no error, but there was one: %v", i, test.input, err) - continue - } - if err == nil || test.shouldErr { - continue - } - if proto != test.proto { - t.Errorf("Test %d: (address = %s) expected protocol with value %s but got %s", i, test.input, test.proto, proto) - } - if ip != test.ip { - t.Errorf("Test %d: (address = %s) expected ip with value %s but got %s", i, test.input, test.ip, ip) - } - if port != test.port { - t.Errorf("Test %d: (address = %s) expected port with value %s but got %s", i, test.input, test.port, port) - } - - } -} - -type checkCall struct { - zone zoneAddr - same bool - overlap bool - overlapKey string -} - -type checkTest struct { - sequence []checkCall -} - -func TestOverlapAddressChecker(t *testing.T) { - for i, test := range []checkTest{ - {sequence: []checkCall{ - {zoneAddr{Transport: "dns", Zone: ".", Address: "", Port: "53"}, false, false, ""}, - {zoneAddr{Transport: "dns", Zone: ".", Address: "", Port: "53"}, true, false, ""}, - }, - }, - {sequence: []checkCall{ - {zoneAddr{Transport: "dns", Zone: ".", Address: "", Port: "53"}, false, false, ""}, - {zoneAddr{Transport: "dns", Zone: ".", Address: "", Port: "54"}, false, false, ""}, - {zoneAddr{Transport: "dns", Zone: ".", Address: "127.0.0.1", Port: "53"}, false, true, "dns://.:53"}, - }, - }, - {sequence: []checkCall{ - {zoneAddr{Transport: "dns", Zone: ".", Address: "127.0.0.1", Port: "53"}, false, false, ""}, - {zoneAddr{Transport: "dns", Zone: ".", Address: "", Port: "54"}, false, false, ""}, - {zoneAddr{Transport: "dns", Zone: ".", Address: "127.0.0.1", Port: "53"}, true, false, ""}, - }, - }, - {sequence: []checkCall{ - {zoneAddr{Transport: "dns", Zone: ".", Address: "127.0.0.1", Port: "53"}, false, false, ""}, - {zoneAddr{Transport: "dns", Zone: ".", Address: "", Port: "54"}, false, false, ""}, - {zoneAddr{Transport: "dns", Zone: ".", Address: "128.0.0.1", Port: "53"}, false, false, ""}, - {zoneAddr{Transport: "dns", Zone: ".", Address: "129.0.0.1", Port: "53"}, false, false, ""}, - {zoneAddr{Transport: "dns", Zone: ".", Address: "", Port: "53"}, false, true, "dns://.:53 on 129.0.0.1"}, - }, - }, - {sequence: []checkCall{ - {zoneAddr{Transport: "dns", Zone: ".", Address: "127.0.0.1", Port: "53"}, false, false, ""}, - {zoneAddr{Transport: "dns", Zone: "com.", Address: "127.0.0.1", Port: "53"}, false, false, ""}, - {zoneAddr{Transport: "dns", Zone: "com.", Address: "", Port: "53"}, false, true, "dns://com.:53 on 127.0.0.1"}, - }, - }, - } { - - checker := newOverlapZone() - for _, call := range test.sequence { - same, overlap := checker.registerAndCheck(call.zone) - sZone := call.zone.String() - if (same != nil) != call.same { - t.Errorf("Test %d: error, for zone %s, 'same' (%v) has not the expected value (%v)", i, sZone, same != nil, call.same) - } - if same == nil { - if (overlap != nil) != call.overlap { - t.Errorf("Test %d: error, for zone %s, 'overlap' (%v) has not the expected value (%v)", i, sZone, overlap != nil, call.overlap) - } - if overlap != nil { - if overlap.String() != call.overlapKey { - t.Errorf("Test %d: error, for zone %s, 'overlap Key' (%v) has not the expected value (%v)", i, sZone, overlap.String(), call.overlapKey) - } - - } - } - - } - } -} diff --git a/vendor/github.com/coredns/coredns/core/dnsserver/https.go b/vendor/github.com/coredns/coredns/core/dnsserver/https.go index 915d366c..53212457 100644 --- a/vendor/github.com/coredns/coredns/core/dnsserver/https.go +++ b/vendor/github.com/coredns/coredns/core/dnsserver/https.go @@ -1,62 +1,11 @@ package dnsserver import ( - "encoding/base64" - "fmt" - "io/ioutil" "net" - "net/http" "github.com/coredns/coredns/plugin/pkg/nonwriter" - "github.com/miekg/dns" ) -// mimeTypeDOH is the DoH mimetype that should be used. -const mimeTypeDOH = "application/dns-message" - -// pathDOH is the URL path that should be used. -const pathDOH = "/dns-query" - -// postRequestToMsg extracts the dns message from the request body. -func postRequestToMsg(req *http.Request) (*dns.Msg, error) { - defer req.Body.Close() - - buf, err := ioutil.ReadAll(req.Body) - if err != nil { - return nil, err - } - m := new(dns.Msg) - err = m.Unpack(buf) - return m, err -} - -// getRequestToMsg extract the dns message from the GET request. -func getRequestToMsg(req *http.Request) (*dns.Msg, error) { - values := req.URL.Query() - b64, ok := values["dns"] - if !ok { - return nil, fmt.Errorf("no 'dns' query parameter found") - } - if len(b64) != 1 { - return nil, fmt.Errorf("multiple 'dns' query values found") - } - return base64ToMsg(b64[0]) -} - -func base64ToMsg(b64 string) (*dns.Msg, error) { - buf, err := b64Enc.DecodeString(b64) - if err != nil { - return nil, err - } - - m := new(dns.Msg) - err = m.Unpack(buf) - - return m, err -} - -var b64Enc = base64.RawURLEncoding - // DoHWriter is a nonwriter.Writer that adds more specific LocalAddr and RemoteAddr methods. type DoHWriter struct { nonwriter.Writer diff --git a/vendor/github.com/coredns/coredns/core/dnsserver/https_test.go b/vendor/github.com/coredns/coredns/core/dnsserver/https_test.go deleted file mode 100644 index a0ddc4b2..00000000 --- a/vendor/github.com/coredns/coredns/core/dnsserver/https_test.go +++ /dev/null @@ -1,66 +0,0 @@ -package dnsserver - -import ( - "bytes" - "encoding/base64" - "net/http" - "testing" - - "github.com/miekg/dns" -) - -func TestPostRequest(t *testing.T) { - const ex = "example.org." - - m := new(dns.Msg) - m.SetQuestion(ex, dns.TypeDNSKEY) - - out, _ := m.Pack() - req, err := http.NewRequest(http.MethodPost, "https://"+ex+pathDOH+"?bla=foo:443", bytes.NewReader(out)) - if err != nil { - t.Errorf("Failure to make request: %s", err) - } - req.Header.Set("content-type", mimeTypeDOH) - req.Header.Set("accept", mimeTypeDOH) - - m, err = postRequestToMsg(req) - if err != nil { - t.Fatalf("Failure to get message from request: %s", err) - } - - if x := m.Question[0].Name; x != ex { - t.Errorf("Qname expected %s, got %s", ex, x) - } - if x := m.Question[0].Qtype; x != dns.TypeDNSKEY { - t.Errorf("Qname expected %d, got %d", x, dns.TypeDNSKEY) - } -} - -func TestGetRequest(t *testing.T) { - const ex = "example.org." - - m := new(dns.Msg) - m.SetQuestion(ex, dns.TypeDNSKEY) - - out, _ := m.Pack() - b64 := base64.RawURLEncoding.EncodeToString(out) - - req, err := http.NewRequest(http.MethodGet, "https://"+ex+pathDOH+"?dns="+b64, nil) - if err != nil { - t.Errorf("Failure to make request: %s", err) - } - req.Header.Set("content-type", mimeTypeDOH) - req.Header.Set("accept", mimeTypeDOH) - - m, err = getRequestToMsg(req) - if err != nil { - t.Fatalf("Failure to get message from request: %s", err) - } - - if x := m.Question[0].Name; x != ex { - t.Errorf("Qname expected %s, got %s", ex, x) - } - if x := m.Question[0].Qtype; x != dns.TypeDNSKEY { - t.Errorf("Qname expected %d, got %d", x, dns.TypeDNSKEY) - } -} diff --git a/vendor/github.com/coredns/coredns/core/dnsserver/register_test.go b/vendor/github.com/coredns/coredns/core/dnsserver/register_test.go deleted file mode 100644 index a2d24e1d..00000000 --- a/vendor/github.com/coredns/coredns/core/dnsserver/register_test.go +++ /dev/null @@ -1,121 +0,0 @@ -package dnsserver - -import ( - "testing" -) - -func TestHandler(t *testing.T) { - tp := testPlugin{} - c := testConfig("dns", tp) - if _, err := NewServer("127.0.0.1:53", []*Config{c}); err != nil { - t.Errorf("Expected no error for NewServer, got %s", err) - } - if h := c.Handler("testplugin"); h != tp { - t.Errorf("Expected testPlugin from Handler, got %T", h) - } - if h := c.Handler("nothing"); h != nil { - t.Errorf("Expected nil from Handler, got %T", h) - } -} - -func TestHandlers(t *testing.T) { - tp := testPlugin{} - c := testConfig("dns", tp) - if _, err := NewServer("127.0.0.1:53", []*Config{c}); err != nil { - t.Errorf("Expected no error for NewServer, got %s", err) - } - hs := c.Handlers() - if len(hs) != 1 || hs[0] != tp { - t.Errorf("Expected [testPlugin] from Handlers, got %v", hs) - } -} - -func TestGroupingServers(t *testing.T) { - for i, test := range []struct { - configs []*Config - expectedGroups []string - failing bool - }{ - // single config -> one group - {configs: []*Config{ - {Transport: "dns", Zone: ".", Port: "53", ListenHosts: []string{""}}, - }, - expectedGroups: []string{"dns://:53"}, - failing: false}, - - // 2 configs on different port -> 2 groups - {configs: []*Config{ - {Transport: "dns", Zone: ".", Port: "53", ListenHosts: []string{""}}, - {Transport: "dns", Zone: ".", Port: "54", ListenHosts: []string{""}}, - }, - expectedGroups: []string{"dns://:53", "dns://:54"}, - failing: false}, - - // 2 configs on same port, both not using bind, diff zones -> 1 group - {configs: []*Config{ - {Transport: "dns", Zone: ".", Port: "53", ListenHosts: []string{""}}, - {Transport: "dns", Zone: "com.", Port: "53", ListenHosts: []string{""}}, - }, - expectedGroups: []string{"dns://:53"}, - failing: false}, - - // 2 configs on same port, one addressed - one not using bind, diff zones -> 1 group - {configs: []*Config{ - {Transport: "dns", Zone: ".", Port: "53", ListenHosts: []string{"127.0.0.1"}}, - {Transport: "dns", Zone: ".", Port: "54", ListenHosts: []string{""}}, - }, - expectedGroups: []string{"dns://127.0.0.1:53", "dns://:54"}, - failing: false}, - - // 2 configs on diff ports, 3 different address, diff zones -> 3 group - {configs: []*Config{ - {Transport: "dns", Zone: ".", Port: "53", ListenHosts: []string{"127.0.0.1", "::1"}}, - {Transport: "dns", Zone: ".", Port: "54", ListenHosts: []string{""}}}, - expectedGroups: []string{"dns://127.0.0.1:53", "dns://[::1]:53", "dns://:54"}, - failing: false}, - - // 2 configs on same port, same address, diff zones -> 1 group - {configs: []*Config{ - {Transport: "dns", Zone: ".", Port: "53", ListenHosts: []string{"127.0.0.1", "::1"}}, - {Transport: "dns", Zone: "com.", Port: "53", ListenHosts: []string{"127.0.0.1", "::1"}}, - }, - expectedGroups: []string{"dns://127.0.0.1:53", "dns://[::1]:53"}, - failing: false}, - - // 2 configs on same port, total 2 diff addresses, diff zones -> 2 groups - {configs: []*Config{ - {Transport: "dns", Zone: ".", Port: "53", ListenHosts: []string{"127.0.0.1"}}, - {Transport: "dns", Zone: "com.", Port: "53", ListenHosts: []string{"::1"}}, - }, - expectedGroups: []string{"dns://127.0.0.1:53", "dns://[::1]:53"}, - failing: false}, - - // 2 configs on same port, total 3 diff addresses, diff zones -> 3 groups - {configs: []*Config{ - {Transport: "dns", Zone: ".", Port: "53", ListenHosts: []string{"127.0.0.1", "::1"}}, - {Transport: "dns", Zone: "com.", Port: "53", ListenHosts: []string{""}}}, - expectedGroups: []string{"dns://127.0.0.1:53", "dns://[::1]:53", "dns://:53"}, - failing: false}, - } { - groups, err := groupConfigsByListenAddr(test.configs) - if err != nil { - if !test.failing { - t.Fatalf("Test %d, expected no errors, but got: %v", i, err) - } - continue - } - if test.failing { - t.Fatalf("Test %d, expected to failed but did not, returned values", i) - } - if len(groups) != len(test.expectedGroups) { - t.Errorf("Test %d : expected the group's size to be %d, was %d", i, len(test.expectedGroups), len(groups)) - continue - } - for _, v := range test.expectedGroups { - if _, ok := groups[v]; !ok { - t.Errorf("Test %d : expected value %v to be in the group, was not", i, v) - - } - } - } -} diff --git a/vendor/github.com/coredns/coredns/core/dnsserver/server_grpc.go b/vendor/github.com/coredns/coredns/core/dnsserver/server_grpc.go index 7b3df647..e5b87749 100644 --- a/vendor/github.com/coredns/coredns/core/dnsserver/server_grpc.go +++ b/vendor/github.com/coredns/coredns/core/dnsserver/server_grpc.go @@ -7,13 +7,14 @@ import ( "fmt" "net" + "github.com/coredns/coredns/pb" + "github.com/coredns/coredns/plugin/pkg/watch" + "github.com/grpc-ecosystem/grpc-opentracing/go/otgrpc" "github.com/miekg/dns" "github.com/opentracing/opentracing-go" "google.golang.org/grpc" "google.golang.org/grpc/peer" - - "github.com/coredns/coredns/pb" ) // ServergRPC represents an instance of a DNS-over-gRPC server. @@ -22,6 +23,7 @@ type ServergRPC struct { grpcServer *grpc.Server listenAddr net.Addr tlsConfig *tls.Config + watch watch.Watcher } // NewServergRPC returns a new CoreDNS GRPC server and compiles all plugin in to it. @@ -38,7 +40,7 @@ func NewServergRPC(addr string, group []*Config) (*ServergRPC, error) { tlsConfig = conf.TLSConfig } - return &ServergRPC{Server: s, tlsConfig: tlsConfig}, nil + return &ServergRPC{Server: s, tlsConfig: tlsConfig, watch: watch.NewWatcher(watchables(s.zones))}, nil } // Serve implements caddy.TCPServer interface. @@ -100,6 +102,9 @@ func (s *ServergRPC) OnStartupComplete() { func (s *ServergRPC) Stop() (err error) { s.m.Lock() defer s.m.Unlock() + if s.watch != nil { + s.watch.Stop() + } if s.grpcServer != nil { s.grpcServer.GracefulStop() } @@ -138,6 +143,12 @@ func (s *ServergRPC) Query(ctx context.Context, in *pb.DnsPacket) (*pb.DnsPacket return &pb.DnsPacket{Msg: packed}, nil } +// Watch is the entrypoint called by the gRPC layer when the user asks +// to watch a query. +func (s *ServergRPC) Watch(stream pb.DnsService_WatchServer) error { + return s.watch.Watch(stream) +} + // Shutdown stops the server (non gracefully). func (s *ServergRPC) Shutdown() error { if s.grpcServer != nil { diff --git a/vendor/github.com/coredns/coredns/core/dnsserver/server_https.go b/vendor/github.com/coredns/coredns/core/dnsserver/server_https.go index c9f0da0c..9b1eaaa7 100644 --- a/vendor/github.com/coredns/coredns/core/dnsserver/server_https.go +++ b/vendor/github.com/coredns/coredns/core/dnsserver/server_https.go @@ -7,8 +7,11 @@ import ( "net" "net/http" "strconv" + "time" - "github.com/miekg/dns" + "github.com/coredns/coredns/plugin/pkg/dnsutil" + "github.com/coredns/coredns/plugin/pkg/doh" + "github.com/coredns/coredns/plugin/pkg/response" ) // ServerHTTPS represents an instance of a DNS-over-HTTPS server. @@ -95,24 +98,12 @@ func (s *ServerHTTPS) Stop() error { // chain, converts it back and write it to the client. func (s *ServerHTTPS) ServeHTTP(w http.ResponseWriter, r *http.Request) { - msg := new(dns.Msg) - var err error - - if r.URL.Path != pathDOH { + if r.URL.Path != doh.Path { http.Error(w, "", http.StatusNotFound) return } - switch r.Method { - case http.MethodPost: - msg, err = postRequestToMsg(r) - case http.MethodGet: - msg, err = getRequestToMsg(r) - default: - http.Error(w, "", http.StatusMethodNotAllowed) - return - } - + msg, err := doh.RequestToMsg(r) if err != nil { http.Error(w, err.Error(), http.StatusBadRequest) return @@ -129,8 +120,11 @@ func (s *ServerHTTPS) ServeHTTP(w http.ResponseWriter, r *http.Request) { buf, _ := dw.Msg.Pack() - w.Header().Set("Content-Type", mimeTypeDOH) - w.Header().Set("Cache-Control", "max-age=128") // TODO(issues/1823): implement proper fix. + mt, _ := response.Typify(dw.Msg, time.Now().UTC()) + age := dnsutil.MinimalTTL(dw.Msg, mt) + + w.Header().Set("Content-Type", doh.MimeType) + w.Header().Set("Cache-Control", fmt.Sprintf("max-age=%f", age.Seconds())) w.Header().Set("Content-Length", strconv.Itoa(len(buf))) w.WriteHeader(http.StatusOK) diff --git a/vendor/github.com/coredns/coredns/core/dnsserver/server_test.go b/vendor/github.com/coredns/coredns/core/dnsserver/server_test.go deleted file mode 100644 index 56a1e0dc..00000000 --- a/vendor/github.com/coredns/coredns/core/dnsserver/server_test.go +++ /dev/null @@ -1,82 +0,0 @@ -package dnsserver - -import ( - "context" - "testing" - - "github.com/coredns/coredns/plugin" - "github.com/coredns/coredns/plugin/test" - - "github.com/miekg/dns" -) - -type testPlugin struct{} - -func (tp testPlugin) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (int, error) { - return 0, nil -} - -func (tp testPlugin) Name() string { return "testplugin" } - -func testConfig(transport string, p plugin.Handler) *Config { - c := &Config{ - Zone: "example.com.", - Transport: transport, - ListenHosts: []string{"127.0.0.1"}, - Port: "53", - Debug: false, - } - - c.AddPlugin(func(next plugin.Handler) plugin.Handler { return p }) - return c -} - -func TestNewServer(t *testing.T) { - _, err := NewServer("127.0.0.1:53", []*Config{testConfig("dns", testPlugin{})}) - if err != nil { - t.Errorf("Expected no error for NewServer, got %s", err) - } - - _, err = NewServergRPC("127.0.0.1:53", []*Config{testConfig("grpc", testPlugin{})}) - if err != nil { - t.Errorf("Expected no error for NewServergRPC, got %s", err) - } - - _, err = NewServerTLS("127.0.0.1:53", []*Config{testConfig("tls", testPlugin{})}) - if err != nil { - t.Errorf("Expected no error for NewServerTLS, got %s", err) - } -} - -func TestIncrementDepthAndCheck(t *testing.T) { - ctx := context.Background() - var err error - for i := 0; i <= maxreentries; i++ { - ctx, err = incrementDepthAndCheck(ctx) - if err != nil { - t.Errorf("Expected no error for depthCheck (i=%v), got %s", i, err) - } - } - _, err = incrementDepthAndCheck(ctx) - if err == nil { - t.Errorf("Expected error for depthCheck (i=%v)", maxreentries+1) - } -} - -func BenchmarkCoreServeDNS(b *testing.B) { - s, err := NewServer("127.0.0.1:53", []*Config{testConfig("dns", testPlugin{})}) - if err != nil { - b.Errorf("Expected no error for NewServer, got %s", err) - } - - ctx := context.TODO() - w := &test.ResponseWriter{} - m := new(dns.Msg) - m.SetQuestion("aaa.example.com.", dns.TypeTXT) - - b.ReportAllocs() - b.ResetTimer() - for i := 0; i < b.N; i++ { - s.ServeDNS(ctx, w, m) - } -} diff --git a/vendor/github.com/coredns/coredns/core/dnsserver/watch.go b/vendor/github.com/coredns/coredns/core/dnsserver/watch.go new file mode 100644 index 00000000..590bac14 --- /dev/null +++ b/vendor/github.com/coredns/coredns/core/dnsserver/watch.go @@ -0,0 +1,18 @@ +package dnsserver + +import ( + "github.com/coredns/coredns/plugin/pkg/watch" +) + +func watchables(zones map[string]*Config) []watch.Watchable { + var w []watch.Watchable + for _, config := range zones { + plugins := config.Handlers() + for _, p := range plugins { + if x, ok := p.(watch.Watchable); ok { + w = append(w, x) + } + } + } + return w +} diff --git a/vendor/github.com/coredns/coredns/core/dnsserver/zdirectives.go b/vendor/github.com/coredns/coredns/core/dnsserver/zdirectives.go index 046600c5..280c0314 100644 --- a/vendor/github.com/coredns/coredns/core/dnsserver/zdirectives.go +++ b/vendor/github.com/coredns/coredns/core/dnsserver/zdirectives.go @@ -10,6 +10,7 @@ package dnsserver // (after) them during a request, but they must not // care what plugin above them are doing. var Directives = []string{ + "metadata", "tls", "reload", "nsid", @@ -29,7 +30,6 @@ var Directives = []string{ "rewrite", "dnssec", "autopath", - "reverse", "template", "hosts", "route53", @@ -39,6 +39,7 @@ var Directives = []string{ "auto", "secondary", "etcd", + "loop", "forward", "proxy", "erratic", diff --git a/vendor/github.com/coredns/coredns/core/plugin/zplugin.go b/vendor/github.com/coredns/coredns/core/plugin/zplugin.go deleted file mode 100644 index d1c0aaa7..00000000 --- a/vendor/github.com/coredns/coredns/core/plugin/zplugin.go +++ /dev/null @@ -1,41 +0,0 @@ -// generated by directives_generate.go; DO NOT EDIT - -package plugin - -import ( - // Include all plugins. - _ "github.com/coredns/coredns/plugin/auto" - _ "github.com/coredns/coredns/plugin/autopath" - _ "github.com/coredns/coredns/plugin/bind" - _ "github.com/coredns/coredns/plugin/cache" - _ "github.com/coredns/coredns/plugin/chaos" - _ "github.com/coredns/coredns/plugin/debug" - _ "github.com/coredns/coredns/plugin/deprecated" - _ "github.com/coredns/coredns/plugin/dnssec" - _ "github.com/coredns/coredns/plugin/dnstap" - _ "github.com/coredns/coredns/plugin/erratic" - _ "github.com/coredns/coredns/plugin/errors" - _ "github.com/coredns/coredns/plugin/etcd" - _ "github.com/coredns/coredns/plugin/federation" - _ "github.com/coredns/coredns/plugin/file" - _ "github.com/coredns/coredns/plugin/forward" - _ "github.com/coredns/coredns/plugin/health" - _ "github.com/coredns/coredns/plugin/hosts" - _ "github.com/coredns/coredns/plugin/kubernetes" - _ "github.com/coredns/coredns/plugin/loadbalance" - _ "github.com/coredns/coredns/plugin/log" - _ "github.com/coredns/coredns/plugin/metrics" - _ "github.com/coredns/coredns/plugin/nsid" - _ "github.com/coredns/coredns/plugin/pprof" - _ "github.com/coredns/coredns/plugin/proxy" - _ "github.com/coredns/coredns/plugin/reload" - _ "github.com/coredns/coredns/plugin/rewrite" - _ "github.com/coredns/coredns/plugin/root" - _ "github.com/coredns/coredns/plugin/route53" - _ "github.com/coredns/coredns/plugin/secondary" - _ "github.com/coredns/coredns/plugin/template" - _ "github.com/coredns/coredns/plugin/tls" - _ "github.com/coredns/coredns/plugin/trace" - _ "github.com/coredns/coredns/plugin/whoami" - _ "github.com/mholt/caddy/onevent" -) diff --git a/vendor/github.com/coredns/coredns/coredns.1.md b/vendor/github.com/coredns/coredns/coredns.1.md deleted file mode 100644 index f89c0ed5..00000000 --- a/vendor/github.com/coredns/coredns/coredns.1.md +++ /dev/null @@ -1,54 +0,0 @@ -## Name - -*coredns* - plugable DNS nameserver optimized for service discovery and flexibility. - -## Synopsis - -*coredns* *[OPTION]*... - -## Description - -CoreDNS is a DNS server that chains plugins. Each plugin handles a DNS feature, like rewriting -queries, kubernetes service discovery or just exporting metrics. There are many other plugins, -each described on and there respective manual pages. Plugins not -bundled in CoreDNS are listed on . - -When started with no options CoreDNS will looks for a file names `Corefile` in the current -directory, if found it will parse its contents and start up accordingly. If no `Corefile` is found -it will start with the *whoami* plugin (coredns-whoami(7)) and start listening on port 53 (unless -overriden with `-dns.port`). - -Available options: - -**-conf** **FILE** -: specificy Corefile to load. - -**-cpu** **CAP** -: specify maximum CPU capacity in percent. - -**-dns.port** **PORT** -: override default port (53) to listen on. - -**-pidfile** **FILE** -: write PID to **FILE**. - -**-plugins** -: list all plugins and quit. - -**-quiet** -: don't print any version and port information on startup. - -**-version** -: show version and quit. - -## Authors - -CoreDNS Authors. - -## Copyright - -Apache License 2.0 - -## See Also - -Corefile(5) @@PLUGINS@@. diff --git a/vendor/github.com/coredns/coredns/coredns.go b/vendor/github.com/coredns/coredns/coredns.go deleted file mode 100644 index 5b3fa2b8..00000000 --- a/vendor/github.com/coredns/coredns/coredns.go +++ /dev/null @@ -1,14 +0,0 @@ -package main - -//go:generate go run directives_generate.go - -import ( - "github.com/coredns/coredns/coremain" - - // Plug in CoreDNS - _ "github.com/coredns/coredns/core/plugin" -) - -func main() { - coremain.Run() -} diff --git a/vendor/github.com/coredns/coredns/corefile.5.md b/vendor/github.com/coredns/coredns/corefile.5.md deleted file mode 100644 index 3976c1e9..00000000 --- a/vendor/github.com/coredns/coredns/corefile.5.md +++ /dev/null @@ -1,115 +0,0 @@ -## Name - -*corefile* - configuration file for CoreDNS - -## Description - -A *corefile* specifies the (internal) servers CoreDNS should run and what plugins each of these -should chain. The syntax is as follows: - -~~~ txt -[SCHEME://]ZONE [[SCHEME://]ZONE]...[:PORT] { - [PLUGIN]... -} -~~~ - -The **ZONE** defines for which name this server should be called, multiple zones are allowed and -should be *white space* separated. You can use a "reverse" syntax to specify a reverse zone (i.e. -ip6.arpa and in-addr.arpa), but using an IP address in the CIDR notation. The optional **SCHEME** -defaults to `dns://`, but can also be `tls://` (DNS over TLS) or `grpc://` (DNS over gRPC). - -Specifying a **ZONE** *and* **PORT** combination multiple time for *different* servers will lead to -an error on startup. - -When a query comes in it is matched again all zones for all servers, the server with the longest -match on the query name will receive the query. - -The optional **PORT** controls on which port the server will bind, this default to 53. If you use -a port number here, you *can't* override it with `-dns.port` (coredns(1)). - -**PLUGIN** defines the plugin(s) we want to load into this server. This is optional as well, but as -server with no plugins will just return SERVFAIL for all queries. Each plugin can have a number of -properties than can have arguments, see documentation for each plugin. - -Comments begin with an unquoted hash `#` and continue to the end of the line. Comments may be -started anywhere on a line. - -Enviroment variables are supported and either the Unix or Windows form may be used: `{$ENV_VAR_1}` -or `{%ENV_VAR_2%}`. - -You can use the `import` "plugin" to include parts of other files, see . - -If CoreDNS can’t find a Corefile to load it loads the following builtin one: - -~~~ Corefile -. { - whoami -} -~~~ - -## Examples - -The **ZONE** is root zone `.`, the **PLUGIN** is chaos. The chaos plugin takes an argument: -`CoreDNS-001`. This text is returned on a CH class query: `dig CH txt version.bind @localhost`. - -~~~ Corefile -. { - chaos CoreDNS-001 -} -~~~ - -When defining a new zone, you either create a new server, or add it to an existing one. Here we -define one server that handles two zones; that potentially chain different plugins: - -~~~ Corefile -example.org { - whoami -} -org { - whoami -} -~~~ - -Is identical to: - -~~~ Corefile -example.org org { - whoami -} -~~~ - -Reverse zones can be specified as domain names: - -~~~ Corefile -0.0.10.in-addr.arpa { - whoami -} -~~~ - -or by just using the CIDR notation: - -~~~ Corefile -10.0.0.0/24 { - whoami -} -~~~ - -This also works on a non octet boundary: - -~~~ Corefile -10.0.0.0/27 { - whoami -} -~~~ - -## Authors - -CoreDNS Authors. - -## Copyright - -Apache License 2.0 - -## See Also - -The manual page for CoreDNS: coredns(1) and more documentation on . diff --git a/vendor/github.com/coredns/coredns/coremain/run.go b/vendor/github.com/coredns/coredns/coremain/run.go index a948a4c9..98eaa5ba 100644 --- a/vendor/github.com/coredns/coredns/coremain/run.go +++ b/vendor/github.com/coredns/coredns/coremain/run.go @@ -29,7 +29,6 @@ func init() { flag.StringVar(&caddy.PidFile, "pidfile", "", "Path to write pid file") flag.BoolVar(&version, "version", false, "Show version") flag.BoolVar(&dnsserver.Quiet, "quiet", false, "Quiet mode (no initialization output)") - flag.BoolVar(&logfile, "log", false, "Log to standard output") // noop for 1.1.4; drop in 1.2.0. caddy.RegisterCaddyfileLoader("flag", caddy.LoaderFunc(confLoader)) caddy.SetDefaultCaddyfileLoader("default", caddy.LoaderFunc(defaultLoader)) diff --git a/vendor/github.com/coredns/coredns/coremain/run_test.go b/vendor/github.com/coredns/coredns/coremain/run_test.go deleted file mode 100644 index da01637d..00000000 --- a/vendor/github.com/coredns/coredns/coremain/run_test.go +++ /dev/null @@ -1,44 +0,0 @@ -package coremain - -import ( - "runtime" - "testing" -) - -func TestSetCPU(t *testing.T) { - currentCPU := runtime.GOMAXPROCS(-1) - maxCPU := runtime.NumCPU() - halfCPU := int(0.5 * float32(maxCPU)) - if halfCPU < 1 { - halfCPU = 1 - } - for i, test := range []struct { - input string - output int - shouldErr bool - }{ - {"1", 1, false}, - {"-1", currentCPU, true}, - {"0", currentCPU, true}, - {"100%", maxCPU, false}, - {"50%", halfCPU, false}, - {"110%", currentCPU, true}, - {"-10%", currentCPU, true}, - {"invalid input", currentCPU, true}, - {"invalid input%", currentCPU, true}, - {"9999", maxCPU, false}, // over available CPU - } { - err := setCPU(test.input) - if test.shouldErr && err == nil { - t.Errorf("Test %d: Expected error, but there wasn't any", i) - } - if !test.shouldErr && err != nil { - t.Errorf("Test %d: Expected no error, but there was one: %v", i, err) - } - if actual, expected := runtime.GOMAXPROCS(-1), test.output; actual != expected { - t.Errorf("Test %d: GOMAXPROCS was %d but expected %d", i, actual, expected) - } - // teardown - runtime.GOMAXPROCS(currentCPU) - } -} diff --git a/vendor/github.com/coredns/coredns/coremain/version.go b/vendor/github.com/coredns/coredns/coremain/version.go index e881d867..7e73e5ad 100644 --- a/vendor/github.com/coredns/coredns/coremain/version.go +++ b/vendor/github.com/coredns/coredns/coremain/version.go @@ -2,7 +2,7 @@ package coremain // Various CoreDNS constants. const ( - CoreVersion = "1.1.4" + CoreVersion = "1.2.0" coreName = "CoreDNS" serverType = "dns" ) diff --git a/vendor/github.com/coredns/coredns/directives_generate.go b/vendor/github.com/coredns/coredns/directives_generate.go deleted file mode 100644 index 3c1c0214..00000000 --- a/vendor/github.com/coredns/coredns/directives_generate.go +++ /dev/null @@ -1,115 +0,0 @@ -//+build ignore - -package main - -import ( - "bufio" - "go/format" - "io/ioutil" - "log" - "os" - "strings" -) - -func main() { - mi := make(map[string]string, 0) - md := []string{} - - file, err := os.Open(pluginFile) - if err != nil { - log.Fatalf("Failed to open %s: %q", pluginFile, err) - } - - defer file.Close() - - scanner := bufio.NewScanner(file) - for scanner.Scan() { - line := scanner.Text() - if strings.HasPrefix(line, "#") { - continue - } - - items := strings.Split(line, ":") - if len(items) != 2 { - // ignore empty lines - continue - } - name, repo := items[0], items[1] - - if _, ok := mi[name]; ok { - log.Fatalf("Duplicate entry %q", name) - } - - md = append(md, name) - mi[name] = pluginPath + repo // Default, unless overridden by 3rd arg - - if _, err := os.Stat(pluginFSPath + repo); err != nil { // External package has been given - mi[name] = repo - } - } - - genImports("core/plugin/zplugin.go", "plugin", mi) - genDirectives("core/dnsserver/zdirectives.go", "dnsserver", md) -} - -func genImports(file, pack string, mi map[string]string) { - outs := header + "package " + pack + "\n\n" + "import (" - - if len(mi) > 0 { - outs += "\n" - } - - outs += "// Include all plugins.\n" - for _, v := range mi { - outs += `_ "` + v + `"` + "\n" - } - outs += ")\n" - - if err := formatAndWrite(file, outs); err != nil { - log.Fatalf("Failed to format and write: %q", err) - } -} - -func genDirectives(file, pack string, md []string) { - - outs := header + "package " + pack + "\n\n" - outs += ` -// Directives are registered in the order they should be -// executed. -// -// Ordering is VERY important. Every plugin will -// feel the effects of all other plugin below -// (after) them during a request, but they must not -// care what plugin above them are doing. -var Directives = []string{ -` - - for i := range md { - outs += `"` + md[i] + `",` + "\n" - } - - outs += "}\n" - - if err := formatAndWrite(file, outs); err != nil { - log.Fatalf("Failed to format and write: %q", err) - } -} - -func formatAndWrite(file string, data string) error { - res, err := format.Source([]byte(data)) - if err != nil { - return err - } - - if err = ioutil.WriteFile(file, res, 0644); err != nil { - return err - } - return nil -} - -const ( - pluginPath = "github.com/coredns/coredns/plugin/" - pluginFile = "plugin.cfg" - pluginFSPath = "plugin/" // Where the plugins are located on the file system - header = "// generated by directives_generate.go; DO NOT EDIT\n\n" -) diff --git a/vendor/github.com/coredns/coredns/man/coredns-auto.7 b/vendor/github.com/coredns/coredns/man/coredns-auto.7 deleted file mode 100644 index d84dd4e0..00000000 --- a/vendor/github.com/coredns/coredns/man/coredns-auto.7 +++ /dev/null @@ -1,93 +0,0 @@ -.\" generated with Ronn/v0.7.3 -.\" http://github.com/rtomayko/ronn/tree/0.7.3 -. -.TH "COREDNS\-AUTO" "7" "May 2018" "CoreDNS" "CoreDNS plugins" -. -.SH "NAME" -\fIauto\fR \- enables serving zone data from an RFC 1035\-style master file, which is automatically picked up from disk\. -. -.SH "DESCRIPTION" -The \fIauto\fR plugin is used for an "old\-style" DNS server\. It serves from a preloaded file that exists on disk\. If the zone file contains signatures (i\.e\. is signed, i\.e\. using DNSSEC) correct DNSSEC answers are returned\. Only NSEC is supported! If you use this setup \fIyou\fR are responsible for re\-signing the zonefile\. New or changed zones are automatically picked up from disk\. -. -.SH "SYNTAX" -. -.nf - -auto [ZONES\.\.\.] { - directory DIR [REGEXP ORIGIN_TEMPLATE [TIMEOUT]] - no_reload - upstream [ADDRESS\.\.\.] -} -. -.fi -. -.P -\fBZONES\fR zones it should be authoritative for\. If empty, the zones from the configuration block are used\. -. -.IP "\(bu" 4 -\fBdirectory\fR loads zones from the speficied \fBDIR\fR\. If a file name matches \fBREGEXP\fR it will be used to extract the origin\. \fBORIGIN_TEMPLATE\fR will be used as a template for the origin\. Strings like \fB{}\fR are replaced with the respective matches in the file name, e\.g\. \fB{1}\fR is the first match, \fB{2}\fR is the second\. The default is: \fBdb\e\.(\.*) {1}\fR i\.e\. from a file with the name \fBdb\.example\.com\fR, the extracted origin will be \fBexample\.com\fR\. \fBTIMEOUT\fR specifies how often CoreDNS should scan the directory; the default is every 60 seconds\. This value is in seconds\. The minimum value is 1 second\. -. -.IP "\(bu" 4 -\fBno_reload\fR by default CoreDNS will try to reload a zone every minute and reloads if the SOA\'s serial has changed\. This option disables that behavior\. -. -.IP "\(bu" 4 -\fBupstream\fR defines upstream resolvers to be used resolve external names found (think CNAMEs) pointing to external names\. \fBADDRESS\fR can be an IP address, an IP:port or a string pointing to a file that is structured as /etc/resolv\.conf\. If no \fBADDRESS\fR is given, CoreDNS will resolve CNAMEs against itself\. -. -.IP "" 0 -. -.P -All directives from the \fIfile\fR plugin are supported\. Note that \fIauto\fR will load all zones found, even though the directive might only receive queries for a specific zone\. I\.e: -. -.IP "" 4 -. -.nf - -\&\. { - auto example\.org { - directory /etc/coredns/zones - } -} -. -.fi -. -.IP "" 0 -. -.P -Will happily pick up a zone for \fBexample\.COM\fR, except it will never be queried, because the \fIauto\fR directive only is authoritative for \fBexample\.ORG\fR\. -. -.SH "EXAMPLES" -Load \fBorg\fR domains from \fB/etc/coredns/zones/org\fR and allow transfers to the internet, but send notifies to 10\.240\.1\.1 -. -.IP "" 4 -. -.nf - -\&\. { - auto org { - directory /etc/coredns/zones/org - transfer to * - transfer to 10\.240\.1\.1 - } -} -. -.fi -. -.IP "" 0 -. -.P -Load \fBorg\fR domains from \fB/etc/coredns/zones/org\fR and looks for file names as \fBwww\.db\.example\.org\fR, where \fBexample\.org\fR is the origin\. Scan every 45 seconds\. -. -.IP "" 4 -. -.nf - -org { - auto { - directory /etc/coredns/zones/org www\e\.db\e\.(\.*) {1} 45 - } -} -. -.fi -. -.IP "" 0 - diff --git a/vendor/github.com/coredns/coredns/man/coredns-autopath.7 b/vendor/github.com/coredns/coredns/man/coredns-autopath.7 deleted file mode 100644 index 7fc38129..00000000 --- a/vendor/github.com/coredns/coredns/man/coredns-autopath.7 +++ /dev/null @@ -1,64 +0,0 @@ -.\" generated with Ronn/v0.7.3 -.\" http://github.com/rtomayko/ronn/tree/0.7.3 -. -.TH "COREDNS\-AUTOPATH" "7" "May 2018" "CoreDNS" "CoreDNS plugins" -. -.SH "NAME" -\fIautopath\fR \- allows for server\-side search path completion\. -. -.SH "DESCRIPTION" -If it sees a query that matches the first element of the configured search path, \fIautopath\fR will follow the chain of search path elements and return the first reply that is not NXDOMAIN\. On any failures, the original reply is returned\. Because \fIautopath\fR returns a reply for a name that wasn\'t the original question it will add a CNAME that points from the original name (with the search path element in it) to the name of this answer\. -. -.SH "SYNTAX" -. -.nf - -autopath [ZONE\.\.\.] RESOLV\-CONF -. -.fi -. -.IP "\(bu" 4 -\fBZONES\fR zones \fIautopath\fR should be authoritative for\. -. -.IP "\(bu" 4 -\fBRESOLV\-CONF\fR points to a \fBresolv\.conf\fR like file or uses a special syntax to point to another plugin\. For instance \fB@kubernetes\fR, will call out to the kubernetes plugin (for each query) to retrieve the search list it should use\. -. -.IP "" 0 -. -.P -If a plugin implements the \fBAutoPather\fR interface then it can be used\. -. -.SH "METRICS" -If monitoring is enabled (via the \fIprometheus\fR directive) then the following metric is exported: -. -.IP "\(bu" 4 -\fBcoredns_autopath_success_count_total{server}\fR \- counter of successfully autopath\-ed queries\. -. -.IP "" 0 -. -.P -The \fBserver\fR label is explained in the \fImetrics\fR plugin documentation\. -. -.SH "EXAMPLES" -. -.nf - -autopath my\-resolv\.conf -. -.fi -. -.P -Use \fBmy\-resolv\.conf\fR as the file to get the search path from\. This file only needs so have one line: \fBsearch domain1 domain2 \.\.\.\fR -. -.IP "" 4 -. -.nf - -autopath @kubernetes -. -.fi -. -.IP "" 0 -. -.P -Use the search path dynamically retrieved from the \fIkubernetes\fR plugin\. diff --git a/vendor/github.com/coredns/coredns/man/coredns-bind.7 b/vendor/github.com/coredns/coredns/man/coredns-bind.7 deleted file mode 100644 index 354f1b91..00000000 --- a/vendor/github.com/coredns/coredns/man/coredns-bind.7 +++ /dev/null @@ -1,74 +0,0 @@ -.\" generated with Ronn/v0.7.3 -.\" http://github.com/rtomayko/ronn/tree/0.7.3 -. -.TH "COREDNS\-BIND" "7" "May 2018" "CoreDNS" "CoreDNS plugins" -. -.SH "NAME" -\fIbind\fR \- overrides the host to which the server should bind\. -. -.SH "DESCRIPTION" -Normally, the listener binds to the wildcard host\. However, you may want the listener to bind to another IP instead\. -. -.P -If several addresses are provided, a listener will be open on each of the IP provided\. -. -.P -Each address has to be an IP of one of the interfaces of the host\. -. -.SH "SYNTAX" -. -.nf - -bind ADDRESS \.\.\. -. -.fi -. -.P -\fBADDRESS\fR is an IP address to bind to\. When several addresses are provided a listener will be opened on each of the addresses\. -. -.SH "EXAMPLES" -To make your socket accessible only to that machine, bind to IP 127\.0\.0\.1 (localhost): -. -.IP "" 4 -. -.nf - -\&\. { - bind 127\.0\.0\.1 -} -. -.fi -. -.IP "" 0 -. -.P -To allow processing DNS requests only local host on both IPv4 and IPv6 stacks, use the syntax: -. -.IP "" 4 -. -.nf - -\&\. { - bind 127\.0\.0\.1 ::1 -} -. -.fi -. -.IP "" 0 -. -.P -If the configuration comes up with several \fIbind\fR directives, all addresses are consolidated together: The following sample is equivalent to the preceding: -. -.IP "" 4 -. -.nf - -\&\. { - bind 127\.0\.0\.1 - bind ::1 -} -. -.fi -. -.IP "" 0 - diff --git a/vendor/github.com/coredns/coredns/man/coredns-cache.7 b/vendor/github.com/coredns/coredns/man/coredns-cache.7 deleted file mode 100644 index c963d413..00000000 --- a/vendor/github.com/coredns/coredns/man/coredns-cache.7 +++ /dev/null @@ -1,122 +0,0 @@ -.\" generated with Ronn/v0.7.3 -.\" http://github.com/rtomayko/ronn/tree/0.7.3 -. -.TH "COREDNS\-CACHE" "7" "May 2018" "CoreDNS" "CoreDNS plugins" -. -.SH "NAME" -\fIcache\fR \- enables a frontend cache\. -. -.SH "DESCRIPTION" -With \fIcache\fR enabled, all records except zone transfers and metadata records will be cached for up to 3600s\. Caching is mostly useful in a scenario when fetching data from the backend (upstream, database, etc\.) is expensive\. -. -.P -This plugin can only be used once per Server Block\. -. -.SH "SYNTAX" -. -.nf - -cache [TTL] [ZONES\.\.\.] -. -.fi -. -.IP "\(bu" 4 -\fBTTL\fR max TTL in seconds\. If not specified, the maximum TTL will be used, which is 3600 for noerror responses and 1800 for denial of existence ones\. Setting a TTL of 300: \fBcache 300\fR would cache records up to 300 seconds\. -. -.IP "\(bu" 4 -\fBZONES\fR zones it should cache for\. If empty, the zones from the configuration block are used\. -. -.IP "" 0 -. -.P -Each element in the cache is cached according to its TTL (with \fBTTL\fR as the max)\. For the negative cache, the SOA\'s MinTTL value is used\. A TTL of zero is not allowed\. A cache is divided into 256 shards, each holding up to 512 items by default \- for a total size of 256 * 512 = 131,072 items\. -. -.P -If you want more control: -. -.IP "" 4 -. -.nf - -cache [TTL] [ZONES\.\.\.] { - success CAPACITY [TTL] - denial CAPACITY [TTL] - prefetch AMOUNT [[DURATION] [PERCENTAGE%]] -} -. -.fi -. -.IP "" 0 -. -.IP "\(bu" 4 -\fBTTL\fR and \fBZONES\fR as above\. -. -.IP "\(bu" 4 -\fBsuccess\fR, override the settings for caching successful responses\. \fBCAPACITY\fR indicates the maximum number of packets we cache before we start evicting (\fIrandomly\fR)\. \fBTTL\fR overrides the cache maximum TTL\. -. -.IP "\(bu" 4 -\fBdenial\fR, override the settings for caching denial of existence responses\. \fBCAPACITY\fR indicates the maximum number of packets we cache before we start evicting (LRU)\. \fBTTL\fR overrides the cache maximum TTL\. There is a third category (\fBerror\fR) but those responses are never cached\. -. -.IP "\(bu" 4 -\fBprefetch\fR will prefetch popular items when they are about to be expunged from the cache\. Popular means \fBAMOUNT\fR queries have been seen with no gaps of \fBDURATION\fR or more between them\. \fBDURATION\fR defaults to 1m\. Prefetching will happen when the TTL drops below \fBPERCENTAGE\fR, which defaults to \fB10%\fR, or latest 1 second before TTL expiration\. Values should be in the range \fB[10%, 90%]\fR\. Note the percent sign is mandatory\. \fBPERCENTAGE\fR is treated as an \fBint\fR\. -. -.IP "" 0 -. -.SH "CAPACITY AND EVICTION" -When specifying \fBCAPACITY\fR, the minimum cache capacity is 131,072\. Specifying a lower value will be ignored\. Specifying a \fBCAPACITY\fR of zero does not disable the cache\. -. -.P -Eviction is done per shard \- i\.e\. when a shard reaches capacity, items are evicted from that shard\. Since shards don\'t fill up perfectly evenly, evictions will occur before the entire cache reaches full capacity\. Each shard capacity is equal to the total cache size / number of shards (256)\. -. -.SH "METRICS" -If monitoring is enabled (via the \fIprometheus\fR directive) then the following metrics are exported: -. -.IP "\(bu" 4 -\fBcoredns_cache_size{server, type}\fR \- Total elements in the cache by cache type\. -. -.IP "\(bu" 4 -\fBcoredns_cache_hits_total{server, type}\fR \- Counter of cache hits by cache type\. -. -.IP "\(bu" 4 -\fBcoredns_cache_misses_total{server}\fR \- Counter of cache misses\. -. -.IP "\(bu" 4 -\fBcoredns_cache_drops_total{server}\fR \- Counter of dropped messages\. -. -.IP "" 0 -. -.P -Cache types are either "denial" or "success"\. \fBServer\fR is the server handling the request, see the metrics plugin for documentation\. -. -.SH "EXAMPLES" -Enable caching for all zones, but cap everything to a TTL of 10 seconds: -. -.IP "" 4 -. -.nf - -\&\. { - cache 10 - whoami -} -. -.fi -. -.IP "" 0 -. -.P -Proxy to Google Public DNS and only cache responses for example\.org (or below)\. -. -.IP "" 4 -. -.nf - -\&\. { - proxy \. 8\.8\.8\.8:53 - cache example\.org -} -. -.fi -. -.IP "" 0 - diff --git a/vendor/github.com/coredns/coredns/man/coredns-chaos.7 b/vendor/github.com/coredns/coredns/man/coredns-chaos.7 deleted file mode 100644 index fe294411..00000000 --- a/vendor/github.com/coredns/coredns/man/coredns-chaos.7 +++ /dev/null @@ -1,77 +0,0 @@ -.\" generated with Ronn/v0.7.3 -.\" http://github.com/rtomayko/ronn/tree/0.7.3 -. -.TH "COREDNS\-CHAOS" "7" "May 2018" "CoreDNS" "CoreDNS plugins" -. -.SH "NAME" -\fIchaos\fR \- allows for responding to TXT queries in the CH class\. -. -.SH "DESCRIPTION" -This is useful for retrieving version or author information from the server by querying a TXT record for a special domainname in the CH class\. -. -.SH "SYNTAX" -. -.nf - -chaos [VERSION] [AUTHORS\.\.\.] -. -.fi -. -.IP "\(bu" 4 -\fBVERSION\fR is the version to return\. Defaults to \fBCoreDNS\-\fR, if not set\. -. -.IP "\(bu" 4 -\fBAUTHORS\fR is what authors to return\. No default\. -. -.IP "" 0 -. -.P -Note that you have to make sure that this plugin will get actual queries for the following zones: \fBversion\.bind\fR, \fBversion\.server\fR, \fBauthors\.bind\fR, \fBhostname\.bind\fR and \fBid\.server\fR\. -. -.SH "EXAMPLES" -Specify all the zones in full\. -. -.IP "" 4 -. -.nf - -version\.bind version\.server authors\.bind hostname\.bind id\.server { - chaos CoreDNS\-001 info@coredns\.io -} -. -.fi -. -.IP "" 0 -. -.P -Or just default to \fB\.\fR: -. -.IP "" 4 -. -.nf - -\&\. { - chaos CoreDNS\-001 info@coredns\.io -} -. -.fi -. -.IP "" 0 -. -.P -And test with \fBdig\fR: -. -.IP "" 4 -. -.nf - -% dig @localhost CH TXT version\.bind -\.\.\. -;; ANSWER SECTION: -version\.bind\. 0 CH TXT "CoreDNS\-001" -\.\.\. -. -.fi -. -.IP "" 0 - diff --git a/vendor/github.com/coredns/coredns/man/coredns-debug.7 b/vendor/github.com/coredns/coredns/man/coredns-debug.7 deleted file mode 100644 index 0c4345a9..00000000 --- a/vendor/github.com/coredns/coredns/man/coredns-debug.7 +++ /dev/null @@ -1,37 +0,0 @@ -.\" generated with Ronn/v0.7.3 -.\" http://github.com/rtomayko/ronn/tree/0.7.3 -. -.TH "COREDNS\-DEBUG" "7" "May 2018" "CoreDNS" "CoreDNS plugins" -. -.SH "NAME" -\fIdebug\fR \- disables the automatic recovery upon a crash so that you\'ll get a nice stack trace\. -. -.SH "DESCRIPTION" -Normally CoreDNS will recover from panics, using \fIdebug\fR inhibits this\. The main use of \fIdebug\fR is to help testing\. A side effect of using \fIdebug\fR is that \fBlog\.Debug\fR and \fBlog\.Debugf\fR will be printed to standard output\. -. -.P -Note that the \fIerrors\fR plugin (if loaded) will also set a \fBrecover\fR negating this setting\. -. -.SH "SYNTAX" -. -.nf - -debug -. -.fi -. -.SH "EXAMPLES" -Disable the ability to recover from crashes and show debug logging: -. -.IP "" 4 -. -.nf - -\&\. { - debug -} -. -.fi -. -.IP "" 0 - diff --git a/vendor/github.com/coredns/coredns/man/coredns-dnssec.7 b/vendor/github.com/coredns/coredns/man/coredns-dnssec.7 deleted file mode 100644 index cbb6e744..00000000 --- a/vendor/github.com/coredns/coredns/man/coredns-dnssec.7 +++ /dev/null @@ -1,107 +0,0 @@ -.\" generated with Ronn/v0.7.3 -.\" http://github.com/rtomayko/ronn/tree/0.7.3 -. -.TH "COREDNS\-DNSSEC" "7" "May 2018" "CoreDNS" "CoreDNS plugins" -. -.SH "NAME" -\fIdnssec\fR \- enable on\-the\-fly DNSSEC signing of served data\. -. -.SH "DESCRIPTION" -With \fIdnssec\fR any reply that doesn\'t (or can\'t) do DNSSEC will get signed on the fly\. Authenticated denial of existence is implemented with NSEC black lies\. Using ECDSA as an algorithm is preferred as this leads to smaller signatures (compared to RSA)\. NSEC3 is \fInot\fR supported\. -. -.P -This plugin can only be used once per Server Block\. -. -.SH "SYNTAX" -. -.nf - -dnssec [ZONES\.\.\. ] { - key file KEY\.\.\. - cache_capacity CAPACITY -} -. -.fi -. -.P -The specified key is used for all signing operations\. The DNSSEC signing will treat this key as a CSK (common signing key), forgoing the ZSK/KSK split\. All signing operations are done online\. Authenticated denial of existence is implemented with NSEC black lies\. Using ECDSA as an algorithm is preferred as this leads to smaller signatures (compared to RSA)\. NSEC3 is \fInot\fR supported\. -. -.P -If multiple \fIdnssec\fR plugins are specified in the same zone, the last one specified will be used (See \fIbugs\fR)\. -. -.IP "\(bu" 4 -\fBZONES\fR zones that should be signed\. If empty, the zones from the configuration block are used\. -. -.IP "\(bu" 4 -\fBkey file\fR indicates that \fBKEY\fR file(s) should be read from disk\. When multiple keys are specified, RRsets will be signed with all keys\. Generating a key can be done with \fBdnssec\-keygen\fR: \fBdnssec\-keygen \-a ECDSAP256SHA256 \fR\. A key created for zone \fIA\fR can be safely used for zone \fIB\fR\. The name of the key file can be specified in one of the following formats -. -.IP "\(bu" 4 -basename of the generated key \fBKexample\.org+013+45330\fR -. -.IP "\(bu" 4 -generated public key \fBKexample\.org+013+45330\.key\fR -. -.IP "\(bu" 4 -generated private key \fBKexample\.org+013+45330\.private\fR -. -.IP "" 0 - -. -.IP "\(bu" 4 -\fBcache_capacity\fR indicates the capacity of the cache\. The dnssec plugin uses a cache to store RRSIGs\. The default for \fBCAPACITY\fR is 10000\. -. -.IP "" 0 -. -.SH "METRICS" -If monitoring is enabled (via the \fIprometheus\fR directive) then the following metrics are exported: -. -.IP "\(bu" 4 -\fBcoredns_dnssec_cache_size{server, type}\fR \- total elements in the cache, type is "signature"\. -. -.IP "\(bu" 4 -\fBcoredns_dnssec_cache_hits_total{server}\fR \- Counter of cache hits\. -. -.IP "\(bu" 4 -\fBcoredns_dnssec_cache_misses_total{server}\fR \- Counter of cache misses\. -. -.IP "" 0 -. -.P -The label \fBserver\fR indicated the server handling the request, see the \fImetrics\fR plugin for details\. -. -.SH "EXAMPLES" -Sign responses for \fBexample\.org\fR with the key "Kexample\.org\.+013+45330\.key"\. -. -.IP "" 4 -. -.nf - -example\.org { - dnssec { - key file Kexample\.org\.+013+45330 - } - whoami -} -. -.fi -. -.IP "" 0 -. -.P -Sign responses for a kubernetes zone with the key "Kcluster\.local+013+45129\.key"\. -. -.IP "" 4 -. -.nf - -cluster\.local { - kubernetes - dnssec { - key file Kcluster\.local+013+45129 - } -} -. -.fi -. -.IP "" 0 - diff --git a/vendor/github.com/coredns/coredns/man/coredns-dnstap.7 b/vendor/github.com/coredns/coredns/man/coredns-dnstap.7 deleted file mode 100644 index 9b627e6d..00000000 --- a/vendor/github.com/coredns/coredns/man/coredns-dnstap.7 +++ /dev/null @@ -1,139 +0,0 @@ -.\" generated with Ronn/v0.7.3 -.\" http://github.com/rtomayko/ronn/tree/0.7.3 -. -.TH "COREDNS\-DNSTAP" "7" "May 2018" "CoreDNS" "CoreDNS plugins" -. -.SH "NAME" -\fIdnstap\fR \- enable logging to dnstap -. -.SH "DESCRIPTION" -dnstap is a flexible, structured binary log format for DNS software: http://dnstap\.info\. With this plugin you make CoreDNS output dnstap logging\. -. -.P -Note that there is an internal buffer, so expect at least 13 requests before the server sends its dnstap messages to the socket\. -. -.SH "SYNTAX" -. -.nf - -dnstap SOCKET [full] -. -.fi -. -.IP "\(bu" 4 -\fBSOCKET\fR is the socket path supplied to the dnstap command line tool\. -. -.IP "\(bu" 4 -\fBfull\fR to include the wire\-format DNS message\. -. -.IP "" 0 -. -.SH "EXAMPLES" -Log information about client requests and responses to \fI/tmp/dnstap\.sock\fR\. -. -.IP "" 4 -. -.nf - -dnstap /tmp/dnstap\.sock -. -.fi -. -.IP "" 0 -. -.P -Log information including the wire\-format DNS message about client requests and responses to \fI/tmp/dnstap\.sock\fR\. -. -.IP "" 4 -. -.nf - -dnstap unix:///tmp/dnstap\.sock full -. -.fi -. -.IP "" 0 -. -.P -Log to a remote endpoint\. -. -.IP "" 4 -. -.nf - -dnstap tcp://127\.0\.0\.1:6000 full -. -.fi -. -.IP "" 0 -. -.SH "COMMAND LINE TOOL" -Dnstap has a command line tool that can be used to inspect the logging\. The tool can be found at Github: \fIhttps://github\.com/dnstap/golang\-dnstap\fR\. It\'s written in Go\. -. -.P -The following command listens on the given socket and decodes messages to stdout\. -. -.IP "" 4 -. -.nf - -$ dnstap \-u /tmp/dnstap\.sock -. -.fi -. -.IP "" 0 -. -.P -The following command listens on the given socket and saves message payloads to a binary dnstap\-format log file\. -. -.IP "" 4 -. -.nf - -$ dnstap \-u /tmp/dnstap\.sock \-w /tmp/test\.dnstap -. -.fi -. -.IP "" 0 -. -.P -Listen for dnstap messages on port 6000\. -. -.IP "" 4 -. -.nf - -$ dnstap \-l 127\.0\.0\.1:6000 -. -.fi -. -.IP "" 0 -. -.SH "USING DNSTAP IN YOUR PLUGIN" -. -.nf - -import ( - "github\.com/coredns/coredns/plugin/dnstap" - "github\.com/coredns/coredns/plugin/dnstap/msg" -) - -func (h Dnstap) ServeDNS(ctx context\.Context, w dns\.ResponseWriter, r *dns\.Msg) (int, error) { - // log client query to Dnstap - if t := dnstap\.TapperFromContext(ctx); t != nil { - b := msg\.New()\.Time(time\.Now())\.Addr(w\.RemoteAddr()) - if t\.Pack() { - b\.Msg(r) - } - if m, err := b\.ToClientQuery(); err == nil { - t\.TapMessage(m) - } - } - - // \.\.\. -} -. -.fi -. -.SH "SEE ALSO" -dnstap\.info \fIhttp://dnstap\.info\fR\. diff --git a/vendor/github.com/coredns/coredns/man/coredns-erratic.7 b/vendor/github.com/coredns/coredns/man/coredns-erratic.7 deleted file mode 100644 index d8c36c51..00000000 --- a/vendor/github.com/coredns/coredns/man/coredns-erratic.7 +++ /dev/null @@ -1,122 +0,0 @@ -.\" generated with Ronn/v0.7.3 -.\" http://github.com/rtomayko/ronn/tree/0.7.3 -. -.TH "COREDNS\-ERRATIC" "7" "May 2018" "CoreDNS" "CoreDNS plugins" -. -.SH "NAME" -\fIerratic\fR \- a plugin useful for testing client behavior\. -. -.SH "DESCRIPTION" -\fIerratic\fR returns a static response to all queries, but the responses can be delayed, dropped or truncated\. The \fIerratic\fR plugin will respond to every A or AAAA query\. For any other type it will return a SERVFAIL response\. The reply for A will return 192\.0\.2\.53 (see RFC 5737 \fIhttps://tools\.ietf\.org/html/rfc5737\fR, for AAAA it returns 2001:DB8::53 (see RFC 3849 \fIhttps://tools\.ietf\.org/html/rfc3849\fR)\. -. -.P -\fIerratic\fR can also be used in conjunction with the \fIautopath\fR plugin\. This is mostly to aid in testing\. -. -.SH "SYNTAX" -. -.nf - -erratic { - drop [AMOUNT] - truncate [AMOUNT] - delay [AMOUNT [DURATION]] -} -. -.fi -. -.IP "\(bu" 4 -\fBdrop\fR: drop 1 per \fBAMOUNT\fR of queries, the default is 2\. -. -.IP "\(bu" 4 -\fBtruncate\fR: truncate 1 per \fBAMOUNT\fR of queries, the default is 2\. -. -.IP "\(bu" 4 -\fBdelay\fR: delay 1 per \fBAMOUNT\fR of queries for \fBDURATION\fR, the default for \fBAMOUNT\fR is 2 and the default for \fBDURATION\fR is 100ms\. -. -.IP "" 0 -. -.SH "HEALTH" -This plugin implements dynamic health checking\. For every dropped query it turns unhealthy\. -. -.SH "EXAMPLES" -. -.nf - -\&\. { - erratic { - drop 3 - } -} -. -.fi -. -.P -Or even shorter if the defaults suits you\. Note this only drops queries, it does not delay them\. -. -.IP "" 4 -. -.nf - -\&\. { - erratic -} -. -.fi -. -.IP "" 0 -. -.P -Delay 1 in 3 queries for 50ms -. -.IP "" 4 -. -.nf - -\&\. { - erratic { - delay 3 50ms - } -} -. -.fi -. -.IP "" 0 -. -.P -Delay 1 in 3 and truncate 1 in 5\. -. -.IP "" 4 -. -.nf - -\&\. { - erratic { - delay 3 5ms - truncate 5 - } -} -. -.fi -. -.IP "" 0 -. -.P -Drop every second query\. -. -.IP "" 4 -. -.nf - -\&\. { - erratic { - drop 2 - truncate 2 - } -} -. -.fi -. -.IP "" 0 -. -.SH "ALSO SEE" -RFC 3849 \fIhttps://tools\.ietf\.org/html/rfc3849\fR and RFC 5737 \fIhttps://tools\.ietf\.org/html/rfc5737\fR\. diff --git a/vendor/github.com/coredns/coredns/man/coredns-errors.7 b/vendor/github.com/coredns/coredns/man/coredns-errors.7 deleted file mode 100644 index cc67c74f..00000000 --- a/vendor/github.com/coredns/coredns/man/coredns-errors.7 +++ /dev/null @@ -1,38 +0,0 @@ -.\" generated with Ronn/v0.7.3 -.\" http://github.com/rtomayko/ronn/tree/0.7.3 -. -.TH "COREDNS\-ERRORS" "7" "May 2018" "CoreDNS" "CoreDNS plugins" -. -.SH "NAME" -\fIerrors\fR \- enable error logging\. -. -.SH "DESCRIPTION" -Any errors encountered during the query processing will be printed to standard output\. -. -.P -This plugin can only be used once per Server Block\. -. -.SH "SYNTAX" -. -.nf - -errors -. -.fi -. -.SH "EXAMPLES" -Use the \fIwhoami\fR to respond to queries and Log errors to standard output\. -. -.IP "" 4 -. -.nf - -\&\. { - whoami - errors -} -. -.fi -. -.IP "" 0 - diff --git a/vendor/github.com/coredns/coredns/man/coredns-etcd.7 b/vendor/github.com/coredns/coredns/man/coredns-etcd.7 deleted file mode 100644 index ee65d92a..00000000 --- a/vendor/github.com/coredns/coredns/man/coredns-etcd.7 +++ /dev/null @@ -1,240 +0,0 @@ -.\" generated with Ronn/v0.7.3 -.\" http://github.com/rtomayko/ronn/tree/0.7.3 -. -.TH "COREDNS\-ETCD" "7" "May 2018" "CoreDNS" "CoreDNS plugins" -. -.SH "NAME" -\fIetcd\fR \- enables reading zone data from an etcd instance\. -. -.SH "DESCRIPTION" -The data in etcd has to be encoded as a message \fIhttps://github\.com/skynetservices/skydns/blob/2fcff74cdc9f9a7dd64189a447ef27ac354b725f/msg/service\.go#L26\fR like SkyDNS \fIhttps://github\.com/skynetservices/skydns\fR\. It should also work just like SkyDNS\. -. -.P -The etcd plugin makes extensive use of the proxy plugin to forward and query other servers in the network\. -. -.SH "SYNTAX" -. -.nf - -etcd [ZONES\.\.\.] -. -.fi -. -.IP "\(bu" 4 -\fBZONES\fR zones etcd should be authoritative for\. -. -.IP "" 0 -. -.P -The path will default to \fB/skydns\fR the local etcd proxy (http://localhost:2379)\. If no zones are specified the block\'s zone will be used as the zone\. -. -.P -If you want to \fBround robin\fR A and AAAA responses look at the \fBloadbalance\fR plugin\. -. -.IP "" 4 -. -.nf - -etcd [ZONES\.\.\.] { - stubzones - fallthrough [ZONES\.\.\.] - path PATH - endpoint ENDPOINT\.\.\. - upstream [ADDRESS\.\.\.] - tls CERT KEY CACERT -} -. -.fi -. -.IP "" 0 -. -.IP "\(bu" 4 -\fBstubzones\fR enables the stub zones feature\. The stubzone is \fIonly\fR done in the etcd tree located under the \fIfirst\fR zone specified\. -. -.IP "\(bu" 4 -\fBfallthrough\fR If zone matches but no record can be generated, pass request to the next plugin\. If \fB[ZONES\.\.\.]\fR is omitted, then fallthrough happens for all zones for which the plugin is authoritative\. If specific zones are listed (for example \fBin\-addr\.arpa\fR and \fBip6\.arpa\fR), then only queries for those zones will be subject to fallthrough\. -. -.IP "\(bu" 4 -\fBPATH\fR the path inside etcd\. Defaults to "/skydns"\. -. -.IP "\(bu" 4 -\fBENDPOINT\fR the etcd endpoints\. Defaults to "http://localhost:2379"\. -. -.IP "\(bu" 4 -\fBupstream\fR upstream resolvers to be used resolve external names found in etcd (think CNAMEs) pointing to external names\. If you want CoreDNS to act as a proxy for clients, you\'ll need to add the proxy plugin\. If no \fBADDRESS\fR is given, CoreDNS will resolve CNAMEs against itself\. \fBADDRESS\fR can be an IP address, and IP:port or a string pointing to a file that is structured as /etc/resolv\.conf\. -. -.IP "\(bu" 4 -\fBtls\fR followed by: -. -.IP "\(bu" 4 -no arguments, if the server certificate is signed by a system\-installed CA and no client cert is needed -. -.IP "\(bu" 4 -a single argument that is the CA PEM file, if the server cert is not signed by a system CA and no client cert is needed -. -.IP "\(bu" 4 -two arguments \- path to cert PEM file, the path to private key PEM file \- if the server certificate is signed by a system\-installed CA and a client certificate is needed -. -.IP "\(bu" 4 -three arguments \- path to cert PEM file, path to client private key PEM file, path to CA PEM file \- if the server certificate is not signed by a system\-installed CA and client certificate is needed\. -. -.IP "" 0 - -. -.IP "" 0 -. -.SH "EXAMPLES" -This is the default SkyDNS setup, with everying specified in full: -. -.IP "" 4 -. -.nf - -\&\. { - etcd skydns\.local { - stubzones - path /skydns - endpoint http://localhost:2379 - upstream 8\.8\.8\.8:53 8\.8\.4\.4:53 - } - prometheus - cache 160 skydns\.local - loadbalance - proxy \. 8\.8\.8\.8:53 8\.8\.4\.4:53 -} -. -.fi -. -.IP "" 0 -. -.P -Or a setup where we use \fB/etc/resolv\.conf\fR as the basis for the proxy and the upstream when resolving external pointing CNAMEs\. -. -.IP "" 4 -. -.nf - -\&\. { - etcd skydns\.local { - path /skydns - upstream /etc/resolv\.conf - } - cache 160 skydns\.local - proxy \. /etc/resolv\.conf -} -. -.fi -. -.IP "" 0 -. -.P -Multiple endpoints are supported as well\. -. -.IP "" 4 -. -.nf - -etcd skydns\.local { - endpoint http://localhost:2379 http://localhost:4001 -\.\.\. -. -.fi -. -.IP "" 0 -. -.SS "REVERSE ZONES" -Reverse zones are supported\. You need to make CoreDNS aware of the fact that you are also authoritative for the reverse\. For instance if you want to add the reverse for 10\.0\.0\.0/24, you\'ll need to add the zone \fB0\.0\.10\.in\-addr\.arpa\fR to the list of zones\. Showing a snippet of a Corefile: -. -.IP "" 4 -. -.nf - -etcd skydns\.local 10\.0\.0\.0/24 { - stubzones -\.\.\. -. -.fi -. -.IP "" 0 -. -.P -Next you\'ll need to populate the zone with reverse records, here we add a reverse for 10\.0\.0\.127 pointing to reverse\.skydns\.local\. -. -.IP "" 4 -. -.nf - -% curl \-XPUT http://127\.0\.0\.1:4001/v2/keys/skydns/arpa/in\-addr/10/0/0/127 \e - \-d value=\'{"host":"reverse\.skydns\.local\."}\' -. -.fi -. -.IP "" 0 -. -.P -Querying with dig: -. -.IP "" 4 -. -.nf - -% dig @localhost \-x 10\.0\.0\.127 +short -reverse\.skydns\.local\. -. -.fi -. -.IP "" 0 -. -.SS "ZONE NAME AS A RECORD" -The zone name itself can be used A record\. This behavior can be achieved by writing special entries to the ETCD path of your zone\. If your zone is named \fBskydns\.local\fR for example, you can create an \fBA\fR record for this zone as follows: -. -.IP "" 4 -. -.nf - -% curl \-XPUT http://127\.0\.0\.1:2379/v2/keys/skydns/local/skydns/dns/apex \-d value=\'{"host":"1\.1\.1\.1","ttl":"60"}\' -. -.fi -. -.IP "" 0 -. -.P -If you query the zone name itself, you will receive the created \fBA\fR record: -. -.IP "" 4 -. -.nf - -% dig +short skydns\.local @localhost -1\.1\.1\.1 -. -.fi -. -.IP "" 0 -. -.P -If you would like to use DNS RR for the zone name, you can set the following: ~~~ % curl \-XPUT http://127\.0\.0\.1:2379/v2/keys/skydns/local/skydns/dns/apex/x1 \-d value=\'{"host":"1\.1\.1\.1","ttl":"60"}\' % curl \-XPUT http://127\.0\.0\.1:2379/v2/keys/skydns/local/skydns/dns/apex/x2 \-d value=\'{"host":"1\.1\.1\.2","ttl":"60"}\' ~~~ -. -.P -If you query the zone name now, you will get the following response: -. -.IP "" 4 -. -.nf - -dig +short skydns\.local @localhost -1\.1\.1\.1 -1\.1\.1\.2 -. -.fi -. -.IP "" 0 -. -.P -If you would like to use \fBAAAA\fR records for the zone name too, you can set the following: ~~~ % curl \-XPUT http://127\.0\.0\.1:2379/v2/keys/skydns/local/skydns/dns/apex/x3 \-d value=\'{"host":"2003::8:1","ttl":"60"}\' % curl \-XPUT http://127\.0\.0\.1:2379/v2/keys/skydns/local/skydns/dns/apex/x4 \-d value=\'{"host":"2003::8:2","ttl":"60"}\' ~~~ -. -.P -If you query the zone name now for \fBAAAA\fR now, you will get the following response: ~~~ sh dig +short skydns\.local AAAA @localhost 2003::8:1 2003::8:2 ~~~ -. -.SH "BUGS" -Only the etcdv2 protocol is supported\. diff --git a/vendor/github.com/coredns/coredns/man/coredns-federation.7 b/vendor/github.com/coredns/coredns/man/coredns-federation.7 deleted file mode 100644 index 8d23cae9..00000000 --- a/vendor/github.com/coredns/coredns/man/coredns-federation.7 +++ /dev/null @@ -1,67 +0,0 @@ -.\" generated with Ronn/v0.7.3 -.\" http://github.com/rtomayko/ronn/tree/0.7.3 -. -.TH "COREDNS\-FEDERATION" "7" "May 2018" "CoreDNS" "CoreDNS plugins" -. -.SH "NAME" -\fIfederation\fR \- enables federated queries to be resolved via the kubernetes plugin\. -. -.SH "DESCRIPTION" -Enabling this plugin allows Federated \fIhttps://kubernetes\.io/docs/tasks/federation/federation\-service\-discovery/\fR queries to be resolved via the kubernetes plugin\. -. -.P -Enabling \fIfederation\fR without also having \fIkubernetes\fR is a noop\. -. -.SH "SYNTAX" -. -.nf - -federation [ZONES\.\.\.] { - NAME DOMAIN -} -. -.fi -. -.IP "\(bu" 4 -Each \fBNAME\fR and \fBDOMAIN\fR defines federation membership\. One entry for each\. A duplicate \fBNAME\fR will silently overwrite any previous value\. -. -.IP "" 0 -. -.SH "EXAMPLES" -Here we handle all service requests in the \fBprod\fR and \fBstage\fR federations\. -. -.IP "" 4 -. -.nf - -\&\. { - kubernetes cluster\.local - federation cluster\.local { - prod prod\.feddomain\.com - staging staging\.feddomain\.com - } -} -. -.fi -. -.IP "" 0 -. -.P -Or slightly shorter: -. -.IP "" 4 -. -.nf - -cluster\.local { - kubernetes - federation { - prod prod\.feddomain\.com - staging staging\.feddomain\.com - } -} -. -.fi -. -.IP "" 0 - diff --git a/vendor/github.com/coredns/coredns/man/coredns-file.7 b/vendor/github.com/coredns/coredns/man/coredns-file.7 deleted file mode 100644 index 47418f1b..00000000 --- a/vendor/github.com/coredns/coredns/man/coredns-file.7 +++ /dev/null @@ -1,91 +0,0 @@ -.\" generated with Ronn/v0.7.3 -.\" http://github.com/rtomayko/ronn/tree/0.7.3 -. -.TH "COREDNS\-FILE" "7" "May 2018" "CoreDNS" "CoreDNS plugins" -. -.SH "NAME" -\fIfile\fR \- enables serving zone data from an RFC 1035\-style master file\. -. -.SH "DESCRIPTION" -The file plugin is used for an "old\-style" DNS server\. It serves from a preloaded file that exists on disk\. If the zone file contains signatures (i\.e\. is signed, i\.e\. DNSSEC) correct DNSSEC answers are returned\. Only NSEC is supported! If you use this setup \fIyou\fR are responsible for resigning the zonefile\. -. -.SH "SYNTAX" -. -.nf - -file DBFILE [ZONES\.\.\.] -. -.fi -. -.IP "\(bu" 4 -\fBDBFILE\fR the database file to read and parse\. If the path is relative the path from the \fIroot\fR directive will be prepended to it\. -. -.IP "\(bu" 4 -\fBZONES\fR zones it should be authoritative for\. If empty, the zones from the configuration block are used\. -. -.IP "" 0 -. -.P -If you want to round robin A and AAAA responses look at the \fIloadbalance\fR plugin\. -. -.IP "" 4 -. -.nf - -file DBFILE [ZONES\.\.\. ] { - transfer to ADDRESS\.\.\. - no_reload - upstream [ADDRESS\.\.\.] -} -. -.fi -. -.IP "" 0 -. -.IP "\(bu" 4 -\fBtransfer\fR enables zone transfers\. It may be specified multiples times\. \fBTo\fR or \fBfrom\fR signals the direction\. \fBADDRESS\fR must be denoted in CIDR notation (127\.0\.0\.1/32 etc\.) or just as plain addresses\. The special wildcard \fB*\fR means: the entire internet (only valid for \'transfer to\')\. When an address is specified a notify message will be send whenever the zone is reloaded\. -. -.IP "\(bu" 4 -\fBno_reload\fR by default CoreDNS will try to reload a zone every minute and reloads if the SOA\'s serial has changed\. This option disables that behavior\. -. -.IP "\(bu" 4 -\fBupstream\fR defines upstream resolvers to be used resolve external names found (think CNAMEs) pointing to external names\. This is only really useful when CoreDNS is configured as a proxy, for normal authoritative serving you don\'t need \fIor\fR want to use this\. \fBADDRESS\fR can be an IP address, and IP:port or a string pointing to a file that is structured as /etc/resolv\.conf\. If no \fBADDRESS\fR is given, CoreDNS will resolve CNAMEs against itself\. -. -.IP "" 0 -. -.SH "EXAMPLES" -Load the \fBexample\.org\fR zone from \fBexample\.org\.signed\fR and allow transfers to the internet, but send notifies to 10\.240\.1\.1 -. -.IP "" 4 -. -.nf - -example\.org { - file example\.org\.signed { - transfer to * - transfer to 10\.240\.1\.1 - } -} -. -.fi -. -.IP "" 0 -. -.P -Or use a single zone file for multiple zones: -. -.IP "" 4 -. -.nf - -\&\. { - file example\.org\.signed example\.org example\.net { - transfer to * - transfer to 10\.240\.1\.1 - } -} -. -.fi -. -.IP "" 0 - diff --git a/vendor/github.com/coredns/coredns/man/coredns-forward.7 b/vendor/github.com/coredns/coredns/man/coredns-forward.7 deleted file mode 100644 index dd95866b..00000000 --- a/vendor/github.com/coredns/coredns/man/coredns-forward.7 +++ /dev/null @@ -1,233 +0,0 @@ -.\" generated with Ronn/v0.7.3 -.\" http://github.com/rtomayko/ronn/tree/0.7.3 -. -.TH "COREDNS\-FORWARD" "7" "June 2018" "CoreDNS" "CoreDNS plugins" -. -.SH "NAME" -\fIforward\fR \- facilitates proxying DNS messages to upstream resolvers\. -. -.SH "DESCRIPTION" -The \fIforward\fR plugin re\-uses already opened sockets to the upstreams\. It supports UDP, TCP and DNS\-over\-TLS and uses in band health checking\. -. -.P -When it detects an error a health check is performed\. This checks runs in a loop, every \fI0\.5s\fR, for as long as the upstream reports unhealthy\. Once healthy we stop health checking (until the next error)\. The health checks use a recursive DNS query (\fB\. IN NS\fR) to get upstream health\. Any response that is not a network error (REFUSED, NOTIMPL, SERVFAIL, etc) is taken as a healthy upstream\. The health check uses the same protocol as specified in \fBTO\fR\. If \fBmax_fails\fR is set to 0, no checking is performed and upstreams will always be considered healthy\. -. -.P -When \fIall\fR upstreams are down it assumes health checking as a mechanism has failed and will try to connect to a random upstream (which may or may not work)\. -. -.P -This plugin can only be used once per Server Block\. -. -.P -How does \fIforward\fR relate to \fIproxy\fR? This plugin is the "new" version of \fIproxy\fR and is faster because it re\-uses connections to the upstreams\. It also does in\-band health checks \- using DNS instead of HTTP\. Since it is newer it has a little less (production) mileage on it\. -. -.SH "SYNTAX" -In its most basic form, a simple forwarder uses this syntax: -. -.IP "" 4 -. -.nf - -forward FROM TO\.\.\. -. -.fi -. -.IP "" 0 -. -.IP "\(bu" 4 -\fBFROM\fR is the base domain to match for the request to be forwarded\. -. -.IP "\(bu" 4 -\fBTO\.\.\.\fR are the destination endpoints to forward to\. The \fBTO\fR syntax allows you to specify a protocol, \fBtls://9\.9\.9\.9\fR or \fBdns://\fR (or no protocol) for plain DNS\. The number of upstreams is limited to 15\. -. -.IP "" 0 -. -.P -Multiple upstreams are randomized (see \fBpolicy\fR) on first use\. When a healthy proxy returns an error during the exchange the next upstream in the list is tried\. -. -.P -Extra knobs are available with an expanded syntax: -. -.IP "" 4 -. -.nf - -forward FROM TO\.\.\. { - except IGNORED_NAMES\.\.\. - force_tcp - expire DURATION - max_fails INTEGER - tls CERT KEY CA - tls_servername NAME - policy random|round_robin|sequential - health_check DURATION -} -. -.fi -. -.IP "" 0 -. -.IP "\(bu" 4 -\fBFROM\fR and \fBTO\.\.\.\fR as above\. -. -.IP "\(bu" 4 -\fBIGNORED_NAMES\fR in \fBexcept\fR is a space\-separated list of domains to exclude from forwarding\. Requests that match none of these names will be passed through\. -. -.IP "\(bu" 4 -\fBforce_tcp\fR, use TCP even when the request comes in over UDP\. -. -.IP "\(bu" 4 -\fBmax_fails\fR is the number of subsequent failed health checks that are needed before considering an upstream to be down\. If 0, the upstream will never be marked as down (nor health checked)\. Default is 2\. -. -.IP "\(bu" 4 -\fBexpire\fR \fBDURATION\fR, expire (cached) connections after this time, the default is 10s\. -. -.IP "\(bu" 4 -\fBtls\fR \fBCERT\fR \fBKEY\fR \fBCA\fR define the TLS properties for TLS connection\. From 0 to 3 arguments can be provided with the meaning as described below -. -.IP "\(bu" 4 -\fBtls\fR \- no client authentication is used, and the system CAs are used to verify the server certificate -. -.IP "\(bu" 4 -\fBtls\fR \fBCA\fR \- no client authentication is used, and the file CA is used to verify the server certificate -. -.IP "\(bu" 4 -\fBtls\fR \fBCERT\fR \fBKEY\fR \- client authentication is used with the specified cert/key pair\. The server certificate is verified with the system CAs -. -.IP "\(bu" 4 -\fBtls\fR \fBCERT\fR \fBKEY\fR \fBCA\fR \- client authentication is used with the specified cert/key pair\. The server certificate is verified using the specified CA file -. -.IP "" 0 - -. -.IP "\(bu" 4 -\fBtls_servername\fR \fBNAME\fR allows you to set a server name in the TLS configuration; for instance 9\.9\.9\.9 needs this to be set to \fBdns\.quad9\.net\fR\. -. -.IP "\(bu" 4 -\fBpolicy\fR specifies the policy to use for selecting upstream servers\. The default is \fBrandom\fR\. -. -.IP "\(bu" 4 -\fBhealth_check\fR, use a different \fBDURATION\fR for health checking, the default duration is 0\.5s\. -. -.IP "" 0 -. -.P -Also note the TLS config is "global" for the whole forwarding proxy if you need a different \fBtls\-name\fR for different upstreams you\'re out of luck\. -. -.P -On each endpoint, the timeouts of the communication are set by default and automatically tuned depending early results\. \- dialTimeout by default is 30 sec, and can decrease automatically down to 100ms \- readTimeout by default is 2 sec, and can decrease automatically down to 10ms -. -.SH "METRICS" -If monitoring is enabled (via the \fIprometheus\fR directive) then the following metric are exported: -. -.IP "\(bu" 4 -\fBcoredns_forward_request_duration_seconds{to}\fR \- duration per upstream interaction\. -. -.IP "\(bu" 4 -\fBcoredns_forward_request_count_total{to}\fR \- query count per upstream\. -. -.IP "\(bu" 4 -\fBcoredns_forward_response_rcode_total{to, rcode}\fR \- count of RCODEs per upstream\. -. -.IP "\(bu" 4 -\fBcoredns_forward_healthcheck_failure_count_total{to}\fR \- number of failed health checks per upstream\. -. -.IP "\(bu" 4 -\fBcoredns_forward_healthcheck_broken_count_total{}\fR \- counter of when all upstreams are unhealthy, and we are randomly (this always uses the \fBrandom\fR policy) spraying to an upstream\. -. -.IP "\(bu" 4 -\fBcoredns_forward_socket_count_total{to}\fR \- number of cached sockets per upstream\. -. -.IP "" 0 -. -.P -Where \fBto\fR is one of the upstream servers (\fBTO\fR from the config), \fBproto\fR is the protocol used by the incoming query ("tcp" or "udp"), and family the transport family ("1" for IPv4, and "2" for IPv6)\. -. -.SH "EXAMPLES" -Proxy all requests within \fBexample\.org\.\fR to a nameserver running on a different port: -. -.IP "" 4 -. -.nf - -example\.org { - forward \. 127\.0\.0\.1:9005 -} -. -.fi -. -.IP "" 0 -. -.P -Load balance all requests between three resolvers, one of which has a IPv6 address\. -. -.IP "" 4 -. -.nf - -\&\. { - forward \. 10\.0\.0\.10:53 10\.0\.0\.11:1053 [2003::1]:53 -} -. -.fi -. -.IP "" 0 -. -.P -Forward everything except requests to \fBexample\.org\fR -. -.IP "" 4 -. -.nf - -\&\. { - forward \. 10\.0\.0\.10:1234 { - except example\.org - } -} -. -.fi -. -.IP "" 0 -. -.P -Proxy everything except \fBexample\.org\fR using the host\'s \fBresolv\.conf\fR\'s nameservers: -. -.IP "" 4 -. -.nf - -\&\. { - forward \. /etc/resolv\.conf { - except example\.org - } -} -. -.fi -. -.IP "" 0 -. -.P -Proxy all requests to 9\.9\.9\.9 using the DNS\-over\-TLS protocol, and cache every answer for up to 30 seconds\. Note the \fBtls_servername\fR is mandatory if you want a working setup, as 9\.9\.9\.9 can\'t be used in the TLS negotiation\. Also set the health check duration to 5s to not completely swamp the service with health checks\. -. -.IP "" 4 -. -.nf - -\&\. { - forward \. tls://9\.9\.9\.9 { - tls_servername dns\.quad9\.net - health_check 5s - } - cache 30 -} -. -.fi -. -.IP "" 0 -. -.SH "BUGS" -The TLS config is global for the whole forwarding proxy if you need a different \fBtls_servername\fR for different upstreams you\'re out of luck\. -. -.SH "ALSO SEE" -RFC 7858 \fIhttps://tools\.ietf\.org/html/rfc7858\fR for DNS over TLS\. diff --git a/vendor/github.com/coredns/coredns/man/coredns-health.7 b/vendor/github.com/coredns/coredns/man/coredns-health.7 deleted file mode 100644 index 23ec1d93..00000000 --- a/vendor/github.com/coredns/coredns/man/coredns-health.7 +++ /dev/null @@ -1,128 +0,0 @@ -.\" generated with Ronn/v0.7.3 -.\" http://github.com/rtomayko/ronn/tree/0.7.3 -. -.TH "COREDNS\-HEALTH" "7" "May 2018" "CoreDNS" "CoreDNS plugins" -. -.SH "NAME" -\fIhealth\fR \- enables a health check endpoint\. -. -.SH "DESCRIPTION" -By enabling \fIhealth\fR any plugin that implements healt\.Healther interface \fIhttps://godoc\.org/github\.com/coredns/coredns/plugin/health#Healther\fR will be queried for it\'s health\. The combined health is exported, by default, on port 8080/health \. -. -.SH "SYNTAX" -. -.nf - -health [ADDRESS] -. -.fi -. -.P -Optionally takes an address; the default is \fB:8080\fR\. The health path is fixed to \fB/health\fR\. The health endpoint returns a 200 response code and the word "OK" when this server is healthy\. It returns a 503\. \fIhealth\fR periodically (1s) polls plugins that exports health information\. If any of the plugins signals that it is unhealthy, the server will go unhealthy too\. Each plugin that supports health checks has a section "Health" in their README\. -. -.P -More options can be set with this extended syntax: -. -.IP "" 4 -. -.nf - -health [ADDRESS] { - lameduck DURATION -} -. -.fi -. -.IP "" 0 -. -.IP "\(bu" 4 -Where \fBlameduck\fR will make the process unhealthy then \fIwait\fR for \fBDURATION\fR before the process shuts down\. -. -.IP "" 0 -. -.P -If you have multiple Server Blocks and need to export health for each of the plugins, you must run health endpoints on different ports: -. -.IP "" 4 -. -.nf - -com { - whoami - health :8080 -} - -net { - erratic - health :8081 -} -. -.fi -. -.IP "" 0 -. -.P -Note that if you format this in one server block you will get an error on startup, that the second server can\'t setup the health plugin (on the same port)\. -. -.IP "" 4 -. -.nf - -com net { - whoami - erratic - health :8080 -} -. -.fi -. -.IP "" 0 -. -.SH "PLUGINS" -Any plugin that implements the Healther interface will be used to report health\. -. -.SH "METRICS" -If monitoring is enabled (via the \fIprometheus\fR directive) then the following metric is exported: -. -.IP "\(bu" 4 -\fBcoredns_health_request_duration_seconds{}\fR \- duration to process a /health query\. As this should be a local operation it should be fast\. A (large) increases in this duration indicates the CoreDNS process is having trouble keeping up with its query load\. -. -.IP "" 0 -. -.P -Note that this metric \fIdoes not\fR have a \fBserver\fR label, because being overloaded is a symptom of the running process, \fInot\fR a specific server\. -. -.SH "EXAMPLES" -Run another health endpoint on http://localhost:8091\. -. -.IP "" 4 -. -.nf - -\&\. { - health localhost:8091 -} -. -.fi -. -.IP "" 0 -. -.P -Set a lameduck duration of 1 second: -. -.IP "" 4 -. -.nf - -\&\. { - health localhost:8092 { - lameduck 1s - } -} -. -.fi -. -.IP "" 0 -. -.SH "BUGS" -When reloading, the Health handler is stopped before the new server instance is started\. If that new server fails to start, then the initial server instance is still available and DNS queries still served, but Health handler stays down\. Health will not reply HTTP request until a successful reload or a complete restart of CoreDNS\. diff --git a/vendor/github.com/coredns/coredns/man/coredns-hosts.7 b/vendor/github.com/coredns/coredns/man/coredns-hosts.7 deleted file mode 100644 index c89b0161..00000000 --- a/vendor/github.com/coredns/coredns/man/coredns-hosts.7 +++ /dev/null @@ -1,131 +0,0 @@ -.\" generated with Ronn/v0.7.3 -.\" http://github.com/rtomayko/ronn/tree/0.7.3 -. -.TH "COREDNS\-HOSTS" "7" "June 2018" "CoreDNS" "CoreDNS plugins" -. -.SH "NAME" -\fIhosts\fR \- enables serving zone data from a \fB/etc/hosts\fR style file\. -. -.SH "DESCRIPTION" -The hosts plugin is useful for serving zones from a \fB/etc/hosts\fR file\. It serves from a preloaded file that exists on disk\. It checks the file for changes and updates the zones accordingly\. This plugin only supports A, AAAA, and PTR records\. The hosts plugin can be used with readily available hosts files that block access to advertising servers\. -. -.P -This plugin can only be used once per Server Block\. -. -.SH "THE HOSTS FILE" -Commonly the entries are of the from \fBIP_address canonical_hostname [aliases\.\.\.]\fR as explained by the hosts(5) man page\. -. -.P -Examples: -. -.IP "" 4 -. -.nf - -# THE FOLLOWING LINES ARE DESIRABLE FOR IPV4 CAPABLE HOSTS -127\.0\.0\.1 localhost -192\.168\.1\.10 example\.com example - -# THE FOLLOWING LINES ARE DESIRABLE FOR IPV6 CAPABLE HOSTS -::1 localhost ip6\-localhost ip6\-loopback -fdfc:a744:27b5:3b0e::1 example\.com example -. -.fi -. -.IP "" 0 -. -.SS "PTR RECORDS" -PTR records for reverse lookups are generated automatically by CoreDNS (based on the hosts file entries) and cannot be created manually\. -. -.SH "SYNTAX" -. -.nf - -hosts [FILE [ZONES\.\.\.]] { - [INLINE] - fallthrough [ZONES\.\.\.] -} -. -.fi -. -.IP "\(bu" 4 -\fBFILE\fR the hosts file to read and parse\. If the path is relative the path from the \fIroot\fR directive will be prepended to it\. Defaults to /etc/hosts if omitted\. We scan the file for changes every 5 seconds\. -. -.IP "\(bu" 4 -\fBZONES\fR zones it should be authoritative for\. If empty, the zones from the configuration block are used\. -. -.IP "\(bu" 4 -\fBINLINE\fR the hosts file contents inlined in Corefile\. If there are any lines before fallthrough then all of them will be treated as the additional content for hosts file\. The specified hosts file path will still be read but entries will be overrided\. -. -.IP "\(bu" 4 -\fBfallthrough\fR If zone matches and no record can be generated, pass request to the next plugin\. If \fB[ZONES\.\.\.]\fR is omitted, then fallthrough happens for all zones for which the plugin is authoritative\. If specific zones are listed (for example \fBin\-addr\.arpa\fR and \fBip6\.arpa\fR), then only queries for those zones will be subject to fallthrough\. -. -.IP "" 0 -. -.SH "EXAMPLES" -Load \fB/etc/hosts\fR file\. -. -.IP "" 4 -. -.nf - -\&\. { - hosts -} -. -.fi -. -.IP "" 0 -. -.P -Load \fBexample\.hosts\fR file in the current directory\. -. -.IP "" 4 -. -.nf - -\&\. { - hosts example\.hosts -} -. -.fi -. -.IP "" 0 -. -.P -Load example\.hosts file and only serve example\.org and example\.net from it and fall through to the next plugin if query doesn\'t match\. -. -.IP "" 4 -. -.nf - -\&\. { - hosts example\.hosts example\.org example\.net { - fallthrough - } -} -. -.fi -. -.IP "" 0 -. -.P -Load hosts file inlined in Corefile\. -. -.IP "" 4 -. -.nf - -\&\. { - hosts example\.hosts example\.org { - 10\.0\.0\.1 example\.org - fallthrough - } -} -. -.fi -. -.IP "" 0 -. -.SH "SEE ALSO" -The form of the entries in the \fB/etc/hosts\fR file are based on IETF RFC 952 \fIhttps://tools\.ietf\.org/html/rfc952\fR which was updated by IETF RFC 1123 \fIhttps://tools\.ietf\.org/html/rfc1123\fR\. diff --git a/vendor/github.com/coredns/coredns/man/coredns-kubernetes.7 b/vendor/github.com/coredns/coredns/man/coredns-kubernetes.7 deleted file mode 100644 index 4fe00322..00000000 --- a/vendor/github.com/coredns/coredns/man/coredns-kubernetes.7 +++ /dev/null @@ -1,252 +0,0 @@ -.\" generated with Ronn/v0.7.3 -.\" http://github.com/rtomayko/ronn/tree/0.7.3 -. -.TH "COREDNS\-KUBERNETES" "7" "June 2018" "CoreDNS" "CoreDNS plugins" -. -.SH "NAME" -\fIkubernetes\fR \- enables the reading zone data from a Kubernetes cluster\. -. -.SH "DESCRIPTION" -It implements the Kubernetes DNS\-Based Service Discovery Specification \fIhttps://github\.com/kubernetes/dns/blob/master/docs/specification\.md\fR\. -. -.P -CoreDNS running the kubernetes plugin can be used as a replacement of kube\-dns in a kubernetes cluster\. See the deployment \fIhttps://github\.com/coredns/deployment\fR repository for details on how to deploy CoreDNS in Kubernetes \fIhttps://github\.com/coredns/deployment/tree/master/kubernetes\fR\. -. -.P -stubDomains and upstreamNameservers \fIhttp://blog\.kubernetes\.io/2017/04/configuring\-private\-dns\-zones\-upstream\-nameservers\-kubernetes\.html\fR are implemented via the \fIproxy\fR plugin and kubernetes \fIupstream\fR\. See example below\. -. -.P -This plugin can only be used once per Server Block\. -. -.SH "SYNTAX" -. -.nf - -kubernetes [ZONES\.\.\.] -. -.fi -. -.P -With only the directive specified, the \fIkubernetes\fR plugin will default to the zone specified in the server\'s block\. It will handle all queries in that zone and connect to Kubernetes in\-cluster\. It will not provide PTR records for services, or A records for pods\. If \fBZONES\fR is used it specifies all the zones the plugin should be authoritative for\. -. -.IP "" 4 -. -.nf - -kubernetes [ZONES\.\.\.] { - resyncperiod DURATION - endpoint URL [URL\.\.\.] - tls CERT KEY CACERT - namespaces NAMESPACE\.\.\. - labels EXPRESSION - pods POD\-MODE - endpoint_pod_names - upstream [ADDRESS\.\.\.] - ttl TTL - transfer to ADDRESS\.\.\. - fallthrough [ZONES\.\.\.] -} -. -.fi -. -.IP "" 0 -. -.IP "\(bu" 4 -\fBresyncperiod\fR specifies the Kubernetes data API \fBDURATION\fR period\. -. -.IP "\(bu" 4 -\fBendpoint\fR specifies the \fBURL\fR for a remote k8s API endpoint\. If omitted, it will connect to k8s in\-cluster using the cluster service account\. Multiple k8s API endpoints could be specified: \fBendpoint http://k8s\-endpoint1:8080 http://k8s\-endpoint2:8080\fR\. CoreDNS will automatically perform a healthcheck and proxy to the healthy k8s API endpoint\. -. -.IP "\(bu" 4 -\fBtls\fR \fBCERT\fR \fBKEY\fR \fBCACERT\fR are the TLS cert, key and the CA cert file names for remote k8s connection\. This option is ignored if connecting in\-cluster (i\.e\. endpoint is not specified)\. -. -.IP "\(bu" 4 -\fBnamespaces\fR \fBNAMESPACE [NAMESPACE\.\.\.]\fR, only exposes the k8s namespaces listed\. If this option is omitted all namespaces are exposed -. -.IP "\(bu" 4 -\fBlabels\fR \fBEXPRESSION\fR only exposes the records for Kubernetes objects that match this label selector\. The label selector syntax is described in the Kubernetes User Guide \- Labels \fIhttp://kubernetes\.io/docs/user\-guide/labels/\fR\. An example that only exposes objects labeled as "application=nginx" in the "staging" or "qa" environments, would use: \fBlabels environment in (staging, qa),application=nginx\fR\. -. -.IP "\(bu" 4 -\fBpods\fR \fBPOD\-MODE\fR sets the mode for handling IP\-based pod A records, e\.g\. \fB1\-2\-3\-4\.ns\.pod\.cluster\.local\. in A 1\.2\.3\.4\fR\. This option is provided to facilitate use of SSL certs when connecting directly to pods\. Valid values for \fBPOD\-MODE\fR: -. -.IP "\(bu" 4 -\fBdisabled\fR: Default\. Do not process pod requests, always returning \fBNXDOMAIN\fR -. -.IP "\(bu" 4 -\fBinsecure\fR: Always return an A record with IP from request (without checking k8s)\. This option is is vulnerable to abuse if used maliciously in conjunction with wildcard SSL certs\. This option is provided for backward compatibility with kube\-dns\. -. -.IP "\(bu" 4 -\fBverified\fR: Return an A record if there exists a pod in same namespace with matching IP\. This option requires substantially more memory than in insecure mode, since it will maintain a watch on all pods\. -. -.IP "" 0 - -. -.IP "\(bu" 4 -\fBendpoint_pod_names\fR uses the pod name of the pod targeted by the endpoint as the endpoint name in A records, e\.g\. \fBendpoint\-name\.my\-service\.namespace\.svc\.cluster\.local\. in A 1\.2\.3\.4\fR By default, the endpoint\-name name selection is as follows: Use the hostname of the endpoint, or if hostname is not set, use the dashed form of the endpoint IP address (e\.g\. \fB1\-2\-3\-4\.my\-service\.namespace\.svc\.cluster\.local\.\fR) If this directive is included, then name selection for endpoints changes as follows: Use the hostname of the endpoint, or if hostname is not set, use the pod name of the pod targeted by the endpoint\. If there is no pod targeted by the endpoint, use the dashed IP address form\. -. -.IP "\(bu" 4 -\fBupstream\fR [\fBADDRESS\fR\.\.\.] defines the upstream resolvers used for resolving services that point to external hosts (aka External Services aka CNAMEs)\. If no \fBADDRESS\fR is given, CoreDNS will resolve External Services against itself\. \fBADDRESS\fR can be an IP, an IP:port, or a path to a file structured like resolv\.conf\. -. -.IP "\(bu" 4 -\fBttl\fR allows you to set a custom TTL for responses\. The default (and allowed minimum) is to use 5 seconds, the maximum is capped at 3600 seconds\. -. -.IP "\(bu" 4 -\fBnoendpoints\fR will turn off the serving of endpoint records by disabling the watch on endpoints\. All endpoint queries and headless service queries will result in an NXDOMAIN\. -. -.IP "\(bu" 4 -\fBtransfer\fR enables zone transfers\. It may be specified multiples times\. \fBTo\fR signals the direction (only \fBto\fR is alllow)\. \fBADDRESS\fR must be denoted in CIDR notation (127\.0\.0\.1/32 etc\.) or just as plain addresses\. The special wildcard \fB*\fR means: the entire internet\. Sending DNS notifies is not supported\. -. -.IP "\(bu" 4 -\fBfallthrough\fR \fB[ZONES\.\.\.]\fR If a query for a record in the zones for which the plugin is authoritative results in NXDOMAIN, normally that is what the response will be\. However, if you specify this option, the query will instead be passed on down the plugin chain, which can include another plugin to handle the query\. If \fB[ZONES\.\.\.]\fR is omitted, then fallthrough happens for all zones for which the plugin is authoritative\. If specific zones are listed (for example \fBin\-addr\.arpa\fR and \fBip6\.arpa\fR), then only queries for those zones will be subject to fallthrough\. -. -.IP "\(bu" 4 -\fBignore empty_service\fR return NXDOMAIN for services without any ready endpoint addresses (e\.g\. ready pods)\. This allows the querying pod to continue searching for the service in the search path\. The search path could, for example, include another kubernetes cluster\. -. -.IP "" 0 -. -.SH "HEALTH" -This plugin implements dynamic health checking\. Currently this is limited to reporting healthy when the API has synced\. -. -.SH "EXAMPLES" -Handle all queries in the \fBcluster\.local\fR zone\. Connect to Kubernetes in\-cluster\. Also handle all \fBin\-addr\.arpa\fR \fBPTR\fR requests for \fB10\.0\.0\.0/17\fR \. Verify the existence of pods when answering pod requests\. Resolve upstream records against \fB10\.102\.3\.10\fR\. Note we show the entire server block here: -. -.IP "" 4 -. -.nf - -10\.0\.0\.0/17 cluster\.local { - kubernetes { - pods verified - upstream 10\.102\.3\.10:53 - } -} -. -.fi -. -.IP "" 0 -. -.P -Or you can selectively expose some namespaces: -. -.IP "" 4 -. -.nf - -kubernetes cluster\.local { - namespaces test staging -} -. -.fi -. -.IP "" 0 -. -.P -Connect to Kubernetes with CoreDNS running outside the cluster: -. -.IP "" 4 -. -.nf - -kubernetes cluster\.local { - endpoint https://k8s\-endpoint:8443 - tls cert key cacert -} -. -.fi -. -.IP "" 0 -. -.SH "STUBDOMAINS AND UPSTREAMNAMESERVERS" -Here we use the \fIproxy\fR plugin to implement a stubDomain that forwards \fBexample\.local\fR to the nameserver \fB10\.100\.0\.10:53\fR\. The \fIupstream\fR option in kubernetes means that ExternalName services (CNAMEs) will be resolved using the respective proxy\. Also configured is an upstreamNameserver \fB8\.8\.8\.8:53\fR that will be used for resolving names that do not fall in \fBcluster\.local\fR or \fBexample\.local\fR\. -. -.IP "" 4 -. -.nf - -\&\.:53 { - kubernetes cluster\.local { - upstream - } - proxy example\.local 10\.100\.0\.10:53 - proxy \. 8\.8\.8\.8:53 -} -. -.fi -. -.IP "" 0 -. -.P -The configuration above represents the following Kube\-DNS stubDomains and upstreamNameservers configuration\. -. -.IP "" 4 -. -.nf - - stubDomains: | - {“example\.local”: [“10\.100\.0\.10:53”]} - upstreamNameservers: | - [“8\.8\.8\.8:53”] -. -.fi -. -.IP "" 0 -. -.SH "AUTOPATH" -The \fIkubernetes\fR plugin can be used in conjunction with the \fIautopath\fR plugin\. Using this feature enables server\-side domain search path completion in kubernetes clusters\. Note: \fBpods\fR must be set to \fBverified\fR for this to function properly\. -. -.IP "" 4 -. -.nf - -cluster\.local { - autopath @kubernetes - kubernetes { - pods verified - } -} -. -.fi -. -.IP "" 0 -. -.SH "FEDERATION" -The \fIkubernetes\fR plugin can be used in conjunction with the \fIfederation\fR plugin\. Using this feature enables serving federated domains from the kubernetes clusters\. -. -.IP "" 4 -. -.nf - -cluster\.local { - federation { - prod prod\.example\.org - staging staging\.example\.org - } - kubernetes -} -. -.fi -. -.IP "" 0 -. -.SH "WILDCARDS" -Some query labels accept a wildcard value to match any value\. If a label is a valid wildcard (*, or the word "any"), then that label will match all values\. The labels that accept wildcards are: -. -.IP "\(bu" 4 -\fIendpoint\fR in an \fBA\fR record request: \fIendpoint\fR\.service\.namespace\.svc\.zone, e\.g\. \fB*\.nginx\.ns\.svc\.cluster\.local\fR -. -.IP "\(bu" 4 -\fIservice\fR in an \fBA\fR record request: \fIservice\fR\.namespace\.svc\.zone, e\.g\. \fB*\.ns\.svc\.cluster\.local\fR -. -.IP "\(bu" 4 -\fInamespace\fR in an \fBA\fR record request: service\.\fInamespace\fR\.svc\.zone, e\.g\. \fBnginx\.*\.svc\.cluster\.local\fR -. -.IP "\(bu" 4 -\fIport and/or protocol\fR in an \fBSRV\fR request: \fBport_\.\fRprotocol_\.service\.namespace\.svc\.zone\., e\.g\. \fB_http\.*\.service\.ns\.svc\.cluster\.local\fR -. -.IP "\(bu" 4 -multiple wild cards are allowed in a single query, e\.g\. \fBA\fR Request \fB*\.*\.svc\.zone\.\fR or \fBSRV\fR request \fB*\.*\.*\.*\.svc\.zone\.\fR -. -.IP "" 0 -. -.P -For example, Wildcards can be used to resolve all Endpoints for a Service as \fBA\fR records\. e\.g\.: \fB*\.service\.ns\.svc\.myzone\.local\fR will return the Endpoint IPs in the Service \fBservice\fR in namespace \fBdefault\fR: \fB*\.service\.default\.svc\.cluster\.local\. 5 IN A 192\.168\.10\.10 *\.service\.default\.svc\.cluster\.local\. 5 IN A 192\.168\.25\.15\fR This response can be randomized using the \fBloadbalance\fR plugin diff --git a/vendor/github.com/coredns/coredns/man/coredns-loadbalance.7 b/vendor/github.com/coredns/coredns/man/coredns-loadbalance.7 deleted file mode 100644 index 07ec73c1..00000000 --- a/vendor/github.com/coredns/coredns/man/coredns-loadbalance.7 +++ /dev/null @@ -1,40 +0,0 @@ -.\" generated with Ronn/v0.7.3 -.\" http://github.com/rtomayko/ronn/tree/0.7.3 -. -.TH "COREDNS\-LOADBALANCE" "7" "May 2018" "CoreDNS" "CoreDNS plugins" -. -.SH "NAME" -\fIloadbalance\fR \- acts as a round\-robin DNS loadbalancer by randomizing the order of A and AAAA records in the answer\. -. -.SH "DESCRIPTION" -See Wikipedia \fIhttps://en\.wikipedia\.org/wiki/Round\-robin_DNS\fR about the pros and cons on this setup\. It will take care to sort any CNAMEs before any address records, because some stub resolver implementations (like glibc) are particular about that\. -. -.SH "SYNTAX" -. -.nf - -loadbalance [POLICY] -. -.fi -. -.IP "\(bu" 4 -\fBPOLICY\fR is how to balance, the default is "round_robin" -. -.IP "" 0 -. -.SH "EXAMPLES" -Load balance replies coming back from Google Public DNS: -. -.IP "" 4 -. -.nf - -\&\. { - loadbalance round_robin - proxy \. 8\.8\.8\.8 8\.8\.4\.4 -} -. -.fi -. -.IP "" 0 - diff --git a/vendor/github.com/coredns/coredns/man/coredns-log.7 b/vendor/github.com/coredns/coredns/man/coredns-log.7 deleted file mode 100644 index 234668e3..00000000 --- a/vendor/github.com/coredns/coredns/man/coredns-log.7 +++ /dev/null @@ -1,257 +0,0 @@ -.\" generated with Ronn/v0.7.3 -.\" http://github.com/rtomayko/ronn/tree/0.7.3 -. -.TH "COREDNS\-LOG" "7" "May 2018" "CoreDNS" "CoreDNS plugins" -. -.SH "NAME" -\fIlog\fR \- enables query logging to standard output\. -. -.SH "DESCRIPTION" -By just using \fIlog\fR you dump all queries (and parts for the reply) on standard output\. Options exist to tweak the output a little\. -. -.P -Note that for busy servers this will incur a performance hit\. -. -.SH "SYNTAX" -. -.nf - -log -. -.fi -. -.IP "\(bu" 4 -With no arguments, a query log entry is written to \fIstdout\fR in the common log format for all requests -. -.IP "" 0 -. -.P -Or if you want/need slightly more control: -. -.IP "" 4 -. -.nf - -log [NAME] [FORMAT] -. -.fi -. -.IP "" 0 -. -.IP "\(bu" 4 -\fBNAME\fR is the name to match in order to be logged -. -.IP "\(bu" 4 -\fBFORMAT\fR is the log format to use (default is Common Log Format) -. -.IP "" 0 -. -.P -You can further specify the classes of responses that get logged: -. -.IP "" 4 -. -.nf - -log [NAME] [FORMAT] { - class CLASSES\.\.\. -} -. -.fi -. -.IP "" 0 -. -.IP "\(bu" 4 -\fBCLASSES\fR is a space\-separated list of classes of responses that should be logged -. -.IP "" 0 -. -.P -The classes of responses have the following meaning: -. -.IP "\(bu" 4 -\fBsuccess\fR: successful response -. -.IP "\(bu" 4 -\fBdenial\fR: either NXDOMAIN or NODATA (name exists, type does not) -. -.IP "\(bu" 4 -\fBerror\fR: SERVFAIL, NOTIMP, REFUSED, etc\. Anything that indicates the remote server is not willing to resolve the request\. -. -.IP "\(bu" 4 -\fBall\fR: the default \- nothing is specified\. Using of this class means that all messages will be logged whatever we mix together with "all"\. -. -.IP "" 0 -. -.P -If no class is specified, it defaults to \fIall\fR\. -. -.SH "LOG FORMAT" -You can specify a custom log format with any placeholder values\. Log supports both request and response placeholders\. -. -.P -The following place holders are supported: -. -.IP "\(bu" 4 -\fB{type}\fR: qtype of the request -. -.IP "\(bu" 4 -\fB{name}\fR: qname of the request -. -.IP "\(bu" 4 -\fB{class}\fR: qclass of the request -. -.IP "\(bu" 4 -\fB{proto}\fR: protocol used (tcp or udp) -. -.IP "\(bu" 4 -\fB{when}\fR: time of the query -. -.IP "\(bu" 4 -\fB{remote}\fR: client\'s IP address, for IPv6 addresses these are enclosed in brackets: \fB[::1]\fR -. -.IP "\(bu" 4 -\fB{size}\fR: request size in bytes -. -.IP "\(bu" 4 -\fB{port}\fR: client\'s port -. -.IP "\(bu" 4 -\fB{duration}\fR: response duration -. -.IP "\(bu" 4 -\fB{rcode}\fR: response RCODE -. -.IP "\(bu" 4 -\fB{rsize}\fR: response size -. -.IP "\(bu" 4 -\fB{>rflags}\fR: response flags, each set flag will be displayed, e\.g\. "aa, tc"\. This includes the qr bit as well\. -. -.IP "\(bu" 4 -\fB{>bufsize}\fR: the EDNS0 buffer size advertised in the query -. -.IP "\(bu" 4 -\fB{>do}\fR: is the EDNS0 DO (DNSSEC OK) bit set in the query -. -.IP "\(bu" 4 -\fB{>id}\fR: query ID -. -.IP "\(bu" 4 -\fB{>opcode}\fR: query OPCODE -. -.IP "" 0 -. -.P -The default Common Log Format is: -. -.IP "" 4 -. -.nf - -`{remote}:{port} \- [{when}] {>id} "{type} {class} {name} {proto} {size} {>do} {>bufsize}" {rcode} {>rflags} {rsize} {duration}` -. -.fi -. -.IP "" 0 -. -.SH "EXAMPLES" -Log all requests to stdout -. -.IP "" 4 -. -.nf - -\&\. { - log - whoami -} -. -.fi -. -.IP "" 0 -. -.P -Custom log format, for all zones (\fB\.\fR) -. -.IP "" 4 -. -.nf - -\&\. { - log \. "{proto} Request: {name} {type} {>id}" -} -. -.fi -. -.IP "" 0 -. -.P -Only log denials for example\.org (and below to a file) -. -.IP "" 4 -. -.nf - -\&\. { - log example\.org { - class denial - } -} -. -.fi -. -.IP "" 0 -. -.P -Log all queries which were not resolved successfully -. -.IP "" 4 -. -.nf - -\&\. { - log \. { - class denial error - } -} -. -.fi -. -.IP "" 0 -. -.P -Log all queries on which we did not get errors -. -.IP "" 4 -. -.nf - -\&\. { - log \. { - class denial success - } -} -. -.fi -. -.IP "" 0 -. -.P -Also the multiple statements can be OR\-ed, for example, we can rewrite the above case as following: -. -.IP "" 4 -. -.nf - -\&\. { - log \. { - class denial - class success - } -} -. -.fi -. -.IP "" 0 - diff --git a/vendor/github.com/coredns/coredns/man/coredns-metrics.7 b/vendor/github.com/coredns/coredns/man/coredns-metrics.7 deleted file mode 100644 index 4678f2d4..00000000 --- a/vendor/github.com/coredns/coredns/man/coredns-metrics.7 +++ /dev/null @@ -1,115 +0,0 @@ -.\" generated with Ronn/v0.7.3 -.\" http://github.com/rtomayko/ronn/tree/0.7.3 -. -.TH "COREDNS\-METRICS" "7" "May 2018" "CoreDNS" "CoreDNS plugins" -. -.SH "NAME" -\fIprometheus\fR \- enables Prometheus \fIhttps://prometheus\.io/\fR metrics\. -. -.SH "DESCRIPTION" -With \fIprometheus\fR you export metrics from CoreDNS and any plugin that has them\. The default location for the metrics is \fBlocalhost:9153\fR\. The metrics path is fixed to \fB/metrics\fR\. The following metrics are exported: -. -.IP "\(bu" 4 -\fBcoredns_build_info{version, revision, goversion}\fR \- info about CoreDNS itself\. -. -.IP "\(bu" 4 -\fBcoredns_panic_count_total{}\fR \- total number of panics\. -. -.IP "\(bu" 4 -\fBcoredns_dns_request_count_total{server, zone, proto, family}\fR \- total query count\. -. -.IP "\(bu" 4 -\fBcoredns_dns_request_duration_seconds{server, zone}\fR \- duration to process each query\. -. -.IP "\(bu" 4 -\fBcoredns_dns_request_size_bytes{server, zone, proto}\fR \- size of the request in bytes\. -. -.IP "\(bu" 4 -\fBcoredns_dns_request_do_count_total{server, zone}\fR \- queries that have the DO bit set -. -.IP "\(bu" 4 -\fBcoredns_dns_request_type_count_total{server, zone, type}\fR \- counter of queries per zone and type\. -. -.IP "\(bu" 4 -\fBcoredns_dns_response_size_bytes{server, zone, proto}\fR \- response size in bytes\. -. -.IP "\(bu" 4 -\fBcoredns_dns_response_rcode_count_total{server, zone, rcode}\fR \- response per zone and rcode\. -. -.IP "" 0 -. -.P -Each counter has a label \fBzone\fR which is the zonename used for the request/response\. -. -.P -Extra labels used are: -. -.IP "\(bu" 4 -\fBserver\fR is identifying the server responsible for the request\. This is a string formatted as the server\'s listening address: \fB://[]:\fR\. I\.e\. for a "normal" DNS server this is \fBdns://:53\fR\. If you are using the \fIbind\fR plugin an IP address is included, e\.g\.: \fBdns://127\.0\.0\.53:53\fR\. -. -.IP "\(bu" 4 -\fBproto\fR which holds the transport of the response ("udp" or "tcp") -. -.IP "\(bu" 4 -The address family (\fBfamily\fR) of the transport (1 = IP (IP version 4), 2 = IP6 (IP version 6))\. -. -.IP "\(bu" 4 -\fBtype\fR which holds the query type\. It holds most common types (A, AAAA, MX, SOA, CNAME, PTR, TXT, NS, SRV, DS, DNSKEY, RRSIG, NSEC, NSEC3, IXFR, AXFR and ANY) and "other" which lumps together all other types\. -. -.IP "\(bu" 4 -The \fBresponse_rcode_count_total\fR has an extra label \fBrcode\fR which holds the rcode of the response\. -. -.IP "" 0 -. -.P -If monitoring is enabled, queries that do not enter the plugin chain are exported under the fake name "dropped" (without a closing dot \- this is never a valid domain name)\. -. -.P -This plugin can only be used once per Server Block\. -. -.SH "SYNTAX" -. -.nf - -prometheus [ADDRESS] -. -.fi -. -.P -For each zone that you want to see metrics for\. -. -.P -It optionally takes an address to which the metrics are exported; the default is \fBlocalhost:9153\fR\. The metrics path is fixed to \fB/metrics\fR\. -. -.SH "EXAMPLES" -Use an alternative address: -. -.IP "" 4 -. -.nf - -\&\. { - prometheus localhost:9253 -} -. -.fi -. -.IP "" 0 -. -.P -Or via an enviroment variable (this is supported throughout the Corefile): \fBexport PORT=9253\fR, and then: -. -.IP "" 4 -. -.nf - -\&\. { - prometheus localhost:{$PORT} -} -. -.fi -. -.IP "" 0 -. -.SH "BUGS" -When reloading, the Prometheus handler is stopped before the new server instance is started\. If that new server fails to start, then the initial server instance is still available and DNS queries still served, but Prometheus handler stays down\. Prometheus will not reply HTTP request until a successful reload or a complete restart of CoreDNS\. diff --git a/vendor/github.com/coredns/coredns/man/coredns-nsid.7 b/vendor/github.com/coredns/coredns/man/coredns-nsid.7 deleted file mode 100644 index 3947a1d7..00000000 --- a/vendor/github.com/coredns/coredns/man/coredns-nsid.7 +++ /dev/null @@ -1,71 +0,0 @@ -.\" generated with Ronn/v0.7.3 -.\" http://github.com/rtomayko/ronn/tree/0.7.3 -. -.TH "COREDNS\-NSID" "7" "May 2018" "CoreDNS" "CoreDNS plugins" -. -.SH "NAME" -\fInsid\fR \- adds an identifier of this server to each reply\. -. -.SH "DESCRIPTION" -This plugin implements RFC 5001 \fIhttps://tools\.ietf\.org/html/rfc5001\fR and adds an EDNS0 OPT resource record to replies that uniquely identify the server\. This is useful in anycast setups to see which server was responsible for generating the reply and for debugging\. -. -.P -This plugin can only be used once per Server Block\. -. -.SH "SYNTAX" -. -.nf - -nsid [DATA] -. -.fi -. -.P -\fBDATA\fR is the string to use in the nsid record\. -. -.P -If \fBDATA\fR is not given, the host\'s name is used\. -. -.SH "EXAMPLES" -Enable nsid: -. -.IP "" 4 -. -.nf - -\&\. { - whoami - nsid Use The Force -} -. -.fi -. -.IP "" 0 -. -.P -And now a client with NSID support will see an OPT record with the NSID option: -. -.IP "" 4 -. -.nf - -% dig +nsid @localhost a whoami\.example\.org - -;; Got answer: -;; \->>HEADER<<\- opcode: QUERY, status: NOERROR, id: 46880 -;; flags: qr aa rd; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 3 - -\.\.\.\. - -; OPT PSEUDOSECTION: -; EDNS: version: 0, flags:; udp: 4096 -; NSID: 55 73 65 20 54 68 65 20 46 6f 72 63 65 ("Use The Force") -;; QUESTION SECTION: -;whoami\.example\.org\. IN A -. -.fi -. -.IP "" 0 -. -.SH "ALSO SEE" -RFC 5001 \fIhttps://tools\.ietf\.org/html/rfc5001\fR diff --git a/vendor/github.com/coredns/coredns/man/coredns-pprof.7 b/vendor/github.com/coredns/coredns/man/coredns-pprof.7 deleted file mode 100644 index 88738e25..00000000 --- a/vendor/github.com/coredns/coredns/man/coredns-pprof.7 +++ /dev/null @@ -1,78 +0,0 @@ -.\" generated with Ronn/v0.7.3 -.\" http://github.com/rtomayko/ronn/tree/0.7.3 -. -.TH "COREDNS\-PPROF" "7" "June 2018" "CoreDNS" "CoreDNS plugins" -. -.SH "NAME" -\fIpprof\fR \- publishes runtime profiling data at endpoints under \fB/debug/pprof\fR\. -. -.SH "DESCRIPTION" -You can visit \fB/debug/pprof\fR on your site for an index of the available endpoints\. By default it will listen on localhost:6053\. -. -.P -This is a debugging tool\. Certain requests (such as collecting execution traces) can be slow\. If you use pprof on a live server, consider restricting access or enabling it only temporarily\. -. -.P -This plugin can only be used once per Server Block\. -. -.SH "SYNTAX" -. -.nf - -pprof [ADDRESS] -. -.fi -. -.P -If not specified, ADDRESS defaults to localhost:6053\. -. -.SH "EXAMPLES" -Enable pprof endpoints: -. -.IP "" 4 -. -.nf - -\&\. { - pprof -} -. -.fi -. -.IP "" 0 -. -.P -And use the pprof tool to get statistics: \fBgo tool pprof http://localhost:6053\fR\. -. -.P -Listen on an alternate address: -. -.IP "" 4 -. -.nf - -\&\. { - pprof 10\.9\.8\.7:6060 -} -. -.fi -. -.IP "" 0 -. -.P -Listen on an all addresses on port 6060: -. -.IP "" 4 -. -.nf - -\&\. { - pprof :6060 -} -. -.fi -. -.IP "" 0 -. -.SH "ALSO SEE" -See Go\'s pprof documentation \fIhttps://golang\.org/pkg/net/http/pprof/\fR and Profiling Go Programs \fIhttps://blog\.golang\.org/profiling\-go\-programs\fR\. diff --git a/vendor/github.com/coredns/coredns/man/coredns-proxy.7 b/vendor/github.com/coredns/coredns/man/coredns-proxy.7 deleted file mode 100644 index 667edcfd..00000000 --- a/vendor/github.com/coredns/coredns/man/coredns-proxy.7 +++ /dev/null @@ -1,227 +0,0 @@ -.\" generated with Ronn/v0.7.3 -.\" http://github.com/rtomayko/ronn/tree/0.7.3 -. -.TH "COREDNS\-PROXY" "7" "June 2018" "CoreDNS" "CoreDNS plugins" -. -.SH "NAME" -\fIproxy\fR \- facilitates both a basic reverse proxy and a robust load balancer\. -. -.SH "DESCRIPTION" -The proxy has support for multiple backends\. The load balancing features include multiple policies, health checks, and failovers\. If all hosts fail their health check the proxy plugin will fail back to randomly selecting a target and sending packets to it\. -. -.SH "SYNTAX" -In its most basic form, a simple reverse proxy uses this syntax: -. -.IP "" 4 -. -.nf - -proxy FROM TO -. -.fi -. -.IP "" 0 -. -.IP "\(bu" 4 -\fBFROM\fR is the base domain to match for the request to be proxied\. -. -.IP "\(bu" 4 -\fBTO\fR is the destination endpoint to proxy to\. -. -.IP "" 0 -. -.P -However, advanced features including load balancing can be utilized with an expanded syntax: -. -.IP "" 4 -. -.nf - -proxy FROM TO\.\.\. { - policy random|least_conn|round_robin|sequential - fail_timeout DURATION - max_fails INTEGER - health_check PATH:PORT [DURATION] - except IGNORED_NAMES\.\.\. - spray - protocol [dns [force_tcp]|grpc [insecure|CACERT|KEY CERT|KEY CERT CACERT]] -} -. -.fi -. -.IP "" 0 -. -.IP "\(bu" 4 -\fBFROM\fR is the name to match for the request to be proxied\. -. -.IP "\(bu" 4 -\fBTO\fR is the destination endpoint to proxy to\. At least one is required, but multiple may be specified\. \fBTO\fR may be an IP:Port pair, or may reference a file in resolv\.conf format -. -.IP "\(bu" 4 -\fBpolicy\fR is the load balancing policy to use; applies only with multiple backends\. May be one of random, least_conn, round_robin or sequential\. Default is random\. -. -.IP "\(bu" 4 -\fBfail_timeout\fR specifies how long to consider a backend as down after it has failed\. While it is down, requests will not be routed to that backend\. A backend is "down" if CoreDNS fails to communicate with it\. The default value is 2 seconds ("2s")\. -. -.IP "\(bu" 4 -\fBmax_fails\fR is the number of failures within fail_timeout that are needed before considering a backend to be down\. If 0, the backend will never be marked as down\. Default is 1\. -. -.IP "\(bu" 4 -\fBhealth_check\fR will check \fBPATH\fR (on \fBPORT\fR) on each backend\. If a backend returns a status code of 200\-399, then that backend is marked healthy for double the healthcheck duration\. If it doesn\'t, it is marked as unhealthy and no requests are routed to it\. If this option is not provided then health checks are disabled\. The default duration is 4 seconds ("4s")\. -. -.IP "\(bu" 4 -\fBIGNORED_NAMES\fR in \fBexcept\fR is a space\-separated list of domains to exclude from proxying\. Requests that match none of these names will be passed through\. -. -.IP "\(bu" 4 -\fBspray\fR when all backends are unhealthy, randomly pick one to send the traffic to\. (This is a failsafe\.) -. -.IP "\(bu" 4 -\fBprotocol\fR specifies what protocol to use to speak to an upstream, \fBdns\fR (the default) is plain old DNS\. The \fBgrpc\fR option will talk to a server that has implemented the DnsService \fIhttps://github\.com/coredns/coredns/blob/master/pb/dns\.proto\fR\. -. -.IP "" 0 -. -.SH "POLICIES" -There are four load\-balancing policies available: * \fBrandom\fR (default) \- Randomly select a backend * \fBleast_conn\fR \- Select the backend with the fewest active connections * \fBround_robin\fR \- Select the backend in round\-robin fashion * \fBsequential\fR \- Select the first available backend looking by order of declaration from left to right * \fBfirst\fR \- Deprecated\. Use sequential instead -. -.P -All polices implement randomly spraying packets to backend hosts when \fIno healthy\fR hosts are available\. This is to preeempt the case where the healthchecking (as a mechanism) fails\. -. -.SH "UPSTREAM PROTOCOLS" -. -.TP -\fBdns\fR -uses the standard DNS exchange\. You can pass \fBforce_tcp\fR to make sure that the proxied connection is performed over TCP, regardless of the inbound request\'s protocol\. -. -.TP -\fBgrpc\fR -extra options are used to control how the TLS connection is made to the gRPC server\. -. -.IP "\(bu" 4 -None \- No client authentication is used, and the system CAs are used to verify the server certificate\. -. -.IP "\(bu" 4 -\fBinsecure\fR \- TLS is not used, the connection is made in plaintext (not good in production)\. -. -.IP "\(bu" 4 -\fBCACERT\fR \- No client authentication is used, and the file \fBCACERT\fR is used to verify the server certificate\. -. -.IP "\(bu" 4 -\fBKEY\fR \fBCERT\fR \- Client authentication is used with the specified key/cert pair\. The server certificate is verified with the system CAs\. -. -.IP "\(bu" 4 -\fBKEY\fR \fBCERT\fR \fBCACERT\fR \- Client authentication is used with the specified key/cert pair\. The server certificate is verified using the \fBCACERT\fR file\. -. -.IP "" 0 - -. -.SH "METRICS" -If monitoring is enabled (via the \fIprometheus\fR directive) then the following metric is exported: -. -.IP "\(bu" 4 -\fBcoredns_proxy_request_duration_seconds{server, proto, proto_proxy, family, to}\fR \- duration per upstream interaction\. -. -.IP "\(bu" 4 -\fBcoredns_proxy_request_count_total{server, proto, proto_proxy, family, to}\fR \- query count per upstream\. -. -.IP "" 0 -. -.P -Where \fBproxy_proto\fR is the protocol used (\fBdns\fR or \fBgrpc\fR) and \fBto\fR is \fBTO\fR specified in the config, \fBproto\fR is the protocol used by the incoming query ("tcp" or "udp"), family the transport family ("1" for IPv4, and "2" for IPv6)\. \fBServer\fR is the server responsible for the request (and metric)\. See the documention in the metrics plugin\. -. -.SH "EXAMPLES" -Proxy all requests within example\.org\. to a backend system: -. -.IP "" 4 -. -.nf - -proxy example\.org 127\.0\.0\.1:9005 -. -.fi -. -.IP "" 0 -. -.P -Load\-balance all requests between three backends (using random policy): -. -.IP "" 4 -. -.nf - -\&\. { - proxy \. 10\.0\.0\.10:53 10\.0\.0\.11:1053 10\.0\.0\.12 -} -. -.fi -. -.IP "" 0 -. -.P -Same as above, but round\-robin style: -. -.IP "" 4 -. -.nf - -\&\. { - proxy \. 10\.0\.0\.10:53 10\.0\.0\.11:1053 10\.0\.0\.12 { - policy round_robin - } -} -. -.fi -. -.IP "" 0 -. -.P -With health checks and proxy headers to pass hostname, IP, and scheme upstream: -. -.IP "" 4 -. -.nf - -\&\. { - proxy \. 10\.0\.0\.11:53 10\.0\.0\.11:53 10\.0\.0\.12:53 { - policy round_robin - health_check /health:8080 - } -} -. -.fi -. -.IP "" 0 -. -.P -Proxy everything except requests to miek\.nl or example\.org -. -.IP "" 4 -. -.nf - -\&\. { - proxy \. 10\.0\.0\.10:1234 { - except miek\.nl example\.org - } -} -. -.fi -. -.IP "" 0 -. -.P -Proxy everything except \fBexample\.org\fR using the host\'s \fBresolv\.conf\fR\'s nameservers: -. -.IP "" 4 -. -.nf - -\&\. { - proxy \. /etc/resolv\.conf { - except example\.org - } -} -. -.fi -. -.IP "" 0 - diff --git a/vendor/github.com/coredns/coredns/man/coredns-reload.7 b/vendor/github.com/coredns/coredns/man/coredns-reload.7 deleted file mode 100644 index a6d44e93..00000000 --- a/vendor/github.com/coredns/coredns/man/coredns-reload.7 +++ /dev/null @@ -1,121 +0,0 @@ -.\" generated with Ronn/v0.7.3 -.\" http://github.com/rtomayko/ronn/tree/0.7.3 -. -.TH "COREDNS\-RELOAD" "7" "May 2018" "CoreDNS" "CoreDNS plugins" -. -.SH "NAME" -\fIreload\fR \- allows automatic reload of a changed Corefile -. -.SH "DESCRIPTION" -This plugin allows automatic reload of a changed \fICorefile\fR\. To enable automatic reloading of \fIzone file\fR changes, use the \fBauto\fR plugin\. -. -.P -This plugin periodically checks if the Corefile has changed by reading it and calculating its MD5 checksum\. If the file has changed, it reloads CoreDNS with the new Corefile\. This eliminates the need to send a SIGHUP or SIGUSR1 after changing the Corefile\. -. -.P -The reloads are graceful \- you should not see any loss of service when the reload happens\. Even if the new Corefile has an error, CoreDNS will continue to run the old config and an error message will be printed to the log\. But see the Bugs section for failure modes\. -. -.P -In some environments (for example, Kubernetes), there may be many CoreDNS instances that started very near the same time and all share a common Corefile\. To prevent these all from reloading at the same time, some jitter is added to the reload check interval\. This is jitter from the perspective of multiple CoreDNS instances; each instance still checks on a regular interval, but all of these instances will have their reloads spread out across the jitter duration\. This isn\'t strictly necessary given that the reloads are graceful, and can be disabled by setting the jitter to \fB0s\fR\. -. -.P -Jitter is re\-calculated whenever the Corefile is reloaded\. -. -.P -This plugin can only be used once per Server Block\. -. -.SH "SYNTAX" -. -.nf - -reload [INTERVAL] [JITTER] -. -.fi -. -.IP "\(bu" 4 -The plugin will check for changes every \fBINTERVAL\fR, subject to +/\- the \fBJITTER\fR duration -. -.IP "\(bu" 4 -\fBINTERVAL\fR and \fBJITTER\fR are Golang (durations)[https://golang\.org/pkg/time/#ParseDuration] -. -.IP "\(bu" 4 -Default \fBINTERVAL\fR is 30s, default \fBJITTER\fR is 15s -. -.IP "\(bu" 4 -Minimal value for \fBINTERVAL\fR is 2s, and for \fBJITTER\fR is 1s -. -.IP "\(bu" 4 -If \fBJITTER\fR is more than half of \fBINTERVAL\fR, it will be set to half of \fBINTERVAL\fR -. -.IP "" 0 -. -.SH "EXAMPLES" -Check with the default intervals: -. -.IP "" 4 -. -.nf - -\&\. { - reload - erratic -} -. -.fi -. -.IP "" 0 -. -.P -Check every 10 seconds (jitter is automatically set to 10 / 2 = 5 in this case): -. -.IP "" 4 -. -.nf - -\&\. { - reload 10s - erratic -} -. -.fi -. -.IP "" 0 -. -.SH "BUGS" -The reload happens without data loss (i\.e\. DNS queries keep flowing), but there is a corner case where the reload fails, and you loose functionality\. Consider the following Corefile: -. -.IP "" 4 -. -.nf - -\&\. { - health :8080 - whoami -} -. -.fi -. -.IP "" 0 -. -.P -CoreDNS starts and serves health from :8080\. Now you change \fB:8080\fR to \fB:443\fR not knowing a process is already listening on that port\. The process reloads and performs the following steps: -. -.IP "1." 4 -close the listener on 8080 -. -.IP "2." 4 -reload and parse the config again -. -.IP "3." 4 -fail to start a new listener on 443 -. -.IP "4." 4 -fail loading the new Corefile, abort and keep using the old process -. -.IP "" 0 -. -.P -After the aborted attempt to reload we are left with the old proceses running, but the listener is closed in step 1; so the health endpoint is broken\. The same can hopen in the prometheus metrics plugin\. -. -.P -In general be careful with assigning new port and expecting reload to work fully\. diff --git a/vendor/github.com/coredns/coredns/man/coredns-reverse.7 b/vendor/github.com/coredns/coredns/man/coredns-reverse.7 deleted file mode 100644 index 827bf055..00000000 --- a/vendor/github.com/coredns/coredns/man/coredns-reverse.7 +++ /dev/null @@ -1,105 +0,0 @@ -.\" generated with Ronn/v0.7.3 -.\" http://github.com/rtomayko/ronn/tree/0.7.3 -. -.TH "COREDNS\-REVERSE" "7" "May 2018" "CoreDNS" "CoreDNS plugins" -. -.SH "NAME" -\fIreverse\fR \- allows for dynamic responses to PTR and the related A/AAAA requests\. -. -.SH "DESCRIPTION" -If a request matches a regular expression (see Template Syntax below) this plugin will generate a response\. This is only done for "address" records (PTR, A and AAAA)\. -. -.SH "SYNTAX" -. -.nf - -reverse NETWORK\.\.\. { - hostname TEMPLATE - [ttl TTL] - [fallthrough [ZONES\.\.\.]] - [wildcard] -. -.fi -. -.IP "\(bu" 4 -\fBNETWORK\fR one or more CIDR formatted networks to respond on\. -. -.IP "\(bu" 4 -\fBhostname\fR injects the IP and zone to a template for the hostname\. Defaults to "ip\-{IP}\.{zone[1]}"\. See below for template\. -. -.IP "\(bu" 4 -\fBttl\fR defaults to 60 -. -.IP "\(bu" 4 -\fBfallthrough\fR if zone matches and no record can be generated, pass request to the next plugin\. If \fB[ZONES\.\.\.]\fR is omitted, then fallthrough happens for all zones for which the plugin is authoritative\. If specific zones are listed (for example \fBin\-addr\.arpa\fR and \fBip6\.arpa\fR), then only queries for those zones will be subject to fallthrough\. -. -.IP "\(bu" 4 -\fBwildcard\fR allows matches to catch all subdomains as well\. -. -.IP "" 0 -. -.SS "TEMPLATE SYNTAX" -The template for the hostname is used for generating the PTR for a reverse lookup and matching the forward lookup back to an IP\. -. -.P -The \fB{ip}\fR symbol is \fBrequired\fR to make reverse work\. For IPv4 lookups the IP is directly extracted With IPv6 lookups the ":" is removed, and any zero ranged are expanded, e\.g\., "ffff::ffff" results in "ffff000000000000000000000000ffff" -. -.P -The \fB{zone[i]}\fR symbol is \fBoptional\fR and can be replaced by a fixed (zone) string\. The zone will be matched by the zones listed in \fIthis\fR configuration stanza\. \fBi\fR needs to be replaced with the index of the configured listener zones, starting with 1\. -. -.SH "EXAMPLES" -. -.nf - -arpa compute\.internal { - # proxy unmatched requests - proxy \. 8\.8\.8\.8 - - # answer requests for IPs in this network - # PTR 1\.0\.32\.10\.in\-addr\.arpa\. 3600 ip\-10\.0\.32\.1\.compute\.internal\. - # A ip\-10\.0\.32\.1\.compute\.internal\. 3600 10\.0\.32\.1 - # v6 is also possible - # PTR 1\.0\.0\.0\.0\.0\.0\.0\.0\.0\.0\.0\.0\.0\.0\.0\.0\.0\.0\.0\.0\.0\.0\.0\.0\.0\.0\.0\.1\.0\.d\.f\.ip6\.arpa\. 3600 ip\-fd010000000000000000000000000001\.compute\.internal\. - # AAAA ip\-fd010000000000000000000000000001\.compute\.internal\. 3600 fd01::1 - reverse 10\.32\.0\.0/16 fd01::/16 { - # template of the ip injection to hostname, zone resolved to compute\.internal\. - hostname ip\-{ip}\.{zone[2]} - - ttl 3600 - - # Forward unanswered or unmatched requests to proxy - # without this flag, requesting A/AAAA records on compute\.internal\. will end here\. - fallthrough - } -} -. -.fi -. -.IP "" 4 -. -.nf - -32\.10\.in\-addr\.arpa\.arpa arpa\.company\.org { - - reverse 10\.32\.0\.0/16 { - # template of the ip injection to hostname, zone resolved to arpa\.company\.org\. - hostname "ip\-{ip}\.v4\.{zone[2]}" - - ttl 3600 - - # fallthrough is not required, v4\.arpa\.company\.org\. will be only answered here - } - - # cidr closer to the ip wins, so we can overwrite the "default" - reverse 10\.32\.2\.0/24 { - # its also possible to set fix domain suffix - hostname ip\-{ip}\.fix\.arpa\.company\.org\. - - ttl 3600 - } -} -. -.fi -. -.IP "" 0 - diff --git a/vendor/github.com/coredns/coredns/man/coredns-rewrite.7 b/vendor/github.com/coredns/coredns/man/coredns-rewrite.7 deleted file mode 100644 index 14c7ec49..00000000 --- a/vendor/github.com/coredns/coredns/man/coredns-rewrite.7 +++ /dev/null @@ -1,357 +0,0 @@ -.\" generated with Ronn/v0.7.3 -.\" http://github.com/rtomayko/ronn/tree/0.7.3 -. -.TH "COREDNS\-REWRITE" "7" "June 2018" "CoreDNS" "CoreDNS plugins" -. -.SH "NAME" -\fIrewrite\fR \- performs internal message rewriting\. -. -.SH "DESCRIPTION" -Rewrites are invisible to the client\. There are simple rewrites (fast) and complex rewrites (slower), but they\'re powerful enough to accommodate most dynamic back\-end applications\. -. -.SH "SYNTAX" -A simplified/easy to digest syntax for \fIrewrite\fR is\.\.\. ~~~ rewrite [continue|stop] FIELD FROM TO ~~~ -. -.IP "\(bu" 4 -\fBFIELD\fR indicates what part of the request/response is being re\-written\. -. -.IP "\(bu" 4 -\fBtype\fR \- the type field of the request will be rewritten\. FROM/TO must be a DNS record type (\fBA\fR, \fBMX\fR, etc); e\.g\., to rewrite ANY queries to HINFO, use \fBrewrite type ANY HINFO\fR\. -. -.IP "\(bu" 4 -\fBclass\fR \- the class of the message will be rewritten\. FROM/TO must be a DNS class type (\fBIN\fR, \fBCH\fR, or \fBHS\fR) e\.g\., to rewrite CH queries to IN use \fBrewrite class CH IN\fR\. -. -.IP "\(bu" 4 -\fBname\fR \- the query name in the \fIrequest\fR is rewritten; by default this is a full match of the name, e\.g\., \fBrewrite name miek\.nl example\.org\fR\. Other match types are supported, see the \fBName Field Rewrites\fR section below\. -. -.IP "\(bu" 4 -\fBanswer name\fR \- the query name in the \fIresponse\fR is rewritten\. This option has special restrictions and requirements, in particular it must always combined with a \fBname\fR rewrite\. See below in the \fBResponse Rewrites\fR section\. -. -.IP "\(bu" 4 -\fBedns0\fR \- an EDNS0 option can be appended to the request as described below in the \fBEDNS0 Options\fR section\. -. -.IP "" 0 - -. -.IP "\(bu" 4 -\fBFROM\fR is the name or type to match -. -.IP "\(bu" 4 -\fBTO\fR is the destination name or type to rewrite to -. -.IP "" 0 -. -.P -If you specify multiple rules and an incoming query matches on multiple rules, the rewrite will behave as following * \fBcontinue\fR will continue apply the next rule in the rule list\. * \fBstop\fR will consider the current rule is the last rule and will not continue\. Default behaviour for not specifying this rule processing mode is \fBstop\fR -. -.SS "NAME FIELD REWRITES" -The \fBrewrite\fR plugin offers the ability to match on the name in the question section of a DNS request\. The match could be exact, substring, or based on a prefix, suffix, or regular expression\. -. -.P -The syntax for the name re\-writing is as follows: -. -.IP "" 4 -. -.nf - -rewrite [continue|stop] name [exact|prefix|suffix|substring|regex] STRING STRING -. -.fi -. -.IP "" 0 -. -.P -The match type, i\.e\. \fBexact\fR, \fBsubstring\fR, etc\., triggers re\-write: -. -.IP "\(bu" 4 -\fBexact\fR (default): on exact match of the name in the question section of a request -. -.IP "\(bu" 4 -\fBsubstring\fR: on a partial match of the name in the question section of a request -. -.IP "\(bu" 4 -\fBprefix\fR: when the name begins with the matching string -. -.IP "\(bu" 4 -\fBsuffix\fR: when the name ends with the matching string -. -.IP "\(bu" 4 -\fBregex\fR: when the name in the question section of a request matches a regular expression -. -.IP "" 0 -. -.P -If the match type is omitted, the \fBexact\fR match type is being assumed\. -. -.P -The following instruction allows re\-writing the name in the query that contains \fBservice\.us\-west\-1\.example\.org\fR substring\. -. -.IP "" 4 -. -.nf - -rewrite name substring service\.us\-west\-1\.example\.org service\.us\-west\-1\.consul -. -.fi -. -.IP "" 0 -. -.P -Thus: -. -.IP "\(bu" 4 -Incoming Request Name: \fBftp\.service\.us\-west\-1\.example\.org\fR -. -.IP "\(bu" 4 -Re\-written Request Name: \fBftp\.service\.us\-west\-1\.consul\fR -. -.IP "" 0 -. -.P -The following instruction uses regular expressions\. The name in a request matching \fB(\.*)\-(us\-west\-1)\e\.example\e\.org\fR regular expression is being replaces with \fB{1}\.service\.{2}\.consul\fR, where \fB{1}\fR and \fB{2}\fR are regular expression match groups\. -. -.IP "" 4 -. -.nf - -rewrite name regex (\.*)\-(us\-west\-1)\e\.example\e\.org {1}\.service\.{2}\.consul -. -.fi -. -.IP "" 0 -. -.P -Thus: -. -.IP "\(bu" 4 -Incoming Request Name: \fBftp\-us\-west\-1\.example\.org\fR -. -.IP "\(bu" 4 -Re\-written Request Name: \fBftp\.service\.us\-west\-1\.consul\fR -. -.IP "" 0 -. -.SS "RESPONSE REWRITES" -When re\-writing incoming DNS requests\' names, CoreDNS re\-writes the \fBQUESTION SECTION\fR section of the requests\. It may be necessary to re\-write the \fBANSWER SECTION\fR of the requests, because some DNS resolvers would treat the mismatch between \fBQUESTION SECTION\fR and \fBANSWER SECTION\fR as a man\-in\-the\-middle attack (MITM)\. -. -.P -For example, a user tries to resolve \fBftp\-us\-west\-1\.coredns\.rocks\fR\. The CoreDNS configuration file has the following rule: -. -.IP "" 4 -. -.nf - -rewrite name regex (\.*)\-(us\-west\-1)\e\.coredns\e\.rocks {1}\.service\.{2}\.consul -. -.fi -. -.IP "" 0 -. -.P -CoreDNS instance re\-wrote the request to \fBftp\-us\-west\-1\.coredns\.rocks\fR with \fBftp\.service\.us\-west\-1\.consul\fR and ultimately resolved it to 3 records\. The resolved records, see \fBANSWER SECTION\fR, were not from \fBcoredns\.rocks\fR, but rather from \fBservice\.us\-west\-1\.consul\fR\. -. -.IP "" 4 -. -.nf - -$ dig @10\.1\.1\.1 ftp\-us\-west\-1\.coredns\.rocks - -; <<>> DiG 9\.8\.3\-P1 <<>> @10\.1\.1\.1 ftp\-us\-west\-1\.coredns\.rocks -; (1 server found) -;; global options: +cmd -;; Got answer: -;; \->>HEADER<<\- opcode: QUERY, status: NOERROR, id: 8619 -;; flags: qr aa rd ra; QUERY: 1, ANSWER: 3, AUTHORITY: 0, ADDITIONAL: 0 - -;; QUESTION SECTION: -;ftp\-us\-west\-1\.coredns\.rocks\. IN A - -;; ANSWER SECTION: -ftp\.service\.us\-west\-1\.consul\. 0 IN A 10\.10\.10\.10 -ftp\.service\.us\-west\-1\.consul\. 0 IN A 10\.20\.20\.20 -ftp\.service\.us\-west\-1\.consul\. 0 IN A 10\.30\.30\.30 -. -.fi -. -.IP "" 0 -. -.P -The above is the mismatch\. -. -.P -The following configuration snippet allows for the re\-writing of the \fBANSWER SECTION\fR, provided that the \fBQUESTION SECTION\fR was re\-written: -. -.IP "" 4 -. -.nf - - rewrite stop { - name regex (\.*)\-(us\-west\-1)\e\.coredns\e\.rocks {1}\.service\.{2}\.consul - answer name (\.*)\e\.service\e\.(us\-west\-1)\e\.consul {1}\-{2}\.coredns\.rocks - } -. -.fi -. -.IP "" 0 -. -.P -Now, the \fBANSWER SECTION\fR matches the \fBQUESTION SECTION\fR: -. -.IP "" 4 -. -.nf - -$ dig @10\.1\.1\.1 ftp\-us\-west\-1\.coredns\.rocks - -; <<>> DiG 9\.8\.3\-P1 <<>> @10\.1\.1\.1 ftp\-us\-west\-1\.coredns\.rocks -; (1 server found) -;; global options: +cmd -;; Got answer: -;; \->>HEADER<<\- opcode: QUERY, status: NOERROR, id: 8619 -;; flags: qr aa rd ra; QUERY: 1, ANSWER: 3, AUTHORITY: 0, ADDITIONAL: 0 - -;; QUESTION SECTION: -;ftp\-us\-west\-1\.coredns\.rocks\. IN A - -;; ANSWER SECTION: -ftp\-us\-west\-1\.coredns\.rocks\. 0 IN A 10\.10\.10\.10 -ftp\-us\-west\-1\.coredns\.rocks\. 0 IN A 10\.20\.20\.20 -ftp\-us\-west\-1\.coredns\.rocks\. 0 IN A 10\.30\.30\.30 -. -.fi -. -.IP "" 0 -. -.P -The syntax for the rewrite of DNS request and response is as follows: -. -.IP "" 4 -. -.nf - -rewrite [continue|stop] { - name regex STRING STRING - answer name STRING STRING -} -. -.fi -. -.IP "" 0 -. -.P -Note that the above syntax is strict\. For response rewrites only \fBname\fR rules are allowed to match the question section, and only by match type \fBregex\fR\. The answer rewrite must be after the name, as ordered in the syntax example\. There must only be two lines (a \fBname\fR follwed by an \fBanswer\fR) in the brackets, additional rules are not supported\. -. -.P -An alternate syntax for the rewrite of DNS request and response is as follows: -. -.IP "" 4 -. -.nf - -rewrite [continue|stop] name regex STRING STRING answer name STRING STRING -. -.fi -. -.IP "" 0 -. -.SH "EDNS0 OPTIONS" -Using FIELD edns0, you can set, append, or replace specific EDNS0 options on the request\. -. -.IP "\(bu" 4 -\fBreplace\fR will modify any "matching" option with the specified option\. The criteria for "matching" varies based on EDNS0 type\. -. -.IP "\(bu" 4 -\fBappend\fR will add the option only if no matching option exists -. -.IP "\(bu" 4 -\fBset\fR will modify a matching option or add one if none is found -. -.IP "" 0 -. -.P -Currently supported are \fBEDNS0_LOCAL\fR, \fBEDNS0_NSID\fR and \fBEDNS0_SUBNET\fR\. -. -.SS "EDNS0_LOCAL" -This has two fields, code and data\. A match is defined as having the same code\. Data may be a string or a variable\. -. -.TP -A string data can be treated as hex if it starts with \fB0x\fR\. Example: - -. -.IP "" 4 -. -.nf - -\&\. { - rewrite edns0 local set 0xffee 0x61626364 - whoami -} -. -.fi -. -.IP "" 0 -. -.P -rewrites the first local option with code 0xffee, setting the data to "abcd"\. Equivalent: -. -.IP "" 4 -. -.nf - -\&\. { - rewrite edns0 local set 0xffee abcd -} -. -.fi -. -.IP "" 0 -. -.TP -A variable data is specified with a pair of curly brackets \fB{}\fR\. Following are the supported variables -{qname}, {qtype}, {client_ip}, {client_port}, {protocol}, {server_ip}, {server_port}\. -. -.P -Example: -. -.IP "" 4 -. -.nf - -rewrite edns0 local set 0xffee {client_ip} -. -.fi -. -.IP "" 0 -. -.SS "EDNS0_NSID" -This has no fields; it will add an NSID option with an empty string for the NSID\. If the option already exists and the action is \fBreplace\fR or \fBset\fR, then the NSID in the option will be set to the empty string\. -. -.SS "EDNS0_SUBNET" -This has two fields, IPv4 bitmask length and IPv6 bitmask length\. The bitmask length is used to extract the client subnet from the source IP address in the query\. -. -.P -Example: -. -.IP "" 4 -. -.nf - -rewrite edns0 subnet set 24 56 -. -.fi -. -.IP "" 0 -. -.IP "\(bu" 4 -If the query has source IP as IPv4, the first 24 bits in the IP will be the network subnet\. -. -.IP "\(bu" 4 -If the query has source IP as IPv6, the first 56 bits in the IP will be the network subnet\. -. -.IP "" 0 -. -.SH "FULL SYNTAX" -The full plugin usage syntax is harder to digest\.\.\. ~~~ rewrite [continue|stop] {type|class|edns0|name [exact|prefix|suffix|substring|regex [FROM TO answer name]]} FROM TO ~~~ -. -.P -The syntax above doesn\'t cover the multi line block option for specifying a name request+response rewrite rule described in the \fBResponse Rewrite\fR section\. diff --git a/vendor/github.com/coredns/coredns/man/coredns-root.7 b/vendor/github.com/coredns/coredns/man/coredns-root.7 deleted file mode 100644 index bfce0883..00000000 --- a/vendor/github.com/coredns/coredns/man/coredns-root.7 +++ /dev/null @@ -1,40 +0,0 @@ -.\" generated with Ronn/v0.7.3 -.\" http://github.com/rtomayko/ronn/tree/0.7.3 -. -.TH "COREDNS\-ROOT" "7" "May 2018" "CoreDNS" "CoreDNS plugins" -. -.SH "NAME" -\fIroot\fR \- simply specifies the root of where to find (zone) files\. -. -.SH "DESCRIPTION" -The default root is the current working directory of CoreDNS\. The \fIroot\fR plugin allows you to change this\. A relative root path is relative to the current working directory\. -. -.P -This plugin can only be used once per Server Block\. -. -.SH "SYNTAX" -. -.nf - -root PATH -. -.fi -. -.P -\fBPATH\fR is the directory to set as CoreDNS\' root\. -. -.SH "EXAMPLES" -Serve zone data (when the \fIfile\fR plugin is used) from \fB/etc/coredns/zones\fR: -. -.IP "" 4 -. -.nf - -\&\. { - root /etc/coredns/zones -} -. -.fi -. -.IP "" 0 - diff --git a/vendor/github.com/coredns/coredns/man/coredns-route53.7 b/vendor/github.com/coredns/coredns/man/coredns-route53.7 deleted file mode 100644 index c2b468c3..00000000 --- a/vendor/github.com/coredns/coredns/man/coredns-route53.7 +++ /dev/null @@ -1,64 +0,0 @@ -.\" generated with Ronn/v0.7.3 -.\" http://github.com/rtomayko/ronn/tree/0.7.3 -. -.TH "COREDNS\-ROUTE53" "7" "May 2018" "CoreDNS" "CoreDNS plugins" -. -.SH "NAME" -\fIroute53\fR \- enables serving zone data from AWS route53\. -. -.SH "DESCRIPTION" -The route53 plugin is useful for serving zones from resource record sets in AWS route53\. This plugin only supports A and AAAA records\. The route53 plugin can be used when coredns is deployed on AWS\. -. -.SH "SYNTAX" -. -.nf - -route53 [ZONE:HOSTED_ZONE_ID\.\.\.] { - [aws_access_key AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY] -} -. -.fi -. -.IP "\(bu" 4 -\fBZONE\fR the name of the domain to be accessed\. -. -.IP "\(bu" 4 -\fBHOSTED_ZONE_ID\fR the ID of the hosted zone that contains the resource record sets to be accessed\. -. -.IP "\(bu" 4 -\fBAWS_ACCESS_KEY_ID\fR and \fBAWS_SECRET_ACCESS_KEY\fR the AWS access key ID and secret access key to be used when query AWS (optional)\. If they are not provided, then coredns tries to access AWS credentials the same way as AWS CLI, e\.g\., environmental variables, AWS credentials file, instance profile credentials, etc\. -. -.IP "" 0 -. -.SH "EXAMPLES" -Enable route53, with implicit aws credentials: -. -.IP "" 4 -. -.nf - -\&\. { - route53 example\.org\.:Z1Z2Z3Z4DZ5Z6Z7 -} -. -.fi -. -.IP "" 0 -. -.P -Enable route53, with explicit aws credentials: -. -.IP "" 4 -. -.nf - -\&\. { - route53 example\.org\.:Z1Z2Z3Z4DZ5Z6Z7 { - aws_access_key AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY - } -} -. -.fi -. -.IP "" 0 - diff --git a/vendor/github.com/coredns/coredns/man/coredns-secondary.7 b/vendor/github.com/coredns/coredns/man/coredns-secondary.7 deleted file mode 100644 index de33575b..00000000 --- a/vendor/github.com/coredns/coredns/man/coredns-secondary.7 +++ /dev/null @@ -1,95 +0,0 @@ -.\" generated with Ronn/v0.7.3 -.\" http://github.com/rtomayko/ronn/tree/0.7.3 -. -.TH "COREDNS\-SECONDARY" "7" "May 2018" "CoreDNS" "CoreDNS plugins" -. -.SH "NAME" -\fIsecondary\fR \- enables serving a zone retrieved from a primary server\. -. -.SH "DESCRIPTION" -With \fIsecondary\fR you can transfer (via AXFR) a zone from another server\. The retrieved zone is \fInot committed\fR to disk (a violation of the RFC)\. This means restarting CoreDNS will cause it to retrieve all secondary zones\. -. -.IP "" 4 -. -.nf - -secondary [ZONES\.\.\.] -. -.fi -. -.IP "" 0 -. -.IP "\(bu" 4 -\fBZONES\fR zones it should be authoritative for\. If empty, the zones from the configuration block are used\. Note that without a remote address to \fIget\fR the zone from, the above is not that useful\. -. -.IP "" 0 -. -.P -A working syntax would be: -. -.IP "" 4 -. -.nf - -secondary [zones\.\.\.] { - transfer from ADDRESS - transfer to ADDRESS - upstream [ADDRESS\.\.\.] -} -. -.fi -. -.IP "" 0 -. -.IP "\(bu" 4 -\fBtransfer from\fR specifies from which address to fetch the zone\. It can be specified multiple times; if one does not work, another will be tried\. -. -.IP "\(bu" 4 -\fBtransfer to\fR can be enabled to allow this secondary zone to be transferred again\. -. -.IP "\(bu" 4 -\fBupstream\fR defines upstream resolvers to be used resolve external names found (think CNAMEs) pointing to external names\. This is only really useful when CoreDNS is configured as a proxy, for normal authoritative serving you don\'t need \fIor\fR want to use this\. \fBADDRESS\fR can be an IP address, and IP:port or a string pointing to a file that is structured as /etc/resolv\.conf\. If no \fBADDRESS\fR is given, CoreDNS will resolve CNAMEs against itself\. -. -.IP "" 0 -. -.P -When a zone is due to be refreshed (Refresh timer fires) a random jitter of 5 seconds is applied, before fetching\. In the case of retry this will be 2 seconds\. If there are any errors during the transfer the transfer fails; this will be logged\. -. -.SH "EXAMPLES" -Transfer \fBexample\.org\fR from 10\.0\.1\.1, and if that fails try 10\.1\.2\.1\. -. -.IP "" 4 -. -.nf - -example\.org { - secondary { - transfer from 10\.0\.1\.1 - transfer from 10\.1\.2\.1 - } -} -. -.fi -. -.IP "" 0 -. -.P -Or re\-export the retrieved zone to other secondaries\. -. -.IP "" 4 -. -.nf - -\&\. { - secondary example\.net { - transfer from 10\.1\.2\.1 - transfer to * - } -} -. -.fi -. -.IP "" 0 -. -.SH "BUGS" -Only AXFR is supported and the retrieved zone is not committed to disk\. diff --git a/vendor/github.com/coredns/coredns/man/coredns-template.7 b/vendor/github.com/coredns/coredns/man/coredns-template.7 deleted file mode 100644 index 7137c365..00000000 --- a/vendor/github.com/coredns/coredns/man/coredns-template.7 +++ /dev/null @@ -1,348 +0,0 @@ -.\" generated with Ronn/v0.7.3 -.\" http://github.com/rtomayko/ronn/tree/0.7.3 -. -.TH "COREDNS\-TEMPLATE" "7" "June 2018" "CoreDNS" "CoreDNS plugins" -. -.SH "NAME" -\fItemplate\fR \- allows for dynamic responses based on the incoming query\. -. -.SH "DESCRIPTION" -The \fItemplate\fR plugin allows you to dynamically respond to queries by just writing a (Go) template\. -. -.SH "SYNTAX" -. -.nf - -template CLASS TYPE [ZONE\.\.\.] { - [match REGEX\.\.\.] - [answer RR] - [additional RR] - [authority RR] - [\.\.\.] - [rcode CODE] - [upstream [ADDRESS\.\.\.]] - [fallthrough [ZONE\.\.\.]] -} -. -.fi -. -.IP "\(bu" 4 -\fBCLASS\fR the query class (usually IN or ANY)\. -. -.IP "\(bu" 4 -\fBTYPE\fR the query type (A, PTR, \.\.\. can be ANY to match all types)\. -. -.IP "\(bu" 4 -\fBZONE\fR the zone scope(s) for this template\. Defaults to the server zones\. -. -.IP "\(bu" 4 -\fBREGEX\fR Go regexp \fIhttps://golang\.org/pkg/regexp/\fR that are matched against the incoming question name\. Specifying no regex matches everything (default: \fB\.*\fR)\. First matching regex wins\. -. -.IP "\(bu" 4 -\fBanswer|additional|authority\fR \fBRR\fR A RFC 1035 \fIhttps://tools\.ietf\.org/html/rfc1035#section\-5\fR style resource record fragment built by a Go template \fIhttps://golang\.org/pkg/text/template/\fR that contains the reply\. -. -.IP "\(bu" 4 -\fBrcode\fR \fBCODE\fR A response code (\fBNXDOMAIN, SERVFAIL, \.\.\.\fR)\. The default is \fBSUCCESS\fR\. -. -.IP "\(bu" 4 -\fBupstream\fR [\fBADDRESS\fR\.\.\.] defines the upstream resolvers used for resolving CNAME\. If no \fBADDRESS\fR is given, CoreDNS will resolve CNAMEs against itself\. \fBADDRESS\fR can be an IP, an IP:port, or a path to a file structured like resolv\.conf\. -. -.IP "\(bu" 4 -\fBfallthrough\fR Continue with the next plugin if the zone matched but no regex matched\. If specific zones are listed (for example \fBin\-addr\.arpa\fR and \fBip6\.arpa\fR), then only queries for those zones will be subject to fallthrough\. -. -.IP "" 0 -. -.P -At least one \fBanswer\fR or \fBrcode\fR directive is needed (e\.g\. \fBrcode NXDOMAIN\fR)\. -. -.P -\fIAlso see\fR contains an additional reading list\. -. -.SH "TEMPLATES" -Each resource record is a full\-featured Go template \fIhttps://golang\.org/pkg/text/template/\fR with the following predefined data -. -.IP "\(bu" 4 -\fB\.Zone\fR the matched zone string (e\.g\. \fBexample\.\fR)\. -. -.IP "\(bu" 4 -\fB\.Name\fR the query name, as a string (lowercased)\. -. -.IP "\(bu" 4 -\fB\.Class\fR the query class (usually \fBIN\fR)\. -. -.IP "\(bu" 4 -\fB\.Type\fR the RR type requested (e\.g\. \fBPTR\fR)\. -. -.IP "\(bu" 4 -\fB\.Match\fR an array of all matches\. \fBindex \.Match 0\fR refers to the whole match\. -. -.IP "\(bu" 4 -\fB\.Group\fR a map of the named capture groups\. -. -.IP "\(bu" 4 -\fB\.Message\fR the complete incoming DNS message\. -. -.IP "\(bu" 4 -\fB\.Question\fR the matched question section\. -. -.IP "" 0 -. -.P -The output of the template must be a RFC 1035 \fIhttps://tools\.ietf\.org/html/rfc1035\fR style resource record (commonly referred to as a "zone file")\. -. -.P -\fBWARNING\fR there is a syntactical problem with Go templates and CoreDNS config files\. Expressions like \fB{{$var}}\fR will be interpreted as a reference to an environment variable by CoreDNS (and Caddy) while \fB{{ $var }}\fR will work\. See \fIBugs\fR and corefile(5)\. -. -.SH "METRICS" -If monitoring is enabled (via the \fIprometheus\fR directive) then the following metrics are exported: -. -.IP "\(bu" 4 -\fBcoredns_template_matches_total{server, regex}\fR the total number of matched requests by regex\. -. -.IP "\(bu" 4 -\fBcoredns_template_template_failures_total{server, regex,section,template}\fR the number of times the Go templating failed\. Regex, section and template label values can be used to map the error back to the config file\. -. -.IP "\(bu" 4 -\fBcoredns_template_rr_failures_total{server, regex,section,template}\fR the number of times the templated resource record was invalid and could not be parsed\. Regex, section and template label values can be used to map the error back to the config file\. -. -.IP "" 0 -. -.P -Both failure cases indicate a problem with the template configuration\. The \fBserver\fR label indicates the server incrementing the metric, see the \fImetrics\fR plugin for details\. -. -.SH "EXAMPLES" -. -.SS "RESOLVE EVERYTHING TO NXDOMAIN" -The most simplistic template is -. -.IP "" 4 -. -.nf - -\&\. { - template ANY ANY { - rcode NXDOMAIN - } -} -. -.fi -. -.IP "" 0 -. -.IP "1." 4 -This template uses the default zone (\fB\.\fR or all queries) -. -.IP "2." 4 -All queries will be answered (no \fBfallthrough\fR) -. -.IP "3." 4 -The answer is always NXDOMAIN -. -.IP "" 0 -. -.SS "RESOLVE \.INVALID AS NXDOMAIN" -The \fB\.invalid\fR domain is a reserved TLD (see RFC 2606 Reserved Top Level DNS Names \fIhttps://tools\.ietf\.org/html/rfc2606#section\-2\fR) to indicate invalid domains\. -. -.IP "" 4 -. -.nf - -\&\. { - proxy \. 8\.8\.8\.8 - - template ANY ANY invalid { - rcode NXDOMAIN - authority "invalid\. 60 {{ \.Class }} SOA ns\.invalid\. hostmaster\.invalid\. (1 60 60 60 60)" - } -} -. -.fi -. -.IP "" 0 -. -.IP "1." 4 -A query to \.invalid will result in NXDOMAIN (rcode) -. -.IP "2." 4 -A dummy SOA record is sent to hand out a TTL of 60s for caching purposes -. -.IP "3." 4 -Querying \fB\.invalid\fR in the \fBCH\fR class will also cause a NXDOMAIN/SOA response -. -.IP "4." 4 -The default regex is \fB\.*\fR -. -.IP "" 0 -. -.SS "BLOCK INVALID SEARCH DOMAIN COMPLETIONS" -Imagine you run \fBexample\.com\fR with a datacenter \fBdc1\.example\.com\fR\. The datacenter domain is part of the DNS search domain\. However \fBsomething\.example\.com\.dc1\.example\.com\fR would indicate a fully qualified domain name (\fBsomething\.example\.com\fR) that inadvertently has the default domain or search path (\fBdc1\.example\.com\fR) added\. -. -.IP "" 4 -. -.nf - -\&\. { - proxy \. 8\.8\.8\.8 - - template IN ANY example\.com\.dc1\.example\.com { - rcode NXDOMAIN - authority "{{ \.Zone }} 60 IN SOA ns\.example\.com hostmaster\.example\.com (1 60 60 60 60)" - } -} -. -.fi -. -.IP "" 0 -. -.P -A more verbose regex based equivalent would be -. -.IP "" 4 -. -.nf - -\&\. { - proxy \. 8\.8\.8\.8 - - template IN ANY example\.com { - match "example\e\.com\e\.(dc1\e\.example\e\.com\e\.)$" - rcode NXDOMAIN - authority "{{ index \.Match 1 }} 60 IN SOA ns\.{{ index \.Match 1 }} hostmaster\.{{ index \.Match 1 }} (1 60 60 60 60)" - fallthrough - } -} -. -.fi -. -.IP "" 0 -. -.P -The regex\-based version can do more complex matching/templating while zone\-based templating is easier to read and use\. -. -.SS "RESOLVE A/PTR FOR \.EXAMPLE" -. -.nf - -\&\. { - proxy \. 8\.8\.8\.8 - - # ip\-a\-b\-c\-d\.example\.com A a\.b\.c\.d - - template IN A example { - match (^|[\.])ip\-10\-(?P[0\-9]*)\-(?P[0\-9]*)\-(?P[0\-9]*)[\.]example[\.]$ - answer "{{ \.Name }} 60 IN A 10\.{{ \.Group\.b }}\.{{ \.Group\.c }}\.{{ \.Group\.d }}" - fallthrough - } - - # d\.c\.b\.a\.in\-addr\.arpa PTR ip\-a\-b\-c\-d\.example - - template IN PTR 10\.in\-addr\.arpa\. { - match ^(?P[0\-9]*)[\.](?P[0\-9]*)[\.](?P[0\-9]*)[\.]10[\.]in\-addr[\.]arpa[\.]$ - answer "{{ \.Name }} 60 IN PTR ip\-10\-{{ \.Group\.b }}\-{{ \.Group\.c }}\-{{ \.Group\.d }}\.example\.com\." - } -} -. -.fi -. -.P -An IPv4 address consists of 4 bytes, \fBa\.b\.c\.d\fR\. Named groups make it less error\-prone to reverse the IP address in the PTR case\. Try to use named groups to explain what your regex and template are doing\. -. -.P -Note that the A record is actually a wildcard: any subdomain of the IP address will resolve to the IP address\. -. -.P -Having templates to map certain PTR/A pairs is a common pattern\. -. -.P -Fallthrough is needed for mixed domains where only some responses are templated\. -. -.SS "RESOLVE MULTIPLE IP PATTERNS" -. -.nf - -\&\. { - proxy \. 8\.8\.8\.8 - - template IN A example { - match "^ip\-(?P10)\-(?P[0\-9]*)\-(?P[0\-9]*)\-(?P[0\-9]*)[\.]dc[\.]example[\.]$" - match "^(?P[0\-9]*)[\.](?P[0\-9]*)[\.](?P[0\-9]*)[\.](?P[0\-9]*)[\.]ext[\.]example[\.]$" - answer "{{ \.Name }} 60 IN A {{ \.Group\.a}}\.{{ \.Group\.b }}\.{{ \.Group\.c }}\.{{ \.Group\.d }}" - fallthrough - } -} -. -.fi -. -.P -Named capture groups can be used to template one response for multiple patterns\. -. -.SS "RESOLVE A AND MX RECORDS FOR IP TEMPLATES IN \.EXAMPLE" -. -.nf - -\&\. { - proxy \. 8\.8\.8\.8 - - template IN A example { - match ^ip\-10\-(?P[0\-9]*)\-(?P[0\-9]*)\-(?P[0\-9]*)[\.]example[\.]$ - answer "{{ \.Name }} 60 IN A 10\.{{ \.Group\.b }}\.{{ \.Group\.c }}\.{{ \.Group\.d }}" - fallthrough - } - template IN MX example { - match ^ip\-10\-(?P[0\-9]*)\-(?P[0\-9]*)\-(?P[0\-9]*)[\.]example[\.]$ - answer "{{ \.Name }} 60 IN MX 10 {{ \.Name }}" - additional "{{ \.Name }} 60 IN A 10\.{{ \.Group\.b }}\.{{ \.Group\.c }}\.{{ \.Group\.d }}" - fallthrough - } -} -. -.fi -. -.SS "ADDING AUTHORITATIVE NAMESERVERS TO THE RESPONSE" -. -.nf - -\&\. { - proxy \. 8\.8\.8\.8 - - template IN A example { - match ^ip\-10\-(?P[0\-9]*)\-(?P[0\-9]*)\-(?P[0\-9]*)[\.]example[\.]$ - answer "{{ \.Name }} 60 IN A 10\.{{ \.Group\.b }}\.{{ \.Group\.c }}\.{{ \.Group\.d }}" - authority "example\. 60 IN NS ns0\.example\." - authority "example\. 60 IN NS ns1\.example\." - additional "ns0\.example\. 60 IN A 203\.0\.113\.8" - additional "ns1\.example\. 60 IN A 198\.51\.100\.8" - fallthrough - } - template IN MX example { - match ^ip\-10\-(?P[0\-9]*)\-(?P[0\-9]*)\-(?P[0\-9]*)[\.]example[\.]$ - answer "{{ \.Name }} 60 IN MX 10 {{ \.Name }}" - additional "{{ \.Name }} 60 IN A 10\.{{ \.Group\.b }}\.{{ \.Group\.c }}\.{{ \.Group\.d }}" - authority "example\. 60 IN NS ns0\.example\." - authority "example\. 60 IN NS ns1\.example\." - additional "ns0\.example\. 60 IN A 203\.0\.113\.8" - additional "ns1\.example\. 60 IN A 198\.51\.100\.8" - fallthrough - } -} -. -.fi -. -.SH "ALSO SEE" -. -.IP "\(bu" 4 -Go regexp \fIhttps://golang\.org/pkg/regexp/\fR for details about the regex implementation -. -.IP "\(bu" 4 -RE2 syntax reference \fIhttps://github\.com/google/re2/wiki/Syntax\fR for details about the regex syntax -. -.IP "\(bu" 4 -RFC 1034 \fIhttps://tools\.ietf\.org/html/rfc1034#section\-3\.6\.1\fR and RFC 1035 \fIhttps://tools\.ietf\.org/html/rfc1035#section\-5\fR for the resource record format -. -.IP "\(bu" 4 -Go template \fIhttps://golang\.org/pkg/text/template/\fR for the template language reference -. -.IP "" 0 -. -.SH "BUGS" -CoreDNS supports caddyfile environment variables \fIhttps://caddyserver\.com/docs/caddyfile#env\fR with notion of \fB{$ENV_VAR}\fR\. This parser feature will break Go template variables \fIhttps://golang\.org/pkg/text/template/#hdr\-Variables\fR notations like\fB{{$variable}}\fR\. The equivalent notation \fB{{ $variable }}\fR will work\. Try to avoid Go template variables in the context of this plugin\. diff --git a/vendor/github.com/coredns/coredns/man/coredns-tls.7 b/vendor/github.com/coredns/coredns/man/coredns-tls.7 deleted file mode 100644 index 20aeb0d7..00000000 --- a/vendor/github.com/coredns/coredns/man/coredns-tls.7 +++ /dev/null @@ -1,68 +0,0 @@ -.\" generated with Ronn/v0.7.3 -.\" http://github.com/rtomayko/ronn/tree/0.7.3 -. -.TH "COREDNS\-TLS" "7" "May 2018" "CoreDNS" "CoreDNS plugins" -. -.SH "NAME" -\fItls\fR \- allows you to configure the server certificates for the TLS and gRPC servers\. -. -.SH "DESCRIPTION" -CoreDNS supports queries that are encrypted using TLS (DNS over Transport Layer Security, RFC 7858) or are using gRPC (https://grpc\.io/, not an IETF standard)\. Normally DNS traffic isn\'t encrypted at all (DNSSEC only signs resource records)\. -. -.P -The \fIproxy\fR plugin also support gRPC (\fBprotocol gRPC\fR), meaning you can chain CoreDNS servers using this protocol\. -. -.P -The \fItls\fR "plugin" allows you to configure the cryptographic keys that are needed for both DNS\-over\-TLS and DNS\-over\-gRPC\. If the \fBtls\fR directive is omitted, then no encryption takes place\. -. -.P -The gRPC protobuffer is defined in \fBpb/dns\.proto\fR\. It defines the proto as a simple wrapper for the wire data of a DNS message\. -. -.SH "SYNTAX" -. -.nf - -tls CERT KEY [CA] -. -.fi -. -.P -Parameter CA is optional\. If not set, system CAs can be used to verify the client certificate -. -.SH "EXAMPLES" -Start a DNS\-over\-TLS server that picks up incoming DNS\-over\-TLS queries on port 5553 and uses the nameservers defined in \fB/etc/resolv\.conf\fR to resolve the query\. This proxy path uses plain old DNS\. -. -.IP "" 4 -. -.nf - -tls://\.:5553 { - tls cert\.pem key\.pem ca\.pem - proxy \. /etc/resolv\.conf -} -. -.fi -. -.IP "" 0 -. -.P -Start a DNS\-over\-gRPC server that is similar to the previous example, but using DNS\-over\-gRPC for incoming queries\. -. -.IP "" 4 -. -.nf - -grpc://\. { - tls cert\.pem key\.pem ca\.pem - proxy \. /etc/resolv\.conf -} -. -.fi -. -.IP "" 0 -. -.P -Only Knot DNS\' \fBkdig\fR supports DNS\-over\-TLS queries, no command line client supports gRPC making debugging these transports harder than it should be\. -. -.SH "ALSO SEE" -RFC 7858 and https://grpc\.io\. diff --git a/vendor/github.com/coredns/coredns/man/coredns-trace.7 b/vendor/github.com/coredns/coredns/man/coredns-trace.7 deleted file mode 100644 index 24421ca2..00000000 --- a/vendor/github.com/coredns/coredns/man/coredns-trace.7 +++ /dev/null @@ -1,147 +0,0 @@ -.\" generated with Ronn/v0.7.3 -.\" http://github.com/rtomayko/ronn/tree/0.7.3 -. -.TH "COREDNS\-TRACE" "7" "May 2018" "CoreDNS" "CoreDNS plugins" -. -.SH "NAME" -\fItrace\fR \- enables OpenTracing\-based tracing of DNS requests as they go through the plugin chain\. -. -.SH "DESCRIPTION" -With \fItrace\fR you enable OpenTracing of how a request flows through CoreDNS\. -. -.SH "SYNTAX" -The simplest form is just: -. -.IP "" 4 -. -.nf - -trace [ENDPOINT\-TYPE] [ENDPOINT] -. -.fi -. -.IP "" 0 -. -.IP "\(bu" 4 -\fBENDPOINT\-TYPE\fR is the type of tracing destination\. Currently only \fBzipkin\fR and \fBdatadog\fR are supported\. Defaults to \fBzipkin\fR\. -. -.IP "\(bu" 4 -\fBENDPOINT\fR is the tracing destination, and defaults to \fBlocalhost:9411\fR\. For Zipkin, if ENDPOINT does not begin with \fBhttp\fR, then it will be transformed to \fBhttp://ENDPOINT/api/v1/spans\fR\. -. -.IP "" 0 -. -.P -With this form, all queries will be traced\. -. -.P -Additional features can be enabled with this syntax: -. -.IP "" 4 -. -.nf - -trace [ENDPOINT\-TYPE] [ENDPOINT] { - every AMOUNT - service NAME - client_server -} -. -.fi -. -.IP "" 0 -. -.IP "\(bu" 4 -\fBevery\fR \fBAMOUNT\fR will only trace one query of each AMOUNT queries\. For example, to trace 1 in every 100 queries, use AMOUNT of 100\. The default is 1\. -. -.IP "\(bu" 4 -\fBservice\fR \fBNAME\fR allows you to specify the service name reported to the tracing server\. Default is \fBcoredns\fR\. -. -.IP "\(bu" 4 -\fBclient_server\fR will enable the \fBClientServerSameSpan\fR OpenTracing feature\. -. -.IP "" 0 -. -.SH "ZIPKIN" -You can run Zipkin on a Docker host like this: -. -.IP "" 4 -. -.nf - -docker run \-d \-p 9411:9411 openzipkin/zipkin -. -.fi -. -.IP "" 0 -. -.SH "EXAMPLES" -Use an alternative Zipkin address: -. -.IP "" 4 -. -.nf - -trace tracinghost:9253 -. -.fi -. -.IP "" 0 -. -.P -or -. -.IP "" 4 -. -.nf - -\&\. { - trace zipkin tracinghost:9253 -} -. -.fi -. -.IP "" 0 -. -.P -If for some reason you are using an API reverse proxy or something and need to remap the standard Zipkin URL you can do something like: -. -.IP "" 4 -. -.nf - -trace http://tracinghost:9411/zipkin/api/v1/spans -. -.fi -. -.IP "" 0 -. -.P -Using DataDog: -. -.IP "" 4 -. -.nf - -trace datadog localhost:8125 -. -.fi -. -.IP "" 0 -. -.P -Trace one query every 10000 queries, rename the service, and enable same span: -. -.IP "" 4 -. -.nf - -trace tracinghost:9411 { - every 10000 - service dnsproxy - client_server -} -. -.fi -. -.IP "" 0 - diff --git a/vendor/github.com/coredns/coredns/man/coredns-whoami.7 b/vendor/github.com/coredns/coredns/man/coredns-whoami.7 deleted file mode 100644 index 1d10e1ba..00000000 --- a/vendor/github.com/coredns/coredns/man/coredns-whoami.7 +++ /dev/null @@ -1,73 +0,0 @@ -.\" generated with Ronn/v0.7.3 -.\" http://github.com/rtomayko/ronn/tree/0.7.3 -. -.TH "COREDNS\-WHOAMI" "7" "May 2018" "CoreDNS" "CoreDNS plugins" -. -.SH "NAME" -\fIwhoami\fR \- returns your resolver\'s local IP address, port and transport\. -. -.SH "DESCRIPTION" -The \fIwhoami\fR plugin is not really that useful, but can be used for having a simple (fast) endpoint to test clients against\. When \fIwhoami\fR returns a response it will have your client\'s IP address the additional section as either an A or AAAA record\. -. -.P -The reply always has an empty answer section\. The port and transport are included in the additional section as a SRV record, transport can be "tcp" or "udp"\. -. -.IP "" 4 -. -.nf - -\&\._\.qname\. 0 IN SRV 0 0 \. -. -.fi -. -.IP "" 0 -. -.P -The \fIwhoami\fR plugin will respond to every A or AAAA query, regardless of the query name\. -. -.P -If CoreDNS can\'t find a Corefile on startup this is the \fIdefault\fR plugin that gets loaded\. As such it can be used to check that CoreDNS is responding to queries\. Other than that this plugin is of limited use in production\. -. -.SH "SYNTAX" -. -.nf - -whoami -. -.fi -. -.SH "EXAMPLES" -Start a server on the default port and load the \fIwhoami\fR plugin\. -. -.IP "" 4 -. -.nf - -\&\. { - whoami -} -. -.fi -. -.IP "" 0 -. -.P -When queried for "example\.org A", CoreDNS will respond with: -. -.IP "" 4 -. -.nf - -;; QUESTION SECTION: -;example\.org\. IN A - -;; ADDITIONAL SECTION: -example\.org\. 0 IN A 10\.240\.0\.1 -_udp\.example\.org\. 0 IN SRV 0 0 40212 -. -.fi -. -.IP "" 0 -. -.SH "SEE ALSO" -Read the blog post \fIhttps://coredns\.io/2017/03/01/how\-to\-add\-plugins\-to\-coredns/\fR on how this plugin is built, or explore the source code \fIhttps://github\.com/coredns/coredns/blob/master/plugin/whoami/\fR\. diff --git a/vendor/github.com/coredns/coredns/man/coredns.1 b/vendor/github.com/coredns/coredns/man/coredns.1 deleted file mode 100644 index 0f8576b6..00000000 --- a/vendor/github.com/coredns/coredns/man/coredns.1 +++ /dev/null @@ -1,59 +0,0 @@ -.\" generated with Ronn/v0.7.3 -.\" http://github.com/rtomayko/ronn/tree/0.7.3 -. -.TH "COREDNS" "1" "June 2018" "CoreDNS" "CoreDNS" -. -.SH "NAME" -\fBcoredns\fR -. -.SH "NAME" -\fIcoredns\fR \- plugable DNS nameserver optimized for service discovery and flexibility\. -. -.SH "SYNOPSIS" -\fIcoredns\fR \fI[OPTION]\fR\.\.\. -. -.SH "DESCRIPTION" -CoreDNS is a DNS server that chains plugins\. Each plugin handles a DNS feature, like rewriting queries, kubernetes service discovery or just exporting metrics\. There are many other plugins, each described on \fIhttps://coredns\.io/plugins\fR and there respective manual pages\. Plugins not bundled in CoreDNS are listed on \fIhttps://coredns\.io/explugins\fR\. -. -.P -When started with no options CoreDNS will looks for a file names \fBCorefile\fR in the current directory, if found it will parse its contents and start up accordingly\. If no \fBCorefile\fR is found it will start with the \fIwhoami\fR plugin (coredns\-whoami(7)) and start listening on port 53 (unless overriden with \fB\-dns\.port\fR)\. -. -.P -Available options: -. -.TP -\fB\-conf\fR \fBFILE\fR -specificy Corefile to load\. -. -.TP -\fB\-cpu\fR \fBCAP\fR -specify maximum CPU capacity in percent\. -. -.TP -\fB\-dns\.port\fR \fBPORT\fR -override default port (53) to listen on\. -. -.TP -\fB\-pidfile\fR \fBFILE\fR -write PID to \fBFILE\fR\. -. -.TP -\fB\-plugins\fR -list all plugins and quit\. -. -.TP -\fB\-quiet\fR -don\'t print any version and port information on startup\. -. -.TP -\fB\-version\fR -show version and quit\. -. -.SH "AUTHORS" -CoreDNS Authors\. -. -.SH "COPYRIGHT" -Apache License 2\.0 -. -.SH "SEE ALSO" -Corefile(5) coredns\-debug(7) coredns\-dnssec(7) coredns\-health(7) coredns\-log(7) coredns\-file(7) coredns\-nsid(7) coredns\-auto(7) coredns\-erratic(7) coredns\-chaos(7) coredns\-dnstap(7) coredns\-pprof(7) coredns\-tls(7) coredns\-loadbalance(7) coredns\-cache(7) coredns\-root(7) coredns\-whoami(7) coredns\-bind(7) coredns\-hosts(7) coredns\-template(7) coredns\-proxy(7) coredns\-autopath(7) coredns\-kubernetes(7) coredns\-forward(7) coredns\-secondary(7) coredns\-route53(7) coredns\-errors(7) coredns\-metrics(7) coredns\-reload(7) coredns\-rewrite(7) coredns\-federation(7) coredns\-etcd(7) coredns\-trace(7)\. diff --git a/vendor/github.com/coredns/coredns/man/corefile.5 b/vendor/github.com/coredns/coredns/man/corefile.5 deleted file mode 100644 index caca3254..00000000 --- a/vendor/github.com/coredns/coredns/man/corefile.5 +++ /dev/null @@ -1,166 +0,0 @@ -.\" generated with Ronn/v0.7.3 -.\" http://github.com/rtomayko/ronn/tree/0.7.3 -. -.TH "COREFILE" "5" "May 2018" "CoreDNS" "CoreDNS" -. -.SH "NAME" -\fBcorefile\fR -. -.SH "NAME" -\fIcorefile\fR \- configuration file for CoreDNS -. -.SH "DESCRIPTION" -A \fIcorefile\fR specifies the (internal) servers CoreDNS should run and what plugins each of these should chain\. The syntax is as follows: -. -.IP "" 4 -. -.nf - -[SCHEME://]ZONE [[SCHEME://]ZONE]\.\.\.[:PORT] { - [PLUGIN]\.\.\. -} -. -.fi -. -.IP "" 0 -. -.P -The \fBZONE\fR defines for which name this server should be called, multiple zones are allowed and should be \fIwhite space\fR separated\. You can use a "reverse" syntax to specify a reverse zone (i\.e\. ip6\.arpa and in\-addr\.arpa), but using an IP address in the CIDR notation\. The optional \fBSCHEME\fR defaults to \fBdns://\fR, but can also be \fBtls://\fR (DNS over TLS) or \fBgrpc://\fR (DNS over gRPC)\. -. -.P -Specifying a \fBZONE\fR \fIand\fR \fBPORT\fR combination multiple time for \fIdifferent\fR servers will lead to an error on startup\. -. -.P -When a query comes in it is matched again all zones for all servers, the server with the longest match on the query name will receive the query\. -. -.P -The optional \fBPORT\fR controls on which port the server will bind, this default to 53\. If you use a port number here, you \fIcan\'t\fR override it with \fB\-dns\.port\fR (coredns(1))\. -. -.P -\fBPLUGIN\fR defines the plugin(s) we want to load into this server\. This is optional as well, but as server with no plugins will just return SERVFAIL for all queries\. Each plugin can have a number of properties than can have arguments, see documentation for each plugin\. -. -.P -Comments begin with an unquoted hash \fB#\fR and continue to the end of the line\. Comments may be started anywhere on a line\. -. -.P -Enviroment variables are supported and either the Unix or Windows form may be used: \fB{$ENV_VAR_1}\fR or \fB{%ENV_VAR_2%}\fR\. -. -.P -You can use the \fBimport\fR "plugin" to include parts of other files, see \fIhttps://coredns\.io/explugins/import\fR\. -. -.P -If CoreDNS can’t find a Corefile to load it loads the following builtin one: -. -.IP "" 4 -. -.nf - -\&\. { - whoami -} -. -.fi -. -.IP "" 0 -. -.SH "EXAMPLES" -The \fBZONE\fR is root zone \fB\.\fR, the \fBPLUGIN\fR is chaos\. The chaos plugin takes an argument: \fBCoreDNS\-001\fR\. This text is returned on a CH class query: \fBdig CH txt version\.bind @localhost\fR\. -. -.IP "" 4 -. -.nf - -\&\. { - chaos CoreDNS\-001 -} -. -.fi -. -.IP "" 0 -. -.P -When defining a new zone, you either create a new server, or add it to an existing one\. Here we define one server that handles two zones; that potentially chain different plugins: -. -.IP "" 4 -. -.nf - -example\.org { - whoami -} -org { - whoami -} -. -.fi -. -.IP "" 0 -. -.P -Is identical to: -. -.IP "" 4 -. -.nf - -example\.org org { - whoami -} -. -.fi -. -.IP "" 0 -. -.P -Reverse zones can be specified as domain names: -. -.IP "" 4 -. -.nf - -0\.0\.10\.in\-addr\.arpa { - whoami -} -. -.fi -. -.IP "" 0 -. -.P -or by just using the CIDR notation: -. -.IP "" 4 -. -.nf - -10\.0\.0\.0/24 { - whoami -} -. -.fi -. -.IP "" 0 -. -.P -This also works on a non octet boundary: -. -.IP "" 4 -. -.nf - -10\.0\.0\.0/27 { - whoami -} -. -.fi -. -.IP "" 0 -. -.SH "AUTHORS" -CoreDNS Authors\. -. -.SH "COPYRIGHT" -Apache License 2\.0 -. -.SH "SEE ALSO" -The manual page for CoreDNS: coredns(1) and more documentation on \fIhttps://coredns\.io\fR\. diff --git a/vendor/github.com/coredns/coredns/pb/dns.pb.go b/vendor/github.com/coredns/coredns/pb/dns.pb.go index 0c75de94..d79e24f6 100644 --- a/vendor/github.com/coredns/coredns/pb/dns.pb.go +++ b/vendor/github.com/coredns/coredns/pb/dns.pb.go @@ -1,6 +1,5 @@ -// Code generated by protoc-gen-go. +// Code generated by protoc-gen-go. DO NOT EDIT. // source: dns.proto -// DO NOT EDIT! /* Package pb is a generated protocol buffer package. @@ -10,6 +9,10 @@ It is generated from these files: It has these top-level messages: DnsPacket + WatchRequest + WatchCreateRequest + WatchCancelRequest + WatchResponse */ package pb @@ -19,7 +22,6 @@ import math "math" import ( context "context" - grpc "google.golang.org/grpc" ) @@ -50,8 +52,223 @@ func (m *DnsPacket) GetMsg() []byte { return nil } +type WatchRequest struct { + // request_union is a request to either create a new watcher or cancel an existing watcher. + // + // Types that are valid to be assigned to RequestUnion: + // *WatchRequest_CreateRequest + // *WatchRequest_CancelRequest + RequestUnion isWatchRequest_RequestUnion `protobuf_oneof:"request_union"` +} + +func (m *WatchRequest) Reset() { *m = WatchRequest{} } +func (m *WatchRequest) String() string { return proto.CompactTextString(m) } +func (*WatchRequest) ProtoMessage() {} +func (*WatchRequest) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{1} } + +type isWatchRequest_RequestUnion interface { + isWatchRequest_RequestUnion() +} + +type WatchRequest_CreateRequest struct { + CreateRequest *WatchCreateRequest `protobuf:"bytes,1,opt,name=create_request,json=createRequest,oneof"` +} +type WatchRequest_CancelRequest struct { + CancelRequest *WatchCancelRequest `protobuf:"bytes,2,opt,name=cancel_request,json=cancelRequest,oneof"` +} + +func (*WatchRequest_CreateRequest) isWatchRequest_RequestUnion() {} +func (*WatchRequest_CancelRequest) isWatchRequest_RequestUnion() {} + +func (m *WatchRequest) GetRequestUnion() isWatchRequest_RequestUnion { + if m != nil { + return m.RequestUnion + } + return nil +} + +func (m *WatchRequest) GetCreateRequest() *WatchCreateRequest { + if x, ok := m.GetRequestUnion().(*WatchRequest_CreateRequest); ok { + return x.CreateRequest + } + return nil +} + +func (m *WatchRequest) GetCancelRequest() *WatchCancelRequest { + if x, ok := m.GetRequestUnion().(*WatchRequest_CancelRequest); ok { + return x.CancelRequest + } + return nil +} + +// XXX_OneofFuncs is for the internal use of the proto package. +func (*WatchRequest) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) error, func(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error), func(msg proto.Message) (n int), []interface{}) { + return _WatchRequest_OneofMarshaler, _WatchRequest_OneofUnmarshaler, _WatchRequest_OneofSizer, []interface{}{ + (*WatchRequest_CreateRequest)(nil), + (*WatchRequest_CancelRequest)(nil), + } +} + +func _WatchRequest_OneofMarshaler(msg proto.Message, b *proto.Buffer) error { + m := msg.(*WatchRequest) + // request_union + switch x := m.RequestUnion.(type) { + case *WatchRequest_CreateRequest: + b.EncodeVarint(1<<3 | proto.WireBytes) + if err := b.EncodeMessage(x.CreateRequest); err != nil { + return err + } + case *WatchRequest_CancelRequest: + b.EncodeVarint(2<<3 | proto.WireBytes) + if err := b.EncodeMessage(x.CancelRequest); err != nil { + return err + } + case nil: + default: + return fmt.Errorf("WatchRequest.RequestUnion has unexpected type %T", x) + } + return nil +} + +func _WatchRequest_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error) { + m := msg.(*WatchRequest) + switch tag { + case 1: // request_union.create_request + if wire != proto.WireBytes { + return true, proto.ErrInternalBadWireType + } + msg := new(WatchCreateRequest) + err := b.DecodeMessage(msg) + m.RequestUnion = &WatchRequest_CreateRequest{msg} + return true, err + case 2: // request_union.cancel_request + if wire != proto.WireBytes { + return true, proto.ErrInternalBadWireType + } + msg := new(WatchCancelRequest) + err := b.DecodeMessage(msg) + m.RequestUnion = &WatchRequest_CancelRequest{msg} + return true, err + default: + return false, nil + } +} + +func _WatchRequest_OneofSizer(msg proto.Message) (n int) { + m := msg.(*WatchRequest) + // request_union + switch x := m.RequestUnion.(type) { + case *WatchRequest_CreateRequest: + s := proto.Size(x.CreateRequest) + n += proto.SizeVarint(1<<3 | proto.WireBytes) + n += proto.SizeVarint(uint64(s)) + n += s + case *WatchRequest_CancelRequest: + s := proto.Size(x.CancelRequest) + n += proto.SizeVarint(2<<3 | proto.WireBytes) + n += proto.SizeVarint(uint64(s)) + n += s + case nil: + default: + panic(fmt.Sprintf("proto: unexpected type %T in oneof", x)) + } + return n +} + +type WatchCreateRequest struct { + Query *DnsPacket `protobuf:"bytes,1,opt,name=query" json:"query,omitempty"` +} + +func (m *WatchCreateRequest) Reset() { *m = WatchCreateRequest{} } +func (m *WatchCreateRequest) String() string { return proto.CompactTextString(m) } +func (*WatchCreateRequest) ProtoMessage() {} +func (*WatchCreateRequest) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{2} } + +func (m *WatchCreateRequest) GetQuery() *DnsPacket { + if m != nil { + return m.Query + } + return nil +} + +type WatchCancelRequest struct { + // watch_id is the watcher id to cancel + WatchId int64 `protobuf:"varint,1,opt,name=watch_id,json=watchId" json:"watch_id,omitempty"` +} + +func (m *WatchCancelRequest) Reset() { *m = WatchCancelRequest{} } +func (m *WatchCancelRequest) String() string { return proto.CompactTextString(m) } +func (*WatchCancelRequest) ProtoMessage() {} +func (*WatchCancelRequest) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{3} } + +func (m *WatchCancelRequest) GetWatchId() int64 { + if m != nil { + return m.WatchId + } + return 0 +} + +type WatchResponse struct { + // watch_id is the ID of the watcher that corresponds to the response. + WatchId int64 `protobuf:"varint,1,opt,name=watch_id,json=watchId" json:"watch_id,omitempty"` + // created is set to true if the response is for a create watch request. + // The client should record the watch_id and expect to receive DNS replies + // from the same stream. + // All replies sent to the created watcher will attach with the same watch_id. + Created bool `protobuf:"varint,2,opt,name=created" json:"created,omitempty"` + // canceled is set to true if the response is for a cancel watch request. + // No further events will be sent to the canceled watcher. + Canceled bool `protobuf:"varint,3,opt,name=canceled" json:"canceled,omitempty"` + Qname string `protobuf:"bytes,4,opt,name=qname" json:"qname,omitempty"` + Err string `protobuf:"bytes,5,opt,name=err" json:"err,omitempty"` +} + +func (m *WatchResponse) Reset() { *m = WatchResponse{} } +func (m *WatchResponse) String() string { return proto.CompactTextString(m) } +func (*WatchResponse) ProtoMessage() {} +func (*WatchResponse) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{4} } + +func (m *WatchResponse) GetWatchId() int64 { + if m != nil { + return m.WatchId + } + return 0 +} + +func (m *WatchResponse) GetCreated() bool { + if m != nil { + return m.Created + } + return false +} + +func (m *WatchResponse) GetCanceled() bool { + if m != nil { + return m.Canceled + } + return false +} + +func (m *WatchResponse) GetQname() string { + if m != nil { + return m.Qname + } + return "" +} + +func (m *WatchResponse) GetErr() string { + if m != nil { + return m.Err + } + return "" +} + func init() { proto.RegisterType((*DnsPacket)(nil), "coredns.dns.DnsPacket") + proto.RegisterType((*WatchRequest)(nil), "coredns.dns.WatchRequest") + proto.RegisterType((*WatchCreateRequest)(nil), "coredns.dns.WatchCreateRequest") + proto.RegisterType((*WatchCancelRequest)(nil), "coredns.dns.WatchCancelRequest") + proto.RegisterType((*WatchResponse)(nil), "coredns.dns.WatchResponse") } // Reference imports to suppress errors if they are not otherwise used. @@ -66,6 +283,7 @@ const _ = grpc.SupportPackageIsVersion4 type DnsServiceClient interface { Query(ctx context.Context, in *DnsPacket, opts ...grpc.CallOption) (*DnsPacket, error) + Watch(ctx context.Context, opts ...grpc.CallOption) (DnsService_WatchClient, error) } type dnsServiceClient struct { @@ -85,10 +303,42 @@ func (c *dnsServiceClient) Query(ctx context.Context, in *DnsPacket, opts ...grp return out, nil } +func (c *dnsServiceClient) Watch(ctx context.Context, opts ...grpc.CallOption) (DnsService_WatchClient, error) { + stream, err := grpc.NewClientStream(ctx, &_DnsService_serviceDesc.Streams[0], c.cc, "/coredns.dns.DnsService/Watch", opts...) + if err != nil { + return nil, err + } + x := &dnsServiceWatchClient{stream} + return x, nil +} + +type DnsService_WatchClient interface { + Send(*WatchRequest) error + Recv() (*WatchResponse, error) + grpc.ClientStream +} + +type dnsServiceWatchClient struct { + grpc.ClientStream +} + +func (x *dnsServiceWatchClient) Send(m *WatchRequest) error { + return x.ClientStream.SendMsg(m) +} + +func (x *dnsServiceWatchClient) Recv() (*WatchResponse, error) { + m := new(WatchResponse) + if err := x.ClientStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + // Server API for DnsService service type DnsServiceServer interface { Query(context.Context, *DnsPacket) (*DnsPacket, error) + Watch(DnsService_WatchServer) error } func RegisterDnsServiceServer(s *grpc.Server, srv DnsServiceServer) { @@ -113,6 +363,32 @@ func _DnsService_Query_Handler(srv interface{}, ctx context.Context, dec func(in return interceptor(ctx, in, info, handler) } +func _DnsService_Watch_Handler(srv interface{}, stream grpc.ServerStream) error { + return srv.(DnsServiceServer).Watch(&dnsServiceWatchServer{stream}) +} + +type DnsService_WatchServer interface { + Send(*WatchResponse) error + Recv() (*WatchRequest, error) + grpc.ServerStream +} + +type dnsServiceWatchServer struct { + grpc.ServerStream +} + +func (x *dnsServiceWatchServer) Send(m *WatchResponse) error { + return x.ServerStream.SendMsg(m) +} + +func (x *dnsServiceWatchServer) Recv() (*WatchRequest, error) { + m := new(WatchRequest) + if err := x.ServerStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + var _DnsService_serviceDesc = grpc.ServiceDesc{ ServiceName: "coredns.dns.DnsService", HandlerType: (*DnsServiceServer)(nil), @@ -122,20 +398,40 @@ var _DnsService_serviceDesc = grpc.ServiceDesc{ Handler: _DnsService_Query_Handler, }, }, - Streams: []grpc.StreamDesc{}, + Streams: []grpc.StreamDesc{ + { + StreamName: "Watch", + Handler: _DnsService_Watch_Handler, + ServerStreams: true, + ClientStreams: true, + }, + }, Metadata: "dns.proto", } func init() { proto.RegisterFile("dns.proto", fileDescriptor0) } var fileDescriptor0 = []byte{ - // 120 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xe2, 0xe2, 0x4c, 0xc9, 0x2b, 0xd6, - 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x4e, 0xce, 0x2f, 0x4a, 0x05, 0x71, 0x53, 0xf2, 0x8a, - 0x95, 0x64, 0xb9, 0x38, 0x5d, 0xf2, 0x8a, 0x03, 0x12, 0x93, 0xb3, 0x53, 0x4b, 0x84, 0x04, 0xb8, - 0x98, 0x73, 0x8b, 0xd3, 0x25, 0x18, 0x15, 0x18, 0x35, 0x78, 0x82, 0x40, 0x4c, 0x23, 0x57, 0x2e, - 0x2e, 0x97, 0xbc, 0xe2, 0xe0, 0xd4, 0xa2, 0xb2, 0xcc, 0xe4, 0x54, 0x21, 0x73, 0x2e, 0xd6, 0xc0, - 0xd2, 0xd4, 0xa2, 0x4a, 0x21, 0x31, 0x3d, 0x24, 0x33, 0xf4, 0xe0, 0x06, 0x48, 0xe1, 0x10, 0x77, - 0x62, 0x89, 0x62, 0x2a, 0x48, 0x4a, 0x62, 0x03, 0xdb, 0x6f, 0x0c, 0x08, 0x00, 0x00, 0xff, 0xff, - 0xf5, 0xd1, 0x3f, 0x26, 0x8c, 0x00, 0x00, 0x00, + // 333 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x52, 0x41, 0x4f, 0x32, 0x31, + 0x14, 0xfc, 0x0a, 0xec, 0x07, 0x3c, 0x40, 0xcd, 0x8b, 0x31, 0xcb, 0x26, 0x46, 0xb2, 0x27, 0x0e, + 0x06, 0x0d, 0x1e, 0xbc, 0xaf, 0x1c, 0xf0, 0xa6, 0xf5, 0x60, 0xe2, 0x85, 0x2c, 0xdd, 0x17, 0x25, + 0x4a, 0x17, 0xda, 0x45, 0xe3, 0x3f, 0xd0, 0xdf, 0xe3, 0x1f, 0x34, 0xfb, 0xba, 0x90, 0x35, 0x88, + 0xb7, 0xce, 0x74, 0x3a, 0xed, 0xcc, 0x2b, 0x34, 0x13, 0x6d, 0x07, 0x0b, 0x93, 0x66, 0x29, 0xb6, + 0x54, 0x6a, 0x28, 0x87, 0x89, 0xb6, 0xe1, 0x31, 0x34, 0x47, 0xda, 0xde, 0xc4, 0xea, 0x99, 0x32, + 0x3c, 0x80, 0xea, 0xdc, 0x3e, 0xfa, 0xa2, 0x27, 0xfa, 0x6d, 0x99, 0x2f, 0xc3, 0x2f, 0x01, 0xed, + 0xfb, 0x38, 0x53, 0x4f, 0x92, 0x96, 0x2b, 0xb2, 0x19, 0x8e, 0x61, 0x4f, 0x19, 0x8a, 0x33, 0x9a, + 0x18, 0xc7, 0xb0, 0xba, 0x35, 0x3c, 0x19, 0x94, 0x5c, 0x07, 0x7c, 0xe4, 0x8a, 0x75, 0xc5, 0xc1, + 0xf1, 0x3f, 0xd9, 0x51, 0x65, 0x82, 0x9d, 0x62, 0xad, 0xe8, 0x65, 0xe3, 0x54, 0xd9, 0xe9, 0xc4, + 0xba, 0xb2, 0x53, 0x99, 0x88, 0xf6, 0xa1, 0x53, 0x58, 0x4c, 0x56, 0x7a, 0x96, 0xea, 0x30, 0x02, + 0xdc, 0x7e, 0x01, 0x9e, 0x82, 0xb7, 0x5c, 0x91, 0x79, 0x2f, 0x5e, 0x7c, 0xf4, 0xe3, 0x9e, 0x4d, + 0x09, 0xd2, 0x89, 0xc2, 0xb3, 0xb5, 0x47, 0xf9, 0x2a, 0xec, 0x42, 0xe3, 0x2d, 0x67, 0x27, 0xb3, + 0x84, 0x6d, 0xaa, 0xb2, 0xce, 0xf8, 0x3a, 0x09, 0x3f, 0x04, 0x74, 0x8a, 0xaa, 0xec, 0x22, 0xd5, + 0x96, 0xfe, 0x10, 0xa3, 0x0f, 0x75, 0xd7, 0x46, 0xc2, 0xa9, 0x1b, 0x72, 0x0d, 0x31, 0x80, 0x86, + 0x4b, 0x47, 0x89, 0x5f, 0xe5, 0xad, 0x0d, 0xc6, 0x43, 0xf0, 0x96, 0x3a, 0x9e, 0x93, 0x5f, 0xeb, + 0x89, 0x7e, 0x53, 0x3a, 0x90, 0x4f, 0x8d, 0x8c, 0xf1, 0x3d, 0xe6, 0xf2, 0xe5, 0xf0, 0x53, 0x00, + 0x8c, 0xb4, 0xbd, 0x23, 0xf3, 0x3a, 0x53, 0x84, 0x97, 0xe0, 0xdd, 0xe6, 0x99, 0x70, 0x47, 0xe4, + 0x60, 0x07, 0x8f, 0x11, 0x78, 0x9c, 0x08, 0xbb, 0xdb, 0x33, 0x29, 0x1a, 0x09, 0x82, 0xdf, 0xb6, + 0x5c, 0x01, 0x7d, 0x71, 0x2e, 0xa2, 0xda, 0x43, 0x65, 0x31, 0x9d, 0xfe, 0xe7, 0xaf, 0x77, 0xf1, + 0x1d, 0x00, 0x00, 0xff, 0xff, 0xd2, 0x5b, 0x8c, 0xe1, 0x87, 0x02, 0x00, 0x00, } diff --git a/vendor/github.com/coredns/coredns/pb/dns.proto b/vendor/github.com/coredns/coredns/pb/dns.proto index 8461f01e..e4ac2eb2 100644 --- a/vendor/github.com/coredns/coredns/pb/dns.proto +++ b/vendor/github.com/coredns/coredns/pb/dns.proto @@ -9,4 +9,41 @@ message DnsPacket { service DnsService { rpc Query (DnsPacket) returns (DnsPacket); + rpc Watch (stream WatchRequest) returns (stream WatchResponse); +} + +message WatchRequest { + // request_union is a request to either create a new watcher or cancel an existing watcher. + oneof request_union { + WatchCreateRequest create_request = 1; + WatchCancelRequest cancel_request = 2; + } +} + +message WatchCreateRequest { + DnsPacket query = 1; +} + +message WatchCancelRequest { + // watch_id is the watcher id to cancel + int64 watch_id = 1; +} + +message WatchResponse { + // watch_id is the ID of the watcher that corresponds to the response. + int64 watch_id = 1; + + // created is set to true if the response is for a create watch request. + // The client should record the watch_id and expect to receive DNS replies + // from the same stream. + // All replies sent to the created watcher will attach with the same watch_id. + bool created = 2; + + // canceled is set to true if the response is for a cancel watch request. + // No further events will be sent to the canceled watcher. + bool canceled = 3; + + string qname = 4; + + string err = 5; } diff --git a/vendor/github.com/coredns/coredns/plugin.cfg b/vendor/github.com/coredns/coredns/plugin.cfg deleted file mode 100644 index c152684b..00000000 --- a/vendor/github.com/coredns/coredns/plugin.cfg +++ /dev/null @@ -1,55 +0,0 @@ -# Directives are registered in the order they should be -# executed. -# -# Ordering is VERY important. Every plugin will -# feel the effects of all other plugin below -# (after) them during a request, but they must not -# care what plugin above them are doing. - -# How to rebuild with updated plugin configurations: -# Modify the list below and run `go gen && go build` - -# The parser takes the input format of -# : -# Or -# : -# -# External plugin example: -# log:github.com/coredns/coredns/plugin/log -# Local plugin example: -# log:log - -tls:tls -reload:reload -nsid:nsid -root:root -bind:bind -debug:debug -trace:trace -health:health -pprof:pprof -prometheus:metrics -errors:errors -log:log -dnstap:dnstap -chaos:chaos -loadbalance:loadbalance -cache:cache -rewrite:rewrite -dnssec:dnssec -autopath:autopath -reverse:deprecated -template:template -hosts:hosts -route53:route53 -federation:federation -kubernetes:kubernetes -file:file -auto:auto -secondary:secondary -etcd:etcd -forward:forward -proxy:proxy -erratic:erratic -whoami:whoami -on:github.com/mholt/caddy/onevent diff --git a/vendor/github.com/coredns/coredns/plugin.md b/vendor/github.com/coredns/coredns/plugin.md deleted file mode 100644 index 49b32236..00000000 --- a/vendor/github.com/coredns/coredns/plugin.md +++ /dev/null @@ -1,134 +0,0 @@ -# Plugins - -## Writing Plugins - -The main method that gets called is `ServeDNS`. It has three parameters: - -* a `context.Context`; -* `dns.ResponseWriter` that is, basically, the client's connection; -* `*dns.Msg` the request from the client. - -`ServeDNS` returns two values, a response code and an error. If the error is not nil CoreDNS, -will return a SERVFAIL to the client. The response code tells CoreDNS if a *reply has been -written by the plugin chain or not*. In the latter case CoreDNS will take care of that. - -CoreDNS treats: - -* SERVFAIL (dns.RcodeServerFailure) -* REFUSED (dns.RcodeRefused) -* FORMERR (dns.RcodeFormatError) -* NOTIMP (dns.RcodeNotImplemented) - -as special and will then assume *nothing* has been written to the client. In all other cases it -assumes something has been written to the client (by the plugin). - -The [*example*](https://github.com/coredns/example) plugin shows a bare-bones implementation that -can be used as a starting point for your plugin. This plugin has tests and extensive comments in the -code. - -## Hooking It Up - -See a couple of blog posts on how to write and add plugin to CoreDNS: - -* -* , slightly older, but useful. - -## Logging - -If your plugin needs to output a log line you should use the `plugin/pkg/log` package. This package -implements log levels. The standard way of outputting is: `log.Info` for info level messages. The -levels available are `log.Info`, `log.Warning`, `log.Error`, `log.Debug`. Each of these also has -a `f` variant. The plugin's name should be included, by using the log package like so: - -~~~ go -import clog "github.com/coredns/coredns/plugin/pkg/log" - -var log = clog.NewWithPlugin("whoami") - -log.Info("message") // outputs: [INFO] plugin/whoami: message -~~~ - -In general, logging should be left to the higher layers by returning an error. However, if there is -a reason to consume the error and notify the user, then logging in the plugin itself can be -acceptable. The `Debug*` functions only output something when the *debug* plugin is loaded in the -server. - -## Metrics - -When exporting metrics the *Namespace* should be `plugin.Namespace` (="coredns"), and the -*Subsystem* should be the name of the plugin. The README.md for the plugin should then also contain - a *Metrics* section detailing the metrics. If the plugin supports dynamic health reporting it - should also have *Health* section detailing on some of its inner workings. - -## Documentation - -Each plugin should have a README.md explaining what the plugin does and how it is configured. The -file should have the following layout: - -* Title: use the plugin's name -* Subsection titled: "Named" - with *PLUGIN* - one line description. -* Subsection titled: "Description" has a longer description. -* Subsection titled: "Syntax", syntax and supported directives. -* Subsection titled: "Examples" - -More sections are of course possible. - -### Style - -We use the Unix manual page style: - -* The name of plugin in the running text should be italic: *plugin*. -* all CAPITAL: user supplied argument, in the running text references this use strong text: `**`: - **EXAMPLE**. -* Optional text: in block quotes: `[optional]`. -* Use three dots to indicate multiple options are allowed: `arg...`. -* Item used literal: `literal`. - -### Example Domain Names - -Please be sure to use `example.org` or `example.net` in any examples and tests you provide. These -are the standard domain names created for this purpose. - -## Fallthrough - -In a perfect world the following would be true for plugin: "Either you are responsible for a zone or -not". If the answer is "not", the plugin should call the next plugin in the chain. If "yes" it -should handle *all* names that fall in this zone and the names below - i.e. it should handle the -entire domain and all sub domains. - -~~~ txt -. { - file example.org db.example -} -~~~ - -In this example the *file* plugin is handling all names below (and including) `example.org`. If -a query comes in that is not a subdomain (or equal to) `example.org` the next plugin is called. - -Now, the world isn't perfect, and there are good reasons to "fallthrough" to the next middlware, -meaning a plugin is only responsible for a *subset* of names within the zone. The first of these -to appear was the *reverse* plugin that synthesis PTR and A/AAAA responses (useful with IPv6). - -The nature of the *reverse* plugin is such that it only deals with A,AAAA and PTR and then only -for a subset of the names. Ideally you would want to layer *reverse* **in front off** another -plugin such as *file* or *auto* (or even *proxy*). This means *reverse* handles some special -reverse cases and **all other** request are handled by the backing plugin. This is exactly what -"fallthrough" does. To keep things explicit we've opted that plugins implement such behavior -should implement a `fallthrough` keyword. - -The `fallthrough` directive should optionally accept a list of zones. Only queries for records -in one of those zones should be allowed to fallthrough. - -## Qualifying for main repo - -Plugins for CoreDNS can live out-of-tree, `plugin.cfg` defaults to CoreDNS' repo but other -repos work just as well. So when do we consider the inclusion of a new plugin in the main repo? - -* First, the plugin should be useful for other people. "Useful" is a subjective term. We will - probably need to further refine this. -* It should be sufficiently different from other plugin to warrant inclusion. -* Current internet standards need be supported: IPv4 and IPv6, so A and AAAA records should be - handled (if your plugin is in the business of dealing with address records that is). -* It must have tests. -* It must have a README.md for documentation. diff --git a/vendor/github.com/coredns/coredns/plugin/auto/OWNERS b/vendor/github.com/coredns/coredns/plugin/auto/OWNERS deleted file mode 100644 index 3fc6bad8..00000000 --- a/vendor/github.com/coredns/coredns/plugin/auto/OWNERS +++ /dev/null @@ -1,5 +0,0 @@ -reviewers: - - miekg - - stp-ip -approvers: - - miekg diff --git a/vendor/github.com/coredns/coredns/plugin/auto/README.md b/vendor/github.com/coredns/coredns/plugin/auto/README.md deleted file mode 100644 index 9bb6f553..00000000 --- a/vendor/github.com/coredns/coredns/plugin/auto/README.md +++ /dev/null @@ -1,78 +0,0 @@ -# auto - -## Name - -*auto* - enables serving zone data from an RFC 1035-style master file, which is automatically picked up from disk. - -## Description - -The *auto* plugin is used for an "old-style" DNS server. It serves from a preloaded file that exists -on disk. If the zone file contains signatures (i.e. is signed, i.e. using DNSSEC) correct DNSSEC answers -are returned. Only NSEC is supported! If you use this setup *you* are responsible for re-signing the -zonefile. New or changed zones are automatically picked up from disk. - -## Syntax - -~~~ -auto [ZONES...] { - directory DIR [REGEXP ORIGIN_TEMPLATE [TIMEOUT]] - no_reload - upstream [ADDRESS...] -} -~~~ - -**ZONES** zones it should be authoritative for. If empty, the zones from the configuration block -are used. - -* `directory` loads zones from the speficied **DIR**. If a file name matches **REGEXP** it will be - used to extract the origin. **ORIGIN_TEMPLATE** will be used as a template for the origin. Strings - like `{}` are replaced with the respective matches in the file name, e.g. `{1}` is the - first match, `{2}` is the second. The default is: `db\.(.*) {1}` i.e. from a file with the - name `db.example.com`, the extracted origin will be `example.com`. **TIMEOUT** specifies how often - CoreDNS should scan the directory; the default is every 60 seconds. This value is in seconds. - The minimum value is 1 second. -* `no_reload` by default CoreDNS will try to reload a zone every minute and reloads if the - SOA's serial has changed. This option disables that behavior. -* `upstream` defines upstream resolvers to be used resolve external names found (think CNAMEs) - pointing to external names. **ADDRESS** can be an IP address, an IP:port or a string pointing to - a file that is structured as /etc/resolv.conf. If no **ADDRESS** is given, CoreDNS will resolve CNAMEs - against itself. - -All directives from the *file* plugin are supported. Note that *auto* will load all zones found, -even though the directive might only receive queries for a specific zone. I.e: - -~~~ corefile -. { - auto example.org { - directory /etc/coredns/zones - } -} -~~~ -Will happily pick up a zone for `example.COM`, except it will never be queried, because the *auto* -directive only is authoritative for `example.ORG`. - -## Examples - -Load `org` domains from `/etc/coredns/zones/org` and allow transfers to the internet, but send -notifies to 10.240.1.1 - -~~~ corefile -. { - auto org { - directory /etc/coredns/zones/org - transfer to * - transfer to 10.240.1.1 - } -} -~~~ - -Load `org` domains from `/etc/coredns/zones/org` and looks for file names as `www.db.example.org`, -where `example.org` is the origin. Scan every 45 seconds. - -~~~ corefile -org { - auto { - directory /etc/coredns/zones/org www\.db\.(.*) {1} 45 - } -} -~~~ diff --git a/vendor/github.com/coredns/coredns/plugin/auto/auto.go b/vendor/github.com/coredns/coredns/plugin/auto/auto.go deleted file mode 100644 index f2d1ab97..00000000 --- a/vendor/github.com/coredns/coredns/plugin/auto/auto.go +++ /dev/null @@ -1,94 +0,0 @@ -// Package auto implements an on-the-fly loading file backend. -package auto - -import ( - "context" - "regexp" - "time" - - "github.com/coredns/coredns/plugin" - "github.com/coredns/coredns/plugin/file" - "github.com/coredns/coredns/plugin/metrics" - "github.com/coredns/coredns/plugin/pkg/upstream" - "github.com/coredns/coredns/request" - - "github.com/miekg/dns" -) - -type ( - // Auto holds the zones and the loader configuration for automatically loading zones. - Auto struct { - Next plugin.Handler - *Zones - - metrics *metrics.Metrics - loader - } - - loader struct { - directory string - template string - re *regexp.Regexp - - // In the future this should be something like ZoneMeta that contains all this stuff. - transferTo []string - noReload bool - upstream upstream.Upstream // Upstream for looking up names during the resolution process. - - duration time.Duration - } -) - -// ServeDNS implements the plugin.Handler interface. -func (a Auto) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (int, error) { - state := request.Request{W: w, Req: r, Context: ctx} - qname := state.Name() - - // Precheck with the origins, i.e. are we allowed to look here? - zone := plugin.Zones(a.Zones.Origins()).Matches(qname) - if zone == "" { - return plugin.NextOrFailure(a.Name(), a.Next, ctx, w, r) - } - - // Now the real zone. - zone = plugin.Zones(a.Zones.Names()).Matches(qname) - - a.Zones.RLock() - z, ok := a.Zones.Z[zone] - a.Zones.RUnlock() - - if !ok || z == nil { - return dns.RcodeServerFailure, nil - } - - if state.QType() == dns.TypeAXFR || state.QType() == dns.TypeIXFR { - xfr := file.Xfr{Zone: z} - return xfr.ServeDNS(ctx, w, r) - } - - answer, ns, extra, result := z.Lookup(state, qname) - - m := new(dns.Msg) - m.SetReply(r) - m.Authoritative, m.RecursionAvailable = true, true - m.Answer, m.Ns, m.Extra = answer, ns, extra - - switch result { - case file.Success: - case file.NoData: - case file.NameError: - m.Rcode = dns.RcodeNameError - case file.Delegation: - m.Authoritative = false - case file.ServerFailure: - return dns.RcodeServerFailure, nil - } - - state.SizeAndDo(m) - m, _ = state.Scrub(m) - w.WriteMsg(m) - return dns.RcodeSuccess, nil -} - -// Name implements the Handler interface. -func (a Auto) Name() string { return "auto" } diff --git a/vendor/github.com/coredns/coredns/plugin/auto/regexp.go b/vendor/github.com/coredns/coredns/plugin/auto/regexp.go deleted file mode 100644 index fa424ec7..00000000 --- a/vendor/github.com/coredns/coredns/plugin/auto/regexp.go +++ /dev/null @@ -1,20 +0,0 @@ -package auto - -// rewriteToExpand rewrites our template string to one that we can give to regexp.ExpandString. This basically -// involves prefixing any '{' with a '$'. -func rewriteToExpand(s string) string { - // Pretty dumb at the moment, every { will get a $ prefixed. - // Also wasteful as we build the string with +=. This is OKish - // as we do this during config parsing. - - copy := "" - - for _, c := range s { - if c == '{' { - copy += "$" - } - copy += string(c) - } - - return copy -} diff --git a/vendor/github.com/coredns/coredns/plugin/auto/regexp_test.go b/vendor/github.com/coredns/coredns/plugin/auto/regexp_test.go deleted file mode 100644 index 17c35eb9..00000000 --- a/vendor/github.com/coredns/coredns/plugin/auto/regexp_test.go +++ /dev/null @@ -1,20 +0,0 @@ -package auto - -import "testing" - -func TestRewriteToExpand(t *testing.T) { - tests := []struct { - in string - expected string - }{ - {in: "", expected: ""}, - {in: "{1}", expected: "${1}"}, - {in: "{1", expected: "${1"}, - } - for i, tc := range tests { - got := rewriteToExpand(tc.in) - if got != tc.expected { - t.Errorf("Test %d: Expected error %v, but got %v", i, tc.expected, got) - } - } -} diff --git a/vendor/github.com/coredns/coredns/plugin/auto/setup.go b/vendor/github.com/coredns/coredns/plugin/auto/setup.go deleted file mode 100644 index 8791b073..00000000 --- a/vendor/github.com/coredns/coredns/plugin/auto/setup.go +++ /dev/null @@ -1,173 +0,0 @@ -package auto - -import ( - "os" - "path" - "regexp" - "strconv" - "time" - - "github.com/coredns/coredns/core/dnsserver" - "github.com/coredns/coredns/plugin" - "github.com/coredns/coredns/plugin/metrics" - clog "github.com/coredns/coredns/plugin/pkg/log" - "github.com/coredns/coredns/plugin/pkg/parse" - "github.com/coredns/coredns/plugin/pkg/upstream" - - "github.com/mholt/caddy" -) - -var log = clog.NewWithPlugin("auto") - -func init() { - caddy.RegisterPlugin("auto", caddy.Plugin{ - ServerType: "dns", - Action: setup, - }) -} - -func setup(c *caddy.Controller) error { - a, err := autoParse(c) - if err != nil { - return plugin.Error("auto", err) - } - - c.OnStartup(func() error { - m := dnsserver.GetConfig(c).Handler("prometheus") - if m == nil { - return nil - } - (&a).metrics = m.(*metrics.Metrics) - return nil - }) - - walkChan := make(chan bool) - - c.OnStartup(func() error { - err := a.Walk() - if err != nil { - return err - } - - go func() { - ticker := time.NewTicker(a.loader.duration) - for { - select { - case <-walkChan: - return - case <-ticker.C: - a.Walk() - } - } - }() - return nil - }) - - c.OnShutdown(func() error { - close(walkChan) - return nil - }) - - dnsserver.GetConfig(c).AddPlugin(func(next plugin.Handler) plugin.Handler { - a.Next = next - return a - }) - - return nil -} - -func autoParse(c *caddy.Controller) (Auto, error) { - var a = Auto{ - loader: loader{template: "${1}", re: regexp.MustCompile(`db\.(.*)`), duration: 60 * time.Second}, - Zones: &Zones{}, - } - - config := dnsserver.GetConfig(c) - - for c.Next() { - // auto [ZONES...] - a.Zones.origins = make([]string, len(c.ServerBlockKeys)) - copy(a.Zones.origins, c.ServerBlockKeys) - - args := c.RemainingArgs() - if len(args) > 0 { - a.Zones.origins = args - } - for i := range a.Zones.origins { - a.Zones.origins[i] = plugin.Host(a.Zones.origins[i]).Normalize() - } - - for c.NextBlock() { - switch c.Val() { - case "directory": // directory DIR [REGEXP [TEMPLATE] [DURATION]] - if !c.NextArg() { - return a, c.ArgErr() - } - a.loader.directory = c.Val() - if !path.IsAbs(a.loader.directory) && config.Root != "" { - a.loader.directory = path.Join(config.Root, a.loader.directory) - } - _, err := os.Stat(a.loader.directory) - if err != nil { - if os.IsNotExist(err) { - log.Warningf("Directory does not exist: %s", a.loader.directory) - } else { - return a, c.Errf("Unable to access root path '%s': %v", a.loader.directory, err) - } - } - - // regexp - if c.NextArg() { - a.loader.re, err = regexp.Compile(c.Val()) - if err != nil { - return a, err - } - if a.loader.re.NumSubexp() == 0 { - return a, c.Errf("Need at least one sub expression") - } - } - - // template - if c.NextArg() { - a.loader.template = rewriteToExpand(c.Val()) - } - - // duration - if c.NextArg() { - i, err := strconv.Atoi(c.Val()) - if err != nil { - return a, err - } - if i < 1 { - i = 1 - } - a.loader.duration = time.Duration(i) * time.Second - } - - case "no_reload": - a.loader.noReload = true - - case "upstream": - args := c.RemainingArgs() - if len(args) == 0 { - return a, c.ArgErr() - } - var err error - a.loader.upstream, err = upstream.New(args) - if err != nil { - return a, err - } - - default: - t, _, e := parse.Transfer(c, false) - if e != nil { - return a, e - } - if t != nil { - a.loader.transferTo = append(a.loader.transferTo, t...) - } - } - } - } - return a, nil -} diff --git a/vendor/github.com/coredns/coredns/plugin/auto/setup_test.go b/vendor/github.com/coredns/coredns/plugin/auto/setup_test.go deleted file mode 100644 index 9754551d..00000000 --- a/vendor/github.com/coredns/coredns/plugin/auto/setup_test.go +++ /dev/null @@ -1,125 +0,0 @@ -package auto - -import ( - "testing" - - "github.com/mholt/caddy" -) - -func TestAutoParse(t *testing.T) { - tests := []struct { - inputFileRules string - shouldErr bool - expectedDirectory string - expectedTempl string - expectedRe string - expectedTo []string - }{ - { - `auto example.org { - directory /tmp - transfer to 127.0.0.1 - }`, - false, "/tmp", "${1}", `db\.(.*)`, []string{"127.0.0.1:53"}, - }, - { - `auto 10.0.0.0/24 { - directory /tmp - }`, - false, "/tmp", "${1}", `db\.(.*)`, nil, - }, - { - `auto { - directory /tmp - no_reload - }`, - false, "/tmp", "${1}", `db\.(.*)`, nil, - }, - { - `auto { - directory /tmp (.*) bliep - }`, - false, "/tmp", "bliep", `(.*)`, nil, - }, - { - `auto { - directory /tmp (.*) bliep 10 - }`, - false, "/tmp", "bliep", `(.*)`, nil, - }, - { - `auto { - directory /tmp (.*) bliep - transfer to 127.0.0.1 - transfer to 127.0.0.2 - upstream 8.8.8.8 - }`, - false, "/tmp", "bliep", `(.*)`, []string{"127.0.0.1:53", "127.0.0.2:53"}, - }, - // errors - { - `auto example.org { - directory - }`, - true, "", "${1}", `db\.(.*)`, nil, - }, - { - `auto example.org { - directory /tmp * {1} - }`, - true, "", "${1}", ``, nil, - }, - { - `auto example.org { - directory /tmp * {1} aa - }`, - true, "", "${1}", ``, nil, - }, - { - `auto example.org { - directory /tmp .* {1} - }`, - true, "", "${1}", ``, nil, - }, - { - `auto example.org { - directory /tmp .* {1} - }`, - true, "", "${1}", ``, nil, - }, - { - `auto example.org { - directory /tmp .* {1} - }`, - true, "", "${1}", ``, nil, - }, - } - - for i, test := range tests { - c := caddy.NewTestController("dns", test.inputFileRules) - a, err := autoParse(c) - - if err == nil && test.shouldErr { - t.Fatalf("Test %d expected errors, but got no error", i) - } else if err != nil && !test.shouldErr { - t.Fatalf("Test %d expected no errors, but got '%v'", i, err) - } else if !test.shouldErr { - if a.loader.directory != test.expectedDirectory { - t.Fatalf("Test %d expected %v, got %v", i, test.expectedDirectory, a.loader.directory) - } - if a.loader.template != test.expectedTempl { - t.Fatalf("Test %d expected %v, got %v", i, test.expectedTempl, a.loader.template) - } - if a.loader.re.String() != test.expectedRe { - t.Fatalf("Test %d expected %v, got %v", i, test.expectedRe, a.loader.re) - } - if test.expectedTo != nil { - for j, got := range a.loader.transferTo { - if got != test.expectedTo[j] { - t.Fatalf("Test %d expected %v, got %v", i, test.expectedTo[j], got) - } - } - } - } - } -} diff --git a/vendor/github.com/coredns/coredns/plugin/auto/walk.go b/vendor/github.com/coredns/coredns/plugin/auto/walk.go deleted file mode 100644 index 35121050..00000000 --- a/vendor/github.com/coredns/coredns/plugin/auto/walk.go +++ /dev/null @@ -1,108 +0,0 @@ -package auto - -import ( - "os" - "path" - "path/filepath" - "regexp" - - "github.com/coredns/coredns/plugin/file" - - "github.com/miekg/dns" -) - -// Walk will recursively walk of the file under l.directory and adds the one that match l.re. -func (a Auto) Walk() error { - - // TODO(miek): should add something so that we don't stomp on each other. - - toDelete := make(map[string]bool) - for _, n := range a.Zones.Names() { - toDelete[n] = true - } - - filepath.Walk(a.loader.directory, func(path string, info os.FileInfo, err error) error { - if info == nil || info.IsDir() { - return nil - } - - match, origin := matches(a.loader.re, info.Name(), a.loader.template) - if !match { - return nil - } - - if _, ok := a.Zones.Z[origin]; ok { - // we already have this zone - toDelete[origin] = false - return nil - } - - reader, err := os.Open(path) - if err != nil { - log.Warningf("Opening %s failed: %s", path, err) - return nil - } - defer reader.Close() - - // Serial for loading a zone is 0, because it is a new zone. - zo, err := file.Parse(reader, origin, path, 0) - if err != nil { - log.Warningf("Parse zone `%s': %v", origin, err) - return nil - } - - zo.NoReload = a.loader.noReload - zo.Upstream = a.loader.upstream - zo.TransferTo = a.loader.transferTo - - a.Zones.Add(zo, origin) - - if a.metrics != nil { - a.metrics.AddZone(origin) - } - - zo.Notify() - - log.Infof("Inserting zone `%s' from: %s", origin, path) - - toDelete[origin] = false - - return nil - }) - - for origin, ok := range toDelete { - if !ok { - continue - } - - if a.metrics != nil { - a.metrics.RemoveZone(origin) - } - - a.Zones.Remove(origin) - - log.Infof("Deleting zone `%s'", origin) - } - - return nil -} - -// matches matches re to filename, if is is a match, the subexpression will be used to expand -// template to an origin. When match is true that origin is returned. Origin is fully qualified. -func matches(re *regexp.Regexp, filename, template string) (match bool, origin string) { - base := path.Base(filename) - - matches := re.FindStringSubmatchIndex(base) - if matches == nil { - return false, "" - } - - by := re.ExpandString(nil, template, base, matches) - if by == nil { - return false, "" - } - - origin = dns.Fqdn(string(by)) - - return true, origin -} diff --git a/vendor/github.com/coredns/coredns/plugin/auto/walk_test.go b/vendor/github.com/coredns/coredns/plugin/auto/walk_test.go deleted file mode 100644 index 7549f863..00000000 --- a/vendor/github.com/coredns/coredns/plugin/auto/walk_test.go +++ /dev/null @@ -1,89 +0,0 @@ -package auto - -import ( - "io/ioutil" - "os" - "path" - "regexp" - "testing" -) - -var dbFiles = []string{"db.example.org", "aa.example.org"} - -const zoneContent = `; testzone -@ IN SOA sns.dns.icann.org. noc.dns.icann.org. 2016082534 7200 3600 1209600 3600 - NS a.iana-servers.net. - NS b.iana-servers.net. - -www IN A 127.0.0.1 -` - -func TestWalk(t *testing.T) { - tempdir, err := createFiles() - if err != nil { - if tempdir != "" { - os.RemoveAll(tempdir) - } - t.Fatal(err) - } - defer os.RemoveAll(tempdir) - - ldr := loader{ - directory: tempdir, - re: regexp.MustCompile(`db\.(.*)`), - template: `${1}`, - } - - a := Auto{ - loader: ldr, - Zones: &Zones{}, - } - - a.Walk() - - // db.example.org and db.example.com should be here (created in createFiles) - for _, name := range []string{"example.com.", "example.org."} { - if _, ok := a.Zones.Z[name]; !ok { - t.Errorf("%s should have been added", name) - } - } -} - -func TestWalkNonExistent(t *testing.T) { - nonExistingDir := "highly_unlikely_to_exist_dir" - - ldr := loader{ - directory: nonExistingDir, - re: regexp.MustCompile(`db\.(.*)`), - template: `${1}`, - } - - a := Auto{ - loader: ldr, - Zones: &Zones{}, - } - - a.Walk() -} - -func createFiles() (string, error) { - dir, err := ioutil.TempDir(os.TempDir(), "coredns") - if err != nil { - return dir, err - } - - for _, name := range dbFiles { - if err := ioutil.WriteFile(path.Join(dir, name), []byte(zoneContent), 0644); err != nil { - return dir, err - } - } - // symlinks - if err = os.Symlink(path.Join(dir, "db.example.org"), path.Join(dir, "db.example.com")); err != nil { - return dir, err - } - if err = os.Symlink(path.Join(dir, "db.example.org"), path.Join(dir, "aa.example.com")); err != nil { - return dir, err - } - - return dir, nil -} diff --git a/vendor/github.com/coredns/coredns/plugin/auto/watcher_test.go b/vendor/github.com/coredns/coredns/plugin/auto/watcher_test.go deleted file mode 100644 index dde7053f..00000000 --- a/vendor/github.com/coredns/coredns/plugin/auto/watcher_test.go +++ /dev/null @@ -1,54 +0,0 @@ -package auto - -import ( - "os" - "path" - "regexp" - "testing" -) - -func TestWatcher(t *testing.T) { - tempdir, err := createFiles() - if err != nil { - if tempdir != "" { - os.RemoveAll(tempdir) - } - t.Fatal(err) - } - defer os.RemoveAll(tempdir) - - ldr := loader{ - directory: tempdir, - re: regexp.MustCompile(`db\.(.*)`), - template: `${1}`, - } - - a := Auto{ - loader: ldr, - Zones: &Zones{}, - } - - a.Walk() - - // example.org and example.com should exist - if x := len(a.Zones.Z["example.org."].All()); x != 4 { - t.Fatalf("Expected 4 RRs, got %d", x) - } - if x := len(a.Zones.Z["example.com."].All()); x != 4 { - t.Fatalf("Expected 4 RRs, got %d", x) - } - - // Now remove one file, rescan and see if it's gone. - if err := os.Remove(path.Join(tempdir, "db.example.com")); err != nil { - t.Fatal(err) - } - - a.Walk() - - if _, ok := a.Zones.Z["example.com."]; ok { - t.Errorf("Expected %q to be gone.", "example.com.") - } - if _, ok := a.Zones.Z["example.org."]; !ok { - t.Errorf("Expected %q to still be there.", "example.org.") - } -} diff --git a/vendor/github.com/coredns/coredns/plugin/auto/zone.go b/vendor/github.com/coredns/coredns/plugin/auto/zone.go deleted file mode 100644 index 9839ad04..00000000 --- a/vendor/github.com/coredns/coredns/plugin/auto/zone.go +++ /dev/null @@ -1,76 +0,0 @@ -// Package auto implements a on-the-fly loading file backend. -package auto - -import ( - "sync" - - "github.com/coredns/coredns/plugin/file" -) - -// Zones maps zone names to a *Zone. This keep track of what we zones we have loaded at -// any one time. -type Zones struct { - Z map[string]*file.Zone // A map mapping zone (origin) to the Zone's data. - names []string // All the keys from the map Z as a string slice. - - origins []string // Any origins from the server block. - - sync.RWMutex -} - -// Names returns the names from z. -func (z *Zones) Names() []string { - z.RLock() - n := z.names - z.RUnlock() - return n -} - -// Origins returns the origins from z. -func (z *Zones) Origins() []string { - // doesn't need locking, because there aren't multiple Go routines accessing it. - return z.origins -} - -// Zones returns a zone with origin name from z, nil when not found. -func (z *Zones) Zones(name string) *file.Zone { - z.RLock() - zo := z.Z[name] - z.RUnlock() - return zo -} - -// Add adds a new zone into z. If zo.NoReload is false, the -// reload goroutine is started. -func (z *Zones) Add(zo *file.Zone, name string) { - z.Lock() - - if z.Z == nil { - z.Z = make(map[string]*file.Zone) - } - - z.Z[name] = zo - z.names = append(z.names, name) - zo.Reload() - - z.Unlock() -} - -// Remove removes the zone named name from z. It also stop the the zone's reload goroutine. -func (z *Zones) Remove(name string) { - z.Lock() - - if zo, ok := z.Z[name]; ok { - zo.OnShutdown() - } - - delete(z.Z, name) - - // TODO(miek): just regenerate Names (might be bad if you have a lot of zones...) - z.names = []string{} - for n := range z.Z { - z.names = append(z.names, n) - } - - z.Unlock() -} diff --git a/vendor/github.com/coredns/coredns/plugin/autopath/OWNERS b/vendor/github.com/coredns/coredns/plugin/autopath/OWNERS deleted file mode 100644 index 187c629c..00000000 --- a/vendor/github.com/coredns/coredns/plugin/autopath/OWNERS +++ /dev/null @@ -1,6 +0,0 @@ -reviewers: - - chrisohaver - - miekg -approvers: - - chrisohaver - - miekg diff --git a/vendor/github.com/coredns/coredns/plugin/autopath/README.md b/vendor/github.com/coredns/coredns/plugin/autopath/README.md deleted file mode 100644 index 5b616d38..00000000 --- a/vendor/github.com/coredns/coredns/plugin/autopath/README.md +++ /dev/null @@ -1,49 +0,0 @@ -# autopath - -## Name - -*autopath* - allows for server-side search path completion. - -## Description - -If it sees a query that matches the first element of the configured search path, *autopath* will -follow the chain of search path elements and return the first reply that is not NXDOMAIN. On any -failures, the original reply is returned. Because *autopath* returns a reply for a name that wasn't -the original question it will add a CNAME that points from the original name (with the search path -element in it) to the name of this answer. - -## Syntax - -~~~ -autopath [ZONE...] RESOLV-CONF -~~~ - -* **ZONES** zones *autopath* should be authoritative for. -* **RESOLV-CONF** points to a `resolv.conf` like file or uses a special syntax to point to another - plugin. For instance `@kubernetes`, will call out to the kubernetes plugin (for each - query) to retrieve the search list it should use. - -If a plugin implements the `AutoPather` interface then it can be used. - -## Metrics - -If monitoring is enabled (via the *prometheus* directive) then the following metric is exported: - -* `coredns_autopath_success_count_total{server}` - counter of successfully autopath-ed queries. - -The `server` label is explained in the *metrics* plugin documentation. - -## Examples - -~~~ -autopath my-resolv.conf -~~~ - -Use `my-resolv.conf` as the file to get the search path from. This file only needs so have one line: -`search domain1 domain2 ...` - -~~~ -autopath @kubernetes -~~~ - -Use the search path dynamically retrieved from the *kubernetes* plugin. diff --git a/vendor/github.com/coredns/coredns/plugin/autopath/autopath.go b/vendor/github.com/coredns/coredns/plugin/autopath/autopath.go deleted file mode 100644 index edc0b084..00000000 --- a/vendor/github.com/coredns/coredns/plugin/autopath/autopath.go +++ /dev/null @@ -1,158 +0,0 @@ -/* -Package autopath implements autopathing. This is a hack; it shortcuts the -client's search path resolution by performing these lookups on the server... - -The server has a copy (via AutoPathFunc) of the client's search path and on -receiving a query it first establish if the suffix matches the FIRST configured -element. If no match can be found the query will be forwarded up the plugin -chain without interference (iff 'fallthrough' has been set). - -If the query is deemed to fall in the search path the server will perform the -queries with each element of the search path appended in sequence until a -non-NXDOMAIN answer has been found. That reply will then be returned to the -client - with some CNAME hackery to let the client accept the reply. - -If all queries return NXDOMAIN we return the original as-is and let the client -continue searching. The client will go to the next element in the search path, -but we won’t do any more autopathing. It means that in the failure case, you do -more work, since the server looks it up, then the client still needs to go -through the search path. - -It is assume the search path ordering is identical between server and client. - -Midldeware implementing autopath, must have a function called `AutoPath` of type -autopath.Func. Note the searchpath must be ending with the empty string. - -I.e: - -func (m Plugins ) AutoPath(state request.Request) []string { - return []string{"first", "second", "last", ""} -} -*/ -package autopath - -import ( - "context" - - "github.com/coredns/coredns/plugin" - "github.com/coredns/coredns/plugin/metrics" - "github.com/coredns/coredns/plugin/pkg/dnsutil" - "github.com/coredns/coredns/plugin/pkg/nonwriter" - "github.com/coredns/coredns/request" - - "github.com/miekg/dns" -) - -// Func defines the function plugin should implement to return a search -// path to the autopath plugin. The last element of the slice must be the empty string. -// If Func returns a nil slice, no autopathing will be done. -type Func func(request.Request) []string - -// AutoPather defines the interface that a plugin should implement in order to be -// used by AutoPath. -type AutoPather interface { - AutoPath(request.Request) []string -} - -// AutoPath perform autopath: service side search path completion. -type AutoPath struct { - Next plugin.Handler - Zones []string - - // Search always includes "" as the last element, so we try the base query with out any search paths added as well. - search []string - searchFunc Func -} - -// ServeDNS implements the plugin.Handle interface. -func (a *AutoPath) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (int, error) { - state := request.Request{W: w, Req: r} - - zone := plugin.Zones(a.Zones).Matches(state.Name()) - if zone == "" { - return plugin.NextOrFailure(a.Name(), a.Next, ctx, w, r) - } - - // Check if autopath should be done, searchFunc takes precedence over the local configured search path. - var err error - searchpath := a.search - - if a.searchFunc != nil { - searchpath = a.searchFunc(state) - } - - if len(searchpath) == 0 { - return plugin.NextOrFailure(a.Name(), a.Next, ctx, w, r) - } - - if !firstInSearchPath(state.Name(), searchpath) { - return plugin.NextOrFailure(a.Name(), a.Next, ctx, w, r) - } - - origQName := state.QName() - - // Establish base name of the query. I.e what was originally asked. - base, err := dnsutil.TrimZone(state.QName(), searchpath[0]) - if err != nil { - return dns.RcodeServerFailure, err - } - - firstReply := new(dns.Msg) - firstRcode := 0 - var firstErr error - - ar := r.Copy() - // Walk the search path and see if we can get a non-nxdomain - if they all fail we return the first - // query we've done and return that as-is. This means the client will do the search path walk again... - for i, s := range searchpath { - newQName := base + "." + s - ar.Question[0].Name = newQName - nw := nonwriter.New(w) - - rcode, err := plugin.NextOrFailure(a.Name(), a.Next, ctx, nw, ar) - if err != nil { - // Return now - not sure if this is the best. We should also check if the write has happened. - return rcode, err - } - if i == 0 { - firstReply = nw.Msg - firstRcode = rcode - firstErr = err - } - - if !plugin.ClientWrite(rcode) { - continue - } - - if nw.Msg.Rcode == dns.RcodeNameError { - continue - } - - msg := nw.Msg - cnamer(msg, origQName) - - // Write whatever non-nxdomain answer we've found. - w.WriteMsg(msg) - autoPathCount.WithLabelValues(metrics.WithServer(ctx)).Add(1) - return rcode, err - - } - if plugin.ClientWrite(firstRcode) { - w.WriteMsg(firstReply) - } - return firstRcode, firstErr -} - -// Name implements the Handler interface. -func (a *AutoPath) Name() string { return "autopath" } - -// firstInSearchPath checks if name is equal to are a sibling of the first element in the search path. -func firstInSearchPath(name string, searchpath []string) bool { - if name == searchpath[0] { - return true - } - if dns.IsSubDomain(searchpath[0], name) { - return true - } - return false -} diff --git a/vendor/github.com/coredns/coredns/plugin/autopath/autopath_test.go b/vendor/github.com/coredns/coredns/plugin/autopath/autopath_test.go deleted file mode 100644 index 4857e5c8..00000000 --- a/vendor/github.com/coredns/coredns/plugin/autopath/autopath_test.go +++ /dev/null @@ -1,166 +0,0 @@ -package autopath - -import ( - "context" - "testing" - - "github.com/coredns/coredns/plugin" - "github.com/coredns/coredns/plugin/pkg/dnstest" - "github.com/coredns/coredns/plugin/test" - - "github.com/miekg/dns" -) - -var autopathTestCases = []test.Case{ - { - // search path expansion. - Qname: "b.example.org.", Qtype: dns.TypeA, - Answer: []dns.RR{ - test.CNAME("b.example.org. 3600 IN CNAME b.com."), - test.A("b.com." + defaultA), - }, - }, - { - // No search path expansion - Qname: "a.example.com.", Qtype: dns.TypeA, - Answer: []dns.RR{ - test.A("a.example.com." + defaultA), - }, - }, -} - -func newTestAutoPath() *AutoPath { - ap := new(AutoPath) - ap.Zones = []string{"."} - ap.Next = nextHandler(map[string]int{ - "b.example.org.": dns.RcodeNameError, - "b.com.": dns.RcodeSuccess, - "a.example.com.": dns.RcodeSuccess, - }) - - ap.search = []string{"example.org.", "example.com.", "com.", ""} - return ap -} - -func TestAutoPath(t *testing.T) { - ap := newTestAutoPath() - ctx := context.TODO() - - for _, tc := range autopathTestCases { - m := tc.Msg() - - rec := dnstest.NewRecorder(&test.ResponseWriter{}) - _, err := ap.ServeDNS(ctx, rec, m) - if err != nil { - t.Errorf("Expected no error, got %v\n", err) - continue - } - - // No sorting here as we want to check if the CNAME sits *before* the - // test of the answer. - resp := rec.Msg - - if !test.Header(t, tc, resp) { - t.Logf("%v\n", resp) - continue - } - if !test.Section(t, tc, test.Answer, resp.Answer) { - t.Logf("%v\n", resp) - } - if !test.Section(t, tc, test.Ns, resp.Ns) { - t.Logf("%v\n", resp) - } - if !test.Section(t, tc, test.Extra, resp.Extra) { - t.Logf("%v\n", resp) - } - } -} - -var autopathNoAnswerTestCases = []test.Case{ - { - // search path expansion, no answer - Qname: "c.example.org.", Qtype: dns.TypeA, - Answer: []dns.RR{ - test.CNAME("b.example.org. 3600 IN CNAME b.com."), - test.A("b.com." + defaultA), - }, - }, -} - -func TestAutoPathNoAnswer(t *testing.T) { - ap := newTestAutoPath() - ctx := context.TODO() - - for _, tc := range autopathNoAnswerTestCases { - m := tc.Msg() - - rec := dnstest.NewRecorder(&test.ResponseWriter{}) - rcode, err := ap.ServeDNS(ctx, rec, m) - if err != nil { - t.Errorf("Expected no error, got %v\n", err) - continue - } - if plugin.ClientWrite(rcode) { - t.Fatalf("Expected no client write, got one for rcode %d", rcode) - } - } -} - -// nextHandler returns a Handler that returns an answer for the question in the -// request per the domain->answer map. On success an RR will be returned: "qname 3600 IN A 127.0.0.53" -func nextHandler(mm map[string]int) test.Handler { - return test.HandlerFunc(func(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (int, error) { - rcode, ok := mm[r.Question[0].Name] - if !ok { - return dns.RcodeServerFailure, nil - } - - m := new(dns.Msg) - m.SetReply(r) - - switch rcode { - case dns.RcodeNameError: - m.Rcode = rcode - m.Ns = []dns.RR{soa} - w.WriteMsg(m) - return m.Rcode, nil - - case dns.RcodeSuccess: - m.Rcode = rcode - a, _ := dns.NewRR(r.Question[0].Name + defaultA) - m.Answer = []dns.RR{a} - - w.WriteMsg(m) - return m.Rcode, nil - default: - panic("nextHandler: unhandled rcode") - } - }) -} - -const defaultA = " 3600 IN A 127.0.0.53" - -var soa = func() dns.RR { - s, _ := dns.NewRR("example.org. 1800 IN SOA example.org. example.org. 1502165581 14400 3600 604800 14400") - return s -}() - -func TestInSearchPath(t *testing.T) { - a := AutoPath{search: []string{"default.svc.cluster.local.", "svc.cluster.local.", "cluster.local."}} - - tests := []struct { - qname string - b bool - }{ - {"google.com", false}, - {"default.svc.cluster.local.", true}, - {"a.default.svc.cluster.local.", true}, - {"a.b.svc.cluster.local.", false}, - } - for i, tc := range tests { - got := firstInSearchPath(tc.qname, a.search) - if got != tc.b { - t.Errorf("Test %d, got %v, expected %v", i, got, tc.b) - } - } -} diff --git a/vendor/github.com/coredns/coredns/plugin/autopath/cname.go b/vendor/github.com/coredns/coredns/plugin/autopath/cname.go deleted file mode 100644 index 3b2c60f4..00000000 --- a/vendor/github.com/coredns/coredns/plugin/autopath/cname.go +++ /dev/null @@ -1,25 +0,0 @@ -package autopath - -import ( - "strings" - - "github.com/miekg/dns" -) - -// cnamer will prefix the answer section with a cname that points from original qname to the -// name of the first RR. It will also update the question section and put original in there. -func cnamer(m *dns.Msg, original string) { - for _, a := range m.Answer { - if strings.EqualFold(original, a.Header().Name) { - continue - } - m.Answer = append(m.Answer, nil) - copy(m.Answer[1:], m.Answer) - m.Answer[0] = &dns.CNAME{ - Hdr: dns.RR_Header{Name: original, Rrtype: dns.TypeCNAME, Class: dns.ClassINET, Ttl: a.Header().Ttl}, - Target: a.Header().Name, - } - break - } - m.Question[0].Name = original -} diff --git a/vendor/github.com/coredns/coredns/plugin/autopath/metrics.go b/vendor/github.com/coredns/coredns/plugin/autopath/metrics.go deleted file mode 100644 index c928bd2f..00000000 --- a/vendor/github.com/coredns/coredns/plugin/autopath/metrics.go +++ /dev/null @@ -1,20 +0,0 @@ -package autopath - -import ( - "sync" - - "github.com/coredns/coredns/plugin" - - "github.com/prometheus/client_golang/prometheus" -) - -var ( - autoPathCount = prometheus.NewCounterVec(prometheus.CounterOpts{ - Namespace: plugin.Namespace, - Subsystem: "autopath", - Name: "success_count_total", - Help: "Counter of requests that did autopath.", - }, []string{"server"}) -) - -var once sync.Once diff --git a/vendor/github.com/coredns/coredns/plugin/autopath/setup.go b/vendor/github.com/coredns/coredns/plugin/autopath/setup.go deleted file mode 100644 index 11c2b815..00000000 --- a/vendor/github.com/coredns/coredns/plugin/autopath/setup.go +++ /dev/null @@ -1,87 +0,0 @@ -package autopath - -import ( - "fmt" - - "github.com/coredns/coredns/core/dnsserver" - "github.com/coredns/coredns/plugin" - "github.com/coredns/coredns/plugin/metrics" - - "github.com/mholt/caddy" - "github.com/miekg/dns" -) - -func init() { - caddy.RegisterPlugin("autopath", caddy.Plugin{ - ServerType: "dns", - Action: setup, - }) - -} - -func setup(c *caddy.Controller) error { - ap, mw, err := autoPathParse(c) - if err != nil { - return plugin.Error("autopath", err) - } - - c.OnStartup(func() error { - once.Do(func() { metrics.MustRegister(c, autoPathCount) }) - return nil - }) - - // Do this in OnStartup, so all plugin has been initialized. - c.OnStartup(func() error { - m := dnsserver.GetConfig(c).Handler(mw) - if m == nil { - return nil - } - if x, ok := m.(AutoPather); ok { - ap.searchFunc = x.AutoPath - } else { - return plugin.Error("autopath", fmt.Errorf("%s does not implement the AutoPather interface", mw)) - } - return nil - }) - - dnsserver.GetConfig(c).AddPlugin(func(next plugin.Handler) plugin.Handler { - ap.Next = next - return ap - }) - - return nil -} - -func autoPathParse(c *caddy.Controller) (*AutoPath, string, error) { - ap := &AutoPath{} - mw := "" - - for c.Next() { - zoneAndresolv := c.RemainingArgs() - if len(zoneAndresolv) < 1 { - return ap, "", fmt.Errorf("no resolv-conf specified") - } - resolv := zoneAndresolv[len(zoneAndresolv)-1] - if resolv[0] == '@' { - mw = resolv[1:] - } else { - // assume file on disk - rc, err := dns.ClientConfigFromFile(resolv) - if err != nil { - return ap, "", fmt.Errorf("failed to parse %q: %v", resolv, err) - } - ap.search = rc.Search - plugin.Zones(ap.search).Normalize() - ap.search = append(ap.search, "") // sentinal value as demanded. - } - ap.Zones = zoneAndresolv[:len(zoneAndresolv)-1] - if len(ap.Zones) == 0 { - ap.Zones = make([]string, len(c.ServerBlockKeys)) - copy(ap.Zones, c.ServerBlockKeys) - } - for i, str := range ap.Zones { - ap.Zones[i] = plugin.Host(str).Normalize() - } - } - return ap, mw, nil -} diff --git a/vendor/github.com/coredns/coredns/plugin/autopath/setup_test.go b/vendor/github.com/coredns/coredns/plugin/autopath/setup_test.go deleted file mode 100644 index 53003693..00000000 --- a/vendor/github.com/coredns/coredns/plugin/autopath/setup_test.go +++ /dev/null @@ -1,77 +0,0 @@ -package autopath - -import ( - "os" - "reflect" - "strings" - "testing" - - "github.com/coredns/coredns/plugin/test" - - "github.com/mholt/caddy" -) - -func TestSetupAutoPath(t *testing.T) { - resolv, rm, err := test.TempFile(os.TempDir(), resolvConf) - if err != nil { - t.Fatalf("Could not create resolv.conf test file %s: %s", resolvConf, err) - } - defer rm() - - tests := []struct { - input string - shouldErr bool - expectedZone string - expectedMw string // expected plugin. - expectedSearch []string // expected search path - expectedErrContent string // substring from the expected error. Empty for positive cases. - }{ - // positive - {`autopath @kubernetes`, false, "", "kubernetes", nil, ""}, - {`autopath example.org @kubernetes`, false, "example.org.", "kubernetes", nil, ""}, - {`autopath 10.0.0.0/8 @kubernetes`, false, "10.in-addr.arpa.", "kubernetes", nil, ""}, - {`autopath ` + resolv, false, "", "", []string{"bar.com.", "baz.com.", ""}, ""}, - // negative - {`autopath kubernetes`, true, "", "", nil, "open kubernetes: no such file or directory"}, - {`autopath`, true, "", "", nil, "no resolv-conf"}, - } - - for i, test := range tests { - c := caddy.NewTestController("dns", test.input) - ap, mw, err := autoPathParse(c) - - if test.shouldErr && err == nil { - t.Errorf("Test %d: Expected error but found %s for input %s", i, err, test.input) - } - - if err != nil { - if !test.shouldErr { - t.Errorf("Test %d: Expected no error but found one for input %s. Error was: %v", i, test.input, err) - } - - if !strings.Contains(err.Error(), test.expectedErrContent) { - t.Errorf("Test %d: Expected error to contain: %v, found error: %v, input: %s", i, test.expectedErrContent, err, test.input) - } - } - - if !test.shouldErr && mw != test.expectedMw { - t.Errorf("Test %d, Plugin not correctly set for input %s. Expected: %s, actual: %s", i, test.input, test.expectedMw, mw) - } - if !test.shouldErr && ap.search != nil { - if !reflect.DeepEqual(test.expectedSearch, ap.search) { - t.Errorf("Test %d, wrong searchpath for input %s. Expected: '%v', actual: '%v'", i, test.input, test.expectedSearch, ap.search) - } - } - if !test.shouldErr && test.expectedZone != "" { - if test.expectedZone != ap.Zones[0] { - t.Errorf("Test %d, expected zone %q for input %s, got: %q", i, test.expectedZone, test.input, ap.Zones[0]) - } - } - } -} - -const resolvConf = `nameserver 1.2.3.4 -domain foo.com -search bar.com baz.com -options ndots:5 -` diff --git a/vendor/github.com/coredns/coredns/plugin/bind/OWNERS b/vendor/github.com/coredns/coredns/plugin/bind/OWNERS deleted file mode 100644 index 0b2f5c68..00000000 --- a/vendor/github.com/coredns/coredns/plugin/bind/OWNERS +++ /dev/null @@ -1,6 +0,0 @@ -reviewers: - - miekg - - fturib -approvers: - - miekg - - fturib diff --git a/vendor/github.com/coredns/coredns/plugin/bind/README.md b/vendor/github.com/coredns/coredns/plugin/bind/README.md deleted file mode 100644 index a33a6c8d..00000000 --- a/vendor/github.com/coredns/coredns/plugin/bind/README.md +++ /dev/null @@ -1,51 +0,0 @@ -# bind - -## Name - -*bind* - overrides the host to which the server should bind. - -## Description - -Normally, the listener binds to the wildcard host. However, you may want the listener to bind to -another IP instead. - -If several addresses are provided, a listener will be open on each of the IP provided. - -Each address has to be an IP of one of the interfaces of the host. - -## Syntax - -~~~ txt -bind ADDRESS ... -~~~ - -**ADDRESS** is an IP address to bind to. -When several addresses are provided a listener will be opened on each of the addresses. - -## Examples - -To make your socket accessible only to that machine, bind to IP 127.0.0.1 (localhost): - -~~~ corefile -. { - bind 127.0.0.1 -} -~~~ - -To allow processing DNS requests only local host on both IPv4 and IPv6 stacks, use the syntax: - -~~~ corefile -. { - bind 127.0.0.1 ::1 -} -~~~ - -If the configuration comes up with several *bind* directives, all addresses are consolidated together: -The following sample is equivalent to the preceding: - -~~~ corefile -. { - bind 127.0.0.1 - bind ::1 -} -~~~ diff --git a/vendor/github.com/coredns/coredns/plugin/bind/bind.go b/vendor/github.com/coredns/coredns/plugin/bind/bind.go deleted file mode 100644 index c4a1306d..00000000 --- a/vendor/github.com/coredns/coredns/plugin/bind/bind.go +++ /dev/null @@ -1,11 +0,0 @@ -// Package bind allows binding to a specific interface instead of bind to all of them. -package bind - -import "github.com/mholt/caddy" - -func init() { - caddy.RegisterPlugin("bind", caddy.Plugin{ - ServerType: "dns", - Action: setup, - }) -} diff --git a/vendor/github.com/coredns/coredns/plugin/bind/bind_test.go b/vendor/github.com/coredns/coredns/plugin/bind/bind_test.go deleted file mode 100644 index ede4efac..00000000 --- a/vendor/github.com/coredns/coredns/plugin/bind/bind_test.go +++ /dev/null @@ -1,46 +0,0 @@ -package bind - -import ( - "testing" - - "github.com/coredns/coredns/core/dnsserver" - - "github.com/mholt/caddy" -) - -func TestSetup(t *testing.T) { - for i, test := range []struct { - config string - expected []string - failing bool - }{ - {`bind 1.2.3.4`, []string{"1.2.3.4"}, false}, - {`bind`, nil, true}, - {`bind 1.2.3.invalid`, nil, true}, - {`bind 1.2.3.4 ::5`, []string{"1.2.3.4", "::5"}, false}, - {`bind ::1 1.2.3.4 ::5 127.9.9.0`, []string{"::1", "1.2.3.4", "::5", "127.9.9.0"}, false}, - {`bind ::1 1.2.3.4 ::5 127.9.9.0 noone`, nil, true}, - } { - c := caddy.NewTestController("dns", test.config) - err := setup(c) - if err != nil { - if !test.failing { - t.Fatalf("Test %d, expected no errors, but got: %v", i, err) - } - continue - } - if test.failing { - t.Fatalf("Test %d, expected to failed but did not, returned values", i) - } - cfg := dnsserver.GetConfig(c) - if len(cfg.ListenHosts) != len(test.expected) { - t.Errorf("Test %d : expected the config's ListenHosts size to be %d, was %d", i, len(test.expected), len(cfg.ListenHosts)) - continue - } - for i, v := range test.expected { - if got, want := cfg.ListenHosts[i], v; got != want { - t.Errorf("Test %d : expected the config's ListenHost to be %s, was %s", i, want, got) - } - } - } -} diff --git a/vendor/github.com/coredns/coredns/plugin/bind/setup.go b/vendor/github.com/coredns/coredns/plugin/bind/setup.go deleted file mode 100644 index e487855c..00000000 --- a/vendor/github.com/coredns/coredns/plugin/bind/setup.go +++ /dev/null @@ -1,32 +0,0 @@ -package bind - -import ( - "fmt" - "net" - - "github.com/coredns/coredns/core/dnsserver" - "github.com/coredns/coredns/plugin" - - "github.com/mholt/caddy" -) - -func setup(c *caddy.Controller) error { - config := dnsserver.GetConfig(c) - - // addresses will be consolidated over all BIND directives available in that BlocServer - all := []string{} - for c.Next() { - addrs := c.RemainingArgs() - if len(addrs) == 0 { - return plugin.Error("bind", fmt.Errorf("at least one address is expected")) - } - for _, addr := range addrs { - if net.ParseIP(addr) == nil { - return plugin.Error("bind", fmt.Errorf("not a valid IP address: %s", addr)) - } - } - all = append(all, addrs...) - } - config.ListenHosts = all - return nil -} diff --git a/vendor/github.com/coredns/coredns/plugin/cache/README.md b/vendor/github.com/coredns/coredns/plugin/cache/README.md index 3af79cb5..e4815268 100644 --- a/vendor/github.com/coredns/coredns/plugin/cache/README.md +++ b/vendor/github.com/coredns/coredns/plugin/cache/README.md @@ -24,8 +24,8 @@ cache [TTL] [ZONES...] * **ZONES** zones it should cache for. If empty, the zones from the configuration block are used. Each element in the cache is cached according to its TTL (with **TTL** as the max). -For the negative cache, the SOA's MinTTL value is used. A TTL of zero is not allowed. -A cache is divided into 256 shards, each holding up to 512 items by default - for a total size +For the negative cache, the SOA's MinTTL value is used. A TTL of zero is not allowed. +A cache is divided into 256 shards, each holding up to 512 items by default - for a total size of 256 * 512 = 131,072 items. If you want more control: diff --git a/vendor/github.com/coredns/coredns/plugin/cache/cache.go b/vendor/github.com/coredns/coredns/plugin/cache/cache.go index 4e64fa73..c4626765 100644 --- a/vendor/github.com/coredns/coredns/plugin/cache/cache.go +++ b/vendor/github.com/coredns/coredns/plugin/cache/cache.go @@ -4,10 +4,12 @@ package cache import ( "encoding/binary" "hash/fnv" + "net" "time" "github.com/coredns/coredns/plugin" "github.com/coredns/coredns/plugin/pkg/cache" + "github.com/coredns/coredns/plugin/pkg/dnsutil" "github.com/coredns/coredns/plugin/pkg/response" "github.com/coredns/coredns/request" @@ -105,7 +107,40 @@ type ResponseWriter struct { state request.Request server string // Server handling the request. - prefetch bool // When true write nothing back to the client. + prefetch bool // When true write nothing back to the client. + remoteAddr net.Addr +} + +// newPrefetchResponseWriter returns a Cache ResponseWriter to be used in +// prefetch requests. It ensures RemoteAddr() can be called even after the +// original connetion has already been closed. +func newPrefetchResponseWriter(server string, state request.Request, c *Cache) *ResponseWriter { + // Resolve the address now, the connection might be already closed when the + // actual prefetch request is made. + addr := state.W.RemoteAddr() + // The protocol of the client triggering a cache prefetch doesn't matter. + // The address type is used by request.Proto to determine the response size, + // and using TCP ensures the message isn't unnecessarily truncated. + if u, ok := addr.(*net.UDPAddr); ok { + addr = &net.TCPAddr{IP: u.IP, Port: u.Port, Zone: u.Zone} + } + + return &ResponseWriter{ + ResponseWriter: state.W, + Cache: c, + state: state, + server: server, + prefetch: true, + remoteAddr: addr, + } +} + +// RemoteAddr implements the dns.ResponseWriter interface. +func (w *ResponseWriter) RemoteAddr() net.Addr { + if w.remoteAddr != nil { + return w.remoteAddr + } + return w.ResponseWriter.RemoteAddr() } // WriteMsg implements the dns.ResponseWriter interface. @@ -124,7 +159,7 @@ func (w *ResponseWriter) WriteMsg(res *dns.Msg) error { duration = w.nttl } - msgTTL := minMsgTTL(res, mt) + msgTTL := dnsutil.MinimalTTL(res, mt) if msgTTL < duration { duration = msgTTL } @@ -192,9 +227,8 @@ func (w *ResponseWriter) Write(buf []byte) (int, error) { } const ( - maxTTL = 1 * time.Hour - maxNTTL = 30 * time.Minute - failSafeTTL = 5 * time.Second + maxTTL = dnsutil.MaximumDefaulTTL + maxNTTL = dnsutil.MaximumDefaulTTL / 2 defaultCap = 10000 // default capacity of the cache. diff --git a/vendor/github.com/coredns/coredns/plugin/cache/cache_test.go b/vendor/github.com/coredns/coredns/plugin/cache/cache_test.go deleted file mode 100644 index c2ab7492..00000000 --- a/vendor/github.com/coredns/coredns/plugin/cache/cache_test.go +++ /dev/null @@ -1,270 +0,0 @@ -package cache - -import ( - "context" - "testing" - "time" - - "github.com/coredns/coredns/plugin" - "github.com/coredns/coredns/plugin/pkg/response" - "github.com/coredns/coredns/plugin/test" - "github.com/coredns/coredns/request" - - "github.com/miekg/dns" -) - -type cacheTestCase struct { - test.Case - in test.Case - AuthenticatedData bool - Authoritative bool - RecursionAvailable bool - Truncated bool - shouldCache bool -} - -var cacheTestCases = []cacheTestCase{ - { - RecursionAvailable: true, AuthenticatedData: true, Authoritative: true, - Case: test.Case{ - Qname: "miek.nl.", Qtype: dns.TypeMX, - Answer: []dns.RR{ - test.MX("miek.nl. 3600 IN MX 1 aspmx.l.google.com."), - test.MX("miek.nl. 3600 IN MX 10 aspmx2.googlemail.com."), - }, - }, - in: test.Case{ - Qname: "miek.nl.", Qtype: dns.TypeMX, - Answer: []dns.RR{ - test.MX("miek.nl. 3601 IN MX 1 aspmx.l.google.com."), - test.MX("miek.nl. 3601 IN MX 10 aspmx2.googlemail.com."), - }, - }, - shouldCache: true, - }, - { - RecursionAvailable: true, AuthenticatedData: true, Authoritative: true, - Case: test.Case{ - Qname: "mIEK.nL.", Qtype: dns.TypeMX, - Answer: []dns.RR{ - test.MX("mIEK.nL. 3600 IN MX 1 aspmx.l.google.com."), - test.MX("mIEK.nL. 3600 IN MX 10 aspmx2.googlemail.com."), - }, - }, - in: test.Case{ - Qname: "mIEK.nL.", Qtype: dns.TypeMX, - Answer: []dns.RR{ - test.MX("mIEK.nL. 3601 IN MX 1 aspmx.l.google.com."), - test.MX("mIEK.nL. 3601 IN MX 10 aspmx2.googlemail.com."), - }, - }, - shouldCache: true, - }, - { - Truncated: true, - Case: test.Case{ - Qname: "miek.nl.", Qtype: dns.TypeMX, - Answer: []dns.RR{test.MX("miek.nl. 1800 IN MX 1 aspmx.l.google.com.")}, - }, - in: test.Case{}, - shouldCache: false, - }, - { - RecursionAvailable: true, Authoritative: true, - Case: test.Case{ - Rcode: dns.RcodeNameError, - Qname: "example.org.", Qtype: dns.TypeA, - Ns: []dns.RR{ - test.SOA("example.org. 3600 IN SOA sns.dns.icann.org. noc.dns.icann.org. 2016082540 7200 3600 1209600 3600"), - }, - }, - in: test.Case{ - Rcode: dns.RcodeNameError, - Qname: "example.org.", Qtype: dns.TypeA, - Ns: []dns.RR{ - test.SOA("example.org. 3600 IN SOA sns.dns.icann.org. noc.dns.icann.org. 2016082540 7200 3600 1209600 3600"), - }, - }, - shouldCache: true, - }, - { - RecursionAvailable: true, Authoritative: true, - Case: test.Case{ - Qname: "miek.nl.", Qtype: dns.TypeMX, - Do: true, - Answer: []dns.RR{ - test.MX("miek.nl. 3600 IN MX 1 aspmx.l.google.com."), - test.MX("miek.nl. 3600 IN MX 10 aspmx2.googlemail.com."), - test.RRSIG("miek.nl. 3600 IN RRSIG MX 8 2 1800 20160521031301 20160421031301 12051 miek.nl. lAaEzB5teQLLKyDenatmyhca7blLRg9DoGNrhe3NReBZN5C5/pMQk8Jc u25hv2fW23/SLm5IC2zaDpp2Fzgm6Jf7e90/yLcwQPuE7JjS55WMF+HE LEh7Z6AEb+Iq4BWmNhUz6gPxD4d9eRMs7EAzk13o1NYi5/JhfL6IlaYy qkc="), - }, - }, - in: test.Case{ - Qname: "miek.nl.", Qtype: dns.TypeMX, - Do: true, - Answer: []dns.RR{ - test.MX("miek.nl. 3600 IN MX 1 aspmx.l.google.com."), - test.MX("miek.nl. 3600 IN MX 10 aspmx2.googlemail.com."), - test.RRSIG("miek.nl. 1800 IN RRSIG MX 8 2 1800 20160521031301 20160421031301 12051 miek.nl. lAaEzB5teQLLKyDenatmyhca7blLRg9DoGNrhe3NReBZN5C5/pMQk8Jc u25hv2fW23/SLm5IC2zaDpp2Fzgm6Jf7e90/yLcwQPuE7JjS55WMF+HE LEh7Z6AEb+Iq4BWmNhUz6gPxD4d9eRMs7EAzk13o1NYi5/JhfL6IlaYy qkc="), - }, - }, - shouldCache: false, - }, - { - RecursionAvailable: true, Authoritative: true, - Case: test.Case{ - Qname: "example.org.", Qtype: dns.TypeMX, - Do: true, - Answer: []dns.RR{ - test.MX("example.org. 3600 IN MX 1 aspmx.l.google.com."), - test.MX("example.org. 3600 IN MX 10 aspmx2.googlemail.com."), - test.RRSIG("example.org. 3600 IN RRSIG MX 8 2 1800 20170521031301 20170421031301 12051 miek.nl. lAaEzB5teQLLKyDenatmyhca7blLRg9DoGNrhe3NReBZN5C5/pMQk8Jc u25hv2fW23/SLm5IC2zaDpp2Fzgm6Jf7e90/yLcwQPuE7JjS55WMF+HE LEh7Z6AEb+Iq4BWmNhUz6gPxD4d9eRMs7EAzk13o1NYi5/JhfL6IlaYy qkc="), - }, - }, - in: test.Case{ - Qname: "example.org.", Qtype: dns.TypeMX, - Do: true, - Answer: []dns.RR{ - test.MX("example.org. 3600 IN MX 1 aspmx.l.google.com."), - test.MX("example.org. 3600 IN MX 10 aspmx2.googlemail.com."), - test.RRSIG("example.org. 1800 IN RRSIG MX 8 2 1800 20170521031301 20170421031301 12051 miek.nl. lAaEzB5teQLLKyDenatmyhca7blLRg9DoGNrhe3NReBZN5C5/pMQk8Jc u25hv2fW23/SLm5IC2zaDpp2Fzgm6Jf7e90/yLcwQPuE7JjS55WMF+HE LEh7Z6AEb+Iq4BWmNhUz6gPxD4d9eRMs7EAzk13o1NYi5/JhfL6IlaYy qkc="), - }, - }, - shouldCache: true, - }, -} - -func cacheMsg(m *dns.Msg, tc cacheTestCase) *dns.Msg { - m.RecursionAvailable = tc.RecursionAvailable - m.AuthenticatedData = tc.AuthenticatedData - m.Authoritative = tc.Authoritative - m.Rcode = tc.Rcode - m.Truncated = tc.Truncated - m.Answer = tc.in.Answer - m.Ns = tc.in.Ns - // m.Extra = tc.in.Extra don't copy Extra, because we don't care and fake EDNS0 DO with tc.Do. - return m -} - -func newTestCache(ttl time.Duration) (*Cache, *ResponseWriter) { - c := New() - c.pttl = ttl - c.nttl = ttl - - crr := &ResponseWriter{ResponseWriter: nil, Cache: c} - return c, crr -} - -func TestCache(t *testing.T) { - now, _ := time.Parse(time.UnixDate, "Fri Apr 21 10:51:21 BST 2017") - utc := now.UTC() - - c, crr := newTestCache(maxTTL) - - for _, tc := range cacheTestCases { - m := tc.in.Msg() - m = cacheMsg(m, tc) - - state := request.Request{W: nil, Req: m} - - mt, _ := response.Typify(m, utc) - k := key(m, mt, state.Do()) - - crr.set(m, k, mt, c.pttl) - - i, _ := c.get(time.Now().UTC(), state, "dns://:53") - ok := i != nil - - if ok != tc.shouldCache { - t.Errorf("Cached message that should not have been cached: %s", state.Name()) - continue - } - - if ok { - resp := i.toMsg(m, time.Now().UTC()) - - if !test.Header(t, tc.Case, resp) { - t.Logf("%v\n", resp) - continue - } - - if !test.Section(t, tc.Case, test.Answer, resp.Answer) { - t.Logf("%v\n", resp) - } - if !test.Section(t, tc.Case, test.Ns, resp.Ns) { - t.Logf("%v\n", resp) - - } - if !test.Section(t, tc.Case, test.Extra, resp.Extra) { - t.Logf("%v\n", resp) - } - } - } -} - -func TestCacheZeroTTL(t *testing.T) { - c := New() - c.Next = zeroTTLBackend() - - req := new(dns.Msg) - req.SetQuestion("example.org.", dns.TypeA) - ctx := context.TODO() - - c.ServeDNS(ctx, &test.ResponseWriter{}, req) - if c.pcache.Len() != 0 { - t.Errorf("Msg with 0 TTL should not have been cached") - } - if c.ncache.Len() != 0 { - t.Errorf("Msg with 0 TTL should not have been cached") - } -} - -func BenchmarkCacheResponse(b *testing.B) { - c := New() - c.prefetch = 1 - c.Next = BackendHandler() - - ctx := context.TODO() - - reqs := make([]*dns.Msg, 5) - for i, q := range []string{"example1", "example2", "a", "b", "ddd"} { - reqs[i] = new(dns.Msg) - reqs[i].SetQuestion(q+".example.org.", dns.TypeA) - } - - b.StartTimer() - - j := 0 - for i := 0; i < b.N; i++ { - req := reqs[j] - c.ServeDNS(ctx, &test.ResponseWriter{}, req) - j++ - j = j % 5 - } -} - -func BackendHandler() plugin.Handler { - return plugin.HandlerFunc(func(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (int, error) { - m := new(dns.Msg) - m.SetReply(r) - m.Response = true - m.RecursionAvailable = true - - owner := m.Question[0].Name - m.Answer = []dns.RR{test.A(owner + " 303 IN A 127.0.0.53")} - - w.WriteMsg(m) - return dns.RcodeSuccess, nil - }) -} - -func zeroTTLBackend() plugin.Handler { - return plugin.HandlerFunc(func(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (int, error) { - m := new(dns.Msg) - m.SetReply(r) - m.Response, m.RecursionAvailable = true, true - - m.Answer = []dns.RR{test.A("example.org. 0 IN A 127.0.0.53")} - w.WriteMsg(m) - return dns.RcodeSuccess, nil - }) -} diff --git a/vendor/github.com/coredns/coredns/plugin/cache/freq/freq_test.go b/vendor/github.com/coredns/coredns/plugin/cache/freq/freq_test.go deleted file mode 100644 index 740194c8..00000000 --- a/vendor/github.com/coredns/coredns/plugin/cache/freq/freq_test.go +++ /dev/null @@ -1,36 +0,0 @@ -package freq - -import ( - "testing" - "time" -) - -func TestFreqUpdate(t *testing.T) { - now := time.Now().UTC() - f := New(now) - window := 1 * time.Minute - - f.Update(window, time.Now().UTC()) - f.Update(window, time.Now().UTC()) - f.Update(window, time.Now().UTC()) - hitsCheck(t, f, 3) - - f.Reset(now, 0) - history := time.Now().UTC().Add(-3 * time.Minute) - f.Update(window, history) - hitsCheck(t, f, 1) -} - -func TestReset(t *testing.T) { - f := New(time.Now().UTC()) - f.Update(1*time.Minute, time.Now().UTC()) - hitsCheck(t, f, 1) - f.Reset(time.Now().UTC(), 0) - hitsCheck(t, f, 0) -} - -func hitsCheck(t *testing.T, f *Freq, expected int) { - if x := f.Hits(); x != expected { - t.Fatalf("Expected hits to be %d, got %d", expected, x) - } -} diff --git a/vendor/github.com/coredns/coredns/plugin/cache/handler.go b/vendor/github.com/coredns/coredns/plugin/cache/handler.go index 59864056..11e1323f 100644 --- a/vendor/github.com/coredns/coredns/plugin/cache/handler.go +++ b/vendor/github.com/coredns/coredns/plugin/cache/handler.go @@ -27,8 +27,8 @@ func (c *Cache) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) server := metrics.WithServer(ctx) - i, ttl := c.get(now, state, server) - if i != nil && ttl > 0 { + i, found := c.get(now, state, server) + if i != nil && found { resp := i.toMsg(r, now) state.SizeAndDo(resp) @@ -36,24 +36,23 @@ func (c *Cache) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) w.WriteMsg(resp) if c.prefetch > 0 { + ttl := i.ttl(now) i.Freq.Update(c.duration, now) threshold := int(math.Ceil(float64(c.percentage) / 100 * float64(i.origTTL))) if i.Freq.Hits() >= c.prefetch && ttl <= threshold { - go func() { + cw := newPrefetchResponseWriter(server, state, c) + go func(w dns.ResponseWriter) { cachePrefetches.WithLabelValues(server).Inc() + plugin.NextOrFailure(c.Name(), c.Next, ctx, w, r) + // When prefetching we loose the item i, and with it the frequency // that we've gathered sofar. See we copy the frequencies info back // into the new item that was stored in the cache. - prr := &ResponseWriter{ResponseWriter: w, Cache: c, - prefetch: true, state: state, - server: server} - plugin.NextOrFailure(c.Name(), c.Next, ctx, prr, r) - if i1 := c.exists(state); i1 != nil { i1.Freq.Reset(now, i.Freq.Hits()) } - }() + }(cw) } } return dns.RcodeSuccess, nil @@ -66,20 +65,20 @@ func (c *Cache) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) // Name implements the Handler interface. func (c *Cache) Name() string { return "cache" } -func (c *Cache) get(now time.Time, state request.Request, server string) (*item, int) { +func (c *Cache) get(now time.Time, state request.Request, server string) (*item, bool) { k := hash(state.Name(), state.QType(), state.Do()) - if i, ok := c.ncache.Get(k); ok { + if i, ok := c.ncache.Get(k); ok && i.(*item).ttl(now) > 0 { cacheHits.WithLabelValues(server, Denial).Inc() - return i.(*item), i.(*item).ttl(now) + return i.(*item), true } - if i, ok := c.pcache.Get(k); ok { + if i, ok := c.pcache.Get(k); ok && i.(*item).ttl(now) > 0 { cacheHits.WithLabelValues(server, Success).Inc() - return i.(*item), i.(*item).ttl(now) + return i.(*item), true } cacheMisses.WithLabelValues(server).Inc() - return nil, 0 + return nil, false } func (c *Cache) exists(state request.Request) *item { diff --git a/vendor/github.com/coredns/coredns/plugin/cache/item.go b/vendor/github.com/coredns/coredns/plugin/cache/item.go index 5761cdf8..f4858c3b 100644 --- a/vendor/github.com/coredns/coredns/plugin/cache/item.go +++ b/vendor/github.com/coredns/coredns/plugin/cache/item.go @@ -4,7 +4,6 @@ import ( "time" "github.com/coredns/coredns/plugin/cache/freq" - "github.com/coredns/coredns/plugin/pkg/response" "github.com/miekg/dns" ) @@ -87,58 +86,3 @@ func (i *item) ttl(now time.Time) int { ttl := int(i.origTTL) - int(now.UTC().Sub(i.stored).Seconds()) return ttl } - -func minMsgTTL(m *dns.Msg, mt response.Type) time.Duration { - if mt != response.NoError && mt != response.NameError && mt != response.NoData { - return 0 - } - - // No data to examine, return a short ttl as a fail safe. - if len(m.Answer)+len(m.Ns)+len(m.Extra) == 0 { - return failSafeTTL - } - - minTTL := maxTTL - for _, r := range m.Answer { - switch mt { - case response.NameError, response.NoData: - if r.Header().Rrtype == dns.TypeSOA { - minTTL = time.Duration(r.(*dns.SOA).Minttl) * time.Second - } - case response.NoError, response.Delegation: - if r.Header().Ttl < uint32(minTTL.Seconds()) { - minTTL = time.Duration(r.Header().Ttl) * time.Second - } - } - } - for _, r := range m.Ns { - switch mt { - case response.NameError, response.NoData: - if r.Header().Rrtype == dns.TypeSOA { - minTTL = time.Duration(r.(*dns.SOA).Minttl) * time.Second - } - case response.NoError, response.Delegation: - if r.Header().Ttl < uint32(minTTL.Seconds()) { - minTTL = time.Duration(r.Header().Ttl) * time.Second - } - } - } - - for _, r := range m.Extra { - if r.Header().Rrtype == dns.TypeOPT { - // OPT records use TTL field for extended rcode and flags - continue - } - switch mt { - case response.NameError, response.NoData: - if r.Header().Rrtype == dns.TypeSOA { - minTTL = time.Duration(r.(*dns.SOA).Minttl) * time.Second - } - case response.NoError, response.Delegation: - if r.Header().Ttl < uint32(minTTL.Seconds()) { - minTTL = time.Duration(r.Header().Ttl) * time.Second - } - } - } - return minTTL -} diff --git a/vendor/github.com/coredns/coredns/plugin/cache/minttl_test.go b/vendor/github.com/coredns/coredns/plugin/cache/minttl_test.go deleted file mode 100644 index 376c638a..00000000 --- a/vendor/github.com/coredns/coredns/plugin/cache/minttl_test.go +++ /dev/null @@ -1,72 +0,0 @@ -package cache - -import ( - "testing" - "time" - - "github.com/coredns/coredns/plugin/pkg/response" - "github.com/coredns/coredns/plugin/test" - - "github.com/miekg/dns" -) - -// See https://github.com/kubernetes/dns/issues/121, add some specific tests for those use cases. - -func TestMinMsgTTL(t *testing.T) { - m := new(dns.Msg) - m.SetQuestion("z.alm.im.", dns.TypeA) - m.Ns = []dns.RR{ - test.SOA("alm.im. 1800 IN SOA ivan.ns.cloudflare.com. dns.cloudflare.com. 2025042470 10000 2400 604800 3600"), - } - - utc := time.Now().UTC() - - mt, _ := response.Typify(m, utc) - if mt != response.NoData { - t.Fatalf("Expected type to be response.NoData, got %s", mt) - } - dur := minMsgTTL(m, mt) // minTTL on msg is 3600 (neg. ttl on SOA) - if dur != time.Duration(3600*time.Second) { - t.Fatalf("Expected minttl duration to be %d, got %d", 3600, dur) - } - - m.Rcode = dns.RcodeNameError - mt, _ = response.Typify(m, utc) - if mt != response.NameError { - t.Fatalf("Expected type to be response.NameError, got %s", mt) - } - dur = minMsgTTL(m, mt) // minTTL on msg is 3600 (neg. ttl on SOA) - if dur != time.Duration(3600*time.Second) { - t.Fatalf("Expected minttl duration to be %d, got %d", 3600, dur) - } -} - -func BenchmarkMinMsgTTL(b *testing.B) { - m := new(dns.Msg) - m.SetQuestion("example.org.", dns.TypeA) - m.Ns = []dns.RR{ - test.A("a.example.org. 1800 IN A 127.0.0.53"), - test.A("b.example.org. 1900 IN A 127.0.0.53"), - test.A("c.example.org. 1600 IN A 127.0.0.53"), - test.A("d.example.org. 1100 IN A 127.0.0.53"), - test.A("e.example.org. 1000 IN A 127.0.0.53"), - } - m.Extra = []dns.RR{ - test.A("a.example.org. 1800 IN A 127.0.0.53"), - test.A("b.example.org. 1600 IN A 127.0.0.53"), - test.A("c.example.org. 1400 IN A 127.0.0.53"), - test.A("d.example.org. 1200 IN A 127.0.0.53"), - test.A("e.example.org. 1100 IN A 127.0.0.53"), - } - - utc := time.Now().UTC() - mt, _ := response.Typify(m, utc) - - b.ResetTimer() - for i := 0; i < b.N; i++ { - dur := minMsgTTL(m, mt) - if dur != 1000*time.Second { - b.Fatalf("Wrong minMsgTTL %d, expected %d", dur, 1000*time.Second) - } - } -} diff --git a/vendor/github.com/coredns/coredns/plugin/cache/prefech_test.go b/vendor/github.com/coredns/coredns/plugin/cache/prefech_test.go deleted file mode 100644 index c4673a72..00000000 --- a/vendor/github.com/coredns/coredns/plugin/cache/prefech_test.go +++ /dev/null @@ -1,163 +0,0 @@ -package cache - -import ( - "context" - "fmt" - "testing" - "time" - - "github.com/coredns/coredns/plugin" - "github.com/coredns/coredns/plugin/pkg/dnstest" - - "github.com/coredns/coredns/plugin/test" - "github.com/miekg/dns" -) - -func TestPrefetch(t *testing.T) { - tests := []struct { - qname string - ttl int - prefetch int - verifications []verification - }{ - { - qname: "hits.reset.example.org.", - ttl: 80, - prefetch: 1, - verifications: []verification{ - { - after: 0 * time.Second, - answer: "hits.reset.example.org. 80 IN A 127.0.0.1", - fetch: true, - }, - { - after: 73 * time.Second, - answer: "hits.reset.example.org. 7 IN A 127.0.0.1", - fetch: true, - }, - { - after: 80 * time.Second, - answer: "hits.reset.example.org. 73 IN A 127.0.0.2", - }, - }, - }, - { - qname: "short.ttl.example.org.", - ttl: 5, - prefetch: 1, - verifications: []verification{ - { - after: 0 * time.Second, - answer: "short.ttl.example.org. 5 IN A 127.0.0.1", - fetch: true, - }, - { - after: 1 * time.Second, - answer: "short.ttl.example.org. 4 IN A 127.0.0.1", - }, - { - after: 4 * time.Second, - answer: "short.ttl.example.org. 1 IN A 127.0.0.1", - fetch: true, - }, - { - after: 5 * time.Second, - answer: "short.ttl.example.org. 4 IN A 127.0.0.2", - }, - }, - }, - { - qname: "no.prefetch.example.org.", - ttl: 30, - prefetch: 0, - verifications: []verification{ - { - after: 0 * time.Second, - answer: "no.prefetch.example.org. 30 IN A 127.0.0.1", - fetch: true, - }, - { - after: 15 * time.Second, - answer: "no.prefetch.example.org. 15 IN A 127.0.0.1", - }, - { - after: 29 * time.Second, - answer: "no.prefetch.example.org. 1 IN A 127.0.0.1", - }, - { - after: 30 * time.Second, - answer: "no.prefetch.example.org. 30 IN A 127.0.0.2", - fetch: true, - }, - }, - }, - } - - t0, err := time.Parse(time.RFC3339, "2018-01-01T14:00:00+00:00") - if err != nil { - t.Fatal(err) - } - for _, tt := range tests { - t.Run(tt.qname, func(t *testing.T) { - fetchc := make(chan struct{}, 1) - - c := New() - c.prefetch = tt.prefetch - c.Next = prefetchHandler(tt.qname, tt.ttl, fetchc) - - req := new(dns.Msg) - req.SetQuestion(tt.qname, dns.TypeA) - rec := dnstest.NewRecorder(&test.ResponseWriter{}) - - for _, v := range tt.verifications { - c.now = func() time.Time { return t0.Add(v.after) } - - c.ServeDNS(context.TODO(), rec, req) - if v.fetch { - select { - case <-fetchc: - if !v.fetch { - t.Fatalf("After %s: want request to trigger a prefetch", v.after) - } - case <-time.After(time.Second): - t.Fatalf("After %s: want request to trigger a prefetch", v.after) - } - } - if want, got := rec.Rcode, dns.RcodeSuccess; want != got { - t.Errorf("After %s: want rcode %d, got %d", v.after, want, got) - } - if want, got := 1, len(rec.Msg.Answer); want != got { - t.Errorf("After %s: want %d answer RR, got %d", v.after, want, got) - } - if want, got := test.A(v.answer).String(), rec.Msg.Answer[0].String(); want != got { - t.Errorf("After %s: want answer %s, got %s", v.after, want, got) - } - } - }) - } -} - -type verification struct { - after time.Duration - answer string - // fetch defines whether a request is sent to the next handler. - fetch bool -} - -// prefetchHandler is a fake plugin implementation which returns a single A -// record with the given qname and ttl. The returned IP address starts at -// 127.0.0.1 and is incremented on every request. -func prefetchHandler(qname string, ttl int, fetchc chan struct{}) plugin.Handler { - i := 0 - return plugin.HandlerFunc(func(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (int, error) { - i++ - m := new(dns.Msg) - m.SetQuestion(qname, dns.TypeA) - m.Response = true - m.Answer = append(m.Answer, test.A(fmt.Sprintf("%s %d IN A 127.0.0.%d", qname, ttl, i))) - - w.WriteMsg(m) - fetchc <- struct{}{} - return dns.RcodeSuccess, nil - }) -} diff --git a/vendor/github.com/coredns/coredns/plugin/cache/setup_test.go b/vendor/github.com/coredns/coredns/plugin/cache/setup_test.go deleted file mode 100644 index c735e0bb..00000000 --- a/vendor/github.com/coredns/coredns/plugin/cache/setup_test.go +++ /dev/null @@ -1,96 +0,0 @@ -package cache - -import ( - "testing" - "time" - - "github.com/mholt/caddy" -) - -func TestSetup(t *testing.T) { - tests := []struct { - input string - shouldErr bool - expectedNcap int - expectedPcap int - expectedNttl time.Duration - expectedPttl time.Duration - expectedPrefetch int - }{ - {`cache`, false, defaultCap, defaultCap, maxNTTL, maxTTL, 0}, - {`cache {}`, false, defaultCap, defaultCap, maxNTTL, maxTTL, 0}, - {`cache example.nl { - success 10 - }`, false, defaultCap, 10, maxNTTL, maxTTL, 0}, - {`cache example.nl { - success 10 - denial 10 15 - }`, false, 10, 10, 15 * time.Second, maxTTL, 0}, - {`cache 25 example.nl { - success 10 - denial 10 15 - }`, false, 10, 10, 15 * time.Second, 25 * time.Second, 0}, - {`cache aaa example.nl`, false, defaultCap, defaultCap, maxNTTL, maxTTL, 0}, - {`cache { - prefetch 10 - }`, false, defaultCap, defaultCap, maxNTTL, maxTTL, 10}, - - // fails - {`cache example.nl { - success - denial 10 15 - }`, true, defaultCap, defaultCap, maxTTL, maxTTL, 0}, - {`cache example.nl { - success 15 - denial aaa - }`, true, defaultCap, defaultCap, maxTTL, maxTTL, 0}, - {`cache example.nl { - positive 15 - negative aaa - }`, true, defaultCap, defaultCap, maxTTL, maxTTL, 0}, - {`cache 0 example.nl`, true, defaultCap, defaultCap, maxTTL, maxTTL, 0}, - {`cache -1 example.nl`, true, defaultCap, defaultCap, maxTTL, maxTTL, 0}, - {`cache 1 example.nl { - positive 0 - }`, true, defaultCap, defaultCap, maxTTL, maxTTL, 0}, - {`cache 1 example.nl { - positive 0 - prefetch -1 - }`, true, defaultCap, defaultCap, maxTTL, maxTTL, 0}, - {`cache 1 example.nl { - prefetch 0 blurp - }`, true, defaultCap, defaultCap, maxTTL, maxTTL, 0}, - {`cache - cache`, true, defaultCap, defaultCap, maxTTL, maxTTL, 0}, - } - for i, test := range tests { - c := caddy.NewTestController("dns", test.input) - ca, err := cacheParse(c) - if test.shouldErr && err == nil { - t.Errorf("Test %v: Expected error but found nil", i) - continue - } else if !test.shouldErr && err != nil { - t.Errorf("Test %v: Expected no error but found error: %v", i, err) - continue - } - if test.shouldErr && err != nil { - continue - } - - if ca.ncap != test.expectedNcap { - t.Errorf("Test %v: Expected ncap %v but found: %v", i, test.expectedNcap, ca.ncap) - } - if ca.pcap != test.expectedPcap { - t.Errorf("Test %v: Expected pcap %v but found: %v", i, test.expectedPcap, ca.pcap) - } - if ca.nttl != test.expectedNttl { - t.Errorf("Test %v: Expected nttl %v but found: %v", i, test.expectedNttl, ca.nttl) - } - if ca.pttl != test.expectedPttl { - t.Errorf("Test %v: Expected pttl %v but found: %v", i, test.expectedPttl, ca.pttl) - } - if ca.prefetch != test.expectedPrefetch { - t.Errorf("Test %v: Expected prefetch %v but found: %v", i, test.expectedPrefetch, ca.prefetch) - } - } -} diff --git a/vendor/github.com/coredns/coredns/plugin/cache/spoof_test.go b/vendor/github.com/coredns/coredns/plugin/cache/spoof_test.go deleted file mode 100644 index 04d714f4..00000000 --- a/vendor/github.com/coredns/coredns/plugin/cache/spoof_test.go +++ /dev/null @@ -1,82 +0,0 @@ -package cache - -import ( - "context" - "testing" - - "github.com/coredns/coredns/plugin" - "github.com/coredns/coredns/plugin/pkg/dnstest" - - "github.com/coredns/coredns/plugin/test" - "github.com/miekg/dns" -) - -func TestSpoof(t *testing.T) { - // Send query for example.org, get reply for example.net; should not be cached. - c := New() - c.Next = spoofHandler(true) - - req := new(dns.Msg) - req.SetQuestion("example.org.", dns.TypeA) - rec := dnstest.NewRecorder(&test.ResponseWriter{}) - - c.ServeDNS(context.TODO(), rec, req) - - qname := rec.Msg.Question[0].Name - if c.pcache.Len() != 0 { - t.Errorf("Cached %s, while reply had %s", "example.org.", qname) - } - - // qtype - c.Next = spoofHandlerType() - req.SetQuestion("example.org.", dns.TypeMX) - - c.ServeDNS(context.TODO(), rec, req) - - qtype := rec.Msg.Question[0].Qtype - if c.pcache.Len() != 0 { - t.Errorf("Cached %s type %d, while reply had %d", "example.org.", dns.TypeMX, qtype) - } -} - -func TestResponse(t *testing.T) { - // Send query for example.org, get reply for example.net; should not be cached. - c := New() - c.Next = spoofHandler(false) - - req := new(dns.Msg) - req.SetQuestion("example.net.", dns.TypeA) - rec := dnstest.NewRecorder(&test.ResponseWriter{}) - - c.ServeDNS(context.TODO(), rec, req) - - if c.pcache.Len() != 0 { - t.Errorf("Cached %s, while reply had response set to %t", "example.net.", rec.Msg.Response) - } -} - -// spoofHandler is a fake plugin implementation which returns a single A records for example.org. The qname in the -// question section is set to example.NET (i.e. they *don't* match). -func spoofHandler(response bool) plugin.Handler { - return plugin.HandlerFunc(func(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (int, error) { - m := new(dns.Msg) - m.SetQuestion("example.net.", dns.TypeA) - m.Response = response - m.Answer = []dns.RR{test.A("example.org. IN A 127.0.0.53")} - w.WriteMsg(m) - return dns.RcodeSuccess, nil - }) -} - -// spoofHandlerType is a fake plugin implementation which returns a single MX records for example.org. The qtype in the -// question section is set to A. -func spoofHandlerType() plugin.Handler { - return plugin.HandlerFunc(func(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (int, error) { - m := new(dns.Msg) - m.SetQuestion("example.org.", dns.TypeA) - m.Response = true - m.Answer = []dns.RR{test.MX("example.org. IN MX 10 mail.example.org.")} - w.WriteMsg(m) - return dns.RcodeSuccess, nil - }) -} diff --git a/vendor/github.com/coredns/coredns/plugin/chaos/OWNERS b/vendor/github.com/coredns/coredns/plugin/chaos/OWNERS deleted file mode 100644 index eee46f68..00000000 --- a/vendor/github.com/coredns/coredns/plugin/chaos/OWNERS +++ /dev/null @@ -1,4 +0,0 @@ -reviewers: - - miekg -approvers: - - miekg diff --git a/vendor/github.com/coredns/coredns/plugin/chaos/README.md b/vendor/github.com/coredns/coredns/plugin/chaos/README.md deleted file mode 100644 index 8ddb2b0c..00000000 --- a/vendor/github.com/coredns/coredns/plugin/chaos/README.md +++ /dev/null @@ -1,51 +0,0 @@ -# chaos - -## Name - -*chaos* - allows for responding to TXT queries in the CH class. - -## Description - -This is useful for retrieving version or author information from the server by querying a TXT record -for a special domainname in the CH class. - -## Syntax - -~~~ -chaos [VERSION] [AUTHORS...] -~~~ - -* **VERSION** is the version to return. Defaults to `CoreDNS-`, if not set. -* **AUTHORS** is what authors to return. No default. - -Note that you have to make sure that this plugin will get actual queries for the -following zones: `version.bind`, `version.server`, `authors.bind`, `hostname.bind` and -`id.server`. - -## Examples - -Specify all the zones in full. - -~~~ corefile -version.bind version.server authors.bind hostname.bind id.server { - chaos CoreDNS-001 info@coredns.io -} -~~~ - -Or just default to `.`: - -~~~ corefile -. { - chaos CoreDNS-001 info@coredns.io -} -~~~ - -And test with `dig`: - -~~~ txt -% dig @localhost CH TXT version.bind -... -;; ANSWER SECTION: -version.bind. 0 CH TXT "CoreDNS-001" -... -~~~ diff --git a/vendor/github.com/coredns/coredns/plugin/chaos/chaos.go b/vendor/github.com/coredns/coredns/plugin/chaos/chaos.go deleted file mode 100644 index 60b002bd..00000000 --- a/vendor/github.com/coredns/coredns/plugin/chaos/chaos.go +++ /dev/null @@ -1,62 +0,0 @@ -// Package chaos implements a plugin that answer to 'CH version.bind TXT' type queries. -package chaos - -import ( - "context" - "os" - - "github.com/coredns/coredns/plugin" - "github.com/coredns/coredns/request" - - "github.com/miekg/dns" -) - -// Chaos allows CoreDNS to reply to CH TXT queries and return author or -// version information. -type Chaos struct { - Next plugin.Handler - Version string - Authors map[string]bool -} - -// ServeDNS implements the plugin.Handler interface. -func (c Chaos) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (int, error) { - state := request.Request{W: w, Req: r} - if state.QClass() != dns.ClassCHAOS || state.QType() != dns.TypeTXT { - return plugin.NextOrFailure(c.Name(), c.Next, ctx, w, r) - } - - m := new(dns.Msg) - m.SetReply(r) - - hdr := dns.RR_Header{Name: state.QName(), Rrtype: dns.TypeTXT, Class: dns.ClassCHAOS, Ttl: 0} - switch state.Name() { - default: - return c.Next.ServeDNS(ctx, w, r) - case "authors.bind.": - for a := range c.Authors { - m.Answer = append(m.Answer, &dns.TXT{Hdr: hdr, Txt: []string{trim(a)}}) - } - case "version.bind.", "version.server.": - m.Answer = []dns.RR{&dns.TXT{Hdr: hdr, Txt: []string{trim(c.Version)}}} - case "hostname.bind.", "id.server.": - hostname, err := os.Hostname() - if err != nil { - hostname = "localhost" - } - m.Answer = []dns.RR{&dns.TXT{Hdr: hdr, Txt: []string{trim(hostname)}}} - } - state.SizeAndDo(m) - w.WriteMsg(m) - return 0, nil -} - -// Name implements the Handler interface. -func (c Chaos) Name() string { return "chaos" } - -func trim(s string) string { - if len(s) < 256 { - return s - } - return s[:255] -} diff --git a/vendor/github.com/coredns/coredns/plugin/chaos/chaos_test.go b/vendor/github.com/coredns/coredns/plugin/chaos/chaos_test.go deleted file mode 100644 index bb58c07b..00000000 --- a/vendor/github.com/coredns/coredns/plugin/chaos/chaos_test.go +++ /dev/null @@ -1,80 +0,0 @@ -package chaos - -import ( - "context" - "testing" - - "github.com/coredns/coredns/plugin" - "github.com/coredns/coredns/plugin/pkg/dnstest" - "github.com/coredns/coredns/plugin/test" - - "github.com/miekg/dns" -) - -func TestChaos(t *testing.T) { - em := Chaos{ - Version: version, - Authors: map[string]bool{"Miek Gieben": true}, - } - - tests := []struct { - next plugin.Handler - qname string - qtype uint16 - expectedCode int - expectedReply string - expectedErr error - }{ - { - next: test.NextHandler(dns.RcodeSuccess, nil), - qname: "version.bind", - expectedCode: dns.RcodeSuccess, - expectedReply: version, - expectedErr: nil, - }, - { - next: test.NextHandler(dns.RcodeSuccess, nil), - qname: "authors.bind", - expectedCode: dns.RcodeSuccess, - expectedReply: "Miek Gieben", - expectedErr: nil, - }, - { - next: test.NextHandler(dns.RcodeSuccess, nil), - qname: "authors.bind", - qtype: dns.TypeSRV, - expectedCode: dns.RcodeSuccess, - expectedErr: nil, - }, - } - - ctx := context.TODO() - - for i, tc := range tests { - req := new(dns.Msg) - if tc.qtype == 0 { - tc.qtype = dns.TypeTXT - } - req.SetQuestion(dns.Fqdn(tc.qname), tc.qtype) - req.Question[0].Qclass = dns.ClassCHAOS - em.Next = tc.next - - rec := dnstest.NewRecorder(&test.ResponseWriter{}) - code, err := em.ServeDNS(ctx, rec, req) - - if err != tc.expectedErr { - t.Errorf("Test %d: Expected error %v, but got %v", i, tc.expectedErr, err) - } - if code != int(tc.expectedCode) { - t.Errorf("Test %d: Expected status code %d, but got %d", i, tc.expectedCode, code) - } - if tc.expectedReply != "" { - answer := rec.Msg.Answer[0].(*dns.TXT).Txt[0] - if answer != tc.expectedReply { - t.Errorf("Test %d: Expected answer %s, but got %s", i, tc.expectedReply, answer) - } - } - } -} - -const version = "CoreDNS-001" diff --git a/vendor/github.com/coredns/coredns/plugin/chaos/setup.go b/vendor/github.com/coredns/coredns/plugin/chaos/setup.go deleted file mode 100644 index 2064f4ea..00000000 --- a/vendor/github.com/coredns/coredns/plugin/chaos/setup.go +++ /dev/null @@ -1,55 +0,0 @@ -package chaos - -import ( - "github.com/coredns/coredns/core/dnsserver" - "github.com/coredns/coredns/plugin" - - "github.com/mholt/caddy" -) - -func init() { - caddy.RegisterPlugin("chaos", caddy.Plugin{ - ServerType: "dns", - Action: setup, - }) - -} - -func setup(c *caddy.Controller) error { - version, authors, err := chaosParse(c) - if err != nil { - return plugin.Error("chaos", err) - } - - dnsserver.GetConfig(c).AddPlugin(func(next plugin.Handler) plugin.Handler { - return Chaos{Next: next, Version: version, Authors: authors} - }) - - return nil -} - -func chaosParse(c *caddy.Controller) (string, map[string]bool, error) { - // Set here so we pick up AppName and AppVersion that get set in coremain's init(). - chaosVersion = caddy.AppName + "-" + caddy.AppVersion - - version := "" - authors := make(map[string]bool) - - for c.Next() { - args := c.RemainingArgs() - if len(args) == 0 { - return chaosVersion, nil, nil - } - if len(args) == 1 { - return args[0], nil, nil - } - version = args[0] - for _, a := range args[1:] { - authors[a] = true - } - return version, authors, nil - } - return version, authors, nil -} - -var chaosVersion string diff --git a/vendor/github.com/coredns/coredns/plugin/chaos/setup_test.go b/vendor/github.com/coredns/coredns/plugin/chaos/setup_test.go deleted file mode 100644 index 6f3c13fb..00000000 --- a/vendor/github.com/coredns/coredns/plugin/chaos/setup_test.go +++ /dev/null @@ -1,54 +0,0 @@ -package chaos - -import ( - "strings" - "testing" - - "github.com/mholt/caddy" -) - -func TestSetupChaos(t *testing.T) { - tests := []struct { - input string - shouldErr bool - expectedVersion string // expected version. - expectedAuthor string // expected author (string, although we get a map). - expectedErrContent string // substring from the expected error. Empty for positive cases. - }{ - // positive - { - `chaos v2`, false, "v2", "", "", - }, - { - `chaos v3 "Miek Gieben"`, false, "v3", "Miek Gieben", "", - }, - } - - for i, test := range tests { - c := caddy.NewTestController("dns", test.input) - version, authors, err := chaosParse(c) - - if test.shouldErr && err == nil { - t.Errorf("Test %d: Expected error but found %s for input %s", i, err, test.input) - } - - if err != nil { - if !test.shouldErr { - t.Errorf("Test %d: Expected no error but found one for input %s. Error was: %v", i, test.input, err) - } - - if !strings.Contains(err.Error(), test.expectedErrContent) { - t.Errorf("Test %d: Expected error to contain: %v, found error: %v, input: %s", i, test.expectedErrContent, err, test.input) - } - } - - if !test.shouldErr && version != test.expectedVersion { - t.Errorf("Chaos not correctly set for input %s. Expected: %s, actual: %s", test.input, test.expectedVersion, version) - } - if !test.shouldErr && authors != nil { - if _, ok := authors[test.expectedAuthor]; !ok { - t.Errorf("Chaos not correctly set for input %s. Expected: '%s', actual: '%s'", test.input, test.expectedAuthor, "Miek Gieben") - } - } - } -} diff --git a/vendor/github.com/coredns/coredns/plugin/deprecated/setup.go b/vendor/github.com/coredns/coredns/plugin/deprecated/setup.go deleted file mode 100644 index 566e266e..00000000 --- a/vendor/github.com/coredns/coredns/plugin/deprecated/setup.go +++ /dev/null @@ -1,38 +0,0 @@ -// Package deprecated is used when we deprecated plugin. In plugin.cfg just go from -// -// startup:github.com/mholt/caddy/startupshutdown -// -// To: -// -// startup:deprecated -// -// And things should work as expected. This means starting CoreDNS will fail with an error. We can only -// point to the release notes to details what next steps a user should take. I.e. there is no way to add this -// to the error generated. -package deprecated - -import ( - "errors" - - "github.com/coredns/coredns/plugin" - - "github.com/mholt/caddy" -) - -// removed has the names of the plugins that need to error on startup. -var removed = []string{"reverse"} - -func setup(c *caddy.Controller) error { - c.Next() - x := c.Val() - return plugin.Error(x, errors.New("this plugin has been deprecated")) -} - -func init() { - for _, plugin := range removed { - caddy.RegisterPlugin(plugin, caddy.Plugin{ - ServerType: "dns", - Action: setup, - }) - } -} diff --git a/vendor/github.com/coredns/coredns/plugin/dnssec/OWNERS b/vendor/github.com/coredns/coredns/plugin/dnssec/OWNERS deleted file mode 100644 index 1bdb8e3d..00000000 --- a/vendor/github.com/coredns/coredns/plugin/dnssec/OWNERS +++ /dev/null @@ -1,6 +0,0 @@ -reviewers: - - isolus - - miekg -approvers: - - isolus - - miekg diff --git a/vendor/github.com/coredns/coredns/plugin/dnssec/README.md b/vendor/github.com/coredns/coredns/plugin/dnssec/README.md deleted file mode 100644 index 7b315b35..00000000 --- a/vendor/github.com/coredns/coredns/plugin/dnssec/README.md +++ /dev/null @@ -1,79 +0,0 @@ -# dnssec - -## Name - -*dnssec* - enable on-the-fly DNSSEC signing of served data. - -## Description - -With *dnssec* any reply that doesn't (or can't) do DNSSEC will get signed on the fly. Authenticated -denial of existence is implemented with NSEC black lies. Using ECDSA as an algorithm is preferred as -this leads to smaller signatures (compared to RSA). NSEC3 is *not* supported. - -This plugin can only be used once per Server Block. - -## Syntax - -~~~ -dnssec [ZONES... ] { - key file KEY... - cache_capacity CAPACITY -} -~~~ - -The specified key is used for all signing operations. The DNSSEC signing will treat this key as a -CSK (common signing key), forgoing the ZSK/KSK split. All signing operations are done online. -Authenticated denial of existence is implemented with NSEC black lies. Using ECDSA as an algorithm -is preferred as this leads to smaller signatures (compared to RSA). NSEC3 is *not* supported. - -If multiple *dnssec* plugins are specified in the same zone, the last one specified will be -used (See [bugs](#bugs)). - -* **ZONES** zones that should be signed. If empty, the zones from the configuration block - are used. - -* `key file` indicates that **KEY** file(s) should be read from disk. When multiple keys are specified, RRsets - will be signed with all keys. Generating a key can be done with `dnssec-keygen`: `dnssec-keygen -a - ECDSAP256SHA256 `. A key created for zone *A* can be safely used for zone *B*. The name of the - key file can be specified in one of the following formats - - * basename of the generated key `Kexample.org+013+45330` - * generated public key `Kexample.org+013+45330.key` - * generated private key `Kexample.org+013+45330.private` - -* `cache_capacity` indicates the capacity of the cache. The dnssec plugin uses a cache to store - RRSIGs. The default for **CAPACITY** is 10000. - -## Metrics - -If monitoring is enabled (via the *prometheus* directive) then the following metrics are exported: - -* `coredns_dnssec_cache_size{server, type}` - total elements in the cache, type is "signature". -* `coredns_dnssec_cache_hits_total{server}` - Counter of cache hits. -* `coredns_dnssec_cache_misses_total{server}` - Counter of cache misses. - -The label `server` indicated the server handling the request, see the *metrics* plugin for details. - -## Examples - -Sign responses for `example.org` with the key "Kexample.org.+013+45330.key". - -~~~ corefile -example.org { - dnssec { - key file Kexample.org.+013+45330 - } - whoami -} -~~~ - -Sign responses for a kubernetes zone with the key "Kcluster.local+013+45129.key". - -~~~ -cluster.local { - kubernetes - dnssec { - key file Kcluster.local+013+45129 - } -} -~~~ diff --git a/vendor/github.com/coredns/coredns/plugin/dnssec/black_lies.go b/vendor/github.com/coredns/coredns/plugin/dnssec/black_lies.go deleted file mode 100644 index bc339b84..00000000 --- a/vendor/github.com/coredns/coredns/plugin/dnssec/black_lies.go +++ /dev/null @@ -1,64 +0,0 @@ -package dnssec - -import ( - "github.com/coredns/coredns/plugin/pkg/response" - "github.com/coredns/coredns/request" - - "github.com/miekg/dns" -) - -// nsec returns an NSEC useful for NXDOMAIN respsones. -// See https://tools.ietf.org/html/draft-valsorda-dnsop-black-lies-00 -// For example, a request for the non-existing name a.example.com would -// cause the following NSEC record to be generated: -// a.example.com. 3600 IN NSEC \000.a.example.com. ( RRSIG NSEC ... ) -// This inturn makes every NXDOMAIN answer a NODATA one, don't forget to flip -// the header rcode to NOERROR. -func (d Dnssec) nsec(state request.Request, mt response.Type, ttl, incep, expir uint32, server string) ([]dns.RR, error) { - nsec := &dns.NSEC{} - nsec.Hdr = dns.RR_Header{Name: state.QName(), Ttl: ttl, Class: dns.ClassINET, Rrtype: dns.TypeNSEC} - nsec.NextDomain = "\\000." + state.QName() - if state.Name() == state.Zone { - nsec.TypeBitMap = filter18(state.QType(), apexBitmap, mt) - } else { - nsec.TypeBitMap = filter14(state.QType(), zoneBitmap, mt) - } - - sigs, err := d.sign([]dns.RR{nsec}, state.Zone, ttl, incep, expir, server) - if err != nil { - return nil, err - } - - return append(sigs, nsec), nil -} - -// The NSEC bit maps we return. -var ( - zoneBitmap = [...]uint16{dns.TypeA, dns.TypeHINFO, dns.TypeTXT, dns.TypeAAAA, dns.TypeLOC, dns.TypeSRV, dns.TypeCERT, dns.TypeSSHFP, dns.TypeRRSIG, dns.TypeNSEC, dns.TypeTLSA, dns.TypeHIP, dns.TypeOPENPGPKEY, dns.TypeSPF} - apexBitmap = [...]uint16{dns.TypeA, dns.TypeNS, dns.TypeSOA, dns.TypeHINFO, dns.TypeMX, dns.TypeTXT, dns.TypeAAAA, dns.TypeLOC, dns.TypeSRV, dns.TypeCERT, dns.TypeSSHFP, dns.TypeRRSIG, dns.TypeNSEC, dns.TypeDNSKEY, dns.TypeTLSA, dns.TypeHIP, dns.TypeOPENPGPKEY, dns.TypeSPF} -) - -// filter14 filters out t from bitmap (if it exists). If mt is not an NODATA response, just return the entire bitmap. -func filter14(t uint16, bitmap [14]uint16, mt response.Type) []uint16 { - if mt != response.NoData && mt != response.NameError { - return zoneBitmap[:] - } - for i := range bitmap { - if bitmap[i] == t { - return append(bitmap[:i], bitmap[i+1:]...) - } - } - return zoneBitmap[:] // make a slice -} - -func filter18(t uint16, bitmap [18]uint16, mt response.Type) []uint16 { - if mt != response.NoData && mt != response.NameError { - return apexBitmap[:] - } - for i := range bitmap { - if bitmap[i] == t { - return append(bitmap[:i], bitmap[i+1:]...) - } - } - return apexBitmap[:] // make a slice -} diff --git a/vendor/github.com/coredns/coredns/plugin/dnssec/black_lies_bitmap_test.go b/vendor/github.com/coredns/coredns/plugin/dnssec/black_lies_bitmap_test.go deleted file mode 100644 index a4a487fc..00000000 --- a/vendor/github.com/coredns/coredns/plugin/dnssec/black_lies_bitmap_test.go +++ /dev/null @@ -1,64 +0,0 @@ -package dnssec - -import ( - "testing" - "time" - - "github.com/coredns/coredns/plugin/test" - "github.com/coredns/coredns/request" - - "github.com/miekg/dns" -) - -const server = "dns//." - -func TestBlackLiesBitmapNoData(t *testing.T) { - d, rm1, rm2 := newDnssec(t, []string{"example.org."}) - defer rm1() - defer rm2() - - m := testTLSAMsg() - state := request.Request{Req: m, Zone: "example.org."} - m = d.Sign(state, time.Now().UTC(), server) - - var nsec *dns.NSEC - for _, r := range m.Ns { - if r.Header().Rrtype == dns.TypeNSEC { - nsec = r.(*dns.NSEC) - } - } - for _, b := range nsec.TypeBitMap { - if uint16(b) == dns.TypeTLSA { - t.Errorf("Type TLSA should not be present in the type bitmap: %v", nsec.TypeBitMap) - } - } -} -func TestBlackLiesBitmapNameError(t *testing.T) { - d, rm1, rm2 := newDnssec(t, []string{"example.org."}) - defer rm1() - defer rm2() - - m := testTLSAMsg() - m.Rcode = dns.RcodeNameError // change to name error - state := request.Request{Req: m, Zone: "example.org."} - m = d.Sign(state, time.Now().UTC(), server) - - var nsec *dns.NSEC - for _, r := range m.Ns { - if r.Header().Rrtype == dns.TypeNSEC { - nsec = r.(*dns.NSEC) - } - } - for _, b := range nsec.TypeBitMap { - if uint16(b) == dns.TypeTLSA { - t.Errorf("Type TLSA should not be present in the type bitmap: %v", nsec.TypeBitMap) - } - } -} - -func testTLSAMsg() *dns.Msg { - return &dns.Msg{MsgHdr: dns.MsgHdr{Rcode: dns.RcodeSuccess}, - Question: []dns.Question{{Name: "25._tcp.example.org.", Qclass: dns.ClassINET, Qtype: dns.TypeTLSA}}, - Ns: []dns.RR{test.SOA("example.org. 1800 IN SOA linode.example.org. miek.example.org. 1461471181 14400 3600 604800 14400")}, - } -} diff --git a/vendor/github.com/coredns/coredns/plugin/dnssec/black_lies_test.go b/vendor/github.com/coredns/coredns/plugin/dnssec/black_lies_test.go deleted file mode 100644 index a9a29029..00000000 --- a/vendor/github.com/coredns/coredns/plugin/dnssec/black_lies_test.go +++ /dev/null @@ -1,86 +0,0 @@ -package dnssec - -import ( - "testing" - "time" - - "github.com/coredns/coredns/plugin/test" - "github.com/coredns/coredns/request" - - "github.com/miekg/dns" -) - -func TestZoneSigningBlackLies(t *testing.T) { - d, rm1, rm2 := newDnssec(t, []string{"miek.nl."}) - defer rm1() - defer rm2() - - m := testNxdomainMsg() - state := request.Request{Req: m, Zone: "miek.nl."} - m = d.Sign(state, time.Now().UTC(), server) - if !section(m.Ns, 2) { - t.Errorf("Authority section should have 2 sigs") - } - var nsec *dns.NSEC - for _, r := range m.Ns { - if r.Header().Rrtype == dns.TypeNSEC { - nsec = r.(*dns.NSEC) - } - } - if m.Rcode != dns.RcodeSuccess { - t.Errorf("Expected rcode %d, got %d", dns.RcodeSuccess, m.Rcode) - } - if nsec == nil { - t.Fatalf("Expected NSEC, got none") - } - if nsec.Hdr.Name != "ww.miek.nl." { - t.Errorf("Expected %s, got %s", "ww.miek.nl.", nsec.Hdr.Name) - } - if nsec.NextDomain != "\\000.ww.miek.nl." { - t.Errorf("Expected %s, got %s", "\\000.ww.miek.nl.", nsec.NextDomain) - } -} - -func TestBlackLiesNoError(t *testing.T) { - d, rm1, rm2 := newDnssec(t, []string{"miek.nl."}) - defer rm1() - defer rm2() - - m := testSuccessMsg() - state := request.Request{Req: m, Zone: "miek.nl."} - m = d.Sign(state, time.Now().UTC(), server) - - if m.Rcode != dns.RcodeSuccess { - t.Errorf("Expected rcode %d, got %d", dns.RcodeSuccess, m.Rcode) - } - - if len(m.Answer) != 2 { - t.Errorf("Answer section should have 2 RRs") - } - sig, txt := false, false - for _, rr := range m.Answer { - if _, ok := rr.(*dns.RRSIG); ok { - sig = true - } - if _, ok := rr.(*dns.TXT); ok { - txt = true - } - } - if !sig || !txt { - t.Errorf("Expected RRSIG and TXT in answer section") - } -} - -func testNxdomainMsg() *dns.Msg { - return &dns.Msg{MsgHdr: dns.MsgHdr{Rcode: dns.RcodeNameError}, - Question: []dns.Question{{Name: "ww.miek.nl.", Qclass: dns.ClassINET, Qtype: dns.TypeTXT}}, - Ns: []dns.RR{test.SOA("miek.nl. 1800 IN SOA linode.atoom.net. miek.miek.nl. 1461471181 14400 3600 604800 14400")}, - } -} - -func testSuccessMsg() *dns.Msg { - return &dns.Msg{MsgHdr: dns.MsgHdr{Rcode: dns.RcodeSuccess}, - Question: []dns.Question{{Name: "www.miek.nl.", Qclass: dns.ClassINET, Qtype: dns.TypeTXT}}, - Answer: []dns.RR{test.TXT(`www.miek.nl. 1800 IN TXT "response"`)}, - } -} diff --git a/vendor/github.com/coredns/coredns/plugin/dnssec/cache.go b/vendor/github.com/coredns/coredns/plugin/dnssec/cache.go deleted file mode 100644 index ea95b73b..00000000 --- a/vendor/github.com/coredns/coredns/plugin/dnssec/cache.go +++ /dev/null @@ -1,22 +0,0 @@ -package dnssec - -import ( - "hash/fnv" - - "github.com/miekg/dns" -) - -// hash serializes the RRset and return a signature cache key. -func hash(rrs []dns.RR) uint32 { - h := fnv.New32() - buf := make([]byte, 256) - for _, r := range rrs { - off, err := dns.PackRR(r, buf, 0, nil, false) - if err == nil { - h.Write(buf[:off]) - } - } - - i := h.Sum32() - return i -} diff --git a/vendor/github.com/coredns/coredns/plugin/dnssec/cache_test.go b/vendor/github.com/coredns/coredns/plugin/dnssec/cache_test.go deleted file mode 100644 index 3df862a3..00000000 --- a/vendor/github.com/coredns/coredns/plugin/dnssec/cache_test.go +++ /dev/null @@ -1,82 +0,0 @@ -package dnssec - -import ( - "testing" - "time" - - "github.com/coredns/coredns/plugin/pkg/cache" - "github.com/coredns/coredns/plugin/test" - "github.com/coredns/coredns/request" -) - -func TestCacheSet(t *testing.T) { - fPriv, rmPriv, _ := test.TempFile(".", privKey) - fPub, rmPub, _ := test.TempFile(".", pubKey) - defer rmPriv() - defer rmPub() - - dnskey, err := ParseKeyFile(fPub, fPriv) - if err != nil { - t.Fatalf("Failed to parse key: %v\n", err) - } - - c := cache.New(defaultCap) - m := testMsg() - state := request.Request{Req: m, Zone: "miek.nl."} - k := hash(m.Answer) // calculate *before* we add the sig - d := New([]string{"miek.nl."}, []*DNSKEY{dnskey}, nil, c) - d.Sign(state, time.Now().UTC(), server) - - _, ok := d.get(k, server) - if !ok { - t.Errorf("Signature was not added to the cache") - } -} - -func TestCacheNotValidExpired(t *testing.T) { - fPriv, rmPriv, _ := test.TempFile(".", privKey) - fPub, rmPub, _ := test.TempFile(".", pubKey) - defer rmPriv() - defer rmPub() - - dnskey, err := ParseKeyFile(fPub, fPriv) - if err != nil { - t.Fatalf("Failed to parse key: %v\n", err) - } - - c := cache.New(defaultCap) - m := testMsg() - state := request.Request{Req: m, Zone: "miek.nl."} - k := hash(m.Answer) // calculate *before* we add the sig - d := New([]string{"miek.nl."}, []*DNSKEY{dnskey}, nil, c) - d.Sign(state, time.Now().UTC().AddDate(0, 0, -9), server) - - _, ok := d.get(k, server) - if ok { - t.Errorf("Signature was added to the cache even though not valid") - } -} - -func TestCacheNotValidYet(t *testing.T) { - fPriv, rmPriv, _ := test.TempFile(".", privKey) - fPub, rmPub, _ := test.TempFile(".", pubKey) - defer rmPriv() - defer rmPub() - - dnskey, err := ParseKeyFile(fPub, fPriv) - if err != nil { - t.Fatalf("Failed to parse key: %v\n", err) - } - - c := cache.New(defaultCap) - m := testMsg() - state := request.Request{Req: m, Zone: "miek.nl."} - k := hash(m.Answer) // calculate *before* we add the sig - d := New([]string{"miek.nl."}, []*DNSKEY{dnskey}, nil, c) - d.Sign(state, time.Now().UTC().AddDate(0, 0, +9), server) - - _, ok := d.get(k, server) - if ok { - t.Errorf("Signature was added to the cache even though not valid yet") - } -} diff --git a/vendor/github.com/coredns/coredns/plugin/dnssec/dnskey.go b/vendor/github.com/coredns/coredns/plugin/dnssec/dnskey.go deleted file mode 100644 index ed99fe6c..00000000 --- a/vendor/github.com/coredns/coredns/plugin/dnssec/dnskey.go +++ /dev/null @@ -1,78 +0,0 @@ -package dnssec - -import ( - "crypto" - "crypto/ecdsa" - "crypto/rsa" - "errors" - "os" - "time" - - "github.com/coredns/coredns/request" - - "github.com/miekg/dns" -) - -// DNSKEY holds a DNSSEC public and private key used for on-the-fly signing. -type DNSKEY struct { - K *dns.DNSKEY - D *dns.DS - s crypto.Signer - tag uint16 -} - -// ParseKeyFile read a DNSSEC keyfile as generated by dnssec-keygen or other -// utilities. It adds ".key" for the public key and ".private" for the private key. -func ParseKeyFile(pubFile, privFile string) (*DNSKEY, error) { - f, e := os.Open(pubFile) - if e != nil { - return nil, e - } - k, e := dns.ReadRR(f, pubFile) - if e != nil { - return nil, e - } - - f, e = os.Open(privFile) - if e != nil { - return nil, e - } - - dk, ok := k.(*dns.DNSKEY) - if !ok { - return nil, errors.New("no public key found") - } - p, e := dk.ReadPrivateKey(f, privFile) - if e != nil { - return nil, e - } - - if s, ok := p.(*rsa.PrivateKey); ok { - return &DNSKEY{K: dk, D: dk.ToDS(dns.SHA256), s: s, tag: dk.KeyTag()}, nil - } - if s, ok := p.(*ecdsa.PrivateKey); ok { - return &DNSKEY{K: dk, D: dk.ToDS(dns.SHA256), s: s, tag: dk.KeyTag()}, nil - } - return &DNSKEY{K: dk, D: dk.ToDS(dns.SHA256), s: nil, tag: 0}, errors.New("no private key found") -} - -// getDNSKEY returns the correct DNSKEY to the client. Signatures are added when do is true. -func (d Dnssec) getDNSKEY(state request.Request, zone string, do bool, server string) *dns.Msg { - keys := make([]dns.RR, len(d.keys)) - for i, k := range d.keys { - keys[i] = dns.Copy(k.K) - keys[i].Header().Name = zone - } - m := new(dns.Msg) - m.SetReply(state.Req) - m.Answer = keys - if !do { - return m - } - - incep, expir := incepExpir(time.Now().UTC()) - if sigs, err := d.sign(keys, zone, 3600, incep, expir, server); err == nil { - m.Answer = append(m.Answer, sigs...) - } - return m -} diff --git a/vendor/github.com/coredns/coredns/plugin/dnssec/dnssec.go b/vendor/github.com/coredns/coredns/plugin/dnssec/dnssec.go deleted file mode 100644 index 3baea569..00000000 --- a/vendor/github.com/coredns/coredns/plugin/dnssec/dnssec.go +++ /dev/null @@ -1,160 +0,0 @@ -// Package dnssec implements a plugin that signs responses on-the-fly using -// NSEC black lies. -package dnssec - -import ( - "time" - - "github.com/coredns/coredns/plugin" - "github.com/coredns/coredns/plugin/pkg/cache" - "github.com/coredns/coredns/plugin/pkg/response" - "github.com/coredns/coredns/plugin/pkg/singleflight" - "github.com/coredns/coredns/request" - - "github.com/miekg/dns" -) - -// Dnssec signs the reply on-the-fly. -type Dnssec struct { - Next plugin.Handler - - zones []string - keys []*DNSKEY - inflight *singleflight.Group - cache *cache.Cache -} - -// New returns a new Dnssec. -func New(zones []string, keys []*DNSKEY, next plugin.Handler, c *cache.Cache) Dnssec { - return Dnssec{Next: next, - zones: zones, - keys: keys, - cache: c, - inflight: new(singleflight.Group), - } -} - -// Sign signs the message in state. it takes care of negative or nodata responses. It -// uses NSEC black lies for authenticated denial of existence. For delegations it -// will insert DS records and sign those. -// Signatures will be cached for a short while. By default we sign for 8 days, -// starting 3 hours ago. -func (d Dnssec) Sign(state request.Request, now time.Time, server string) *dns.Msg { - req := state.Req - - incep, expir := incepExpir(now) - - mt, _ := response.Typify(req, time.Now().UTC()) // TODO(miek): need opt record here? - if mt == response.Delegation { - // This reverts 11203e44. Reverting with git revert leads to conflicts in dnskey.go, and I'm - // not sure yet if we just should fiddle with inserting DSs or not. - // Easy way to, see #1211 for discussion. - /* - ttl := req.Ns[0].Header().Ttl - - ds := []dns.RR{} - for i := range d.keys { - ds = append(ds, d.keys[i].D) - } - if sigs, err := d.sign(ds, zone, ttl, incep, expir); err == nil { - req.Ns = append(req.Ns, ds...) - req.Ns = append(req.Ns, sigs...) - } - */ - return req - } - - if mt == response.NameError || mt == response.NoData { - if req.Ns[0].Header().Rrtype != dns.TypeSOA || len(req.Ns) > 1 { - return req - } - - ttl := req.Ns[0].Header().Ttl - - if sigs, err := d.sign(req.Ns, state.Zone, ttl, incep, expir, server); err == nil { - req.Ns = append(req.Ns, sigs...) - } - if sigs, err := d.nsec(state, mt, ttl, incep, expir, server); err == nil { - req.Ns = append(req.Ns, sigs...) - } - if len(req.Ns) > 1 { // actually added nsec and sigs, reset the rcode - req.Rcode = dns.RcodeSuccess - } - return req - } - - for _, r := range rrSets(req.Answer) { - ttl := r[0].Header().Ttl - if sigs, err := d.sign(r, state.Zone, ttl, incep, expir, server); err == nil { - req.Answer = append(req.Answer, sigs...) - } - } - for _, r := range rrSets(req.Ns) { - ttl := r[0].Header().Ttl - if sigs, err := d.sign(r, state.Zone, ttl, incep, expir, server); err == nil { - req.Ns = append(req.Ns, sigs...) - } - } - for _, r := range rrSets(req.Extra) { - ttl := r[0].Header().Ttl - if sigs, err := d.sign(r, state.Zone, ttl, incep, expir, server); err == nil { - req.Extra = append(sigs, req.Extra...) // prepend to leave OPT alone - } - } - return req -} - -func (d Dnssec) sign(rrs []dns.RR, signerName string, ttl, incep, expir uint32, server string) ([]dns.RR, error) { - k := hash(rrs) - sgs, ok := d.get(k, server) - if ok { - return sgs, nil - } - - sigs, err := d.inflight.Do(k, func() (interface{}, error) { - sigs := make([]dns.RR, len(d.keys)) - var e error - for i, k := range d.keys { - sig := k.newRRSIG(signerName, ttl, incep, expir) - e = sig.Sign(k.s, rrs) - sigs[i] = sig - } - d.set(k, sigs) - return sigs, e - }) - return sigs.([]dns.RR), err -} - -func (d Dnssec) set(key uint32, sigs []dns.RR) { - d.cache.Add(key, sigs) -} - -func (d Dnssec) get(key uint32, server string) ([]dns.RR, bool) { - if s, ok := d.cache.Get(key); ok { - // we sign for 8 days, check if a signature in the cache reached 3/4 of that - is75 := time.Now().UTC().Add(sixDays) - for _, rr := range s.([]dns.RR) { - if !rr.(*dns.RRSIG).ValidityPeriod(is75) { - cacheMisses.WithLabelValues(server).Inc() - return nil, false - } - } - - cacheHits.WithLabelValues(server).Inc() - return s.([]dns.RR), true - } - cacheMisses.WithLabelValues(server).Inc() - return nil, false -} - -func incepExpir(now time.Time) (uint32, uint32) { - incep := uint32(now.Add(-3 * time.Hour).Unix()) // -(2+1) hours, be sure to catch daylight saving time and such - expir := uint32(now.Add(eightDays).Unix()) // sign for 8 days - return incep, expir -} - -const ( - eightDays = 8 * 24 * time.Hour - sixDays = 6 * 24 * time.Hour - defaultCap = 10000 // default capacity of the cache. -) diff --git a/vendor/github.com/coredns/coredns/plugin/dnssec/dnssec_test.go b/vendor/github.com/coredns/coredns/plugin/dnssec/dnssec_test.go deleted file mode 100644 index ebd84c1d..00000000 --- a/vendor/github.com/coredns/coredns/plugin/dnssec/dnssec_test.go +++ /dev/null @@ -1,253 +0,0 @@ -package dnssec - -import ( - "testing" - "time" - - "github.com/coredns/coredns/plugin/pkg/cache" - "github.com/coredns/coredns/plugin/test" - "github.com/coredns/coredns/request" - - "github.com/miekg/dns" -) - -func TestZoneSigning(t *testing.T) { - d, rm1, rm2 := newDnssec(t, []string{"miek.nl."}) - defer rm1() - defer rm2() - - m := testMsg() - state := request.Request{Req: m, Zone: "miek.nl."} - - m = d.Sign(state, time.Now().UTC(), server) - if !section(m.Answer, 1) { - t.Errorf("Answer section should have 1 RRSIG") - } - if !section(m.Ns, 1) { - t.Errorf("Authority section should have 1 RRSIG") - } -} - -func TestZoneSigningDouble(t *testing.T) { - d, rm1, rm2 := newDnssec(t, []string{"miek.nl."}) - defer rm1() - defer rm2() - - fPriv1, rmPriv1, _ := test.TempFile(".", privKey1) - fPub1, rmPub1, _ := test.TempFile(".", pubKey1) - defer rmPriv1() - defer rmPub1() - - key1, err := ParseKeyFile(fPub1, fPriv1) - if err != nil { - t.Fatalf("Failed to parse key: %v\n", err) - } - d.keys = append(d.keys, key1) - - m := testMsg() - state := request.Request{Req: m, Zone: "miek.nl."} - m = d.Sign(state, time.Now().UTC(), server) - if !section(m.Answer, 2) { - t.Errorf("Answer section should have 1 RRSIG") - } - if !section(m.Ns, 2) { - t.Errorf("Authority section should have 1 RRSIG") - } -} - -// TestSigningDifferentZone tests if a key for miek.nl and be used for example.org. -func TestSigningDifferentZone(t *testing.T) { - fPriv, rmPriv, _ := test.TempFile(".", privKey) - fPub, rmPub, _ := test.TempFile(".", pubKey) - defer rmPriv() - defer rmPub() - - key, err := ParseKeyFile(fPub, fPriv) - if err != nil { - t.Fatalf("Failed to parse key: %v\n", err) - } - - m := testMsgEx() - state := request.Request{Req: m, Zone: "example.org."} - c := cache.New(defaultCap) - d := New([]string{"example.org."}, []*DNSKEY{key}, nil, c) - m = d.Sign(state, time.Now().UTC(), server) - if !section(m.Answer, 1) { - t.Errorf("Answer section should have 1 RRSIG") - t.Logf("%+v\n", m) - } - if !section(m.Ns, 1) { - t.Errorf("Authority section should have 1 RRSIG") - t.Logf("%+v\n", m) - } -} - -func TestSigningCname(t *testing.T) { - d, rm1, rm2 := newDnssec(t, []string{"miek.nl."}) - defer rm1() - defer rm2() - - m := testMsgCname() - state := request.Request{Req: m, Zone: "miek.nl."} - m = d.Sign(state, time.Now().UTC(), server) - if !section(m.Answer, 1) { - t.Errorf("Answer section should have 1 RRSIG") - } -} - -// Disabled for now, see #1211. -func testZoneSigningDelegation(t *testing.T) { - d, rm1, rm2 := newDnssec(t, []string{"miek.nl."}) - defer rm1() - defer rm2() - - m := testDelegationMsg() - state := request.Request{Req: m, Zone: "miek.nl."} - m = d.Sign(state, time.Now().UTC(), server) - if !section(m.Ns, 1) { - t.Errorf("Authority section should have 1 RRSIG") - t.Logf("%v\n", m) - } - - ds := 0 - for i := range m.Ns { - if _, ok := m.Ns[i].(*dns.DS); ok { - ds++ - } - } - if ds != 1 { - t.Errorf("Authority section should have 1 DS") - t.Logf("%v\n", m) - - } - if !section(m.Extra, 0) { - t.Errorf("Answer section should have 0 RRSIGs") - t.Logf("%v\n", m) - } -} - -func TestSigningDname(t *testing.T) { - d, rm1, rm2 := newDnssec(t, []string{"miek.nl."}) - defer rm1() - defer rm2() - - m := testMsgDname() - state := request.Request{Req: m, Zone: "miek.nl."} - // We sign *everything* we see, also the synthesized CNAME. - m = d.Sign(state, time.Now().UTC(), server) - if !section(m.Answer, 3) { - t.Errorf("Answer section should have 3 RRSIGs") - } -} - -func TestSigningEmpty(t *testing.T) { - d, rm1, rm2 := newDnssec(t, []string{"miek.nl."}) - defer rm1() - defer rm2() - - m := testEmptyMsg() - m.SetQuestion("a.miek.nl.", dns.TypeA) - state := request.Request{Req: m, Zone: "miek.nl."} - m = d.Sign(state, time.Now().UTC(), server) - if !section(m.Ns, 2) { - t.Errorf("Authority section should have 2 RRSIGs") - } -} - -func section(rss []dns.RR, nrSigs int) bool { - i := 0 - for _, r := range rss { - if r.Header().Rrtype == dns.TypeRRSIG { - i++ - } - } - return nrSigs == i -} - -func testMsg() *dns.Msg { - // don't care about the message header - return &dns.Msg{ - Answer: []dns.RR{test.MX("miek.nl. 1703 IN MX 1 aspmx.l.google.com.")}, - Ns: []dns.RR{test.NS("miek.nl. 1703 IN NS omval.tednet.nl.")}, - } -} -func testMsgEx() *dns.Msg { - return &dns.Msg{ - Answer: []dns.RR{test.MX("example.org. 1703 IN MX 1 aspmx.l.google.com.")}, - Ns: []dns.RR{test.NS("example.org. 1703 IN NS omval.tednet.nl.")}, - } -} - -func testMsgCname() *dns.Msg { - return &dns.Msg{ - Answer: []dns.RR{test.CNAME("www.miek.nl. 1800 IN CNAME a.miek.nl.")}, - } -} - -func testDelegationMsg() *dns.Msg { - return &dns.Msg{ - Ns: []dns.RR{ - test.NS("miek.nl. 3600 IN NS linode.atoom.net."), - test.NS("miek.nl. 3600 IN NS ns-ext.nlnetlabs.nl."), - test.NS("miek.nl. 3600 IN NS omval.tednet.nl."), - }, - Extra: []dns.RR{ - test.A("omval.tednet.nl. 3600 IN A 185.49.141.42"), - test.AAAA("omval.tednet.nl. 3600 IN AAAA 2a04:b900:0:100::42"), - }, - } -} - -func testMsgDname() *dns.Msg { - return &dns.Msg{ - Answer: []dns.RR{ - test.CNAME("a.dname.miek.nl. 1800 IN CNAME a.test.miek.nl."), - test.A("a.test.miek.nl. 1800 IN A 139.162.196.78"), - test.DNAME("dname.miek.nl. 1800 IN DNAME test.miek.nl."), - }, - } -} - -func testEmptyMsg() *dns.Msg { - // don't care about the message header - return &dns.Msg{ - Ns: []dns.RR{test.SOA("miek.nl. 1800 IN SOA ns.miek.nl. dnsmaster.miek.nl. 2017100301 200 100 604800 3600")}, - } -} - -func newDnssec(t *testing.T, zones []string) (Dnssec, func(), func()) { - k, rm1, rm2 := newKey(t) - c := cache.New(defaultCap) - d := New(zones, []*DNSKEY{k}, nil, c) - return d, rm1, rm2 -} - -func newKey(t *testing.T) (*DNSKEY, func(), func()) { - fPriv, rmPriv, _ := test.TempFile(".", privKey) - fPub, rmPub, _ := test.TempFile(".", pubKey) - - key, err := ParseKeyFile(fPub, fPriv) - if err != nil { - t.Fatalf("Failed to parse key: %v\n", err) - } - return key, rmPriv, rmPub -} - -const ( - pubKey = `miek.nl. IN DNSKEY 257 3 13 0J8u0XJ9GNGFEBXuAmLu04taHG4BXPP3gwhetiOUMnGA+x09nqzgF5IY OyjWB7N3rXqQbnOSILhH1hnuyh7mmA==` - privKey = `Private-key-format: v1.3 -Algorithm: 13 (ECDSAP256SHA256) -PrivateKey: /4BZk8AFvyW5hL3cOLSVxIp1RTqHSAEloWUxj86p3gs= -Created: 20160423195532 -Publish: 20160423195532 -Activate: 20160423195532 -` - pubKey1 = `example.org. IN DNSKEY 257 3 13 tVRWNSGpHZbCi7Pr7OmbADVUO3MxJ0Lb8Lk3o/HBHqCxf5K/J50lFqRa 98lkdAIiFOVRy8LyMvjwmxZKwB5MNw==` - privKey1 = `Private-key-format: v1.3 -Algorithm: 13 (ECDSAP256SHA256) -PrivateKey: i8j4OfDGT8CQt24SDwLz2hg9yx4qKOEOh1LvbAuSp1c= -Created: 20160423211746 -Publish: 20160423211746 -Activate: 20160423211746 -` -) diff --git a/vendor/github.com/coredns/coredns/plugin/dnssec/handler.go b/vendor/github.com/coredns/coredns/plugin/dnssec/handler.go deleted file mode 100644 index 159c1953..00000000 --- a/vendor/github.com/coredns/coredns/plugin/dnssec/handler.go +++ /dev/null @@ -1,81 +0,0 @@ -package dnssec - -import ( - "context" - "sync" - - "github.com/coredns/coredns/plugin" - "github.com/coredns/coredns/plugin/metrics" - "github.com/coredns/coredns/request" - - "github.com/miekg/dns" - "github.com/prometheus/client_golang/prometheus" -) - -// ServeDNS implements the plugin.Handler interface. -func (d Dnssec) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (int, error) { - state := request.Request{W: w, Req: r} - - do := state.Do() - qname := state.Name() - qtype := state.QType() - zone := plugin.Zones(d.zones).Matches(qname) - if zone == "" { - return plugin.NextOrFailure(d.Name(), d.Next, ctx, w, r) - } - - state.Zone = zone - server := metrics.WithServer(ctx) - - // Intercept queries for DNSKEY, but only if one of the zones matches the qname, otherwise we let - // the query through. - if qtype == dns.TypeDNSKEY { - for _, z := range d.zones { - if qname == z { - resp := d.getDNSKEY(state, z, do, server) - resp.Authoritative = true - state.SizeAndDo(resp) - w.WriteMsg(resp) - return dns.RcodeSuccess, nil - } - } - } - - drr := &ResponseWriter{w, d, server} - return plugin.NextOrFailure(d.Name(), d.Next, ctx, drr, r) -} - -var ( - cacheSize = prometheus.NewGaugeVec(prometheus.GaugeOpts{ - Namespace: plugin.Namespace, - Subsystem: "dnssec", - Name: "cache_size", - Help: "The number of elements in the dnssec cache.", - }, []string{"server", "type"}) - - cacheCapacity = prometheus.NewGaugeVec(prometheus.GaugeOpts{ - Namespace: plugin.Namespace, - Subsystem: "dnssec", - Name: "cache_capacity", - Help: "The dnssec cache's capacity.", - }, []string{"server", "type"}) - - cacheHits = prometheus.NewCounterVec(prometheus.CounterOpts{ - Namespace: plugin.Namespace, - Subsystem: "dnssec", - Name: "cache_hits_total", - Help: "The count of cache hits.", - }, []string{"server"}) - - cacheMisses = prometheus.NewCounterVec(prometheus.CounterOpts{ - Namespace: plugin.Namespace, - Subsystem: "dnssec", - Name: "cache_misses_total", - Help: "The count of cache misses.", - }, []string{"server"}) -) - -// Name implements the Handler interface. -func (d Dnssec) Name() string { return "dnssec" } - -var once sync.Once diff --git a/vendor/github.com/coredns/coredns/plugin/dnssec/handler_test.go b/vendor/github.com/coredns/coredns/plugin/dnssec/handler_test.go deleted file mode 100644 index a1c35c63..00000000 --- a/vendor/github.com/coredns/coredns/plugin/dnssec/handler_test.go +++ /dev/null @@ -1,186 +0,0 @@ -package dnssec - -import ( - "context" - "strings" - "testing" - - "github.com/coredns/coredns/plugin/file" - "github.com/coredns/coredns/plugin/pkg/cache" - "github.com/coredns/coredns/plugin/pkg/dnstest" - "github.com/coredns/coredns/plugin/test" - - "github.com/miekg/dns" -) - -var dnssecTestCases = []test.Case{ - { - Qname: "miek.nl.", Qtype: dns.TypeDNSKEY, - Answer: []dns.RR{ - test.DNSKEY("miek.nl. 3600 IN DNSKEY 257 3 13 0J8u0XJ9GNGFEBXuAmLu04taHG4"), - }, - }, - { - Qname: "miek.nl.", Qtype: dns.TypeDNSKEY, Do: true, - Answer: []dns.RR{ - test.DNSKEY("miek.nl. 3600 IN DNSKEY 257 3 13 0J8u0XJ9GNGFEBXuAmLu04taHG4"), - test.RRSIG("miek.nl. 3600 IN RRSIG DNSKEY 13 2 3600 20160503150844 20160425120844 18512 miek.nl. Iw/kNOyM"), - }, - Extra: []dns.RR{test.OPT(4096, true)}, - }, -} - -var dnsTestCases = []test.Case{ - { - Qname: "miek.nl.", Qtype: dns.TypeDNSKEY, - Answer: []dns.RR{ - test.DNSKEY("miek.nl. 3600 IN DNSKEY 257 3 13 0J8u0XJ9GNGFEBXuAmLu04taHG4"), - }, - }, - { - Qname: "miek.nl.", Qtype: dns.TypeMX, - Answer: []dns.RR{ - test.MX("miek.nl. 1800 IN MX 1 aspmx.l.google.com."), - }, - Ns: []dns.RR{ - test.NS("miek.nl. 1800 IN NS linode.atoom.net."), - }, - }, - { - Qname: "miek.nl.", Qtype: dns.TypeMX, Do: true, - Answer: []dns.RR{ - test.MX("miek.nl. 1800 IN MX 1 aspmx.l.google.com."), - test.RRSIG("miek.nl. 1800 IN RRSIG MX 13 2 3600 20160503192428 20160425162428 18512 miek.nl. 4nxuGKitXjPVA9zP1JIUvA09"), - }, - Ns: []dns.RR{ - test.NS("miek.nl. 1800 IN NS linode.atoom.net."), - test.RRSIG("miek.nl. 1800 IN RRSIG NS 13 2 3600 20161217114912 20161209084912 18512 miek.nl. ad9gA8VWgF1H8ze9/0Rk2Q=="), - }, - Extra: []dns.RR{test.OPT(4096, true)}, - }, - { - Qname: "www.miek.nl.", Qtype: dns.TypeAAAA, Do: true, - Answer: []dns.RR{ - test.AAAA("a.miek.nl. 1800 IN AAAA 2a01:7e00::f03c:91ff:fef1:6735"), - test.RRSIG("a.miek.nl. 1800 IN RRSIG AAAA 13 3 3600 20160503193047 20160425163047 18512 miek.nl. UAyMG+gcnoXW3"), - test.CNAME("www.miek.nl. 1800 IN CNAME a.miek.nl."), - test.RRSIG("www.miek.nl. 1800 IN RRSIG CNAME 13 3 3600 20160503193047 20160425163047 18512 miek.nl. E3qGZn"), - }, - Ns: []dns.RR{ - test.NS("miek.nl. 1800 IN NS linode.atoom.net."), - test.RRSIG("miek.nl. 1800 IN RRSIG NS 13 2 3600 20161217114912 20161209084912 18512 miek.nl. ad9gA8VWgF1H8ze9/0Rk2Q=="), - }, - Extra: []dns.RR{test.OPT(4096, true)}, - }, - { - Qname: "wwwww.miek.nl.", Qtype: dns.TypeAAAA, Do: true, - Ns: []dns.RR{ - test.RRSIG("miek.nl. 1800 IN RRSIG SOA 13 2 3600 20171220135446 20171212105446 18512 miek.nl. hCRzzjYz6w=="), - test.SOA("miek.nl. 1800 IN SOA linode.atoom.net. miek.miek.nl. 1282630057 14400 3600 604800 14400"), - test.NSEC("wwwww.miek.nl. 1800 IN NSEC \\000.wwwww.miek.nl. A HINFO TXT LOC SRV CERT SSHFP RRSIG NSEC TLSA HIP OPENPGPKEY SPF"), - test.RRSIG("wwwww.miek.nl. 1800 IN RRSIG NSEC 13 3 3600 20171220135446 20171212105446 18512 miek.nl. cVUQWs8xw=="), - }, - Extra: []dns.RR{test.OPT(4096, true)}, - }, - { - Qname: "miek.nl.", Qtype: dns.TypeHINFO, Do: true, - Ns: []dns.RR{ - test.NSEC("miek.nl. 1800 IN NSEC \\000.miek.nl. A NS SOA MX TXT AAAA LOC SRV CERT SSHFP RRSIG NSEC DNSKEY TLSA HIP OPENPGPKEY SPF"), - test.RRSIG("miek.nl. 1800 IN RRSIG NSEC 13 2 3600 20171220141741 20171212111741 18512 miek.nl. GuXROL7Uu+UiPcg=="), - test.RRSIG("miek.nl. 1800 IN RRSIG SOA 13 2 3600 20171220141741 20171212111741 18512 miek.nl. 8bLTReqmuQtw=="), - test.SOA("miek.nl. 1800 IN SOA linode.atoom.net. miek.miek.nl. 1282630057 14400 3600 604800 14400"), - }, - Extra: []dns.RR{test.OPT(4096, true)}, - }, - { - Qname: "www.example.org.", Qtype: dns.TypeAAAA, Do: true, - Rcode: dns.RcodeServerFailure, - // Extra: []dns.RR{test.OPT(4096, true)}, // test.ErrorHandler is a simple handler that does not do EDNS on ServerFailure - }, -} - -func TestLookupZone(t *testing.T) { - zone, err := file.Parse(strings.NewReader(dbMiekNL), "miek.nl.", "stdin", 0) - if err != nil { - return - } - fm := file.File{Next: test.ErrorHandler(), Zones: file.Zones{Z: map[string]*file.Zone{"miek.nl.": zone}, Names: []string{"miek.nl."}}} - dnskey, rm1, rm2 := newKey(t) - defer rm1() - defer rm2() - c := cache.New(defaultCap) - dh := New([]string{"miek.nl."}, []*DNSKEY{dnskey}, fm, c) - ctx := context.TODO() - - for _, tc := range dnsTestCases { - m := tc.Msg() - - rec := dnstest.NewRecorder(&test.ResponseWriter{}) - _, err := dh.ServeDNS(ctx, rec, m) - if err != nil { - t.Errorf("Expected no error, got %v\n", err) - return - } - - resp := rec.Msg - test.SortAndCheck(t, resp, tc) - } -} - -func TestLookupDNSKEY(t *testing.T) { - dnskey, rm1, rm2 := newKey(t) - defer rm1() - defer rm2() - c := cache.New(defaultCap) - dh := New([]string{"miek.nl."}, []*DNSKEY{dnskey}, test.ErrorHandler(), c) - ctx := context.TODO() - - for _, tc := range dnssecTestCases { - m := tc.Msg() - - rec := dnstest.NewRecorder(&test.ResponseWriter{}) - _, err := dh.ServeDNS(ctx, rec, m) - if err != nil { - t.Errorf("Expected no error, got %v\n", err) - return - } - - resp := rec.Msg - if !resp.Authoritative { - t.Errorf("Authoritative Answer should be true, got false") - } - - test.SortAndCheck(t, resp, tc) - - // If there is an NSEC present in authority section check if the bitmap does not have the qtype set. - for _, rr := range resp.Ns { - if n, ok := rr.(*dns.NSEC); ok { - for i := range n.TypeBitMap { - if n.TypeBitMap[i] == tc.Qtype { - t.Errorf("Bitmap contains qtype: %d", tc.Qtype) - } - } - } - } - } -} - -const dbMiekNL = ` -$TTL 30M -$ORIGIN miek.nl. -@ IN SOA linode.atoom.net. miek.miek.nl. ( - 1282630057 ; Serial - 4H ; Refresh - 1H ; Retry - 7D ; Expire - 4H ) ; Negative Cache TTL - IN NS linode.atoom.net. - - IN MX 1 aspmx.l.google.com. - - IN A 139.162.196.78 - IN AAAA 2a01:7e00::f03c:91ff:fef1:6735 - -a IN A 139.162.196.78 - IN AAAA 2a01:7e00::f03c:91ff:fef1:6735 -www IN CNAME a` diff --git a/vendor/github.com/coredns/coredns/plugin/dnssec/responsewriter.go b/vendor/github.com/coredns/coredns/plugin/dnssec/responsewriter.go deleted file mode 100644 index 0e4af8d1..00000000 --- a/vendor/github.com/coredns/coredns/plugin/dnssec/responsewriter.go +++ /dev/null @@ -1,49 +0,0 @@ -package dnssec - -import ( - "time" - - "github.com/coredns/coredns/plugin" - "github.com/coredns/coredns/request" - - "github.com/miekg/dns" -) - -// ResponseWriter sign the response on the fly. -type ResponseWriter struct { - dns.ResponseWriter - d Dnssec - server string // server label for metrics. -} - -// WriteMsg implements the dns.ResponseWriter interface. -func (d *ResponseWriter) WriteMsg(res *dns.Msg) error { - // By definition we should sign anything that comes back, we should still figure out for - // which zone it should be. - state := request.Request{W: d.ResponseWriter, Req: res} - - zone := plugin.Zones(d.d.zones).Matches(state.Name()) - if zone == "" { - return d.ResponseWriter.WriteMsg(res) - } - state.Zone = zone - - if state.Do() { - res = d.d.Sign(state, time.Now().UTC(), d.server) - - cacheSize.WithLabelValues(d.server, "signature").Set(float64(d.d.cache.Len())) - } - state.SizeAndDo(res) - - return d.ResponseWriter.WriteMsg(res) -} - -// Write implements the dns.ResponseWriter interface. -func (d *ResponseWriter) Write(buf []byte) (int, error) { - log.Warning("Dnssec called with Write: not signing reply") - n, err := d.ResponseWriter.Write(buf) - return n, err -} - -// Hijack implements the dns.ResponseWriter interface. -func (d *ResponseWriter) Hijack() { d.ResponseWriter.Hijack() } diff --git a/vendor/github.com/coredns/coredns/plugin/dnssec/rrsig.go b/vendor/github.com/coredns/coredns/plugin/dnssec/rrsig.go deleted file mode 100644 index d67cdc92..00000000 --- a/vendor/github.com/coredns/coredns/plugin/dnssec/rrsig.go +++ /dev/null @@ -1,53 +0,0 @@ -package dnssec - -import "github.com/miekg/dns" - -// newRRSIG return a new RRSIG, with all fields filled out, except the signed data. -func (k *DNSKEY) newRRSIG(signerName string, ttl, incep, expir uint32) *dns.RRSIG { - sig := new(dns.RRSIG) - - sig.Hdr.Rrtype = dns.TypeRRSIG - sig.Algorithm = k.K.Algorithm - sig.KeyTag = k.tag - sig.SignerName = signerName - sig.Hdr.Ttl = ttl - sig.OrigTtl = origTTL - - sig.Inception = incep - sig.Expiration = expir - - return sig -} - -type rrset struct { - qname string - qtype uint16 -} - -// rrSets returns rrs as a map of RRsets. It skips RRSIG and OPT records as those don't need to be signed. -func rrSets(rrs []dns.RR) map[rrset][]dns.RR { - m := make(map[rrset][]dns.RR) - - for _, r := range rrs { - if r.Header().Rrtype == dns.TypeRRSIG || r.Header().Rrtype == dns.TypeOPT { - continue - } - - if s, ok := m[rrset{r.Header().Name, r.Header().Rrtype}]; ok { - s = append(s, r) - m[rrset{r.Header().Name, r.Header().Rrtype}] = s - continue - } - - s := make([]dns.RR, 1, 3) - s[0] = r - m[rrset{r.Header().Name, r.Header().Rrtype}] = s - } - - if len(m) > 0 { - return m - } - return nil -} - -const origTTL = 3600 diff --git a/vendor/github.com/coredns/coredns/plugin/dnssec/setup.go b/vendor/github.com/coredns/coredns/plugin/dnssec/setup.go deleted file mode 100644 index 675a48d8..00000000 --- a/vendor/github.com/coredns/coredns/plugin/dnssec/setup.go +++ /dev/null @@ -1,146 +0,0 @@ -package dnssec - -import ( - "fmt" - "strconv" - "strings" - - "github.com/coredns/coredns/core/dnsserver" - "github.com/coredns/coredns/plugin" - "github.com/coredns/coredns/plugin/metrics" - "github.com/coredns/coredns/plugin/pkg/cache" - clog "github.com/coredns/coredns/plugin/pkg/log" - - "github.com/mholt/caddy" -) - -var log = clog.NewWithPlugin("dnssec") - -func init() { - caddy.RegisterPlugin("dnssec", caddy.Plugin{ - ServerType: "dns", - Action: setup, - }) -} - -func setup(c *caddy.Controller) error { - zones, keys, capacity, err := dnssecParse(c) - if err != nil { - return plugin.Error("dnssec", err) - } - - ca := cache.New(capacity) - dnsserver.GetConfig(c).AddPlugin(func(next plugin.Handler) plugin.Handler { - return New(zones, keys, next, ca) - }) - - c.OnStartup(func() error { - once.Do(func() { - metrics.MustRegister(c, cacheSize, cacheHits, cacheMisses) - }) - return nil - }) - - return nil -} - -func dnssecParse(c *caddy.Controller) ([]string, []*DNSKEY, int, error) { - zones := []string{} - - keys := []*DNSKEY{} - - capacity := defaultCap - - i := 0 - for c.Next() { - if i > 0 { - return nil, nil, 0, plugin.ErrOnce - } - i++ - - // dnssec [zones...] - zones = make([]string, len(c.ServerBlockKeys)) - copy(zones, c.ServerBlockKeys) - args := c.RemainingArgs() - if len(args) > 0 { - zones = args - } - - for c.NextBlock() { - - switch x := c.Val(); x { - case "key": - k, e := keyParse(c) - if e != nil { - return nil, nil, 0, e - } - keys = append(keys, k...) - case "cache_capacity": - if !c.NextArg() { - return nil, nil, 0, c.ArgErr() - } - value := c.Val() - cacheCap, err := strconv.Atoi(value) - if err != nil { - return nil, nil, 0, err - } - capacity = cacheCap - default: - return nil, nil, 0, c.Errf("unknown property '%s'", x) - } - - } - } - for i := range zones { - zones[i] = plugin.Host(zones[i]).Normalize() - } - - // Check if each keys owner name can actually sign the zones we want them to sign. - for _, k := range keys { - kname := plugin.Name(k.K.Header().Name) - ok := false - for i := range zones { - if kname.Matches(zones[i]) { - ok = true - break - } - } - if !ok { - return zones, keys, capacity, fmt.Errorf("key %s (keyid: %d) can not sign any of the zones", string(kname), k.tag) - } - } - - return zones, keys, capacity, nil -} - -func keyParse(c *caddy.Controller) ([]*DNSKEY, error) { - keys := []*DNSKEY{} - - if !c.NextArg() { - return nil, c.ArgErr() - } - value := c.Val() - if value == "file" { - ks := c.RemainingArgs() - if len(ks) == 0 { - return nil, c.ArgErr() - } - - for _, k := range ks { - base := k - // Kmiek.nl.+013+26205.key, handle .private or without extension: Kmiek.nl.+013+26205 - if strings.HasSuffix(k, ".key") { - base = k[:len(k)-4] - } - if strings.HasSuffix(k, ".private") { - base = k[:len(k)-8] - } - k, err := ParseKeyFile(base+".key", base+".private") - if err != nil { - return nil, err - } - keys = append(keys, k) - } - } - return keys, nil -} diff --git a/vendor/github.com/coredns/coredns/plugin/dnssec/setup_test.go b/vendor/github.com/coredns/coredns/plugin/dnssec/setup_test.go deleted file mode 100644 index b4ca7484..00000000 --- a/vendor/github.com/coredns/coredns/plugin/dnssec/setup_test.go +++ /dev/null @@ -1,122 +0,0 @@ -package dnssec - -import ( - "io/ioutil" - "os" - "strings" - "testing" - - "github.com/mholt/caddy" -) - -func TestSetupDnssec(t *testing.T) { - if err := ioutil.WriteFile("Kcluster.local.key", []byte(keypub), 0644); err != nil { - t.Fatalf("Failed to write pub key file: %s", err) - } - defer func() { os.Remove("Kcluster.local.key") }() - if err := ioutil.WriteFile("Kcluster.local.private", []byte(keypriv), 0644); err != nil { - t.Fatalf("Failed to write private key file: %s", err) - } - defer func() { os.Remove("Kcluster.local.private") }() - - tests := []struct { - input string - shouldErr bool - expectedZones []string - expectedKeys []string - expectedCapacity int - expectedErrContent string - }{ - {`dnssec`, false, nil, nil, defaultCap, ""}, - {`dnssec example.org`, false, []string{"example.org."}, nil, defaultCap, ""}, - {`dnssec 10.0.0.0/8`, false, []string{"10.in-addr.arpa."}, nil, defaultCap, ""}, - { - `dnssec example.org { - cache_capacity 100 - }`, false, []string{"example.org."}, nil, 100, "", - }, - { - `dnssec cluster.local { - key file Kcluster.local - }`, false, []string{"cluster.local."}, nil, defaultCap, "", - }, - { - `dnssec example.org cluster.local { - key file Kcluster.local - }`, false, []string{"example.org.", "cluster.local."}, nil, defaultCap, "", - }, - // fails - { - `dnssec example.org { - key file Kcluster.local - }`, true, []string{"example.org."}, nil, defaultCap, "can not sign any", - }, - { - `dnssec example.org { - key - }`, true, []string{"example.org."}, nil, defaultCap, "argument count", - }, - { - `dnssec example.org { - key file - }`, true, []string{"example.org."}, nil, defaultCap, "argument count", - }, - {`dnssec - dnssec`, true, nil, nil, defaultCap, ""}, - } - - for i, test := range tests { - c := caddy.NewTestController("dns", test.input) - zones, keys, capacity, err := dnssecParse(c) - - if test.shouldErr && err == nil { - t.Errorf("Test %d: Expected error but found %s for input %s", i, err, test.input) - } - - if err != nil { - if !test.shouldErr { - t.Errorf("Test %d: Expected no error but found one for input %s. Error was: %v", i, test.input, err) - } - - if !strings.Contains(err.Error(), test.expectedErrContent) { - t.Errorf("Test %d: Expected error to contain: %v, found error: %v, input: %s", i, test.expectedErrContent, err, test.input) - } - } - if !test.shouldErr { - for i, z := range test.expectedZones { - if zones[i] != z { - t.Errorf("Dnssec not correctly set for input %s. Expected: %s, actual: %s", test.input, z, zones[i]) - } - } - for i, k := range test.expectedKeys { - if k != keys[i].K.Header().Name { - t.Errorf("Dnssec not correctly set for input %s. Expected: '%s', actual: '%s'", test.input, k, keys[i].K.Header().Name) - } - } - if capacity != test.expectedCapacity { - t.Errorf("Dnssec not correctly set capacity for input '%s' Expected: '%d', actual: '%d'", test.input, capacity, test.expectedCapacity) - } - } - } -} - -const keypub = `; This is a zone-signing key, keyid 45330, for cluster.local. -; Created: 20170901060531 (Fri Sep 1 08:05:31 2017) -; Publish: 20170901060531 (Fri Sep 1 08:05:31 2017) -; Activate: 20170901060531 (Fri Sep 1 08:05:31 2017) -cluster.local. IN DNSKEY 256 3 5 AwEAAcFpDv+Cb23kFJowu+VU++b2N1uEHi6Ll9H0BzLasFOdJjEEclCO q/KlD4682vOMXxJNN8ZwOyiCa7Y0TEYqSwWvhHyn3bHCwuy4I6fss4Wd 7Y9dU+6QTgJ8LimGG40Iizjc9zqoU8Q+q81vIukpYWOHioHoY7hsWBvS RSlzDJk3` - -const keypriv = `Private-key-format: v1.3 -Algorithm: 5 (RSASHA1) -Modulus: wWkO/4JvbeQUmjC75VT75vY3W4QeLouX0fQHMtqwU50mMQRyUI6r8qUPjrza84xfEk03xnA7KIJrtjRMRipLBa+EfKfdscLC7Lgjp+yzhZ3tj11T7pBOAnwuKYYbjQiLONz3OqhTxD6rzW8i6SlhY4eKgehjuGxYG9JFKXMMmTc= -PublicExponent: AQAB -PrivateExponent: K5XyZFBPrjMVFX5gCZlyPyVDamNGrfSVXSIiMSqpS96BSdCXtmHAjCj4bZFPwkzi6+vs4tJN8p4ZifEVM0a6qwPZyENBrc2qbsweOXE6l8BaPVWFX30xvVRzGXuNtXxlBXE17zoHty5r5mRyRou1bc2HUS5otdkEjE30RiocQVk= -Prime1: 7RRFUxaZkVNVH1DaT/SV5Sb8kABB389qLwU++argeDCVf+Wm9BBlTrsz2U6bKlfpaUmYZKtCCd+CVxqzMyuu0w== -Prime2: 0NiY3d7Fa08IGY9L4TaFc02A721YcDNBBf95BP31qGvwnYsLFM/1xZwaEsIjohg8g+m/GpyIlvNMbK6pywIVjQ== -Exponent1: XjXO8pype9mMmvwrNNix9DTQ6nxfsQugW30PMHGZ78kGr6NX++bEC0xS50jYWjRDGcbYGzD+9iNujSScD3qNZw== -Exponent2: wkoOhLIfhUIj7etikyUup2Ld5WAbW15DSrotstg0NrgcQ+Q7reP96BXeJ79WeREFE09cyvv/EjdLzPv81/CbbQ== -Coefficient: ah4LL0KLTO8kSKHK+X9Ud8grYi94QSNdbX11ge/eFcS/41QhDuZRTAFv4y0+IG+VWd+XzojLsQs+jzLe5GzINg== -Created: 20170901060531 -Publish: 20170901060531 -Activate: 20170901060531 -` diff --git a/vendor/github.com/coredns/coredns/plugin/dnstap/OWNERS b/vendor/github.com/coredns/coredns/plugin/dnstap/OWNERS deleted file mode 100644 index 6f672429..00000000 --- a/vendor/github.com/coredns/coredns/plugin/dnstap/OWNERS +++ /dev/null @@ -1,6 +0,0 @@ -reviewers: - - varyoo - - yongtang -approvers: - - varyoo - - yongtang diff --git a/vendor/github.com/coredns/coredns/plugin/dnstap/README.md b/vendor/github.com/coredns/coredns/plugin/dnstap/README.md deleted file mode 100644 index 2f8ea766..00000000 --- a/vendor/github.com/coredns/coredns/plugin/dnstap/README.md +++ /dev/null @@ -1,93 +0,0 @@ -# dnstap - -## Name - -*dnstap* - enable logging to dnstap - -## Description - -dnstap is a flexible, structured binary log format for DNS software: http://dnstap.info. With this -plugin you make CoreDNS output dnstap logging. - -Note that there is an internal buffer, so expect at least 13 requests before the server sends its -dnstap messages to the socket. - -## Syntax - -~~~ txt -dnstap SOCKET [full] -~~~ - -* **SOCKET** is the socket path supplied to the dnstap command line tool. -* `full` to include the wire-format DNS message. - -## Examples - -Log information about client requests and responses to */tmp/dnstap.sock*. - -~~~ txt -dnstap /tmp/dnstap.sock -~~~ - -Log information including the wire-format DNS message about client requests and responses to */tmp/dnstap.sock*. - -~~~ txt -dnstap unix:///tmp/dnstap.sock full -~~~ - -Log to a remote endpoint. - -~~~ txt -dnstap tcp://127.0.0.1:6000 full -~~~ - -## Command Line Tool - -Dnstap has a command line tool that can be used to inspect the logging. The tool can be found -at Github: . It's written in Go. - -The following command listens on the given socket and decodes messages to stdout. - -~~~ sh -$ dnstap -u /tmp/dnstap.sock -~~~ - -The following command listens on the given socket and saves message payloads to a binary dnstap-format log file. - -~~~ sh -$ dnstap -u /tmp/dnstap.sock -w /tmp/test.dnstap -~~~ - -Listen for dnstap messages on port 6000. - -~~~ sh -$ dnstap -l 127.0.0.1:6000 -~~~ - -## Using Dnstap in your plugin - -~~~ Go -import ( - "github.com/coredns/coredns/plugin/dnstap" - "github.com/coredns/coredns/plugin/dnstap/msg" -) - -func (h Dnstap) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (int, error) { - // log client query to Dnstap - if t := dnstap.TapperFromContext(ctx); t != nil { - b := msg.New().Time(time.Now()).Addr(w.RemoteAddr()) - if t.Pack() { - b.Msg(r) - } - if m, err := b.ToClientQuery(); err == nil { - t.TapMessage(m) - } - } - - // ... -} -~~~ - -## See Also - -[dnstap.info](http://dnstap.info). diff --git a/vendor/github.com/coredns/coredns/plugin/dnstap/dnstapio/dnstap_encoder.go b/vendor/github.com/coredns/coredns/plugin/dnstap/dnstapio/dnstap_encoder.go deleted file mode 100644 index 07dfc841..00000000 --- a/vendor/github.com/coredns/coredns/plugin/dnstap/dnstapio/dnstap_encoder.go +++ /dev/null @@ -1,92 +0,0 @@ -package dnstapio - -import ( - "encoding/binary" - "fmt" - "io" - - tap "github.com/dnstap/golang-dnstap" - fs "github.com/farsightsec/golang-framestream" - "github.com/golang/protobuf/proto" -) - -const ( - frameLenSize = 4 - protobufSize = 1024 * 1024 -) - -type dnstapEncoder struct { - fse *fs.Encoder - opts *fs.EncoderOptions - writer io.Writer - buffer *proto.Buffer -} - -func newDnstapEncoder(o *fs.EncoderOptions) *dnstapEncoder { - return &dnstapEncoder{ - opts: o, - buffer: proto.NewBuffer(make([]byte, 0, protobufSize)), - } -} - -func (enc *dnstapEncoder) resetWriter(w io.Writer) error { - fse, err := fs.NewEncoder(w, enc.opts) - if err != nil { - return err - } - if err = fse.Flush(); err != nil { - return err - } - enc.fse = fse - enc.writer = w - return nil -} - -func (enc *dnstapEncoder) writeMsg(msg *tap.Dnstap) error { - if len(enc.buffer.Bytes()) >= protobufSize { - if err := enc.flushBuffer(); err != nil { - return err - } - } - bufLen := len(enc.buffer.Bytes()) - // add placeholder for frame length - if err := enc.buffer.EncodeFixed32(0); err != nil { - enc.buffer.SetBuf(enc.buffer.Bytes()[:bufLen]) - return err - } - if err := enc.buffer.Marshal(msg); err != nil { - enc.buffer.SetBuf(enc.buffer.Bytes()[:bufLen]) - return err - } - enc.encodeFrameLen(enc.buffer.Bytes()[bufLen:]) - return nil -} - -func (enc *dnstapEncoder) flushBuffer() error { - if enc.fse == nil || enc.writer == nil { - return fmt.Errorf("no writer") - } - - buf := enc.buffer.Bytes() - written := 0 - for written < len(buf) { - n, err := enc.writer.Write(buf[written:]) - written += n - if err != nil { - return err - } - } - enc.buffer.Reset() - return nil -} - -func (enc *dnstapEncoder) encodeFrameLen(buf []byte) { - binary.BigEndian.PutUint32(buf, uint32(len(buf)-4)) -} - -func (enc *dnstapEncoder) close() error { - if enc.fse != nil { - return enc.fse.Close() - } - return nil -} diff --git a/vendor/github.com/coredns/coredns/plugin/dnstap/dnstapio/dnstap_encoder_test.go b/vendor/github.com/coredns/coredns/plugin/dnstap/dnstapio/dnstap_encoder_test.go deleted file mode 100644 index a7fe23d2..00000000 --- a/vendor/github.com/coredns/coredns/plugin/dnstap/dnstapio/dnstap_encoder_test.go +++ /dev/null @@ -1,53 +0,0 @@ -package dnstapio - -import ( - "bytes" - "testing" - - tap "github.com/dnstap/golang-dnstap" - fs "github.com/farsightsec/golang-framestream" - "github.com/golang/protobuf/proto" -) - -func dnstapMsg() *tap.Dnstap { - t := tap.Dnstap_MESSAGE - mt := tap.Message_CLIENT_RESPONSE - msg := &tap.Message{Type: &mt} - return &tap.Dnstap{Type: &t, Message: msg} -} - -func TestEncoderCompatibility(t *testing.T) { - opts := &fs.EncoderOptions{ - ContentType: []byte("protobuf:dnstap.DnstapTest"), - Bidirectional: false, - } - msg := dnstapMsg() - - //framestream encoder - fsW := new(bytes.Buffer) - fsEnc, err := fs.NewEncoder(fsW, opts) - if err != nil { - t.Fatal(err) - } - data, err := proto.Marshal(msg) - if err != nil { - t.Fatal(err) - } - fsEnc.Write(data) - fsEnc.Close() - - //dnstap encoder - dnstapW := new(bytes.Buffer) - dnstapEnc := newDnstapEncoder(opts) - if err := dnstapEnc.resetWriter(dnstapW); err != nil { - t.Fatal(err) - } - dnstapEnc.writeMsg(msg) - dnstapEnc.flushBuffer() - dnstapEnc.close() - - //compare results - if !bytes.Equal(fsW.Bytes(), dnstapW.Bytes()) { - t.Fatal("DnstapEncoder is not compatible with framestream Encoder") - } -} diff --git a/vendor/github.com/coredns/coredns/plugin/dnstap/dnstapio/io.go b/vendor/github.com/coredns/coredns/plugin/dnstap/dnstapio/io.go deleted file mode 100644 index 65e2e222..00000000 --- a/vendor/github.com/coredns/coredns/plugin/dnstap/dnstapio/io.go +++ /dev/null @@ -1,146 +0,0 @@ -package dnstapio - -import ( - "net" - "sync/atomic" - "time" - - clog "github.com/coredns/coredns/plugin/pkg/log" - - tap "github.com/dnstap/golang-dnstap" - fs "github.com/farsightsec/golang-framestream" -) - -var log = clog.NewWithPlugin("dnstap") - -const ( - tcpWriteBufSize = 1024 * 1024 - tcpTimeout = 4 * time.Second - flushTimeout = 1 * time.Second - queueSize = 10000 -) - -type dnstapIO struct { - endpoint string - socket bool - conn net.Conn - enc *dnstapEncoder - queue chan tap.Dnstap - dropped uint32 - quit chan struct{} -} - -// New returns a new and initialized DnstapIO. -func New(endpoint string, socket bool) DnstapIO { - return &dnstapIO{ - endpoint: endpoint, - socket: socket, - enc: newDnstapEncoder(&fs.EncoderOptions{ - ContentType: []byte("protobuf:dnstap.Dnstap"), - Bidirectional: true, - }), - queue: make(chan tap.Dnstap, queueSize), - quit: make(chan struct{}), - } -} - -// DnstapIO interface -type DnstapIO interface { - Connect() - Dnstap(payload tap.Dnstap) - Close() -} - -func (dio *dnstapIO) newConnect() error { - var err error - if dio.socket { - if dio.conn, err = net.Dial("unix", dio.endpoint); err != nil { - return err - } - } else { - if dio.conn, err = net.DialTimeout("tcp", dio.endpoint, tcpTimeout); err != nil { - return err - } - if tcpConn, ok := dio.conn.(*net.TCPConn); ok { - tcpConn.SetWriteBuffer(tcpWriteBufSize) - tcpConn.SetNoDelay(false) - } - } - - return dio.enc.resetWriter(dio.conn) -} - -// Connect connects to the dnstop endpoint. -func (dio *dnstapIO) Connect() { - if err := dio.newConnect(); err != nil { - log.Error("No connection to dnstap endpoint") - } - go dio.serve() -} - -// Dnstap enqueues the payload for log. -func (dio *dnstapIO) Dnstap(payload tap.Dnstap) { - select { - case dio.queue <- payload: - default: - atomic.AddUint32(&dio.dropped, 1) - } -} - -func (dio *dnstapIO) closeConnection() { - dio.enc.close() - if dio.conn != nil { - dio.conn.Close() - dio.conn = nil - } -} - -// Close waits until the I/O routine is finished to return. -func (dio *dnstapIO) Close() { - close(dio.quit) -} - -func (dio *dnstapIO) flushBuffer() { - if dio.conn == nil { - if err := dio.newConnect(); err != nil { - return - } - log.Info("Reconnected to dnstap") - } - - if err := dio.enc.flushBuffer(); err != nil { - log.Warningf("Connection lost: %s", err) - dio.closeConnection() - if err := dio.newConnect(); err != nil { - log.Errorf("Cannot connect to dnstap: %s", err) - } else { - log.Info("Reconnected to dnstap") - } - } -} - -func (dio *dnstapIO) write(payload *tap.Dnstap) { - if err := dio.enc.writeMsg(payload); err != nil { - atomic.AddUint32(&dio.dropped, 1) - } -} - -func (dio *dnstapIO) serve() { - timeout := time.After(flushTimeout) - for { - select { - case <-dio.quit: - dio.flushBuffer() - dio.closeConnection() - return - case payload := <-dio.queue: - dio.write(&payload) - case <-timeout: - if dropped := atomic.SwapUint32(&dio.dropped, 0); dropped > 0 { - log.Warningf("Dropped dnstap messages: %d", dropped) - } - dio.flushBuffer() - timeout = time.After(flushTimeout) - } - } -} diff --git a/vendor/github.com/coredns/coredns/plugin/dnstap/dnstapio/io_test.go b/vendor/github.com/coredns/coredns/plugin/dnstap/dnstapio/io_test.go deleted file mode 100644 index dc84cee7..00000000 --- a/vendor/github.com/coredns/coredns/plugin/dnstap/dnstapio/io_test.go +++ /dev/null @@ -1,162 +0,0 @@ -package dnstapio - -import ( - "net" - "sync" - "testing" - "time" - - tap "github.com/dnstap/golang-dnstap" - fs "github.com/farsightsec/golang-framestream" -) - -const ( - endpointTCP = "localhost:0" - endpointSocket = "dnstap.sock" -) - -var ( - msgType = tap.Dnstap_MESSAGE - msg = tap.Dnstap{Type: &msgType} -) - -func accept(t *testing.T, l net.Listener, count int) { - server, err := l.Accept() - if err != nil { - t.Fatalf("Server accepted: %s", err) - return - } - - dec, err := fs.NewDecoder(server, &fs.DecoderOptions{ - ContentType: []byte("protobuf:dnstap.Dnstap"), - Bidirectional: true, - }) - if err != nil { - t.Fatalf("Server decoder: %s", err) - return - } - - for i := 0; i < count; i++ { - if _, err := dec.Decode(); err != nil { - t.Errorf("Server decode: %s", err) - } - } - - if err := server.Close(); err != nil { - t.Error(err) - } -} - -func TestTransport(t *testing.T) { - transport := [2][3]string{ - {"tcp", endpointTCP, "false"}, - {"unix", endpointSocket, "true"}, - } - - for _, param := range transport { - // Start TCP listener - l, err := net.Listen(param[0], param[1]) - if err != nil { - t.Fatalf("Cannot start listener: %s", err) - } - - var wg sync.WaitGroup - wg.Add(1) - go func() { - accept(t, l, 1) - wg.Done() - }() - - dio := New(l.Addr().String(), param[2] == "true") - dio.Connect() - - dio.Dnstap(msg) - - wg.Wait() - l.Close() - dio.Close() - } -} - -func TestRace(t *testing.T) { - count := 10 - - // Start TCP listener - l, err := net.Listen("tcp", endpointTCP) - if err != nil { - t.Fatalf("Cannot start listener: %s", err) - } - defer l.Close() - - var wg sync.WaitGroup - wg.Add(1) - go func() { - accept(t, l, count) - wg.Done() - }() - - dio := New(l.Addr().String(), false) - dio.Connect() - defer dio.Close() - - wg.Add(count) - for i := 0; i < count; i++ { - go func() { - time.Sleep(50 * time.Millisecond) - dio.Dnstap(msg) - wg.Done() - }() - } - - wg.Wait() -} - -func TestReconnect(t *testing.T) { - count := 5 - - // Start TCP listener - l, err := net.Listen("tcp", endpointTCP) - if err != nil { - t.Fatalf("Cannot start listener: %s", err) - } - - var wg sync.WaitGroup - wg.Add(1) - go func() { - accept(t, l, 1) - wg.Done() - }() - - addr := l.Addr().String() - dio := New(addr, false) - dio.Connect() - defer dio.Close() - - msg := tap.Dnstap_MESSAGE - dio.Dnstap(tap.Dnstap{Type: &msg}) - - wg.Wait() - - // Close listener - l.Close() - - // And start TCP listener again on the same port - l, err = net.Listen("tcp", addr) - if err != nil { - t.Fatalf("Cannot start listener: %s", err) - } - defer l.Close() - - wg.Add(1) - go func() { - accept(t, l, 1) - wg.Done() - }() - - for i := 0; i < count; i++ { - time.Sleep(time.Second) - dio.Dnstap(tap.Dnstap{Type: &msg}) - } - - wg.Wait() -} diff --git a/vendor/github.com/coredns/coredns/plugin/dnstap/handler.go b/vendor/github.com/coredns/coredns/plugin/dnstap/handler.go deleted file mode 100644 index 1c411e2a..00000000 --- a/vendor/github.com/coredns/coredns/plugin/dnstap/handler.go +++ /dev/null @@ -1,97 +0,0 @@ -package dnstap - -import ( - "context" - "time" - - "github.com/coredns/coredns/plugin" - "github.com/coredns/coredns/plugin/dnstap/taprw" - - tap "github.com/dnstap/golang-dnstap" - "github.com/miekg/dns" -) - -// Dnstap is the dnstap handler. -type Dnstap struct { - Next plugin.Handler - IO IORoutine - - // Set to true to include the relevant raw DNS message into the dnstap messages. - JoinRawMessage bool -} - -type ( - // IORoutine is the dnstap I/O thread as defined by: . - IORoutine interface { - Dnstap(tap.Dnstap) - } - // Tapper is implemented by the Context passed by the dnstap handler. - Tapper interface { - TapMessage(message *tap.Message) - Pack() bool - } - tapContext struct { - context.Context - Dnstap - } -) - -// ContextKey defines the type of key that is used to save data into the context -type ContextKey string - -const ( - // DnstapSendOption specifies the Dnstap message to be send. Default is sent all. - DnstapSendOption ContextKey = "dnstap-send-option" -) - -// TapperFromContext will return a Tapper if the dnstap plugin is enabled. -func TapperFromContext(ctx context.Context) (t Tapper) { - t, _ = ctx.(Tapper) - return -} - -// TapMessage implements Tapper. -func (h *Dnstap) TapMessage(m *tap.Message) { - t := tap.Dnstap_MESSAGE - h.IO.Dnstap(tap.Dnstap{ - Type: &t, - Message: m, - }) -} - -// Pack returns true if the raw DNS message should be included into the dnstap messages. -func (h Dnstap) Pack() bool { - return h.JoinRawMessage -} - -// ServeDNS logs the client query and response to dnstap and passes the dnstap Context. -func (h Dnstap) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (int, error) { - - // Add send option into context so other plugin can decide on which DNSTap - // message to be sent out - sendOption := taprw.SendOption{Cq: true, Cr: true} - newCtx := context.WithValue(ctx, DnstapSendOption, &sendOption) - - rw := &taprw.ResponseWriter{ - ResponseWriter: w, - Tapper: &h, - Query: r, - Send: &sendOption, - QueryEpoch: time.Now(), - } - - code, err := plugin.NextOrFailure(h.Name(), h.Next, tapContext{newCtx, h}, rw, r) - if err != nil { - // ignore dnstap errors - return code, err - } - - if err = rw.DnstapError(); err != nil { - return code, plugin.Error("dnstap", err) - } - - return code, nil -} - -// Name returns dnstap. -func (h Dnstap) Name() string { return "dnstap" } diff --git a/vendor/github.com/coredns/coredns/plugin/dnstap/handler_test.go b/vendor/github.com/coredns/coredns/plugin/dnstap/handler_test.go deleted file mode 100644 index b86fe019..00000000 --- a/vendor/github.com/coredns/coredns/plugin/dnstap/handler_test.go +++ /dev/null @@ -1,116 +0,0 @@ -package dnstap - -import ( - "context" - "errors" - "net" - "strings" - "testing" - - "github.com/coredns/coredns/plugin" - "github.com/coredns/coredns/plugin/dnstap/test" - mwtest "github.com/coredns/coredns/plugin/test" - tap "github.com/dnstap/golang-dnstap" - "github.com/miekg/dns" -) - -func testCase(t *testing.T, tapq, tapr *tap.Message, q, r *dns.Msg) { - w := writer{t: t} - w.queue = append(w.queue, tapq, tapr) - h := Dnstap{ - Next: mwtest.HandlerFunc(func(_ context.Context, - w dns.ResponseWriter, _ *dns.Msg) (int, error) { - - return 0, w.WriteMsg(r) - }), - IO: &w, - JoinRawMessage: false, - } - _, err := h.ServeDNS(context.TODO(), &mwtest.ResponseWriter{}, q) - if err != nil { - t.Fatal(err) - } -} - -type writer struct { - t *testing.T - queue []*tap.Message -} - -func (w *writer) Dnstap(e tap.Dnstap) { - if len(w.queue) == 0 { - w.t.Error("Message not expected.") - } - if !test.MsgEqual(w.queue[0], e.Message) { - w.t.Errorf("Want: %v, have: %v", w.queue[0], e.Message) - } - w.queue = w.queue[1:] -} - -func TestDnstap(t *testing.T) { - q := mwtest.Case{Qname: "example.org", Qtype: dns.TypeA}.Msg() - r := mwtest.Case{ - Qname: "example.org.", Qtype: dns.TypeA, - Answer: []dns.RR{ - mwtest.A("example.org. 3600 IN A 10.0.0.1"), - }, - }.Msg() - tapq, _ := test.TestingData().ToClientQuery() - tapr, _ := test.TestingData().ToClientResponse() - testCase(t, tapq, tapr, q, r) -} - -type noWriter struct { -} - -func (n noWriter) Dnstap(d tap.Dnstap) { -} - -func endWith(c int, err error) plugin.Handler { - return mwtest.HandlerFunc(func(_ context.Context, w dns.ResponseWriter, _ *dns.Msg) (int, error) { - w.WriteMsg(nil) // trigger plugin dnstap to log client query and response - // maybe dnstap should log the client query when no message is written... - return c, err - }) -} - -type badAddr struct { -} - -func (bad badAddr) Network() string { - return "bad network" -} -func (bad badAddr) String() string { - return "bad address" -} - -type badRW struct { - dns.ResponseWriter -} - -func (bad *badRW) RemoteAddr() net.Addr { - return badAddr{} -} - -func TestError(t *testing.T) { - h := Dnstap{ - Next: endWith(0, nil), - IO: noWriter{}, - JoinRawMessage: false, - } - rw := &badRW{&mwtest.ResponseWriter{}} - - // the dnstap error will show only if there is no plugin error - _, err := h.ServeDNS(context.TODO(), rw, nil) - if err == nil || !strings.HasPrefix(err.Error(), "plugin/dnstap") { - t.Fatal("Must return the dnstap error but have:", err) - } - - // plugin errors will always overwrite dnstap errors - pluginErr := errors.New("plugin error") - h.Next = endWith(0, pluginErr) - _, err = h.ServeDNS(context.TODO(), rw, nil) - if err != pluginErr { - t.Fatal("Must return the plugin error but have:", err) - } -} diff --git a/vendor/github.com/coredns/coredns/plugin/dnstap/msg/msg.go b/vendor/github.com/coredns/coredns/plugin/dnstap/msg/msg.go deleted file mode 100644 index d96fc6c9..00000000 --- a/vendor/github.com/coredns/coredns/plugin/dnstap/msg/msg.go +++ /dev/null @@ -1,159 +0,0 @@ -package msg - -import ( - "errors" - "net" - "strconv" - "time" - - tap "github.com/dnstap/golang-dnstap" - "github.com/miekg/dns" -) - -// Builder helps to build a Dnstap message. -type Builder struct { - Packed []byte - SocketProto tap.SocketProtocol - SocketFam tap.SocketFamily - Address net.IP - Port uint32 - TimeSec uint64 - TimeNsec uint32 - - err error -} - -// New returns a new Builder -func New() *Builder { - return &Builder{} -} - -// Addr adds the remote address to the message. -func (b *Builder) Addr(remote net.Addr) *Builder { - if b.err != nil { - return b - } - - switch addr := remote.(type) { - case *net.TCPAddr: - b.Address = addr.IP - b.Port = uint32(addr.Port) - b.SocketProto = tap.SocketProtocol_TCP - case *net.UDPAddr: - b.Address = addr.IP - b.Port = uint32(addr.Port) - b.SocketProto = tap.SocketProtocol_UDP - default: - b.err = errors.New("unknown remote address type") - return b - } - - if b.Address.To4() != nil { - b.SocketFam = tap.SocketFamily_INET - } else { - b.SocketFam = tap.SocketFamily_INET6 - } - return b -} - -// Msg adds the raw DNS message to the dnstap message. -func (b *Builder) Msg(m *dns.Msg) *Builder { - if b.err != nil { - return b - } - - b.Packed, b.err = m.Pack() - return b -} - -// HostPort adds the remote address as encoded by dnsutil.ParseHostPortOrFile to the message. -func (b *Builder) HostPort(addr string) *Builder { - ip, port, err := net.SplitHostPort(addr) - if err != nil { - b.err = err - return b - } - p, err := strconv.ParseUint(port, 10, 32) - if err != nil { - b.err = err - return b - } - b.Port = uint32(p) - - if ip := net.ParseIP(ip); ip != nil { - b.Address = []byte(ip) - if ip := ip.To4(); ip != nil { - b.SocketFam = tap.SocketFamily_INET - } else { - b.SocketFam = tap.SocketFamily_INET6 - } - return b - } - b.err = errors.New("not an ip address") - return b -} - -// Time adds the timestamp to the message. -func (b *Builder) Time(ts time.Time) *Builder { - b.TimeSec = uint64(ts.Unix()) - b.TimeNsec = uint32(ts.Nanosecond()) - return b -} - -// ToClientResponse transforms Data into a client response message. -func (b *Builder) ToClientResponse() (*tap.Message, error) { - t := tap.Message_CLIENT_RESPONSE - return &tap.Message{ - Type: &t, - SocketFamily: &b.SocketFam, - SocketProtocol: &b.SocketProto, - ResponseTimeSec: &b.TimeSec, - ResponseTimeNsec: &b.TimeNsec, - ResponseMessage: b.Packed, - QueryAddress: b.Address, - QueryPort: &b.Port, - }, b.err -} - -// ToClientQuery transforms Data into a client query message. -func (b *Builder) ToClientQuery() (*tap.Message, error) { - t := tap.Message_CLIENT_QUERY - return &tap.Message{ - Type: &t, - SocketFamily: &b.SocketFam, - SocketProtocol: &b.SocketProto, - QueryTimeSec: &b.TimeSec, - QueryTimeNsec: &b.TimeNsec, - QueryMessage: b.Packed, - QueryAddress: b.Address, - QueryPort: &b.Port, - }, b.err -} - -// ToOutsideQuery transforms the data into a forwarder or resolver query message. -func (b *Builder) ToOutsideQuery(t tap.Message_Type) (*tap.Message, error) { - return &tap.Message{ - Type: &t, - SocketFamily: &b.SocketFam, - SocketProtocol: &b.SocketProto, - QueryTimeSec: &b.TimeSec, - QueryTimeNsec: &b.TimeNsec, - QueryMessage: b.Packed, - ResponseAddress: b.Address, - ResponsePort: &b.Port, - }, b.err -} - -// ToOutsideResponse transforms the data into a forwarder or resolver response message. -func (b *Builder) ToOutsideResponse(t tap.Message_Type) (*tap.Message, error) { - return &tap.Message{ - Type: &t, - SocketFamily: &b.SocketFam, - SocketProtocol: &b.SocketProto, - ResponseTimeSec: &b.TimeSec, - ResponseTimeNsec: &b.TimeNsec, - ResponseMessage: b.Packed, - ResponseAddress: b.Address, - ResponsePort: &b.Port, - }, b.err -} diff --git a/vendor/github.com/coredns/coredns/plugin/dnstap/msg/msg_test.go b/vendor/github.com/coredns/coredns/plugin/dnstap/msg/msg_test.go deleted file mode 100644 index 57a4e4fe..00000000 --- a/vendor/github.com/coredns/coredns/plugin/dnstap/msg/msg_test.go +++ /dev/null @@ -1,39 +0,0 @@ -package msg - -import ( - "net" - "reflect" - "testing" - - "github.com/coredns/coredns/plugin/test" - "github.com/coredns/coredns/request" - - tap "github.com/dnstap/golang-dnstap" - "github.com/miekg/dns" -) - -func testRequest(t *testing.T, expected Builder, r request.Request) { - d := Builder{} - d.Addr(r.W.RemoteAddr()) - if d.SocketProto != expected.SocketProto || - d.SocketFam != expected.SocketFam || - !reflect.DeepEqual(d.Address, expected.Address) || - d.Port != expected.Port { - t.Fatalf("Expected: %v, have: %v", expected, d) - return - } -} -func TestRequest(t *testing.T) { - testRequest(t, Builder{ - SocketProto: tap.SocketProtocol_UDP, - SocketFam: tap.SocketFamily_INET, - Address: net.ParseIP("10.240.0.1"), - Port: 40212, - }, testingRequest()) -} -func testingRequest() request.Request { - m := new(dns.Msg) - m.SetQuestion("example.com.", dns.TypeA) - m.SetEdns0(4097, true) - return request.Request{W: &test.ResponseWriter{}, Req: m} -} diff --git a/vendor/github.com/coredns/coredns/plugin/dnstap/setup.go b/vendor/github.com/coredns/coredns/plugin/dnstap/setup.go deleted file mode 100644 index c7050b35..00000000 --- a/vendor/github.com/coredns/coredns/plugin/dnstap/setup.go +++ /dev/null @@ -1,96 +0,0 @@ -package dnstap - -import ( - "strings" - - "github.com/coredns/coredns/core/dnsserver" - "github.com/coredns/coredns/plugin" - "github.com/coredns/coredns/plugin/dnstap/dnstapio" - "github.com/coredns/coredns/plugin/pkg/dnsutil" - clog "github.com/coredns/coredns/plugin/pkg/log" - - "github.com/mholt/caddy" - "github.com/mholt/caddy/caddyfile" -) - -var log = clog.NewWithPlugin("dnstap") - -func init() { - caddy.RegisterPlugin("dnstap", caddy.Plugin{ - ServerType: "dns", - Action: wrapSetup, - }) -} - -func wrapSetup(c *caddy.Controller) error { - if err := setup(c); err != nil { - return plugin.Error("dnstap", err) - } - return nil -} - -type config struct { - target string - socket bool - full bool -} - -func parseConfig(d *caddyfile.Dispenser) (c config, err error) { - d.Next() // directive name - - if !d.Args(&c.target) { - return c, d.ArgErr() - } - - if strings.HasPrefix(c.target, "tcp://") { - // remote IP endpoint - servers, err := dnsutil.ParseHostPortOrFile(c.target[6:]) - if err != nil { - return c, d.ArgErr() - } - c.target = servers[0] - } else { - // default to UNIX socket - if strings.HasPrefix(c.target, "unix://") { - c.target = c.target[7:] - } - c.socket = true - } - - c.full = d.NextArg() && d.Val() == "full" - - return -} - -func setup(c *caddy.Controller) error { - conf, err := parseConfig(&c.Dispenser) - if err != nil { - return err - } - - dio := dnstapio.New(conf.target, conf.socket) - dnstap := Dnstap{IO: dio, JoinRawMessage: conf.full} - - c.OnStartup(func() error { - dio.Connect() - return nil - }) - - c.OnRestart(func() error { - dio.Close() - return nil - }) - - c.OnFinalShutdown(func() error { - dio.Close() - return nil - }) - - dnsserver.GetConfig(c).AddPlugin( - func(next plugin.Handler) plugin.Handler { - dnstap.Next = next - return dnstap - }) - - return nil -} diff --git a/vendor/github.com/coredns/coredns/plugin/dnstap/setup_test.go b/vendor/github.com/coredns/coredns/plugin/dnstap/setup_test.go deleted file mode 100644 index eeeb4502..00000000 --- a/vendor/github.com/coredns/coredns/plugin/dnstap/setup_test.go +++ /dev/null @@ -1,35 +0,0 @@ -package dnstap - -import ( - "testing" - - "github.com/mholt/caddy" -) - -func TestConfig(t *testing.T) { - tests := []struct { - file string - path string - full bool - socket bool - fail bool - }{ - {"dnstap dnstap.sock full", "dnstap.sock", true, true, false}, - {"dnstap unix://dnstap.sock", "dnstap.sock", false, true, false}, - {"dnstap tcp://127.0.0.1:6000", "127.0.0.1:6000", false, false, false}, - {"dnstap", "fail", false, true, true}, - } - for _, c := range tests { - cad := caddy.NewTestController("dns", c.file) - conf, err := parseConfig(&cad.Dispenser) - if c.fail { - if err == nil { - t.Errorf("%s: %s", c.file, err) - } - } else if err != nil || conf.target != c.path || - conf.full != c.full || conf.socket != c.socket { - - t.Errorf("Expected: %+v\nhave: %+v\nerror: %s\n", c, conf, err) - } - } -} diff --git a/vendor/github.com/coredns/coredns/plugin/dnstap/taprw/writer.go b/vendor/github.com/coredns/coredns/plugin/dnstap/taprw/writer.go deleted file mode 100644 index 06e6c941..00000000 --- a/vendor/github.com/coredns/coredns/plugin/dnstap/taprw/writer.go +++ /dev/null @@ -1,79 +0,0 @@ -// Package taprw takes a query and intercepts the response. -// It will log both after the response is written. -package taprw - -import ( - "fmt" - "time" - - "github.com/coredns/coredns/plugin/dnstap/msg" - - tap "github.com/dnstap/golang-dnstap" - "github.com/miekg/dns" -) - -// SendOption stores the flag to indicate whether a certain DNSTap message to -// be sent out or not. -type SendOption struct { - Cq bool - Cr bool -} - -// Tapper is what ResponseWriter needs to log to dnstap. -type Tapper interface { - TapMessage(*tap.Message) - Pack() bool -} - -// ResponseWriter captures the client response and logs the query to dnstap. -// Single request use. -// SendOption configures Dnstap to selectively send Dnstap messages. Default is send all. -type ResponseWriter struct { - QueryEpoch time.Time - Query *dns.Msg - dns.ResponseWriter - Tapper - Send *SendOption - - dnstapErr error -} - -// DnstapError check if a dnstap error occurred during Write and returns it. -func (w *ResponseWriter) DnstapError() error { - return w.dnstapErr -} - -// WriteMsg writes back the response to the client and THEN works on logging the request -// and response to dnstap. -func (w *ResponseWriter) WriteMsg(resp *dns.Msg) (writeErr error) { - writeErr = w.ResponseWriter.WriteMsg(resp) - writeEpoch := time.Now() - - b := msg.New().Time(w.QueryEpoch).Addr(w.RemoteAddr()) - - if w.Send == nil || w.Send.Cq { - if w.Pack() { - b.Msg(w.Query) - } - if m, err := b.ToClientQuery(); err != nil { - w.dnstapErr = fmt.Errorf("client query: %s", err) - } else { - w.TapMessage(m) - } - } - - if w.Send == nil || w.Send.Cr { - if writeErr == nil { - if w.Pack() { - b.Msg(resp) - } - if m, err := b.Time(writeEpoch).ToClientResponse(); err != nil { - w.dnstapErr = fmt.Errorf("client response: %s", err) - } else { - w.TapMessage(m) - } - } - } - - return writeErr -} diff --git a/vendor/github.com/coredns/coredns/plugin/dnstap/taprw/writer_test.go b/vendor/github.com/coredns/coredns/plugin/dnstap/taprw/writer_test.go deleted file mode 100644 index d5594389..00000000 --- a/vendor/github.com/coredns/coredns/plugin/dnstap/taprw/writer_test.go +++ /dev/null @@ -1,115 +0,0 @@ -package taprw - -import ( - "testing" - - "github.com/coredns/coredns/plugin/dnstap/test" - mwtest "github.com/coredns/coredns/plugin/test" - - "github.com/miekg/dns" -) - -func testingMsg() (m *dns.Msg) { - m = new(dns.Msg) - m.SetQuestion("example.com.", dns.TypeA) - m.SetEdns0(4097, true) - return -} - -func TestClientQueryResponse(t *testing.T) { - trapper := test.TrapTapper{Full: true} - m := testingMsg() - rw := ResponseWriter{ - Query: m, - Tapper: &trapper, - ResponseWriter: &mwtest.ResponseWriter{}, - } - d := test.TestingData() - - // will the wire-format msg be reported? - bin, err := m.Pack() - if err != nil { - t.Fatal(err) - return - } - d.Packed = bin - - if err := rw.WriteMsg(m); err != nil { - t.Fatal(err) - return - } - if l := len(trapper.Trap); l != 2 { - t.Fatalf("Mmsg %d trapped", l) - return - } - want, err := d.ToClientQuery() - if err != nil { - t.Fatal("Testing data must build", err) - } - have := trapper.Trap[0] - if !test.MsgEqual(want, have) { - t.Fatalf("Query: want: %v\nhave: %v", want, have) - } - want, err = d.ToClientResponse() - if err != nil { - t.Fatal("Testing data must build", err) - } - have = trapper.Trap[1] - if !test.MsgEqual(want, have) { - t.Fatalf("Response: want: %v\nhave: %v", want, have) - } -} - -func TestClientQueryResponseWithSendOption(t *testing.T) { - trapper := test.TrapTapper{Full: true} - m := testingMsg() - rw := ResponseWriter{ - Query: m, - Tapper: &trapper, - ResponseWriter: &mwtest.ResponseWriter{}, - } - d := test.TestingData() - bin, err := m.Pack() - if err != nil { - t.Fatal(err) - return - } - d.Packed = bin - - // Do not send both CQ and CR - o := SendOption{Cq: false, Cr: false} - rw.Send = &o - - if err := rw.WriteMsg(m); err != nil { - t.Fatal(err) - return - } - if l := len(trapper.Trap); l != 0 { - t.Fatalf("%d msg trapped", l) - return - } - - //Send CQ - o.Cq = true - if err := rw.WriteMsg(m); err != nil { - t.Fatal(err) - return - } - if l := len(trapper.Trap); l != 1 { - t.Fatalf("%d msg trapped", l) - return - } - - //Send CR - trapper.Trap = trapper.Trap[:0] - o.Cq = false - o.Cr = true - if err := rw.WriteMsg(m); err != nil { - t.Fatal(err) - return - } - if l := len(trapper.Trap); l != 1 { - t.Fatalf("%d msg trapped", l) - return - } -} diff --git a/vendor/github.com/coredns/coredns/plugin/dnstap/test/helpers.go b/vendor/github.com/coredns/coredns/plugin/dnstap/test/helpers.go deleted file mode 100644 index 4f71a5a8..00000000 --- a/vendor/github.com/coredns/coredns/plugin/dnstap/test/helpers.go +++ /dev/null @@ -1,79 +0,0 @@ -package test - -import ( - "context" - "net" - "reflect" - - "github.com/coredns/coredns/plugin/dnstap/msg" - - tap "github.com/dnstap/golang-dnstap" -) - -// Context is a message trap. -type Context struct { - context.Context - TrapTapper -} - -// TestingData returns the Data matching coredns/test.ResponseWriter. -func TestingData() (d *msg.Builder) { - d = &msg.Builder{ - SocketFam: tap.SocketFamily_INET, - SocketProto: tap.SocketProtocol_UDP, - Address: net.ParseIP("10.240.0.1"), - Port: 40212, - } - return -} - -type comp struct { - Type *tap.Message_Type - SF *tap.SocketFamily - SP *tap.SocketProtocol - QA []byte - RA []byte - QP *uint32 - RP *uint32 - QTSec bool - RTSec bool - RM []byte - QM []byte -} - -func toComp(m *tap.Message) comp { - return comp{ - Type: m.Type, - SF: m.SocketFamily, - SP: m.SocketProtocol, - QA: m.QueryAddress, - RA: m.ResponseAddress, - QP: m.QueryPort, - RP: m.ResponsePort, - QTSec: m.QueryTimeSec != nil, - RTSec: m.ResponseTimeSec != nil, - RM: m.ResponseMessage, - QM: m.QueryMessage, - } -} - -// MsgEqual compares two dnstap messages ignoring timestamps. -func MsgEqual(a, b *tap.Message) bool { - return reflect.DeepEqual(toComp(a), toComp(b)) -} - -// TrapTapper traps messages. -type TrapTapper struct { - Trap []*tap.Message - Full bool -} - -// Pack returns field Full. -func (t *TrapTapper) Pack() bool { - return t.Full -} - -// TapMessage adds the message to the trap. -func (t *TrapTapper) TapMessage(m *tap.Message) { - t.Trap = append(t.Trap, m) -} diff --git a/vendor/github.com/coredns/coredns/plugin/erratic/OWNERS b/vendor/github.com/coredns/coredns/plugin/erratic/OWNERS deleted file mode 100644 index eee46f68..00000000 --- a/vendor/github.com/coredns/coredns/plugin/erratic/OWNERS +++ /dev/null @@ -1,4 +0,0 @@ -reviewers: - - miekg -approvers: - - miekg diff --git a/vendor/github.com/coredns/coredns/plugin/erratic/README.md b/vendor/github.com/coredns/coredns/plugin/erratic/README.md deleted file mode 100644 index ab58b161..00000000 --- a/vendor/github.com/coredns/coredns/plugin/erratic/README.md +++ /dev/null @@ -1,90 +0,0 @@ -# erratic - -## Name - -*erratic* - a plugin useful for testing client behavior. - -## Description - -*erratic* returns a static response to all queries, but the responses can be delayed, dropped or truncated. -The *erratic* plugin will respond to every A or AAAA query. For any other type it will return -a SERVFAIL response. The reply for A will return 192.0.2.53 (see [RFC -5737](https://tools.ietf.org/html/rfc5737), -for AAAA it returns 2001:DB8::53 (see [RFC 3849](https://tools.ietf.org/html/rfc3849)). - -*erratic* can also be used in conjunction with the *autopath* plugin. This is mostly to aid in -testing. - -## Syntax - -~~~ txt -erratic { - drop [AMOUNT] - truncate [AMOUNT] - delay [AMOUNT [DURATION]] -} -~~~ - -* `drop`: drop 1 per **AMOUNT** of queries, the default is 2. -* `truncate`: truncate 1 per **AMOUNT** of queries, the default is 2. -* `delay`: delay 1 per **AMOUNT** of queries for **DURATION**, the default for **AMOUNT** is 2 and - the default for **DURATION** is 100ms. - -## Health - -This plugin implements dynamic health checking. For every dropped query it turns unhealthy. - -## Examples - -~~~ corefile -. { - erratic { - drop 3 - } -} -~~~ - -Or even shorter if the defaults suits you. Note this only drops queries, it does not delay them. - -~~~ corefile -. { - erratic -} -~~~ - -Delay 1 in 3 queries for 50ms - -~~~ corefile -. { - erratic { - delay 3 50ms - } -} -~~~ - -Delay 1 in 3 and truncate 1 in 5. - -~~~ corefile -. { - erratic { - delay 3 5ms - truncate 5 - } -} -~~~ - -Drop every second query. - -~~~ corefile -. { - erratic { - drop 2 - truncate 2 - } -} -~~~ - -## Also See - -[RFC 3849](https://tools.ietf.org/html/rfc3849) and -[RFC 5737](https://tools.ietf.org/html/rfc5737). diff --git a/vendor/github.com/coredns/coredns/plugin/erratic/autopath.go b/vendor/github.com/coredns/coredns/plugin/erratic/autopath.go deleted file mode 100644 index 0e29fffe..00000000 --- a/vendor/github.com/coredns/coredns/plugin/erratic/autopath.go +++ /dev/null @@ -1,8 +0,0 @@ -package erratic - -import "github.com/coredns/coredns/request" - -// AutoPath implements the AutoPathFunc call from the autopath plugin. -func (e *Erratic) AutoPath(state request.Request) []string { - return []string{"a.example.org.", "b.example.org.", ""} -} diff --git a/vendor/github.com/coredns/coredns/plugin/erratic/erratic.go b/vendor/github.com/coredns/coredns/plugin/erratic/erratic.go deleted file mode 100644 index 290e0c2c..00000000 --- a/vendor/github.com/coredns/coredns/plugin/erratic/erratic.go +++ /dev/null @@ -1,94 +0,0 @@ -// Package erratic implements a plugin that returns erratic answers (delayed, dropped). -package erratic - -import ( - "context" - "sync/atomic" - "time" - - "github.com/coredns/coredns/request" - - "github.com/miekg/dns" -) - -// Erratic is a plugin that returns erratic responses to each client. -type Erratic struct { - drop uint64 - - delay uint64 - duration time.Duration - - truncate uint64 - - q uint64 // counter of queries -} - -// ServeDNS implements the plugin.Handler interface. -func (e *Erratic) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (int, error) { - state := request.Request{W: w, Req: r} - drop := false - delay := false - trunc := false - - queryNr := atomic.LoadUint64(&e.q) - atomic.AddUint64(&e.q, 1) - - if e.drop > 0 && queryNr%e.drop == 0 { - drop = true - } - if e.delay > 0 && queryNr%e.delay == 0 { - delay = true - } - if e.truncate > 0 && queryNr&e.truncate == 0 { - trunc = true - } - - m := new(dns.Msg) - m.SetReply(r) - m.Authoritative = true - if trunc { - m.Truncated = true - } - - // small dance to copy rrA or rrAAAA into a non-pointer var that allows us to overwrite the ownername - // in a non-racy way. - switch state.QType() { - case dns.TypeA: - rr := *(rrA.(*dns.A)) - rr.Header().Name = state.QName() - m.Answer = append(m.Answer, &rr) - case dns.TypeAAAA: - rr := *(rrAAAA.(*dns.AAAA)) - rr.Header().Name = state.QName() - m.Answer = append(m.Answer, &rr) - default: - if !drop { - if delay { - time.Sleep(e.duration) - } - // coredns will return error. - return dns.RcodeServerFailure, nil - } - } - - if drop { - return 0, nil - } - - if delay { - time.Sleep(e.duration) - } - - state.SizeAndDo(m) - w.WriteMsg(m) - - return 0, nil -} - -// Name implements the Handler interface. -func (e *Erratic) Name() string { return "erratic" } - -var ( - rrA, _ = dns.NewRR(". IN 0 A 192.0.2.53") - rrAAAA, _ = dns.NewRR(". IN 0 AAAA 2001:DB8::53") -) diff --git a/vendor/github.com/coredns/coredns/plugin/erratic/erratic_test.go b/vendor/github.com/coredns/coredns/plugin/erratic/erratic_test.go deleted file mode 100644 index 8a3b4e01..00000000 --- a/vendor/github.com/coredns/coredns/plugin/erratic/erratic_test.go +++ /dev/null @@ -1,79 +0,0 @@ -package erratic - -import ( - "context" - "testing" - - "github.com/coredns/coredns/plugin/pkg/dnstest" - "github.com/coredns/coredns/plugin/test" - - "github.com/miekg/dns" -) - -func TestErraticDrop(t *testing.T) { - e := &Erratic{drop: 2} // 50% drops - - tests := []struct { - expectedCode int - expectedErr error - drop bool - }{ - {expectedCode: dns.RcodeSuccess, expectedErr: nil, drop: true}, - {expectedCode: dns.RcodeSuccess, expectedErr: nil, drop: false}, - } - - ctx := context.TODO() - - for i, tc := range tests { - req := new(dns.Msg) - req.SetQuestion("example.org.", dns.TypeA) - - rec := dnstest.NewRecorder(&test.ResponseWriter{}) - code, err := e.ServeDNS(ctx, rec, req) - - if err != tc.expectedErr { - t.Errorf("Test %d: Expected error %q, but got %q", i, tc.expectedErr, err) - } - if code != int(tc.expectedCode) { - t.Errorf("Test %d: Expected status code %d, but got %d", i, tc.expectedCode, code) - } - - if tc.drop && rec.Msg != nil { - t.Errorf("Test %d: Expected dropped message, but got %q", i, rec.Msg.Question[0].Name) - } - } -} - -func TestErraticTruncate(t *testing.T) { - e := &Erratic{truncate: 2} // 50% drops - - tests := []struct { - expectedCode int - expectedErr error - truncate bool - }{ - {expectedCode: dns.RcodeSuccess, expectedErr: nil, truncate: true}, - {expectedCode: dns.RcodeSuccess, expectedErr: nil, truncate: false}, - } - - ctx := context.TODO() - - for i, tc := range tests { - req := new(dns.Msg) - req.SetQuestion("example.org.", dns.TypeA) - - rec := dnstest.NewRecorder(&test.ResponseWriter{}) - code, err := e.ServeDNS(ctx, rec, req) - - if err != tc.expectedErr { - t.Errorf("Test %d: Expected error %q, but got %q", i, tc.expectedErr, err) - } - if code != int(tc.expectedCode) { - t.Errorf("Test %d: Expected status code %d, but got %d", i, tc.expectedCode, code) - } - - if tc.truncate && !rec.Msg.Truncated { - t.Errorf("Test %d: Expected truncated message, but got %q", i, rec.Msg.Question[0].Name) - } - } -} diff --git a/vendor/github.com/coredns/coredns/plugin/erratic/health.go b/vendor/github.com/coredns/coredns/plugin/erratic/health.go deleted file mode 100644 index 1d9625e1..00000000 --- a/vendor/github.com/coredns/coredns/plugin/erratic/health.go +++ /dev/null @@ -1,14 +0,0 @@ -package erratic - -import ( - "sync/atomic" -) - -// Health implements the health.Healther interface. -func (e *Erratic) Health() bool { - q := atomic.LoadUint64(&e.q) - if e.drop > 0 && q%e.drop == 0 { - return false - } - return true -} diff --git a/vendor/github.com/coredns/coredns/plugin/erratic/setup.go b/vendor/github.com/coredns/coredns/plugin/erratic/setup.go deleted file mode 100644 index 52c4d245..00000000 --- a/vendor/github.com/coredns/coredns/plugin/erratic/setup.go +++ /dev/null @@ -1,117 +0,0 @@ -package erratic - -import ( - "fmt" - "strconv" - "time" - - "github.com/coredns/coredns/core/dnsserver" - "github.com/coredns/coredns/plugin" - - "github.com/mholt/caddy" -) - -func init() { - caddy.RegisterPlugin("erratic", caddy.Plugin{ - ServerType: "dns", - Action: setup, - }) -} - -func setup(c *caddy.Controller) error { - e, err := parseErratic(c) - if err != nil { - return plugin.Error("erratic", err) - } - - dnsserver.GetConfig(c).AddPlugin(func(next plugin.Handler) plugin.Handler { - return e - }) - - return nil -} - -func parseErratic(c *caddy.Controller) (*Erratic, error) { - e := &Erratic{drop: 2} - drop := false // true if we've seen the drop keyword - - for c.Next() { // 'erratic' - for c.NextBlock() { - switch c.Val() { - case "drop": - args := c.RemainingArgs() - if len(args) > 1 { - return nil, c.ArgErr() - } - - if len(args) == 0 { - continue - } - - amount, err := strconv.ParseInt(args[0], 10, 32) - if err != nil { - return nil, err - } - if amount < 0 { - return nil, fmt.Errorf("illegal amount value given %q", args[0]) - } - e.drop = uint64(amount) - drop = true - case "delay": - args := c.RemainingArgs() - if len(args) > 2 { - return nil, c.ArgErr() - } - - // Defaults. - e.delay = 2 - e.duration = 100 * time.Millisecond - if len(args) == 0 { - continue - } - - amount, err := strconv.ParseInt(args[0], 10, 32) - if err != nil { - return nil, err - } - if amount < 0 { - return nil, fmt.Errorf("illegal amount value given %q", args[0]) - } - e.delay = uint64(amount) - - if len(args) > 1 { - duration, err := time.ParseDuration(args[1]) - if err != nil { - return nil, err - } - e.duration = duration - } - case "truncate": - args := c.RemainingArgs() - if len(args) > 1 { - return nil, c.ArgErr() - } - - if len(args) == 0 { - continue - } - - amount, err := strconv.ParseInt(args[0], 10, 32) - if err != nil { - return nil, err - } - if amount < 0 { - return nil, fmt.Errorf("illegal amount value given %q", args[0]) - } - e.truncate = uint64(amount) - default: - return nil, c.Errf("unknown property '%s'", c.Val()) - } - } - } - if (e.delay > 0 || e.truncate > 0) && !drop { // delay is set, but we've haven't seen a drop keyword, remove default drop stuff - e.drop = 0 - } - - return e, nil -} diff --git a/vendor/github.com/coredns/coredns/plugin/erratic/setup_test.go b/vendor/github.com/coredns/coredns/plugin/erratic/setup_test.go deleted file mode 100644 index 4ff9bacd..00000000 --- a/vendor/github.com/coredns/coredns/plugin/erratic/setup_test.go +++ /dev/null @@ -1,103 +0,0 @@ -package erratic - -import ( - "testing" - - "github.com/mholt/caddy" -) - -func TestSetup(t *testing.T) { - c := caddy.NewTestController("dns", `erratic { - drop - }`) - if err := setup(c); err != nil { - t.Fatalf("Test 1, expected no errors, but got: %q", err) - } - - c = caddy.NewTestController("dns", `erratic`) - if err := setup(c); err != nil { - t.Fatalf("Test 2, expected no errors, but got: %q", err) - } - - c = caddy.NewTestController("dns", `erratic { - drop -1 - }`) - if err := setup(c); err == nil { - t.Fatalf("Test 4, expected errors, but got: %q", err) - } -} - -func TestParseErratic(t *testing.T) { - tests := []struct { - input string - shouldErr bool - drop uint64 - delay uint64 - truncate uint64 - }{ - // oks - {`erratic`, false, 2, 0, 0}, - {`erratic { - drop 2 - delay 3 1ms - - }`, false, 2, 3, 0}, - {`erratic { - truncate 2 - delay 3 1ms - - }`, false, 0, 3, 2}, - {`erraric { - drop 3 - delay - }`, false, 3, 2, 0}, - // fails - {`erratic { - drop -1 - }`, true, 0, 0, 0}, - {`erratic { - delay -1 - }`, true, 0, 0, 0}, - {`erratic { - delay 1 2 4 - }`, true, 0, 0, 0}, - {`erratic { - delay 15.a - }`, true, 0, 0, 0}, - {`erraric { - drop 3 - delay 3 bla - }`, true, 0, 0, 0}, - {`erraric { - truncate 15.a - }`, true, 0, 0, 0}, - {`erraric { - something-else - }`, true, 0, 0, 0}, - } - for i, test := range tests { - c := caddy.NewTestController("dns", test.input) - e, err := parseErratic(c) - if test.shouldErr && err == nil { - t.Errorf("Test %v: Expected error but found nil", i) - continue - } else if !test.shouldErr && err != nil { - t.Errorf("Test %v: Expected no error but found error: %v", i, err) - continue - } - - if test.shouldErr { - continue - } - - if test.delay != e.delay { - t.Errorf("Test %v: Expected delay %d but found: %d", i, test.delay, e.delay) - } - if test.drop != e.drop { - t.Errorf("Test %v: Expected drop %d but found: %d", i, test.drop, e.drop) - } - if test.truncate != e.truncate { - t.Errorf("Test %v: Expected truncate %d but found: %d", i, test.truncate, e.truncate) - } - } -} diff --git a/vendor/github.com/coredns/coredns/plugin/errors/OWNERS b/vendor/github.com/coredns/coredns/plugin/errors/OWNERS deleted file mode 100644 index eee46f68..00000000 --- a/vendor/github.com/coredns/coredns/plugin/errors/OWNERS +++ /dev/null @@ -1,4 +0,0 @@ -reviewers: - - miekg -approvers: - - miekg diff --git a/vendor/github.com/coredns/coredns/plugin/errors/README.md b/vendor/github.com/coredns/coredns/plugin/errors/README.md deleted file mode 100644 index f15b271f..00000000 --- a/vendor/github.com/coredns/coredns/plugin/errors/README.md +++ /dev/null @@ -1,28 +0,0 @@ -# errors - -## Name - -*errors* - enable error logging. - -## Description - -Any errors encountered during the query processing will be printed to standard output. - -This plugin can only be used once per Server Block. - -## Syntax - -~~~ -errors -~~~ - -## Examples - -Use the *whoami* to respond to queries and Log errors to standard output. - -~~~ corefile -. { - whoami - errors -} -~~~ diff --git a/vendor/github.com/coredns/coredns/plugin/errors/errors.go b/vendor/github.com/coredns/coredns/plugin/errors/errors.go deleted file mode 100644 index 88027b19..00000000 --- a/vendor/github.com/coredns/coredns/plugin/errors/errors.go +++ /dev/null @@ -1,29 +0,0 @@ -// Package errors implements an HTTP error handling plugin. -package errors - -import ( - "context" - - "github.com/coredns/coredns/plugin" - clog "github.com/coredns/coredns/plugin/pkg/log" - "github.com/coredns/coredns/request" - - "github.com/miekg/dns" -) - -// errorHandler handles DNS errors (and errors from other plugin). -type errorHandler struct{ Next plugin.Handler } - -// ServeDNS implements the plugin.Handler interface. -func (h errorHandler) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (int, error) { - rcode, err := plugin.NextOrFailure(h.Name(), h.Next, ctx, w, r) - - if err != nil { - state := request.Request{W: w, Req: r} - clog.Errorf("%d %s %s: %v", rcode, state.Name(), state.Type(), err) - } - - return rcode, err -} - -func (h errorHandler) Name() string { return "errors" } diff --git a/vendor/github.com/coredns/coredns/plugin/errors/errors_test.go b/vendor/github.com/coredns/coredns/plugin/errors/errors_test.go deleted file mode 100644 index afe809c7..00000000 --- a/vendor/github.com/coredns/coredns/plugin/errors/errors_test.go +++ /dev/null @@ -1,74 +0,0 @@ -package errors - -import ( - "bytes" - "context" - "errors" - "fmt" - "log" - "strings" - "testing" - - "github.com/coredns/coredns/plugin" - "github.com/coredns/coredns/plugin/pkg/dnstest" - "github.com/coredns/coredns/plugin/test" - - "github.com/miekg/dns" -) - -func TestErrors(t *testing.T) { - buf := bytes.Buffer{} - log.SetOutput(&buf) - em := errorHandler{} - - testErr := errors.New("test error") - tests := []struct { - next plugin.Handler - expectedCode int - expectedLog string - expectedErr error - }{ - { - next: genErrorHandler(dns.RcodeSuccess, nil), - expectedCode: dns.RcodeSuccess, - expectedLog: "", - expectedErr: nil, - }, - { - next: genErrorHandler(dns.RcodeNotAuth, testErr), - expectedCode: dns.RcodeNotAuth, - expectedLog: fmt.Sprintf("[ERROR] %d %s: %v\n", dns.RcodeNotAuth, "example.org. A", testErr), - expectedErr: testErr, - }, - } - - ctx := context.TODO() - req := new(dns.Msg) - req.SetQuestion("example.org.", dns.TypeA) - - for i, tc := range tests { - em.Next = tc.next - buf.Reset() - rec := dnstest.NewRecorder(&test.ResponseWriter{}) - code, err := em.ServeDNS(ctx, rec, req) - - if err != tc.expectedErr { - t.Errorf("Test %d: Expected error %v, but got %v", - i, tc.expectedErr, err) - } - if code != tc.expectedCode { - t.Errorf("Test %d: Expected status code %d, but got %d", - i, tc.expectedCode, code) - } - if log := buf.String(); !strings.Contains(log, tc.expectedLog) { - t.Errorf("Test %d: Expected log %q, but got %q", - i, tc.expectedLog, log) - } - } -} - -func genErrorHandler(rcode int, err error) plugin.Handler { - return plugin.HandlerFunc(func(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (int, error) { - return rcode, err - }) -} diff --git a/vendor/github.com/coredns/coredns/plugin/errors/setup.go b/vendor/github.com/coredns/coredns/plugin/errors/setup.go deleted file mode 100644 index d90928f7..00000000 --- a/vendor/github.com/coredns/coredns/plugin/errors/setup.go +++ /dev/null @@ -1,55 +0,0 @@ -package errors - -import ( - "fmt" - - "github.com/coredns/coredns/core/dnsserver" - "github.com/coredns/coredns/plugin" - - "github.com/mholt/caddy" -) - -func init() { - caddy.RegisterPlugin("errors", caddy.Plugin{ - ServerType: "dns", - Action: setup, - }) -} - -func setup(c *caddy.Controller) error { - handler, err := errorsParse(c) - if err != nil { - return plugin.Error("errors", err) - } - - dnsserver.GetConfig(c).AddPlugin(func(next plugin.Handler) plugin.Handler { - handler.Next = next - return handler - }) - - return nil -} - -func errorsParse(c *caddy.Controller) (errorHandler, error) { - handler := errorHandler{} - - i := 0 - for c.Next() { - if i > 0 { - return handler, plugin.ErrOnce - } - i++ - - args := c.RemainingArgs() - switch len(args) { - case 0: - case 1: - if args[0] != "stdout" { - return handler, fmt.Errorf("invalid log file: %s", args[0]) - } - default: - return handler, c.ArgErr() - } - } - return handler, nil -} diff --git a/vendor/github.com/coredns/coredns/plugin/errors/setup_test.go b/vendor/github.com/coredns/coredns/plugin/errors/setup_test.go deleted file mode 100644 index 3cfd7c03..00000000 --- a/vendor/github.com/coredns/coredns/plugin/errors/setup_test.go +++ /dev/null @@ -1,33 +0,0 @@ -package errors - -import ( - "testing" - - "github.com/mholt/caddy" -) - -func TestErrorsParse(t *testing.T) { - tests := []struct { - inputErrorsRules string - shouldErr bool - }{ - {`errors`, false}, - {`errors stdout`, false}, - {`errors errors.txt`, true}, - {`errors visible`, true}, - {`errors { log visible }`, true}, - {`errors - errors `, true}, - {`errors a b`, true}, - } - for i, test := range tests { - c := caddy.NewTestController("dns", test.inputErrorsRules) - _, err := errorsParse(c) - - if err == nil && test.shouldErr { - t.Errorf("Test %d didn't error, but it should have", i) - } else if err != nil && !test.shouldErr { - t.Errorf("Test %d errored, but it shouldn't have; got '%v'", i, err) - } - } -} diff --git a/vendor/github.com/coredns/coredns/plugin/etcd/OWNERS b/vendor/github.com/coredns/coredns/plugin/etcd/OWNERS deleted file mode 100644 index eee46f68..00000000 --- a/vendor/github.com/coredns/coredns/plugin/etcd/OWNERS +++ /dev/null @@ -1,4 +0,0 @@ -reviewers: - - miekg -approvers: - - miekg diff --git a/vendor/github.com/coredns/coredns/plugin/etcd/README.md b/vendor/github.com/coredns/coredns/plugin/etcd/README.md deleted file mode 100644 index 2306729b..00000000 --- a/vendor/github.com/coredns/coredns/plugin/etcd/README.md +++ /dev/null @@ -1,175 +0,0 @@ -# etcd - -## Name - -*etcd* - enables reading zone data from an etcd instance. - -## Description - -The data in etcd has to be encoded as -a [message](https://github.com/skynetservices/skydns/blob/2fcff74cdc9f9a7dd64189a447ef27ac354b725f/msg/service.go#L26) -like [SkyDNS](https://github.com/skynetservices/skydns). It should also work just like SkyDNS. - -The etcd plugin makes extensive use of the proxy plugin to forward and query other servers in the -network. - -## Syntax - -~~~ -etcd [ZONES...] -~~~ - -* **ZONES** zones etcd should be authoritative for. - -The path will default to `/skydns` the local etcd proxy (http://localhost:2379). If no zones are -specified the block's zone will be used as the zone. - -If you want to `round robin` A and AAAA responses look at the `loadbalance` plugin. - -~~~ -etcd [ZONES...] { - stubzones - fallthrough [ZONES...] - path PATH - endpoint ENDPOINT... - upstream [ADDRESS...] - tls CERT KEY CACERT -} -~~~ - -* `stubzones` enables the stub zones feature. The stubzone is *only* done in the etcd tree located - under the *first* zone specified. -* `fallthrough` If zone matches but no record can be generated, pass request to the next plugin. - If **[ZONES...]** is omitted, then fallthrough happens for all zones for which the plugin - is authoritative. If specific zones are listed (for example `in-addr.arpa` and `ip6.arpa`), then only - queries for those zones will be subject to fallthrough. -* **PATH** the path inside etcd. Defaults to "/skydns". -* **ENDPOINT** the etcd endpoints. Defaults to "http://localhost:2379". -* `upstream` upstream resolvers to be used resolve external names found in etcd (think CNAMEs) - pointing to external names. If you want CoreDNS to act as a proxy for clients, you'll need to add - the proxy plugin. If no **ADDRESS** is given, CoreDNS will resolve CNAMEs against itself. - **ADDRESS** can be an IP address, and IP:port or a string pointing to a file that is structured - as /etc/resolv.conf. -* `tls` followed by: - - * no arguments, if the server certificate is signed by a system-installed CA and no client cert is needed - * a single argument that is the CA PEM file, if the server cert is not signed by a system CA and no client cert is needed - * two arguments - path to cert PEM file, the path to private key PEM file - if the server certificate is signed by a system-installed CA and a client certificate is needed - * three arguments - path to cert PEM file, path to client private key PEM file, path to CA PEM - file - if the server certificate is not signed by a system-installed CA and client certificate - is needed. - -## Examples - -This is the default SkyDNS setup, with everying specified in full: - -~~~ corefile -. { - etcd skydns.local { - stubzones - path /skydns - endpoint http://localhost:2379 - upstream 8.8.8.8:53 8.8.4.4:53 - } - prometheus - cache 160 skydns.local - loadbalance - proxy . 8.8.8.8:53 8.8.4.4:53 -} -~~~ - -Or a setup where we use `/etc/resolv.conf` as the basis for the proxy and the upstream -when resolving external pointing CNAMEs. - -~~~ corefile -. { - etcd skydns.local { - path /skydns - upstream /etc/resolv.conf - } - cache 160 skydns.local - proxy . /etc/resolv.conf -} -~~~ - -Multiple endpoints are supported as well. - -~~~ -etcd skydns.local { - endpoint http://localhost:2379 http://localhost:4001 -... -~~~ - - -### Reverse zones - -Reverse zones are supported. You need to make CoreDNS aware of the fact that you are also -authoritative for the reverse. For instance if you want to add the reverse for 10.0.0.0/24, you'll -need to add the zone `0.0.10.in-addr.arpa` to the list of zones. Showing a snippet of a Corefile: - -~~~ -etcd skydns.local 10.0.0.0/24 { - stubzones -... -~~~ - -Next you'll need to populate the zone with reverse records, here we add a reverse for -10.0.0.127 pointing to reverse.skydns.local. - -~~~ -% curl -XPUT http://127.0.0.1:4001/v2/keys/skydns/arpa/in-addr/10/0/0/127 \ - -d value='{"host":"reverse.skydns.local."}' -~~~ - -Querying with dig: - -~~~ sh -% dig @localhost -x 10.0.0.127 +short -reverse.skydns.local. -~~~ - -### Zone name as A record - -The zone name itself can be used A record. This behavior can be achieved by writing special entries to the ETCD path of your zone. If your zone is named `skydns.local` for example, you can create an `A` record for this zone as follows: - -~~~ -% curl -XPUT http://127.0.0.1:2379/v2/keys/skydns/local/skydns/dns/apex -d value='{"host":"1.1.1.1","ttl":"60"}' -~~~ - -If you query the zone name itself, you will receive the created `A` record: - -~~~ sh -% dig +short skydns.local @localhost -1.1.1.1 -~~~ - -If you would like to use DNS RR for the zone name, you can set the following: -~~~ -% curl -XPUT http://127.0.0.1:2379/v2/keys/skydns/local/skydns/dns/apex/x1 -d value='{"host":"1.1.1.1","ttl":"60"}' -% curl -XPUT http://127.0.0.1:2379/v2/keys/skydns/local/skydns/dns/apex/x2 -d value='{"host":"1.1.1.2","ttl":"60"}' -~~~ - -If you query the zone name now, you will get the following response: - -~~~ sh -dig +short skydns.local @localhost -1.1.1.1 -1.1.1.2 -~~~ - -If you would like to use `AAAA` records for the zone name too, you can set the following: -~~~ -% curl -XPUT http://127.0.0.1:2379/v2/keys/skydns/local/skydns/dns/apex/x3 -d value='{"host":"2003::8:1","ttl":"60"}' -% curl -XPUT http://127.0.0.1:2379/v2/keys/skydns/local/skydns/dns/apex/x4 -d value='{"host":"2003::8:2","ttl":"60"}' -~~~ - -If you query the zone name now for `AAAA` now, you will get the following response: -~~~ sh -dig +short skydns.local AAAA @localhost -2003::8:1 -2003::8:2 -~~~ - -## Bugs - -Only the etcdv2 protocol is supported. diff --git a/vendor/github.com/coredns/coredns/plugin/etcd/cname_test.go b/vendor/github.com/coredns/coredns/plugin/etcd/cname_test.go deleted file mode 100644 index bf27573c..00000000 --- a/vendor/github.com/coredns/coredns/plugin/etcd/cname_test.go +++ /dev/null @@ -1,79 +0,0 @@ -// +build etcd - -package etcd - -// etcd needs to be running on http://localhost:2379 - -import ( - "testing" - - "github.com/coredns/coredns/plugin/etcd/msg" - "github.com/coredns/coredns/plugin/pkg/dnstest" - "github.com/coredns/coredns/plugin/test" - - "github.com/miekg/dns" -) - -// Check the ordering of returned cname. -func TestCnameLookup(t *testing.T) { - etc := newEtcdPlugin() - - for _, serv := range servicesCname { - set(t, etc, serv.Key, 0, serv) - defer delete(t, etc, serv.Key) - } - for _, tc := range dnsTestCasesCname { - m := tc.Msg() - - rec := dnstest.NewRecorder(&test.ResponseWriter{}) - _, err := etc.ServeDNS(ctxt, rec, m) - if err != nil { - t.Errorf("Expected no error, got %v\n", err) - return - } - - resp := rec.Msg - if !test.Header(t, tc, resp) { - t.Logf("%v\n", resp) - continue - } - if !test.Section(t, tc, test.Answer, resp.Answer) { - t.Logf("%v\n", resp) - } - if !test.Section(t, tc, test.Ns, resp.Ns) { - t.Logf("%v\n", resp) - } - if !test.Section(t, tc, test.Extra, resp.Extra) { - t.Logf("%v\n", resp) - } - } -} - -var servicesCname = []*msg.Service{ - {Host: "cname1.region2.skydns.test", Key: "a.server1.dev.region1.skydns.test."}, - {Host: "cname2.region2.skydns.test", Key: "cname1.region2.skydns.test."}, - {Host: "cname3.region2.skydns.test", Key: "cname2.region2.skydns.test."}, - {Host: "cname4.region2.skydns.test", Key: "cname3.region2.skydns.test."}, - {Host: "cname5.region2.skydns.test", Key: "cname4.region2.skydns.test."}, - {Host: "cname6.region2.skydns.test", Key: "cname5.region2.skydns.test."}, - {Host: "endpoint.region2.skydns.test", Key: "cname6.region2.skydns.test."}, - {Host: "10.240.0.1", Key: "endpoint.region2.skydns.test."}, -} - -var dnsTestCasesCname = []test.Case{ - { - Qname: "a.server1.dev.region1.skydns.test.", Qtype: dns.TypeSRV, - Answer: []dns.RR{ - test.SRV("a.server1.dev.region1.skydns.test. 300 IN SRV 10 100 0 cname1.region2.skydns.test."), - }, - Extra: []dns.RR{ - test.CNAME("cname1.region2.skydns.test. 300 IN CNAME cname2.region2.skydns.test."), - test.CNAME("cname2.region2.skydns.test. 300 IN CNAME cname3.region2.skydns.test."), - test.CNAME("cname3.region2.skydns.test. 300 IN CNAME cname4.region2.skydns.test."), - test.CNAME("cname4.region2.skydns.test. 300 IN CNAME cname5.region2.skydns.test."), - test.CNAME("cname5.region2.skydns.test. 300 IN CNAME cname6.region2.skydns.test."), - test.CNAME("cname6.region2.skydns.test. 300 IN CNAME endpoint.region2.skydns.test."), - test.A("endpoint.region2.skydns.test. 300 IN A 10.240.0.1"), - }, - }, -} diff --git a/vendor/github.com/coredns/coredns/plugin/etcd/etcd.go b/vendor/github.com/coredns/coredns/plugin/etcd/etcd.go deleted file mode 100644 index fc4542bf..00000000 --- a/vendor/github.com/coredns/coredns/plugin/etcd/etcd.go +++ /dev/null @@ -1,178 +0,0 @@ -// Package etcd provides the etcd backend plugin. -package etcd - -import ( - "context" - "encoding/json" - "fmt" - "strings" - "time" - - "github.com/coredns/coredns/plugin" - "github.com/coredns/coredns/plugin/etcd/msg" - "github.com/coredns/coredns/plugin/pkg/fall" - "github.com/coredns/coredns/plugin/proxy" - "github.com/coredns/coredns/request" - - "github.com/coredns/coredns/plugin/pkg/upstream" - etcdc "github.com/coreos/etcd/client" - "github.com/miekg/dns" -) - -// Etcd is a plugin talks to an etcd cluster. -type Etcd struct { - Next plugin.Handler - Fall fall.F - Zones []string - PathPrefix string - Upstream upstream.Upstream // Proxy for looking up names during the resolution process - Client etcdc.KeysAPI - Ctx context.Context - Stubmap *map[string]proxy.Proxy // list of proxies for stub resolving. - - endpoints []string // Stored here as well, to aid in testing. -} - -// Services implements the ServiceBackend interface. -func (e *Etcd) Services(state request.Request, exact bool, opt plugin.Options) (services []msg.Service, err error) { - services, err = e.Records(state, exact) - if err != nil { - return - } - - services = msg.Group(services) - return -} - -// Reverse implements the ServiceBackend interface. -func (e *Etcd) Reverse(state request.Request, exact bool, opt plugin.Options) (services []msg.Service, err error) { - return e.Services(state, exact, opt) -} - -// Lookup implements the ServiceBackend interface. -func (e *Etcd) Lookup(state request.Request, name string, typ uint16) (*dns.Msg, error) { - return e.Upstream.Lookup(state, name, typ) -} - -// IsNameError implements the ServiceBackend interface. -func (e *Etcd) IsNameError(err error) bool { - if ee, ok := err.(etcdc.Error); ok && ee.Code == etcdc.ErrorCodeKeyNotFound { - return true - } - return false -} - -// Records looks up records in etcd. If exact is true, it will lookup just this -// name. This is used when find matches when completing SRV lookups for instance. -func (e *Etcd) Records(state request.Request, exact bool) ([]msg.Service, error) { - name := state.Name() - - path, star := msg.PathWithWildcard(name, e.PathPrefix) - r, err := e.get(path, true) - if err != nil { - return nil, err - } - segments := strings.Split(msg.Path(name, e.PathPrefix), "/") - switch { - case exact && r.Node.Dir: - return nil, nil - case r.Node.Dir: - return e.loopNodes(r.Node.Nodes, segments, star, nil) - default: - return e.loopNodes([]*etcdc.Node{r.Node}, segments, false, nil) - } -} - -// get is a wrapper for client.Get -func (e *Etcd) get(path string, recursive bool) (*etcdc.Response, error) { - ctx, cancel := context.WithTimeout(e.Ctx, etcdTimeout) - defer cancel() - r, err := e.Client.Get(ctx, path, &etcdc.GetOptions{Sort: false, Recursive: recursive}) - if err != nil { - return nil, err - } - return r, nil -} - -// skydns/local/skydns/east/staging/web -// skydns/local/skydns/west/production/web -// -// skydns/local/skydns/*/*/web -// skydns/local/skydns/*/web - -// loopNodes recursively loops through the nodes and returns all the values. The nodes' keyname -// will be match against any wildcards when star is true. -func (e *Etcd) loopNodes(ns []*etcdc.Node, nameParts []string, star bool, bx map[msg.Service]bool) (sx []msg.Service, err error) { - if bx == nil { - bx = make(map[msg.Service]bool) - } -Nodes: - for _, n := range ns { - if n.Dir { - nodes, err := e.loopNodes(n.Nodes, nameParts, star, bx) - if err != nil { - return nil, err - } - sx = append(sx, nodes...) - continue - } - if star { - keyParts := strings.Split(n.Key, "/") - for i, n := range nameParts { - if i > len(keyParts)-1 { - // name is longer than key - continue Nodes - } - if n == "*" || n == "any" { - continue - } - if keyParts[i] != n { - continue Nodes - } - } - } - serv := new(msg.Service) - if err := json.Unmarshal([]byte(n.Value), serv); err != nil { - return nil, fmt.Errorf("%s: %s", n.Key, err.Error()) - } - b := msg.Service{Host: serv.Host, Port: serv.Port, Priority: serv.Priority, Weight: serv.Weight, Text: serv.Text, Key: n.Key} - if _, ok := bx[b]; ok { - continue - } - bx[b] = true - - serv.Key = n.Key - serv.TTL = e.TTL(n, serv) - if serv.Priority == 0 { - serv.Priority = priority - } - sx = append(sx, *serv) - } - return sx, nil -} - -// TTL returns the smaller of the etcd TTL and the service's -// TTL. If neither of these are set (have a zero value), a default is used. -func (e *Etcd) TTL(node *etcdc.Node, serv *msg.Service) uint32 { - etcdTTL := uint32(node.TTL) - - if etcdTTL == 0 && serv.TTL == 0 { - return ttl - } - if etcdTTL == 0 { - return serv.TTL - } - if serv.TTL == 0 { - return etcdTTL - } - if etcdTTL < serv.TTL { - return etcdTTL - } - return serv.TTL -} - -const ( - priority = 10 // default priority when nothing is set - ttl = 300 // default ttl when nothing is set - etcdTimeout = 5 * time.Second -) diff --git a/vendor/github.com/coredns/coredns/plugin/etcd/group_test.go b/vendor/github.com/coredns/coredns/plugin/etcd/group_test.go deleted file mode 100644 index f5493dc1..00000000 --- a/vendor/github.com/coredns/coredns/plugin/etcd/group_test.go +++ /dev/null @@ -1,74 +0,0 @@ -// +build etcd - -package etcd - -import ( - "testing" - - "github.com/coredns/coredns/plugin/etcd/msg" - "github.com/coredns/coredns/plugin/pkg/dnstest" - "github.com/coredns/coredns/plugin/test" - - "github.com/miekg/dns" -) - -func TestGroupLookup(t *testing.T) { - etc := newEtcdPlugin() - - for _, serv := range servicesGroup { - set(t, etc, serv.Key, 0, serv) - defer delete(t, etc, serv.Key) - } - for _, tc := range dnsTestCasesGroup { - m := tc.Msg() - - rec := dnstest.NewRecorder(&test.ResponseWriter{}) - _, err := etc.ServeDNS(ctxt, rec, m) - if err != nil { - t.Errorf("Expected no error, got %v\n", err) - continue - } - - resp := rec.Msg - test.SortAndCheck(t, resp, tc) - } -} - -// Note the key is encoded as DNS name, while in "reality" it is a etcd path. -var servicesGroup = []*msg.Service{ - {Host: "127.0.0.1", Key: "a.dom.skydns.test.", Group: "g1"}, - {Host: "127.0.0.2", Key: "b.sub.dom.skydns.test.", Group: "g1"}, - - {Host: "127.0.0.1", Key: "a.dom2.skydns.test.", Group: "g1"}, - {Host: "127.0.0.2", Key: "b.sub.dom2.skydns.test.", Group: ""}, - - {Host: "127.0.0.1", Key: "a.dom1.skydns.test.", Group: "g1"}, - {Host: "127.0.0.2", Key: "b.sub.dom1.skydns.test.", Group: "g2"}, -} - -var dnsTestCasesGroup = []test.Case{ - // Groups - { - // hits the group 'g1' and only includes those records - Qname: "dom.skydns.test.", Qtype: dns.TypeA, - Answer: []dns.RR{ - test.A("dom.skydns.test. 300 IN A 127.0.0.1"), - test.A("dom.skydns.test. 300 IN A 127.0.0.2"), - }, - }, - { - // One has group, the other has not... Include the non-group always. - Qname: "dom2.skydns.test.", Qtype: dns.TypeA, - Answer: []dns.RR{ - test.A("dom2.skydns.test. 300 IN A 127.0.0.1"), - test.A("dom2.skydns.test. 300 IN A 127.0.0.2"), - }, - }, - { - // The groups differ. - Qname: "dom1.skydns.test.", Qtype: dns.TypeA, - Answer: []dns.RR{ - test.A("dom1.skydns.test. 300 IN A 127.0.0.1"), - }, - }, -} diff --git a/vendor/github.com/coredns/coredns/plugin/etcd/handler.go b/vendor/github.com/coredns/coredns/plugin/etcd/handler.go deleted file mode 100644 index 8520680d..00000000 --- a/vendor/github.com/coredns/coredns/plugin/etcd/handler.go +++ /dev/null @@ -1,97 +0,0 @@ -package etcd - -import ( - "context" - - "github.com/coredns/coredns/plugin" - "github.com/coredns/coredns/request" - - "github.com/miekg/dns" -) - -// ServeDNS implements the plugin.Handler interface. -func (e *Etcd) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (int, error) { - opt := plugin.Options{} - state := request.Request{W: w, Req: r, Context: ctx} - - name := state.Name() - - // We need to check stubzones first, because we may get a request for a zone we - // are not auth. for *but* do have a stubzone forward for. If we do the stubzone - // handler will handle the request. - if e.Stubmap != nil && len(*e.Stubmap) > 0 { - for zone := range *e.Stubmap { - if plugin.Name(zone).Matches(name) { - stub := Stub{Etcd: e, Zone: zone} - return stub.ServeDNS(ctx, w, r) - } - } - } - - zone := plugin.Zones(e.Zones).Matches(state.Name()) - if zone == "" { - return plugin.NextOrFailure(e.Name(), e.Next, ctx, w, r) - } - - var ( - records, extra []dns.RR - err error - ) - - switch state.QType() { - case dns.TypeA: - records, err = plugin.A(e, zone, state, nil, opt) - case dns.TypeAAAA: - records, err = plugin.AAAA(e, zone, state, nil, opt) - case dns.TypeTXT: - records, err = plugin.TXT(e, zone, state, opt) - case dns.TypeCNAME: - records, err = plugin.CNAME(e, zone, state, opt) - case dns.TypePTR: - records, err = plugin.PTR(e, zone, state, opt) - case dns.TypeMX: - records, extra, err = plugin.MX(e, zone, state, opt) - case dns.TypeSRV: - records, extra, err = plugin.SRV(e, zone, state, opt) - case dns.TypeSOA: - records, err = plugin.SOA(e, zone, state, opt) - case dns.TypeNS: - if state.Name() == zone { - records, extra, err = plugin.NS(e, zone, state, opt) - break - } - fallthrough - default: - // Do a fake A lookup, so we can distinguish between NODATA and NXDOMAIN - _, err = plugin.A(e, zone, state, nil, opt) - } - - if e.IsNameError(err) { - if e.Fall.Through(state.Name()) { - return plugin.NextOrFailure(e.Name(), e.Next, ctx, w, r) - } - // Make err nil when returning here, so we don't log spam for NXDOMAIN. - return plugin.BackendError(e, zone, dns.RcodeNameError, state, nil /* err */, opt) - } - if err != nil { - return plugin.BackendError(e, zone, dns.RcodeServerFailure, state, err, opt) - } - - if len(records) == 0 { - return plugin.BackendError(e, zone, dns.RcodeSuccess, state, err, opt) - } - - m := new(dns.Msg) - m.SetReply(r) - m.Authoritative, m.RecursionAvailable = true, true - m.Answer = append(m.Answer, records...) - m.Extra = append(m.Extra, extra...) - - state.SizeAndDo(m) - m, _ = state.Scrub(m) - w.WriteMsg(m) - return dns.RcodeSuccess, nil -} - -// Name implements the Handler interface. -func (e *Etcd) Name() string { return "etcd" } diff --git a/vendor/github.com/coredns/coredns/plugin/etcd/lookup_test.go b/vendor/github.com/coredns/coredns/plugin/etcd/lookup_test.go deleted file mode 100644 index 51e4b954..00000000 --- a/vendor/github.com/coredns/coredns/plugin/etcd/lookup_test.go +++ /dev/null @@ -1,329 +0,0 @@ -// +build etcd - -package etcd - -import ( - "context" - "encoding/json" - "testing" - "time" - - "github.com/coredns/coredns/plugin/etcd/msg" - "github.com/coredns/coredns/plugin/pkg/dnstest" - "github.com/coredns/coredns/plugin/pkg/tls" - "github.com/coredns/coredns/plugin/pkg/upstream" - "github.com/coredns/coredns/plugin/proxy" - "github.com/coredns/coredns/plugin/test" - - etcdc "github.com/coreos/etcd/client" - "github.com/miekg/dns" -) - -func init() { - ctxt = context.TODO() -} - -// Note the key is encoded as DNS name, while in "reality" it is a etcd path. -var services = []*msg.Service{ - {Host: "dev.server1", Port: 8080, Key: "a.server1.dev.region1.skydns.test."}, - {Host: "10.0.0.1", Port: 8080, Key: "a.server1.prod.region1.skydns.test."}, - {Host: "10.0.0.2", Port: 8080, Key: "b.server1.prod.region1.skydns.test."}, - {Host: "::1", Port: 8080, Key: "b.server6.prod.region1.skydns.test."}, - // Unresolvable internal name. - {Host: "unresolvable.skydns.test", Key: "cname.prod.region1.skydns.test."}, - // Priority. - {Host: "priority.server1", Priority: 333, Port: 8080, Key: "priority.skydns.test."}, - // Subdomain. - {Host: "sub.server1", Port: 0, Key: "a.sub.region1.skydns.test."}, - {Host: "sub.server2", Port: 80, Key: "b.sub.region1.skydns.test."}, - {Host: "10.0.0.1", Port: 8080, Key: "c.sub.region1.skydns.test."}, - // Cname loop. - {Host: "a.cname.skydns.test", Key: "b.cname.skydns.test."}, - {Host: "b.cname.skydns.test", Key: "a.cname.skydns.test."}, - // Nameservers. - {Host: "10.0.0.2", Key: "a.ns.dns.skydns.test."}, - {Host: "10.0.0.3", Key: "b.ns.dns.skydns.test."}, - // Zone name as A record (basic, return all) - {Host: "10.0.0.2", Key: "x.skydns_zonea.test."}, - {Host: "10.0.0.3", Key: "y.skydns_zonea.test."}, - // Zone name as A (single entry). - {Host: "10.0.0.2", Key: "x.skydns_zoneb.test."}, - {Host: "10.0.0.3", Key: "y.skydns_zoneb.test."}, - {Host: "10.0.0.4", Key: "apex.dns.skydns_zoneb.test."}, - // A zone record (rr multiple entries). - {Host: "10.0.0.2", Key: "x.skydns_zonec.test."}, - {Host: "10.0.0.3", Key: "y.skydns_zonec.test."}, - {Host: "10.0.0.4", Key: "a1.apex.dns.skydns_zonec.test."}, - {Host: "10.0.0.5", Key: "a2.apex.dns.skydns_zonec.test."}, - // AAAA zone record (rr multiple entries mixed with A). - {Host: "10.0.0.2", Key: "x.skydns_zoned.test."}, - {Host: "10.0.0.3", Key: "y.skydns_zoned.test."}, - {Host: "10.0.0.4", Key: "a1.apex.dns.skydns_zoned.test."}, - {Host: "10.0.0.5", Key: "a2.apex.dns.skydns_zoned.test."}, - {Host: "2003::8:1", Key: "a3.apex.dns.skydns_zoned.test."}, - {Host: "2003::8:2", Key: "a4.apex.dns.skydns_zoned.test."}, - // Reverse. - {Host: "reverse.example.com", Key: "1.0.0.10.in-addr.arpa."}, // 10.0.0.1 -} - -var dnsTestCases = []test.Case{ - // SRV Test - { - Qname: "a.server1.dev.region1.skydns.test.", Qtype: dns.TypeSRV, - Answer: []dns.RR{test.SRV("a.server1.dev.region1.skydns.test. 300 SRV 10 100 8080 dev.server1.")}, - }, - // SRV Test (case test) - { - Qname: "a.SERVer1.dEv.region1.skydns.tEst.", Qtype: dns.TypeSRV, - Answer: []dns.RR{test.SRV("a.SERVer1.dEv.region1.skydns.tEst. 300 SRV 10 100 8080 dev.server1.")}, - }, - // NXDOMAIN Test - { - Qname: "doesnotexist.skydns.test.", Qtype: dns.TypeA, - Rcode: dns.RcodeNameError, - Ns: []dns.RR{ - test.SOA("skydns.test. 300 SOA ns.dns.skydns.test. hostmaster.skydns.test. 0 0 0 0 0"), - }, - }, - // A Test - { - Qname: "a.server1.prod.region1.skydns.test.", Qtype: dns.TypeA, - Answer: []dns.RR{test.A("a.server1.prod.region1.skydns.test. 300 A 10.0.0.1")}, - }, - // SRV Test where target is IP address - { - Qname: "a.server1.prod.region1.skydns.test.", Qtype: dns.TypeSRV, - Answer: []dns.RR{test.SRV("a.server1.prod.region1.skydns.test. 300 SRV 10 100 8080 a.server1.prod.region1.skydns.test.")}, - Extra: []dns.RR{test.A("a.server1.prod.region1.skydns.test. 300 A 10.0.0.1")}, - }, - // AAAA Test - { - Qname: "b.server6.prod.region1.skydns.test.", Qtype: dns.TypeAAAA, - Answer: []dns.RR{test.AAAA("b.server6.prod.region1.skydns.test. 300 AAAA ::1")}, - }, - // Multiple A Record Test - { - Qname: "server1.prod.region1.skydns.test.", Qtype: dns.TypeA, - Answer: []dns.RR{ - test.A("server1.prod.region1.skydns.test. 300 A 10.0.0.1"), - test.A("server1.prod.region1.skydns.test. 300 A 10.0.0.2"), - }, - }, - // Priority Test - { - Qname: "priority.skydns.test.", Qtype: dns.TypeSRV, - Answer: []dns.RR{test.SRV("priority.skydns.test. 300 SRV 333 100 8080 priority.server1.")}, - }, - // Subdomain Test - { - Qname: "sub.region1.skydns.test.", Qtype: dns.TypeSRV, - Answer: []dns.RR{ - test.SRV("sub.region1.skydns.test. 300 IN SRV 10 33 0 sub.server1."), - test.SRV("sub.region1.skydns.test. 300 IN SRV 10 33 80 sub.server2."), - test.SRV("sub.region1.skydns.test. 300 IN SRV 10 33 8080 c.sub.region1.skydns.test."), - }, - Extra: []dns.RR{test.A("c.sub.region1.skydns.test. 300 IN A 10.0.0.1")}, - }, - // CNAME (unresolvable internal name) - { - Qname: "cname.prod.region1.skydns.test.", Qtype: dns.TypeA, - Ns: []dns.RR{test.SOA("skydns.test. 300 SOA ns.dns.skydns.test. hostmaster.skydns.test. 0 0 0 0 0")}, - }, - // Wildcard Test - { - Qname: "*.region1.skydns.test.", Qtype: dns.TypeSRV, - Answer: []dns.RR{ - test.SRV("*.region1.skydns.test. 300 IN SRV 10 12 0 sub.server1."), - test.SRV("*.region1.skydns.test. 300 IN SRV 10 12 0 unresolvable.skydns.test."), - test.SRV("*.region1.skydns.test. 300 IN SRV 10 12 80 sub.server2."), - test.SRV("*.region1.skydns.test. 300 IN SRV 10 12 8080 a.server1.prod.region1.skydns.test."), - test.SRV("*.region1.skydns.test. 300 IN SRV 10 12 8080 b.server1.prod.region1.skydns.test."), - test.SRV("*.region1.skydns.test. 300 IN SRV 10 12 8080 b.server6.prod.region1.skydns.test."), - test.SRV("*.region1.skydns.test. 300 IN SRV 10 12 8080 c.sub.region1.skydns.test."), - test.SRV("*.region1.skydns.test. 300 IN SRV 10 12 8080 dev.server1."), - }, - Extra: []dns.RR{ - test.A("a.server1.prod.region1.skydns.test. 300 IN A 10.0.0.1"), - test.A("b.server1.prod.region1.skydns.test. 300 IN A 10.0.0.2"), - test.AAAA("b.server6.prod.region1.skydns.test. 300 IN AAAA ::1"), - test.A("c.sub.region1.skydns.test. 300 IN A 10.0.0.1"), - }, - }, - // Wildcard Test - { - Qname: "prod.*.skydns.test.", Qtype: dns.TypeSRV, - Answer: []dns.RR{ - - test.SRV("prod.*.skydns.test. 300 IN SRV 10 25 0 unresolvable.skydns.test."), - test.SRV("prod.*.skydns.test. 300 IN SRV 10 25 8080 a.server1.prod.region1.skydns.test."), - test.SRV("prod.*.skydns.test. 300 IN SRV 10 25 8080 b.server1.prod.region1.skydns.test."), - test.SRV("prod.*.skydns.test. 300 IN SRV 10 25 8080 b.server6.prod.region1.skydns.test."), - }, - Extra: []dns.RR{ - test.A("a.server1.prod.region1.skydns.test. 300 IN A 10.0.0.1"), - test.A("b.server1.prod.region1.skydns.test. 300 IN A 10.0.0.2"), - test.AAAA("b.server6.prod.region1.skydns.test. 300 IN AAAA ::1"), - }, - }, - // Wildcard Test - { - Qname: "prod.any.skydns.test.", Qtype: dns.TypeSRV, - Answer: []dns.RR{ - test.SRV("prod.any.skydns.test. 300 IN SRV 10 25 0 unresolvable.skydns.test."), - test.SRV("prod.any.skydns.test. 300 IN SRV 10 25 8080 a.server1.prod.region1.skydns.test."), - test.SRV("prod.any.skydns.test. 300 IN SRV 10 25 8080 b.server1.prod.region1.skydns.test."), - test.SRV("prod.any.skydns.test. 300 IN SRV 10 25 8080 b.server6.prod.region1.skydns.test."), - }, - Extra: []dns.RR{ - test.A("a.server1.prod.region1.skydns.test. 300 IN A 10.0.0.1"), - test.A("b.server1.prod.region1.skydns.test. 300 IN A 10.0.0.2"), - test.AAAA("b.server6.prod.region1.skydns.test. 300 IN AAAA ::1"), - }, - }, - // CNAME loop detection - { - Qname: "a.cname.skydns.test.", Qtype: dns.TypeA, - Ns: []dns.RR{test.SOA("skydns.test. 300 SOA ns.dns.skydns.test. hostmaster.skydns.test. 1407441600 28800 7200 604800 60")}, - }, - // NODATA Test - { - Qname: "a.server1.dev.region1.skydns.test.", Qtype: dns.TypeTXT, - Ns: []dns.RR{test.SOA("skydns.test. 300 SOA ns.dns.skydns.test. hostmaster.skydns.test. 0 0 0 0 0")}, - }, - // NODATA Test - { - Qname: "a.server1.dev.region1.skydns.test.", Qtype: dns.TypeHINFO, - Ns: []dns.RR{test.SOA("skydns.test. 300 SOA ns.dns.skydns.test. hostmaster.skydns.test. 0 0 0 0 0")}, - }, - // NXDOMAIN Test - { - Qname: "a.server1.nonexistent.region1.skydns.test.", Qtype: dns.TypeHINFO, Rcode: dns.RcodeNameError, - Ns: []dns.RR{test.SOA("skydns.test. 300 SOA ns.dns.skydns.test. hostmaster.skydns.test. 0 0 0 0 0")}, - }, - { - Qname: "skydns.test.", Qtype: dns.TypeSOA, - Answer: []dns.RR{test.SOA("skydns.test. 300 IN SOA ns.dns.skydns.test. hostmaster.skydns.test. 1460498836 14400 3600 604800 60")}, - }, - // NS Record Test - { - Qname: "skydns.test.", Qtype: dns.TypeNS, - Answer: []dns.RR{ - test.NS("skydns.test. 300 NS a.ns.dns.skydns.test."), - test.NS("skydns.test. 300 NS b.ns.dns.skydns.test."), - }, - Extra: []dns.RR{ - test.A("a.ns.dns.skydns.test. 300 A 10.0.0.2"), - test.A("b.ns.dns.skydns.test. 300 A 10.0.0.3"), - }, - }, - // NS Record Test - { - Qname: "a.skydns.test.", Qtype: dns.TypeNS, Rcode: dns.RcodeNameError, - Ns: []dns.RR{test.SOA("skydns.test. 300 IN SOA ns.dns.skydns.test. hostmaster.skydns.test. 1460498836 14400 3600 604800 60")}, - }, - // A Record For NS Record Test - { - Qname: "ns.dns.skydns.test.", Qtype: dns.TypeA, - Answer: []dns.RR{ - test.A("ns.dns.skydns.test. 300 A 10.0.0.2"), - test.A("ns.dns.skydns.test. 300 A 10.0.0.3"), - }, - }, - { - Qname: "skydns_extra.test.", Qtype: dns.TypeSOA, - Answer: []dns.RR{test.SOA("skydns_extra.test. 300 IN SOA ns.dns.skydns_extra.test. hostmaster.skydns_extra.test. 1460498836 14400 3600 604800 60")}, - }, - // A Record Test for backward compatibility for zone records - { - Qname: "skydns_zonea.test.", Qtype: dns.TypeA, - Answer: []dns.RR{ - test.A("skydns_zonea.test. 300 A 10.0.0.2"), - test.A("skydns_zonea.test. 300 A 10.0.0.3"), - }, - }, - // A Record Test for single A zone record - { - Qname: "skydns_zoneb.test.", Qtype: dns.TypeA, - Answer: []dns.RR{test.A("skydns_zoneb.test. 300 A 10.0.0.4")}, - }, - // A Record Test for multiple A zone records - { - Qname: "skydns_zonec.test.", Qtype: dns.TypeA, - Answer: []dns.RR{ - test.A("skydns_zonec.test. 300 A 10.0.0.4"), - test.A("skydns_zonec.test. 300 A 10.0.0.5"), - }, - }, - // A Record Test for multiple mixed A and AAAA records - { - Qname: "skydns_zoned.test.", Qtype: dns.TypeA, - Answer: []dns.RR{ - test.A("skydns_zoned.test. 300 A 10.0.0.4"), - test.A("skydns_zoned.test. 300 A 10.0.0.5"), - }, - }, - // AAAA Record Test for multiple mixed A and AAAA records - { - Qname: "skydns_zoned.test.", Qtype: dns.TypeAAAA, - Answer: []dns.RR{ - test.AAAA("skydns_zoned.test. 300 AAAA 2003::8:1"), - test.AAAA("skydns_zoned.test. 300 AAAA 2003::8:2"), - }, - }, - // Reverse lookup - { - Qname: "1.0.0.10.in-addr.arpa.", Qtype: dns.TypePTR, - Answer: []dns.RR{test.PTR("1.0.0.10.in-addr.arpa. 300 PTR reverse.example.com.")}, - }, -} - -func newEtcdPlugin() *Etcd { - ctxt = context.TODO() - - endpoints := []string{"http://localhost:2379"} - tlsc, _ := tls.NewTLSConfigFromArgs() - client, _ := newEtcdClient(endpoints, tlsc) - - p := proxy.NewLookup([]string{"8.8.8.8:53"}) - return &Etcd{ - Upstream: upstream.Upstream{Forward: &p}, - PathPrefix: "skydns", - Ctx: context.Background(), - Zones: []string{"skydns.test.", "skydns_extra.test.", "skydns_zonea.test.", "skydns_zoneb.test.", "skydns_zonec.test.", "skydns_zoned.test.", "in-addr.arpa."}, - Client: client, - } -} - -func set(t *testing.T, e *Etcd, k string, ttl time.Duration, m *msg.Service) { - b, err := json.Marshal(m) - if err != nil { - t.Fatal(err) - } - path, _ := msg.PathWithWildcard(k, e.PathPrefix) - e.Client.Set(ctxt, path, string(b), &etcdc.SetOptions{TTL: ttl}) -} - -func delete(t *testing.T, e *Etcd, k string) { - path, _ := msg.PathWithWildcard(k, e.PathPrefix) - e.Client.Delete(ctxt, path, &etcdc.DeleteOptions{Recursive: false}) -} - -func TestLookup(t *testing.T) { - etc := newEtcdPlugin() - for _, serv := range services { - set(t, etc, serv.Key, 0, serv) - defer delete(t, etc, serv.Key) - } - - for _, tc := range dnsTestCases { - m := tc.Msg() - - rec := dnstest.NewRecorder(&test.ResponseWriter{}) - etc.ServeDNS(ctxt, rec, m) - - resp := rec.Msg - test.SortAndCheck(t, resp, tc) - } -} - -var ctxt context.Context diff --git a/vendor/github.com/coredns/coredns/plugin/etcd/msg/path_test.go b/vendor/github.com/coredns/coredns/plugin/etcd/msg/path_test.go deleted file mode 100644 index a9ec5971..00000000 --- a/vendor/github.com/coredns/coredns/plugin/etcd/msg/path_test.go +++ /dev/null @@ -1,12 +0,0 @@ -package msg - -import "testing" - -func TestPath(t *testing.T) { - for _, path := range []string{"mydns", "skydns"} { - result := Path("service.staging.skydns.local.", path) - if result != "/"+path+"/local/skydns/staging/service" { - t.Errorf("Failure to get domain's path with prefix: %s", result) - } - } -} diff --git a/vendor/github.com/coredns/coredns/plugin/etcd/msg/service_test.go b/vendor/github.com/coredns/coredns/plugin/etcd/msg/service_test.go deleted file mode 100644 index 5b16d2d9..00000000 --- a/vendor/github.com/coredns/coredns/plugin/etcd/msg/service_test.go +++ /dev/null @@ -1,125 +0,0 @@ -package msg - -import "testing" - -func TestSplit255(t *testing.T) { - xs := split255("abc") - if len(xs) != 1 && xs[0] != "abc" { - t.Errorf("Failure to split abc") - } - s := "" - for i := 0; i < 255; i++ { - s += "a" - } - xs = split255(s) - if len(xs) != 1 && xs[0] != s { - t.Errorf("Failure to split 255 char long string") - } - s += "b" - xs = split255(s) - if len(xs) != 2 || xs[1] != "b" { - t.Errorf("Failure to split 256 char long string: %d", len(xs)) - } - for i := 0; i < 255; i++ { - s += "a" - } - xs = split255(s) - if len(xs) != 3 || xs[2] != "a" { - t.Errorf("Failure to split 510 char long string: %d", len(xs)) - } -} - -func TestGroup(t *testing.T) { - // Key are in the wrong order, but for this test it does not matter. - sx := Group( - []Service{ - {Host: "127.0.0.1", Group: "g1", Key: "b/sub/dom1/skydns/test"}, - {Host: "127.0.0.2", Group: "g2", Key: "a/dom1/skydns/test"}, - }, - ) - // Expecting to return the shortest key with a Group attribute. - if len(sx) != 1 { - t.Fatalf("Failure to group zeroth set: %v", sx) - } - if sx[0].Key != "a/dom1/skydns/test" { - t.Fatalf("Failure to group zeroth set: %v, wrong Key", sx) - } - - // Groups disagree, so we will not do anything. - sx = Group( - []Service{ - {Host: "server1", Group: "g1", Key: "region1/skydns/test"}, - {Host: "server2", Group: "g2", Key: "region1/skydns/test"}, - }, - ) - if len(sx) != 2 { - t.Fatalf("Failure to group first set: %v", sx) - } - - // Group is g1, include only the top-level one. - sx = Group( - []Service{ - {Host: "server1", Group: "g1", Key: "a/dom/region1/skydns/test"}, - {Host: "server2", Group: "g2", Key: "a/subdom/dom/region1/skydns/test"}, - }, - ) - if len(sx) != 1 { - t.Fatalf("Failure to group second set: %v", sx) - } - - // Groupless services must be included. - sx = Group( - []Service{ - {Host: "server1", Group: "g1", Key: "a/dom/region1/skydns/test"}, - {Host: "server2", Group: "g2", Key: "a/subdom/dom/region1/skydns/test"}, - {Host: "server2", Group: "", Key: "b/subdom/dom/region1/skydns/test"}, - }, - ) - if len(sx) != 2 { - t.Fatalf("Failure to group third set: %v", sx) - } - - // Empty group on the highest level: include that one also. - sx = Group( - []Service{ - {Host: "server1", Group: "g1", Key: "a/dom/region1/skydns/test"}, - {Host: "server1", Group: "", Key: "b/dom/region1/skydns/test"}, - {Host: "server2", Group: "g2", Key: "a/subdom/dom/region1/skydns/test"}, - }, - ) - if len(sx) != 2 { - t.Fatalf("Failure to group fourth set: %v", sx) - } - - // Empty group on the highest level: include that one also, and the rest. - sx = Group( - []Service{ - {Host: "server1", Group: "g5", Key: "a/dom/region1/skydns/test"}, - {Host: "server1", Group: "", Key: "b/dom/region1/skydns/test"}, - {Host: "server2", Group: "g5", Key: "a/subdom/dom/region1/skydns/test"}, - }, - ) - if len(sx) != 3 { - t.Fatalf("Failure to group fith set: %v", sx) - } - - // One group. - sx = Group( - []Service{ - {Host: "server1", Group: "g6", Key: "a/dom/region1/skydns/test"}, - }, - ) - if len(sx) != 1 { - t.Fatalf("Failure to group sixth set: %v", sx) - } - - // No group, once service - sx = Group( - []Service{ - {Host: "server1", Key: "a/dom/region1/skydns/test"}, - }, - ) - if len(sx) != 1 { - t.Fatalf("Failure to group seventh set: %v", sx) - } -} diff --git a/vendor/github.com/coredns/coredns/plugin/etcd/msg/type_test.go b/vendor/github.com/coredns/coredns/plugin/etcd/msg/type_test.go deleted file mode 100644 index bad1eead..00000000 --- a/vendor/github.com/coredns/coredns/plugin/etcd/msg/type_test.go +++ /dev/null @@ -1,31 +0,0 @@ -package msg - -import ( - "testing" - - "github.com/miekg/dns" -) - -func TestType(t *testing.T) { - tests := []struct { - serv Service - expectedType uint16 - }{ - {Service{Host: "example.org"}, dns.TypeCNAME}, - {Service{Host: "127.0.0.1"}, dns.TypeA}, - {Service{Host: "2000::3"}, dns.TypeAAAA}, - {Service{Host: "2000..3"}, dns.TypeCNAME}, - {Service{Host: "127.0.0.257"}, dns.TypeCNAME}, - {Service{Host: "127.0.0.252", Mail: true}, dns.TypeA}, - {Service{Host: "127.0.0.252", Mail: true, Text: "a"}, dns.TypeA}, - {Service{Host: "127.0.0.254", Mail: false, Text: "a"}, dns.TypeA}, - } - - for i, tc := range tests { - what, _ := tc.serv.HostType() - if what != tc.expectedType { - t.Errorf("Test %d: Expected what %v, but got %v", i, tc.expectedType, what) - } - } - -} diff --git a/vendor/github.com/coredns/coredns/plugin/etcd/multi_test.go b/vendor/github.com/coredns/coredns/plugin/etcd/multi_test.go deleted file mode 100644 index 9d506267..00000000 --- a/vendor/github.com/coredns/coredns/plugin/etcd/multi_test.go +++ /dev/null @@ -1,58 +0,0 @@ -// +build etcd - -package etcd - -import ( - "testing" - - "github.com/coredns/coredns/plugin/etcd/msg" - "github.com/coredns/coredns/plugin/pkg/dnstest" - "github.com/coredns/coredns/plugin/test" - - "github.com/miekg/dns" -) - -func TestMultiLookup(t *testing.T) { - etc := newEtcdPlugin() - etc.Zones = []string{"skydns.test.", "miek.nl."} - etc.Next = test.ErrorHandler() - - for _, serv := range servicesMulti { - set(t, etc, serv.Key, 0, serv) - defer delete(t, etc, serv.Key) - } - for _, tc := range dnsTestCasesMulti { - m := tc.Msg() - - rec := dnstest.NewRecorder(&test.ResponseWriter{}) - _, err := etc.ServeDNS(ctxt, rec, m) - if err != nil { - t.Errorf("Expected no error, got %v\n", err) - return - } - - resp := rec.Msg - test.SortAndCheck(t, resp, tc) - } -} - -// Note the key is encoded as DNS name, while in "reality" it is a etcd path. -var servicesMulti = []*msg.Service{ - {Host: "dev.server1", Port: 8080, Key: "a.server1.dev.region1.skydns.test."}, - {Host: "dev.server1", Port: 8080, Key: "a.server1.dev.region1.miek.nl."}, - {Host: "dev.server1", Port: 8080, Key: "a.server1.dev.region1.example.org."}, -} - -var dnsTestCasesMulti = []test.Case{ - { - Qname: "a.server1.dev.region1.skydns.test.", Qtype: dns.TypeSRV, - Answer: []dns.RR{test.SRV("a.server1.dev.region1.skydns.test. 300 SRV 10 100 8080 dev.server1.")}, - }, - { - Qname: "a.server1.dev.region1.miek.nl.", Qtype: dns.TypeSRV, - Answer: []dns.RR{test.SRV("a.server1.dev.region1.miek.nl. 300 SRV 10 100 8080 dev.server1.")}, - }, - { - Qname: "a.server1.dev.region1.example.org.", Qtype: dns.TypeSRV, Rcode: dns.RcodeServerFailure, - }, -} diff --git a/vendor/github.com/coredns/coredns/plugin/etcd/other_test.go b/vendor/github.com/coredns/coredns/plugin/etcd/other_test.go deleted file mode 100644 index d37a0470..00000000 --- a/vendor/github.com/coredns/coredns/plugin/etcd/other_test.go +++ /dev/null @@ -1,136 +0,0 @@ -// +build etcd - -// tests mx and txt records - -package etcd - -import ( - "fmt" - "strings" - "testing" - - "github.com/coredns/coredns/plugin/etcd/msg" - "github.com/coredns/coredns/plugin/pkg/dnstest" - "github.com/coredns/coredns/plugin/test" - - "github.com/miekg/dns" -) - -func TestOtherLookup(t *testing.T) { - etc := newEtcdPlugin() - - for _, serv := range servicesOther { - set(t, etc, serv.Key, 0, serv) - defer delete(t, etc, serv.Key) - } - for _, tc := range dnsTestCasesOther { - m := tc.Msg() - - rec := dnstest.NewRecorder(&test.ResponseWriter{}) - _, err := etc.ServeDNS(ctxt, rec, m) - if err != nil { - t.Errorf("Expected no error, got %v\n", err) - continue - } - - resp := rec.Msg - test.SortAndCheck(t, resp, tc) - } -} - -// Note the key is encoded as DNS name, while in "reality" it is a etcd path. -var servicesOther = []*msg.Service{ - {Host: "dev.server1", Port: 8080, Key: "a.server1.dev.region1.skydns.test."}, - - // mx - {Host: "mx.skydns.test", Priority: 50, Mail: true, Key: "a.mail.skydns.test."}, - {Host: "mx.miek.nl", Priority: 50, Mail: true, Key: "b.mail.skydns.test."}, - {Host: "a.ipaddr.skydns.test", Priority: 30, Mail: true, Key: "a.mx.skydns.test."}, - - {Host: "a.ipaddr.skydns.test", Mail: true, Key: "a.mx2.skydns.test."}, - {Host: "b.ipaddr.skydns.test", Mail: true, Key: "b.mx2.skydns.test."}, - - {Host: "a.ipaddr.skydns.test", Priority: 20, Mail: true, Key: "a.mx3.skydns.test."}, - {Host: "a.ipaddr.skydns.test", Priority: 30, Mail: true, Key: "b.mx3.skydns.test."}, - - {Host: "172.16.1.1", Key: "a.ipaddr.skydns.test."}, - {Host: "172.16.1.2", Key: "b.ipaddr.skydns.test."}, - - // txt - {Text: "abc", Key: "a1.txt.skydns.test."}, - {Text: "abc abc", Key: "a2.txt.skydns.test."}, - // txt sizes - {Text: strings.Repeat("0", 400), Key: "large400.skydns.test."}, - {Text: strings.Repeat("0", 600), Key: "large600.skydns.test."}, - {Text: strings.Repeat("0", 2000), Key: "large2000.skydns.test."}, - - // duplicate ip address - {Host: "10.11.11.10", Key: "http.multiport.http.skydns.test.", Port: 80}, - {Host: "10.11.11.10", Key: "https.multiport.http.skydns.test.", Port: 443}, -} - -var dnsTestCasesOther = []test.Case{ - // MX Tests - { - // NODATA as this is not an Mail: true record. - Qname: "a.server1.dev.region1.skydns.test.", Qtype: dns.TypeMX, - Ns: []dns.RR{ - test.SOA("skydns.test. 300 SOA ns.dns.skydns.test. hostmaster.skydns.test. 0 0 0 0 0"), - }, - }, - { - Qname: "a.mail.skydns.test.", Qtype: dns.TypeMX, - Answer: []dns.RR{test.MX("a.mail.skydns.test. 300 IN MX 50 mx.skydns.test.")}, - Extra: []dns.RR{ - test.A("a.ipaddr.skydns.test. 300 IN A 172.16.1.1"), - test.CNAME("mx.skydns.test. 300 IN CNAME a.ipaddr.skydns.test."), - }, - }, - { - Qname: "mx2.skydns.test.", Qtype: dns.TypeMX, - Answer: []dns.RR{ - test.MX("mx2.skydns.test. 300 IN MX 10 a.ipaddr.skydns.test."), - test.MX("mx2.skydns.test. 300 IN MX 10 b.ipaddr.skydns.test."), - }, - Extra: []dns.RR{ - test.A("a.ipaddr.skydns.test. 300 A 172.16.1.1"), - test.A("b.ipaddr.skydns.test. 300 A 172.16.1.2"), - }, - }, - // different priority, same host - { - Qname: "mx3.skydns.test.", Qtype: dns.TypeMX, - Answer: []dns.RR{ - test.MX("mx3.skydns.test. 300 IN MX 20 a.ipaddr.skydns.test."), - test.MX("mx3.skydns.test. 300 IN MX 30 a.ipaddr.skydns.test."), - }, - Extra: []dns.RR{ - test.A("a.ipaddr.skydns.test. 300 A 172.16.1.1"), - }, - }, - // Txt - { - Qname: "a1.txt.skydns.test.", Qtype: dns.TypeTXT, - Answer: []dns.RR{ - test.TXT("a1.txt.skydns.test. 300 IN TXT \"abc\""), - }, - }, - { - Qname: "a2.txt.skydns.test.", Qtype: dns.TypeTXT, - Answer: []dns.RR{ - test.TXT("a2.txt.skydns.test. 300 IN TXT \"abc abc\""), - }, - }, - // Large txt less than 512 - { - Qname: "large400.skydns.test.", Qtype: dns.TypeTXT, - Answer: []dns.RR{ - test.TXT(fmt.Sprintf("large400.skydns.test. 300 IN TXT \"%s\"", strings.Repeat("0", 400))), - }, - }, - // Duplicate IP address test - { - Qname: "multiport.http.skydns.test.", Qtype: dns.TypeA, - Answer: []dns.RR{test.A("multiport.http.skydns.test. 300 IN A 10.11.11.10")}, - }, -} diff --git a/vendor/github.com/coredns/coredns/plugin/etcd/setup.go b/vendor/github.com/coredns/coredns/plugin/etcd/setup.go deleted file mode 100644 index 0cc8b055..00000000 --- a/vendor/github.com/coredns/coredns/plugin/etcd/setup.go +++ /dev/null @@ -1,145 +0,0 @@ -package etcd - -import ( - "context" - "crypto/tls" - - "github.com/coredns/coredns/core/dnsserver" - "github.com/coredns/coredns/plugin" - clog "github.com/coredns/coredns/plugin/pkg/log" - mwtls "github.com/coredns/coredns/plugin/pkg/tls" - "github.com/coredns/coredns/plugin/pkg/upstream" - "github.com/coredns/coredns/plugin/proxy" - - etcdc "github.com/coreos/etcd/client" - "github.com/mholt/caddy" -) - -var log = clog.NewWithPlugin("etcd") - -func init() { - caddy.RegisterPlugin("etcd", caddy.Plugin{ - ServerType: "dns", - Action: setup, - }) -} - -func setup(c *caddy.Controller) error { - e, stubzones, err := etcdParse(c) - if err != nil { - return plugin.Error("etcd", err) - } - - if stubzones { - c.OnStartup(func() error { - e.UpdateStubZones() - return nil - }) - } - - dnsserver.GetConfig(c).AddPlugin(func(next plugin.Handler) plugin.Handler { - e.Next = next - return e - }) - - return nil -} - -func etcdParse(c *caddy.Controller) (*Etcd, bool, error) { - stub := make(map[string]proxy.Proxy) - etc := Etcd{ - // Don't default to a proxy for lookups. - // Proxy: proxy.NewLookup([]string{"8.8.8.8:53", "8.8.4.4:53"}), - PathPrefix: "skydns", - Ctx: context.Background(), - Stubmap: &stub, - } - var ( - tlsConfig *tls.Config - err error - endpoints = []string{defaultEndpoint} - stubzones = false - ) - for c.Next() { - etc.Zones = c.RemainingArgs() - if len(etc.Zones) == 0 { - etc.Zones = make([]string, len(c.ServerBlockKeys)) - copy(etc.Zones, c.ServerBlockKeys) - } - for i, str := range etc.Zones { - etc.Zones[i] = plugin.Host(str).Normalize() - } - - if c.NextBlock() { - for { - switch c.Val() { - case "stubzones": - stubzones = true - case "fallthrough": - etc.Fall.SetZonesFromArgs(c.RemainingArgs()) - case "debug": - /* it is a noop now */ - case "path": - if !c.NextArg() { - return &Etcd{}, false, c.ArgErr() - } - etc.PathPrefix = c.Val() - case "endpoint": - args := c.RemainingArgs() - if len(args) == 0 { - return &Etcd{}, false, c.ArgErr() - } - endpoints = args - case "upstream": - args := c.RemainingArgs() - if len(args) == 0 { - return nil, false, c.ArgErr() - } - u, err := upstream.New(args) - if err != nil { - return nil, false, err - } - etc.Upstream = u - case "tls": // cert key cacertfile - args := c.RemainingArgs() - tlsConfig, err = mwtls.NewTLSConfigFromArgs(args...) - if err != nil { - return &Etcd{}, false, err - } - default: - if c.Val() != "}" { - return &Etcd{}, false, c.Errf("unknown property '%s'", c.Val()) - } - } - - if !c.Next() { - break - } - } - - } - client, err := newEtcdClient(endpoints, tlsConfig) - if err != nil { - return &Etcd{}, false, err - } - etc.Client = client - etc.endpoints = endpoints - - return &etc, stubzones, nil - } - return &Etcd{}, false, nil -} - -func newEtcdClient(endpoints []string, cc *tls.Config) (etcdc.KeysAPI, error) { - etcdCfg := etcdc.Config{ - Endpoints: endpoints, - Transport: mwtls.NewHTTPSTransport(cc), - } - cli, err := etcdc.New(etcdCfg) - if err != nil { - return nil, err - } - return etcdc.NewKeysAPI(cli), nil -} - -const defaultEndpoint = "http://localhost:2379" diff --git a/vendor/github.com/coredns/coredns/plugin/etcd/setup_test.go b/vendor/github.com/coredns/coredns/plugin/etcd/setup_test.go deleted file mode 100644 index 517aeea5..00000000 --- a/vendor/github.com/coredns/coredns/plugin/etcd/setup_test.go +++ /dev/null @@ -1,77 +0,0 @@ -package etcd - -import ( - "strings" - "testing" - - "github.com/mholt/caddy" -) - -func TestSetupEtcd(t *testing.T) { - tests := []struct { - input string - shouldErr bool - expectedPath string - expectedEndpoint []string - expectedErrContent string // substring from the expected error. Empty for positive cases. - }{ - // positive - { - `etcd`, false, "skydns", []string{"http://localhost:2379"}, "", - }, - { - `etcd { - endpoint http://localhost:2379 http://localhost:3379 http://localhost:4379 - -}`, false, "skydns", []string{"http://localhost:2379", "http://localhost:3379", "http://localhost:4379"}, "", - }, - { - `etcd skydns.local { - endpoint localhost:300 -} -`, false, "skydns", []string{"localhost:300"}, "", - }, - // negative - { - `etcd { - endpoints localhost:300 -} -`, true, "", []string{""}, "unknown property 'endpoints'", - }, - } - - for i, test := range tests { - c := caddy.NewTestController("dns", test.input) - etcd, _ /*stubzones*/, err := etcdParse(c) - - if test.shouldErr && err == nil { - t.Errorf("Test %d: Expected error but found %s for input %s", i, err, test.input) - } - - if err != nil { - if !test.shouldErr { - t.Errorf("Test %d: Expected no error but found one for input %s. Error was: %v", i, test.input, err) - continue - } - - if !strings.Contains(err.Error(), test.expectedErrContent) { - t.Errorf("Test %d: Expected error to contain: %v, found error: %v, input: %s", i, test.expectedErrContent, err, test.input) - continue - } - } - - if !test.shouldErr && etcd.PathPrefix != test.expectedPath { - t.Errorf("Etcd not correctly set for input %s. Expected: %s, actual: %s", test.input, test.expectedPath, etcd.PathPrefix) - } - if !test.shouldErr { - if len(etcd.endpoints) != len(test.expectedEndpoint) { - t.Errorf("Etcd not correctly set for input %s. Expected: '%+v', actual: '%+v'", test.input, test.expectedEndpoint, etcd.endpoints) - } - for i, endpoint := range etcd.endpoints { - if endpoint != test.expectedEndpoint[i] { - t.Errorf("Etcd not correctly set for input %s. Expected: '%+v', actual: '%+v'", test.input, test.expectedEndpoint, etcd.endpoints) - } - } - } - } -} diff --git a/vendor/github.com/coredns/coredns/plugin/etcd/stub.go b/vendor/github.com/coredns/coredns/plugin/etcd/stub.go deleted file mode 100644 index c270bcd2..00000000 --- a/vendor/github.com/coredns/coredns/plugin/etcd/stub.go +++ /dev/null @@ -1,81 +0,0 @@ -package etcd - -import ( - "net" - "strconv" - "time" - - "github.com/coredns/coredns/plugin/etcd/msg" - "github.com/coredns/coredns/plugin/pkg/dnsutil" - "github.com/coredns/coredns/plugin/proxy" - "github.com/coredns/coredns/request" - - "github.com/miekg/dns" -) - -// UpdateStubZones checks etcd for an update on the stubzones. -func (e *Etcd) UpdateStubZones() { - go func() { - for { - e.updateStubZones() - time.Sleep(15 * time.Second) - } - }() -} - -// Look in .../dns/stub//xx for msg.Services. Loop through them -// extract and add them as forwarders (ip:port-combos) for -// the stub zones. Only numeric (i.e. IP address) hosts are used. -// Only the first zone configured on e is used for the lookup. -func (e *Etcd) updateStubZones() { - zone := e.Zones[0] - - fakeState := request.Request{W: nil, Req: new(dns.Msg)} - fakeState.Req.SetQuestion(stubDomain+"."+zone, dns.TypeA) - - services, err := e.Records(fakeState, false) - if err != nil { - return - } - - stubmap := make(map[string]proxy.Proxy) - // track the nameservers on a per domain basis, but allow a list on the domain. - nameservers := map[string][]string{} - -Services: - for _, serv := range services { - if serv.Port == 0 { - serv.Port = 53 - } - ip := net.ParseIP(serv.Host) - if ip == nil { - log.Warningf("Non IP address stub nameserver: %s", serv.Host) - continue - } - - domain := msg.Domain(serv.Key) - labels := dns.SplitDomainName(domain) - - // If the remaining name equals any of the zones we have, we ignore it. - for _, z := range e.Zones { - // Chop of left most label, because that is used as the nameserver place holder - // and drop the right most labels that belong to zone. - // We must *also* chop of dns.stub. which means cutting two more labels. - domain = dnsutil.Join(labels[1 : len(labels)-dns.CountLabel(z)-2]) - if domain == z { - log.Warningf("Skipping nameserver for domain we are authoritative for: %s", domain) - continue Services - } - } - nameservers[domain] = append(nameservers[domain], net.JoinHostPort(serv.Host, strconv.Itoa(serv.Port))) - } - - for domain, nss := range nameservers { - stubmap[domain] = proxy.NewLookup(nss) - } - // atomic swap (at least that's what we hope it is) - if len(stubmap) > 0 { - e.Stubmap = &stubmap - } - return -} diff --git a/vendor/github.com/coredns/coredns/plugin/etcd/stub_handler.go b/vendor/github.com/coredns/coredns/plugin/etcd/stub_handler.go deleted file mode 100644 index 300e0a35..00000000 --- a/vendor/github.com/coredns/coredns/plugin/etcd/stub_handler.go +++ /dev/null @@ -1,86 +0,0 @@ -package etcd - -import ( - "context" - "errors" - - "github.com/coredns/coredns/request" - - "github.com/miekg/dns" -) - -// Stub wraps an Etcd. We have this type so that it can have a ServeDNS method. -type Stub struct { - *Etcd - Zone string // for what zone (and thus what nameservers are we called) -} - -// ServeDNS implements the plugin.Handler interface. -func (s Stub) ServeDNS(ctx context.Context, w dns.ResponseWriter, req *dns.Msg) (int, error) { - if hasStubEdns0(req) { - log.Warningf("Forwarding cycle detected, refusing msg: %s", req.Question[0].Name) - return dns.RcodeRefused, errors.New("stub forward cycle") - } - req = addStubEdns0(req) - proxy, ok := (*s.Etcd.Stubmap)[s.Zone] - if !ok { // somebody made a mistake.. - return dns.RcodeServerFailure, nil - } - - state := request.Request{W: w, Req: req} - m, e := proxy.Forward(state) - if e != nil { - return dns.RcodeServerFailure, e - } - m.RecursionAvailable = true - state.SizeAndDo(m) - m, _ = state.Scrub(m) - w.WriteMsg(m) - return dns.RcodeSuccess, nil -} - -// hasStubEdns0 checks if the message is carrying our special edns0 zero option. -func hasStubEdns0(m *dns.Msg) bool { - option := m.IsEdns0() - if option == nil { - return false - } - for _, o := range option.Option { - if o.Option() == ednsStubCode && len(o.(*dns.EDNS0_LOCAL).Data) == 1 && - o.(*dns.EDNS0_LOCAL).Data[0] == 1 { - return true - } - } - return false -} - -// addStubEdns0 adds our special option to the message's OPT record. -func addStubEdns0(m *dns.Msg) *dns.Msg { - option := m.IsEdns0() - // Add a custom EDNS0 option to the packet, so we can detect loops when 2 stubs are forwarding to each other. - if option != nil { - option.Option = append(option.Option, &dns.EDNS0_LOCAL{Code: ednsStubCode, Data: []byte{1}}) - return m - } - - m.Extra = append(m.Extra, ednsStub) - return m -} - -const ( - ednsStubCode = dns.EDNS0LOCALSTART + 10 - stubDomain = "stub.dns" -) - -var ednsStub = func() *dns.OPT { - o := new(dns.OPT) - o.Hdr.Name = "." - o.Hdr.Rrtype = dns.TypeOPT - o.SetUDPSize(4096) - - e := new(dns.EDNS0_LOCAL) - e.Code = ednsStubCode - e.Data = []byte{1} - o.Option = append(o.Option, e) - return o -}() diff --git a/vendor/github.com/coredns/coredns/plugin/etcd/stub_test.go b/vendor/github.com/coredns/coredns/plugin/etcd/stub_test.go deleted file mode 100644 index c4a262b8..00000000 --- a/vendor/github.com/coredns/coredns/plugin/etcd/stub_test.go +++ /dev/null @@ -1,88 +0,0 @@ -// +build etcd - -package etcd - -import ( - "net" - "strconv" - "testing" - - "github.com/coredns/coredns/plugin/etcd/msg" - "github.com/coredns/coredns/plugin/pkg/dnstest" - "github.com/coredns/coredns/plugin/test" - - "github.com/miekg/dns" -) - -func fakeStubServerExampleNet(t *testing.T) (*dns.Server, string) { - server, addr, err := test.UDPServer("127.0.0.1:0") - if err != nil { - t.Fatalf("Failed to create a UDP server: %s", err) - } - // add handler for example.net - dns.HandleFunc("example.net.", func(w dns.ResponseWriter, r *dns.Msg) { - m := new(dns.Msg) - m.SetReply(r) - m.Answer = []dns.RR{test.A("example.net. 86400 IN A 93.184.216.34")} - w.WriteMsg(m) - }) - - return server, addr -} - -func TestStubLookup(t *testing.T) { - server, addr := fakeStubServerExampleNet(t) - defer server.Shutdown() - - host, p, _ := net.SplitHostPort(addr) - port, _ := strconv.Atoi(p) - exampleNetStub := &msg.Service{Host: host, Port: port, Key: "a.example.net.stub.dns.skydns.test."} - servicesStub = append(servicesStub, exampleNetStub) - - etc := newEtcdPlugin() - - for _, serv := range servicesStub { - set(t, etc, serv.Key, 0, serv) - defer delete(t, etc, serv.Key) - } - - etc.updateStubZones() - - for _, tc := range dnsTestCasesStub { - m := tc.Msg() - - rec := dnstest.NewRecorder(&test.ResponseWriter{}) - _, err := etc.ServeDNS(ctxt, rec, m) - if err != nil && m.Question[0].Name == "example.org." { - // This is OK, we expect this backend to *not* work. - continue - } - if err != nil { - t.Errorf("Expected no error, got %v for %s\n", err, m.Question[0].Name) - } - resp := rec.Msg - if resp == nil { - // etcd not running? - continue - } - - test.SortAndCheck(t, resp, tc) - } -} - -var servicesStub = []*msg.Service{ - // Two tests, ask a question that should return servfail because remote it no accessible - // and one with edns0 option added, that should return refused. - {Host: "127.0.0.1", Port: 666, Key: "b.example.org.stub.dns.skydns.test."}, -} - -var dnsTestCasesStub = []test.Case{ - { - Qname: "example.org.", Qtype: dns.TypeA, Rcode: dns.RcodeServerFailure, - }, - { - Qname: "example.net.", Qtype: dns.TypeA, - Answer: []dns.RR{test.A("example.net. 86400 IN A 93.184.216.34")}, - Extra: []dns.RR{test.OPT(4096, false)}, // This will have an EDNS0 section, because *we* added our local stub forward to detect loops. - }, -} diff --git a/vendor/github.com/coredns/coredns/plugin/etcd/xfr.go b/vendor/github.com/coredns/coredns/plugin/etcd/xfr.go deleted file mode 100644 index 358ff7a3..00000000 --- a/vendor/github.com/coredns/coredns/plugin/etcd/xfr.go +++ /dev/null @@ -1,25 +0,0 @@ -package etcd - -import ( - "context" - "time" - - "github.com/coredns/coredns/request" - - "github.com/miekg/dns" -) - -// Serial implements the Transferer interface. -func (e *Etcd) Serial(state request.Request) uint32 { - return uint32(time.Now().Unix()) -} - -// MinTTL implements the Transferer interface. -func (e *Etcd) MinTTL(state request.Request) uint32 { - return 30 -} - -// Transfer implements the Transferer interface. -func (e *Etcd) Transfer(ctx context.Context, state request.Request) (int, error) { - return dns.RcodeServerFailure, nil -} diff --git a/vendor/github.com/coredns/coredns/plugin/federation/OWNERS b/vendor/github.com/coredns/coredns/plugin/federation/OWNERS deleted file mode 100644 index 187c629c..00000000 --- a/vendor/github.com/coredns/coredns/plugin/federation/OWNERS +++ /dev/null @@ -1,6 +0,0 @@ -reviewers: - - chrisohaver - - miekg -approvers: - - chrisohaver - - miekg diff --git a/vendor/github.com/coredns/coredns/plugin/federation/README.md b/vendor/github.com/coredns/coredns/plugin/federation/README.md deleted file mode 100644 index 021921cb..00000000 --- a/vendor/github.com/coredns/coredns/plugin/federation/README.md +++ /dev/null @@ -1,50 +0,0 @@ -# federation - -## Name - -*federation* - enables federated queries to be resolved via the kubernetes plugin. - -## Description - -Enabling this plugin allows -[Federated](https://kubernetes.io/docs/tasks/federation/federation-service-discovery/) queries to be -resolved via the kubernetes plugin. - -Enabling *federation* without also having *kubernetes* is a noop. - -## Syntax - -~~~ -federation [ZONES...] { - NAME DOMAIN -} -~~~ - -* Each **NAME** and **DOMAIN** defines federation membership. One entry for each. A duplicate - **NAME** will silently overwrite any previous value. - -## Examples - -Here we handle all service requests in the `prod` and `stage` federations. - -~~~ -. { - kubernetes cluster.local - federation cluster.local { - prod prod.feddomain.com - staging staging.feddomain.com - } -} -~~~ - -Or slightly shorter: - -~~~ -cluster.local { - kubernetes - federation { - prod prod.feddomain.com - staging staging.feddomain.com - } -} -~~~ diff --git a/vendor/github.com/coredns/coredns/plugin/federation/federation.go b/vendor/github.com/coredns/coredns/plugin/federation/federation.go deleted file mode 100644 index 2e98875b..00000000 --- a/vendor/github.com/coredns/coredns/plugin/federation/federation.go +++ /dev/null @@ -1,142 +0,0 @@ -/* -Package federation implements kubernetes federation. It checks if the qname matches -a possible federation. If this is the case and the captured answer is an NXDOMAIN, -federation is performed. If this is not the case the original answer is returned. - -The federation label is always the 2nd to last once the zone is chopped of. For -instance "nginx.mynamespace.myfederation.svc.example.com" has "myfederation" as -the federation label. For federation to work we do a normal k8s lookup -*without* that label, if that comes back with NXDOMAIN or NODATA(??) we create -a federation record and return that. - -Federation is only useful in conjunction with the kubernetes plugin, without it is a noop. -*/ -package federation - -import ( - "context" - - "github.com/coredns/coredns/plugin" - "github.com/coredns/coredns/plugin/etcd/msg" - "github.com/coredns/coredns/plugin/pkg/dnsutil" - "github.com/coredns/coredns/plugin/pkg/nonwriter" - "github.com/coredns/coredns/request" - - "github.com/miekg/dns" -) - -// Federation contains the name to zone mapping used for federation in kubernetes. -type Federation struct { - f map[string]string - zones []string - - Next plugin.Handler - Federations Func -} - -// Func needs to be implemented by any plugin that implements -// federation. Right now this is only the kubernetes plugin. -type Func func(state request.Request, fname, fzone string) (msg.Service, error) - -// New returns a new federation. -func New() *Federation { - return &Federation{f: make(map[string]string)} -} - -// ServeDNS implements the plugin.Handle interface. -func (f *Federation) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (int, error) { - if f.Federations == nil { - return plugin.NextOrFailure(f.Name(), f.Next, ctx, w, r) - } - - state := request.Request{W: w, Req: r} - zone := plugin.Zones(f.zones).Matches(state.Name()) - if zone == "" { - return plugin.NextOrFailure(f.Name(), f.Next, ctx, w, r) - } - - state.Zone = zone - - // Remove the federation label from the qname to see if something exists. - without, label := f.isNameFederation(state.Name(), state.Zone) - if without == "" { - return plugin.NextOrFailure(f.Name(), f.Next, ctx, w, r) - } - - qname := r.Question[0].Name - r.Question[0].Name = without - state.Clear() - - // Start the next plugin, but with a nowriter, capture the result, if NXDOMAIN - // perform federation, otherwise just write the result. - nw := nonwriter.New(w) - ret, err := plugin.NextOrFailure(f.Name(), f.Next, ctx, nw, r) - - if !plugin.ClientWrite(ret) { - // something went wrong - r.Question[0].Name = qname - return ret, err - } - - if m := nw.Msg; m.Rcode != dns.RcodeNameError { - // If positive answer we need to substitute the original qname in the answer. - m.Question[0].Name = qname - for _, a := range m.Answer { - a.Header().Name = qname - } - - state.SizeAndDo(m) - m, _ = state.Scrub(m) - w.WriteMsg(m) - - return dns.RcodeSuccess, nil - } - - // Still here, we've seen NXDOMAIN and need to perform federation. - service, err := f.Federations(state, label, f.f[label]) // state references Req which has updated qname - if err != nil { - r.Question[0].Name = qname - return dns.RcodeServerFailure, err - } - - r.Question[0].Name = qname - - m := new(dns.Msg) - m.SetReply(r) - m.Authoritative, m.RecursionAvailable = true, true - - m.Answer = []dns.RR{service.NewCNAME(state.QName(), service.Host)} - - state.SizeAndDo(m) - m, _ = state.Scrub(m) - w.WriteMsg(m) - - return dns.RcodeSuccess, nil -} - -// Name implements the plugin.Handle interface. -func (f *Federation) Name() string { return "federation" } - -// IsNameFederation checks the qname to see if it is a potential federation. The federation -// label is always the 2nd to last once the zone is chopped of. For instance -// "nginx.mynamespace.myfederation.svc.example.com" has "myfederation" as the federation label. -// IsNameFederation returns a new qname with the federation label and the label itself or two -// empty strings if there wasn't a hit. -func (f *Federation) isNameFederation(name, zone string) (string, string) { - base, _ := dnsutil.TrimZone(name, zone) - - // TODO(miek): dns.PrevLabel is better for memory, or dns.Split. - labels := dns.SplitDomainName(base) - ll := len(labels) - if ll < 2 { - return "", "" - } - - fed := labels[ll-2] - - if _, ok := f.f[fed]; ok { - without := dnsutil.Join(labels[:ll-2]) + labels[ll-1] + "." + zone - return without, fed - } - return "", "" -} diff --git a/vendor/github.com/coredns/coredns/plugin/federation/federation_test.go b/vendor/github.com/coredns/coredns/plugin/federation/federation_test.go deleted file mode 100644 index 54a9c350..00000000 --- a/vendor/github.com/coredns/coredns/plugin/federation/federation_test.go +++ /dev/null @@ -1,81 +0,0 @@ -package federation - -import ( - "context" - "testing" - - "github.com/coredns/coredns/plugin/kubernetes" - "github.com/coredns/coredns/plugin/pkg/dnstest" - "github.com/coredns/coredns/plugin/test" - - "github.com/miekg/dns" -) - -func TestIsNameFederation(t *testing.T) { - tests := []struct { - fed string - qname string - expectedZone string - }{ - {"prod", "nginx.mynamespace.prod.svc.example.com.", "nginx.mynamespace.svc.example.com."}, - {"prod", "nginx.mynamespace.staging.svc.example.com.", ""}, - {"prod", "nginx.mynamespace.example.com.", ""}, - {"prod", "example.com.", ""}, - {"prod", "com.", ""}, - } - - fed := New() - for i, tc := range tests { - fed.f[tc.fed] = "test-name" - if x, _ := fed.isNameFederation(tc.qname, "example.com."); x != tc.expectedZone { - t.Errorf("Test %d, failed to get zone, expected %s, got %s", i, tc.expectedZone, x) - } - } -} - -func TestFederationKubernetes(t *testing.T) { - tests := []test.Case{ - { - // service exists so we return the IP address associated with it. - Qname: "svc1.testns.prod.svc.cluster.local.", Qtype: dns.TypeA, - Rcode: dns.RcodeSuccess, - Answer: []dns.RR{ - test.A("svc1.testns.prod.svc.cluster.local. 303 IN A 10.0.0.1"), - }, - }, - { - // service does not exist, do the federation dance. - Qname: "svc0.testns.prod.svc.cluster.local.", Qtype: dns.TypeA, - Rcode: dns.RcodeSuccess, - Answer: []dns.RR{ - test.CNAME("svc0.testns.prod.svc.cluster.local. 303 IN CNAME svc0.testns.prod.svc.fd-az.fd-r.federal.example."), - }, - }, - } - - k := kubernetes.New([]string{"cluster.local."}) - k.APIConn = &APIConnFederationTest{} - - fed := New() - fed.zones = []string{"cluster.local."} - fed.Federations = k.Federations - fed.Next = k - fed.f = map[string]string{ - "prod": "federal.example.", - } - - ctx := context.TODO() - for i, tc := range tests { - m := tc.Msg() - - rec := dnstest.NewRecorder(&test.ResponseWriter{}) - _, err := fed.ServeDNS(ctx, rec, m) - if err != nil { - t.Errorf("Test %d, expected no error, got %v\n", i, err) - return - } - - resp := rec.Msg - test.SortAndCheck(t, resp, tc) - } -} diff --git a/vendor/github.com/coredns/coredns/plugin/federation/kubernetes_api_test.go b/vendor/github.com/coredns/coredns/plugin/federation/kubernetes_api_test.go deleted file mode 100644 index ee4757d2..00000000 --- a/vendor/github.com/coredns/coredns/plugin/federation/kubernetes_api_test.go +++ /dev/null @@ -1,193 +0,0 @@ -package federation - -import ( - "github.com/coredns/coredns/plugin/kubernetes" - - api "k8s.io/api/core/v1" - meta "k8s.io/apimachinery/pkg/apis/meta/v1" -) - -type APIConnFederationTest struct{} - -func (APIConnFederationTest) HasSynced() bool { return true } -func (APIConnFederationTest) Run() { return } -func (APIConnFederationTest) Stop() error { return nil } -func (APIConnFederationTest) SvcIndexReverse(string) []*api.Service { return nil } -func (APIConnFederationTest) EpIndexReverse(string) []*api.Endpoints { return nil } -func (APIConnFederationTest) Modified() int64 { return 0 } - -func (APIConnFederationTest) PodIndex(string) []*api.Pod { - a := []*api.Pod{{ - ObjectMeta: meta.ObjectMeta{ - Namespace: "podns", - }, - Status: api.PodStatus{ - PodIP: "10.240.0.1", // Remote IP set in test.ResponseWriter - }, - }} - return a -} - -func (APIConnFederationTest) SvcIndex(string) []*api.Service { - svcs := []*api.Service{ - { - ObjectMeta: meta.ObjectMeta{ - Name: "svc1", - Namespace: "testns", - }, - Spec: api.ServiceSpec{ - ClusterIP: "10.0.0.1", - Ports: []api.ServicePort{{ - Name: "http", - Protocol: "tcp", - Port: 80, - }}, - }, - }, - { - ObjectMeta: meta.ObjectMeta{ - Name: "hdls1", - Namespace: "testns", - }, - Spec: api.ServiceSpec{ - ClusterIP: api.ClusterIPNone, - }, - }, - { - ObjectMeta: meta.ObjectMeta{ - Name: "external", - Namespace: "testns", - }, - Spec: api.ServiceSpec{ - ExternalName: "ext.interwebs.test", - Ports: []api.ServicePort{{ - Name: "http", - Protocol: "tcp", - Port: 80, - }}, - }, - }, - } - return svcs -} - -func (APIConnFederationTest) ServiceList() []*api.Service { - svcs := []*api.Service{ - { - ObjectMeta: meta.ObjectMeta{ - Name: "svc1", - Namespace: "testns", - }, - Spec: api.ServiceSpec{ - ClusterIP: "10.0.0.1", - Ports: []api.ServicePort{{ - Name: "http", - Protocol: "tcp", - Port: 80, - }}, - }, - }, - { - ObjectMeta: meta.ObjectMeta{ - Name: "hdls1", - Namespace: "testns", - }, - Spec: api.ServiceSpec{ - ClusterIP: api.ClusterIPNone, - }, - }, - { - ObjectMeta: meta.ObjectMeta{ - Name: "external", - Namespace: "testns", - }, - Spec: api.ServiceSpec{ - ExternalName: "ext.interwebs.test", - Ports: []api.ServicePort{{ - Name: "http", - Protocol: "tcp", - Port: 80, - }}, - }, - }, - } - return svcs -} - -func (APIConnFederationTest) EpIndex(string) []*api.Endpoints { - eps := []*api.Endpoints{ - { - Subsets: []api.EndpointSubset{ - { - Addresses: []api.EndpointAddress{ - { - IP: "172.0.0.1", - Hostname: "ep1a", - }, - }, - Ports: []api.EndpointPort{ - { - Port: 80, - Protocol: "tcp", - Name: "http", - }, - }, - }, - }, - ObjectMeta: meta.ObjectMeta{ - Name: "svc1", - Namespace: "testns", - }, - }, - } - return eps -} - -func (APIConnFederationTest) EndpointsList() []*api.Endpoints { - eps := []*api.Endpoints{ - { - Subsets: []api.EndpointSubset{ - { - Addresses: []api.EndpointAddress{ - { - IP: "172.0.0.1", - Hostname: "ep1a", - }, - }, - Ports: []api.EndpointPort{ - { - Port: 80, - Protocol: "tcp", - Name: "http", - }, - }, - }, - }, - ObjectMeta: meta.ObjectMeta{ - Name: "svc1", - Namespace: "testns", - }, - }, - } - return eps -} - -func (APIConnFederationTest) GetNodeByName(name string) (*api.Node, error) { - return &api.Node{ - ObjectMeta: meta.ObjectMeta{ - Name: "test.node.foo.bar", - Labels: map[string]string{ - kubernetes.LabelRegion: "fd-r", - kubernetes.LabelZone: "fd-az", - }, - }, - }, nil -} - -func (APIConnFederationTest) GetNamespaceByName(name string) (*api.Namespace, error) { - return &api.Namespace{ - ObjectMeta: meta.ObjectMeta{ - Name: name, - }, - }, nil -} diff --git a/vendor/github.com/coredns/coredns/plugin/federation/setup.go b/vendor/github.com/coredns/coredns/plugin/federation/setup.go deleted file mode 100644 index 72514fe8..00000000 --- a/vendor/github.com/coredns/coredns/plugin/federation/setup.go +++ /dev/null @@ -1,89 +0,0 @@ -package federation - -import ( - "fmt" - - "github.com/coredns/coredns/core/dnsserver" - "github.com/coredns/coredns/plugin" - "github.com/coredns/coredns/plugin/kubernetes" - "github.com/miekg/dns" - - "github.com/mholt/caddy" -) - -func init() { - caddy.RegisterPlugin("federation", caddy.Plugin{ - ServerType: "dns", - Action: setup, - }) -} - -func setup(c *caddy.Controller) error { - fed, err := federationParse(c) - if err != nil { - return plugin.Error("federation", err) - } - - // Do this in OnStartup, so all plugin has been initialized. - c.OnStartup(func() error { - m := dnsserver.GetConfig(c).Handler("kubernetes") - if m == nil { - return nil - } - if x, ok := m.(*kubernetes.Kubernetes); ok { - fed.Federations = x.Federations - } - return nil - }) - - dnsserver.GetConfig(c).AddPlugin(func(next plugin.Handler) plugin.Handler { - fed.Next = next - return fed - }) - - return nil -} - -func federationParse(c *caddy.Controller) (*Federation, error) { - fed := New() - - for c.Next() { - // federation [zones..] - zones := c.RemainingArgs() - origins := []string{} - if len(zones) > 0 { - origins = make([]string, len(zones)) - copy(origins, zones) - } else { - origins = make([]string, len(c.ServerBlockKeys)) - copy(origins, c.ServerBlockKeys) - } - - for c.NextBlock() { - x := c.Val() - switch x { - default: - args := c.RemainingArgs() - if x := len(args); x != 1 { - return fed, fmt.Errorf("need two arguments for federation, got %d", x) - } - - fed.f[x] = dns.Fqdn(args[0]) - } - } - - for i := range origins { - origins[i] = plugin.Host(origins[i]).Normalize() - } - - fed.zones = origins - - if len(fed.f) == 0 { - return fed, fmt.Errorf("at least one name to zone federation expected") - } - - return fed, nil - } - - return fed, nil -} diff --git a/vendor/github.com/coredns/coredns/plugin/federation/setup_test.go b/vendor/github.com/coredns/coredns/plugin/federation/setup_test.go deleted file mode 100644 index e85b0177..00000000 --- a/vendor/github.com/coredns/coredns/plugin/federation/setup_test.go +++ /dev/null @@ -1,65 +0,0 @@ -package federation - -import ( - "testing" - - "github.com/mholt/caddy" -) - -func TestSetup(t *testing.T) { - tests := []struct { - input string - shouldErr bool - expectedLen int - expectedNameZone []string // contains only entry for now - }{ - // ok - {`federation { - prod prod.example.org - }`, false, 1, []string{"prod", "prod.example.org."}}, - - {`federation { - staging staging.example.org - prod prod.example.org - }`, false, 2, []string{"prod", "prod.example.org."}}, - {`federation { - staging staging.example.org - prod prod.example.org - }`, false, 2, []string{"staging", "staging.example.org."}}, - {`federation example.com { - staging staging.example.org - prod prod.example.org - }`, false, 2, []string{"staging", "staging.example.org."}}, - // errors - {`federation { - }`, true, 0, []string{}}, - {`federation { - staging - }`, true, 0, []string{}}, - } - for i, test := range tests { - c := caddy.NewTestController("dns", test.input) - fed, err := federationParse(c) - if test.shouldErr && err == nil { - t.Errorf("Test %v: Expected error but found nil", i) - continue - } else if !test.shouldErr && err != nil { - t.Errorf("Test %v: Expected no error but found error: %v", i, err) - continue - } - if test.shouldErr && err != nil { - continue - } - - if x := len(fed.f); x != test.expectedLen { - t.Errorf("Test %v: Expected map length of %d, got: %d", i, test.expectedLen, x) - } - if x, ok := fed.f[test.expectedNameZone[0]]; !ok { - t.Errorf("Test %v: Expected name for %s, got nothing", i, test.expectedNameZone[0]) - } else { - if x != test.expectedNameZone[1] { - t.Errorf("Test %v: Expected zone: %s, got %s", i, test.expectedNameZone[1], x) - } - } - } -} diff --git a/vendor/github.com/coredns/coredns/plugin/file/OWNERS b/vendor/github.com/coredns/coredns/plugin/file/OWNERS deleted file mode 100644 index b69d5c74..00000000 --- a/vendor/github.com/coredns/coredns/plugin/file/OWNERS +++ /dev/null @@ -1,7 +0,0 @@ -reviewers: - - miekg - - yongtang - - stp-ip -approvers: - - miekg - - yongtang diff --git a/vendor/github.com/coredns/coredns/plugin/file/README.md b/vendor/github.com/coredns/coredns/plugin/file/README.md deleted file mode 100644 index 1643251c..00000000 --- a/vendor/github.com/coredns/coredns/plugin/file/README.md +++ /dev/null @@ -1,70 +0,0 @@ -# file - -## Name - -*file* - enables serving zone data from an RFC 1035-style master file. - -## Description - -The file plugin is used for an "old-style" DNS server. It serves from a preloaded file that exists -on disk. If the zone file contains signatures (i.e. is signed, i.e. DNSSEC) correct DNSSEC answers -are returned. Only NSEC is supported! If you use this setup *you* are responsible for resigning the -zonefile. - -## Syntax - -~~~ -file DBFILE [ZONES...] -~~~ - -* **DBFILE** the database file to read and parse. If the path is relative the path from the *root* - directive will be prepended to it. -* **ZONES** zones it should be authoritative for. If empty, the zones from the configuration block - are used. - -If you want to round robin A and AAAA responses look at the *loadbalance* plugin. - -~~~ -file DBFILE [ZONES... ] { - transfer to ADDRESS... - no_reload - upstream [ADDRESS...] -} -~~~ - -* `transfer` enables zone transfers. It may be specified multiples times. `To` or `from` signals - the direction. **ADDRESS** must be denoted in CIDR notation (127.0.0.1/32 etc.) or just as plain - addresses. The special wildcard `*` means: the entire internet (only valid for 'transfer to'). - When an address is specified a notify message will be send whenever the zone is reloaded. -* `no_reload` by default CoreDNS will try to reload a zone every minute and reloads if the - SOA's serial has changed. This option disables that behavior. -* `upstream` defines upstream resolvers to be used resolve external names found (think CNAMEs) - pointing to external names. This is only really useful when CoreDNS is configured as a proxy, for - normal authoritative serving you don't need *or* want to use this. **ADDRESS** can be an IP - address, and IP:port or a string pointing to a file that is structured as /etc/resolv.conf. - If no **ADDRESS** is given, CoreDNS will resolve CNAMEs against itself. - -## Examples - -Load the `example.org` zone from `example.org.signed` and allow transfers to the internet, but send -notifies to 10.240.1.1 - -~~~ corefile -example.org { - file example.org.signed { - transfer to * - transfer to 10.240.1.1 - } -} -~~~ - -Or use a single zone file for multiple zones: - -~~~ -. { - file example.org.signed example.org example.net { - transfer to * - transfer to 10.240.1.1 - } -} -~~~ diff --git a/vendor/github.com/coredns/coredns/plugin/file/closest.go b/vendor/github.com/coredns/coredns/plugin/file/closest.go deleted file mode 100644 index 64652af8..00000000 --- a/vendor/github.com/coredns/coredns/plugin/file/closest.go +++ /dev/null @@ -1,24 +0,0 @@ -package file - -import ( - "github.com/coredns/coredns/plugin/file/tree" - - "github.com/miekg/dns" -) - -// ClosestEncloser returns the closest encloser for qname. -func (z *Zone) ClosestEncloser(qname string) (*tree.Elem, bool) { - - offset, end := dns.NextLabel(qname, 0) - for !end { - elem, _ := z.Tree.Search(qname) - if elem != nil { - return elem, true - } - qname = qname[offset:] - - offset, end = dns.NextLabel(qname, offset) - } - - return z.Tree.Search(z.origin) -} diff --git a/vendor/github.com/coredns/coredns/plugin/file/closest_test.go b/vendor/github.com/coredns/coredns/plugin/file/closest_test.go deleted file mode 100644 index 40c04ff2..00000000 --- a/vendor/github.com/coredns/coredns/plugin/file/closest_test.go +++ /dev/null @@ -1,38 +0,0 @@ -package file - -import ( - "strings" - "testing" -) - -func TestClosestEncloser(t *testing.T) { - z, err := Parse(strings.NewReader(dbMiekNL), testzone, "stdin", 0) - if err != nil { - t.Fatalf("Expect no error when reading zone, got %q", err) - } - - tests := []struct { - in, out string - }{ - {"miek.nl.", "miek.nl."}, - {"www.miek.nl.", "www.miek.nl."}, - - {"blaat.miek.nl.", "miek.nl."}, - {"blaat.www.miek.nl.", "www.miek.nl."}, - {"www.blaat.miek.nl.", "miek.nl."}, - {"blaat.a.miek.nl.", "a.miek.nl."}, - } - - for _, tc := range tests { - ce, _ := z.ClosestEncloser(tc.in) - if ce == nil { - if z.origin != tc.out { - t.Errorf("Expected ce to be %s for %s, got %s", tc.out, tc.in, ce.Name()) - } - continue - } - if ce.Name() != tc.out { - t.Errorf("Expected ce to be %s for %s, got %s", tc.out, tc.in, ce.Name()) - } - } -} diff --git a/vendor/github.com/coredns/coredns/plugin/file/cname_test.go b/vendor/github.com/coredns/coredns/plugin/file/cname_test.go deleted file mode 100644 index 10eb7d93..00000000 --- a/vendor/github.com/coredns/coredns/plugin/file/cname_test.go +++ /dev/null @@ -1,124 +0,0 @@ -package file - -import ( - "context" - "strings" - "testing" - - "github.com/coredns/coredns/plugin/pkg/dnstest" - "github.com/coredns/coredns/plugin/pkg/upstream" - "github.com/coredns/coredns/plugin/test" - - "github.com/miekg/dns" -) - -func TestLookupCNAMEChain(t *testing.T) { - name := "example.org." - zone, err := Parse(strings.NewReader(dbExampleCNAME), name, "stdin", 0) - if err != nil { - t.Fatalf("Expected no error when reading zone, got %q", err) - } - - fm := File{Next: test.ErrorHandler(), Zones: Zones{Z: map[string]*Zone{name: zone}, Names: []string{name}}} - ctx := context.TODO() - - for _, tc := range cnameTestCases { - m := tc.Msg() - - rec := dnstest.NewRecorder(&test.ResponseWriter{}) - _, err := fm.ServeDNS(ctx, rec, m) - if err != nil { - t.Errorf("Expected no error, got %v\n", err) - return - } - - resp := rec.Msg - test.SortAndCheck(t, resp, tc) - } -} - -var cnameTestCases = []test.Case{ - { - Qname: "a.example.org.", Qtype: dns.TypeA, - Answer: []dns.RR{ - test.A("a.example.org. 1800 IN A 127.0.0.1"), - }, - }, - { - Qname: "www3.example.org.", Qtype: dns.TypeCNAME, - Answer: []dns.RR{ - test.CNAME("www3.example.org. 1800 IN CNAME www2.example.org."), - }, - }, - { - Qname: "dangling.example.org.", Qtype: dns.TypeA, - Answer: []dns.RR{ - test.CNAME("dangling.example.org. 1800 IN CNAME foo.example.org."), - }, - }, - { - Qname: "www3.example.org.", Qtype: dns.TypeA, - Answer: []dns.RR{ - test.A("a.example.org. 1800 IN A 127.0.0.1"), - test.CNAME("www.example.org. 1800 IN CNAME a.example.org."), - test.CNAME("www1.example.org. 1800 IN CNAME www.example.org."), - test.CNAME("www2.example.org. 1800 IN CNAME www1.example.org."), - test.CNAME("www3.example.org. 1800 IN CNAME www2.example.org."), - }, - }, -} - -func TestLookupCNAMEExternal(t *testing.T) { - name := "example.org." - zone, err := Parse(strings.NewReader(dbExampleCNAME), name, "stdin", 0) - if err != nil { - t.Fatalf("Expected no error when reading zone, got %q", err) - } - zone.Upstream, _ = upstream.New([]string{"8.8.8.8:53"}) // TODO(miek): point to local instance - - fm := File{Next: test.ErrorHandler(), Zones: Zones{Z: map[string]*Zone{name: zone}, Names: []string{name}}} - ctx := context.TODO() - - for _, tc := range exernalTestCases { - m := tc.Msg() - - rec := dnstest.NewRecorder(&test.ResponseWriter{}) - _, err := fm.ServeDNS(ctx, rec, m) - if err != nil { - t.Errorf("Expected no error, got %v\n", err) - return - } - - resp := rec.Msg - test.SortAndCheck(t, resp, tc) - } -} - -var exernalTestCases = []test.Case{ - { - Qname: "external.example.org.", Qtype: dns.TypeA, - Answer: []dns.RR{ - test.CNAME("external.example.org. 1800 CNAME www.example.net."), - // magic 303 TTL that says: don't check TTL. - test.A("www.example.net. 303 IN A 93.184.216.34"), - }, - }, -} - -const dbExampleCNAME = ` -$TTL 30M -$ORIGIN example.org. -@ IN SOA linode.atoom.net. miek.miek.nl. ( - 1282630057 ; Serial - 4H ; Refresh - 1H ; Retry - 7D ; Expire - 4H ) ; Negative Cache TTL - -a IN A 127.0.0.1 -www3 IN CNAME www2 -www2 IN CNAME www1 -www1 IN CNAME www -www IN CNAME a -dangling IN CNAME foo -external IN CNAME www.example.net.` diff --git a/vendor/github.com/coredns/coredns/plugin/file/delegation_test.go b/vendor/github.com/coredns/coredns/plugin/file/delegation_test.go deleted file mode 100644 index 116b6b24..00000000 --- a/vendor/github.com/coredns/coredns/plugin/file/delegation_test.go +++ /dev/null @@ -1,227 +0,0 @@ -package file - -import ( - "context" - "strings" - "testing" - - "github.com/coredns/coredns/plugin/pkg/dnstest" - "github.com/coredns/coredns/plugin/test" - - "github.com/miekg/dns" -) - -var delegationTestCases = []test.Case{ - { - Qname: "a.delegated.miek.nl.", Qtype: dns.TypeTXT, - Ns: []dns.RR{ - test.NS("delegated.miek.nl. 1800 IN NS a.delegated.miek.nl."), - test.NS("delegated.miek.nl. 1800 IN NS ns-ext.nlnetlabs.nl."), - }, - Extra: []dns.RR{ - test.A("a.delegated.miek.nl. 1800 IN A 139.162.196.78"), - test.AAAA("a.delegated.miek.nl. 1800 IN AAAA 2a01:7e00::f03c:91ff:fef1:6735"), - }, - }, - { - Qname: "delegated.miek.nl.", Qtype: dns.TypeNS, - Ns: []dns.RR{ - test.NS("delegated.miek.nl. 1800 IN NS a.delegated.miek.nl."), - test.NS("delegated.miek.nl. 1800 IN NS ns-ext.nlnetlabs.nl."), - }, - Extra: []dns.RR{ - test.A("a.delegated.miek.nl. 1800 IN A 139.162.196.78"), - test.AAAA("a.delegated.miek.nl. 1800 IN AAAA 2a01:7e00::f03c:91ff:fef1:6735"), - }, - }, - { - Qname: "foo.delegated.miek.nl.", Qtype: dns.TypeA, - Ns: []dns.RR{ - test.NS("delegated.miek.nl. 1800 IN NS a.delegated.miek.nl."), - test.NS("delegated.miek.nl. 1800 IN NS ns-ext.nlnetlabs.nl."), - }, - Extra: []dns.RR{ - test.A("a.delegated.miek.nl. 1800 IN A 139.162.196.78"), - test.AAAA("a.delegated.miek.nl. 1800 IN AAAA 2a01:7e00::f03c:91ff:fef1:6735"), - }, - }, - { - Qname: "foo.delegated.miek.nl.", Qtype: dns.TypeTXT, - Ns: []dns.RR{ - test.NS("delegated.miek.nl. 1800 IN NS a.delegated.miek.nl."), - test.NS("delegated.miek.nl. 1800 IN NS ns-ext.nlnetlabs.nl."), - }, - Extra: []dns.RR{ - test.A("a.delegated.miek.nl. 1800 IN A 139.162.196.78"), - test.AAAA("a.delegated.miek.nl. 1800 IN AAAA 2a01:7e00::f03c:91ff:fef1:6735"), - }, - }, - { - Qname: "miek.nl.", Qtype: dns.TypeSOA, - Answer: []dns.RR{ - test.SOA("miek.nl. 1800 IN SOA linode.atoom.net. miek.miek.nl. 1282630057 14400 3600 604800 14400"), - }, - Ns: miekAuth, - }, - { - Qname: "miek.nl.", Qtype: dns.TypeAAAA, - Ns: []dns.RR{ - test.SOA("miek.nl. 1800 IN SOA linode.atoom.net. miek.miek.nl. 1282630057 14400 3600 604800 14400"), - }, - }, -} - -var secureDelegationTestCases = []test.Case{ - { - Qname: "a.delegated.example.org.", Qtype: dns.TypeTXT, - Do: true, - Ns: []dns.RR{ - test.DS("delegated.example.org. 1800 IN DS 10056 5 1 EE72CABD1927759CDDA92A10DBF431504B9E1F13"), - test.DS("delegated.example.org. 1800 IN DS 10056 5 2 E4B05F87725FA86D9A64F1E53C3D0E6250946599DFE639C45955B0ED416CDDFA"), - test.NS("delegated.example.org. 1800 IN NS a.delegated.example.org."), - test.NS("delegated.example.org. 1800 IN NS ns-ext.nlnetlabs.nl."), - test.RRSIG("delegated.example.org. 1800 IN RRSIG DS 13 3 1800 20161129153240 20161030153240 49035 example.org. rlNNzcUmtbjLSl02ZzQGUbWX75yCUx0Mug1jHtKVqRq1hpPE2S3863tIWSlz+W9wz4o19OI4jbznKKqk+DGKog=="), - }, - Extra: []dns.RR{ - test.OPT(4096, true), - test.A("a.delegated.example.org. 1800 IN A 139.162.196.78"), - test.AAAA("a.delegated.example.org. 1800 IN AAAA 2a01:7e00::f03c:91ff:fef1:6735"), - }, - }, - { - Qname: "delegated.example.org.", Qtype: dns.TypeNS, - Do: true, - Ns: []dns.RR{ - test.DS("delegated.example.org. 1800 IN DS 10056 5 1 EE72CABD1927759CDDA92A10DBF431504B9E1F13"), - test.DS("delegated.example.org. 1800 IN DS 10056 5 2 E4B05F87725FA86D9A64F1E53C3D0E6250946599DFE639C45955B0ED416CDDFA"), - test.NS("delegated.example.org. 1800 IN NS a.delegated.example.org."), - test.NS("delegated.example.org. 1800 IN NS ns-ext.nlnetlabs.nl."), - test.RRSIG("delegated.example.org. 1800 IN RRSIG DS 13 3 1800 20161129153240 20161030153240 49035 example.org. rlNNzcUmtbjLSl02ZzQGUbWX75yCUx0Mug1jHtKVqRq1hpPE2S3863tIWSlz+W9wz4o19OI4jbznKKqk+DGKog=="), - }, - Extra: []dns.RR{ - test.OPT(4096, true), - test.A("a.delegated.example.org. 1800 IN A 139.162.196.78"), - test.AAAA("a.delegated.example.org. 1800 IN AAAA 2a01:7e00::f03c:91ff:fef1:6735"), - }, - }, - { - Qname: "foo.delegated.example.org.", Qtype: dns.TypeA, - Do: true, - Ns: []dns.RR{ - test.DS("delegated.example.org. 1800 IN DS 10056 5 1 EE72CABD1927759CDDA92A10DBF431504B9E1F13"), - test.DS("delegated.example.org. 1800 IN DS 10056 5 2 E4B05F87725FA86D9A64F1E53C3D0E6250946599DFE639C45955B0ED416CDDFA"), - test.NS("delegated.example.org. 1800 IN NS a.delegated.example.org."), - test.NS("delegated.example.org. 1800 IN NS ns-ext.nlnetlabs.nl."), - test.RRSIG("delegated.example.org. 1800 IN RRSIG DS 13 3 1800 20161129153240 20161030153240 49035 example.org. rlNNzcUmtbjLSl02ZzQGUbWX75yCUx0Mug1jHtKVqRq1hpPE2S3863tIWSlz+W9wz4o19OI4jbznKKqk+DGKog=="), - }, - Extra: []dns.RR{ - test.OPT(4096, true), - test.A("a.delegated.example.org. 1800 IN A 139.162.196.78"), - test.AAAA("a.delegated.example.org. 1800 IN AAAA 2a01:7e00::f03c:91ff:fef1:6735"), - }, - }, - { - Qname: "foo.delegated.example.org.", Qtype: dns.TypeDS, - Do: true, - Ns: []dns.RR{ - test.DS("delegated.example.org. 1800 IN DS 10056 5 1 EE72CABD1927759CDDA92A10DBF431504B9E1F13"), - test.DS("delegated.example.org. 1800 IN DS 10056 5 2 E4B05F87725FA86D9A64F1E53C3D0E6250946599DFE639C45955B0ED416CDDFA"), - test.NS("delegated.example.org. 1800 IN NS a.delegated.example.org."), - test.NS("delegated.example.org. 1800 IN NS ns-ext.nlnetlabs.nl."), - test.RRSIG("delegated.example.org. 1800 IN RRSIG DS 13 3 1800 20161129153240 20161030153240 49035 example.org. rlNNzcUmtbjLSl02ZzQGUbWX75yCUx0Mug1jHtKVqRq1hpPE2S3863tIWSlz+W9wz4o19OI4jbznKKqk+DGKog=="), - }, - Extra: []dns.RR{ - test.OPT(4096, true), - test.A("a.delegated.example.org. 1800 IN A 139.162.196.78"), - test.AAAA("a.delegated.example.org. 1800 IN AAAA 2a01:7e00::f03c:91ff:fef1:6735"), - }, - }, - { - Qname: "delegated.example.org.", Qtype: dns.TypeDS, - Do: true, - Answer: []dns.RR{ - test.DS("delegated.example.org. 1800 IN DS 10056 5 1 EE72CABD1927759CDDA92A10DBF431504B9E1F13"), - test.DS("delegated.example.org. 1800 IN DS 10056 5 2 E4B05F87725FA86D9A64F1E53C3D0E6250946599DFE639C45955B0ED416CDDFA"), - test.RRSIG("delegated.example.org. 1800 IN RRSIG DS 13 3 1800 20161129153240 20161030153240 49035 example.org. rlNNzcUmtbjLSl02ZzQGUbWX75yCUx0Mug1jHtKVqRq1hpPE2S3863tIWSlz+W9wz4o19OI4jbznKKqk+DGKog=="), - }, - Ns: []dns.RR{ - test.NS("example.org. 1800 IN NS a.iana-servers.net."), - test.NS("example.org. 1800 IN NS b.iana-servers.net."), - test.RRSIG("example.org. 1800 IN RRSIG NS 13 2 1800 20161129153240 20161030153240 49035 example.org. llrHoIuw="), - }, - Extra: []dns.RR{ - test.OPT(4096, true), - }, - }, -} - -var miekAuth = []dns.RR{ - test.NS("miek.nl. 1800 IN NS ext.ns.whyscream.net."), - test.NS("miek.nl. 1800 IN NS linode.atoom.net."), - test.NS("miek.nl. 1800 IN NS ns-ext.nlnetlabs.nl."), - test.NS("miek.nl. 1800 IN NS omval.tednet.nl."), -} - -func TestLookupDelegation(t *testing.T) { - testDelegation(t, dbMiekNLDelegation, testzone, delegationTestCases) -} - -func TestLookupSecureDelegation(t *testing.T) { - testDelegation(t, exampleOrgSigned, "example.org.", secureDelegationTestCases) -} - -func testDelegation(t *testing.T, z, origin string, testcases []test.Case) { - zone, err := Parse(strings.NewReader(z), origin, "stdin", 0) - if err != nil { - t.Fatalf("Expect no error when reading zone, got %q", err) - } - - fm := File{Next: test.ErrorHandler(), Zones: Zones{Z: map[string]*Zone{origin: zone}, Names: []string{origin}}} - ctx := context.TODO() - - for _, tc := range testcases { - m := tc.Msg() - - rec := dnstest.NewRecorder(&test.ResponseWriter{}) - _, err := fm.ServeDNS(ctx, rec, m) - if err != nil { - t.Errorf("Expected no error, got %q\n", err) - return - } - - resp := rec.Msg - test.SortAndCheck(t, resp, tc) - } -} - -const dbMiekNLDelegation = ` -$TTL 30M -$ORIGIN miek.nl. -@ IN SOA linode.atoom.net. miek.miek.nl. ( - 1282630057 ; Serial - 4H ; Refresh - 1H ; Retry - 7D ; Expire - 4H ) ; Negative Cache TTL - IN NS linode.atoom.net. - IN NS ns-ext.nlnetlabs.nl. - IN NS omval.tednet.nl. - IN NS ext.ns.whyscream.net. - - IN MX 1 aspmx.l.google.com. - IN MX 5 alt1.aspmx.l.google.com. - IN MX 5 alt2.aspmx.l.google.com. - IN MX 10 aspmx2.googlemail.com. - IN MX 10 aspmx3.googlemail.com. - -delegated IN NS a.delegated - IN NS ns-ext.nlnetlabs.nl. - -a.delegated IN TXT "obscured" - IN A 139.162.196.78 - IN AAAA 2a01:7e00::f03c:91ff:fef1:6735 - -a IN A 139.162.196.78 - IN AAAA 2a01:7e00::f03c:91ff:fef1:6735 -www IN CNAME a -archive IN CNAME a` diff --git a/vendor/github.com/coredns/coredns/plugin/file/dname.go b/vendor/github.com/coredns/coredns/plugin/file/dname.go deleted file mode 100644 index f552bfdf..00000000 --- a/vendor/github.com/coredns/coredns/plugin/file/dname.go +++ /dev/null @@ -1,44 +0,0 @@ -package file - -import ( - "github.com/coredns/coredns/plugin/pkg/dnsutil" - - "github.com/miekg/dns" -) - -// substituteDNAME performs the DNAME substitution defined by RFC 6672, -// assuming the QTYPE of the query is not DNAME. It returns an empty -// string if there is no match. -func substituteDNAME(qname, owner, target string) string { - if dns.IsSubDomain(owner, qname) && qname != owner { - labels := dns.SplitDomainName(qname) - labels = append(labels[0:len(labels)-dns.CountLabel(owner)], dns.SplitDomainName(target)...) - - return dnsutil.Join(labels) - } - - return "" -} - -// synthesizeCNAME returns a CNAME RR pointing to the resulting name of -// the DNAME substitution. The owner name of the CNAME is the QNAME of -// the query and the TTL is the same as the corresponding DNAME RR. -// -// It returns nil if the DNAME substitution has no match. -func synthesizeCNAME(qname string, d *dns.DNAME) *dns.CNAME { - target := substituteDNAME(qname, d.Header().Name, d.Target) - if target == "" { - return nil - } - - r := new(dns.CNAME) - r.Hdr = dns.RR_Header{ - Name: qname, - Rrtype: dns.TypeCNAME, - Class: dns.ClassINET, - Ttl: d.Header().Ttl, - } - r.Target = target - - return r -} diff --git a/vendor/github.com/coredns/coredns/plugin/file/dname_test.go b/vendor/github.com/coredns/coredns/plugin/file/dname_test.go deleted file mode 100644 index 9dd2c2e2..00000000 --- a/vendor/github.com/coredns/coredns/plugin/file/dname_test.go +++ /dev/null @@ -1,300 +0,0 @@ -package file - -import ( - "context" - "strings" - "testing" - - "github.com/coredns/coredns/plugin/pkg/dnstest" - "github.com/coredns/coredns/plugin/test" - - "github.com/miekg/dns" -) - -// RFC 6672, Section 2.2. Assuming QTYPE != DNAME. -var dnameSubstitutionTestCases = []struct { - qname string - owner string - target string - expected string -}{ - {"com.", "example.com.", "example.net.", ""}, - {"example.com.", "example.com.", "example.net.", ""}, - {"a.example.com.", "example.com.", "example.net.", "a.example.net."}, - {"a.b.example.com.", "example.com.", "example.net.", "a.b.example.net."}, - {"ab.example.com.", "b.example.com.", "example.net.", ""}, - {"foo.example.com.", "example.com.", "example.net.", "foo.example.net."}, - {"a.x.example.com.", "x.example.com.", "example.net.", "a.example.net."}, - {"a.example.com.", "example.com.", "y.example.net.", "a.y.example.net."}, - {"cyc.example.com.", "example.com.", "example.com.", "cyc.example.com."}, - {"cyc.example.com.", "example.com.", "c.example.com.", "cyc.c.example.com."}, - {"shortloop.x.x.", "x.", ".", "shortloop.x."}, - {"shortloop.x.", "x.", ".", "shortloop."}, -} - -func TestDNAMESubstitution(t *testing.T) { - for i, tc := range dnameSubstitutionTestCases { - result := substituteDNAME(tc.qname, tc.owner, tc.target) - if result != tc.expected { - if result == "" { - result = "" - } - - t.Errorf("Case %d: Expected %s -> %s, got %v", i, tc.qname, tc.expected, result) - return - } - } -} - -var dnameTestCases = []test.Case{ - { - Qname: "dname.miek.nl.", Qtype: dns.TypeDNAME, - Answer: []dns.RR{ - test.DNAME("dname.miek.nl. 1800 IN DNAME test.miek.nl."), - }, - Ns: miekAuth, - }, - { - Qname: "dname.miek.nl.", Qtype: dns.TypeA, - Answer: []dns.RR{ - test.A("dname.miek.nl. 1800 IN A 127.0.0.1"), - }, - Ns: miekAuth, - }, - { - Qname: "dname.miek.nl.", Qtype: dns.TypeMX, - Answer: []dns.RR{}, - Ns: []dns.RR{ - test.SOA("miek.nl. 1800 IN SOA linode.atoom.net. miek.miek.nl. 1282630057 14400 3600 604800 14400"), - }, - }, - { - Qname: "a.dname.miek.nl.", Qtype: dns.TypeA, - Answer: []dns.RR{ - test.CNAME("a.dname.miek.nl. 1800 IN CNAME a.test.miek.nl."), - test.A("a.test.miek.nl. 1800 IN A 139.162.196.78"), - test.DNAME("dname.miek.nl. 1800 IN DNAME test.miek.nl."), - }, - Ns: miekAuth, - }, - { - Qname: "www.dname.miek.nl.", Qtype: dns.TypeA, - Answer: []dns.RR{ - test.A("a.test.miek.nl. 1800 IN A 139.162.196.78"), - test.DNAME("dname.miek.nl. 1800 IN DNAME test.miek.nl."), - test.CNAME("www.dname.miek.nl. 1800 IN CNAME www.test.miek.nl."), - test.CNAME("www.test.miek.nl. 1800 IN CNAME a.test.miek.nl."), - }, - Ns: miekAuth, - }, -} - -func TestLookupDNAME(t *testing.T) { - zone, err := Parse(strings.NewReader(dbMiekNLDNAME), testzone, "stdin", 0) - if err != nil { - t.Fatalf("Expect no error when reading zone, got %q", err) - } - - fm := File{Next: test.ErrorHandler(), Zones: Zones{Z: map[string]*Zone{testzone: zone}, Names: []string{testzone}}} - ctx := context.TODO() - - for _, tc := range dnameTestCases { - m := tc.Msg() - - rec := dnstest.NewRecorder(&test.ResponseWriter{}) - _, err := fm.ServeDNS(ctx, rec, m) - if err != nil { - t.Errorf("Expected no error, got %v\n", err) - return - } - - resp := rec.Msg - test.SortAndCheck(t, resp, tc) - } -} - -var dnameDnssecTestCases = []test.Case{ - { - // We have no auth section, because the test zone does not have nameservers. - Qname: "ns.example.org.", Qtype: dns.TypeA, - Answer: []dns.RR{ - test.A("ns.example.org. 1800 IN A 127.0.0.1"), - }, - }, - { - Qname: "dname.example.org.", Qtype: dns.TypeDNAME, - Do: true, - Answer: []dns.RR{ - test.DNAME("dname.example.org. 1800 IN DNAME test.example.org."), - test.RRSIG("dname.example.org. 1800 IN RRSIG DNAME 5 3 1800 20170702091734 20170602091734 54282 example.org. HvXtiBM="), - }, - Extra: []dns.RR{test.OPT(4096, true)}, - }, - { - Qname: "a.dname.example.org.", Qtype: dns.TypeA, - Do: true, - Answer: []dns.RR{ - test.CNAME("a.dname.example.org. 1800 IN CNAME a.test.example.org."), - test.DNAME("dname.example.org. 1800 IN DNAME test.example.org."), - test.RRSIG("dname.example.org. 1800 IN RRSIG DNAME 5 3 1800 20170702091734 20170602091734 54282 example.org. HvXtiBM="), - }, - Extra: []dns.RR{test.OPT(4096, true)}, - }, -} - -func TestLookupDNAMEDNSSEC(t *testing.T) { - zone, err := Parse(strings.NewReader(dbExampleDNAMESigned), testzone, "stdin", 0) - if err != nil { - t.Fatalf("Expect no error when reading zone, got %q", err) - } - - fm := File{Next: test.ErrorHandler(), Zones: Zones{Z: map[string]*Zone{"example.org.": zone}, Names: []string{"example.org."}}} - ctx := context.TODO() - - for _, tc := range dnameDnssecTestCases { - m := tc.Msg() - - rec := dnstest.NewRecorder(&test.ResponseWriter{}) - _, err := fm.ServeDNS(ctx, rec, m) - if err != nil { - t.Errorf("Expected no error, got %v\n", err) - return - } - - resp := rec.Msg - test.SortAndCheck(t, resp, tc) - } -} - -const dbMiekNLDNAME = ` -$TTL 30M -$ORIGIN miek.nl. -@ IN SOA linode.atoom.net. miek.miek.nl. ( - 1282630057 ; Serial - 4H ; Refresh - 1H ; Retry - 7D ; Expire - 4H ) ; Negative Cache TTL - IN NS linode.atoom.net. - IN NS ns-ext.nlnetlabs.nl. - IN NS omval.tednet.nl. - IN NS ext.ns.whyscream.net. - -test IN MX 1 aspmx.l.google.com. - IN MX 5 alt1.aspmx.l.google.com. - IN MX 5 alt2.aspmx.l.google.com. - IN MX 10 aspmx2.googlemail.com. - IN MX 10 aspmx3.googlemail.com. -a.test IN A 139.162.196.78 - IN AAAA 2a01:7e00::f03c:91ff:fef1:6735 -www.test IN CNAME a.test - -dname IN DNAME test -dname IN A 127.0.0.1 -a.dname IN A 127.0.0.1 -` - -const dbExampleDNAMESigned = ` -; File written on Fri Jun 2 10:17:34 2017 -; dnssec_signzone version 9.10.3-P4-Debian -example.org. 1800 IN SOA a.example.org. b.example.org. ( - 1282630057 ; serial - 14400 ; refresh (4 hours) - 3600 ; retry (1 hour) - 604800 ; expire (1 week) - 14400 ; minimum (4 hours) - ) - 1800 RRSIG SOA 5 2 1800 ( - 20170702091734 20170602091734 54282 example.org. - mr5eQtFs1GubgwaCcqrpiF6Cgi822OkESPeV - X0OJYq3JzthJjHw8TfYAJWQ2yGqhlePHir9h - FT/uFZdYyytHq+qgIUbJ9IVCrq0gZISZdHML - Ry1DNffMR9CpD77KocOAUABfopcvH/3UGOHn - TFxkAr447zPaaoC68JYGxYLfZk8= ) - 1800 NS ns.example.org. - 1800 RRSIG NS 5 2 1800 ( - 20170702091734 20170602091734 54282 example.org. - McM4UdMxkscVQkJnnEbdqwyjpPgq5a/EuOLA - r2MvG43/cwOaWULiZoNzLi5Rjzhf+GTeVTan - jw6EsL3gEuYI1nznwlLQ04/G0XAHjbq5VvJc - rlscBD+dzf774yfaTjRNoeo2xTem6S7nyYPW - Y+1f6xkrsQPLYJfZ6VZ9QqyupBw= ) - 14400 NSEC dname.example.org. NS SOA RRSIG NSEC DNSKEY - 14400 RRSIG NSEC 5 2 14400 ( - 20170702091734 20170602091734 54282 example.org. - VT+IbjDFajM0doMKFipdX3+UXfCn3iHIxg5x - LElp4Q/YddTbX+6tZf53+EO+G8Kye3JDLwEl - o8VceijNeF3igZ+LiZuXCei5Qg/TJ7IAUnAO - xd85IWwEYwyKkKd6Z2kXbAN2pdcHE8EmboQd - wfTr9oyWhpZk1Z+pN8vdejPrG0M= ) - 1800 DNSKEY 256 3 5 ( - AwEAAczLlmTk5bMXUzpBo/Jta6MWSZYy3Nfw - gz8t/pkfSh4IlFF6vyXZhEqCeQsCBdD7ltkD - h5qd4A+nFrYOMwsi5XIjoHMlJN15xwFS9EgS - ZrZmuxePIEiYB5KccEf9JQMgM1t07Iu1FnrY - 02OuAqGWcO4tuyTLaK3QP4MLQOfAgKqf - ) ; ZSK; alg = RSASHA1; key id = 54282 - 1800 RRSIG DNSKEY 5 2 1800 ( - 20170702091734 20170602091734 54282 example.org. - MBgSRtZ6idJblLIHxZWpWL/1oqIwImb1mkl7 - hDFxqV6Hw19yLX06P7gcJEWiisdZBkVEfcOK - LeMJly05vgKfrMzLgIu2Ry4bL8AMKc8NMXBG - b1VDCEBW69P2omogj2KnORHDCZQr/BX9+wBU - 5rIMTTKlMSI5sT6ecJHHEymtiac= ) -dname.example.org. 1800 IN A 127.0.0.1 - 1800 RRSIG A 5 3 1800 ( - 20170702091734 20170602091734 54282 example.org. - LPCK2nLyDdGwvmzGLkUO2atEUjoc+aEspkC3 - keZCdXZaLnAwBH7dNAjvvXzzy0WrgWeiyDb4 - +rJ2N0oaKEZicM4QQDHKhugJblKbU5G4qTey - LSEaV3vvQnzGd0S6dCqnwfPj9czagFN7Zlf5 - DmLtdxx0aiDPCUpqT0+H/vuGPfk= ) - 1800 DNAME test.example.org. - 1800 RRSIG DNAME 5 3 1800 ( - 20170702091734 20170602091734 54282 example.org. - HvX79T1flWJ8H9/1XZjX6gz8rP/o2jbfPXJ9 - vC7ids/ZJilSReabLru4DCqcw1IV2DM/CZdE - tBnED/T2PJXvMut9tnYMrz+ZFPxoV6XyA3Z7 - bok3B0OuxizzAN2EXdol04VdbMHoWUzjQCzi - 0Ri12zLGRPzDepZ7FolgD+JtiBM= ) - 14400 NSEC a.dname.example.org. A DNAME RRSIG NSEC - 14400 RRSIG NSEC 5 3 14400 ( - 20170702091734 20170602091734 54282 example.org. - U3ZPYMUBJl3wF2SazQv/kBf6ec0CH+7n0Hr9 - w6lBKkiXz7P9WQzJDVnTHEZOrbDI6UetFGyC - 6qcaADCASZ9Wxc+riyK1Hl4ox+Y/CHJ97WHy - oS2X//vEf6qmbHQXin0WQtFdU/VCRYF40X5v - 8VfqOmrr8iKiEqXND8XNVf58mTw= ) -a.dname.example.org. 1800 IN A 127.0.0.1 - 1800 RRSIG A 5 4 1800 ( - 20170702091734 20170602091734 54282 example.org. - y7RHBWZwli8SJQ4BgTmdXmYS3KGHZ7AitJCx - zXFksMQtNoOfVEQBwnFqjAb8ezcV5u92h1gN - i1EcuxCFiElML1XFT8dK2GnlPAga9w3oIwd5 - wzW/YHcnR0P9lF56Sl7RoIt6+jJqOdRfixS6 - TDoLoXsNbOxQ+qV3B8pU2Tam204= ) - 14400 NSEC ns.example.org. A RRSIG NSEC - 14400 RRSIG NSEC 5 4 14400 ( - 20170702091734 20170602091734 54282 example.org. - Tmu27q3+xfONSZZtZLhejBUVtEw+83ZU1AFb - Rsxctjry/x5r2JSxw/sgSAExxX/7tx/okZ8J - oJqtChpsr91Kiw3eEBgINi2lCYIpMJlW4cWz - 8bYlHfR81VsKYgy/cRgrq1RRvBoJnw+nwSty - mKPIvUtt67LAvLxJheSCEMZLCKI= ) -ns.example.org. 1800 IN A 127.0.0.1 - 1800 RRSIG A 5 3 1800 ( - 20170702091734 20170602091734 54282 example.org. - mhi1SGaaAt+ndQEg5uKWKCH0HMzaqh/9dUK3 - p2wWMBrLbTZrcWyz10zRnvehicXDCasbBrer - ZpDQnz5AgxYYBURvdPfUzx1XbNuRJRE4l5PN - CEUTlTWcqCXnlSoPKEJE5HRf7v0xg2BrBUfM - 4mZnW2bFLwjrRQ5mm/mAmHmTROk= ) - 14400 NSEC example.org. A RRSIG NSEC - 14400 RRSIG NSEC 5 3 14400 ( - 20170702091734 20170602091734 54282 example.org. - loHcdjX+NIWLAkUDfPSy2371wrfUvrBQTfMO - 17eO2Y9E/6PE935NF5bjQtZBRRghyxzrFJhm - vY1Ad5ZTb+NLHvdSWbJQJog+eCc7QWp64WzR - RXpMdvaE6ZDwalWldLjC3h8QDywDoFdndoRY - eHOsmTvvtWWqtO6Fa5A8gmHT5HA= ) -` diff --git a/vendor/github.com/coredns/coredns/plugin/file/dnssec_test.go b/vendor/github.com/coredns/coredns/plugin/file/dnssec_test.go deleted file mode 100644 index 29cd9a61..00000000 --- a/vendor/github.com/coredns/coredns/plugin/file/dnssec_test.go +++ /dev/null @@ -1,358 +0,0 @@ -package file - -import ( - "context" - "strings" - "testing" - - "github.com/coredns/coredns/plugin/pkg/dnstest" - "github.com/coredns/coredns/plugin/test" - - "github.com/miekg/dns" -) - -var dnssecTestCases = []test.Case{ - { - Qname: "miek.nl.", Qtype: dns.TypeSOA, Do: true, - Answer: []dns.RR{ - test.RRSIG("miek.nl. 1800 IN RRSIG SOA 8 2 1800 20160426031301 20160327031301 12051 miek.nl. FIrzy07acBbtyQczy1dc="), - test.SOA("miek.nl. 1800 IN SOA linode.atoom.net. miek.miek.nl. 1282630057 14400 3600 604800 14400"), - }, - Ns: auth, - Extra: []dns.RR{test.OPT(4096, true)}, - }, - { - Qname: "miek.nl.", Qtype: dns.TypeAAAA, Do: true, - Answer: []dns.RR{ - test.AAAA("miek.nl. 1800 IN AAAA 2a01:7e00::f03c:91ff:fef1:6735"), - test.RRSIG("miek.nl. 1800 IN RRSIG AAAA 8 2 1800 20160426031301 20160327031301 12051 miek.nl. SsRT="), - }, - Ns: auth, - Extra: []dns.RR{test.OPT(4096, true)}, - }, - { - Qname: "miek.nl.", Qtype: dns.TypeNS, Do: true, - Answer: []dns.RR{ - test.NS("miek.nl. 1800 IN NS ext.ns.whyscream.net."), - test.NS("miek.nl. 1800 IN NS linode.atoom.net."), - test.NS("miek.nl. 1800 IN NS ns-ext.nlnetlabs.nl."), - test.NS("miek.nl. 1800 IN NS omval.tednet.nl."), - test.RRSIG("miek.nl. 1800 IN RRSIG NS 8 2 1800 20160426031301 20160327031301 12051 miek.nl. ZLtsQhwaz+lHfNpztFoR1Vxs="), - }, - Extra: []dns.RR{test.OPT(4096, true)}, - }, - { - Qname: "miek.nl.", Qtype: dns.TypeMX, Do: true, - Answer: []dns.RR{ - test.MX("miek.nl. 1800 IN MX 1 aspmx.l.google.com."), - test.MX("miek.nl. 1800 IN MX 10 aspmx2.googlemail.com."), - test.MX("miek.nl. 1800 IN MX 10 aspmx3.googlemail.com."), - test.MX("miek.nl. 1800 IN MX 5 alt1.aspmx.l.google.com."), - test.MX("miek.nl. 1800 IN MX 5 alt2.aspmx.l.google.com."), - test.RRSIG("miek.nl. 1800 IN RRSIG MX 8 2 1800 20160426031301 20160327031301 12051 miek.nl. kLqG+iOr="), - }, - Ns: auth, - Extra: []dns.RR{test.OPT(4096, true)}, - }, - { - Qname: "www.miek.nl.", Qtype: dns.TypeA, Do: true, - Answer: []dns.RR{ - test.A("a.miek.nl. 1800 IN A 139.162.196.78"), - test.RRSIG("a.miek.nl. 1800 IN RRSIG A 8 3 1800 20160426031301 20160327031301 12051 miek.nl. lxLotCjWZ3kihTxk="), - test.CNAME("www.miek.nl. 1800 IN CNAME a.miek.nl."), - test.RRSIG("www.miek.nl. 1800 RRSIG CNAME 8 3 1800 20160426031301 20160327031301 12051 miek.nl. NVZmMJaypS+wDL2Lar4Zw1zF"), - }, - Ns: auth, - Extra: []dns.RR{ - test.OPT(4096, true), - }, - }, - { - // NoData - Qname: "a.miek.nl.", Qtype: dns.TypeSRV, Do: true, - Ns: []dns.RR{ - test.NSEC("a.miek.nl. 14400 IN NSEC archive.miek.nl. A AAAA RRSIG NSEC"), - test.RRSIG("a.miek.nl. 14400 IN RRSIG NSEC 8 3 14400 20160426031301 20160327031301 12051 miek.nl. GqnF6cutipmSHEao="), - test.RRSIG("miek.nl. 1800 IN RRSIG SOA 8 2 1800 20160426031301 20160327031301 12051 miek.nl. FIrzy07acBbtyQczy1dc="), - test.SOA("miek.nl. 1800 IN SOA linode.atoom.net. miek.miek.nl. 1282630057 14400 3600 604800 14400"), - }, - Extra: []dns.RR{test.OPT(4096, true)}, - }, - { - Qname: "b.miek.nl.", Qtype: dns.TypeA, Do: true, - Rcode: dns.RcodeNameError, - Ns: []dns.RR{ - test.NSEC("archive.miek.nl. 14400 IN NSEC go.dns.miek.nl. CNAME RRSIG NSEC"), - test.RRSIG("archive.miek.nl. 14400 IN RRSIG NSEC 8 3 14400 20160426031301 20160327031301 12051 miek.nl. jEpx8lcp4do5fWXg="), - test.NSEC("miek.nl. 14400 IN NSEC a.miek.nl. A NS SOA MX AAAA RRSIG NSEC DNSKEY"), - test.RRSIG("miek.nl. 14400 IN RRSIG NSEC 8 2 14400 20160426031301 20160327031301 12051 miek.nl. mFfc3r/9PSC1H6oSpdC"), - test.RRSIG("miek.nl. 1800 IN RRSIG SOA 8 2 1800 20160426031301 20160327031301 12051 miek.nl. FIrzy07acBbtyQczy1dc="), - test.SOA("miek.nl. 1800 IN SOA linode.atoom.net. miek.miek.nl. 1282630057 14400 3600 604800 14400"), - }, - Extra: []dns.RR{test.OPT(4096, true)}, - }, - { - Qname: "b.blaat.miek.nl.", Qtype: dns.TypeA, Do: true, - Rcode: dns.RcodeNameError, - Ns: []dns.RR{ - test.NSEC("archive.miek.nl. 14400 IN NSEC go.dns.miek.nl. CNAME RRSIG NSEC"), - test.RRSIG("archive.miek.nl. 14400 IN RRSIG NSEC 8 3 14400 20160426031301 20160327031301 12051 miek.nl. jEpx8lcp4do5fWXg="), - test.NSEC("miek.nl. 14400 IN NSEC a.miek.nl. A NS SOA MX AAAA RRSIG NSEC DNSKEY"), - test.RRSIG("miek.nl. 14400 IN RRSIG NSEC 8 2 14400 20160426031301 20160327031301 12051 miek.nl. mFfc3r/9PSC1H6oSpdC"), - test.RRSIG("miek.nl. 1800 IN RRSIG SOA 8 2 1800 20160426031301 20160327031301 12051 miek.nl. FIrzy07acBbtyQczy1dc="), - test.SOA("miek.nl. 1800 IN SOA linode.atoom.net. miek.miek.nl. 1282630057 14400 3600 604800 14400"), - }, - Extra: []dns.RR{test.OPT(4096, true)}, - }, - { - Qname: "b.a.miek.nl.", Qtype: dns.TypeA, Do: true, - Rcode: dns.RcodeNameError, - Ns: []dns.RR{ - // dedupped NSEC, because 1 nsec tells all - test.NSEC("a.miek.nl. 14400 IN NSEC archive.miek.nl. A AAAA RRSIG NSEC"), - test.RRSIG("a.miek.nl. 14400 IN RRSIG NSEC 8 3 14400 20160426031301 20160327031301 12051 miek.nl. GqnF6cut/RRGPQ1QGQE1ipmSHEao="), - test.RRSIG("miek.nl. 1800 IN RRSIG SOA 8 2 1800 20160426031301 20160327031301 12051 miek.nl. FIrzy07acBbtyQczy1dc="), - test.SOA("miek.nl. 1800 IN SOA linode.atoom.net. miek.miek.nl. 1282630057 14400 3600 604800 14400"), - }, - Extra: []dns.RR{test.OPT(4096, true)}, - }, -} - -var auth = []dns.RR{ - test.NS("miek.nl. 1800 IN NS ext.ns.whyscream.net."), - test.NS("miek.nl. 1800 IN NS linode.atoom.net."), - test.NS("miek.nl. 1800 IN NS ns-ext.nlnetlabs.nl."), - test.NS("miek.nl. 1800 IN NS omval.tednet.nl."), - test.RRSIG("miek.nl. 1800 IN RRSIG NS 8 2 1800 20160426031301 20160327031301 12051 miek.nl. ZLtsQhwazbqSpztFoR1Vxs="), -} - -func TestLookupDNSSEC(t *testing.T) { - zone, err := Parse(strings.NewReader(dbMiekNLSigned), testzone, "stdin", 0) - if err != nil { - t.Fatalf("Expected no error when reading zone, got %q", err) - } - - fm := File{Next: test.ErrorHandler(), Zones: Zones{Z: map[string]*Zone{testzone: zone}, Names: []string{testzone}}} - ctx := context.TODO() - - for _, tc := range dnssecTestCases { - m := tc.Msg() - - rec := dnstest.NewRecorder(&test.ResponseWriter{}) - _, err := fm.ServeDNS(ctx, rec, m) - if err != nil { - t.Errorf("Expected no error, got %v\n", err) - return - } - - resp := rec.Msg - test.SortAndCheck(t, resp, tc) - } -} - -func BenchmarkFileLookupDNSSEC(b *testing.B) { - zone, err := Parse(strings.NewReader(dbMiekNLSigned), testzone, "stdin", 0) - if err != nil { - return - } - - fm := File{Next: test.ErrorHandler(), Zones: Zones{Z: map[string]*Zone{testzone: zone}, Names: []string{testzone}}} - ctx := context.TODO() - rec := dnstest.NewRecorder(&test.ResponseWriter{}) - - tc := test.Case{ - Qname: "b.miek.nl.", Qtype: dns.TypeA, Do: true, - Rcode: dns.RcodeNameError, - Ns: []dns.RR{ - test.NSEC("archive.miek.nl. 14400 IN NSEC go.dns.miek.nl. CNAME RRSIG NSEC"), - test.RRSIG("archive.miek.nl. 14400 IN RRSIG NSEC 8 3 14400 20160426031301 20160327031301 12051 miek.nl. jEpx8lcp4do5fWXg="), - test.NSEC("miek.nl. 14400 IN NSEC a.miek.nl. A NS SOA MX AAAA RRSIG NSEC DNSKEY"), - test.RRSIG("miek.nl. 14400 IN RRSIG NSEC 8 2 14400 20160426031301 20160327031301 12051 miek.nl. mFfc3r/9PSC1H6oSpdC"), - test.RRSIG("miek.nl. 1800 IN RRSIG SOA 8 2 1800 20160426031301 20160327031301 12051 miek.nl. FIrzy07acBbtyQczy1dc="), - test.SOA("miek.nl. 1800 IN SOA linode.atoom.net. miek.miek.nl. 1282630057 14400 3600 604800 14400"), - }, - } - - m := tc.Msg() - - b.ResetTimer() - - for i := 0; i < b.N; i++ { - fm.ServeDNS(ctx, rec, m) - } -} - -const dbMiekNLSigned = ` -; File written on Sun Mar 27 04:13:01 2016 -; dnssec_signzone version 9.10.3-P4-Ubuntu -miek.nl. 1800 IN SOA linode.atoom.net. miek.miek.nl. ( - 1459051981 ; serial - 14400 ; refresh (4 hours) - 3600 ; retry (1 hour) - 604800 ; expire (1 week) - 14400 ; minimum (4 hours) - ) - 1800 RRSIG SOA 8 2 1800 ( - 20160426031301 20160327031301 12051 miek.nl. - FIrzy07acBzrf6kNW13Ypmq/ahojoMqOj0qJ - ixTevTvwOEcVuw9GlJoYIHTYg+hm1sZHtx9K - RiVmYsm8SHKsJA1WzixtT4K7vQvM+T+qbeOJ - xA6YTivKUcGRWRXQlOTUAlHS/KqBEfmxKgRS - 68G4oOEClFDSJKh7RbtyQczy1dc= ) - 1800 NS ext.ns.whyscream.net. - 1800 NS omval.tednet.nl. - 1800 NS linode.atoom.net. - 1800 NS ns-ext.nlnetlabs.nl. - 1800 RRSIG NS 8 2 1800 ( - 20160426031301 20160327031301 12051 miek.nl. - ZLtsQhwaz+CwrgzgFiEAqbqS/JH65MYjziA3 - 6EXwlGDy41lcfGm71PpxA7cDzFhWNkJNk4QF - q48wtpP4IGPPpHbnJHKDUXj6se7S+ylAGbS+ - VgVJ4YaVcE6xA9ZVhVpz8CSSjeH34vmqq9xj - zmFjofuDvraZflHfNpztFoR1Vxs= ) - 1800 A 139.162.196.78 - 1800 RRSIG A 8 2 1800 ( - 20160426031301 20160327031301 12051 miek.nl. - hl+6Q075tsCkxIqbop8zZ6U8rlFvooz7Izzx - MgCZYVLcg75El28EXKIhBfRb1dPaKbd+v+AD - wrJMHL131pY5sU2Ly05K+7CqmmyaXgDaVsKS - rSw/TbhGDIItBemeseeuXGAKAbY2+gE7kNN9 - mZoQ9hRB3SrxE2jhctv66DzYYQQ= ) - 1800 MX 1 aspmx.l.google.com. - 1800 MX 5 alt1.aspmx.l.google.com. - 1800 MX 5 alt2.aspmx.l.google.com. - 1800 MX 10 aspmx2.googlemail.com. - 1800 MX 10 aspmx3.googlemail.com. - 1800 RRSIG MX 8 2 1800 ( - 20160426031301 20160327031301 12051 miek.nl. - kLqG+iOrKSzms1H9Et9me8Zts1rbyeCFSVQD - G9is/u6ec3Lqg2vwJddf/yRsjVpVgadWSAkc - GSDuD2dK8oBeP24axWc3Z1OY2gdMI7w+PKWT - Z+pjHVjbjM47Ii/a6jk5SYeOwpGMsdEwhtTP - vk2O2WGljifqV3uE7GshF5WNR10= ) - 1800 AAAA 2a01:7e00::f03c:91ff:fef1:6735 - 1800 RRSIG AAAA 8 2 1800 ( - 20160426031301 20160327031301 12051 miek.nl. - SsRTHytW4YTAuHovHQgfIMhNwMtMp4gaAU/Z - lgTO+IkBb9y9F8uHrf25gG6RqA1bnGV/gezV - NU5negXm50bf1BNcyn3aCwEbA0rCGYIL+nLJ - szlBVbBu6me/Ym9bbJlfgfHRDfsVy2ZkNL+B - jfNQtGCSDoJwshjcqJlfIVSardo= ) - 14400 NSEC a.miek.nl. A NS SOA MX AAAA RRSIG NSEC DNSKEY - 14400 RRSIG NSEC 8 2 14400 ( - 20160426031301 20160327031301 12051 miek.nl. - mFfc3r/9PSC1H6oSpdC+FDy/Iu02W2Tf0x+b - n6Lpe1gCC1uvcSUrrmBNlyAWRr5Zm+ZXssEb - cKddRGiu/5sf0bUWrs4tqokL/HUl10X/sBxb - HfwNAeD7R7+CkpMv67li5AhsDgmQzpX2r3P6 - /6oZyLvODGobysbmzeWM6ckE8IE= ) - 1800 DNSKEY 256 3 8 ( - AwEAAcNEU67LJI5GEgF9QLNqLO1SMq1EdoQ6 - E9f85ha0k0ewQGCblyW2836GiVsm6k8Kr5EC - IoMJ6fZWf3CQSQ9ycWfTyOHfmI3eQ/1Covhb - 2y4bAmL/07PhrL7ozWBW3wBfM335Ft9xjtXH - Py7ztCbV9qZ4TVDTW/Iyg0PiwgoXVesz - ) ; ZSK; alg = RSASHA256; key id = 12051 - 1800 DNSKEY 257 3 8 ( - AwEAAcWdjBl4W4wh/hPxMDcBytmNCvEngIgB - 9Ut3C2+QI0oVz78/WK9KPoQF7B74JQ/mjO4f - vIncBmPp6mFNxs9/WQX0IXf7oKviEVOXLjct - R4D1KQLX0wprvtUIsQFIGdXaO6suTT5eDbSd - 6tTwu5xIkGkDmQhhH8OQydoEuCwV245ZwF/8 - AIsqBYDNQtQ6zhd6jDC+uZJXg/9LuPOxFHbi - MTjp6j3CCW0kHbfM/YHZErWWtjPj3U3Z7knQ - SIm5PO5FRKBEYDdr5UxWJ/1/20SrzI3iztvP - wHDsA2rdHm/4YRzq7CvG4N0t9ac/T0a0Sxba - /BUX2UVPWaIVBdTRBtgHi0s= - ) ; KSK; alg = RSASHA256; key id = 33694 - 1800 RRSIG DNSKEY 8 2 1800 ( - 20160426031301 20160327031301 12051 miek.nl. - o/D6o8+/bNGQyyRvwZ2hM0BJ+3HirvNjZoko - yGhGe9sPSrYU39WF3JVIQvNJFK6W3/iwlKir - TPOeYlN6QilnztFq1vpCxwj2kxJaIJhZecig - LsKxY/fOHwZlIbBLZZadQG6JoGRLHnImSzpf - xtyVaXQtfnJFC07HHt9np3kICfE= ) - 1800 RRSIG DNSKEY 8 2 1800 ( - 20160426031301 20160327031301 33694 miek.nl. - Ak/mbbQVQV+nUgw5Sw/c+TSoYqIwbLARzuNE - QJvJNoRR4tKVOY6qSxQv+j5S7vzyORZ+yeDp - NlEa1T9kxZVBMABoOtLX5kRqZncgijuH8fxb - L57Sv2IzINI9+DOcy9Q9p9ygtwYzQKrYoNi1 - 0hwHi6emGkVG2gGghruMinwOJASGgQy487Yd - eIpcEKJRw73nxd2le/4/Vafy+mBpKWOczfYi - 5m9MSSxcK56NFYjPG7TvdIw0m70F/smY9KBP - pGWEdzRQDlqfZ4fpDaTAFGyRX0mPFzMbs1DD - 3hQ4LHUSi/NgQakdH9eF42EVEDeL4cI69K98 - 6NNk6X9TRslO694HKw== ) -a.miek.nl. 1800 IN A 139.162.196.78 - 1800 RRSIG A 8 3 1800 ( - 20160426031301 20160327031301 12051 miek.nl. - lxLotCjWZ3kikNNcePu6HOCqMHDINKFRJRD8 - laz2KQ9DKtgXPdnRw5RJvVITSj8GUVzw1ec1 - CYVEKu/eMw/rc953Zns528QBypGPeMNLe2vu - C6a6UhZnGHA48dSd9EX33eSJs0MP9xsC9csv - LGdzYmv++eslkKxkhSOk2j/hTxk= ) - 1800 AAAA 2a01:7e00::f03c:91ff:fef1:6735 - 1800 RRSIG AAAA 8 3 1800 ( - 20160426031301 20160327031301 12051 miek.nl. - ji3QMlaUzlK85ppB5Pc+y2WnfqOi6qrm6dm1 - bXgsEov/5UV1Lmcv8+Y5NBbTbBlXGlWcpqNp - uWpf9z3lbguDWznpnasN2MM8t7yxo/Cr7WRf - QCzui7ewpWiA5hq7j0kVbM4nnDc6cO+U93hO - mMhVbeVI70HM2m0HaHkziEyzVZk= ) - 14400 NSEC archive.miek.nl. A AAAA RRSIG NSEC - 14400 RRSIG NSEC 8 3 14400 ( - 20160426031301 20160327031301 12051 miek.nl. - GqnF6cut/KCxbnJj27MCjjVGkjObV0hLhHOP - E1/GXAUTEKG6BWxJq8hidS3p/yrOmP5PEL9T - 4FjBp0/REdVmGpuLaiHyMselES82p/uMMdY5 - QqRM6LHhZdO1zsRbyzOZbm5MsW6GR7K2kHlX - 9TdBIULiRRGPQ1QGQE1ipmSHEao= ) -archive.miek.nl. 1800 IN CNAME a.miek.nl. - 1800 RRSIG CNAME 8 3 1800 ( - 20160426031301 20160327031301 12051 miek.nl. - s4zVJiDrVuUiUFr8CNQLuXYYfpqpl8rovL50 - BYsub/xK756NENiOTAOjYH6KYg7RSzsygJjV - YQwXolZly2/KXAr48SCtxzkGFxLexxiKcFaj - vm7ZDl7Btoa5l68qmBcxOX5E/W0IKITi4PNK - mhBs7dlaf0IbPGNgMxae72RosxM= ) - 14400 NSEC go.dns.miek.nl. CNAME RRSIG NSEC - 14400 RRSIG NSEC 8 3 14400 ( - 20160426031301 20160327031301 12051 miek.nl. - jEp7LsoK++/PRFh2HieLzasA1jXBpp90NyDf - RfpfOxdM69yRKfvXMc2bazIiMuDhxht79dGI - Gj02cn1cvX60SlaHkeFtqTdJcHdK9rbI65EK - YHFZFzGh9XVnuMJKpUsm/xS1dnUSAnXN8q+0 - xBlUDlQpsAFv/cx8lcp4do5fWXg= ) -go.dns.miek.nl. 1800 IN TXT "Hello!" - 1800 RRSIG TXT 8 4 1800 ( - 20160426031301 20160327031301 12051 miek.nl. - O0uo1NsXTq2TTfgOmGbHQQEchrcpllaDAMMX - dTDizw3t+vZ5SR32qJ8W7y6VXLgUqJgcdRxS - Fou1pp+t5juRZSQ0LKgxMpZAgHorkzPvRf1b - E9eBKrDSuLGagsQRwHeldFGFgsXtCbf07vVH - zoKR8ynuG4/cAoY0JzMhCts+56U= ) - 14400 NSEC www.miek.nl. TXT RRSIG NSEC - 14400 RRSIG NSEC 8 4 14400 ( - 20160426031301 20160327031301 12051 miek.nl. - BW6qo7kYe3Z+Y0ebaVTWTy1c3bpdf8WUEoXq - WDQxLDEj2fFiuEBDaSN5lTWRg3wj8kZmr6Uk - LvX0P29lbATFarIgkyiAdbOEdaf88nMfqBW8 - z2T5xrPQcN0F13uehmv395yAJs4tebRxErMl - KdkVF0dskaDvw8Wo3YgjHUf6TXM= ) -www.miek.nl. 1800 IN CNAME a.miek.nl. - 1800 RRSIG CNAME 8 3 1800 ( - 20160426031301 20160327031301 12051 miek.nl. - MiQQh2lScoNiNVZmMJaypS+wDL2Lar4Zw1zF - Uo4tL16BfQOt7yl8gXdAH2JMFqoKAoIdM2K6 - XwFOwKTOGSW0oNCOcaE7ts+1Z1U0H3O2tHfq - FAzfg1s9pQ5zxk8J/bJgkVIkw2/cyB0y1/PK - EmIqvChBSb4NchTuMCSqo63LJM8= ) - 14400 NSEC miek.nl. CNAME RRSIG NSEC - 14400 RRSIG NSEC 8 3 14400 ( - 20160426031301 20160327031301 12051 miek.nl. - OPPZ8iaUPrVKEP4cqeCiiv1WLRAY30GRIhc/ - me0gBwFkbmTEnvB+rUp831OJZDZBNKv4QdZj - Uyc26wKUOQeUyMJqv4IRDgxH7nq9GB5JRjYZ - IVxtGD1aqWLXz+8aMaf9ARJjtYUd3K4lt8Wz - LbJSo5Wdq7GOWqhgkY5n3XD0/FA= )` diff --git a/vendor/github.com/coredns/coredns/plugin/file/dnssex_test.go b/vendor/github.com/coredns/coredns/plugin/file/dnssex_test.go deleted file mode 100644 index d9a0a456..00000000 --- a/vendor/github.com/coredns/coredns/plugin/file/dnssex_test.go +++ /dev/null @@ -1,145 +0,0 @@ -package file - -const dbDnssexNLSigned = ` -; File written on Tue Mar 29 21:02:24 2016 -; dnssec_signzone version 9.10.3-P4-Ubuntu -dnssex.nl. 1800 IN SOA linode.atoom.net. miek.miek.nl. ( - 1459281744 ; serial - 14400 ; refresh (4 hours) - 3600 ; retry (1 hour) - 604800 ; expire (1 week) - 14400 ; minimum (4 hours) - ) - 1800 RRSIG SOA 8 2 1800 ( - 20160428190224 20160329190224 14460 dnssex.nl. - CA/Y3m9hCOiKC/8ieSOv8SeP964BUdG/8MC3 - WtKljUosK9Z9bBGrVizDjjqgq++lyH8BZJcT - aabAsERs4xj5PRtcxicwQXZACX5VYjXHQeZm - CyytFU5wq2gcXSmvUH86zZzftx3RGPvn1aOo - TlcvoC3iF8fYUCpROlUS0YR8Cdw= ) - 1800 NS omval.tednet.nl. - 1800 NS linode.atoom.net. - 1800 NS ns-ext.nlnetlabs.nl. - 1800 RRSIG NS 8 2 1800 ( - 20160428190224 20160329190224 14460 dnssex.nl. - dLIeEvP86jj5nd3orv9bH7hTvkblF4Na0sbl - k6fJA6ha+FPN1d6Pig3NNEEVQ/+wlOp/JTs2 - v07L7roEEUCbBprI8gMSld2gFDwNLW3DAB4M - WD/oayYdAnumekcLzhgvWixTABjWAGRTGQsP - sVDFXsGMf9TGGC9FEomgkCVeNC0= ) - 1800 A 139.162.196.78 - 1800 RRSIG A 8 2 1800 ( - 20160428190224 20160329190224 14460 dnssex.nl. - LKJKLzPiSEDWOLAag2YpfD5EJCuDcEAJu+FZ - Xy+4VyOv9YvRHCTL4vbrevOo5+XymY2RxU1q - j+6leR/Fe7nlreSj2wzAAk2bIYn4m6r7hqeO - aKZsUFfpX8cNcFtGEywfHndCPELbRxFeEziP - utqHFLPNMX5nYCpS28w4oJ5sAnM= ) - 1800 TXT "Doing It Safe Is Better" - 1800 RRSIG TXT 8 2 1800 ( - 20160428190224 20160329190224 14460 dnssex.nl. - f6S+DUfJK1UYdOb3AHgUXzFTTtu+yLp/Fv7S - Hv0CAGhXAVw+nBbK719igFvBtObS33WKwzxD - 1pQNMaJcS6zeevtD+4PKB1KDC4fyJffeEZT6 - E30jGR8Y29/xA+Fa4lqDNnj9zP3b8TiABCle - ascY5abkgWCALLocFAzFJQ/27YQ= ) - 1800 AAAA 2a01:7e00::f03c:91ff:fef1:6735 - 1800 RRSIG AAAA 8 2 1800 ( - 20160428190224 20160329190224 14460 dnssex.nl. - PWcPSawEUBAfCuv0liEOQ8RYe7tfNW4rubIJ - LE+dbrub1DUer3cWrDoCYFtOufvcbkYJQ2CQ - AGjJmAQ5J2aqYDOPMrKa615V0KT3ifbZJcGC - gkIic4U/EXjaQpRoLdDzR9MyVXOmbA6sKYzj - ju1cNkLqM8D7Uunjl4pIr6rdSFo= ) - 14400 NSEC *.dnssex.nl. A NS SOA TXT AAAA RRSIG NSEC DNSKEY - 14400 RRSIG NSEC 8 2 14400 ( - 20160428190224 20160329190224 14460 dnssex.nl. - oIvM6JZIlNc1aNKGTxv58ApSnDr1nDPPgnD9 - 9oJZRIn7eb5WnpeDz2H3z5+x6Bhlp5hJJaUp - KJ3Ss6Jg/IDnrmIvKmgq6L6gHj1Y1IiHmmU8 - VeZTRzdTsDx/27OsN23roIvsytjveNSEMfIm - iLZ23x5kg1kBdJ9p3xjYHm5lR+8= ) - 1800 DNSKEY 256 3 8 ( - AwEAAazSO6uvLPEVknDA8yxjFe8nnAMU7txp - wb19k55hQ81WV3G4bpBM1NdN6sbYHrkXaTNx - 2bQWAkvX6pz0XFx3z/MPhW+vkakIWFYpyQ7R - AT5LIJfToVfiCDiyhhF0zVobKBInO9eoGjd9 - BAW3TUt+LmNAO/Ak5D5BX7R3CuA7v9k7 - ) ; ZSK; alg = RSASHA256; key id = 14460 - 1800 DNSKEY 257 3 8 ( - AwEAAbyeaV9zg0IqdtgYoqK5jJ239anzwG2i - gvH1DxSazLyaoNvEkCIvPgMLW/JWfy7Z1mQp - SMy9DtzL5pzRyQgw7kIeXLbi6jufUFd9pxN+ - xnzKLf9mY5AcnGToTrbSL+jnMT67wG+c34+Q - PeVfucHNUePBxsbz2+4xbXiViSQyCQGv - ) ; KSK; alg = RSASHA256; key id = 18772 - 1800 RRSIG DNSKEY 8 2 1800 ( - 20160428190224 20160329190224 14460 dnssex.nl. - cFSFtJE+DBGNxb52AweFaVHBe5Ue5MDpqNdC - TIneUnEhP2m+vK4zJ/TraK0WdQFpsX63pod8 - PZ9y03vHUfewivyonCCBD3DcNdoU9subhN22 - tez9Ct8Z5/9E4RAz7orXal4M1VUEhRcXSEH8 - SJW20mfVsqJAiKqqNeGB/pAj23I= ) - 1800 RRSIG DNSKEY 8 2 1800 ( - 20160428190224 20160329190224 18772 dnssex.nl. - oiiwo/7NYacePqohEp50261elhm6Dieh4j2S - VZGAHU5gqLIQeW9CxKJKtSCkBVgUo4cvO4Rn - 2tzArAuclDvBrMXRIoct8u7f96moeFE+x5FI - DYqICiV6k449ljj9o4t/5G7q2CRsEfxZKpTI - A/L0+uDk0RwVVzL45+TnilcsmZs= ) -*.dnssex.nl. 1800 IN TXT "Doing It Safe Is Better" - 1800 RRSIG TXT 8 2 1800 ( - 20160428190224 20160329190224 14460 dnssex.nl. - FUZSTyvZfeuuOpCmNzVKOfITRHJ6/ygjmnnb - XGBxVUyQjoLuYXwD5XqZWGw4iKH6QeSDfGCx - 4MPqA4qQmW7Wwth7mat9yMfA4+p2sO84bysl - 7/BG9+W2G+q1uQiM9bX9V42P2X/XuW5Y/t9Y - 8u1sljQ7D8WwS6naH/vbaJxnDBw= ) - 14400 NSEC a.dnssex.nl. TXT RRSIG NSEC - 14400 RRSIG NSEC 8 2 14400 ( - 20160428190224 20160329190224 14460 dnssex.nl. - os6INm6q2eXknD5z8TpfbK00uxVbQefMvHcR - /RNX/kh0xXvzAaaDOV+Ge/Ko+2dXnKP+J1LY - G9ffXNpdbaQy5ygzH5F041GJst4566GdG/jt - 7Z7vLHYxEBTpZfxo+PLsXQXH3VTemZyuWyDf - qJzafXJVH1F0nDrcXmMlR6jlBHA= ) -www.dnssex.nl. 1800 IN CNAME a.dnssex.nl. - 1800 RRSIG CNAME 8 3 1800 ( - 20160428190224 20160329190224 14460 dnssex.nl. - Omv42q/uVvdNsWQoSrQ6m6w6U7r7Abga7uF4 - 25b3gZlse0C+WyMyGFMGUbapQm7azvBpreeo - uKJHjzd+ufoG+Oul6vU9vyoj+ejgHzGLGbJQ - HftfP+UqP5SWvAaipP/LULTWKPuiBcLDLiBI - PGTfsq0DB6R+qCDTV0fNnkgxEBQ= ) - 14400 NSEC dnssex.nl. CNAME RRSIG NSEC - 14400 RRSIG NSEC 8 3 14400 ( - 20160428190224 20160329190224 14460 dnssex.nl. - TBN3ddfZW+kC84/g3QlNNJMeLZoyCalPQylt - KXXLPGuxfGpl3RYRY8KaHbP+5a8MnHjqjuMB - Lofb7yKMFxpSzMh8E36vnOqry1mvkSakNj9y - 9jM8PwDjcpYUwn/ql76MsmNgEV5CLeQ7lyH4 - AOrL79yOSQVI3JHJIjKSiz88iSw= ) -a.dnssex.nl. 1800 IN A 139.162.196.78 - 1800 RRSIG A 8 3 1800 ( - 20160428190224 20160329190224 14460 dnssex.nl. - OXHpFj9nSpKi5yA/ULH7MOpGAWfyJ2yC/2xa - Pw0fqSY4QvcRt+V3adcFA4H9+P1b32GpxEjB - lXmCJID+H4lYkhUR4r4IOZBVtKG2SJEBZXip - pH00UkOIBiXxbGzfX8VL04v2G/YxUgLW57kA - aknaeTOkJsO20Y+8wmR9EtzaRFI= ) - 1800 AAAA 2a01:7e00::f03c:91ff:fef1:6735 - 1800 RRSIG AAAA 8 3 1800 ( - 20160428190224 20160329190224 14460 dnssex.nl. - jrepc/VnRzJypnrG0WDEqaAr3HMjWrPxJNX0 - 86gbFjZG07QxBmrA1rj0jM9YEWTjjyWb2tT7 - lQhzKDYX/0XdOVUeeOM4FoSks80V+pWR8fvj - AZ5HmX69g36tLosMDKNR4lXcrpv89QovG4Hr - /r58fxEKEFJqrLDjMo6aOrg+uKA= ) - 14400 NSEC www.dnssex.nl. A AAAA RRSIG NSEC - 14400 RRSIG NSEC 8 3 14400 ( - 20160428190224 20160329190224 14460 dnssex.nl. - S+UM62wXRNNFN3QDWK5YFWUbHBXC4aqaqinZ - A2ZDeC+IQgyw7vazPz7cLI5T0YXXks0HTMlr - soEjKnnRZsqSO9EuUavPNE1hh11Jjm0fB+5+ - +Uro0EmA5Dhgc0Z2VpbXVQEhNDf/pI1gem15 - RffN2tBYNykZn4Has2ySgRaaRYQ= )` diff --git a/vendor/github.com/coredns/coredns/plugin/file/ds_test.go b/vendor/github.com/coredns/coredns/plugin/file/ds_test.go deleted file mode 100644 index 5e4ed7e4..00000000 --- a/vendor/github.com/coredns/coredns/plugin/file/ds_test.go +++ /dev/null @@ -1,75 +0,0 @@ -package file - -import ( - "context" - "strings" - "testing" - - "github.com/coredns/coredns/plugin/pkg/dnstest" - "github.com/coredns/coredns/plugin/test" - - "github.com/miekg/dns" -) - -var dsTestCases = []test.Case{ - { - Qname: "a.delegated.miek.nl.", Qtype: dns.TypeDS, - Ns: []dns.RR{ - test.NS("delegated.miek.nl. 1800 IN NS a.delegated.miek.nl."), - test.NS("delegated.miek.nl. 1800 IN NS ns-ext.nlnetlabs.nl."), - }, - Extra: []dns.RR{ - test.A("a.delegated.miek.nl. 1800 IN A 139.162.196.78"), - test.AAAA("a.delegated.miek.nl. 1800 IN AAAA 2a01:7e00::f03c:91ff:fef1:6735"), - }, - }, - { - Qname: "_udp.delegated.miek.nl.", Qtype: dns.TypeDS, - Ns: []dns.RR{ - test.NS("delegated.miek.nl. 1800 IN NS a.delegated.miek.nl."), - test.NS("delegated.miek.nl. 1800 IN NS ns-ext.nlnetlabs.nl."), - }, - Extra: []dns.RR{ - test.A("a.delegated.miek.nl. 1800 IN A 139.162.196.78"), - test.AAAA("a.delegated.miek.nl. 1800 IN AAAA 2a01:7e00::f03c:91ff:fef1:6735"), - }, - }, - { - // This works *here* because we skip the server routing for DS in core/dnsserver/server.go - Qname: "_udp.miek.nl.", Qtype: dns.TypeDS, - Rcode: dns.RcodeNameError, - Ns: []dns.RR{ - test.SOA("miek.nl. 1800 IN SOA linode.atoom.net. miek.miek.nl. 1282630057 14400 3600 604800 14400"), - }, - }, - { - Qname: "miek.nl.", Qtype: dns.TypeDS, - Ns: []dns.RR{ - test.SOA("miek.nl. 1800 IN SOA linode.atoom.net. miek.miek.nl. 1282630057 14400 3600 604800 14400"), - }, - }, -} - -func TestLookupDS(t *testing.T) { - zone, err := Parse(strings.NewReader(dbMiekNLDelegation), testzone, "stdin", 0) - if err != nil { - t.Fatalf("Expected no error when reading zone, got %q", err) - } - - fm := File{Next: test.ErrorHandler(), Zones: Zones{Z: map[string]*Zone{testzone: zone}, Names: []string{testzone}}} - ctx := context.TODO() - - for _, tc := range dsTestCases { - m := tc.Msg() - - rec := dnstest.NewRecorder(&test.ResponseWriter{}) - _, err := fm.ServeDNS(ctx, rec, m) - if err != nil { - t.Errorf("Expected no error, got %v\n", err) - return - } - - resp := rec.Msg - test.SortAndCheck(t, resp, tc) - } -} diff --git a/vendor/github.com/coredns/coredns/plugin/file/ent_test.go b/vendor/github.com/coredns/coredns/plugin/file/ent_test.go deleted file mode 100644 index 496d1a72..00000000 --- a/vendor/github.com/coredns/coredns/plugin/file/ent_test.go +++ /dev/null @@ -1,159 +0,0 @@ -package file - -import ( - "context" - "strings" - "testing" - - "github.com/coredns/coredns/plugin/pkg/dnstest" - "github.com/coredns/coredns/plugin/test" - - "github.com/miekg/dns" -) - -var entTestCases = []test.Case{ - { - Qname: "b.c.miek.nl.", Qtype: dns.TypeA, - Ns: []dns.RR{ - test.SOA("miek.nl. 1800 IN SOA linode.atoom.net. miek.miek.nl. 1282630057 14400 3600 604800 14400"), - }, - }, - { - Qname: "b.c.miek.nl.", Qtype: dns.TypeA, Do: true, - Ns: []dns.RR{ - test.NSEC("a.miek.nl. 14400 IN NSEC a.b.c.miek.nl. A RRSIG NSEC"), - test.RRSIG("a.miek.nl. 14400 IN RRSIG NSEC 8 3 14400 20160502144311 20160402144311 12051 miek.nl. d5XZEy6SUpq98ZKUlzqhAfkLI9pQPc="), - test.RRSIG("miek.nl. 1800 IN RRSIG SOA 8 2 1800 20160502144311 20160402144311 12051 miek.nl. KegoBxA3Tbrhlc4cEdkRiteIkOfsq"), - test.SOA("miek.nl. 1800 IN SOA linode.atoom.net. miek.miek.nl. 1282630057 14400 3600 604800 14400"), - }, - Extra: []dns.RR{test.OPT(4096, true)}, - }, -} - -func TestLookupEnt(t *testing.T) { - zone, err := Parse(strings.NewReader(dbMiekENTNL), testzone, "stdin", 0) - if err != nil { - t.Fatalf("Expect no error when reading zone, got %q", err) - } - - fm := File{Next: test.ErrorHandler(), Zones: Zones{Z: map[string]*Zone{testzone: zone}, Names: []string{testzone}}} - ctx := context.TODO() - - for _, tc := range entTestCases { - m := tc.Msg() - - rec := dnstest.NewRecorder(&test.ResponseWriter{}) - _, err := fm.ServeDNS(ctx, rec, m) - if err != nil { - t.Errorf("Expected no error, got %v\n", err) - return - } - - resp := rec.Msg - test.SortAndCheck(t, resp, tc) - } -} - -// fdjfdjkf -const dbMiekENTNL = `; File written on Sat Apr 2 16:43:11 2016 -; dnssec_signzone version 9.10.3-P4-Ubuntu -miek.nl. 1800 IN SOA linode.atoom.net. miek.miek.nl. ( - 1282630057 ; serial - 14400 ; refresh (4 hours) - 3600 ; retry (1 hour) - 604800 ; expire (1 week) - 14400 ; minimum (4 hours) - ) - 1800 RRSIG SOA 8 2 1800 ( - 20160502144311 20160402144311 12051 miek.nl. - KegoBxA3Tbrhlc4cEdkRiteIkOfsqD4oCLLM - ISJ5bChWy00LGHUlAnHVu5Ti96hUjVNmGSxa - xtGSuAAMFCr52W8pAB8LBIlu9B6QZUPHMccr - SuzxAX3ioawk2uTjm+k8AGPT4RoQdXemGLAp - zJTASolTVmeMTh5J0sZTZJrtvZ0= ) - 1800 NS linode.atoom.net. - 1800 RRSIG NS 8 2 1800 ( - 20160502144311 20160402144311 12051 miek.nl. - m0cOHL6Rre/0jZPXe+0IUjs/8AFASRCvDbSx - ZQsRDSlZgS6RoMP3OC77cnrKDVlfZ2Vhq3Ce - nYPoGe0/atB92XXsilmstx4HTSU64gsV9iLN - Xkzk36617t7zGOl/qumqfaUXeA9tihItzEim - 6SGnufVZI4o8xeyaVCNDDuN0bvY= ) - 14400 NSEC a.miek.nl. NS SOA RRSIG NSEC DNSKEY - 14400 RRSIG NSEC 8 2 14400 ( - 20160502144311 20160402144311 12051 miek.nl. - BCWVgwxWrs4tBjS9QXKkftCUbiLi40NyH1yA - nbFy1wCKQ2jDH00810+ia4b66QrjlAKgxE9z - 9U7MKSMV86sNkyAtlCi+2OnjtWF6sxPdJO7k - CHeg46XBjrQuiJRY8CneQX56+IEPdufLeqPR - l+ocBQ2UkGhXmQdWp3CFDn2/eqU= ) - 1800 DNSKEY 256 3 8 ( - AwEAAcNEU67LJI5GEgF9QLNqLO1SMq1EdoQ6 - E9f85ha0k0ewQGCblyW2836GiVsm6k8Kr5EC - IoMJ6fZWf3CQSQ9ycWfTyOHfmI3eQ/1Covhb - 2y4bAmL/07PhrL7ozWBW3wBfM335Ft9xjtXH - Py7ztCbV9qZ4TVDTW/Iyg0PiwgoXVesz - ) ; ZSK; alg = RSASHA256; key id = 12051 - 1800 DNSKEY 257 3 8 ( - AwEAAcWdjBl4W4wh/hPxMDcBytmNCvEngIgB - 9Ut3C2+QI0oVz78/WK9KPoQF7B74JQ/mjO4f - vIncBmPp6mFNxs9/WQX0IXf7oKviEVOXLjct - R4D1KQLX0wprvtUIsQFIGdXaO6suTT5eDbSd - 6tTwu5xIkGkDmQhhH8OQydoEuCwV245ZwF/8 - AIsqBYDNQtQ6zhd6jDC+uZJXg/9LuPOxFHbi - MTjp6j3CCW0kHbfM/YHZErWWtjPj3U3Z7knQ - SIm5PO5FRKBEYDdr5UxWJ/1/20SrzI3iztvP - wHDsA2rdHm/4YRzq7CvG4N0t9ac/T0a0Sxba - /BUX2UVPWaIVBdTRBtgHi0s= - ) ; KSK; alg = RSASHA256; key id = 33694 - 1800 RRSIG DNSKEY 8 2 1800 ( - 20160502144311 20160402144311 12051 miek.nl. - YNpi1jRDQKpnsQEjIjxqy+kJGaYnV16e8Iug - 40c82y4pee7kIojFUllSKP44qiJpCArxF557 - tfjfwBd6c4hkqCScGPZXJ06LMyG4u//rhVMh - 4hyKcxzQFKxmrFlj3oQGksCI8lxGX6RxiZuR - qv2ol2lUWrqetpAL+Zzwt71884E= ) - 1800 RRSIG DNSKEY 8 2 1800 ( - 20160502144311 20160402144311 33694 miek.nl. - jKpLDEeyadgM0wDgzEk6sBBdWr2/aCrkAOU/ - w6dYIafN98f21oIYQfscV1gc7CTsA0vwzzUu - x0QgwxoNLMvSxxjOiW/2MzF8eozczImeCWbl - ad/pVCYH6Jn5UBrZ5RCWMVcs2RP5KDXWeXKs - jEN/0EmQg5qNd4zqtlPIQinA9I1HquJAnS56 - pFvYyGIbZmGEbhR18sXVBeTWYr+zOMHn2quX - 0kkrx2udz+sPg7i4yRsLdhw138gPRy1qvbaC - 8ELs1xo1mC9pTlDOhz24Q3iXpVAU1lXLYOh9 - nUP1/4UvZEYXHBUQk/XPRciojniWjAF825x3 - QoSivMHblBwRdAKJSg== ) -a.miek.nl. 1800 IN A 127.0.0.1 - 1800 RRSIG A 8 3 1800 ( - 20160502144311 20160402144311 12051 miek.nl. - lUOYdSxScjyYz+Ebc+nb6iTNgCohqj7K+Dat - 97KE7haV2nP3LxdYuDCJYZpeyhsXDLHd4bFI - bInYPwJiC6DUCxPCuCWy0KYlZOWW8KCLX3Ia - BOPQbvIwLsJhnX+/tyMD9mXortoqATO79/6p - nNxvFeM8pFDwaih17fXMuFR/BsI= ) - 14400 NSEC a.b.c.miek.nl. A RRSIG NSEC - 14400 RRSIG NSEC 8 3 14400 ( - 20160502144311 20160402144311 12051 miek.nl. - d5XZEy6SUp+TPRJQED+0R65zf2Yeo/1dlEA2 - jYYvkXGSHXke4sg9nH8U3nr1rLcuqA1DsQgH - uMIjdENvXuZ+WCSwvIbhC+JEI6AyQ6Gfaf/D - I3mfu60C730IRByTrKM5C2rt11lwRQlbdaUY - h23/nn/q98ZKUlzqhAfkLI9pQPc= ) -a.b.c.miek.nl. 1800 IN A 127.0.0.1 - 1800 RRSIG A 8 5 1800 ( - 20160502144311 20160402144311 12051 miek.nl. - FwgU5+fFD4hEebco3gvKQt3PXfY+dcOJr8dl - Ky4WLsONIdhP+4e9oprPisSLxImErY21BcrW - xzu1IZrYDsS8XBVV44lBx5WXEKvAOrUcut/S - OWhFZW7ncdIQCp32ZBIatiLRJEqXUjx+guHs - noFLiHix35wJWsRKwjGLIhH1fbs= ) - 14400 NSEC miek.nl. A RRSIG NSEC - 14400 RRSIG NSEC 8 5 14400 ( - 20160502144311 20160402144311 12051 miek.nl. - lXgOqm9/jRRYvaG5jC1CDvTtGYxMroTzf4t4 - jeYGb60+qI0q9sHQKfAJvoQ5o8o1qfR7OuiF - f544ipYT9eTcJRyGAOoJ37yMie7ZIoVJ91tB - r8YdzZ9Q6x3v1cbwTaQiacwhPZhGYOw63qIs - q5IQErIPos2sNk+y9D8BEce2DO4= )` diff --git a/vendor/github.com/coredns/coredns/plugin/file/example_org.go b/vendor/github.com/coredns/coredns/plugin/file/example_org.go deleted file mode 100644 index eba18e0e..00000000 --- a/vendor/github.com/coredns/coredns/plugin/file/example_org.go +++ /dev/null @@ -1,113 +0,0 @@ -package file - -// exampleOrgSigned is a fake signed example.org zone with two delegations, -// one signed (with DSs) and one "normal". -const exampleOrgSigned = ` -example.org. 1800 IN SOA a.iana-servers.net. devnull.example.org. ( - 1282630057 ; serial - 14400 ; refresh (4 hours) - 3600 ; retry (1 hour) - 604800 ; expire (1 week) - 14400 ; minimum (4 hours) - ) - 1800 RRSIG SOA 13 2 1800 ( - 20161129153240 20161030153240 49035 example.org. - GVnMpFmN+6PDdgCtlYDEYBsnBNDgYmEJNvos - Bk9+PNTPNWNst+BXCpDadTeqRwrr1RHEAQ7j - YWzNwqn81pN+IA== ) - 1800 NS a.iana-servers.net. - 1800 NS b.iana-servers.net. - 1800 RRSIG NS 13 2 1800 ( - 20161129153240 20161030153240 49035 example.org. - llrHoIuwjnbo28LOt4p5zWAs98XGqrXicKVI - Qxyaf/ORM8boJvW2XrKr3nj6Y8FKMhzd287D - 5PBzVCL6MZyjQg== ) - 14400 NSEC a.example.org. NS SOA RRSIG NSEC DNSKEY - 14400 RRSIG NSEC 13 2 14400 ( - 20161129153240 20161030153240 49035 example.org. - BQROf1swrmYi3GqpP5M/h5vTB8jmJ/RFnlaX - 7fjxvV7aMvXCsr3ekWeB2S7L6wWFihDYcKJg - 9BxVPqxzBKeaqg== ) - 1800 DNSKEY 256 3 13 ( - UNTqlHbC51EbXuY0rshW19Iz8SkCuGVS+L0e - bQj53dvtNlaKfWmtTauC797FoyVLbQwoMy/P - G68SXgLCx8g+9g== - ) ; ZSK; alg = ECDSAP256SHA256; key id = 49035 - 1800 RRSIG DNSKEY 13 2 1800 ( - 20161129153240 20161030153240 49035 example.org. - LnLHyqYJaCMOt7EHB4GZxzAzWLwEGCTFiEhC - jj1X1VuQSjJcN42Zd3yF+jihSW6huknrig0Z - Mqv0FM6mJ/qPKg== ) -a.delegated.example.org. 1800 IN A 139.162.196.78 - 1800 TXT "obscured" - 1800 AAAA 2a01:7e00::f03c:91ff:fef1:6735 -archive.example.org. 1800 IN CNAME a.example.org. - 1800 RRSIG CNAME 13 3 1800 ( - 20161129153240 20161030153240 49035 example.org. - SDFW1z/PN9knzH8BwBvmWK0qdIwMVtGrMgRw - 7lgy4utRrdrRdCSLZy3xpkmkh1wehuGc4R0S - 05Z3DPhB0Fg5BA== ) - 14400 NSEC delegated.example.org. CNAME RRSIG NSEC - 14400 RRSIG NSEC 13 3 14400 ( - 20161129153240 20161030153240 49035 example.org. - DQqLSVNl8F6v1K09wRU6/M6hbHy2VUddnOwn - JusJjMlrAOmoOctCZ/N/BwqCXXBA+d9yFGdH - knYumXp+BVPBAQ== ) -www.example.org. 1800 IN CNAME a.example.org. - 1800 RRSIG CNAME 13 3 1800 ( - 20161129153240 20161030153240 49035 example.org. - adzujOxCV0uBV4OayPGfR11iWBLiiSAnZB1R - slmhBFaDKOKSNYijGtiVPeaF+EuZs63pzd4y - 6Nm2Iq9cQhAwAA== ) - 14400 NSEC example.org. CNAME RRSIG NSEC - 14400 RRSIG NSEC 13 3 14400 ( - 20161129153240 20161030153240 49035 example.org. - jy3f96GZGBaRuQQjuqsoP1YN8ObZF37o+WkV - PL7TruzI7iNl0AjrUDy9FplP8Mqk/HWyvlPe - N3cU+W8NYlfDDQ== ) -a.example.org. 1800 IN A 139.162.196.78 - 1800 RRSIG A 13 3 1800 ( - 20161129153240 20161030153240 49035 example.org. - 41jFz0Dr8tZBN4Kv25S5dD4vTmviFiLx7xSA - qMIuLFm0qibKL07perKpxqgLqM0H1wreT4xz - I9Y4Dgp1nsOuMA== ) - 1800 AAAA 2a01:7e00::f03c:91ff:fef1:6735 - 1800 RRSIG AAAA 13 3 1800 ( - 20161129153240 20161030153240 49035 example.org. - brHizDxYCxCHrSKIu+J+XQbodRcb7KNRdN4q - VOWw8wHqeBsFNRzvFF6jwPQYphGP7kZh1KAb - VuY5ZVVhM2kHjw== ) - 14400 NSEC archive.example.org. A AAAA RRSIG NSEC - 14400 RRSIG NSEC 13 3 14400 ( - 20161129153240 20161030153240 49035 example.org. - zIenVlg5ScLr157EWigrTGUgrv7W/1s49Fic - i2k+OVjZfT50zw+q5X6DPKkzfAiUhIuqs53r - hZUzZwV/1Wew9Q== ) -delegated.example.org. 1800 IN NS a.delegated.example.org. - 1800 IN NS ns-ext.nlnetlabs.nl. - 1800 DS 10056 5 1 ( - EE72CABD1927759CDDA92A10DBF431504B9E - 1F13 ) - 1800 DS 10056 5 2 ( - E4B05F87725FA86D9A64F1E53C3D0E625094 - 6599DFE639C45955B0ED416CDDFA ) - 1800 RRSIG DS 13 3 1800 ( - 20161129153240 20161030153240 49035 example.org. - rlNNzcUmtbjLSl02ZzQGUbWX75yCUx0Mug1j - HtKVqRq1hpPE2S3863tIWSlz+W9wz4o19OI4 - jbznKKqk+DGKog== ) - 14400 NSEC sub.example.org. NS DS RRSIG NSEC - 14400 RRSIG NSEC 13 3 14400 ( - 20161129153240 20161030153240 49035 example.org. - lNQ5kRTB26yvZU5bFn84LYFCjwWTmBcRCDbD - cqWZvCSw4LFOcqbz1/wJKIRjIXIqnWIrfIHe - fZ9QD5xZsrPgUQ== ) -sub.example.org. 1800 IN NS sub1.example.net. - 1800 IN NS sub2.example.net. - 14400 NSEC www.example.org. NS RRSIG NSEC - 14400 RRSIG NSEC 13 3 14400 ( - 20161129153240 20161030153240 49035 example.org. - VYjahdV+TTkA3RBdnUI0hwXDm6U5k/weeZZr - ix1znORpOELbeLBMJW56cnaG+LGwOQfw9qqj - bOuULDst84s4+g== ) -` diff --git a/vendor/github.com/coredns/coredns/plugin/file/file.go b/vendor/github.com/coredns/coredns/plugin/file/file.go deleted file mode 100644 index f2294fa5..00000000 --- a/vendor/github.com/coredns/coredns/plugin/file/file.go +++ /dev/null @@ -1,151 +0,0 @@ -// Package file implements a file backend. -package file - -import ( - "context" - "fmt" - "io" - - "github.com/coredns/coredns/plugin" - clog "github.com/coredns/coredns/plugin/pkg/log" - "github.com/coredns/coredns/request" - - "github.com/miekg/dns" -) - -var log = clog.NewWithPlugin("file") - -type ( - // File is the plugin that reads zone data from disk. - File struct { - Next plugin.Handler - Zones Zones - } - - // Zones maps zone names to a *Zone. - Zones struct { - Z map[string]*Zone // A map mapping zone (origin) to the Zone's data - Names []string // All the keys from the map Z as a string slice. - } -) - -// ServeDNS implements the plugin.Handle interface. -func (f File) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (int, error) { - state := request.Request{W: w, Req: r, Context: ctx} - - qname := state.Name() - // TODO(miek): match the qname better in the map - zone := plugin.Zones(f.Zones.Names).Matches(qname) - if zone == "" { - return plugin.NextOrFailure(f.Name(), f.Next, ctx, w, r) - } - - z, ok := f.Zones.Z[zone] - if !ok || z == nil { - return dns.RcodeServerFailure, nil - } - - // This is only for when we are a secondary zones. - if r.Opcode == dns.OpcodeNotify { - if z.isNotify(state) { - m := new(dns.Msg) - m.SetReply(r) - m.Authoritative, m.RecursionAvailable = true, true - state.SizeAndDo(m) - w.WriteMsg(m) - - log.Infof("Notify from %s for %s: checking transfer", state.IP(), zone) - ok, err := z.shouldTransfer() - if ok { - z.TransferIn() - } else { - log.Infof("Notify from %s for %s: no serial increase seen", state.IP(), zone) - } - if err != nil { - log.Warningf("Notify from %s for %s: failed primary check: %s", state.IP(), zone, err) - } - return dns.RcodeSuccess, nil - } - log.Infof("Dropping notify from %s for %s", state.IP(), zone) - return dns.RcodeSuccess, nil - } - - if z.Expired != nil && *z.Expired { - log.Errorf("Zone %s is expired", zone) - return dns.RcodeServerFailure, nil - } - - if state.QType() == dns.TypeAXFR || state.QType() == dns.TypeIXFR { - xfr := Xfr{z} - return xfr.ServeDNS(ctx, w, r) - } - - answer, ns, extra, result := z.Lookup(state, qname) - - m := new(dns.Msg) - m.SetReply(r) - m.Authoritative, m.RecursionAvailable = true, true - m.Answer, m.Ns, m.Extra = answer, ns, extra - - switch result { - case Success: - case NoData: - case NameError: - m.Rcode = dns.RcodeNameError - case Delegation: - m.Authoritative = false - case ServerFailure: - return dns.RcodeServerFailure, nil - } - - state.SizeAndDo(m) - m, _ = state.Scrub(m) - w.WriteMsg(m) - return dns.RcodeSuccess, nil -} - -// Name implements the Handler interface. -func (f File) Name() string { return "file" } - -type serialErr struct { - err string - zone string - origin string - serial int64 -} - -func (s *serialErr) Error() string { - return fmt.Sprintf("%s for origin %s in file %s, with serial %d", s.err, s.origin, s.zone, s.serial) -} - -// Parse parses the zone in filename and returns a new Zone or an error. -// If serial >= 0 it will reload the zone, if the SOA hasn't changed -// it returns an error indicating nothing was read. -func Parse(f io.Reader, origin, fileName string, serial int64) (*Zone, error) { - tokens := dns.ParseZone(f, dns.Fqdn(origin), fileName) - z := NewZone(origin, fileName) - seenSOA := false - for x := range tokens { - if x.Error != nil { - return nil, x.Error - } - - if !seenSOA && serial >= 0 { - if s, ok := x.RR.(*dns.SOA); ok { - if s.Serial == uint32(serial) { // same serial - return nil, &serialErr{err: "no change in SOA serial", origin: origin, zone: fileName, serial: serial} - } - seenSOA = true - } - } - - if err := z.Insert(x.RR); err != nil { - return nil, err - } - } - if !seenSOA { - return nil, fmt.Errorf("file %q has no SOA record", fileName) - } - - return z, nil -} diff --git a/vendor/github.com/coredns/coredns/plugin/file/file_test.go b/vendor/github.com/coredns/coredns/plugin/file/file_test.go deleted file mode 100644 index 0e4050e3..00000000 --- a/vendor/github.com/coredns/coredns/plugin/file/file_test.go +++ /dev/null @@ -1,31 +0,0 @@ -package file - -import ( - "strings" - "testing" -) - -func BenchmarkFileParseInsert(b *testing.B) { - for i := 0; i < b.N; i++ { - Parse(strings.NewReader(dbMiekENTNL), testzone, "stdin", 0) - } -} - -func TestParseNoSOA(t *testing.T) { - _, err := Parse(strings.NewReader(dbNoSOA), "example.org.", "stdin", 0) - if err == nil { - t.Fatalf("Zone %q should have failed to load", "example.org.") - } - if !strings.Contains(err.Error(), "no SOA record") { - t.Fatalf("Zone %q should have failed to load with no soa error: %s", "example.org.", err) - } -} - -const dbNoSOA = ` -$TTL 1M -$ORIGIN example.org. - -www IN A 192.168.0.14 -mail IN A 192.168.0.15 -imap IN CNAME mail -` diff --git a/vendor/github.com/coredns/coredns/plugin/file/fuzz.go b/vendor/github.com/coredns/coredns/plugin/file/fuzz.go deleted file mode 100644 index 84f5c185..00000000 --- a/vendor/github.com/coredns/coredns/plugin/file/fuzz.go +++ /dev/null @@ -1,50 +0,0 @@ -// +build fuzz - -package file - -import ( - "strings" - - "github.com/coredns/coredns/plugin/pkg/fuzz" - "github.com/coredns/coredns/plugin/test" -) - -// Fuzz fuzzes file. -func Fuzz(data []byte) int { - name := "miek.nl." - zone, _ := Parse(strings.NewReader(fuzzMiekNL), name, "stdin", 0) - f := File{Next: test.ErrorHandler(), Zones: Zones{Z: map[string]*Zone{name: zone}, Names: []string{name}}} - - return fuzz.Do(f, data) -} - -const fuzzMiekNL = ` -$TTL 30M -$ORIGIN miek.nl. -@ IN SOA linode.atoom.net. miek.miek.nl. ( - 1282630057 ; Serial - 4H ; Refresh - 1H ; Retry - 7D ; Expire - 4H ) ; Negative Cache TTL - IN NS linode.atoom.net. - IN NS ns-ext.nlnetlabs.nl. - IN NS omval.tednet.nl. - IN NS ext.ns.whyscream.net. - - IN MX 1 aspmx.l.google.com. - IN MX 5 alt1.aspmx.l.google.com. - IN MX 5 alt2.aspmx.l.google.com. - IN MX 10 aspmx2.googlemail.com. - IN MX 10 aspmx3.googlemail.com. - - IN A 139.162.196.78 - IN AAAA 2a01:7e00::f03c:91ff:fef1:6735 - -a IN A 139.162.196.78 - IN AAAA 2a01:7e00::f03c:91ff:fef1:6735 -www IN CNAME a -archive IN CNAME a - -srv IN SRV 10 10 8080 a.miek.nl. -mx IN MX 10 a.miek.nl.` diff --git a/vendor/github.com/coredns/coredns/plugin/file/glue_test.go b/vendor/github.com/coredns/coredns/plugin/file/glue_test.go deleted file mode 100644 index 9cb71a99..00000000 --- a/vendor/github.com/coredns/coredns/plugin/file/glue_test.go +++ /dev/null @@ -1,253 +0,0 @@ -package file - -import ( - "context" - "strings" - "testing" - - "github.com/coredns/coredns/plugin/pkg/dnstest" - "github.com/coredns/coredns/plugin/test" - - "github.com/miekg/dns" -) - -// another personal zone (helps in testing as my secondary is NSD -// atoom = atom in English. -var atoomTestCases = []test.Case{ - { - Qname: atoom, Qtype: dns.TypeNS, Do: true, - Answer: []dns.RR{ - test.NS("atoom.net. 1800 IN NS linode.atoom.net."), - test.NS("atoom.net. 1800 IN NS ns-ext.nlnetlabs.nl."), - test.NS("atoom.net. 1800 IN NS omval.tednet.nl."), - test.RRSIG("atoom.net. 1800 IN RRSIG NS 8 2 1800 20170112031301 20161213031301 53289 atoom.net. DLe+G1 jlw="), - }, - Extra: []dns.RR{ - test.OPT(4096, true), - test.A("linode.atoom.net. 1800 IN A 176.58.119.54"), - test.AAAA("linode.atoom.net. 1800 IN AAAA 2a01:7e00::f03c:91ff:fe79:234c"), - test.RRSIG("linode.atoom.net. 1800 IN RRSIG A 8 3 1800 20170112031301 20161213031301 53289 atoom.net. Z4Ka4OLDoyxj72CL vkI="), - test.RRSIG("linode.atoom.net. 1800 IN RRSIG AAAA 8 3 1800 20170112031301 20161213031301 53289 atoom.net. l+9Qc914zFH/okG2fzJ1q olQ="), - }, - }, -} - -func TestLookupGlue(t *testing.T) { - zone, err := Parse(strings.NewReader(dbAtoomNetSigned), atoom, "stdin", 0) - if err != nil { - t.Fatalf("Expected no error when reading zone, got %q", err) - } - - fm := File{Next: test.ErrorHandler(), Zones: Zones{Z: map[string]*Zone{atoom: zone}, Names: []string{atoom}}} - ctx := context.TODO() - - for _, tc := range atoomTestCases { - m := tc.Msg() - - rec := dnstest.NewRecorder(&test.ResponseWriter{}) - _, err := fm.ServeDNS(ctx, rec, m) - if err != nil { - t.Errorf("Expected no error, got %v\n", err) - return - } - - resp := rec.Msg - test.SortAndCheck(t, resp, tc) - } -} - -const dbAtoomNetSigned = ` -; File written on Tue Dec 13 04:13:01 2016 -; dnssec_signzone version 9.10.3-P4-Debian -atoom.net. 1800 IN SOA linode.atoom.net. miek.miek.nl. ( - 1481602381 ; serial - 14400 ; refresh (4 hours) - 3600 ; retry (1 hour) - 604800 ; expire (1 week) - 14400 ; minimum (4 hours) - ) - 1800 RRSIG SOA 8 2 1800 ( - 20170112031301 20161213031301 53289 atoom.net. - GZ30uFuGATKzwHXgpEwK70qjdXSAqmbB5d4z - e7WTibvJDPLa1ptZBI7Zuod2KMOkT1ocSvhL - U7makhdv0BQx+5RSaP25mAmPIzfU7/T7R+DJ - 5q1GLlDSvOprfyMUlwOgZKZinesSdUa9gRmu - 8E+XnPNJ/jcTrGzzaDjn1/irrM0= ) - 1800 NS omval.tednet.nl. - 1800 NS linode.atoom.net. - 1800 NS ns-ext.nlnetlabs.nl. - 1800 RRSIG NS 8 2 1800 ( - 20170112031301 20161213031301 53289 atoom.net. - D8Sd9JpXIOxOrUF5Hi1ASutyQwP7JNu8XZxA - rse86A6L01O8H8sCNib2VEoJjHuZ/dDEogng - OgmfqeFy04cpSX19GAk3bkx8Lr6aEat3nqIC - XA/xsCCfXy0NKZpI05zntHPbbP5tF/NvpE7n - 0+oLtlHSPEg1ZnEgwNoLe+G1jlw= ) - 1800 A 176.58.119.54 - 1800 RRSIG A 8 2 1800 ( - 20170112031301 20161213031301 53289 atoom.net. - mrjiUFNCqDgCW8TuhjzcMh0V841uC224QvwH - 0+OvYhcve9twbX3Y12PSFmz77Xz3Jg9WAj4I - qhh3iHUac4dzUXyC702DT62yMF/9CMUO0+Ee - b6wRtvPHr2Tt0i/xV/BTbArInIvurXJrvKvo - LsZHOfsg7dZs6Mvdpe/CgwRExpk= ) - 1800 AAAA 2a01:7e00::f03c:91ff:fe79:234c - 1800 RRSIG AAAA 8 2 1800 ( - 20170112031301 20161213031301 53289 atoom.net. - EkMxX2vUaP4h0qbWlHaT4yNhm8MrPMZTn/3R - zNw+i3oF2cLMWKh6GCfuIX/x5ID706o8kfum - bxTYwuTe1LJ+GoZHWEiH8VCa1laTlh8l3qSi - PZKU8339rr5cCYluk6p9PbAuRkYYOEruNg42 - wPOx46dsAlvp2XpOaOeJtU64QGQ= ) - 14400 NSEC deb.atoom.net. A NS SOA AAAA RRSIG NSEC DNSKEY - 14400 RRSIG NSEC 8 2 14400 ( - 20170112031301 20161213031301 53289 atoom.net. - P7Stx7lqRKl8tbTAAaJ0W6UhgJwZz3cjpM8z - eplbhXEVohKtyJ9xgptKt1vreH6lkhzciar5 - EB9Nj0VOmcthiht/+As8aEKmf8UlcJ2EbLII - NT7NUaasxsrLE2rjjX5mEtzOZ1uQAGiU8Hnk - XdGweTgIVFuiCcMCgaKpC2TRrMw= ) - 1800 DNSKEY 256 3 8 ( - AwEAAeDZTH9YT9qLMPlq4VrxX7H3GbWcqCrC - tXc9RT/hf96GN+ttnnEQVaJY8Gbly3IZpYQW - MwaCi0t30UULXE3s9FUQtl4AMbplyiz9EF8L - /XoBS1yhGm5WV5u608ihoPaRkYNyVV3egb5Y - hA5EXWy2vfsa1XWPpxvSAhlqM0YENtP3 - ) ; ZSK; alg = RSASHA256; key id = 53289 - 1800 DNSKEY 257 3 8 ( - AwEAAepN7Vo8enDCruVduVlGxTDIv7QG0wJQ - fTL1hMy4k0Yf/7dXzrn5bZT4ytBvH1hoBImH - mtTrQo6DQlBBVXDJXTyQjQozaHpN1HhTJJTz - IXl8UrdbkLWvz6QSeJPmBBYQRAqylUA2KE29 - nxyiNboheDLiIWyQ7Q/Op7lYaKMdb555kQAs - b/XT4Tb3/3BhAjcofNofNBjDjPq2i8pAo8HU - 5mW5/Pl+ZT/S0aqQPnCkHk/iofSRu3ZdBzkH - 54eoC+BdyXb7gTbPGRr+1gMbf/rzhRiZ4vnX - NoEzGAXmorKzJHANNb6KQ/932V9UDHm9wbln - 6y3s7IBvsMX5KF8vo81Stkc= - ) ; KSK; alg = RSASHA256; key id = 19114 - 1800 RRSIG DNSKEY 8 2 1800 ( - 20170112031301 20161213031301 19114 atoom.net. - IEjViubKdef8RWB5bcnirqVcqDk16irkywJZ - sBjMyNs03/a+sl0UHEGAB7qCC+Rn+RDaM5It - WF+Gha6BwRIN9NuSg3BwB2h1nJtHw61pMVU9 - 2j9Q3pq7X1xoTBAcwY95t5a1xlw0iTCaLu1L - Iu/PbVp1gj1o8BF/PiYilvZJGUjaTgsi+YNi - 2kiWpp6afO78/W4nfVx+lQBmpyfX1lwL5PEC - 9f5PMbzRmOapvUBc2XdddGywLdmlNsLHimGV - t7kkHZHOWQR1TvvMbU3dsC0bFCrBVGDhEuxC - hATR+X5YV0AyDSyrew7fOGJKrapwMWS3yRLr - FAt0Vcxno5lwQImbCQ== ) - 1800 RRSIG DNSKEY 8 2 1800 ( - 20170112031301 20161213031301 53289 atoom.net. - sSxdgPT+gFZPN0ot6lZRGqOwvONUEsg0uEbf - kh19JlWHu/qvq5HOOK2VOW/UnswpVmtpFk0W - z/jiCNHifjpCCVn5tfCMZDLGekmPOjdobw24 - swBuGjnn0NHvxHoN6S+mb+AR6V/dLjquNUda - yzBc2Ua+XtQ7SCLKIvEhcNg9H3o= ) -deb.atoom.net. 1800 IN A 176.58.119.54 - 1800 RRSIG A 8 3 1800 ( - 20170112031301 20161213031301 53289 atoom.net. - ZW7jm/VDa/I9DxWlE7Cm+HHymiVv4Wk5UGYI - Uf/g0EfxLCBR6SwL5QKuV1z7xoWKaiNqqrmc - gg35xgskKyS8QHgCCODhDzcIKe+MSsBXbY04 - AtrC5dV3JJQoA65Ng/48hwcyghAjXKrA2Yyq - GXf2DSvWeIV9Jmk0CsOELP24dpk= ) - 1800 TXT "v=spf1 a ip6:2a01:7e00::f03c:91ff:fe79:234c ~all" - 1800 RRSIG TXT 8 3 1800 ( - 20170112031301 20161213031301 53289 atoom.net. - fpvVJ+Z6tzSd9yETn/PhLSCRISwRD1c3ET80 - 8twnx3XfAPQfV2R8dw7pz8Vw4TSxvf19bAZc - PWRjW682gb7gAxoJshCXBYabMfqExrBc9V1S - ezwm3D93xNMyegxzHx2b/H8qp3ZWdsMLTvvN - Azu7P4iyO+WRWT0R7bJGrdTwRz8= ) - 1800 AAAA 2a01:7e00::f03c:91ff:fe79:234c - 1800 RRSIG AAAA 8 3 1800 ( - 20170112031301 20161213031301 53289 atoom.net. - aaPF6NqXfWamzi+xUDVeYa7StJUVM1tDsL34 - w5uozFRZ0f4K/Z88Kk5CgztxmtpNNKGdLWa0 - iryUJsbVWAbSQfrZNkNckBtczMNxGgjqn97A - 2//F6ajH/qrR3dWcCm+VJMgu3UPqAxLiCaYO - GQUx6Y8JA1VIM/RJAM6BhgNxjD0= ) - 14400 NSEC lafhart.atoom.net. A TXT AAAA RRSIG NSEC - 14400 RRSIG NSEC 8 3 14400 ( - 20170112031301 20161213031301 53289 atoom.net. - 1Llad64NDWcz8CyBu2TsyANrJ9Tpfm5257sY - FPYF579p3c9Imwp9kYEO1zMEKgNoXBN/sQnd - YCugq3r2GAI6bfJj8sV5bt6GKuZcGHMESug4 - uh2gU0NDcCA4GPdBYGdusePwV0RNpcRnVCFA - fsACp+22j3uwRUbCh0re0ufbAs4= ) -lafhart.atoom.net. 1800 IN A 178.79.160.171 - 1800 RRSIG A 8 3 1800 ( - 20170112031301 20161213031301 53289 atoom.net. - fruP6cvMVICXEV8NcheS73NWLCEKlO1FgW6B - 35D2GhtfYZe+M23V5YBRtlVCCrAdS0etdCOf - xH9yt3u2kVvDXuMRiQr1zJPRDEq3cScYumpd - bOO8cjHiCic5lEcRVWNNHXyGtpqTvrp9CxOu - IQw1WgAlZyKj43zGg3WZi6OTKLg= ) - 14400 NSEC linode.atoom.net. A RRSIG NSEC - 14400 RRSIG NSEC 8 3 14400 ( - 20170112031301 20161213031301 53289 atoom.net. - 2AUWXbScL0jIJ7G6UsJAlUs+bgSprZ1zY6v/ - iVB5BAYwZD6pPky7LZdzvPEHh0aNLGIFbbU8 - SDJI7u/e4RUTlE+8yyjl6obZNfNKyJFqE5xN - 1BJ8sjFrVn6KaHIDKEOZunNb1MlMfCRkLg9O - 94zg04XEgVUfaYCPxvLs3fCEgzw= ) -voordeur.atoom.net. 1800 IN A 77.249.87.46 - 1800 RRSIG A 8 3 1800 ( - 20170112031301 20161213031301 53289 atoom.net. - SzJz0NaKLRA/lW4CxgMHgeuQLp5QqFEjQv3I - zfPtY4joQsZn8RN8RLECcpcPKjbC8Dj6mxIJ - dd2vwhsCVlZKMNcZUOfpB7eGx1TR9HnzMkY9 - OdTt30a9+tktagrJEoy31vAhj1hJqLbSgvOa - pRr1P4ZpQ53/qH8JX/LOmqfWTdg= ) - 14400 NSEC www.atoom.net. A RRSIG NSEC - 14400 RRSIG NSEC 8 3 14400 ( - 20170112031301 20161213031301 53289 atoom.net. - CETJhUJy1rKjVj9wsW1549gth+/Z37//BI6S - nxJ+2Oq63jEjlbznmyo5hvFW54DbVUod+cLo - N9PdlNQDr1XsRBgWhkKW37RkuoRVEPwqRykv - xzn9i7CgYKAAHFyWMGihBLkV9ByPp8GDR8Zr - DEkrG3ErDlBcwi3FqGZFsSOW2xg= ) -www.atoom.net. 1800 IN CNAME deb.atoom.net. - 1800 RRSIG CNAME 8 3 1800 ( - 20170112031301 20161213031301 53289 atoom.net. - 1lhG6iTtbeesBCVOrA8a7+V2gogCuXzKgSi8 - 6K0Pzq2CwqTScdNcZvcDOIbLq45Am5p09PIj - lXnd2fw6WAxphwvRhmwCve3uTZMUt5STw7oi - 0rED7GMuFUSC/BX0XVly7NET3ECa1vaK6RhO - hDSsKPWFI7to4d1z6tQ9j9Kvm4Y= ) - 14400 NSEC atoom.net. CNAME RRSIG NSEC - 14400 RRSIG NSEC 8 3 14400 ( - 20170112031301 20161213031301 53289 atoom.net. - CC4yCYP1q75/gTmPz+mVM6Lam2foPP5oTccY - RtROuTkgbt8DtAoPe304vmNazWBlGidnWJeD - YyAAe3znIHP0CgrxjD/hRL9FUzMnVrvB3mnx - 4W13wP1rE97RqJxV1kk22Wl3uCkVGy7LCjb0 - JLFvzCe2fuMe7YcTzI+t1rioTP0= ) -linode.atoom.net. 1800 IN A 176.58.119.54 - 1800 RRSIG A 8 3 1800 ( - 20170112031301 20161213031301 53289 atoom.net. - Z4Ka4OLDha4eQNWs3GtUd1Cumr48RUnH523I - nZzGXtpQNou70qsm5Jt8n/HmsZ4L5DoxomRz - rgZTGnrqj43+A16UUGfVEk6SfUUHOgxgspQW - zoaqk5/5mQO1ROsLKY8RqaRqzvbToHvqeZEh - VkTPVA02JK9UFlKqoyxj72CLvkI= ) - 1800 AAAA 2a01:7e00::f03c:91ff:fe79:234c - 1800 RRSIG AAAA 8 3 1800 ( - 20170112031301 20161213031301 53289 atoom.net. - l+9Qce/EQyKrTJVKLv7iatjuCO285ckd5Oie - P2LzWVsL4tW04oHzieKZwIuNBRE+px8g5qrT - LIK2TikCGL1xHAd7CT7gbCtDcZ7jHmSTmMTJ - 405nOV3G3xWelreLI5Fn5ck8noEsF64kiw1y - XfkyQn2B914zFH/okG2fzJ1qolQ= ) - 14400 NSEC voordeur.atoom.net. A AAAA RRSIG NSEC - 14400 RRSIG NSEC 8 3 14400 ( - 20170112031301 20161213031301 53289 atoom.net. - Owzmz7QrVL2Gw2njEsUVEknMl2amx1HG9X3K - tO+Ihyy4tApiUFxUjAu3P/30QdqbB85h7s// - ipwX/AmQJNoxTScR3nHt9qDqJ044DPmiuh0l - NuIjguyZRANApmKCTA6AoxXIUqToIIjfVzi/ - PxXE6T3YIPlK7Bxgv1lcCBJ1fmE= )` - -const atoom = "atoom.net." diff --git a/vendor/github.com/coredns/coredns/plugin/file/include_test.go b/vendor/github.com/coredns/coredns/plugin/file/include_test.go deleted file mode 100644 index fad91df5..00000000 --- a/vendor/github.com/coredns/coredns/plugin/file/include_test.go +++ /dev/null @@ -1,32 +0,0 @@ -package file - -import ( - "strings" - "testing" - - "github.com/coredns/coredns/plugin/test" -) - -// Make sure the external miekg/dns dependency is up to date - -func TestInclude(t *testing.T) { - - name, rm, err := test.TempFile(".", "foo\tIN\tA\t127.0.0.1\n") - if err != nil { - t.Fatalf("Unable to create tmpfile %q: %s", name, err) - } - defer rm() - - zone := `$ORIGIN example.org. -@ IN SOA sns.dns.icann.org. noc.dns.icann.org. 2017042766 7200 3600 1209600 3600 -$INCLUDE ` + name + "\n" - - z, err := Parse(strings.NewReader(zone), "example.org.", "test", 0) - if err != nil { - t.Errorf("Unable to parse zone %q: %s", "example.org.", err) - } - - if _, ok := z.Search("foo.example.org."); !ok { - t.Errorf("Failed to find %q in parsed zone", "foo.example.org.") - } -} diff --git a/vendor/github.com/coredns/coredns/plugin/file/lookup.go b/vendor/github.com/coredns/coredns/plugin/file/lookup.go deleted file mode 100644 index 31248f31..00000000 --- a/vendor/github.com/coredns/coredns/plugin/file/lookup.go +++ /dev/null @@ -1,471 +0,0 @@ -package file - -import ( - "github.com/coredns/coredns/plugin/file/tree" - "github.com/coredns/coredns/request" - - "github.com/miekg/dns" -) - -// Result is the result of a Lookup -type Result int - -const ( - // Success is a successful lookup. - Success Result = iota - // NameError indicates a nameerror - NameError - // Delegation indicates the lookup resulted in a delegation. - Delegation - // NoData indicates the lookup resulted in a NODATA. - NoData - // ServerFailure indicates a server failure during the lookup. - ServerFailure -) - -// Lookup looks up qname and qtype in the zone. When do is true DNSSEC records are included. -// Three sets of records are returned, one for the answer, one for authority and one for the additional section. -func (z *Zone) Lookup(state request.Request, qname string) ([]dns.RR, []dns.RR, []dns.RR, Result) { - - qtype := state.QType() - do := state.Do() - - if !z.NoReload { - z.reloadMu.RLock() - } - defer func() { - if !z.NoReload { - z.reloadMu.RUnlock() - } - }() - - // If z is a secondary zone we might not have transferred it, meaning we have - // all zone context setup, except the actual record. This means (for one thing) the apex - // is empty and we don't have a SOA record. - soa := z.Apex.SOA - if soa == nil { - return nil, nil, nil, ServerFailure - } - - if qtype == dns.TypeSOA { - return z.soa(do), z.ns(do), nil, Success - } - if qtype == dns.TypeNS && qname == z.origin { - nsrrs := z.ns(do) - glue := z.Glue(nsrrs, do) - return nsrrs, nil, glue, Success - } - - var ( - found, shot bool - parts string - i int - elem, wildElem *tree.Elem - ) - - // Lookup: - // * Per label from the right, look if it exists. We do this to find potential - // delegation records. - // * If the per-label search finds nothing, we will look for the wildcard at the - // level. If found we keep it around. If we don't find the complete name we will - // use the wildcard. - // - // Main for-loop handles delegation and finding or not finding the qname. - // If found we check if it is a CNAME/DNAME and do CNAME processing - // We also check if we have type and do a nodata resposne. - // - // If not found, we check the potential wildcard, and use that for further processing. - // If not found and no wildcard we will process this as an NXDOMAIN response. - for { - parts, shot = z.nameFromRight(qname, i) - // We overshot the name, break and check if we previously found something. - if shot { - break - } - - elem, found = z.Tree.Search(parts) - if !found { - // Apex will always be found, when we are here we can search for a wildcard - // and save the result of that search. So when nothing match, but we have a - // wildcard we should expand the wildcard. - - wildcard := replaceWithAsteriskLabel(parts) - if wild, found := z.Tree.Search(wildcard); found { - wildElem = wild - } - - // Keep on searching, because maybe we hit an empty-non-terminal (which aren't - // stored in the tree. Only when we have match the full qname (and possible wildcard - // we can be confident that we didn't find anything. - i++ - continue - } - - // If we see DNAME records, we should return those. - if dnamerrs := elem.Types(dns.TypeDNAME); dnamerrs != nil { - // Only one DNAME is allowed per name. We just pick the first one to synthesize from. - dname := dnamerrs[0] - if cname := synthesizeCNAME(state.Name(), dname.(*dns.DNAME)); cname != nil { - answer, ns, extra, rcode := z.additionalProcessing(state, elem, []dns.RR{cname}) - - if do { - sigs := elem.Types(dns.TypeRRSIG) - sigs = signatureForSubType(sigs, dns.TypeDNAME) - dnamerrs = append(dnamerrs, sigs...) - } - - // The relevant DNAME RR should be included in the answer section, - // if the DNAME is being employed as a substitution instruction. - answer = append(dnamerrs, answer...) - - return answer, ns, extra, rcode - } - // The domain name that owns a DNAME record is allowed to have other RR types - // at that domain name, except those have restrictions on what they can coexist - // with (e.g. another DNAME). So there is nothing special left here. - } - - // If we see NS records, it means the name as been delegated, and we should return the delegation. - if nsrrs := elem.Types(dns.TypeNS); nsrrs != nil { - - // If the query is specifically for DS and the qname matches the delegated name, we should - // return the DS in the answer section and leave the rest empty, i.e. just continue the loop - // and continue searching. - if qtype == dns.TypeDS && elem.Name() == qname { - i++ - continue - } - - glue := z.Glue(nsrrs, do) - if do { - dss := z.typeFromElem(elem, dns.TypeDS, do) - nsrrs = append(nsrrs, dss...) - } - - return nil, nsrrs, glue, Delegation - } - - i++ - } - - // What does found and !shot mean - do we ever hit it? - if found && !shot { - return nil, nil, nil, ServerFailure - } - - // Found entire name. - if found && shot { - - if rrs := elem.Types(dns.TypeCNAME); len(rrs) > 0 && qtype != dns.TypeCNAME { - return z.additionalProcessing(state, elem, rrs) - } - - rrs := elem.Types(qtype, qname) - - // NODATA - if len(rrs) == 0 { - ret := z.soa(do) - if do { - nsec := z.typeFromElem(elem, dns.TypeNSEC, do) - ret = append(ret, nsec...) - } - return nil, ret, nil, NoData - } - - // Additional section processing for MX, SRV. Check response and see if any of the names are in baliwick - - // if so add IP addresses to the additional section. - additional := additionalProcessing(z, rrs, do) - - if do { - sigs := elem.Types(dns.TypeRRSIG) - sigs = signatureForSubType(sigs, qtype) - rrs = append(rrs, sigs...) - } - - return rrs, z.ns(do), additional, Success - - } - - // Haven't found the original name. - - // Found wildcard. - if wildElem != nil { - auth := z.ns(do) - - if rrs := wildElem.Types(dns.TypeCNAME, qname); len(rrs) > 0 { - return z.additionalProcessing(state, wildElem, rrs) - } - - rrs := wildElem.Types(qtype, qname) - - // NODATA response. - if len(rrs) == 0 { - ret := z.soa(do) - if do { - nsec := z.typeFromElem(wildElem, dns.TypeNSEC, do) - ret = append(ret, nsec...) - } - return nil, ret, nil, Success - } - - if do { - // An NSEC is needed to say no longer name exists under this wildcard. - if deny, found := z.Tree.Prev(qname); found { - nsec := z.typeFromElem(deny, dns.TypeNSEC, do) - auth = append(auth, nsec...) - } - - sigs := wildElem.Types(dns.TypeRRSIG, qname) - sigs = signatureForSubType(sigs, qtype) - rrs = append(rrs, sigs...) - - } - return rrs, auth, nil, Success - } - - rcode := NameError - - // Hacky way to get around empty-non-terminals. If a longer name does exist, but this qname, does not, it - // must be an empty-non-terminal. If so, we do the proper NXDOMAIN handling, but set the rcode to be success. - if x, found := z.Tree.Next(qname); found { - if dns.IsSubDomain(qname, x.Name()) { - rcode = Success - } - } - - ret := z.soa(do) - if do { - deny, found := z.Tree.Prev(qname) - if !found { - goto Out - } - nsec := z.typeFromElem(deny, dns.TypeNSEC, do) - ret = append(ret, nsec...) - - if rcode != NameError { - goto Out - } - - ce, found := z.ClosestEncloser(qname) - - // wildcard denial only for NXDOMAIN - if found { - // wildcard denial - wildcard := "*." + ce.Name() - if ss, found := z.Tree.Prev(wildcard); found { - // Only add this nsec if it is different than the one already added - if ss.Name() != deny.Name() { - nsec := z.typeFromElem(ss, dns.TypeNSEC, do) - ret = append(ret, nsec...) - } - } - } - - } -Out: - return nil, ret, nil, rcode -} - -// Return type tp from e and add signatures (if they exists) and do is true. -func (z *Zone) typeFromElem(elem *tree.Elem, tp uint16, do bool) []dns.RR { - rrs := elem.Types(tp) - if do { - sigs := elem.Types(dns.TypeRRSIG) - sigs = signatureForSubType(sigs, tp) - if len(sigs) > 0 { - rrs = append(rrs, sigs...) - } - } - return rrs -} - -func (z *Zone) soa(do bool) []dns.RR { - if do { - ret := append([]dns.RR{z.Apex.SOA}, z.Apex.SIGSOA...) - return ret - } - return []dns.RR{z.Apex.SOA} -} - -func (z *Zone) ns(do bool) []dns.RR { - if do { - ret := append(z.Apex.NS, z.Apex.SIGNS...) - return ret - } - return z.Apex.NS -} - -// aditionalProcessing adds signatures and tries to resolve CNAMEs that point to external names. -func (z *Zone) additionalProcessing(state request.Request, elem *tree.Elem, rrs []dns.RR) ([]dns.RR, []dns.RR, []dns.RR, Result) { - - qtype := state.QType() - do := state.Do() - - if do { - sigs := elem.Types(dns.TypeRRSIG) - sigs = signatureForSubType(sigs, dns.TypeCNAME) - if len(sigs) > 0 { - rrs = append(rrs, sigs...) - } - } - - targetName := rrs[0].(*dns.CNAME).Target - elem, _ = z.Tree.Search(targetName) - if elem == nil { - rrs = append(rrs, z.externalLookup(state, targetName, qtype)...) - return rrs, z.ns(do), nil, Success - } - - i := 0 - -Redo: - cname := elem.Types(dns.TypeCNAME) - if len(cname) > 0 { - rrs = append(rrs, cname...) - - if do { - sigs := elem.Types(dns.TypeRRSIG) - sigs = signatureForSubType(sigs, dns.TypeCNAME) - if len(sigs) > 0 { - rrs = append(rrs, sigs...) - } - } - targetName := cname[0].(*dns.CNAME).Target - elem, _ = z.Tree.Search(targetName) - if elem == nil { - rrs = append(rrs, z.externalLookup(state, targetName, qtype)...) - return rrs, z.ns(do), nil, Success - } - - i++ - if i > maxChain { - return rrs, z.ns(do), nil, Success - } - - goto Redo - } - - targets := cnameForType(elem.All(), qtype) - if len(targets) > 0 { - rrs = append(rrs, targets...) - - if do { - sigs := elem.Types(dns.TypeRRSIG) - sigs = signatureForSubType(sigs, qtype) - if len(sigs) > 0 { - rrs = append(rrs, sigs...) - } - } - } - - return rrs, z.ns(do), nil, Success -} - -func cnameForType(targets []dns.RR, origQtype uint16) []dns.RR { - ret := []dns.RR{} - for _, target := range targets { - if target.Header().Rrtype == origQtype { - ret = append(ret, target) - } - } - return ret -} - -func (z *Zone) externalLookup(state request.Request, target string, qtype uint16) []dns.RR { - m, e := z.Upstream.Lookup(state, target, qtype) - if e != nil { - // TODO(miek): Log, or return error here? - return nil - } - if m == nil { - return nil - } - return m.Answer -} - -// signatureForSubType range through the signature and return the correct ones for the subtype. -func signatureForSubType(rrs []dns.RR, subtype uint16) []dns.RR { - sigs := []dns.RR{} - for _, sig := range rrs { - if s, ok := sig.(*dns.RRSIG); ok { - if s.TypeCovered == subtype { - sigs = append(sigs, s) - } - } - } - return sigs -} - -// Glue returns any potential glue records for nsrrs. -func (z *Zone) Glue(nsrrs []dns.RR, do bool) []dns.RR { - glue := []dns.RR{} - for _, rr := range nsrrs { - if ns, ok := rr.(*dns.NS); ok && dns.IsSubDomain(ns.Header().Name, ns.Ns) { - glue = append(glue, z.searchGlue(ns.Ns, do)...) - } - } - return glue -} - -// searchGlue looks up A and AAAA for name. -func (z *Zone) searchGlue(name string, do bool) []dns.RR { - glue := []dns.RR{} - - // A - if elem, found := z.Tree.Search(name); found { - glue = append(glue, elem.Types(dns.TypeA)...) - if do { - sigs := elem.Types(dns.TypeRRSIG) - sigs = signatureForSubType(sigs, dns.TypeA) - glue = append(glue, sigs...) - } - } - - // AAAA - if elem, found := z.Tree.Search(name); found { - glue = append(glue, elem.Types(dns.TypeAAAA)...) - if do { - sigs := elem.Types(dns.TypeRRSIG) - sigs = signatureForSubType(sigs, dns.TypeAAAA) - glue = append(glue, sigs...) - } - } - return glue -} - -// additionalProcessing checks the current answer section and retrieves A or AAAA records -// (and possible SIGs) to need to be put in the additional section. -func additionalProcessing(z *Zone, answer []dns.RR, do bool) (extra []dns.RR) { - for _, rr := range answer { - name := "" - switch x := rr.(type) { - case *dns.SRV: - name = x.Target - case *dns.MX: - name = x.Mx - } - if !dns.IsSubDomain(z.origin, name) { - continue - } - - elem, _ := z.Tree.Search(name) - if elem == nil { - continue - } - - sigs := elem.Types(dns.TypeRRSIG) - for _, addr := range []uint16{dns.TypeA, dns.TypeAAAA} { - if a := elem.Types(addr); a != nil { - extra = append(extra, a...) - if do { - sig := signatureForSubType(sigs, addr) - extra = append(extra, sig...) - } - } - } - } - - return extra -} - -const maxChain = 8 diff --git a/vendor/github.com/coredns/coredns/plugin/file/lookup_test.go b/vendor/github.com/coredns/coredns/plugin/file/lookup_test.go deleted file mode 100644 index 97cae6b0..00000000 --- a/vendor/github.com/coredns/coredns/plugin/file/lookup_test.go +++ /dev/null @@ -1,194 +0,0 @@ -package file - -import ( - "context" - "strings" - "testing" - - "github.com/coredns/coredns/plugin/pkg/dnstest" - "github.com/coredns/coredns/plugin/test" - - "github.com/miekg/dns" -) - -var dnsTestCases = []test.Case{ - { - Qname: "www.miek.nl.", Qtype: dns.TypeA, - Answer: []dns.RR{ - test.A("a.miek.nl. 1800 IN A 139.162.196.78"), - test.CNAME("www.miek.nl. 1800 IN CNAME a.miek.nl."), - }, - Ns: miekAuth, - }, - { - Qname: "www.miek.nl.", Qtype: dns.TypeAAAA, - Answer: []dns.RR{ - test.AAAA("a.miek.nl. 1800 IN AAAA 2a01:7e00::f03c:91ff:fef1:6735"), - test.CNAME("www.miek.nl. 1800 IN CNAME a.miek.nl."), - }, - Ns: miekAuth, - }, - { - Qname: "miek.nl.", Qtype: dns.TypeSOA, - Answer: []dns.RR{ - test.SOA("miek.nl. 1800 IN SOA linode.atoom.net. miek.miek.nl. 1282630057 14400 3600 604800 14400"), - }, - Ns: miekAuth, - }, - { - Qname: "miek.nl.", Qtype: dns.TypeAAAA, - Answer: []dns.RR{ - test.AAAA("miek.nl. 1800 IN AAAA 2a01:7e00::f03c:91ff:fef1:6735"), - }, - Ns: miekAuth, - }, - { - Qname: "mIeK.NL.", Qtype: dns.TypeAAAA, - Answer: []dns.RR{ - test.AAAA("miek.nl. 1800 IN AAAA 2a01:7e00::f03c:91ff:fef1:6735"), - }, - Ns: miekAuth, - }, - { - Qname: "miek.nl.", Qtype: dns.TypeMX, - Answer: []dns.RR{ - test.MX("miek.nl. 1800 IN MX 1 aspmx.l.google.com."), - test.MX("miek.nl. 1800 IN MX 10 aspmx2.googlemail.com."), - test.MX("miek.nl. 1800 IN MX 10 aspmx3.googlemail.com."), - test.MX("miek.nl. 1800 IN MX 5 alt1.aspmx.l.google.com."), - test.MX("miek.nl. 1800 IN MX 5 alt2.aspmx.l.google.com."), - }, - Ns: miekAuth, - }, - { - Qname: "a.miek.nl.", Qtype: dns.TypeSRV, - Ns: []dns.RR{ - test.SOA("miek.nl. 1800 IN SOA linode.atoom.net. miek.miek.nl. 1282630057 14400 3600 604800 14400"), - }, - }, - { - Qname: "b.miek.nl.", Qtype: dns.TypeA, - Rcode: dns.RcodeNameError, - Ns: []dns.RR{ - test.SOA("miek.nl. 1800 IN SOA linode.atoom.net. miek.miek.nl. 1282630057 14400 3600 604800 14400"), - }, - }, - { - Qname: "srv.miek.nl.", Qtype: dns.TypeSRV, - Answer: []dns.RR{ - test.SRV("srv.miek.nl. 1800 IN SRV 10 10 8080 a.miek.nl."), - }, - Extra: []dns.RR{ - test.A("a.miek.nl. 1800 IN A 139.162.196.78"), - test.AAAA("a.miek.nl. 1800 IN AAAA 2a01:7e00::f03c:91ff:fef1:6735"), - }, - Ns: miekAuth, - }, - { - Qname: "mx.miek.nl.", Qtype: dns.TypeMX, - Answer: []dns.RR{ - test.MX("mx.miek.nl. 1800 IN MX 10 a.miek.nl."), - }, - Extra: []dns.RR{ - test.A("a.miek.nl. 1800 IN A 139.162.196.78"), - test.AAAA("a.miek.nl. 1800 IN AAAA 2a01:7e00::f03c:91ff:fef1:6735"), - }, - Ns: miekAuth, - }, -} - -const ( - testzone = "miek.nl." - testzone1 = "dnssex.nl." -) - -func TestLookup(t *testing.T) { - zone, err := Parse(strings.NewReader(dbMiekNL), testzone, "stdin", 0) - if err != nil { - t.Fatalf("Expected no error when reading zone, got %q", err) - } - - fm := File{Next: test.ErrorHandler(), Zones: Zones{Z: map[string]*Zone{testzone: zone}, Names: []string{testzone}}} - ctx := context.TODO() - - for _, tc := range dnsTestCases { - m := tc.Msg() - - rec := dnstest.NewRecorder(&test.ResponseWriter{}) - _, err := fm.ServeDNS(ctx, rec, m) - if err != nil { - t.Errorf("Expected no error, got %v\n", err) - return - } - - resp := rec.Msg - test.SortAndCheck(t, resp, tc) - } -} - -func TestLookupNil(t *testing.T) { - fm := File{Next: test.ErrorHandler(), Zones: Zones{Z: map[string]*Zone{testzone: nil}, Names: []string{testzone}}} - ctx := context.TODO() - - m := dnsTestCases[0].Msg() - rec := dnstest.NewRecorder(&test.ResponseWriter{}) - fm.ServeDNS(ctx, rec, m) -} - -func BenchmarkFileLookup(b *testing.B) { - zone, err := Parse(strings.NewReader(dbMiekNL), testzone, "stdin", 0) - if err != nil { - return - } - - fm := File{Next: test.ErrorHandler(), Zones: Zones{Z: map[string]*Zone{testzone: zone}, Names: []string{testzone}}} - ctx := context.TODO() - rec := dnstest.NewRecorder(&test.ResponseWriter{}) - - tc := test.Case{ - Qname: "www.miek.nl.", Qtype: dns.TypeA, - Answer: []dns.RR{ - test.CNAME("www.miek.nl. 1800 IN CNAME a.miek.nl."), - test.A("a.miek.nl. 1800 IN A 139.162.196.78"), - }, - } - - m := tc.Msg() - - b.ResetTimer() - - for i := 0; i < b.N; i++ { - fm.ServeDNS(ctx, rec, m) - } -} - -const dbMiekNL = ` -$TTL 30M -$ORIGIN miek.nl. -@ IN SOA linode.atoom.net. miek.miek.nl. ( - 1282630057 ; Serial - 4H ; Refresh - 1H ; Retry - 7D ; Expire - 4H ) ; Negative Cache TTL - IN NS linode.atoom.net. - IN NS ns-ext.nlnetlabs.nl. - IN NS omval.tednet.nl. - IN NS ext.ns.whyscream.net. - - IN MX 1 aspmx.l.google.com. - IN MX 5 alt1.aspmx.l.google.com. - IN MX 5 alt2.aspmx.l.google.com. - IN MX 10 aspmx2.googlemail.com. - IN MX 10 aspmx3.googlemail.com. - - IN A 139.162.196.78 - IN AAAA 2a01:7e00::f03c:91ff:fef1:6735 - -a IN A 139.162.196.78 - IN AAAA 2a01:7e00::f03c:91ff:fef1:6735 -www IN CNAME a -archive IN CNAME a - -srv IN SRV 10 10 8080 a.miek.nl. -mx IN MX 10 a.miek.nl.` diff --git a/vendor/github.com/coredns/coredns/plugin/file/notify.go b/vendor/github.com/coredns/coredns/plugin/file/notify.go deleted file mode 100644 index ce6a0b09..00000000 --- a/vendor/github.com/coredns/coredns/plugin/file/notify.go +++ /dev/null @@ -1,81 +0,0 @@ -package file - -import ( - "fmt" - "net" - - "github.com/coredns/coredns/plugin/pkg/rcode" - "github.com/coredns/coredns/request" - - "github.com/miekg/dns" -) - -// isNotify checks if state is a notify message and if so, will *also* check if it -// is from one of the configured masters. If not it will not be a valid notify -// message. If the zone z is not a secondary zone the message will also be ignored. -func (z *Zone) isNotify(state request.Request) bool { - if state.Req.Opcode != dns.OpcodeNotify { - return false - } - if len(z.TransferFrom) == 0 { - return false - } - // If remote IP matches we accept. - remote := state.IP() - for _, f := range z.TransferFrom { - from, _, err := net.SplitHostPort(f) - if err != nil { - continue - } - if from == remote { - return true - } - } - return false -} - -// Notify will send notifies to all configured TransferTo IP addresses. -func (z *Zone) Notify() { - go notify(z.origin, z.TransferTo) -} - -// notify sends notifies to the configured remote servers. It will try up to three times -// before giving up on a specific remote. We will sequentially loop through "to" -// until they all have replied (or have 3 failed attempts). -func notify(zone string, to []string) error { - m := new(dns.Msg) - m.SetNotify(zone) - c := new(dns.Client) - - for _, t := range to { - if t == "*" { - continue - } - if err := notifyAddr(c, m, t); err != nil { - log.Error(err.Error()) - } else { - log.Infof("Sent notify for zone %q to %q", zone, t) - } - } - return nil -} - -func notifyAddr(c *dns.Client, m *dns.Msg, s string) error { - var err error - - code := dns.RcodeServerFailure - for i := 0; i < 3; i++ { - ret, _, err := c.Exchange(m, s) - if err != nil { - continue - } - code = ret.Rcode - if code == dns.RcodeSuccess { - return nil - } - } - if err != nil { - return fmt.Errorf("notify for zone %q was not accepted by %q: %q", m.Question[0].Name, s, err) - } - return fmt.Errorf("notify for zone %q was not accepted by %q: rcode was %q", m.Question[0].Name, s, rcode.ToString(code)) -} diff --git a/vendor/github.com/coredns/coredns/plugin/file/nsec3_test.go b/vendor/github.com/coredns/coredns/plugin/file/nsec3_test.go deleted file mode 100644 index ed9f74f2..00000000 --- a/vendor/github.com/coredns/coredns/plugin/file/nsec3_test.go +++ /dev/null @@ -1,28 +0,0 @@ -package file - -import ( - "strings" - "testing" -) - -func TestParseNSEC3PARAM(t *testing.T) { - _, err := Parse(strings.NewReader(nsec3paramTest), "miek.nl", "stdin", 0) - if err == nil { - t.Fatalf("Expected error when reading zone, got nothing") - } -} - -func TestParseNSEC3(t *testing.T) { - _, err := Parse(strings.NewReader(nsec3Test), "miek.nl", "stdin", 0) - if err == nil { - t.Fatalf("Expected error when reading zone, got nothing") - } -} - -const nsec3paramTest = `miek.nl. 1800 IN SOA linode.atoom.net. miek.miek.nl. 1460175181 14400 3600 604800 14400 -miek.nl. 1800 IN NS omval.tednet.nl. -miek.nl. 0 IN NSEC3PARAM 1 0 5 A3DEBC9CC4F695C7` - -const nsec3Test = `example.org. 1800 IN SOA sns.dns.icann.org. noc.dns.icann.org. 2016082508 7200 3600 1209600 3600 -aub8v9ce95ie18spjubsr058h41n7pa5.example.org. 284 IN NSEC3 1 1 5 D0CBEAAF0AC77314 AUB95P93VPKP55G6U5S4SGS7LS61ND85 NS SOA TXT RRSIG DNSKEY NSEC3PARAM -aub8v9ce95ie18spjubsr058h41n7pa5.example.org. 284 IN RRSIG NSEC3 8 2 600 20160910232502 20160827231002 14028 example.org. XBNpA7KAIjorPbXvTinOHrc1f630aHic2U716GHLHA4QMx9cl9ss4QjR Wj2UpDM9zBW/jNYb1xb0yjQoez/Jv200w0taSWjRci5aUnRpOi9bmcrz STHb6wIUjUsbJ+NstQsUwVkj6679UviF1FqNwr4GlJnWG3ZrhYhE+NI6 s0k=` diff --git a/vendor/github.com/coredns/coredns/plugin/file/reload.go b/vendor/github.com/coredns/coredns/plugin/file/reload.go deleted file mode 100644 index af06b98a..00000000 --- a/vendor/github.com/coredns/coredns/plugin/file/reload.go +++ /dev/null @@ -1,67 +0,0 @@ -package file - -import ( - "os" - "time" -) - -// TickTime is the default time we use to reload zone. Exported to be tweaked in tests. -var TickTime = 1 * time.Minute - -// Reload reloads a zone when it is changed on disk. If z.NoRoload is true, no reloading will be done. -func (z *Zone) Reload() error { - if z.NoReload { - return nil - } - - tick := time.NewTicker(TickTime) - - go func() { - - for { - select { - - case <-tick.C: - reader, err := os.Open(z.file) - if err != nil { - log.Errorf("Failed to open zone %q in %q: %v", z.origin, z.file, err) - continue - } - - serial := z.SOASerialIfDefined() - zone, err := Parse(reader, z.origin, z.file, serial) - if err != nil { - if _, ok := err.(*serialErr); !ok { - log.Errorf("Parsing zone %q: %v", z.origin, err) - } - continue - } - - // copy elements we need - z.reloadMu.Lock() - z.Apex = zone.Apex - z.Tree = zone.Tree - z.reloadMu.Unlock() - - log.Infof("Successfully reloaded zone %q in %q with serial %d", z.origin, z.file, z.Apex.SOA.Serial) - z.Notify() - - case <-z.reloadShutdown: - tick.Stop() - return - } - } - }() - return nil -} - -// SOASerialIfDefined returns the SOA's serial if the zone has a SOA record in the Apex, or -// -1 otherwise. -func (z *Zone) SOASerialIfDefined() int64 { - z.reloadMu.Lock() - defer z.reloadMu.Unlock() - if z.Apex.SOA != nil { - return int64(z.Apex.SOA.Serial) - } - return -1 -} diff --git a/vendor/github.com/coredns/coredns/plugin/file/reload_test.go b/vendor/github.com/coredns/coredns/plugin/file/reload_test.go deleted file mode 100644 index e9815366..00000000 --- a/vendor/github.com/coredns/coredns/plugin/file/reload_test.go +++ /dev/null @@ -1,81 +0,0 @@ -package file - -import ( - "io/ioutil" - "os" - "strings" - "testing" - "time" - - "github.com/coredns/coredns/plugin/test" - "github.com/coredns/coredns/request" - - "github.com/miekg/dns" -) - -func TestZoneReload(t *testing.T) { - fileName, rm, err := test.TempFile(".", reloadZoneTest) - if err != nil { - t.Fatalf("Failed to create zone: %s", err) - } - defer rm() - reader, err := os.Open(fileName) - if err != nil { - t.Fatalf("Failed to open zone: %s", err) - } - z, err := Parse(reader, "miek.nl", fileName, 0) - if err != nil { - t.Fatalf("Failed to parse zone: %s", err) - } - - TickTime = 500 * time.Millisecond - z.Reload() - time.Sleep(time.Second) - - r := new(dns.Msg) - r.SetQuestion("miek.nl", dns.TypeSOA) - state := request.Request{W: &test.ResponseWriter{}, Req: r} - if _, _, _, res := z.Lookup(state, "miek.nl."); res != Success { - t.Fatalf("Failed to lookup, got %d", res) - } - - r = new(dns.Msg) - r.SetQuestion("miek.nl", dns.TypeNS) - state = request.Request{W: &test.ResponseWriter{}, Req: r} - if _, _, _, res := z.Lookup(state, "miek.nl."); res != Success { - t.Fatalf("Failed to lookup, got %d", res) - } - - if len(z.All()) != 5 { - t.Fatalf("Expected 5 RRs, got %d", len(z.All())) - } - if err := ioutil.WriteFile(fileName, []byte(reloadZone2Test), 0644); err != nil { - t.Fatalf("Failed to write new zone data: %s", err) - } - // Could still be racy, but we need to wait a bit for the event to be seen - time.Sleep(1 * time.Second) - - if len(z.All()) != 3 { - t.Fatalf("Expected 3 RRs, got %d", len(z.All())) - } -} - -func TestZoneReloadSOAChange(t *testing.T) { - _, err := Parse(strings.NewReader(reloadZoneTest), "miek.nl.", "stdin", 1460175181) - if err == nil { - t.Fatalf("Zone should not have been re-parsed") - } - -} - -const reloadZoneTest = `miek.nl. 1627 IN SOA linode.atoom.net. miek.miek.nl. 1460175181 14400 3600 604800 14400 -miek.nl. 1627 IN NS ext.ns.whyscream.net. -miek.nl. 1627 IN NS omval.tednet.nl. -miek.nl. 1627 IN NS linode.atoom.net. -miek.nl. 1627 IN NS ns-ext.nlnetlabs.nl. -` - -const reloadZone2Test = `miek.nl. 1627 IN SOA linode.atoom.net. miek.miek.nl. 1460175182 14400 3600 604800 14400 -miek.nl. 1627 IN NS ext.ns.whyscream.net. -miek.nl. 1627 IN NS omval.tednet.nl. -` diff --git a/vendor/github.com/coredns/coredns/plugin/file/secondary.go b/vendor/github.com/coredns/coredns/plugin/file/secondary.go deleted file mode 100644 index dc732ee6..00000000 --- a/vendor/github.com/coredns/coredns/plugin/file/secondary.go +++ /dev/null @@ -1,195 +0,0 @@ -package file - -import ( - "math/rand" - "time" - - "github.com/miekg/dns" -) - -// TransferIn retrieves the zone from the masters, parses it and sets it live. -func (z *Zone) TransferIn() error { - if len(z.TransferFrom) == 0 { - return nil - } - m := new(dns.Msg) - m.SetAxfr(z.origin) - - z1 := z.CopyWithoutApex() - var ( - Err error - tr string - ) - -Transfer: - for _, tr = range z.TransferFrom { - t := new(dns.Transfer) - c, err := t.In(m, tr) - if err != nil { - log.Errorf("Failed to setup transfer `%s' with `%q': %v", z.origin, tr, err) - Err = err - continue Transfer - } - for env := range c { - if env.Error != nil { - log.Errorf("Failed to transfer `%s' from %q: %v", z.origin, tr, env.Error) - Err = env.Error - continue Transfer - } - for _, rr := range env.RR { - if err := z1.Insert(rr); err != nil { - log.Errorf("Failed to parse transfer `%s' from: %q: %v", z.origin, tr, err) - Err = err - continue Transfer - } - } - } - Err = nil - break - } - if Err != nil { - return Err - } - - z.Tree = z1.Tree - z.Apex = z1.Apex - *z.Expired = false - log.Infof("Transferred: %s from %s", z.origin, tr) - return nil -} - -// shouldTransfer checks the primaries of zone, retrieves the SOA record, checks the current serial -// and the remote serial and will return true if the remote one is higher than the locally configured one. -func (z *Zone) shouldTransfer() (bool, error) { - c := new(dns.Client) - c.Net = "tcp" // do this query over TCP to minimize spoofing - m := new(dns.Msg) - m.SetQuestion(z.origin, dns.TypeSOA) - - var Err error - serial := -1 - -Transfer: - for _, tr := range z.TransferFrom { - Err = nil - ret, _, err := c.Exchange(m, tr) - if err != nil || ret.Rcode != dns.RcodeSuccess { - Err = err - continue - } - for _, a := range ret.Answer { - if a.Header().Rrtype == dns.TypeSOA { - serial = int(a.(*dns.SOA).Serial) - break Transfer - } - } - } - if serial == -1 { - return false, Err - } - if z.Apex.SOA == nil { - return true, Err - } - return less(z.Apex.SOA.Serial, uint32(serial)), Err -} - -// less return true of a is smaller than b when taking RFC 1982 serial arithmetic into account. -func less(a, b uint32) bool { - if a < b { - return (b - a) <= MaxSerialIncrement - } - return (a - b) > MaxSerialIncrement -} - -// Update updates the secondary zone according to its SOA. It will run for the life time of the server -// and uses the SOA parameters. Every refresh it will check for a new SOA number. If that fails (for all -// server) it wil retry every retry interval. If the zone failed to transfer before the expire, the zone -// will be marked expired. -func (z *Zone) Update() error { - // If we don't have a SOA, we don't have a zone, wait for it to appear. - for z.Apex.SOA == nil { - time.Sleep(1 * time.Second) - } - retryActive := false - -Restart: - refresh := time.Second * time.Duration(z.Apex.SOA.Refresh) - retry := time.Second * time.Duration(z.Apex.SOA.Retry) - expire := time.Second * time.Duration(z.Apex.SOA.Expire) - - refreshTicker := time.NewTicker(refresh) - retryTicker := time.NewTicker(retry) - expireTicker := time.NewTicker(expire) - - for { - select { - case <-expireTicker.C: - if !retryActive { - break - } - *z.Expired = true - - case <-retryTicker.C: - if !retryActive { - break - } - - time.Sleep(jitter(2000)) // 2s randomize - - ok, err := z.shouldTransfer() - if err != nil { - log.Warningf("Failed retry check %s", err) - continue - } - - if ok { - if err := z.TransferIn(); err != nil { - // transfer failed, leave retryActive true - break - } - retryActive = false - // transfer OK, possible new SOA, stop timers and redo - refreshTicker.Stop() - retryTicker.Stop() - expireTicker.Stop() - goto Restart - } - - case <-refreshTicker.C: - - time.Sleep(jitter(5000)) // 5s randomize - - ok, err := z.shouldTransfer() - if err != nil { - log.Warningf("Failed refresh check %s", err) - retryActive = true - continue - } - - if ok { - if err := z.TransferIn(); err != nil { - // transfer failed - retryActive = true - break - } - retryActive = false - // transfer OK, possible new SOA, stop timers and redo - refreshTicker.Stop() - retryTicker.Stop() - expireTicker.Stop() - goto Restart - } - } - } -} - -// jitter returns a random duration between [0,n) * time.Millisecond -func jitter(n int) time.Duration { - r := rand.Intn(n) - return time.Duration(r) * time.Millisecond - -} - -// MaxSerialIncrement is the maximum difference between two serial numbers. If the difference between -// two serials is greater than this number, the smaller one is considered greater. -const MaxSerialIncrement uint32 = 2147483647 diff --git a/vendor/github.com/coredns/coredns/plugin/file/secondary_test.go b/vendor/github.com/coredns/coredns/plugin/file/secondary_test.go deleted file mode 100644 index 8db8353c..00000000 --- a/vendor/github.com/coredns/coredns/plugin/file/secondary_test.go +++ /dev/null @@ -1,164 +0,0 @@ -package file - -import ( - "fmt" - "testing" - - "github.com/coredns/coredns/plugin/test" - "github.com/coredns/coredns/request" - - "github.com/miekg/dns" -) - -// TODO(miek): should test notifies as well, ie start test server (a real coredns one)... -// setup other test server that sends notify, see if CoreDNS comes calling for a zone -// tranfer - -func TestLess(t *testing.T) { - const ( - min = 0 - max = 4294967295 - low = 12345 - high = 4000000000 - ) - - if less(min, max) { - t.Fatalf("Less: should be false") - } - if !less(max, min) { - t.Fatalf("Less: should be true") - } - if !less(high, low) { - t.Fatalf("Less: should be true") - } - if !less(7, 9) { - t.Fatalf("Less; should be true") - } -} - -type soa struct { - serial uint32 -} - -func (s *soa) Handler(w dns.ResponseWriter, req *dns.Msg) { - m := new(dns.Msg) - m.SetReply(req) - switch req.Question[0].Qtype { - case dns.TypeSOA: - m.Answer = make([]dns.RR, 1) - m.Answer[0] = test.SOA(fmt.Sprintf("%s IN SOA bla. bla. %d 0 0 0 0 ", testZone, s.serial)) - w.WriteMsg(m) - case dns.TypeAXFR: - m.Answer = make([]dns.RR, 4) - m.Answer[0] = test.SOA(fmt.Sprintf("%s IN SOA bla. bla. %d 0 0 0 0 ", testZone, s.serial)) - m.Answer[1] = test.A(fmt.Sprintf("%s IN A 127.0.0.1", testZone)) - m.Answer[2] = test.A(fmt.Sprintf("%s IN A 127.0.0.1", testZone)) - m.Answer[3] = test.SOA(fmt.Sprintf("%s IN SOA bla. bla. %d 0 0 0 0 ", testZone, s.serial)) - w.WriteMsg(m) - } -} - -func (s *soa) TransferHandler(w dns.ResponseWriter, req *dns.Msg) { - m := new(dns.Msg) - m.SetReply(req) - m.Answer = make([]dns.RR, 1) - m.Answer[0] = test.SOA(fmt.Sprintf("%s IN SOA bla. bla. %d 0 0 0 0 ", testZone, s.serial)) - w.WriteMsg(m) -} - -const testZone = "secondary.miek.nl." - -func TestShouldTransfer(t *testing.T) { - soa := soa{250} - - dns.HandleFunc(testZone, soa.Handler) - defer dns.HandleRemove(testZone) - - s, addrstr, err := test.TCPServer("127.0.0.1:0") - if err != nil { - t.Fatalf("Unable to run test server: %v", err) - } - defer s.Shutdown() - - z := new(Zone) - z.origin = testZone - z.TransferFrom = []string{addrstr} - - // when we have a nil SOA (initial state) - should, err := z.shouldTransfer() - if err != nil { - t.Fatalf("Unable to run shouldTransfer: %v", err) - } - if !should { - t.Fatalf("ShouldTransfer should return true for serial: %d", soa.serial) - } - // Serial smaller - z.Apex.SOA = test.SOA(fmt.Sprintf("%s IN SOA bla. bla. %d 0 0 0 0 ", testZone, soa.serial-1)) - should, err = z.shouldTransfer() - if err != nil { - t.Fatalf("Unable to run shouldTransfer: %v", err) - } - if !should { - t.Fatalf("ShouldTransfer should return true for serial: %q", soa.serial-1) - } - // Serial equal - z.Apex.SOA = test.SOA(fmt.Sprintf("%s IN SOA bla. bla. %d 0 0 0 0 ", testZone, soa.serial)) - should, err = z.shouldTransfer() - if err != nil { - t.Fatalf("Unable to run shouldTransfer: %v", err) - } - if should { - t.Fatalf("ShouldTransfer should return false for serial: %d", soa.serial) - } -} - -func TestTransferIn(t *testing.T) { - soa := soa{250} - - dns.HandleFunc(testZone, soa.Handler) - defer dns.HandleRemove(testZone) - - s, addrstr, err := test.TCPServer("127.0.0.1:0") - if err != nil { - t.Fatalf("Unable to run test server: %v", err) - } - defer s.Shutdown() - - z := new(Zone) - z.Expired = new(bool) - z.origin = testZone - z.TransferFrom = []string{addrstr} - - err = z.TransferIn() - if err != nil { - t.Fatalf("Unable to run TransferIn: %v", err) - } - if z.Apex.SOA.String() != fmt.Sprintf("%s 3600 IN SOA bla. bla. 250 0 0 0 0", testZone) { - t.Fatalf("Unknown SOA transferred") - } -} - -func TestIsNotify(t *testing.T) { - z := new(Zone) - z.Expired = new(bool) - z.origin = testZone - state := newRequest(testZone, dns.TypeSOA) - // need to set opcode - state.Req.Opcode = dns.OpcodeNotify - - z.TransferFrom = []string{"10.240.0.1:53"} // IP from from testing/responseWriter - if !z.isNotify(state) { - t.Fatal("Should have been valid notify") - } - z.TransferFrom = []string{"10.240.0.2:53"} - if z.isNotify(state) { - t.Fatal("Should have been invalid notify") - } -} - -func newRequest(zone string, qtype uint16) request.Request { - m := new(dns.Msg) - m.SetQuestion("example.com.", dns.TypeA) - m.SetEdns0(4097, true) - return request.Request{W: &test.ResponseWriter{}, Req: m} -} diff --git a/vendor/github.com/coredns/coredns/plugin/file/setup.go b/vendor/github.com/coredns/coredns/plugin/file/setup.go deleted file mode 100644 index 3f8d1969..00000000 --- a/vendor/github.com/coredns/coredns/plugin/file/setup.go +++ /dev/null @@ -1,132 +0,0 @@ -package file - -import ( - "os" - "path" - - "github.com/coredns/coredns/core/dnsserver" - "github.com/coredns/coredns/plugin" - "github.com/coredns/coredns/plugin/pkg/parse" - "github.com/coredns/coredns/plugin/pkg/upstream" - - "github.com/mholt/caddy" -) - -func init() { - caddy.RegisterPlugin("file", caddy.Plugin{ - ServerType: "dns", - Action: setup, - }) -} - -func setup(c *caddy.Controller) error { - zones, err := fileParse(c) - if err != nil { - return plugin.Error("file", err) - } - - // Add startup functions to notify the master(s). - for _, n := range zones.Names { - z := zones.Z[n] - c.OnStartup(func() error { - z.StartupOnce.Do(func() { - if len(z.TransferTo) > 0 { - z.Notify() - } - z.Reload() - }) - return nil - }) - } - for _, n := range zones.Names { - z := zones.Z[n] - c.OnShutdown(z.OnShutdown) - } - - dnsserver.GetConfig(c).AddPlugin(func(next plugin.Handler) plugin.Handler { - return File{Next: next, Zones: zones} - }) - - return nil -} - -func fileParse(c *caddy.Controller) (Zones, error) { - z := make(map[string]*Zone) - names := []string{} - origins := []string{} - - config := dnsserver.GetConfig(c) - - for c.Next() { - // file db.file [zones...] - if !c.NextArg() { - return Zones{}, c.ArgErr() - } - fileName := c.Val() - - origins = make([]string, len(c.ServerBlockKeys)) - copy(origins, c.ServerBlockKeys) - args := c.RemainingArgs() - if len(args) > 0 { - origins = args - } - - if !path.IsAbs(fileName) && config.Root != "" { - fileName = path.Join(config.Root, fileName) - } - - reader, err := os.Open(fileName) - if err != nil { - // bail out - return Zones{}, err - } - - for i := range origins { - origins[i] = plugin.Host(origins[i]).Normalize() - zone, err := Parse(reader, origins[i], fileName, 0) - if err == nil { - z[origins[i]] = zone - } else { - return Zones{}, err - } - names = append(names, origins[i]) - } - - noReload := false - upstr := upstream.Upstream{} - t := []string{} - var e error - - for c.NextBlock() { - switch c.Val() { - case "transfer": - t, _, e = parse.Transfer(c, false) - if e != nil { - return Zones{}, e - } - - case "no_reload": - noReload = true - - case "upstream": - args := c.RemainingArgs() - upstr, err = upstream.New(args) - if err != nil { - return Zones{}, err - } - - default: - return Zones{}, c.Errf("unknown property '%s'", c.Val()) - } - - for _, origin := range origins { - if t != nil { - z[origin].TransferTo = append(z[origin].TransferTo, t...) - } - z[origin].NoReload = noReload - z[origin].Upstream = upstr - } - } - } - return Zones{Z: z, Names: names}, nil -} diff --git a/vendor/github.com/coredns/coredns/plugin/file/setup_test.go b/vendor/github.com/coredns/coredns/plugin/file/setup_test.go deleted file mode 100644 index 39cadaaf..00000000 --- a/vendor/github.com/coredns/coredns/plugin/file/setup_test.go +++ /dev/null @@ -1,91 +0,0 @@ -package file - -import ( - "testing" - - "github.com/coredns/coredns/plugin/test" - - "github.com/mholt/caddy" -) - -func TestFileParse(t *testing.T) { - zoneFileName1, rm, err := test.TempFile(".", dbMiekNL) - if err != nil { - t.Fatal(err) - } - defer rm() - - zoneFileName2, rm, err := test.TempFile(".", dbDnssexNLSigned) - if err != nil { - t.Fatal(err) - } - defer rm() - - tests := []struct { - inputFileRules string - shouldErr bool - expectedZones Zones - }{ - { - `file ` + zoneFileName1 + ` miek.nl { - transfer from 127.0.0.1 - }`, - true, - Zones{}, - }, - { - `file`, - true, - Zones{}, - }, - { - `file ` + zoneFileName1 + ` miek.nl.`, - false, - Zones{Names: []string{"miek.nl."}}, - }, - { - `file ` + zoneFileName2 + ` dnssex.nl.`, - false, - Zones{Names: []string{"dnssex.nl."}}, - }, - { - `file ` + zoneFileName2 + ` 10.0.0.0/8`, - false, - Zones{Names: []string{"10.in-addr.arpa."}}, - }, - { - `file ` + zoneFileName1 + ` example.net. { - upstream a - }`, - true, - Zones{Names: []string{}}, - }, - { - `file ` + zoneFileName1 + ` example.net. { - no_rebloat - }`, - true, - Zones{Names: []string{}}, - }, - } - - for i, test := range tests { - c := caddy.NewTestController("dns", test.inputFileRules) - actualZones, err := fileParse(c) - - if err == nil && test.shouldErr { - t.Fatalf("Test %d expected errors, but got no error", i) - } else if err != nil && !test.shouldErr { - t.Fatalf("Test %d expected no errors, but got '%v'", i, err) - } else { - if len(actualZones.Names) != len(test.expectedZones.Names) { - t.Fatalf("Test %d expected %v, got %v", i, test.expectedZones.Names, actualZones.Names) - } - for j, name := range test.expectedZones.Names { - if actualZones.Names[j] != name { - t.Fatalf("Test %d expected %v for %d th zone, got %v", i, name, j, actualZones.Names[j]) - } - } - } - } -} diff --git a/vendor/github.com/coredns/coredns/plugin/file/shutdown.go b/vendor/github.com/coredns/coredns/plugin/file/shutdown.go deleted file mode 100644 index cecd76e9..00000000 --- a/vendor/github.com/coredns/coredns/plugin/file/shutdown.go +++ /dev/null @@ -1,9 +0,0 @@ -package file - -// OnShutdown shuts down any running go-routines for this zone. -func (z *Zone) OnShutdown() error { - if !z.NoReload { - z.reloadShutdown <- true - } - return nil -} diff --git a/vendor/github.com/coredns/coredns/plugin/file/tree/all.go b/vendor/github.com/coredns/coredns/plugin/file/tree/all.go deleted file mode 100644 index fd806365..00000000 --- a/vendor/github.com/coredns/coredns/plugin/file/tree/all.go +++ /dev/null @@ -1,48 +0,0 @@ -package tree - -// All traverses tree and returns all elements -func (t *Tree) All() []*Elem { - if t.Root == nil { - return nil - } - found := t.Root.all(nil) - return found -} - -func (n *Node) all(found []*Elem) []*Elem { - if n.Left != nil { - found = n.Left.all(found) - } - found = append(found, n.Elem) - if n.Right != nil { - found = n.Right.all(found) - } - return found -} - -// Do performs fn on all values stored in the tree. A boolean is returned indicating whether the -// Do traversal was interrupted by an Operation returning true. If fn alters stored values' sort -// relationships, future tree operation behaviors are undefined. -func (t *Tree) Do(fn func(e *Elem) bool) bool { - if t.Root == nil { - return false - } - return t.Root.do(fn) -} - -func (n *Node) do(fn func(e *Elem) bool) (done bool) { - if n.Left != nil { - done = n.Left.do(fn) - if done { - return - } - } - done = fn(n.Elem) - if done { - return - } - if n.Right != nil { - done = n.Right.do(fn) - } - return -} diff --git a/vendor/github.com/coredns/coredns/plugin/file/tree/elem.go b/vendor/github.com/coredns/coredns/plugin/file/tree/elem.go deleted file mode 100644 index 6317cc91..00000000 --- a/vendor/github.com/coredns/coredns/plugin/file/tree/elem.go +++ /dev/null @@ -1,136 +0,0 @@ -package tree - -import "github.com/miekg/dns" - -// Elem is an element in the tree. -type Elem struct { - m map[uint16][]dns.RR - name string // owner name -} - -// newElem returns a new elem. -func newElem(rr dns.RR) *Elem { - e := Elem{m: make(map[uint16][]dns.RR)} - e.m[rr.Header().Rrtype] = []dns.RR{rr} - return &e -} - -// Types returns the RRs with type qtype from e. If qname is given (only the -// first one is used), the RR are copied and the owner is replaced with qname[0]. -func (e *Elem) Types(qtype uint16, qname ...string) []dns.RR { - rrs := e.m[qtype] - - if rrs != nil && len(qname) > 0 { - copied := make([]dns.RR, len(rrs)) - for i := range rrs { - copied[i] = dns.Copy(rrs[i]) - copied[i].Header().Name = qname[0] - } - return copied - } - return rrs -} - -// All returns all RRs from e, regardless of type. -func (e *Elem) All() []dns.RR { - list := []dns.RR{} - for _, rrs := range e.m { - list = append(list, rrs...) - } - return list -} - -// Name returns the name for this node. -func (e *Elem) Name() string { - if e.name != "" { - return e.name - } - for _, rrs := range e.m { - e.name = rrs[0].Header().Name - return e.name - } - return "" -} - -// Empty returns true is e does not contain any RRs, i.e. is an -// empty-non-terminal. -func (e *Elem) Empty() bool { - return len(e.m) == 0 -} - -// Insert inserts rr into e. If rr is equal to existing rrs this is a noop. -func (e *Elem) Insert(rr dns.RR) { - t := rr.Header().Rrtype - if e.m == nil { - e.m = make(map[uint16][]dns.RR) - e.m[t] = []dns.RR{rr} - return - } - rrs, ok := e.m[t] - if !ok { - e.m[t] = []dns.RR{rr} - return - } - for _, er := range rrs { - if equalRdata(er, rr) { - return - } - } - - rrs = append(rrs, rr) - e.m[t] = rrs -} - -// Delete removes rr from e. When e is empty after the removal the returned bool is true. -func (e *Elem) Delete(rr dns.RR) (empty bool) { - if e.m == nil { - return true - } - - t := rr.Header().Rrtype - rrs, ok := e.m[t] - if !ok { - return - } - - for i, er := range rrs { - if equalRdata(er, rr) { - rrs = removeFromSlice(rrs, i) - e.m[t] = rrs - empty = len(rrs) == 0 - if empty { - delete(e.m, t) - } - return - } - } - return -} - -// Less is a tree helper function that calls less. -func Less(a *Elem, name string) int { return less(name, a.Name()) } - -// Assuming the same type and name this will check if the rdata is equal as well. -func equalRdata(a, b dns.RR) bool { - switch x := a.(type) { - // TODO(miek): more types, i.e. all types. + tests for this. - case *dns.A: - return x.A.Equal(b.(*dns.A).A) - case *dns.AAAA: - return x.AAAA.Equal(b.(*dns.AAAA).AAAA) - case *dns.MX: - if x.Mx == b.(*dns.MX).Mx && x.Preference == b.(*dns.MX).Preference { - return true - } - } - return false -} - -// removeFromSlice removes index i from the slice. -func removeFromSlice(rrs []dns.RR, i int) []dns.RR { - if i >= len(rrs) { - return rrs - } - rrs = append(rrs[:i], rrs[i+1:]...) - return rrs -} diff --git a/vendor/github.com/coredns/coredns/plugin/file/tree/less.go b/vendor/github.com/coredns/coredns/plugin/file/tree/less.go deleted file mode 100644 index 3b834008..00000000 --- a/vendor/github.com/coredns/coredns/plugin/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') } diff --git a/vendor/github.com/coredns/coredns/plugin/file/tree/less_test.go b/vendor/github.com/coredns/coredns/plugin/file/tree/less_test.go deleted file mode 100644 index ed021b66..00000000 --- a/vendor/github.com/coredns/coredns/plugin/file/tree/less_test.go +++ /dev/null @@ -1,81 +0,0 @@ -package tree - -import ( - "sort" - "strings" - "testing" -) - -type set []string - -func (p set) Len() int { return len(p) } -func (p set) Swap(i, j int) { p[i], p[j] = p[j], p[i] } -func (p set) Less(i, j int) bool { d := less(p[i], p[j]); return d <= 0 } - -func TestLess(t *testing.T) { - tests := []struct { - in []string - out []string - }{ - { - []string{"aaa.powerdns.de", "bbb.powerdns.net.", "xxx.powerdns.com."}, - []string{"xxx.powerdns.com.", "aaa.powerdns.de", "bbb.powerdns.net."}, - }, - { - []string{"aaa.POWERDNS.de", "bbb.PoweRdnS.net.", "xxx.powerdns.com."}, - []string{"xxx.powerdns.com.", "aaa.POWERDNS.de", "bbb.PoweRdnS.net."}, - }, - { - []string{"aaa.aaaa.aa.", "aa.aaa.a.", "bbb.bbbb.bb."}, - []string{"aa.aaa.a.", "aaa.aaaa.aa.", "bbb.bbbb.bb."}, - }, - { - []string{"aaaaa.", "aaa.", "bbb."}, - []string{"aaa.", "aaaaa.", "bbb."}, - }, - { - []string{"a.a.a.a.", "a.a.", "a.a.a."}, - []string{"a.a.", "a.a.a.", "a.a.a.a."}, - }, - { - []string{"example.", "z.example.", "a.example."}, - []string{"example.", "a.example.", "z.example."}, - }, - { - []string{"a.example.", "Z.a.example.", "z.example.", "yljkjljk.a.example.", "\\001.z.example.", "example.", "*.z.example.", "\\200.z.example.", "zABC.a.EXAMPLE."}, - []string{"example.", "a.example.", "yljkjljk.a.example.", "Z.a.example.", "zABC.a.EXAMPLE.", "z.example.", "\\001.z.example.", "*.z.example.", "\\200.z.example."}, - }, - { - // RFC3034 example. - []string{"a.example.", "Z.a.example.", "z.example.", "yljkjljk.a.example.", "example.", "*.z.example.", "zABC.a.EXAMPLE."}, - []string{"example.", "a.example.", "yljkjljk.a.example.", "Z.a.example.", "zABC.a.EXAMPLE.", "z.example.", "*.z.example."}, - }, - } - -Tests: - for j, test := range tests { - // Need to lowercase these example as the Less function does lowercase for us anymore. - for i, b := range test.in { - test.in[i] = strings.ToLower(b) - } - for i, b := range test.out { - test.out[i] = strings.ToLower(b) - } - - sort.Sort(set(test.in)) - for i := 0; i < len(test.in); i++ { - if test.in[i] != test.out[i] { - t.Errorf("Test %d: expected %s, got %s\n", j, test.out[i], test.in[i]) - n := "" - for k, in := range test.in { - if k+1 == len(test.in) { - n = "\n" - } - t.Logf("%s <-> %s\n%s", in, test.out[k], n) - } - continue Tests - } - - } - } -} diff --git a/vendor/github.com/coredns/coredns/plugin/file/tree/print.go b/vendor/github.com/coredns/coredns/plugin/file/tree/print.go deleted file mode 100644 index bd86ef69..00000000 --- a/vendor/github.com/coredns/coredns/plugin/file/tree/print.go +++ /dev/null @@ -1,62 +0,0 @@ -package tree - -import "fmt" - -// Print prints a Tree. Main use is to aid in debugging. -func (t *Tree) Print() { - if t.Root == nil { - fmt.Println("") - } - t.Root.print() -} - -func (n *Node) print() { - q := newQueue() - q.push(n) - - nodesInCurrentLevel := 1 - nodesInNextLevel := 0 - - for !q.empty() { - do := q.pop() - nodesInCurrentLevel-- - - if do != nil { - fmt.Print(do.Elem.Name(), " ") - q.push(do.Left) - q.push(do.Right) - nodesInNextLevel += 2 - } - if nodesInCurrentLevel == 0 { - fmt.Println() - } - nodesInCurrentLevel = nodesInNextLevel - nodesInNextLevel = 0 - } - fmt.Println() -} - -type queue []*Node - -// newQueue returns a new queue. -func newQueue() queue { - q := queue([]*Node{}) - return q -} - -// push pushes n to the end of the queue. -func (q *queue) push(n *Node) { - *q = append(*q, n) -} - -// pop pops the first element off the queue. -func (q *queue) pop() *Node { - n := (*q)[0] - *q = (*q)[1:] - return n -} - -// empty returns true when the queue contains zero nodes. -func (q *queue) empty() bool { - return len(*q) == 0 -} diff --git a/vendor/github.com/coredns/coredns/plugin/file/tree/tree.go b/vendor/github.com/coredns/coredns/plugin/file/tree/tree.go deleted file mode 100644 index ed33c09a..00000000 --- a/vendor/github.com/coredns/coredns/plugin/file/tree/tree.go +++ /dev/null @@ -1,455 +0,0 @@ -// Copyright ©2012 The bíogo Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found at the end of this file. - -// Package tree implements Left-Leaning Red Black trees as described by Robert Sedgewick. -// -// More details relating to the implementation are available at the following locations: -// -// http://www.cs.princeton.edu/~rs/talks/LLRB/LLRB.pdf -// http://www.cs.princeton.edu/~rs/talks/LLRB/Java/RedBlackBST.java -// http://www.teachsolaisgames.com/articles/balanced_left_leaning.html -// -// Heavily modified by Miek Gieben for use in DNS zones. -package tree - -import "github.com/miekg/dns" - -const ( - td234 = iota - bu23 -) - -// Operation mode of the LLRB tree. -const mode = bu23 - -func init() { - if mode != td234 && mode != bu23 { - panic("tree: unknown mode") - } -} - -// A Color represents the color of a Node. -type Color bool - -const ( - // Red as false give us the defined behaviour that new nodes are red. Although this - // is incorrect for the root node, that is resolved on the first insertion. - red Color = false - black Color = true -) - -// A Node represents a node in the LLRB tree. -type Node struct { - Elem *Elem - Left, Right *Node - Color Color -} - -// A Tree manages the root node of an LLRB tree. Public methods are exposed through this type. -type Tree struct { - Root *Node // Root node of the tree. - Count int // Number of elements stored. -} - -// Helper methods - -// color returns the effect color of a Node. A nil node returns black. -func (n *Node) color() Color { - if n == nil { - return black - } - return n.Color -} - -// (a,c)b -rotL-> ((a,)b,)c -func (n *Node) rotateLeft() (root *Node) { - // Assumes: n has two children. - root = n.Right - n.Right = root.Left - root.Left = n - root.Color = n.Color - n.Color = red - return -} - -// (a,c)b -rotR-> (,(,c)b)a -func (n *Node) rotateRight() (root *Node) { - // Assumes: n has two children. - root = n.Left - n.Left = root.Right - root.Right = n - root.Color = n.Color - n.Color = red - return -} - -// (aR,cR)bB -flipC-> (aB,cB)bR | (aB,cB)bR -flipC-> (aR,cR)bB -func (n *Node) flipColors() { - // Assumes: n has two children. - n.Color = !n.Color - n.Left.Color = !n.Left.Color - n.Right.Color = !n.Right.Color -} - -// fixUp ensures that black link balance is correct, that red nodes lean left, -// and that 4 nodes are split in the case of BU23 and properly balanced in TD234. -func (n *Node) fixUp() *Node { - if n.Right.color() == red { - if mode == td234 && n.Right.Left.color() == red { - n.Right = n.Right.rotateRight() - } - n = n.rotateLeft() - } - if n.Left.color() == red && n.Left.Left.color() == red { - n = n.rotateRight() - } - if mode == bu23 && n.Left.color() == red && n.Right.color() == red { - n.flipColors() - } - return n -} - -func (n *Node) moveRedLeft() *Node { - n.flipColors() - if n.Right.Left.color() == red { - n.Right = n.Right.rotateRight() - n = n.rotateLeft() - n.flipColors() - if mode == td234 && n.Right.Right.color() == red { - n.Right = n.Right.rotateLeft() - } - } - return n -} - -func (n *Node) moveRedRight() *Node { - n.flipColors() - if n.Left.Left.color() == red { - n = n.rotateRight() - n.flipColors() - } - return n -} - -// Len returns the number of elements stored in the Tree. -func (t *Tree) Len() int { - return t.Count -} - -// Search returns the first match of qname in the Tree. -func (t *Tree) Search(qname string) (*Elem, bool) { - if t.Root == nil { - return nil, false - } - n, res := t.Root.search(qname) - if n == nil { - return nil, res - } - return n.Elem, res -} - -// search searches the tree for qname and type. -func (n *Node) search(qname string) (*Node, bool) { - for n != nil { - switch c := Less(n.Elem, qname); { - case c == 0: - return n, true - case c < 0: - n = n.Left - default: - n = n.Right - } - } - - return n, false -} - -// Insert inserts rr into the Tree at the first match found -// with e or when a nil node is reached. -func (t *Tree) Insert(rr dns.RR) { - var d int - t.Root, d = t.Root.insert(rr) - t.Count += d - t.Root.Color = black -} - -// insert inserts rr in to the tree. -func (n *Node) insert(rr dns.RR) (root *Node, d int) { - if n == nil { - return &Node{Elem: newElem(rr)}, 1 - } else if n.Elem == nil { - n.Elem = newElem(rr) - return n, 1 - } - - if mode == td234 { - if n.Left.color() == red && n.Right.color() == red { - n.flipColors() - } - } - - switch c := Less(n.Elem, rr.Header().Name); { - case c == 0: - n.Elem.Insert(rr) - case c < 0: - n.Left, d = n.Left.insert(rr) - default: - n.Right, d = n.Right.insert(rr) - } - - if n.Right.color() == red && n.Left.color() == black { - n = n.rotateLeft() - } - if n.Left.color() == red && n.Left.Left.color() == red { - n = n.rotateRight() - } - - if mode == bu23 { - if n.Left.color() == red && n.Right.color() == red { - n.flipColors() - } - } - - root = n - - return -} - -// DeleteMin deletes the node with the minimum value in the tree. -func (t *Tree) DeleteMin() { - if t.Root == nil { - return - } - var d int - t.Root, d = t.Root.deleteMin() - t.Count += d - if t.Root == nil { - return - } - t.Root.Color = black -} - -func (n *Node) deleteMin() (root *Node, d int) { - if n.Left == nil { - return nil, -1 - } - if n.Left.color() == black && n.Left.Left.color() == black { - n = n.moveRedLeft() - } - n.Left, d = n.Left.deleteMin() - - root = n.fixUp() - - return -} - -// DeleteMax deletes the node with the maximum value in the tree. -func (t *Tree) DeleteMax() { - if t.Root == nil { - return - } - var d int - t.Root, d = t.Root.deleteMax() - t.Count += d - if t.Root == nil { - return - } - t.Root.Color = black -} - -func (n *Node) deleteMax() (root *Node, d int) { - if n.Left != nil && n.Left.color() == red { - n = n.rotateRight() - } - if n.Right == nil { - return nil, -1 - } - if n.Right.color() == black && n.Right.Left.color() == black { - n = n.moveRedRight() - } - n.Right, d = n.Right.deleteMax() - - root = n.fixUp() - - return -} - -// Delete removes rr from the tree, is the node turns empty, that node is deleted with DeleteNode. -func (t *Tree) Delete(rr dns.RR) { - if t.Root == nil { - return - } - - el, _ := t.Search(rr.Header().Name) - if el == nil { - t.deleteNode(rr) - return - } - // Delete from this element. - empty := el.Delete(rr) - if empty { - t.deleteNode(rr) - return - } -} - -// DeleteNode deletes the node that matches rr according to Less(). -func (t *Tree) deleteNode(rr dns.RR) { - if t.Root == nil { - return - } - var d int - t.Root, d = t.Root.delete(rr) - t.Count += d - if t.Root == nil { - return - } - t.Root.Color = black -} - -func (n *Node) delete(rr dns.RR) (root *Node, d int) { - if Less(n.Elem, rr.Header().Name) < 0 { - if n.Left != nil { - if n.Left.color() == black && n.Left.Left.color() == black { - n = n.moveRedLeft() - } - n.Left, d = n.Left.delete(rr) - } - } else { - if n.Left.color() == red { - n = n.rotateRight() - } - if n.Right == nil && Less(n.Elem, rr.Header().Name) == 0 { - return nil, -1 - } - if n.Right != nil { - if n.Right.color() == black && n.Right.Left.color() == black { - n = n.moveRedRight() - } - if Less(n.Elem, rr.Header().Name) == 0 { - n.Elem = n.Right.min().Elem - n.Right, d = n.Right.deleteMin() - } else { - n.Right, d = n.Right.delete(rr) - } - } - } - - root = n.fixUp() - return -} - -// Min returns the minimum value stored in the tree. -func (t *Tree) Min() *Elem { - if t.Root == nil { - return nil - } - return t.Root.min().Elem -} - -func (n *Node) min() *Node { - for ; n.Left != nil; n = n.Left { - } - return n -} - -// Max returns the maximum value stored in the tree. -func (t *Tree) Max() *Elem { - if t.Root == nil { - return nil - } - return t.Root.max().Elem -} - -func (n *Node) max() *Node { - for ; n.Right != nil; n = n.Right { - } - return n -} - -// Prev returns the greatest value equal to or less than the qname according to Less(). -func (t *Tree) Prev(qname string) (*Elem, bool) { - if t.Root == nil { - return nil, false - } - - n := t.Root.floor(qname) - if n == nil { - return nil, false - } - return n.Elem, true -} - -func (n *Node) floor(qname string) *Node { - if n == nil { - return nil - } - switch c := Less(n.Elem, qname); { - case c == 0: - return n - case c <= 0: - return n.Left.floor(qname) - default: - if r := n.Right.floor(qname); r != nil { - return r - } - } - return n -} - -// Next returns the smallest value equal to or greater than the qname according to Less(). -func (t *Tree) Next(qname string) (*Elem, bool) { - if t.Root == nil { - return nil, false - } - n := t.Root.ceil(qname) - if n == nil { - return nil, false - } - return n.Elem, true -} - -func (n *Node) ceil(qname string) *Node { - if n == nil { - return nil - } - switch c := Less(n.Elem, qname); { - case c == 0: - return n - case c > 0: - return n.Right.ceil(qname) - default: - if l := n.Left.ceil(qname); l != nil { - return l - } - } - return n -} - -/* -Copyright ©2012 The bíogo Authors. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - -* Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. -* Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. -* Neither the name of the bíogo project nor the names of its authors and - contributors may be used to endorse or promote products derived from this - software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ diff --git a/vendor/github.com/coredns/coredns/plugin/file/wildcard.go b/vendor/github.com/coredns/coredns/plugin/file/wildcard.go deleted file mode 100644 index 9526cb53..00000000 --- a/vendor/github.com/coredns/coredns/plugin/file/wildcard.go +++ /dev/null @@ -1,13 +0,0 @@ -package file - -import "github.com/miekg/dns" - -// replaceWithWildcard replaces the left most label with '*'. -func replaceWithAsteriskLabel(qname string) (wildcard string) { - i, shot := dns.NextLabel(qname, 0) - if shot { - return "" - } - - return "*." + qname[i:] -} diff --git a/vendor/github.com/coredns/coredns/plugin/file/wildcard_test.go b/vendor/github.com/coredns/coredns/plugin/file/wildcard_test.go deleted file mode 100644 index 8f73d154..00000000 --- a/vendor/github.com/coredns/coredns/plugin/file/wildcard_test.go +++ /dev/null @@ -1,292 +0,0 @@ -package file - -import ( - "context" - "strings" - "testing" - - "github.com/coredns/coredns/plugin/pkg/dnstest" - "github.com/coredns/coredns/plugin/test" - - "github.com/miekg/dns" -) - -var wildcardTestCases = []test.Case{ - { - Qname: "wild.dnssex.nl.", Qtype: dns.TypeTXT, - Answer: []dns.RR{ - test.TXT(`wild.dnssex.nl. 1800 IN TXT "Doing It Safe Is Better"`), - }, - Ns: dnssexAuth[:len(dnssexAuth)-1], // remove RRSIG on the end - }, - { - Qname: "a.wild.dnssex.nl.", Qtype: dns.TypeTXT, - Answer: []dns.RR{ - test.TXT(`a.wild.dnssex.nl. 1800 IN TXT "Doing It Safe Is Better"`), - }, - Ns: dnssexAuth[:len(dnssexAuth)-1], // remove RRSIG on the end - }, - { - Qname: "wild.dnssex.nl.", Qtype: dns.TypeTXT, Do: true, - Answer: []dns.RR{ - test.RRSIG("wild.dnssex.nl. 1800 IN RRSIG TXT 8 2 1800 20160428190224 20160329190224 14460 dnssex.nl. FUZSTyvZfeuuOpCm"), - test.TXT(`wild.dnssex.nl. 1800 IN TXT "Doing It Safe Is Better"`), - }, - Ns: append([]dns.RR{ - test.NSEC("a.dnssex.nl. 14400 IN NSEC www.dnssex.nl. A AAAA RRSIG NSEC"), - test.RRSIG("a.dnssex.nl. 14400 IN RRSIG NSEC 8 3 14400 20160428190224 20160329190224 14460 dnssex.nl. S+UMs2ySgRaaRY"), - }, dnssexAuth...), - Extra: []dns.RR{test.OPT(4096, true)}, - }, - { - Qname: "a.wild.dnssex.nl.", Qtype: dns.TypeTXT, Do: true, - Answer: []dns.RR{ - test.RRSIG("a.wild.dnssex.nl. 1800 IN RRSIG TXT 8 2 1800 20160428190224 20160329190224 14460 dnssex.nl. FUZSTyvZfeuuOpCm"), - test.TXT(`a.wild.dnssex.nl. 1800 IN TXT "Doing It Safe Is Better"`), - }, - Ns: append([]dns.RR{ - test.NSEC("a.dnssex.nl. 14400 IN NSEC www.dnssex.nl. A AAAA RRSIG NSEC"), - test.RRSIG("a.dnssex.nl. 14400 IN RRSIG NSEC 8 3 14400 20160428190224 20160329190224 14460 dnssex.nl. S+UMs2ySgRaaRY"), - }, dnssexAuth...), - Extra: []dns.RR{test.OPT(4096, true)}, - }, - // nodata responses - { - Qname: "wild.dnssex.nl.", Qtype: dns.TypeSRV, - Ns: []dns.RR{ - test.SOA(`dnssex.nl. 1800 IN SOA linode.atoom.net. miek.miek.nl. 1459281744 14400 3600 604800 14400`), - }, - }, - { - Qname: "wild.dnssex.nl.", Qtype: dns.TypeSRV, Do: true, - Ns: []dns.RR{ - // TODO(miek): needs closest encloser proof as well? This is the wrong answer - test.NSEC(`*.dnssex.nl. 14400 IN NSEC a.dnssex.nl. TXT RRSIG NSEC`), - test.RRSIG(`*.dnssex.nl. 14400 IN RRSIG NSEC 8 2 14400 20160428190224 20160329190224 14460 dnssex.nl. os6INm6q2eXknD5z8TaaDOV+Ge/Ko+2dXnKP+J1fqJzafXJVH1F0nDrcXmMlR6jlBHA=`), - test.RRSIG(`dnssex.nl. 1800 IN RRSIG SOA 8 2 1800 20160428190224 20160329190224 14460 dnssex.nl. CA/Y3m9hCOiKC/8ieSOv8SeP964Bq++lyH8BZJcTaabAsERs4xj5PRtcxicwQXZiF8fYUCpROlUS0YR8Cdw=`), - test.SOA(`dnssex.nl. 1800 IN SOA linode.atoom.net. miek.miek.nl. 1459281744 14400 3600 604800 14400`), - }, - Extra: []dns.RR{test.OPT(4096, true)}, - }, -} - -var dnssexAuth = []dns.RR{ - test.NS("dnssex.nl. 1800 IN NS linode.atoom.net."), - test.NS("dnssex.nl. 1800 IN NS ns-ext.nlnetlabs.nl."), - test.NS("dnssex.nl. 1800 IN NS omval.tednet.nl."), - test.RRSIG("dnssex.nl. 1800 IN RRSIG NS 8 2 1800 20160428190224 20160329190224 14460 dnssex.nl. dLIeEvP86jj5ndkcLzhgvWixTABjWAGRTGQsPsVDFXsGMf9TGGC9FEomgkCVeNC0="), -} - -func TestLookupWildcard(t *testing.T) { - zone, err := Parse(strings.NewReader(dbDnssexNLSigned), testzone1, "stdin", 0) - if err != nil { - t.Fatalf("Expect no error when reading zone, got %q", err) - } - - fm := File{Next: test.ErrorHandler(), Zones: Zones{Z: map[string]*Zone{testzone1: zone}, Names: []string{testzone1}}} - ctx := context.TODO() - - for _, tc := range wildcardTestCases { - m := tc.Msg() - - rec := dnstest.NewRecorder(&test.ResponseWriter{}) - _, err := fm.ServeDNS(ctx, rec, m) - if err != nil { - t.Errorf("Expected no error, got %v\n", err) - return - } - - resp := rec.Msg - test.SortAndCheck(t, resp, tc) - } -} - -var wildcardDoubleTestCases = []test.Case{ - { - Qname: "wild.w.example.org.", Qtype: dns.TypeTXT, - Answer: []dns.RR{ - test.TXT(`wild.w.example.org. IN TXT "Wildcard"`), - }, - Ns: exampleAuth, - }, - { - Qname: "wild.c.example.org.", Qtype: dns.TypeTXT, - Answer: []dns.RR{ - test.TXT(`wild.c.example.org. IN TXT "c Wildcard"`), - }, - Ns: exampleAuth, - }, - { - Qname: "wild.d.example.org.", Qtype: dns.TypeTXT, - Answer: []dns.RR{ - test.TXT(`alias.example.org. IN TXT "Wildcard CNAME expansion"`), - test.CNAME(`wild.d.example.org. IN CNAME alias.example.org`), - }, - Ns: exampleAuth, - }, - { - Qname: "alias.example.org.", Qtype: dns.TypeTXT, - Answer: []dns.RR{ - test.TXT(`alias.example.org. IN TXT "Wildcard CNAME expansion"`), - }, - Ns: exampleAuth, - }, -} - -var exampleAuth = []dns.RR{ - test.NS("example.org. 3600 IN NS a.iana-servers.net."), - test.NS("example.org. 3600 IN NS b.iana-servers.net."), -} - -func TestLookupDoubleWildcard(t *testing.T) { - zone, err := Parse(strings.NewReader(exampleOrg), "example.org.", "stdin", 0) - if err != nil { - t.Fatalf("Expect no error when reading zone, got %q", err) - } - - fm := File{Next: test.ErrorHandler(), Zones: Zones{Z: map[string]*Zone{"example.org.": zone}, Names: []string{"example.org."}}} - ctx := context.TODO() - - for _, tc := range wildcardDoubleTestCases { - m := tc.Msg() - - rec := dnstest.NewRecorder(&test.ResponseWriter{}) - _, err := fm.ServeDNS(ctx, rec, m) - if err != nil { - t.Errorf("Expected no error, got %v\n", err) - return - } - - resp := rec.Msg - test.SortAndCheck(t, resp, tc) - } -} - -func TestReplaceWithAsteriskLabel(t *testing.T) { - tests := []struct { - in, out string - }{ - {".", ""}, - {"miek.nl.", "*.nl."}, - {"www.miek.nl.", "*.miek.nl."}, - } - - for _, tc := range tests { - got := replaceWithAsteriskLabel(tc.in) - if got != tc.out { - t.Errorf("Expected to be %s, got %s", tc.out, got) - } - } -} - -var apexWildcardTestCases = []test.Case{ - { - Qname: "foo.example.org.", Qtype: dns.TypeA, - Answer: []dns.RR{test.A(`foo.example.org. 3600 IN A 127.0.0.54`)}, - Ns: []dns.RR{test.NS(`example.org. 3600 IN NS b.iana-servers.net.`)}, - }, - { - Qname: "bar.example.org.", Qtype: dns.TypeA, - Answer: []dns.RR{test.A(`bar.example.org. 3600 IN A 127.0.0.53`)}, - Ns: []dns.RR{test.NS(`example.org. 3600 IN NS b.iana-servers.net.`)}, - }, -} - -func TestLookupApexWildcard(t *testing.T) { - const name = "example.org." - zone, err := Parse(strings.NewReader(apexWildcard), name, "stdin", 0) - if err != nil { - t.Fatalf("Expect no error when reading zone, got %q", err) - } - - fm := File{Next: test.ErrorHandler(), Zones: Zones{Z: map[string]*Zone{name: zone}, Names: []string{name}}} - ctx := context.TODO() - - for _, tc := range apexWildcardTestCases { - m := tc.Msg() - - rec := dnstest.NewRecorder(&test.ResponseWriter{}) - _, err := fm.ServeDNS(ctx, rec, m) - if err != nil { - t.Errorf("Expected no error, got %v\n", err) - return - } - - resp := rec.Msg - test.SortAndCheck(t, resp, tc) - } -} - -var multiWildcardTestCases = []test.Case{ - { - Qname: "foo.example.org.", Qtype: dns.TypeA, - Answer: []dns.RR{test.A(`foo.example.org. 3600 IN A 127.0.0.54`)}, - Ns: []dns.RR{test.NS(`example.org. 3600 IN NS b.iana-servers.net.`)}, - }, - { - Qname: "bar.example.org.", Qtype: dns.TypeA, - Answer: []dns.RR{test.A(`bar.example.org. 3600 IN A 127.0.0.53`)}, - Ns: []dns.RR{test.NS(`example.org. 3600 IN NS b.iana-servers.net.`)}, - }, - { - Qname: "bar.intern.example.org.", Qtype: dns.TypeA, - Answer: []dns.RR{test.A(`bar.intern.example.org. 3600 IN A 127.0.1.52`)}, - Ns: []dns.RR{test.NS(`example.org. 3600 IN NS b.iana-servers.net.`)}, - }, -} - -func TestLookupMultiWildcard(t *testing.T) { - const name = "example.org." - zone, err := Parse(strings.NewReader(doubleWildcard), name, "stdin", 0) - if err != nil { - t.Fatalf("Expect no error when reading zone, got %q", err) - } - - fm := File{Next: test.ErrorHandler(), Zones: Zones{Z: map[string]*Zone{name: zone}, Names: []string{name}}} - ctx := context.TODO() - - for _, tc := range multiWildcardTestCases { - m := tc.Msg() - - rec := dnstest.NewRecorder(&test.ResponseWriter{}) - _, err := fm.ServeDNS(ctx, rec, m) - if err != nil { - t.Errorf("Expected no error, got %v\n", err) - return - } - - resp := rec.Msg - test.SortAndCheck(t, resp, tc) - } -} - -const exampleOrg = `; example.org test file -$TTL 3600 -example.org. IN SOA sns.dns.icann.org. noc.dns.icann.org. 2015082541 7200 3600 1209600 3600 -example.org. IN NS b.iana-servers.net. -example.org. IN NS a.iana-servers.net. -example.org. IN A 127.0.0.1 -example.org. IN A 127.0.0.2 -*.w.example.org. IN TXT "Wildcard" -a.b.c.w.example.org. IN TXT "Not a wildcard" -*.c.example.org. IN TXT "c Wildcard" -*.d.example.org. IN CNAME alias.example.org. -alias.example.org. IN TXT "Wildcard CNAME expansion" -` - -const apexWildcard = `; example.org test file with wildcard at apex -$TTL 3600 -example.org. IN SOA sns.dns.icann.org. noc.dns.icann.org. 2015082541 7200 3600 1209600 3600 -example.org. IN NS b.iana-servers.net. -*.example.org. IN A 127.0.0.53 -foo.example.org. IN A 127.0.0.54 -` - -const doubleWildcard = `; example.org test file with wildcard at apex -$TTL 3600 -example.org. IN SOA sns.dns.icann.org. noc.dns.icann.org. 2015082541 7200 3600 1209600 3600 -example.org. IN NS b.iana-servers.net. -*.example.org. IN A 127.0.0.53 -*.intern.example.org. IN A 127.0.1.52 -foo.example.org. IN A 127.0.0.54 -` diff --git a/vendor/github.com/coredns/coredns/plugin/file/xfr.go b/vendor/github.com/coredns/coredns/plugin/file/xfr.go deleted file mode 100644 index 3ad38090..00000000 --- a/vendor/github.com/coredns/coredns/plugin/file/xfr.go +++ /dev/null @@ -1,61 +0,0 @@ -package file - -import ( - "context" - "fmt" - - "github.com/coredns/coredns/plugin" - "github.com/coredns/coredns/request" - - "github.com/miekg/dns" -) - -// Xfr serves up an AXFR. -type Xfr struct { - *Zone -} - -// ServeDNS implements the plugin.Handler interface. -func (x Xfr) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (int, error) { - state := request.Request{W: w, Req: r} - if !x.TransferAllowed(state) { - return dns.RcodeServerFailure, nil - } - if state.QType() != dns.TypeAXFR && state.QType() != dns.TypeIXFR { - return 0, plugin.Error(x.Name(), fmt.Errorf("xfr called with non transfer type: %d", state.QType())) - } - - records := x.All() - if len(records) == 0 { - return dns.RcodeServerFailure, nil - } - - ch := make(chan *dns.Envelope) - defer close(ch) - tr := new(dns.Transfer) - go tr.Out(w, r, ch) - - j, l := 0, 0 - records = append(records, records[0]) // add closing SOA to the end - log.Infof("Outgoing transfer of %d records of zone %s to %s started", len(records), x.origin, state.IP()) - for i, r := range records { - l += dns.Len(r) - if l > transferLength { - ch <- &dns.Envelope{RR: records[j:i]} - l = 0 - j = i - } - } - if j < len(records) { - ch <- &dns.Envelope{RR: records[j:]} - } - - w.Hijack() - // w.Close() // Client closes connection - return dns.RcodeSuccess, nil -} - -// Name implements the plugin.Hander interface. -func (x Xfr) Name() string { return "xfr" } - -const transferLength = 1000 // Start a new envelop after message reaches this size in bytes. Intentionally small to test multi envelope parsing. diff --git a/vendor/github.com/coredns/coredns/plugin/file/xfr_test.go b/vendor/github.com/coredns/coredns/plugin/file/xfr_test.go deleted file mode 100644 index 69ad68e6..00000000 --- a/vendor/github.com/coredns/coredns/plugin/file/xfr_test.go +++ /dev/null @@ -1,34 +0,0 @@ -package file - -import ( - "fmt" - "strings" -) - -func ExampleZone_All() { - zone, err := Parse(strings.NewReader(dbMiekNL), testzone, "stdin", 0) - if err != nil { - return - } - records := zone.All() - for _, r := range records { - fmt.Printf("%+v\n", r) - } - // Output - // xfr_test.go:15: miek.nl. 1800 IN SOA linode.atoom.net. miek.miek.nl. 1282630057 14400 3600 604800 14400 - // xfr_test.go:15: www.miek.nl. 1800 IN CNAME a.miek.nl. - // xfr_test.go:15: miek.nl. 1800 IN NS linode.atoom.net. - // xfr_test.go:15: miek.nl. 1800 IN NS ns-ext.nlnetlabs.nl. - // xfr_test.go:15: miek.nl. 1800 IN NS omval.tednet.nl. - // xfr_test.go:15: miek.nl. 1800 IN NS ext.ns.whyscream.net. - // xfr_test.go:15: miek.nl. 1800 IN MX 1 aspmx.l.google.com. - // xfr_test.go:15: miek.nl. 1800 IN MX 5 alt1.aspmx.l.google.com. - // xfr_test.go:15: miek.nl. 1800 IN MX 5 alt2.aspmx.l.google.com. - // xfr_test.go:15: miek.nl. 1800 IN MX 10 aspmx2.googlemail.com. - // xfr_test.go:15: miek.nl. 1800 IN MX 10 aspmx3.googlemail.com. - // xfr_test.go:15: miek.nl. 1800 IN A 139.162.196.78 - // xfr_test.go:15: miek.nl. 1800 IN AAAA 2a01:7e00::f03c:91ff:fef1:6735 - // xfr_test.go:15: archive.miek.nl. 1800 IN CNAME a.miek.nl. - // xfr_test.go:15: a.miek.nl. 1800 IN A 139.162.196.78 - // xfr_test.go:15: a.miek.nl. 1800 IN AAAA 2a01:7e00::f03c:91ff:fef1:6735 -} diff --git a/vendor/github.com/coredns/coredns/plugin/file/zone.go b/vendor/github.com/coredns/coredns/plugin/file/zone.go deleted file mode 100644 index da294ed4..00000000 --- a/vendor/github.com/coredns/coredns/plugin/file/zone.go +++ /dev/null @@ -1,200 +0,0 @@ -package file - -import ( - "fmt" - "net" - "path" - "strings" - "sync" - - "github.com/coredns/coredns/plugin/file/tree" - "github.com/coredns/coredns/plugin/pkg/upstream" - "github.com/coredns/coredns/request" - - "github.com/miekg/dns" -) - -// Zone defines a structure that contains all data related to a DNS zone. -type Zone struct { - origin string - origLen int - file string - *tree.Tree - Apex Apex - - TransferTo []string - StartupOnce sync.Once - TransferFrom []string - Expired *bool - - NoReload bool - reloadMu sync.RWMutex - reloadShutdown chan bool - Upstream upstream.Upstream // Upstream for looking up names during the resolution process -} - -// Apex contains the apex records of a zone: SOA, NS and their potential signatures. -type Apex struct { - SOA *dns.SOA - NS []dns.RR - SIGSOA []dns.RR - SIGNS []dns.RR -} - -// NewZone returns a new zone. -func NewZone(name, file string) *Zone { - z := &Zone{ - origin: dns.Fqdn(name), - origLen: dns.CountLabel(dns.Fqdn(name)), - file: path.Clean(file), - Tree: &tree.Tree{}, - Expired: new(bool), - reloadShutdown: make(chan bool), - } - *z.Expired = false - - return z -} - -// Copy copies a zone. -func (z *Zone) Copy() *Zone { - z1 := NewZone(z.origin, z.file) - z1.TransferTo = z.TransferTo - z1.TransferFrom = z.TransferFrom - z1.Expired = z.Expired - - z1.Apex = z.Apex - return z1 -} - -// CopyWithoutApex copies zone z without the Apex records. -func (z *Zone) CopyWithoutApex() *Zone { - z1 := NewZone(z.origin, z.file) - z1.TransferTo = z.TransferTo - z1.TransferFrom = z.TransferFrom - z1.Expired = z.Expired - - return z1 -} - -// Insert inserts r into z. -func (z *Zone) Insert(r dns.RR) error { - r.Header().Name = strings.ToLower(r.Header().Name) - - switch h := r.Header().Rrtype; h { - case dns.TypeNS: - r.(*dns.NS).Ns = strings.ToLower(r.(*dns.NS).Ns) - - if r.Header().Name == z.origin { - z.Apex.NS = append(z.Apex.NS, r) - return nil - } - case dns.TypeSOA: - r.(*dns.SOA).Ns = strings.ToLower(r.(*dns.SOA).Ns) - r.(*dns.SOA).Mbox = strings.ToLower(r.(*dns.SOA).Mbox) - - z.Apex.SOA = r.(*dns.SOA) - return nil - case dns.TypeNSEC3, dns.TypeNSEC3PARAM: - return fmt.Errorf("NSEC3 zone is not supported, dropping RR: %s for zone: %s", r.Header().Name, z.origin) - case dns.TypeRRSIG: - x := r.(*dns.RRSIG) - switch x.TypeCovered { - case dns.TypeSOA: - z.Apex.SIGSOA = append(z.Apex.SIGSOA, x) - return nil - case dns.TypeNS: - if r.Header().Name == z.origin { - z.Apex.SIGNS = append(z.Apex.SIGNS, x) - return nil - } - } - case dns.TypeCNAME: - r.(*dns.CNAME).Target = strings.ToLower(r.(*dns.CNAME).Target) - case dns.TypeMX: - r.(*dns.MX).Mx = strings.ToLower(r.(*dns.MX).Mx) - case dns.TypeSRV: - r.(*dns.SRV).Target = strings.ToLower(r.(*dns.SRV).Target) - } - - z.Tree.Insert(r) - return nil -} - -// Delete deletes r from z. -func (z *Zone) Delete(r dns.RR) { z.Tree.Delete(r) } - -// TransferAllowed checks if incoming request for transferring the zone is allowed according to the ACLs. -func (z *Zone) TransferAllowed(state request.Request) bool { - for _, t := range z.TransferTo { - if t == "*" { - return true - } - // If remote IP matches we accept. - remote := state.IP() - to, _, err := net.SplitHostPort(t) - if err != nil { - continue - } - if to == remote { - return true - } - } - // TODO(miek): future matching against IP/CIDR notations - return false -} - -// All returns all records from the zone, the first record will be the SOA record, -// otionally followed by all RRSIG(SOA)s. -func (z *Zone) All() []dns.RR { - if !z.NoReload { - z.reloadMu.RLock() - defer z.reloadMu.RUnlock() - } - - records := []dns.RR{} - allNodes := z.Tree.All() - for _, a := range allNodes { - records = append(records, a.All()...) - } - - if len(z.Apex.SIGNS) > 0 { - records = append(z.Apex.SIGNS, records...) - } - records = append(z.Apex.NS, records...) - - if len(z.Apex.SIGSOA) > 0 { - records = append(z.Apex.SIGSOA, records...) - } - return append([]dns.RR{z.Apex.SOA}, records...) -} - -// Print prints the zone's tree to stdout. -func (z *Zone) Print() { - z.Tree.Print() -} - -// NameFromRight returns the labels from the right, staring with the -// origin and then i labels extra. When we are overshooting the name -// the returned boolean is set to true. -func (z *Zone) nameFromRight(qname string, i int) (string, bool) { - if i <= 0 { - return z.origin, false - } - - for j := 1; j <= z.origLen; j++ { - if _, shot := dns.PrevLabel(qname, j); shot { - return qname, shot - } - } - - k := 0 - shot := false - for j := 1; j <= i; j++ { - k, shot = dns.PrevLabel(qname, j+z.origLen) - if shot { - return qname, shot - } - } - return qname[k:], false -} diff --git a/vendor/github.com/coredns/coredns/plugin/file/zone_test.go b/vendor/github.com/coredns/coredns/plugin/file/zone_test.go deleted file mode 100644 index c9ff174d..00000000 --- a/vendor/github.com/coredns/coredns/plugin/file/zone_test.go +++ /dev/null @@ -1,30 +0,0 @@ -package file - -import "testing" - -func TestNameFromRight(t *testing.T) { - z := NewZone("example.org.", "stdin") - - tests := []struct { - in string - labels int - shot bool - expected string - }{ - {"example.org.", 0, false, "example.org."}, - {"a.example.org.", 0, false, "example.org."}, - {"a.example.org.", 1, false, "a.example.org."}, - {"a.example.org.", 2, true, "a.example.org."}, - {"a.b.example.org.", 2, false, "a.b.example.org."}, - } - - for i, tc := range tests { - got, shot := z.nameFromRight(tc.in, tc.labels) - if got != tc.expected { - t.Errorf("Test %d: expected %s, got %s\n", i, tc.expected, got) - } - if shot != tc.shot { - t.Errorf("Test %d: expected shot to be %t, got %t\n", i, tc.shot, shot) - } - } -} diff --git a/vendor/github.com/coredns/coredns/plugin/forward/OWNERS b/vendor/github.com/coredns/coredns/plugin/forward/OWNERS deleted file mode 100644 index 3ef197ec..00000000 --- a/vendor/github.com/coredns/coredns/plugin/forward/OWNERS +++ /dev/null @@ -1,12 +0,0 @@ -reviewers: - - fturib - - grobie - - johnbelamaric - - miekg - - rdrozhdzh -approvers: - - fturib - - grobie - - johnbelamaric - - rdrozhdzh - - miekg diff --git a/vendor/github.com/coredns/coredns/plugin/forward/README.md b/vendor/github.com/coredns/coredns/plugin/forward/README.md deleted file mode 100644 index d87ba2ee..00000000 --- a/vendor/github.com/coredns/coredns/plugin/forward/README.md +++ /dev/null @@ -1,165 +0,0 @@ -# forward - -## Name - -*forward* - facilitates proxying DNS messages to upstream resolvers. - -## Description - -The *forward* plugin re-uses already opened sockets to the upstreams. It supports UDP, TCP and -DNS-over-TLS and uses in band health checking. - -When it detects an error a health check is performed. This checks runs in a loop, every *0.5s*, for -as long as the upstream reports unhealthy. Once healthy we stop health checking (until the next -error). The health checks use a recursive DNS query (`. IN NS`) to get upstream health. Any response -that is not a network error (REFUSED, NOTIMPL, SERVFAIL, etc) is taken as a healthy upstream. The -health check uses the same protocol as specified in **TO**. If `max_fails` is set to 0, no checking -is performed and upstreams will always be considered healthy. - -When *all* upstreams are down it assumes health checking as a mechanism has failed and will try to -connect to a random upstream (which may or may not work). - -This plugin can only be used once per Server Block. - -How does *forward* relate to *proxy*? This plugin is the "new" version of *proxy* and is faster -because it re-uses connections to the upstreams. It also does in-band health checks - using DNS -instead of HTTP. Since it is newer it has a little less (production) mileage on it. - -## Syntax - -In its most basic form, a simple forwarder uses this syntax: - -~~~ -forward FROM TO... -~~~ - -* **FROM** is the base domain to match for the request to be forwarded. -* **TO...** are the destination endpoints to forward to. The **TO** syntax allows you to specify - a protocol, `tls://9.9.9.9` or `dns://` (or no protocol) for plain DNS. The number of upstreams is - limited to 15. - -Multiple upstreams are randomized (see `policy`) on first use. When a healthy proxy returns an error -during the exchange the next upstream in the list is tried. - -Extra knobs are available with an expanded syntax: - -~~~ -forward FROM TO... { - except IGNORED_NAMES... - force_tcp - expire DURATION - max_fails INTEGER - tls CERT KEY CA - tls_servername NAME - policy random|round_robin|sequential - health_check DURATION -} -~~~ - -* **FROM** and **TO...** as above. -* **IGNORED_NAMES** in `except` is a space-separated list of domains to exclude from forwarding. - Requests that match none of these names will be passed through. -* `force_tcp`, use TCP even when the request comes in over UDP. -* `max_fails` is the number of subsequent failed health checks that are needed before considering - an upstream to be down. If 0, the upstream will never be marked as down (nor health checked). - Default is 2. -* `expire` **DURATION**, expire (cached) connections after this time, the default is 10s. -* `tls` **CERT** **KEY** **CA** define the TLS properties for TLS connection. From 0 to 3 arguments can be - provided with the meaning as described below - - * `tls` - no client authentication is used, and the system CAs are used to verify the server certificate - * `tls` **CA** - no client authentication is used, and the file CA is used to verify the server certificate - * `tls` **CERT** **KEY** - client authentication is used with the specified cert/key pair. - The server certificate is verified with the system CAs - * `tls` **CERT** **KEY** **CA** - client authentication is used with the specified cert/key pair. - The server certificate is verified using the specified CA file - -* `tls_servername` **NAME** allows you to set a server name in the TLS configuration; for instance 9.9.9.9 - needs this to be set to `dns.quad9.net`. -* `policy` specifies the policy to use for selecting upstream servers. The default is `random`. -* `health_check`, use a different **DURATION** for health checking, the default duration is 0.5s. - -Also note the TLS config is "global" for the whole forwarding proxy if you need a different -`tls-name` for different upstreams you're out of luck. - -On each endpoint, the timeouts of the communication are set by default and automatically tuned depending early results. -- dialTimeout by default is 30 sec, and can decrease automatically down to 100ms -- readTimeout by default is 2 sec, and can decrease automatically down to 10ms - -## Metrics - -If monitoring is enabled (via the *prometheus* directive) then the following metric are exported: - -* `coredns_forward_request_duration_seconds{to}` - duration per upstream interaction. -* `coredns_forward_request_count_total{to}` - query count per upstream. -* `coredns_forward_response_rcode_total{to, rcode}` - count of RCODEs per upstream. -* `coredns_forward_healthcheck_failure_count_total{to}` - number of failed health checks per upstream. -* `coredns_forward_healthcheck_broken_count_total{}` - counter of when all upstreams are unhealthy, - and we are randomly (this always uses the `random` policy) spraying to an upstream. -* `coredns_forward_socket_count_total{to}` - number of cached sockets per upstream. - -Where `to` is one of the upstream servers (**TO** from the config), `proto` is the protocol used by -the incoming query ("tcp" or "udp"), and family the transport family ("1" for IPv4, and "2" for -IPv6). - -## Examples - -Proxy all requests within `example.org.` to a nameserver running on a different port: - -~~~ corefile -example.org { - forward . 127.0.0.1:9005 -} -~~~ - -Load balance all requests between three resolvers, one of which has a IPv6 address. - -~~~ corefile -. { - forward . 10.0.0.10:53 10.0.0.11:1053 [2003::1]:53 -} -~~~ - -Forward everything except requests to `example.org` - -~~~ corefile -. { - forward . 10.0.0.10:1234 { - except example.org - } -} -~~~ - -Proxy everything except `example.org` using the host's `resolv.conf`'s nameservers: - -~~~ corefile -. { - forward . /etc/resolv.conf { - except example.org - } -} -~~~ - -Proxy all requests to 9.9.9.9 using the DNS-over-TLS protocol, and cache every answer for up to 30 -seconds. Note the `tls_servername` is mandatory if you want a working setup, as 9.9.9.9 can't be -used in the TLS negotiation. Also set the health check duration to 5s to not completely swamp the -service with health checks. - -~~~ corefile -. { - forward . tls://9.9.9.9 { - tls_servername dns.quad9.net - health_check 5s - } - cache 30 -} -~~~ - -## Bugs - -The TLS config is global for the whole forwarding proxy if you need a different `tls_servername` for -different upstreams you're out of luck. - -## Also See - -[RFC 7858](https://tools.ietf.org/html/rfc7858) for DNS over TLS. diff --git a/vendor/github.com/coredns/coredns/plugin/forward/connect.go b/vendor/github.com/coredns/coredns/plugin/forward/connect.go deleted file mode 100644 index fe6313e0..00000000 --- a/vendor/github.com/coredns/coredns/plugin/forward/connect.go +++ /dev/null @@ -1,139 +0,0 @@ -// Package forward implements a forwarding proxy. It caches an upstream net.Conn for some time, so if the same -// client returns the upstream's Conn will be precached. Depending on how you benchmark this looks to be -// 50% faster than just openening a new connection for every client. It works with UDP and TCP and uses -// inband healthchecking. -package forward - -import ( - "context" - "io" - "strconv" - "sync/atomic" - "time" - - "github.com/coredns/coredns/request" - - "github.com/miekg/dns" -) - -// limitTimeout is a utility function to auto-tune timeout values -// average observed time is moved towards the last observed delay moderated by a weight -// next timeout to use will be the double of the computed average, limited by min and max frame. -func limitTimeout(currentAvg *int64, minValue time.Duration, maxValue time.Duration) time.Duration { - rt := time.Duration(atomic.LoadInt64(currentAvg)) - if rt < minValue { - return minValue - } - if rt < maxValue/2 { - return 2 * rt - } - return maxValue -} - -func averageTimeout(currentAvg *int64, observedDuration time.Duration, weight int64) { - dt := time.Duration(atomic.LoadInt64(currentAvg)) - atomic.AddInt64(currentAvg, int64(observedDuration-dt)/weight) -} - -func (t *transport) dialTimeout() time.Duration { - return limitTimeout(&t.avgDialTime, minDialTimeout, maxDialTimeout) -} - -func (t *transport) updateDialTimeout(newDialTime time.Duration) { - averageTimeout(&t.avgDialTime, newDialTime, cumulativeAvgWeight) -} - -// Dial dials the address configured in transport, potentially reusing a connection or creating a new one. -func (t *transport) Dial(proto string) (*dns.Conn, bool, error) { - // If tls has been configured; use it. - if t.tlsConfig != nil { - proto = "tcp-tls" - } - - t.dial <- proto - c := <-t.ret - - if c != nil { - return c, true, nil - } - - reqTime := time.Now() - timeout := t.dialTimeout() - if proto == "tcp-tls" { - conn, err := dns.DialTimeoutWithTLS("tcp", t.addr, t.tlsConfig, timeout) - t.updateDialTimeout(time.Since(reqTime)) - return conn, false, err - } - conn, err := dns.DialTimeout(proto, t.addr, timeout) - t.updateDialTimeout(time.Since(reqTime)) - return conn, false, err -} - -func (p *Proxy) readTimeout() time.Duration { - return limitTimeout(&p.avgRtt, minTimeout, maxTimeout) -} - -func (p *Proxy) updateRtt(newRtt time.Duration) { - averageTimeout(&p.avgRtt, newRtt, cumulativeAvgWeight) -} - -// Connect selects an upstream, sends the request and waits for a response. -func (p *Proxy) Connect(ctx context.Context, state request.Request, forceTCP, metric bool) (*dns.Msg, error) { - start := time.Now() - - proto := state.Proto() - if forceTCP { - proto = "tcp" - } - - conn, cached, err := p.Dial(proto) - if err != nil { - return nil, err - } - - // Set buffer size correctly for this client. - conn.UDPSize = uint16(state.Size()) - if conn.UDPSize < 512 { - conn.UDPSize = 512 - } - - conn.SetWriteDeadline(time.Now().Add(timeout)) - reqTime := time.Now() - if err := conn.WriteMsg(state.Req); err != nil { - conn.Close() // not giving it back - if err == io.EOF && cached { - return nil, ErrCachedClosed - } - return nil, err - } - - conn.SetReadDeadline(time.Now().Add(p.readTimeout())) - ret, err := conn.ReadMsg() - if err != nil { - p.updateRtt(timeout) - conn.Close() // not giving it back - if err == io.EOF && cached { - return nil, ErrCachedClosed - } - return ret, err - } - - p.updateRtt(time.Since(reqTime)) - - p.Yield(conn) - - if metric { - rc, ok := dns.RcodeToString[ret.Rcode] - if !ok { - rc = strconv.Itoa(ret.Rcode) - } - - RequestCount.WithLabelValues(p.addr).Add(1) - RcodeCount.WithLabelValues(rc, p.addr).Add(1) - RequestDuration.WithLabelValues(p.addr).Observe(time.Since(start).Seconds()) - } - - return ret, nil -} - -const cumulativeAvgWeight = 4 diff --git a/vendor/github.com/coredns/coredns/plugin/forward/forward.go b/vendor/github.com/coredns/coredns/plugin/forward/forward.go deleted file mode 100644 index ce81392f..00000000 --- a/vendor/github.com/coredns/coredns/plugin/forward/forward.go +++ /dev/null @@ -1,206 +0,0 @@ -// Package forward implements a forwarding proxy. It caches an upstream net.Conn for some time, so if the same -// client returns the upstream's Conn will be precached. Depending on how you benchmark this looks to be -// 50% faster than just openening a new connection for every client. It works with UDP and TCP and uses -// inband healthchecking. -package forward - -import ( - "context" - "crypto/tls" - "errors" - "time" - - "github.com/coredns/coredns/plugin" - "github.com/coredns/coredns/request" - - "github.com/miekg/dns" - ot "github.com/opentracing/opentracing-go" -) - -// Forward represents a plugin instance that can proxy requests to another (DNS) server. It has a list -// of proxies each representing one upstream proxy. -type Forward struct { - proxies []*Proxy - p Policy - hcInterval time.Duration - - from string - ignored []string - - tlsConfig *tls.Config - tlsServerName string - maxfails uint32 - expire time.Duration - - forceTCP bool // also here for testing - - Next plugin.Handler -} - -// New returns a new Forward. -func New() *Forward { - f := &Forward{maxfails: 2, tlsConfig: new(tls.Config), expire: defaultExpire, p: new(random), from: ".", hcInterval: hcDuration} - return f -} - -// SetProxy appends p to the proxy list and starts healthchecking. -func (f *Forward) SetProxy(p *Proxy) { - f.proxies = append(f.proxies, p) - p.start(f.hcInterval) -} - -// Len returns the number of configured proxies. -func (f *Forward) Len() int { return len(f.proxies) } - -// Name implements plugin.Handler. -func (f *Forward) Name() string { return "forward" } - -// ServeDNS implements plugin.Handler. -func (f *Forward) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (int, error) { - - state := request.Request{W: w, Req: r} - if !f.match(state) { - return plugin.NextOrFailure(f.Name(), f.Next, ctx, w, r) - } - - fails := 0 - var span, child ot.Span - var upstreamErr error - span = ot.SpanFromContext(ctx) - i := 0 - list := f.List() - deadline := time.Now().Add(defaultTimeout) - - for time.Now().Before(deadline) { - if i >= len(list) { - // reached the end of list, reset to begin - i = 0 - fails = 0 - } - - proxy := list[i] - i++ - if proxy.Down(f.maxfails) { - fails++ - if fails < len(f.proxies) { - continue - } - // All upstream proxies are dead, assume healtcheck is completely broken and randomly - // select an upstream to connect to. - r := new(random) - proxy = r.List(f.proxies)[0] - - HealthcheckBrokenCount.Add(1) - } - - if span != nil { - child = span.Tracer().StartSpan("connect", ot.ChildOf(span.Context())) - ctx = ot.ContextWithSpan(ctx, child) - } - - var ( - ret *dns.Msg - err error - ) - for { - ret, err = proxy.Connect(ctx, state, f.forceTCP, true) - if err != nil && err == ErrCachedClosed { // Remote side closed conn, can only happen with TCP. - continue - } - break - } - - if child != nil { - child.Finish() - } - - ret, err = truncated(state, ret, err) - upstreamErr = err - - if err != nil { - // Kick off health check to see if *our* upstream is broken. - if f.maxfails != 0 { - proxy.Healthcheck() - } - - if fails < len(f.proxies) { - continue - } - break - } - - // Check if the reply is correct; if not return FormErr. - if !state.Match(ret) { - formerr := state.ErrorMessage(dns.RcodeFormatError) - w.WriteMsg(formerr) - return 0, nil - } - - // When using force_tcp the upstream can send a message that is too big for - // the udp buffer, hence we need to truncate the message to at least make it - // fit the udp buffer. - ret, _ = state.Scrub(ret) - - w.WriteMsg(ret) - - return 0, nil - } - - if upstreamErr != nil { - return dns.RcodeServerFailure, upstreamErr - } - - return dns.RcodeServerFailure, ErrNoHealthy -} - -func (f *Forward) match(state request.Request) bool { - from := f.from - - if !plugin.Name(from).Matches(state.Name()) || !f.isAllowedDomain(state.Name()) { - return false - } - - return true -} - -func (f *Forward) isAllowedDomain(name string) bool { - if dns.Name(name) == dns.Name(f.from) { - return true - } - - for _, ignore := range f.ignored { - if plugin.Name(ignore).Matches(name) { - return false - } - } - return true -} - -// From returns the base domain to match for the request to be forwarded. -func (f *Forward) From() string { return f.from } - -// ForceTCP returns if TCP is forced to be used even when the request comes in over UDP. -func (f *Forward) ForceTCP() bool { return f.forceTCP } - -// List returns a set of proxies to be used for this client depending on the policy in f. -func (f *Forward) List() []*Proxy { return f.p.List(f.proxies) } - -var ( - // ErrNoHealthy means no healthy proxies left - ErrNoHealthy = errors.New("no healthy proxies") - // ErrNoForward means no forwarder defined - ErrNoForward = errors.New("no forwarder defined") - // ErrCachedClosed means cached connection was closed by peer - ErrCachedClosed = errors.New("cached connection was closed by peer") -) - -// policy tells forward what policy for selecting upstream it uses. -type policy int - -const ( - randomPolicy policy = iota - roundRobinPolicy - sequentialPolicy -) - -const defaultTimeout = 5 * time.Second diff --git a/vendor/github.com/coredns/coredns/plugin/forward/forward_test.go b/vendor/github.com/coredns/coredns/plugin/forward/forward_test.go deleted file mode 100644 index 96f5fa0c..00000000 --- a/vendor/github.com/coredns/coredns/plugin/forward/forward_test.go +++ /dev/null @@ -1,68 +0,0 @@ -package forward - -import ( - "testing" - - "github.com/coredns/coredns/plugin/pkg/dnstest" - "github.com/coredns/coredns/plugin/test" - "github.com/coredns/coredns/request" - - "github.com/miekg/dns" -) - -func TestForward(t *testing.T) { - s := dnstest.NewServer(func(w dns.ResponseWriter, r *dns.Msg) { - ret := new(dns.Msg) - ret.SetReply(r) - ret.Answer = append(ret.Answer, test.A("example.org. IN A 127.0.0.1")) - w.WriteMsg(ret) - }) - defer s.Close() - - p := NewProxy(s.Addr, nil /* not TLS */) - f := New() - f.SetProxy(p) - defer f.Close() - - state := request.Request{W: &test.ResponseWriter{}, Req: new(dns.Msg)} - state.Req.SetQuestion("example.org.", dns.TypeA) - resp, err := f.Forward(state) - if err != nil { - t.Fatal("Expected to receive reply, but didn't") - } - // expect answer section with A record in it - if len(resp.Answer) == 0 { - t.Fatalf("Expected to at least one RR in the answer section, got none: %s", resp) - } - if resp.Answer[0].Header().Rrtype != dns.TypeA { - t.Errorf("Expected RR to A, got: %d", resp.Answer[0].Header().Rrtype) - } - if resp.Answer[0].(*dns.A).A.String() != "127.0.0.1" { - t.Errorf("Expected 127.0.0.1, got: %s", resp.Answer[0].(*dns.A).A.String()) - } -} - -func TestForwardRefused(t *testing.T) { - s := dnstest.NewServer(func(w dns.ResponseWriter, r *dns.Msg) { - ret := new(dns.Msg) - ret.SetReply(r) - ret.Rcode = dns.RcodeRefused - w.WriteMsg(ret) - }) - defer s.Close() - - p := NewProxy(s.Addr, nil) - f := New() - f.SetProxy(p) - defer f.Close() - - state := request.Request{W: &test.ResponseWriter{}, Req: new(dns.Msg)} - state.Req.SetQuestion("example.org.", dns.TypeA) - resp, err := f.Forward(state) - if err != nil { - t.Fatal("Expected to receive reply, but didn't") - } - if resp.Rcode != dns.RcodeRefused { - t.Errorf("Expected rcode to be %d, got %d", dns.RcodeRefused, resp.Rcode) - } -} diff --git a/vendor/github.com/coredns/coredns/plugin/forward/health.go b/vendor/github.com/coredns/coredns/plugin/forward/health.go deleted file mode 100644 index 03322e92..00000000 --- a/vendor/github.com/coredns/coredns/plugin/forward/health.go +++ /dev/null @@ -1,39 +0,0 @@ -package forward - -import ( - "sync/atomic" - - "github.com/miekg/dns" -) - -// For HC we send to . IN NS +norec message to the upstream. Dial timeouts and empty -// replies are considered fails, basically anything else constitutes a healthy upstream. - -// Check is used as the up.Func in the up.Probe. -func (p *Proxy) Check() error { - err := p.send() - if err != nil { - HealthcheckFailureCount.WithLabelValues(p.addr).Add(1) - atomic.AddUint32(&p.fails, 1) - return err - } - - atomic.StoreUint32(&p.fails, 0) - return nil -} - -func (p *Proxy) send() error { - hcping := new(dns.Msg) - hcping.SetQuestion(".", dns.TypeNS) - - m, _, err := p.client.Exchange(hcping, p.addr) - // If we got a header, we're alright, basically only care about I/O errors 'n stuff - if err != nil && m != nil { - // Silly check, something sane came back - if m.Response || m.Opcode == dns.OpcodeQuery { - err = nil - } - } - - return err -} diff --git a/vendor/github.com/coredns/coredns/plugin/forward/health_test.go b/vendor/github.com/coredns/coredns/plugin/forward/health_test.go deleted file mode 100644 index 0588f145..00000000 --- a/vendor/github.com/coredns/coredns/plugin/forward/health_test.go +++ /dev/null @@ -1,182 +0,0 @@ -package forward - -import ( - "context" - "sync/atomic" - "testing" - "time" - - "github.com/coredns/coredns/plugin/pkg/dnstest" - "github.com/coredns/coredns/plugin/test" - - "github.com/miekg/dns" -) - -func TestHealth(t *testing.T) { - const expected = 0 - i := uint32(0) - s := dnstest.NewServer(func(w dns.ResponseWriter, r *dns.Msg) { - if r.Question[0].Name == "." { - atomic.AddUint32(&i, 1) - } - ret := new(dns.Msg) - ret.SetReply(r) - w.WriteMsg(ret) - }) - defer s.Close() - - p := NewProxy(s.Addr, nil /* no TLS */) - f := New() - f.SetProxy(p) - defer f.Close() - - req := new(dns.Msg) - req.SetQuestion("example.org.", dns.TypeA) - - f.ServeDNS(context.TODO(), &test.ResponseWriter{}, req) - - time.Sleep(1 * time.Second) - i1 := atomic.LoadUint32(&i) - if i1 != expected { - t.Errorf("Expected number of health checks to be %d, got %d", expected, i1) - } -} - -func TestHealthTimeout(t *testing.T) { - const expected = 1 - i := uint32(0) - q := uint32(0) - s := dnstest.NewServer(func(w dns.ResponseWriter, r *dns.Msg) { - if r.Question[0].Name == "." { - // health check, answer - atomic.AddUint32(&i, 1) - ret := new(dns.Msg) - ret.SetReply(r) - w.WriteMsg(ret) - return - } - if atomic.LoadUint32(&q) == 0 { //drop only first query - atomic.AddUint32(&q, 1) - return - } - ret := new(dns.Msg) - ret.SetReply(r) - w.WriteMsg(ret) - }) - defer s.Close() - - p := NewProxy(s.Addr, nil /* no TLS */) - f := New() - f.SetProxy(p) - defer f.Close() - - req := new(dns.Msg) - req.SetQuestion("example.org.", dns.TypeA) - - f.ServeDNS(context.TODO(), &test.ResponseWriter{}, req) - - time.Sleep(1 * time.Second) - i1 := atomic.LoadUint32(&i) - if i1 != expected { - t.Errorf("Expected number of health checks to be %d, got %d", expected, i1) - } -} - -func TestHealthFailTwice(t *testing.T) { - const expected = 2 - i := uint32(0) - q := uint32(0) - s := dnstest.NewServer(func(w dns.ResponseWriter, r *dns.Msg) { - if r.Question[0].Name == "." { - atomic.AddUint32(&i, 1) - i1 := atomic.LoadUint32(&i) - // Timeout health until we get the second one - if i1 < 2 { - return - } - ret := new(dns.Msg) - ret.SetReply(r) - w.WriteMsg(ret) - return - } - if atomic.LoadUint32(&q) == 0 { //drop only first query - atomic.AddUint32(&q, 1) - return - } - ret := new(dns.Msg) - ret.SetReply(r) - w.WriteMsg(ret) - }) - defer s.Close() - - p := NewProxy(s.Addr, nil /* no TLS */) - f := New() - f.SetProxy(p) - defer f.Close() - - req := new(dns.Msg) - req.SetQuestion("example.org.", dns.TypeA) - - f.ServeDNS(context.TODO(), &test.ResponseWriter{}, req) - - time.Sleep(3 * time.Second) - i1 := atomic.LoadUint32(&i) - if i1 != expected { - t.Errorf("Expected number of health checks to be %d, got %d", expected, i1) - } -} - -func TestHealthMaxFails(t *testing.T) { - s := dnstest.NewServer(func(w dns.ResponseWriter, r *dns.Msg) { - // timeout - }) - defer s.Close() - - p := NewProxy(s.Addr, nil /* no TLS */) - f := New() - f.maxfails = 2 - f.SetProxy(p) - defer f.Close() - - req := new(dns.Msg) - req.SetQuestion("example.org.", dns.TypeA) - - f.ServeDNS(context.TODO(), &test.ResponseWriter{}, req) - - time.Sleep(1 * time.Second) - if !p.Down(f.maxfails) { - t.Errorf("Expected Proxy fails to be greater than %d, got %d", f.maxfails, p.fails) - } -} - -func TestHealthNoMaxFails(t *testing.T) { - const expected = 0 - i := uint32(0) - s := dnstest.NewServer(func(w dns.ResponseWriter, r *dns.Msg) { - if r.Question[0].Name == "." { - // health check, answer - atomic.AddUint32(&i, 1) - ret := new(dns.Msg) - ret.SetReply(r) - w.WriteMsg(ret) - } - }) - defer s.Close() - - p := NewProxy(s.Addr, nil /* no TLS */) - f := New() - f.maxfails = 0 - f.SetProxy(p) - defer f.Close() - - req := new(dns.Msg) - req.SetQuestion("example.org.", dns.TypeA) - - f.ServeDNS(context.TODO(), &test.ResponseWriter{}, req) - - time.Sleep(1 * time.Second) - i1 := atomic.LoadUint32(&i) - if i1 != expected { - t.Errorf("Expected number of health checks to be %d, got %d", expected, i1) - } -} diff --git a/vendor/github.com/coredns/coredns/plugin/forward/lookup.go b/vendor/github.com/coredns/coredns/plugin/forward/lookup.go deleted file mode 100644 index 65ee593f..00000000 --- a/vendor/github.com/coredns/coredns/plugin/forward/lookup.go +++ /dev/null @@ -1,88 +0,0 @@ -// Package forward implements a forwarding proxy. It caches an upstream net.Conn for some time, so if the same -// client returns the upstream's Conn will be precached. Depending on how you benchmark this looks to be -// 50% faster than just openening a new connection for every client. It works with UDP and TCP and uses -// inband healthchecking. -package forward - -import ( - "context" - - "github.com/coredns/coredns/request" - - "github.com/miekg/dns" -) - -// Forward forward the request in state as-is. Unlike Lookup that adds EDNS0 suffix to the message. -// Forward may be called with a nil f, an error is returned in that case. -func (f *Forward) Forward(state request.Request) (*dns.Msg, error) { - if f == nil { - return nil, ErrNoForward - } - - fails := 0 - var upstreamErr error - for _, proxy := range f.List() { - if proxy.Down(f.maxfails) { - fails++ - if fails < len(f.proxies) { - continue - } - // All upstream proxies are dead, assume healtcheck is complete broken and randomly - // select an upstream to connect to. - proxy = f.List()[0] - } - - ret, err := proxy.Connect(context.Background(), state, f.forceTCP, true) - - ret, err = truncated(state, ret, err) - upstreamErr = err - - if err != nil { - if fails < len(f.proxies) { - continue - } - break - } - - // Check if the reply is correct; if not return FormErr. - if !state.Match(ret) { - return state.ErrorMessage(dns.RcodeFormatError), nil - } - - return ret, err - } - - if upstreamErr != nil { - return nil, upstreamErr - } - - return nil, ErrNoHealthy -} - -// Lookup will use name and type to forge a new message and will send that upstream. It will -// set any EDNS0 options correctly so that downstream will be able to process the reply. -// Lookup may be called with a nil f, an error is returned in that case. -func (f *Forward) Lookup(state request.Request, name string, typ uint16) (*dns.Msg, error) { - if f == nil { - return nil, ErrNoForward - } - - req := new(dns.Msg) - req.SetQuestion(name, typ) - state.SizeAndDo(req) - - state2 := request.Request{W: state.W, Req: req} - - return f.Forward(state2) -} - -// NewLookup returns a Forward that can be used for plugin that need an upstream to resolve external names. -// Note that the caller must run Close on the forward to stop the health checking goroutines. -func NewLookup(addr []string) *Forward { - f := New() - for i := range addr { - p := NewProxy(addr[i], nil) - f.SetProxy(p) - } - return f -} diff --git a/vendor/github.com/coredns/coredns/plugin/forward/lookup_test.go b/vendor/github.com/coredns/coredns/plugin/forward/lookup_test.go deleted file mode 100644 index e37a0c5d..00000000 --- a/vendor/github.com/coredns/coredns/plugin/forward/lookup_test.go +++ /dev/null @@ -1,42 +0,0 @@ -package forward - -import ( - "testing" - - "github.com/coredns/coredns/plugin/pkg/dnstest" - "github.com/coredns/coredns/plugin/test" - "github.com/coredns/coredns/request" - - "github.com/miekg/dns" -) - -func TestLookup(t *testing.T) { - s := dnstest.NewServer(func(w dns.ResponseWriter, r *dns.Msg) { - ret := new(dns.Msg) - ret.SetReply(r) - ret.Answer = append(ret.Answer, test.A("example.org. IN A 127.0.0.1")) - w.WriteMsg(ret) - }) - defer s.Close() - - p := NewProxy(s.Addr, nil /* no TLS */) - f := New() - f.SetProxy(p) - defer f.Close() - - state := request.Request{W: &test.ResponseWriter{}, Req: new(dns.Msg)} - resp, err := f.Lookup(state, "example.org.", dns.TypeA) - if err != nil { - t.Fatal("Expected to receive reply, but didn't") - } - // expect answer section with A record in it - if len(resp.Answer) == 0 { - t.Fatalf("Expected to at least one RR in the answer section, got none: %s", resp) - } - if resp.Answer[0].Header().Rrtype != dns.TypeA { - t.Errorf("Expected RR to A, got: %d", resp.Answer[0].Header().Rrtype) - } - if resp.Answer[0].(*dns.A).A.String() != "127.0.0.1" { - t.Errorf("Expected 127.0.0.1, got: %s", resp.Answer[0].(*dns.A).A.String()) - } -} diff --git a/vendor/github.com/coredns/coredns/plugin/forward/metrics.go b/vendor/github.com/coredns/coredns/plugin/forward/metrics.go deleted file mode 100644 index b0368f72..00000000 --- a/vendor/github.com/coredns/coredns/plugin/forward/metrics.go +++ /dev/null @@ -1,52 +0,0 @@ -package forward - -import ( - "sync" - - "github.com/coredns/coredns/plugin" - - "github.com/prometheus/client_golang/prometheus" -) - -// Variables declared for monitoring. -var ( - RequestCount = prometheus.NewCounterVec(prometheus.CounterOpts{ - Namespace: plugin.Namespace, - Subsystem: "forward", - Name: "request_count_total", - Help: "Counter of requests made per upstream.", - }, []string{"to"}) - RcodeCount = prometheus.NewCounterVec(prometheus.CounterOpts{ - Namespace: plugin.Namespace, - Subsystem: "forward", - Name: "response_rcode_count_total", - Help: "Counter of requests made per upstream.", - }, []string{"rcode", "to"}) - RequestDuration = prometheus.NewHistogramVec(prometheus.HistogramOpts{ - Namespace: plugin.Namespace, - Subsystem: "forward", - Name: "request_duration_seconds", - Buckets: plugin.TimeBuckets, - Help: "Histogram of the time each request took.", - }, []string{"to"}) - HealthcheckFailureCount = prometheus.NewCounterVec(prometheus.CounterOpts{ - Namespace: plugin.Namespace, - Subsystem: "forward", - Name: "healthcheck_failure_count_total", - Help: "Counter of the number of failed healtchecks.", - }, []string{"to"}) - HealthcheckBrokenCount = prometheus.NewCounter(prometheus.CounterOpts{ - Namespace: plugin.Namespace, - Subsystem: "forward", - Name: "healthcheck_broken_count_total", - Help: "Counter of the number of complete failures of the healtchecks.", - }) - SocketGauge = prometheus.NewGaugeVec(prometheus.GaugeOpts{ - Namespace: plugin.Namespace, - Subsystem: "forward", - Name: "socket_count_total", - Help: "Gauge of open sockets per upstream.", - }, []string{"to"}) -) - -var once sync.Once diff --git a/vendor/github.com/coredns/coredns/plugin/forward/persistent.go b/vendor/github.com/coredns/coredns/plugin/forward/persistent.go deleted file mode 100644 index 52bd2491..00000000 --- a/vendor/github.com/coredns/coredns/plugin/forward/persistent.go +++ /dev/null @@ -1,166 +0,0 @@ -package forward - -import ( - "crypto/tls" - "net" - "sort" - "time" - - "github.com/miekg/dns" -) - -// a persistConn hold the dns.Conn and the last used time. -type persistConn struct { - c *dns.Conn - used time.Time -} - -// transport hold the persistent cache. -type transport struct { - avgDialTime int64 // kind of average time of dial time - conns map[string][]*persistConn // Buckets for udp, tcp and tcp-tls. - expire time.Duration // After this duration a connection is expired. - addr string - tlsConfig *tls.Config - - dial chan string - yield chan *dns.Conn - ret chan *dns.Conn - stop chan bool -} - -func newTransport(addr string, tlsConfig *tls.Config) *transport { - t := &transport{ - avgDialTime: int64(defaultDialTimeout / 2), - conns: make(map[string][]*persistConn), - expire: defaultExpire, - addr: addr, - dial: make(chan string), - yield: make(chan *dns.Conn), - ret: make(chan *dns.Conn), - stop: make(chan bool), - } - return t -} - -// len returns the number of connection, used for metrics. Can only be safely -// used inside connManager() because of data races. -func (t *transport) len() int { - l := 0 - for _, conns := range t.conns { - l += len(conns) - } - return l -} - -// connManagers manages the persistent connection cache for UDP and TCP. -func (t *transport) connManager() { - ticker := time.NewTicker(t.expire) -Wait: - for { - select { - case proto := <-t.dial: - // take the last used conn - complexity O(1) - if stack := t.conns[proto]; len(stack) > 0 { - pc := stack[len(stack)-1] - if time.Since(pc.used) < t.expire { - // Found one, remove from pool and return this conn. - t.conns[proto] = stack[:len(stack)-1] - t.ret <- pc.c - continue Wait - } - // clear entire cache if the last conn is expired - t.conns[proto] = nil - // now, the connections being passed to closeConns() are not reachable from - // transport methods anymore. So, it's safe to close them in a separate goroutine - go closeConns(stack) - } - SocketGauge.WithLabelValues(t.addr).Set(float64(t.len())) - - t.ret <- nil - - case conn := <-t.yield: - - SocketGauge.WithLabelValues(t.addr).Set(float64(t.len() + 1)) - - // no proto here, infer from config and conn - if _, ok := conn.Conn.(*net.UDPConn); ok { - t.conns["udp"] = append(t.conns["udp"], &persistConn{conn, time.Now()}) - continue Wait - } - - if t.tlsConfig == nil { - t.conns["tcp"] = append(t.conns["tcp"], &persistConn{conn, time.Now()}) - continue Wait - } - - t.conns["tcp-tls"] = append(t.conns["tcp-tls"], &persistConn{conn, time.Now()}) - - case <-ticker.C: - t.cleanup(false) - - case <-t.stop: - t.cleanup(true) - close(t.ret) - return - } - } -} - -// closeConns closes connections. -func closeConns(conns []*persistConn) { - for _, pc := range conns { - pc.c.Close() - } -} - -// cleanup removes connections from cache. -func (t *transport) cleanup(all bool) { - staleTime := time.Now().Add(-t.expire) - for proto, stack := range t.conns { - if len(stack) == 0 { - continue - } - if all { - t.conns[proto] = nil - // now, the connections being passed to closeConns() are not reachable from - // transport methods anymore. So, it's safe to close them in a separate goroutine - go closeConns(stack) - continue - } - if stack[0].used.After(staleTime) { - continue - } - - // connections in stack are sorted by "used" - good := sort.Search(len(stack), func(i int) bool { - return stack[i].used.After(staleTime) - }) - t.conns[proto] = stack[good:] - // now, the connections being passed to closeConns() are not reachable from - // transport methods anymore. So, it's safe to close them in a separate goroutine - go closeConns(stack[:good]) - } -} - -// Yield return the connection to transport for reuse. -func (t *transport) Yield(c *dns.Conn) { t.yield <- c } - -// Start starts the transport's connection manager. -func (t *transport) Start() { go t.connManager() } - -// Stop stops the transport's connection manager. -func (t *transport) Stop() { close(t.stop) } - -// SetExpire sets the connection expire time in transport. -func (t *transport) SetExpire(expire time.Duration) { t.expire = expire } - -// SetTLSConfig sets the TLS config in transport. -func (t *transport) SetTLSConfig(cfg *tls.Config) { t.tlsConfig = cfg } - -const ( - defaultExpire = 10 * time.Second - minDialTimeout = 100 * time.Millisecond - maxDialTimeout = 30 * time.Second - defaultDialTimeout = 30 * time.Second -) diff --git a/vendor/github.com/coredns/coredns/plugin/forward/persistent_test.go b/vendor/github.com/coredns/coredns/plugin/forward/persistent_test.go deleted file mode 100644 index e046cf4d..00000000 --- a/vendor/github.com/coredns/coredns/plugin/forward/persistent_test.go +++ /dev/null @@ -1,161 +0,0 @@ -package forward - -import ( - "testing" - "time" - - "github.com/coredns/coredns/plugin/pkg/dnstest" - - "github.com/miekg/dns" -) - -func TestCached(t *testing.T) { - s := dnstest.NewServer(func(w dns.ResponseWriter, r *dns.Msg) { - ret := new(dns.Msg) - ret.SetReply(r) - w.WriteMsg(ret) - }) - defer s.Close() - - tr := newTransport(s.Addr, nil /* no TLS */) - tr.Start() - defer tr.Stop() - - c1, cache1, _ := tr.Dial("udp") - c2, cache2, _ := tr.Dial("udp") - - if cache1 || cache2 { - t.Errorf("Expected non-cached connection") - } - - tr.Yield(c1) - tr.Yield(c2) - c3, cached3, _ := tr.Dial("udp") - if !cached3 { - t.Error("Expected cached connection (c3)") - } - if c2 != c3 { - t.Error("Expected c2 == c3") - } - - tr.Yield(c3) - - // dial another protocol - c4, cached4, _ := tr.Dial("tcp") - if cached4 { - t.Errorf("Expected non-cached connection (c4)") - } - tr.Yield(c4) -} - -func TestCleanupByTimer(t *testing.T) { - s := dnstest.NewServer(func(w dns.ResponseWriter, r *dns.Msg) { - ret := new(dns.Msg) - ret.SetReply(r) - w.WriteMsg(ret) - }) - defer s.Close() - - tr := newTransport(s.Addr, nil /* no TLS */) - tr.SetExpire(100 * time.Millisecond) - tr.Start() - defer tr.Stop() - - c1, _, _ := tr.Dial("udp") - c2, _, _ := tr.Dial("udp") - tr.Yield(c1) - time.Sleep(10 * time.Millisecond) - tr.Yield(c2) - - time.Sleep(120 * time.Millisecond) - c3, cached, _ := tr.Dial("udp") - if cached { - t.Error("Expected non-cached connection (c3)") - } - tr.Yield(c3) - - time.Sleep(120 * time.Millisecond) - c4, cached, _ := tr.Dial("udp") - if cached { - t.Error("Expected non-cached connection (c4)") - } - tr.Yield(c4) -} - -func TestPartialCleanup(t *testing.T) { - s := dnstest.NewServer(func(w dns.ResponseWriter, r *dns.Msg) { - ret := new(dns.Msg) - ret.SetReply(r) - w.WriteMsg(ret) - }) - defer s.Close() - - tr := newTransport(s.Addr, nil /* no TLS */) - tr.SetExpire(100 * time.Millisecond) - tr.Start() - defer tr.Stop() - - c1, _, _ := tr.Dial("udp") - c2, _, _ := tr.Dial("udp") - c3, _, _ := tr.Dial("udp") - c4, _, _ := tr.Dial("udp") - c5, _, _ := tr.Dial("udp") - - tr.Yield(c1) - time.Sleep(10 * time.Millisecond) - tr.Yield(c2) - time.Sleep(10 * time.Millisecond) - tr.Yield(c3) - time.Sleep(50 * time.Millisecond) - tr.Yield(c4) - time.Sleep(10 * time.Millisecond) - tr.Yield(c5) - time.Sleep(40 * time.Millisecond) - - c6, _, _ := tr.Dial("udp") - if c6 != c5 { - t.Errorf("Expected c6 == c5") - } - c7, _, _ := tr.Dial("udp") - if c7 != c4 { - t.Errorf("Expected c7 == c4") - } - c8, cached, _ := tr.Dial("udp") - if cached { - t.Error("Expected non-cached connection (c8)") - } - - tr.Yield(c6) - tr.Yield(c7) - tr.Yield(c8) -} - -func TestCleanupAll(t *testing.T) { - s := dnstest.NewServer(func(w dns.ResponseWriter, r *dns.Msg) { - ret := new(dns.Msg) - ret.SetReply(r) - w.WriteMsg(ret) - }) - defer s.Close() - - tr := newTransport(s.Addr, nil /* no TLS */) - - c1, _ := dns.DialTimeout("udp", tr.addr, defaultDialTimeout) - c2, _ := dns.DialTimeout("udp", tr.addr, defaultDialTimeout) - c3, _ := dns.DialTimeout("udp", tr.addr, defaultDialTimeout) - - tr.conns["udp"] = []*persistConn{ - {c1, time.Now()}, - {c2, time.Now()}, - {c3, time.Now()}, - } - - if tr.len() != 3 { - t.Error("Expected 3 connections") - } - tr.cleanup(true) - - if tr.len() > 0 { - t.Error("Expected no cached connections") - } -} diff --git a/vendor/github.com/coredns/coredns/plugin/forward/policy.go b/vendor/github.com/coredns/coredns/plugin/forward/policy.go deleted file mode 100644 index 2066e131..00000000 --- a/vendor/github.com/coredns/coredns/plugin/forward/policy.go +++ /dev/null @@ -1,64 +0,0 @@ -package forward - -import ( - "math/rand" - "sync/atomic" -) - -// Policy defines a policy we use for selecting upstreams. -type Policy interface { - List([]*Proxy) []*Proxy - String() string -} - -// random is a policy that implements random upstream selection. -type random struct{} - -func (r *random) String() string { return "random" } - -func (r *random) List(p []*Proxy) []*Proxy { - switch len(p) { - case 1: - return p - case 2: - if rand.Int()%2 == 0 { - return []*Proxy{p[1], p[0]} // swap - } - return p - } - - perms := rand.Perm(len(p)) - rnd := make([]*Proxy, len(p)) - - for i, p1 := range perms { - rnd[i] = p[p1] - } - return rnd -} - -// roundRobin is a policy that selects hosts based on round robin ordering. -type roundRobin struct { - robin uint32 -} - -func (r *roundRobin) String() string { return "round_robin" } - -func (r *roundRobin) List(p []*Proxy) []*Proxy { - poolLen := uint32(len(p)) - i := atomic.AddUint32(&r.robin, 1) % poolLen - - robin := []*Proxy{p[i]} - robin = append(robin, p[:i]...) - robin = append(robin, p[i+1:]...) - - return robin -} - -// sequential is a policy that selects hosts based on sequential ordering. -type sequential struct{} - -func (r *sequential) String() string { return "sequential" } - -func (r *sequential) List(p []*Proxy) []*Proxy { - return p -} diff --git a/vendor/github.com/coredns/coredns/plugin/forward/protocol.go b/vendor/github.com/coredns/coredns/plugin/forward/protocol.go deleted file mode 100644 index 338b6011..00000000 --- a/vendor/github.com/coredns/coredns/plugin/forward/protocol.go +++ /dev/null @@ -1,30 +0,0 @@ -package forward - -// Copied from coredns/core/dnsserver/address.go - -import ( - "strings" -) - -// protocol returns the protocol of the string s. The second string returns s -// with the prefix chopped off. -func protocol(s string) (int, string) { - switch { - case strings.HasPrefix(s, _tls+"://"): - return TLS, s[len(_tls)+3:] - case strings.HasPrefix(s, _dns+"://"): - return DNS, s[len(_dns)+3:] - } - return DNS, s -} - -// Supported protocols. -const ( - DNS = iota + 1 - TLS -) - -const ( - _dns = "dns" - _tls = "tls" -) diff --git a/vendor/github.com/coredns/coredns/plugin/forward/proxy.go b/vendor/github.com/coredns/coredns/plugin/forward/proxy.go deleted file mode 100644 index a1fa7e6a..00000000 --- a/vendor/github.com/coredns/coredns/plugin/forward/proxy.go +++ /dev/null @@ -1,113 +0,0 @@ -package forward - -import ( - "crypto/tls" - "runtime" - "sync/atomic" - "time" - - "github.com/coredns/coredns/plugin/pkg/up" - - "github.com/miekg/dns" -) - -// Proxy defines an upstream host. -type Proxy struct { - avgRtt int64 - fails uint32 - - addr string - client *dns.Client - - // Connection caching - expire time.Duration - transport *transport - - // health checking - probe *up.Probe -} - -// NewProxy returns a new proxy. -func NewProxy(addr string, tlsConfig *tls.Config) *Proxy { - p := &Proxy{ - addr: addr, - fails: 0, - probe: up.New(), - transport: newTransport(addr, tlsConfig), - avgRtt: int64(timeout / 2), - } - p.client = dnsClient(tlsConfig) - runtime.SetFinalizer(p, (*Proxy).finalizer) - return p -} - -// Addr returns the address to forward to. -func (p *Proxy) Addr() (addr string) { return p.addr } - -// dnsClient returns a client used for health checking. -func dnsClient(tlsConfig *tls.Config) *dns.Client { - c := new(dns.Client) - c.Net = "udp" - // TODO(miek): this should be half of hcDuration? - c.ReadTimeout = 1 * time.Second - c.WriteTimeout = 1 * time.Second - - if tlsConfig != nil { - c.Net = "tcp-tls" - c.TLSConfig = tlsConfig - } - return c -} - -// SetTLSConfig sets the TLS config in the lower p.transport and in the healthchecking client. -func (p *Proxy) SetTLSConfig(cfg *tls.Config) { - p.transport.SetTLSConfig(cfg) - p.client = dnsClient(cfg) -} - -// IsTLS returns true if proxy uses tls. -func (p *Proxy) IsTLS() bool { return p.transport.tlsConfig != nil } - -// SetExpire sets the expire duration in the lower p.transport. -func (p *Proxy) SetExpire(expire time.Duration) { p.transport.SetExpire(expire) } - -// Dial connects to the host in p with the configured transport. -func (p *Proxy) Dial(proto string) (*dns.Conn, bool, error) { return p.transport.Dial(proto) } - -// Yield returns the connection to the pool. -func (p *Proxy) Yield(c *dns.Conn) { p.transport.Yield(c) } - -// Healthcheck kicks of a round of health checks for this proxy. -func (p *Proxy) Healthcheck() { p.probe.Do(p.Check) } - -// Down returns true if this proxy is down, i.e. has *more* fails than maxfails. -func (p *Proxy) Down(maxfails uint32) bool { - if maxfails == 0 { - return false - } - - fails := atomic.LoadUint32(&p.fails) - return fails > maxfails -} - -// close stops the health checking goroutine. -func (p *Proxy) close() { - p.probe.Stop() -} - -func (p *Proxy) finalizer() { - p.transport.Stop() -} - -// start starts the proxy's healthchecking. -func (p *Proxy) start(duration time.Duration) { - p.probe.Start(duration) - p.transport.Start() -} - -const ( - timeout = 2 * time.Second - maxTimeout = 2 * time.Second - minTimeout = 10 * time.Millisecond - hcDuration = 500 * time.Millisecond -) diff --git a/vendor/github.com/coredns/coredns/plugin/forward/proxy_test.go b/vendor/github.com/coredns/coredns/plugin/forward/proxy_test.go deleted file mode 100644 index 234458b6..00000000 --- a/vendor/github.com/coredns/coredns/plugin/forward/proxy_test.go +++ /dev/null @@ -1,95 +0,0 @@ -package forward - -import ( - "context" - "testing" - - "github.com/coredns/coredns/plugin/pkg/dnstest" - "github.com/coredns/coredns/plugin/test" - "github.com/coredns/coredns/request" - - "github.com/mholt/caddy" - "github.com/miekg/dns" -) - -func TestProxyClose(t *testing.T) { - s := dnstest.NewServer(func(w dns.ResponseWriter, r *dns.Msg) { - ret := new(dns.Msg) - ret.SetReply(r) - w.WriteMsg(ret) - }) - defer s.Close() - - req := new(dns.Msg) - req.SetQuestion("example.org.", dns.TypeA) - state := request.Request{W: &test.ResponseWriter{}, Req: req} - ctx := context.TODO() - - for i := 0; i < 100; i++ { - p := NewProxy(s.Addr, nil) - p.start(hcDuration) - - go func() { p.Connect(ctx, state, false, false) }() - go func() { p.Connect(ctx, state, true, false) }() - go func() { p.Connect(ctx, state, false, false) }() - go func() { p.Connect(ctx, state, true, false) }() - - p.close() - } -} - -func TestProxy(t *testing.T) { - s := dnstest.NewServer(func(w dns.ResponseWriter, r *dns.Msg) { - ret := new(dns.Msg) - ret.SetReply(r) - ret.Answer = append(ret.Answer, test.A("example.org. IN A 127.0.0.1")) - w.WriteMsg(ret) - }) - defer s.Close() - - c := caddy.NewTestController("dns", "forward . "+s.Addr) - f, err := parseForward(c) - if err != nil { - t.Errorf("Failed to create forwarder: %s", err) - } - f.OnStartup() - defer f.OnShutdown() - - m := new(dns.Msg) - m.SetQuestion("example.org.", dns.TypeA) - rec := dnstest.NewRecorder(&test.ResponseWriter{}) - - if _, err := f.ServeDNS(context.TODO(), rec, m); err != nil { - t.Fatal("Expected to receive reply, but didn't") - } - if x := rec.Msg.Answer[0].Header().Name; x != "example.org." { - t.Errorf("Expected %s, got %s", "example.org.", x) - } -} - -func TestProxyTLSFail(t *testing.T) { - // This is an udp/tcp test server, so we shouldn't reach it with TLS. - s := dnstest.NewServer(func(w dns.ResponseWriter, r *dns.Msg) { - ret := new(dns.Msg) - ret.SetReply(r) - ret.Answer = append(ret.Answer, test.A("example.org. IN A 127.0.0.1")) - w.WriteMsg(ret) - }) - defer s.Close() - - c := caddy.NewTestController("dns", "forward . tls://"+s.Addr) - f, err := parseForward(c) - if err != nil { - t.Errorf("Failed to create forwarder: %s", err) - } - f.OnStartup() - defer f.OnShutdown() - - m := new(dns.Msg) - m.SetQuestion("example.org.", dns.TypeA) - rec := dnstest.NewRecorder(&test.ResponseWriter{}) - - if _, err := f.ServeDNS(context.TODO(), rec, m); err == nil { - t.Fatal("Expected *not* to receive reply, but got one") - } -} diff --git a/vendor/github.com/coredns/coredns/plugin/forward/setup.go b/vendor/github.com/coredns/coredns/plugin/forward/setup.go deleted file mode 100644 index 7afafc8a..00000000 --- a/vendor/github.com/coredns/coredns/plugin/forward/setup.go +++ /dev/null @@ -1,241 +0,0 @@ -package forward - -import ( - "fmt" - "net" - "strconv" - "time" - - "github.com/coredns/coredns/core/dnsserver" - "github.com/coredns/coredns/plugin" - "github.com/coredns/coredns/plugin/metrics" - "github.com/coredns/coredns/plugin/pkg/dnsutil" - pkgtls "github.com/coredns/coredns/plugin/pkg/tls" - - "github.com/mholt/caddy" -) - -func init() { - caddy.RegisterPlugin("forward", caddy.Plugin{ - ServerType: "dns", - Action: setup, - }) -} - -func setup(c *caddy.Controller) error { - f, err := parseForward(c) - if err != nil { - return plugin.Error("forward", err) - } - if f.Len() > max { - return plugin.Error("forward", fmt.Errorf("more than %d TOs configured: %d", max, f.Len())) - } - - dnsserver.GetConfig(c).AddPlugin(func(next plugin.Handler) plugin.Handler { - f.Next = next - return f - }) - - c.OnStartup(func() error { - once.Do(func() { - metrics.MustRegister(c, RequestCount, RcodeCount, RequestDuration, HealthcheckFailureCount, SocketGauge) - }) - return f.OnStartup() - }) - - c.OnShutdown(func() error { - return f.OnShutdown() - }) - - return nil -} - -// OnStartup starts a goroutines for all proxies. -func (f *Forward) OnStartup() (err error) { - for _, p := range f.proxies { - p.start(f.hcInterval) - } - return nil -} - -// OnShutdown stops all configured proxies. -func (f *Forward) OnShutdown() error { - for _, p := range f.proxies { - p.close() - } - return nil -} - -// Close is a synonym for OnShutdown(). -func (f *Forward) Close() { f.OnShutdown() } - -func parseForward(c *caddy.Controller) (*Forward, error) { - f := New() - - protocols := map[int]int{} - - i := 0 - for c.Next() { - if i > 0 { - return nil, plugin.ErrOnce - } - i++ - - if !c.Args(&f.from) { - return f, c.ArgErr() - } - f.from = plugin.Host(f.from).Normalize() - - to := c.RemainingArgs() - if len(to) == 0 { - return f, c.ArgErr() - } - - // A bit fiddly, but first check if we've got protocols and if so add them back in when we create the proxies. - protocols = make(map[int]int) - for i := range to { - protocols[i], to[i] = protocol(to[i]) - } - - // If parseHostPortOrFile expands a file with a lot of nameserver our accounting in protocols doesn't make - // any sense anymore... For now: lets don't care. - toHosts, err := dnsutil.ParseHostPortOrFile(to...) - if err != nil { - return f, err - } - - for i, h := range toHosts { - // Double check the port, if e.g. is 53 and the transport is TLS make it 853. - // This can be somewhat annoying because you *can't* have TLS on port 53 then. - switch protocols[i] { - case TLS: - h1, p, err := net.SplitHostPort(h) - if err != nil { - break - } - - // This is more of a bug in dnsutil.ParseHostPortOrFile that defaults to - // 53 because it doesn't know about the tls:// // and friends (that should be fixed). Hence - // Fix the port number here, back to what the user intended. - if p == "53" { - h = net.JoinHostPort(h1, "853") - } - } - - // We can't set tlsConfig here, because we haven't parsed it yet. - // We set it below at the end of parseBlock, use nil now. - p := NewProxy(h, nil /* no TLS */) - f.proxies = append(f.proxies, p) - } - - for c.NextBlock() { - if err := parseBlock(c, f); err != nil { - return f, err - } - } - } - - if f.tlsServerName != "" { - f.tlsConfig.ServerName = f.tlsServerName - } - for i := range f.proxies { - // Only set this for proxies that need it. - if protocols[i] == TLS { - f.proxies[i].SetTLSConfig(f.tlsConfig) - } - f.proxies[i].SetExpire(f.expire) - } - return f, nil -} - -func parseBlock(c *caddy.Controller, f *Forward) error { - switch c.Val() { - case "except": - ignore := c.RemainingArgs() - if len(ignore) == 0 { - return c.ArgErr() - } - for i := 0; i < len(ignore); i++ { - ignore[i] = plugin.Host(ignore[i]).Normalize() - } - f.ignored = ignore - case "max_fails": - if !c.NextArg() { - return c.ArgErr() - } - n, err := strconv.Atoi(c.Val()) - if err != nil { - return err - } - if n < 0 { - return fmt.Errorf("max_fails can't be negative: %d", n) - } - f.maxfails = uint32(n) - case "health_check": - if !c.NextArg() { - return c.ArgErr() - } - dur, err := time.ParseDuration(c.Val()) - if err != nil { - return err - } - if dur < 0 { - return fmt.Errorf("health_check can't be negative: %d", dur) - } - f.hcInterval = dur - case "force_tcp": - if c.NextArg() { - return c.ArgErr() - } - f.forceTCP = true - case "tls": - args := c.RemainingArgs() - if len(args) > 3 { - return c.ArgErr() - } - - tlsConfig, err := pkgtls.NewTLSConfigFromArgs(args...) - if err != nil { - return err - } - f.tlsConfig = tlsConfig - case "tls_servername": - if !c.NextArg() { - return c.ArgErr() - } - f.tlsServerName = c.Val() - case "expire": - if !c.NextArg() { - return c.ArgErr() - } - dur, err := time.ParseDuration(c.Val()) - if err != nil { - return err - } - if dur < 0 { - return fmt.Errorf("expire can't be negative: %s", dur) - } - f.expire = dur - case "policy": - if !c.NextArg() { - return c.ArgErr() - } - switch x := c.Val(); x { - case "random": - f.p = &random{} - case "round_robin": - f.p = &roundRobin{} - case "sequential": - f.p = &sequential{} - default: - return c.Errf("unknown policy '%s'", x) - } - - default: - return c.Errf("unknown property '%s'", c.Val()) - } - - return nil -} - -const max = 15 // Maximum number of upstreams. diff --git a/vendor/github.com/coredns/coredns/plugin/forward/setup_policy_test.go b/vendor/github.com/coredns/coredns/plugin/forward/setup_policy_test.go deleted file mode 100644 index 986f3aa0..00000000 --- a/vendor/github.com/coredns/coredns/plugin/forward/setup_policy_test.go +++ /dev/null @@ -1,47 +0,0 @@ -package forward - -import ( - "strings" - "testing" - - "github.com/mholt/caddy" -) - -func TestSetupPolicy(t *testing.T) { - tests := []struct { - input string - shouldErr bool - expectedPolicy string - expectedErr string - }{ - // positive - {"forward . 127.0.0.1 {\npolicy random\n}\n", false, "random", ""}, - {"forward . 127.0.0.1 {\npolicy round_robin\n}\n", false, "round_robin", ""}, - {"forward . 127.0.0.1 {\npolicy sequential\n}\n", false, "sequential", ""}, - // negative - {"forward . 127.0.0.1 {\npolicy random2\n}\n", true, "random", "unknown policy"}, - } - - for i, test := range tests { - c := caddy.NewTestController("dns", test.input) - f, err := parseForward(c) - - if test.shouldErr && err == nil { - t.Errorf("Test %d: expected error but found %s for input %s", i, err, test.input) - } - - if err != nil { - if !test.shouldErr { - t.Errorf("Test %d: expected no error but found one for input %s, got: %v", i, test.input, err) - } - - if !strings.Contains(err.Error(), test.expectedErr) { - t.Errorf("Test %d: expected error to contain: %v, found error: %v, input: %s", i, test.expectedErr, err, test.input) - } - } - - if !test.shouldErr && f.p.String() != test.expectedPolicy { - t.Errorf("Test %d: expected: %s, got: %s", i, test.expectedPolicy, f.p.String()) - } - } -} diff --git a/vendor/github.com/coredns/coredns/plugin/forward/setup_test.go b/vendor/github.com/coredns/coredns/plugin/forward/setup_test.go deleted file mode 100644 index fba2359b..00000000 --- a/vendor/github.com/coredns/coredns/plugin/forward/setup_test.go +++ /dev/null @@ -1,118 +0,0 @@ -package forward - -import ( - "reflect" - "strings" - "testing" - - "github.com/mholt/caddy" -) - -func TestSetup(t *testing.T) { - tests := []struct { - input string - shouldErr bool - expectedFrom string - expectedIgnored []string - expectedFails uint32 - expectedForceTCP bool - expectedErr string - }{ - // positive - {"forward . 127.0.0.1", false, ".", nil, 2, false, ""}, - {"forward . 127.0.0.1 {\nexcept miek.nl\n}\n", false, ".", nil, 2, false, ""}, - {"forward . 127.0.0.1 {\nmax_fails 3\n}\n", false, ".", nil, 3, false, ""}, - {"forward . 127.0.0.1 {\nforce_tcp\n}\n", false, ".", nil, 2, true, ""}, - {"forward . 127.0.0.1:53", false, ".", nil, 2, false, ""}, - {"forward . 127.0.0.1:8080", false, ".", nil, 2, false, ""}, - {"forward . [::1]:53", false, ".", nil, 2, false, ""}, - {"forward . [2003::1]:53", false, ".", nil, 2, false, ""}, - // negative - {"forward . a27.0.0.1", true, "", nil, 0, false, "not an IP"}, - {"forward . 127.0.0.1 {\nblaatl\n}\n", true, "", nil, 0, false, "unknown property"}, - {`forward . ::1 - forward com ::2`, true, "", nil, 0, false, "plugin"}, - } - - for i, test := range tests { - c := caddy.NewTestController("dns", test.input) - f, err := parseForward(c) - - if test.shouldErr && err == nil { - t.Errorf("Test %d: expected error but found %s for input %s", i, err, test.input) - } - - if err != nil { - if !test.shouldErr { - t.Errorf("Test %d: expected no error but found one for input %s, got: %v", i, test.input, err) - } - - if !strings.Contains(err.Error(), test.expectedErr) { - t.Errorf("Test %d: expected error to contain: %v, found error: %v, input: %s", i, test.expectedErr, err, test.input) - } - } - - if !test.shouldErr && f.from != test.expectedFrom { - t.Errorf("Test %d: expected: %s, got: %s", i, test.expectedFrom, f.from) - } - if !test.shouldErr && test.expectedIgnored != nil { - if !reflect.DeepEqual(f.ignored, test.expectedIgnored) { - t.Errorf("Test %d: expected: %q, actual: %q", i, test.expectedIgnored, f.ignored) - } - } - if !test.shouldErr && f.maxfails != test.expectedFails { - t.Errorf("Test %d: expected: %d, got: %d", i, test.expectedFails, f.maxfails) - } - if !test.shouldErr && f.forceTCP != test.expectedForceTCP { - t.Errorf("Test %d: expected: %t, got: %t", i, test.expectedForceTCP, f.forceTCP) - } - } -} - -func TestSetupTLS(t *testing.T) { - tests := []struct { - input string - shouldErr bool - expectedServerName string - expectedErr string - }{ - // positive - {`forward . tls://127.0.0.1 { - tls_servername dns - }`, false, "dns", ""}, - {`forward . 127.0.0.1 { - tls_servername dns - }`, false, "", ""}, - {`forward . 127.0.0.1 { - tls - }`, false, "", ""}, - {`forward . tls://127.0.0.1`, false, "", ""}, - } - - for i, test := range tests { - c := caddy.NewTestController("dns", test.input) - f, err := parseForward(c) - - if test.shouldErr && err == nil { - t.Errorf("Test %d: expected error but found %s for input %s", i, err, test.input) - } - - if err != nil { - if !test.shouldErr { - t.Errorf("Test %d: expected no error but found one for input %s, got: %v", i, test.input, err) - } - - if !strings.Contains(err.Error(), test.expectedErr) { - t.Errorf("Test %d: expected error to contain: %v, found error: %v, input: %s", i, test.expectedErr, err, test.input) - } - } - - if !test.shouldErr && test.expectedServerName != "" && test.expectedServerName != f.tlsConfig.ServerName { - t.Errorf("Test %d: expected: %q, actual: %q", i, test.expectedServerName, f.tlsConfig.ServerName) - } - - if !test.shouldErr && test.expectedServerName != "" && test.expectedServerName != f.proxies[0].client.TLSConfig.ServerName { - t.Errorf("Test %d: expected: %q, actual: %q", i, test.expectedServerName, f.proxies[0].client.TLSConfig.ServerName) - } - } -} diff --git a/vendor/github.com/coredns/coredns/plugin/forward/truncated.go b/vendor/github.com/coredns/coredns/plugin/forward/truncated.go deleted file mode 100644 index f9bd464d..00000000 --- a/vendor/github.com/coredns/coredns/plugin/forward/truncated.go +++ /dev/null @@ -1,29 +0,0 @@ -package forward - -import ( - "github.com/coredns/coredns/request" - - "github.com/miekg/dns" -) - -// truncated looks at the error and if truncated return a nil errror -// and a possible reconstructed dns message if that was nil. -func truncated(state request.Request, ret *dns.Msg, err error) (*dns.Msg, error) { - // If you query for instance ANY isc.org; you get a truncated query back which miekg/dns fails to unpack - // because the RRs are not finished. The returned message can be useful or useless. Return the original - // query with some header bits set that they should retry with TCP. - if err != dns.ErrTruncated { - return ret, err - } - - // We may or may not have something sensible... if not reassemble something to send to the client. - m := ret - if ret == nil { - m = new(dns.Msg) - m.SetReply(state.Req) - m.Truncated = true - m.Authoritative = true - m.Rcode = dns.RcodeSuccess - } - return m, nil -} diff --git a/vendor/github.com/coredns/coredns/plugin/forward/truncated_test.go b/vendor/github.com/coredns/coredns/plugin/forward/truncated_test.go deleted file mode 100644 index 1c9e92a0..00000000 --- a/vendor/github.com/coredns/coredns/plugin/forward/truncated_test.go +++ /dev/null @@ -1,120 +0,0 @@ -package forward - -import ( - "sync/atomic" - "testing" - - "github.com/coredns/coredns/plugin/pkg/dnstest" - "github.com/coredns/coredns/plugin/test" - "github.com/coredns/coredns/request" - - "github.com/miekg/dns" -) - -func TestLookupTruncated(t *testing.T) { - i := int32(0) - s := dnstest.NewServer(func(w dns.ResponseWriter, r *dns.Msg) { - j := atomic.LoadInt32(&i) - atomic.AddInt32(&i, 1) - - if j == 0 { - ret := new(dns.Msg) - ret.SetReply(r) - ret.Truncated = true - ret.Answer = append(ret.Answer, test.A("example.org. IN A 127.0.0.1")) - w.WriteMsg(ret) - return - - } - - ret := new(dns.Msg) - ret.SetReply(r) - ret.Answer = append(ret.Answer, test.A("example.org. IN A 127.0.0.1")) - w.WriteMsg(ret) - }) - defer s.Close() - - p := NewProxy(s.Addr, nil /* no TLS */) - f := New() - f.SetProxy(p) - defer f.Close() - - state := request.Request{W: &test.ResponseWriter{}, Req: new(dns.Msg)} - - resp, err := f.Lookup(state, "example.org.", dns.TypeA) - if err != nil { - t.Fatal("Expected to receive reply, but didn't") - } - // expect answer with TC - if !resp.Truncated { - t.Error("Expected to receive reply with TC bit set, but didn't") - } - if len(resp.Answer) != 1 { - t.Error("Expected to receive original reply, but answer is missing") - } - - resp, err = f.Lookup(state, "example.org.", dns.TypeA) - if err != nil { - t.Fatal("Expected to receive reply, but didn't") - } - // expect answer without TC - if resp.Truncated { - t.Error("Expected to receive reply without TC bit set, but didn't") - } -} - -func TestForwardTruncated(t *testing.T) { - i := int32(0) - s := dnstest.NewServer(func(w dns.ResponseWriter, r *dns.Msg) { - j := atomic.LoadInt32(&i) - atomic.AddInt32(&i, 1) - - if j == 0 { - ret := new(dns.Msg) - ret.SetReply(r) - ret.Truncated = true - ret.Answer = append(ret.Answer, test.A("example.org. IN A 127.0.0.1")) - w.WriteMsg(ret) - return - - } - - ret := new(dns.Msg) - ret.SetReply(r) - ret.Answer = append(ret.Answer, test.A("example.org. IN A 127.0.0.1")) - w.WriteMsg(ret) - }) - defer s.Close() - - f := New() - - p1 := NewProxy(s.Addr, nil /* no TLS */) - f.SetProxy(p1) - p2 := NewProxy(s.Addr, nil /* no TLS */) - f.SetProxy(p2) - defer f.Close() - - state := request.Request{W: &test.ResponseWriter{}, Req: new(dns.Msg)} - state.Req.SetQuestion("example.org.", dns.TypeA) - resp, err := f.Forward(state) - if err != nil { - t.Fatal("Expected to receive reply, but didn't") - } - - // expect answer with TC - if !resp.Truncated { - t.Error("Expected to receive reply with TC bit set, but didn't") - } - if len(resp.Answer) != 1 { - t.Error("Expected to receive original reply, but answer is missing") - } - - resp, err = f.Forward(state) - if err != nil { - t.Fatal("Expected to receive reply, but didn't") - } - // expect answer without TC - if resp.Truncated { - t.Error("Expected to receive reply without TC bit set, but didn't") - } -} diff --git a/vendor/github.com/coredns/coredns/plugin/health/OWNERS b/vendor/github.com/coredns/coredns/plugin/health/OWNERS deleted file mode 100644 index d909fd45..00000000 --- a/vendor/github.com/coredns/coredns/plugin/health/OWNERS +++ /dev/null @@ -1,6 +0,0 @@ -reviewers: - - fastest963 - - miekg -approvers: - - fastest963 - - miekg diff --git a/vendor/github.com/coredns/coredns/plugin/health/README.md b/vendor/github.com/coredns/coredns/plugin/health/README.md deleted file mode 100644 index b7d4892b..00000000 --- a/vendor/github.com/coredns/coredns/plugin/health/README.md +++ /dev/null @@ -1,102 +0,0 @@ -# health - -## Name - -*health* - enables a health check endpoint. - -## Description - -By enabling *health* any plugin that implements -[healt.Healther interface](https://godoc.org/github.com/coredns/coredns/plugin/health#Healther) -will be queried for it's health. The combined health is exported, by default, on port 8080/health . - -## Syntax - -~~~ -health [ADDRESS] -~~~ - -Optionally takes an address; the default is `:8080`. The health path is fixed to `/health`. The -health endpoint returns a 200 response code and the word "OK" when this server is healthy. It returns -a 503. *health* periodically (1s) polls plugins that exports health information. If any of the -plugins signals that it is unhealthy, the server will go unhealthy too. Each plugin that supports -health checks has a section "Health" in their README. - -More options can be set with this extended syntax: - -~~~ -health [ADDRESS] { - lameduck DURATION -} -~~~ - -* Where `lameduck` will make the process unhealthy then *wait* for **DURATION** before the process - shuts down. - -If you have multiple Server Blocks and need to export health for each of the plugins, you must run -health endpoints on different ports: - -~~~ corefile -com { - whoami - health :8080 -} - -net { - erratic - health :8081 -} -~~~ - -Note that if you format this in one server block you will get an error on startup, that the second -server can't setup the health plugin (on the same port). - -~~~ txt -com net { - whoami - erratic - health :8080 -} -~~~~ - -## Plugins - -Any plugin that implements the Healther interface will be used to report health. - -## Metrics - -If monitoring is enabled (via the *prometheus* directive) then the following metric is exported: - -* `coredns_health_request_duration_seconds{}` - duration to process a /health query. As this should - be a local operation it should be fast. A (large) increases in this duration indicates the - CoreDNS process is having trouble keeping up with its query load. - -Note that this metric *does not* have a `server` label, because being overloaded is a symptom of -the running process, *not* a specific server. - -## Examples - -Run another health endpoint on http://localhost:8091. - -~~~ corefile -. { - health localhost:8091 -} -~~~ - -Set a lameduck duration of 1 second: - -~~~ corefile -. { - health localhost:8092 { - lameduck 1s - } -} -~~~ - -## Bugs - -When reloading, the Health handler is stopped before the new server instance is started. -If that new server fails to start, then the initial server instance is still available and DNS queries still served, -but Health handler stays down. -Health will not reply HTTP request until a successful reload or a complete restart of CoreDNS. diff --git a/vendor/github.com/coredns/coredns/plugin/health/health.go b/vendor/github.com/coredns/coredns/plugin/health/health.go deleted file mode 100644 index 7f35b070..00000000 --- a/vendor/github.com/coredns/coredns/plugin/health/health.go +++ /dev/null @@ -1,96 +0,0 @@ -// Package health implements an HTTP handler that responds to health checks. -package health - -import ( - "io" - "net" - "net/http" - "sync" - "time" - - clog "github.com/coredns/coredns/plugin/pkg/log" -) - -var log = clog.NewWithPlugin("health") - -// Health implements healthchecks by polling plugins. -type health struct { - Addr string - lameduck time.Duration - - ln net.Listener - nlSetup bool - mux *http.ServeMux - - // A slice of Healthers that the health plugin will poll every second for their health status. - h []Healther - sync.RWMutex - ok bool // ok is the global boolean indicating an all healthy plugin stack - - stop chan bool - pollstop chan bool -} - -// newHealth returns a new initialized health. -func newHealth(addr string) *health { - return &health{Addr: addr, stop: make(chan bool), pollstop: make(chan bool)} -} - -func (h *health) OnStartup() error { - if h.Addr == "" { - h.Addr = defAddr - } - - ln, err := net.Listen("tcp", h.Addr) - if err != nil { - return err - } - - h.ln = ln - h.mux = http.NewServeMux() - h.nlSetup = true - - h.mux.HandleFunc(path, func(w http.ResponseWriter, r *http.Request) { - if h.Ok() { - w.WriteHeader(http.StatusOK) - io.WriteString(w, ok) - return - } - w.WriteHeader(http.StatusServiceUnavailable) - }) - - go func() { http.Serve(h.ln, h.mux) }() - go func() { h.overloaded() }() - - return nil -} - -func (h *health) OnRestart() error { return h.OnFinalShutdown() } - -func (h *health) OnFinalShutdown() error { - if !h.nlSetup { - return nil - } - - // Stop polling plugins - h.pollstop <- true - // NACK health - h.SetOk(false) - - if h.lameduck > 0 { - log.Infof("Going into lameduck mode for %s", h.lameduck) - time.Sleep(h.lameduck) - } - - h.ln.Close() - - h.stop <- true - h.nlSetup = false - return nil -} - -const ( - ok = "OK" - defAddr = ":8080" - path = "/health" -) diff --git a/vendor/github.com/coredns/coredns/plugin/health/health_test.go b/vendor/github.com/coredns/coredns/plugin/health/health_test.go deleted file mode 100644 index acd06ea3..00000000 --- a/vendor/github.com/coredns/coredns/plugin/health/health_test.go +++ /dev/null @@ -1,77 +0,0 @@ -package health - -import ( - "fmt" - "io/ioutil" - "net/http" - "testing" - "time" - - "github.com/coredns/coredns/plugin/erratic" -) - -func TestHealth(t *testing.T) { - h := newHealth(":0") - h.h = append(h.h, &erratic.Erratic{}) - - if err := h.OnStartup(); err != nil { - t.Fatalf("Unable to startup the health server: %v", err) - } - defer h.OnFinalShutdown() - - go func() { - <-h.pollstop - return - }() - - // Reconstruct the http address based on the port allocated by operating system. - address := fmt.Sprintf("http://%s%s", h.ln.Addr().String(), path) - - // Nothing set should return unhealthy - response, err := http.Get(address) - if err != nil { - t.Fatalf("Unable to query %s: %v", address, err) - } - if response.StatusCode != 503 { - t.Errorf("Invalid status code: expecting '503', got '%d'", response.StatusCode) - } - response.Body.Close() - - h.poll() - - response, err = http.Get(address) - if err != nil { - t.Fatalf("Unable to query %s: %v", address, err) - } - if response.StatusCode != 200 { - t.Errorf("Invalid status code: expecting '200', got '%d'", response.StatusCode) - } - content, err := ioutil.ReadAll(response.Body) - if err != nil { - t.Fatalf("Unable to get response body from %s: %v", address, err) - } - response.Body.Close() - - if string(content) != ok { - t.Errorf("Invalid response body: expecting 'OK', got '%s'", string(content)) - } -} - -func TestHealthLameduck(t *testing.T) { - h := newHealth(":0") - h.lameduck = 250 * time.Millisecond - h.h = append(h.h, &erratic.Erratic{}) - - if err := h.OnStartup(); err != nil { - t.Fatalf("Unable to startup the health server: %v", err) - } - - // Both these things are behind a sync.Once, fake reading from the channels. - go func() { - <-h.pollstop - <-h.stop - return - }() - - h.OnFinalShutdown() -} diff --git a/vendor/github.com/coredns/coredns/plugin/health/healther.go b/vendor/github.com/coredns/coredns/plugin/health/healther.go deleted file mode 100644 index 8bb6c907..00000000 --- a/vendor/github.com/coredns/coredns/plugin/health/healther.go +++ /dev/null @@ -1,36 +0,0 @@ -package health - -// Healther interface needs to be implemented by each plugin willing to provide -// healthhceck information to the health plugin. Note this method should return -// quickly, i.e. just checking a boolean status, as it is called every second -// from the health plugin. -type Healther interface { - // Health returns a boolean indicating the health status of a plugin. - // False indicates unhealthy. - Health() bool -} - -// Ok returns the global health status of all plugin configured in this server. -func (h *health) Ok() bool { - h.RLock() - defer h.RUnlock() - return h.ok -} - -// SetOk sets the global health status of all plugin configured in this server. -func (h *health) SetOk(ok bool) { - h.Lock() - defer h.Unlock() - h.ok = ok -} - -// poll polls all healthers and sets the global state. -func (h *health) poll() { - for _, m := range h.h { - if !m.Health() { - h.SetOk(false) - return - } - } - h.SetOk(true) -} diff --git a/vendor/github.com/coredns/coredns/plugin/health/overloaded.go b/vendor/github.com/coredns/coredns/plugin/health/overloaded.go deleted file mode 100644 index 06b0b65e..00000000 --- a/vendor/github.com/coredns/coredns/plugin/health/overloaded.go +++ /dev/null @@ -1,52 +0,0 @@ -package health - -import ( - "net/http" - "sync" - "time" - - "github.com/coredns/coredns/plugin" - - "github.com/prometheus/client_golang/prometheus" -) - -// overloaded queries the health end point and updates a metrics showing how long it took. -func (h *health) overloaded() { - timeout := time.Duration(5 * time.Second) - client := http.Client{ - Timeout: timeout, - } - url := "http://" + h.Addr - tick := time.NewTicker(1 * time.Second) - - for { - select { - case <-tick.C: - start := time.Now() - resp, err := client.Get(url) - if err != nil { - HealthDuration.Observe(timeout.Seconds()) - continue - } - resp.Body.Close() - HealthDuration.Observe(time.Since(start).Seconds()) - - case <-h.stop: - tick.Stop() - return - } - } -} - -var ( - // HealthDuration is the metric used for exporting how fast we can retrieve the /health endpoint. - HealthDuration = prometheus.NewHistogram(prometheus.HistogramOpts{ - Namespace: plugin.Namespace, - Subsystem: "health", - Name: "request_duration_seconds", - Buckets: plugin.TimeBuckets, - Help: "Histogram of the time (in seconds) each request took.", - }) -) - -var once sync.Once diff --git a/vendor/github.com/coredns/coredns/plugin/health/setup.go b/vendor/github.com/coredns/coredns/plugin/health/setup.go deleted file mode 100644 index 0b90d829..00000000 --- a/vendor/github.com/coredns/coredns/plugin/health/setup.go +++ /dev/null @@ -1,105 +0,0 @@ -package health - -import ( - "fmt" - "net" - "time" - - "github.com/coredns/coredns/core/dnsserver" - "github.com/coredns/coredns/plugin" - "github.com/coredns/coredns/plugin/metrics" - - "github.com/mholt/caddy" -) - -func init() { - caddy.RegisterPlugin("health", caddy.Plugin{ - ServerType: "dns", - Action: setup, - }) -} - -func setup(c *caddy.Controller) error { - addr, lame, err := healthParse(c) - if err != nil { - return plugin.Error("health", err) - } - - h := newHealth(addr) - h.lameduck = lame - - c.OnStartup(func() error { - plugins := dnsserver.GetConfig(c).Handlers() - for _, p := range plugins { - if x, ok := p.(Healther); ok { - h.h = append(h.h, x) - } - } - return nil - }) - - c.OnStartup(func() error { - // Poll all middleware every second. - h.poll() - go func() { - for { - select { - case <-time.After(1 * time.Second): - h.poll() - case <-h.pollstop: - return - } - } - }() - return nil - }) - - c.OnStartup(func() error { - once.Do(func() { metrics.MustRegister(c, HealthDuration) }) - return nil - }) - - c.OnStartup(h.OnStartup) - c.OnRestart(h.OnRestart) - c.OnFinalShutdown(h.OnFinalShutdown) - - // Don't do AddPlugin, as health is not *really* a plugin just a separate webserver running. - return nil -} - -func healthParse(c *caddy.Controller) (string, time.Duration, error) { - addr := "" - dur := time.Duration(0) - for c.Next() { - args := c.RemainingArgs() - - switch len(args) { - case 0: - case 1: - addr = args[0] - if _, _, e := net.SplitHostPort(addr); e != nil { - return "", 0, e - } - default: - return "", 0, c.ArgErr() - } - - for c.NextBlock() { - switch c.Val() { - case "lameduck": - args := c.RemainingArgs() - if len(args) != 1 { - return "", 0, c.ArgErr() - } - l, err := time.ParseDuration(args[0]) - if err != nil { - return "", 0, fmt.Errorf("unable to parse lameduck duration value: '%v' : %v", args[0], err) - } - dur = l - default: - return "", 0, c.ArgErr() - } - } - } - return addr, dur, nil -} diff --git a/vendor/github.com/coredns/coredns/plugin/health/setup_test.go b/vendor/github.com/coredns/coredns/plugin/health/setup_test.go deleted file mode 100644 index 4db6fc77..00000000 --- a/vendor/github.com/coredns/coredns/plugin/health/setup_test.go +++ /dev/null @@ -1,45 +0,0 @@ -package health - -import ( - "testing" - - "github.com/mholt/caddy" -) - -func TestSetupHealth(t *testing.T) { - tests := []struct { - input string - shouldErr bool - }{ - {`health`, false}, - {`health localhost:1234`, false}, - {`health localhost:1234 { - lameduck 4s -}`, false}, - {`health bla:a`, false}, - - {`health bla`, true}, - {`health bla bla`, true}, - {`health localhost:1234 { - lameduck a -}`, true}, - {`health localhost:1234 { - lamedudk 4 -} `, true}, - } - - for i, test := range tests { - c := caddy.NewTestController("dns", test.input) - _, _, err := healthParse(c) - - if test.shouldErr && err == nil { - t.Errorf("Test %d: Expected error but found none for input %s", i, test.input) - } - - if err != nil { - if !test.shouldErr { - t.Errorf("Test %d: Expected no error but found one for input %s. Error was: %v", i, test.input, err) - } - } - } -} diff --git a/vendor/github.com/coredns/coredns/plugin/hosts/OWNERS b/vendor/github.com/coredns/coredns/plugin/hosts/OWNERS deleted file mode 100644 index ae6484f9..00000000 --- a/vendor/github.com/coredns/coredns/plugin/hosts/OWNERS +++ /dev/null @@ -1,6 +0,0 @@ -reviewers: - - johnbelamaric - - pmoroney -approvers: - - johnbelamaric - - pmoroney diff --git a/vendor/github.com/coredns/coredns/plugin/hosts/README.md b/vendor/github.com/coredns/coredns/plugin/hosts/README.md deleted file mode 100644 index b2a04154..00000000 --- a/vendor/github.com/coredns/coredns/plugin/hosts/README.md +++ /dev/null @@ -1,100 +0,0 @@ -# hosts - -## Name - -*hosts* - enables serving zone data from a `/etc/hosts` style file. - -## Description - -The hosts plugin is useful for serving zones from a `/etc/hosts` file. It serves from a preloaded -file that exists on disk. It checks the file for changes and updates the zones accordingly. This -plugin only supports A, AAAA, and PTR records. The hosts plugin can be used with readily -available hosts files that block access to advertising servers. - -This plugin can only be used once per Server Block. - -## The hosts file - -Commonly the entries are of the from `IP_address canonical_hostname [aliases...]` as explained by the hosts(5) man page. - -Examples: - -~~~ -# The following lines are desirable for IPv4 capable hosts -127.0.0.1 localhost -192.168.1.10 example.com example - -# The following lines are desirable for IPv6 capable hosts -::1 localhost ip6-localhost ip6-loopback -fdfc:a744:27b5:3b0e::1 example.com example -~~~ - -### PTR records - -PTR records for reverse lookups are generated automatically by CoreDNS (based on the hosts file entries) and cannot be created manually. - -## Syntax - -~~~ -hosts [FILE [ZONES...]] { - [INLINE] - fallthrough [ZONES...] -} -~~~ - -* **FILE** the hosts file to read and parse. If the path is relative the path from the *root* - directive will be prepended to it. Defaults to /etc/hosts if omitted. We scan the file for changes - every 5 seconds. -* **ZONES** zones it should be authoritative for. If empty, the zones from the configuration block - are used. -* **INLINE** the hosts file contents inlined in Corefile. If there are any lines before fallthrough - then all of them will be treated as the additional content for hosts file. The specified hosts - file path will still be read but entries will be overrided. -* `fallthrough` If zone matches and no record can be generated, pass request to the next plugin. - If **[ZONES...]** is omitted, then fallthrough happens for all zones for which the plugin - is authoritative. If specific zones are listed (for example `in-addr.arpa` and `ip6.arpa`), then only - queries for those zones will be subject to fallthrough. - -## Examples - -Load `/etc/hosts` file. - -~~~ corefile -. { - hosts -} -~~~ - -Load `example.hosts` file in the current directory. - -~~~ -. { - hosts example.hosts -} -~~~ - -Load example.hosts file and only serve example.org and example.net from it and fall through to the -next plugin if query doesn't match. - -~~~ -. { - hosts example.hosts example.org example.net { - fallthrough - } -} -~~~ - -Load hosts file inlined in Corefile. - -~~~ -. { - hosts example.hosts example.org { - 10.0.0.1 example.org - fallthrough - } -} -~~~ - -## See also - -The form of the entries in the `/etc/hosts` file are based on IETF [RFC 952](https://tools.ietf.org/html/rfc952) which was updated by IETF [RFC 1123](https://tools.ietf.org/html/rfc1123). diff --git a/vendor/github.com/coredns/coredns/plugin/hosts/hosts.go b/vendor/github.com/coredns/coredns/plugin/hosts/hosts.go deleted file mode 100644 index c9ce163c..00000000 --- a/vendor/github.com/coredns/coredns/plugin/hosts/hosts.go +++ /dev/null @@ -1,137 +0,0 @@ -package hosts - -import ( - "context" - "net" - - "github.com/coredns/coredns/plugin" - "github.com/coredns/coredns/plugin/pkg/dnsutil" - "github.com/coredns/coredns/plugin/pkg/fall" - "github.com/coredns/coredns/request" - - "github.com/miekg/dns" -) - -// Hosts is the plugin handler -type Hosts struct { - Next plugin.Handler - *Hostsfile - - Fall fall.F -} - -// ServeDNS implements the plugin.Handle interface. -func (h Hosts) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (int, error) { - state := request.Request{W: w, Req: r} - qname := state.Name() - - answers := []dns.RR{} - - zone := plugin.Zones(h.Origins).Matches(qname) - if zone == "" { - // PTR zones don't need to be specified in Origins - if state.Type() != "PTR" { - // If this doesn't match we need to fall through regardless of h.Fallthrough - return plugin.NextOrFailure(h.Name(), h.Next, ctx, w, r) - } - } - - switch state.QType() { - case dns.TypePTR: - names := h.LookupStaticAddr(dnsutil.ExtractAddressFromReverse(qname)) - if len(names) == 0 { - // If this doesn't match we need to fall through regardless of h.Fallthrough - return plugin.NextOrFailure(h.Name(), h.Next, ctx, w, r) - } - answers = h.ptr(qname, names) - case dns.TypeA: - ips := h.LookupStaticHostV4(qname) - answers = a(qname, ips) - case dns.TypeAAAA: - ips := h.LookupStaticHostV6(qname) - answers = aaaa(qname, ips) - } - - if len(answers) == 0 { - if h.Fall.Through(qname) { - return plugin.NextOrFailure(h.Name(), h.Next, ctx, w, r) - } - if !h.otherRecordsExist(state.QType(), qname) { - return dns.RcodeNameError, nil - } - } - - m := new(dns.Msg) - m.SetReply(r) - m.Authoritative, m.RecursionAvailable = true, true - m.Answer = answers - - state.SizeAndDo(m) - m, _ = state.Scrub(m) - w.WriteMsg(m) - return dns.RcodeSuccess, nil -} - -func (h Hosts) otherRecordsExist(qtype uint16, qname string) bool { - switch qtype { - case dns.TypeA: - if len(h.LookupStaticHostV6(qname)) > 0 { - return true - } - case dns.TypeAAAA: - if len(h.LookupStaticHostV4(qname)) > 0 { - return true - } - default: - if len(h.LookupStaticHostV4(qname)) > 0 { - return true - } - if len(h.LookupStaticHostV6(qname)) > 0 { - return true - } - } - return false - -} - -// Name implements the plugin.Handle interface. -func (h Hosts) Name() string { return "hosts" } - -// a takes a slice of net.IPs and returns a slice of A RRs. -func a(zone string, ips []net.IP) []dns.RR { - answers := []dns.RR{} - for _, ip := range ips { - r := new(dns.A) - r.Hdr = dns.RR_Header{Name: zone, Rrtype: dns.TypeA, - Class: dns.ClassINET, Ttl: 3600} - r.A = ip - answers = append(answers, r) - } - return answers -} - -// aaaa takes a slice of net.IPs and returns a slice of AAAA RRs. -func aaaa(zone string, ips []net.IP) []dns.RR { - answers := []dns.RR{} - for _, ip := range ips { - r := new(dns.AAAA) - r.Hdr = dns.RR_Header{Name: zone, Rrtype: dns.TypeAAAA, - Class: dns.ClassINET, Ttl: 3600} - r.AAAA = ip - answers = append(answers, r) - } - return answers -} - -// ptr takes a slice of host names and filters out the ones that aren't in Origins, if specified, and returns a slice of PTR RRs. -func (h *Hosts) ptr(zone string, names []string) []dns.RR { - answers := []dns.RR{} - for _, n := range names { - r := new(dns.PTR) - r.Hdr = dns.RR_Header{Name: zone, Rrtype: dns.TypePTR, - Class: dns.ClassINET, Ttl: 3600} - r.Ptr = dns.Fqdn(n) - answers = append(answers, r) - } - return answers -} diff --git a/vendor/github.com/coredns/coredns/plugin/hosts/hosts_test.go b/vendor/github.com/coredns/coredns/plugin/hosts/hosts_test.go deleted file mode 100644 index db387613..00000000 --- a/vendor/github.com/coredns/coredns/plugin/hosts/hosts_test.go +++ /dev/null @@ -1,74 +0,0 @@ -package hosts - -import ( - "context" - "strings" - "testing" - - "github.com/coredns/coredns/plugin/pkg/dnstest" - "github.com/coredns/coredns/plugin/test" - - "github.com/miekg/dns" -) - -func TestLookupA(t *testing.T) { - h := Hosts{Next: test.ErrorHandler(), Hostsfile: &Hostsfile{Origins: []string{"."}}} - h.parseReader(strings.NewReader(hostsExample)) - - ctx := context.TODO() - - for _, tc := range hostsTestCases { - m := tc.Msg() - - rec := dnstest.NewRecorder(&test.ResponseWriter{}) - _, err := h.ServeDNS(ctx, rec, m) - if err != nil { - t.Errorf("Expected no error, got %v\n", err) - return - } - - resp := rec.Msg - test.SortAndCheck(t, resp, tc) - } -} - -var hostsTestCases = []test.Case{ - { - Qname: "example.org.", Qtype: dns.TypeA, - Answer: []dns.RR{ - test.A("example.org. 3600 IN A 10.0.0.1"), - }, - }, - { - Qname: "localhost.", Qtype: dns.TypeAAAA, - Answer: []dns.RR{ - test.AAAA("localhost. 3600 IN AAAA ::1"), - }, - }, - { - Qname: "1.0.0.10.in-addr.arpa.", Qtype: dns.TypePTR, - Answer: []dns.RR{ - test.PTR("1.0.0.10.in-addr.arpa. 3600 PTR example.org."), - }, - }, - { - Qname: "1.0.0.127.in-addr.arpa.", Qtype: dns.TypePTR, - Answer: []dns.RR{ - test.PTR("1.0.0.127.in-addr.arpa. 3600 PTR localhost."), - test.PTR("1.0.0.127.in-addr.arpa. 3600 PTR localhost.domain."), - }, - }, - { - Qname: "example.org.", Qtype: dns.TypeAAAA, - Answer: []dns.RR{}, - }, - { - Qname: "example.org.", Qtype: dns.TypeMX, - Answer: []dns.RR{}, - }, -} - -const hostsExample = ` -127.0.0.1 localhost localhost.domain -::1 localhost localhost.domain -10.0.0.1 example.org` diff --git a/vendor/github.com/coredns/coredns/plugin/hosts/hostsfile.go b/vendor/github.com/coredns/coredns/plugin/hosts/hostsfile.go deleted file mode 100644 index 4b912b17..00000000 --- a/vendor/github.com/coredns/coredns/plugin/hosts/hostsfile.go +++ /dev/null @@ -1,228 +0,0 @@ -// Copyright 2009 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// This file is a modified version of net/hosts.go from the golang repo - -package hosts - -import ( - "bufio" - "bytes" - "io" - "net" - "os" - "strings" - "sync" - "time" - - "github.com/coredns/coredns/plugin" -) - -func parseLiteralIP(addr string) net.IP { - if i := strings.Index(addr, "%"); i >= 0 { - // discard ipv6 zone - addr = addr[0:i] - } - - return net.ParseIP(addr) -} - -func absDomainName(b string) string { - return plugin.Name(b).Normalize() -} - -type hostsMap struct { - // Key for the list of literal IP addresses must be a host - // name. It would be part of DNS labels, a FQDN or an absolute - // FQDN. - // For now the key is converted to lower case for convenience. - byNameV4 map[string][]net.IP - byNameV6 map[string][]net.IP - - // Key for the list of host names must be a literal IP address - // including IPv6 address with zone identifier. - // We don't support old-classful IP address notation. - byAddr map[string][]string -} - -func newHostsMap() *hostsMap { - return &hostsMap{ - byNameV4: make(map[string][]net.IP), - byNameV6: make(map[string][]net.IP), - byAddr: make(map[string][]string), - } -} - -// Hostsfile contains known host entries. -type Hostsfile struct { - sync.RWMutex - - // list of zones we are authoritive for - Origins []string - - // hosts maps for lookups - hmap *hostsMap - - // inline saves the hosts file that is inlined in a Corefile. - // We need a copy here as we want to use it to initialize the maps for parse. - inline *hostsMap - - // path to the hosts file - path string - - // mtime and size are only read and modified by a single goroutine - mtime time.Time - size int64 -} - -// readHosts determines if the cached data needs to be updated based on the size and modification time of the hostsfile. -func (h *Hostsfile) readHosts() { - file, err := os.Open(h.path) - if err != nil { - // We already log a warning if the file doesn't exist or can't be opened on setup. No need to return the error here. - return - } - defer file.Close() - - stat, err := file.Stat() - if err == nil && h.mtime.Equal(stat.ModTime()) && h.size == stat.Size() { - return - } - - h.Lock() - defer h.Unlock() - h.parseReader(file) - - // Update the data cache. - h.mtime = stat.ModTime() - h.size = stat.Size() -} - -func (h *Hostsfile) initInline(inline []string) { - if len(inline) == 0 { - return - } - - hmap := newHostsMap() - h.inline = h.parse(strings.NewReader(strings.Join(inline, "\n")), hmap) - *h.hmap = *h.inline -} - -func (h *Hostsfile) parseReader(r io.Reader) { - h.hmap = h.parse(r, h.inline) -} - -// Parse reads the hostsfile and populates the byName and byAddr maps. -func (h *Hostsfile) parse(r io.Reader, override *hostsMap) *hostsMap { - hmap := newHostsMap() - - scanner := bufio.NewScanner(r) - for scanner.Scan() { - line := scanner.Bytes() - if i := bytes.Index(line, []byte{'#'}); i >= 0 { - // Discard comments. - line = line[0:i] - } - f := bytes.Fields(line) - if len(f) < 2 { - continue - } - addr := parseLiteralIP(string(f[0])) - if addr == nil { - continue - } - ver := ipVersion(string(f[0])) - for i := 1; i < len(f); i++ { - name := absDomainName(string(f[i])) - if plugin.Zones(h.Origins).Matches(name) == "" { - // name is not in Origins - continue - } - switch ver { - case 4: - hmap.byNameV4[name] = append(hmap.byNameV4[name], addr) - case 6: - hmap.byNameV6[name] = append(hmap.byNameV6[name], addr) - default: - continue - } - hmap.byAddr[addr.String()] = append(hmap.byAddr[addr.String()], name) - } - } - - if override == nil { - return hmap - } - - for name := range override.byNameV4 { - hmap.byNameV4[name] = append(hmap.byNameV4[name], override.byNameV4[name]...) - } - for name := range override.byNameV4 { - hmap.byNameV6[name] = append(hmap.byNameV6[name], override.byNameV6[name]...) - } - for addr := range override.byAddr { - hmap.byAddr[addr] = append(hmap.byAddr[addr], override.byAddr[addr]...) - } - - return hmap -} - -// ipVersion returns what IP version was used textually -func ipVersion(s string) int { - for i := 0; i < len(s); i++ { - switch s[i] { - case '.': - return 4 - case ':': - return 6 - } - } - return 0 -} - -// LookupStaticHostV4 looks up the IPv4 addresses for the given host from the hosts file. -func (h *Hostsfile) LookupStaticHostV4(host string) []net.IP { - h.RLock() - defer h.RUnlock() - if len(h.hmap.byNameV4) != 0 { - if ips, ok := h.hmap.byNameV4[absDomainName(host)]; ok { - ipsCp := make([]net.IP, len(ips)) - copy(ipsCp, ips) - return ipsCp - } - } - return nil -} - -// LookupStaticHostV6 looks up the IPv6 addresses for the given host from the hosts file. -func (h *Hostsfile) LookupStaticHostV6(host string) []net.IP { - h.RLock() - defer h.RUnlock() - if len(h.hmap.byNameV6) != 0 { - if ips, ok := h.hmap.byNameV6[absDomainName(host)]; ok { - ipsCp := make([]net.IP, len(ips)) - copy(ipsCp, ips) - return ipsCp - } - } - return nil -} - -// LookupStaticAddr looks up the hosts for the given address from the hosts file. -func (h *Hostsfile) LookupStaticAddr(addr string) []string { - h.RLock() - defer h.RUnlock() - addr = parseLiteralIP(addr).String() - if addr == "" { - return nil - } - if len(h.hmap.byAddr) != 0 { - if hosts, ok := h.hmap.byAddr[addr]; ok { - hostsCp := make([]string, len(hosts)) - copy(hostsCp, hosts) - return hostsCp - } - } - return nil -} diff --git a/vendor/github.com/coredns/coredns/plugin/hosts/hostsfile_test.go b/vendor/github.com/coredns/coredns/plugin/hosts/hostsfile_test.go deleted file mode 100644 index cb923ab6..00000000 --- a/vendor/github.com/coredns/coredns/plugin/hosts/hostsfile_test.go +++ /dev/null @@ -1,238 +0,0 @@ -// Copyright 2009 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package hosts - -import ( - "net" - "reflect" - "strings" - "testing" -) - -func testHostsfile(file string) *Hostsfile { - h := &Hostsfile{Origins: []string{"."}} - h.parseReader(strings.NewReader(file)) - return h -} - -type staticHostEntry struct { - in string - v4 []string - v6 []string -} - -var ( - hosts = `255.255.255.255 broadcasthost - 127.0.0.2 odin - 127.0.0.3 odin # inline comment - ::2 odin - 127.1.1.1 thor - # aliases - 127.1.1.2 ullr ullrhost - fe80::1%lo0 localhost - # Bogus entries that must be ignored. - 123.123.123 loki - 321.321.321.321` - singlelinehosts = `127.0.0.2 odin` - ipv4hosts = `# See https://tools.ietf.org/html/rfc1123. - # - # The literal IPv4 address parser in the net package is a relaxed - # one. It may accept a literal IPv4 address in dotted-decimal notation - # with leading zeros such as "001.2.003.4". - - # internet address and host name - 127.0.0.1 localhost # inline comment separated by tab - 127.000.000.002 localhost # inline comment separated by space - - # internet address, host name and aliases - 127.000.000.003 localhost localhost.localdomain` - ipv6hosts = `# See https://tools.ietf.org/html/rfc5952, https://tools.ietf.org/html/rfc4007. - - # internet address and host name - ::1 localhost # inline comment separated by tab - fe80:0000:0000:0000:0000:0000:0000:0001 localhost # inline comment separated by space - - # internet address with zone identifier and host name - fe80:0000:0000:0000:0000:0000:0000:0002%lo0 localhost - - # internet address, host name and aliases - fe80::3%lo0 localhost localhost.localdomain` - casehosts = `127.0.0.1 PreserveMe PreserveMe.local - ::1 PreserveMe PreserveMe.local` -) - -var lookupStaticHostTests = []struct { - file string - ents []staticHostEntry -}{ - { - hosts, - []staticHostEntry{ - {"odin", []string{"127.0.0.2", "127.0.0.3"}, []string{"::2"}}, - {"thor", []string{"127.1.1.1"}, []string{}}, - {"ullr", []string{"127.1.1.2"}, []string{}}, - {"ullrhost", []string{"127.1.1.2"}, []string{}}, - {"localhost", []string{}, []string{"fe80::1"}}, - }, - }, - { - singlelinehosts, // see golang.org/issue/6646 - []staticHostEntry{ - {"odin", []string{"127.0.0.2"}, []string{}}, - }, - }, - { - ipv4hosts, - []staticHostEntry{ - {"localhost", []string{"127.0.0.1", "127.0.0.2", "127.0.0.3"}, []string{}}, - {"localhost.localdomain", []string{"127.0.0.3"}, []string{}}, - }, - }, - { - ipv6hosts, - []staticHostEntry{ - {"localhost", []string{}, []string{"::1", "fe80::1", "fe80::2", "fe80::3"}}, - {"localhost.localdomain", []string{}, []string{"fe80::3"}}, - }, - }, - { - casehosts, - []staticHostEntry{ - {"PreserveMe", []string{"127.0.0.1"}, []string{"::1"}}, - {"PreserveMe.local", []string{"127.0.0.1"}, []string{"::1"}}, - }, - }, -} - -func TestLookupStaticHost(t *testing.T) { - - for _, tt := range lookupStaticHostTests { - h := testHostsfile(tt.file) - for _, ent := range tt.ents { - testStaticHost(t, ent, h) - } - } -} - -func testStaticHost(t *testing.T, ent staticHostEntry, h *Hostsfile) { - ins := []string{ent.in, absDomainName(ent.in), strings.ToLower(ent.in), strings.ToUpper(ent.in)} - for k, in := range ins { - addrsV4 := h.LookupStaticHostV4(in) - if len(addrsV4) != len(ent.v4) { - t.Fatalf("%d, lookupStaticHostV4(%s) = %v; want %v", k, in, addrsV4, ent.v4) - } - for i, v4 := range addrsV4 { - if v4.String() != ent.v4[i] { - t.Fatalf("%d, lookupStaticHostV4(%s) = %v; want %v", k, in, addrsV4, ent.v4) - } - } - addrsV6 := h.LookupStaticHostV6(in) - if len(addrsV6) != len(ent.v6) { - t.Fatalf("%d, lookupStaticHostV6(%s) = %v; want %v", k, in, addrsV6, ent.v6) - } - for i, v6 := range addrsV6 { - if v6.String() != ent.v6[i] { - t.Fatalf("%d, lookupStaticHostV6(%s) = %v; want %v", k, in, addrsV6, ent.v6) - } - } - } -} - -type staticIPEntry struct { - in string - out []string -} - -var lookupStaticAddrTests = []struct { - file string - ents []staticIPEntry -}{ - { - hosts, - []staticIPEntry{ - {"255.255.255.255", []string{"broadcasthost"}}, - {"127.0.0.2", []string{"odin"}}, - {"127.0.0.3", []string{"odin"}}, - {"::2", []string{"odin"}}, - {"127.1.1.1", []string{"thor"}}, - {"127.1.1.2", []string{"ullr", "ullrhost"}}, - {"fe80::1", []string{"localhost"}}, - }, - }, - { - singlelinehosts, // see golang.org/issue/6646 - []staticIPEntry{ - {"127.0.0.2", []string{"odin"}}, - }, - }, - { - ipv4hosts, // see golang.org/issue/8996 - []staticIPEntry{ - {"127.0.0.1", []string{"localhost"}}, - {"127.0.0.2", []string{"localhost"}}, - {"127.0.0.3", []string{"localhost", "localhost.localdomain"}}, - }, - }, - { - ipv6hosts, // see golang.org/issue/8996 - []staticIPEntry{ - {"::1", []string{"localhost"}}, - {"fe80::1", []string{"localhost"}}, - {"fe80::2", []string{"localhost"}}, - {"fe80::3", []string{"localhost", "localhost.localdomain"}}, - }, - }, - { - casehosts, // see golang.org/issue/12806 - []staticIPEntry{ - {"127.0.0.1", []string{"PreserveMe", "PreserveMe.local"}}, - {"::1", []string{"PreserveMe", "PreserveMe.local"}}, - }, - }, -} - -func TestLookupStaticAddr(t *testing.T) { - for _, tt := range lookupStaticAddrTests { - h := testHostsfile(tt.file) - for _, ent := range tt.ents { - testStaticAddr(t, ent, h) - } - } -} - -func testStaticAddr(t *testing.T, ent staticIPEntry, h *Hostsfile) { - hosts := h.LookupStaticAddr(ent.in) - for i := range ent.out { - ent.out[i] = absDomainName(ent.out[i]) - } - if !reflect.DeepEqual(hosts, ent.out) { - t.Errorf("%s, lookupStaticAddr(%s) = %v; want %v", h.path, ent.in, hosts, h) - } -} - -func TestHostCacheModification(t *testing.T) { - // Ensure that programs can't modify the internals of the host cache. - // See https://github.com/golang/go/issues/14212. - - h := testHostsfile(ipv4hosts) - ent := staticHostEntry{"localhost", []string{"127.0.0.1", "127.0.0.2", "127.0.0.3"}, []string{}} - testStaticHost(t, ent, h) - // Modify the addresses return by lookupStaticHost. - addrs := h.LookupStaticHostV6(ent.in) - for i := range addrs { - addrs[i] = net.IPv4zero - } - testStaticHost(t, ent, h) - - h = testHostsfile(ipv6hosts) - entip := staticIPEntry{"::1", []string{"localhost"}} - testStaticAddr(t, entip, h) - // Modify the hosts return by lookupStaticAddr. - hosts := h.LookupStaticAddr(entip.in) - for i := range hosts { - hosts[i] += "junk" - } - testStaticAddr(t, entip, h) -} diff --git a/vendor/github.com/coredns/coredns/plugin/hosts/setup.go b/vendor/github.com/coredns/coredns/plugin/hosts/setup.go deleted file mode 100644 index ed5cd5c7..00000000 --- a/vendor/github.com/coredns/coredns/plugin/hosts/setup.go +++ /dev/null @@ -1,131 +0,0 @@ -package hosts - -import ( - "os" - "path" - "strings" - "time" - - "github.com/coredns/coredns/core/dnsserver" - "github.com/coredns/coredns/plugin" - clog "github.com/coredns/coredns/plugin/pkg/log" - - "github.com/mholt/caddy" -) - -var log = clog.NewWithPlugin("hosts") - -func init() { - caddy.RegisterPlugin("hosts", caddy.Plugin{ - ServerType: "dns", - Action: setup, - }) -} - -func setup(c *caddy.Controller) error { - h, err := hostsParse(c) - if err != nil { - return plugin.Error("hosts", err) - } - - parseChan := make(chan bool) - - c.OnStartup(func() error { - h.readHosts() - - go func() { - ticker := time.NewTicker(5 * time.Second) - for { - select { - case <-parseChan: - return - case <-ticker.C: - h.readHosts() - } - } - }() - return nil - }) - - c.OnShutdown(func() error { - close(parseChan) - return nil - }) - - dnsserver.GetConfig(c).AddPlugin(func(next plugin.Handler) plugin.Handler { - h.Next = next - return h - }) - - return nil -} - -func hostsParse(c *caddy.Controller) (Hosts, error) { - var h = Hosts{ - Hostsfile: &Hostsfile{ - path: "/etc/hosts", - hmap: newHostsMap(), - }, - } - - config := dnsserver.GetConfig(c) - - inline := []string{} - i := 0 - for c.Next() { - if i > 0 { - return h, plugin.ErrOnce - } - i++ - - args := c.RemainingArgs() - if len(args) >= 1 { - h.path = args[0] - args = args[1:] - - if !path.IsAbs(h.path) && config.Root != "" { - h.path = path.Join(config.Root, h.path) - } - s, err := os.Stat(h.path) - if err != nil { - if os.IsNotExist(err) { - log.Warningf("File does not exist: %s", h.path) - } else { - return h, c.Errf("unable to access hosts file '%s': %v", h.path, err) - } - } - if s != nil && s.IsDir() { - log.Warningf("Hosts file %q is a directory", h.path) - } - } - - origins := make([]string, len(c.ServerBlockKeys)) - copy(origins, c.ServerBlockKeys) - if len(args) > 0 { - origins = args - } - - for i := range origins { - origins[i] = plugin.Host(origins[i]).Normalize() - } - h.Origins = origins - - for c.NextBlock() { - switch c.Val() { - case "fallthrough": - h.Fall.SetZonesFromArgs(c.RemainingArgs()) - default: - if len(h.Fall.Zones) == 0 { - line := strings.Join(append([]string{c.Val()}, c.RemainingArgs()...), " ") - inline = append(inline, line) - continue - } - return h, c.Errf("unknown property '%s'", c.Val()) - } - } - } - - h.initInline(inline) - - return h, nil -} diff --git a/vendor/github.com/coredns/coredns/plugin/hosts/setup_test.go b/vendor/github.com/coredns/coredns/plugin/hosts/setup_test.go deleted file mode 100644 index 78b1cff8..00000000 --- a/vendor/github.com/coredns/coredns/plugin/hosts/setup_test.go +++ /dev/null @@ -1,170 +0,0 @@ -package hosts - -import ( - "testing" - - "github.com/coredns/coredns/plugin/pkg/fall" - - "github.com/mholt/caddy" -) - -func TestHostsParse(t *testing.T) { - tests := []struct { - inputFileRules string - shouldErr bool - expectedPath string - expectedOrigins []string - expectedFallthrough fall.F - }{ - { - `hosts -`, - false, "/etc/hosts", nil, fall.Zero, - }, - { - `hosts /tmp`, - false, "/tmp", nil, fall.Zero, - }, - { - `hosts /etc/hosts miek.nl.`, - false, "/etc/hosts", []string{"miek.nl."}, fall.Zero, - }, - { - `hosts /etc/hosts miek.nl. pun.gent.`, - false, "/etc/hosts", []string{"miek.nl.", "pun.gent."}, fall.Zero, - }, - { - `hosts { - fallthrough - }`, - false, "/etc/hosts", nil, fall.Root, - }, - { - `hosts /tmp { - fallthrough - }`, - false, "/tmp", nil, fall.Root, - }, - { - `hosts /etc/hosts miek.nl. { - fallthrough - }`, - false, "/etc/hosts", []string{"miek.nl."}, fall.Root, - }, - { - `hosts /etc/hosts miek.nl 10.0.0.9/8 { - fallthrough - }`, - false, "/etc/hosts", []string{"miek.nl.", "10.in-addr.arpa."}, fall.Root, - }, - { - `hosts /etc/hosts { - fallthrough - } - hosts /etc/hosts { - fallthrough - }`, - true, "/etc/hosts", nil, fall.Root, - }, - } - - for i, test := range tests { - c := caddy.NewTestController("dns", test.inputFileRules) - h, err := hostsParse(c) - - if err == nil && test.shouldErr { - t.Fatalf("Test %d expected errors, but got no error", i) - } else if err != nil && !test.shouldErr { - t.Fatalf("Test %d expected no errors, but got '%v'", i, err) - } else if !test.shouldErr { - if h.path != test.expectedPath { - t.Fatalf("Test %d expected %v, got %v", i, test.expectedPath, h.path) - } - } else { - if !h.Fall.Equal(test.expectedFallthrough) { - t.Fatalf("Test %d expected fallthrough of %v, got %v", i, test.expectedFallthrough, h.Fall) - } - if len(h.Origins) != len(test.expectedOrigins) { - t.Fatalf("Test %d expected %v, got %v", i, test.expectedOrigins, h.Origins) - } - for j, name := range test.expectedOrigins { - if h.Origins[j] != name { - t.Fatalf("Test %d expected %v for %d th zone, got %v", i, name, j, h.Origins[j]) - } - } - } - } -} - -func TestHostsInlineParse(t *testing.T) { - tests := []struct { - inputFileRules string - shouldErr bool - expectedbyAddr map[string][]string - expectedFallthrough fall.F - }{ - { - `hosts highly_unlikely_to_exist_hosts_file example.org { - 10.0.0.1 example.org - fallthrough - }`, - false, - map[string][]string{ - `10.0.0.1`: { - `example.org.`, - }, - }, - fall.Root, - }, - { - `hosts highly_unlikely_to_exist_hosts_file example.org { - 10.0.0.1 example.org - }`, - false, - map[string][]string{ - `10.0.0.1`: { - `example.org.`, - }, - }, - fall.Zero, - }, - { - `hosts highly_unlikely_to_exist_hosts_file example.org { - fallthrough - 10.0.0.1 example.org - }`, - true, - map[string][]string{}, - fall.Root, - }, - } - - for i, test := range tests { - c := caddy.NewTestController("dns", test.inputFileRules) - h, err := hostsParse(c) - if err == nil && test.shouldErr { - t.Fatalf("Test %d expected errors, but got no error", i) - } else if err != nil && !test.shouldErr { - t.Fatalf("Test %d expected no errors, but got '%v'", i, err) - } else if !test.shouldErr { - if !h.Fall.Equal(test.expectedFallthrough) { - t.Fatalf("Test %d expected fallthrough of %v, got %v", i, test.expectedFallthrough, h.Fall) - } - for k, expectedVal := range test.expectedbyAddr { - if val, ok := h.hmap.byAddr[k]; !ok { - t.Fatalf("Test %d expected %v, got no entry", i, k) - } else { - if len(expectedVal) != len(val) { - t.Fatalf("Test %d expected %v records for %v, got %v", i, len(expectedVal), k, len(val)) - } - for j := range expectedVal { - if expectedVal[j] != val[j] { - t.Fatalf("Test %d expected %v for %v, got %v", i, expectedVal[j], j, val[j]) - } - } - } - } - } - } - -} diff --git a/vendor/github.com/coredns/coredns/plugin/kubernetes/OWNERS b/vendor/github.com/coredns/coredns/plugin/kubernetes/OWNERS deleted file mode 100644 index c477bfa3..00000000 --- a/vendor/github.com/coredns/coredns/plugin/kubernetes/OWNERS +++ /dev/null @@ -1,16 +0,0 @@ -reviewers: - - bradbeam - - chrisohaver - - fturib - - johnbelamaric - - miekg - - rajansandeep - - yongtang -approvers: - - bradbeam - - chrisohaver - - fturib - - johnbelamaric - - miekg - - rajansandeep - - yongtang diff --git a/vendor/github.com/coredns/coredns/plugin/kubernetes/README.md b/vendor/github.com/coredns/coredns/plugin/kubernetes/README.md deleted file mode 100644 index 128e843e..00000000 --- a/vendor/github.com/coredns/coredns/plugin/kubernetes/README.md +++ /dev/null @@ -1,216 +0,0 @@ -# kubernetes - -## Name - -*kubernetes* - enables the reading zone data from a Kubernetes cluster. - -## Description - -It implements the [Kubernetes DNS-Based Service Discovery -Specification](https://github.com/kubernetes/dns/blob/master/docs/specification.md). - -CoreDNS running the kubernetes plugin can be used as a replacement of kube-dns in a kubernetes -cluster. See the [deployment](https://github.com/coredns/deployment) repository for details on [how -to deploy CoreDNS in Kubernetes](https://github.com/coredns/deployment/tree/master/kubernetes). - -[stubDomains and upstreamNameservers](http://blog.kubernetes.io/2017/04/configuring-private-dns-zones-upstream-nameservers-kubernetes.html) -are implemented via the *proxy* plugin and kubernetes *upstream*. See example below. - -This plugin can only be used once per Server Block. - -## Syntax - -~~~ -kubernetes [ZONES...] -~~~ - -With only the directive specified, the *kubernetes* plugin will default to the zone specified in -the server's block. It will handle all queries in that zone and connect to Kubernetes in-cluster. It -will not provide PTR records for services, or A records for pods. If **ZONES** is used it specifies -all the zones the plugin should be authoritative for. - -``` -kubernetes [ZONES...] { - resyncperiod DURATION - endpoint URL [URL...] - tls CERT KEY CACERT - namespaces NAMESPACE... - labels EXPRESSION - pods POD-MODE - endpoint_pod_names - upstream [ADDRESS...] - ttl TTL - transfer to ADDRESS... - fallthrough [ZONES...] -} -``` - -* `resyncperiod` specifies the Kubernetes data API **DURATION** period. -* `endpoint` specifies the **URL** for a remote k8s API endpoint. - If omitted, it will connect to k8s in-cluster using the cluster service account. - Multiple k8s API endpoints could be specified: - `endpoint http://k8s-endpoint1:8080 http://k8s-endpoint2:8080`. CoreDNS - will automatically perform a healthcheck and proxy to the healthy k8s API endpoint. -* `tls` **CERT** **KEY** **CACERT** are the TLS cert, key and the CA cert file names for remote k8s connection. - This option is ignored if connecting in-cluster (i.e. endpoint is not specified). -* `namespaces` **NAMESPACE [NAMESPACE...]**, only exposes the k8s namespaces listed. - If this option is omitted all namespaces are exposed -* `labels` **EXPRESSION** only exposes the records for Kubernetes objects that match this label selector. - The label selector syntax is described in the - [Kubernetes User Guide - Labels](http://kubernetes.io/docs/user-guide/labels/). An example that - only exposes objects labeled as "application=nginx" in the "staging" or "qa" environments, would - use: `labels environment in (staging, qa),application=nginx`. -* `pods` **POD-MODE** sets the mode for handling IP-based pod A records, e.g. - `1-2-3-4.ns.pod.cluster.local. in A 1.2.3.4`. - This option is provided to facilitate use of SSL certs when connecting directly to pods. Valid - values for **POD-MODE**: - - * `disabled`: Default. Do not process pod requests, always returning `NXDOMAIN` - * `insecure`: Always return an A record with IP from request (without checking k8s). This option - is is vulnerable to abuse if used maliciously in conjunction with wildcard SSL certs. This - option is provided for backward compatibility with kube-dns. - * `verified`: Return an A record if there exists a pod in same namespace with matching IP. This - option requires substantially more memory than in insecure mode, since it will maintain a watch - on all pods. - -* `endpoint_pod_names` uses the pod name of the pod targeted by the endpoint as - the endpoint name in A records, e.g. - `endpoint-name.my-service.namespace.svc.cluster.local. in A 1.2.3.4` - By default, the endpoint-name name selection is as follows: Use the hostname - of the endpoint, or if hostname is not set, use the dashed form of the endpoint - IP address (e.g. `1-2-3-4.my-service.namespace.svc.cluster.local.`) - If this directive is included, then name selection for endpoints changes as - follows: Use the hostname of the endpoint, or if hostname is not set, use the - pod name of the pod targeted by the endpoint. If there is no pod targeted by - the endpoint, use the dashed IP address form. -* `upstream` [**ADDRESS**...] defines the upstream resolvers used for resolving services - that point to external hosts (aka External Services aka CNAMEs). If no **ADDRESS** is given, CoreDNS - will resolve External Services against itself. **ADDRESS** can be an IP, an IP:port, or a path - to a file structured like resolv.conf. -* `ttl` allows you to set a custom TTL for responses. The default (and allowed minimum) is to use - 5 seconds, the maximum is capped at 3600 seconds. -* `noendpoints` will turn off the serving of endpoint records by disabling the watch on endpoints. - All endpoint queries and headless service queries will result in an NXDOMAIN. -* `transfer` enables zone transfers. It may be specified multiples times. `To` signals the direction - (only `to` is alllow). **ADDRESS** must be denoted in CIDR notation (127.0.0.1/32 etc.) or just as - plain addresses. The special wildcard `*` means: the entire internet. - Sending DNS notifies is not supported. -* `fallthrough` **[ZONES...]** If a query for a record in the zones for which the plugin is authoritative - results in NXDOMAIN, normally that is what the response will be. However, if you specify this option, - the query will instead be passed on down the plugin chain, which can include another plugin to handle - the query. If **[ZONES...]** is omitted, then fallthrough happens for all zones for which the plugin - is authoritative. If specific zones are listed (for example `in-addr.arpa` and `ip6.arpa`), then only - queries for those zones will be subject to fallthrough. -* `ignore empty_service` return NXDOMAIN for services without any ready endpoint addresses (e.g. ready pods). - This allows the querying pod to continue searching for the service in the search path. - The search path could, for example, include another kubernetes cluster. - -## Health - -This plugin implements dynamic health checking. Currently this is limited to reporting healthy when -the API has synced. - -## Examples - -Handle all queries in the `cluster.local` zone. Connect to Kubernetes in-cluster. Also handle all -`in-addr.arpa` `PTR` requests for `10.0.0.0/17` . Verify the existence of pods when answering pod -requests. Resolve upstream records against `10.102.3.10`. Note we show the entire server block here: - -~~~ txt -10.0.0.0/17 cluster.local { - kubernetes { - pods verified - upstream 10.102.3.10:53 - } -} -~~~ - -Or you can selectively expose some namespaces: - -~~~ txt -kubernetes cluster.local { - namespaces test staging -} -~~~ - -Connect to Kubernetes with CoreDNS running outside the cluster: - -~~~ txt -kubernetes cluster.local { - endpoint https://k8s-endpoint:8443 - tls cert key cacert -} -~~~ - - -## stubDomains and upstreamNameservers - -Here we use the *proxy* plugin to implement a stubDomain that forwards `example.local` to the nameserver `10.100.0.10:53`. -The *upstream* option in kubernetes means that ExternalName services (CNAMEs) will be resolved using the respective proxy. -Also configured is an upstreamNameserver `8.8.8.8:53` that will be used for resolving names that do not fall in `cluster.local` -or `example.local`. - -~~~ txt -.:53 { - kubernetes cluster.local { - upstream - } - proxy example.local 10.100.0.10:53 - proxy . 8.8.8.8:53 -} -~~~ - -The configuration above represents the following Kube-DNS stubDomains and upstreamNameservers configuration. - -~~~ txt - stubDomains: | - {“example.local”: [“10.100.0.10:53”]} - upstreamNameservers: | - [“8.8.8.8:53”] -~~~ - -## AutoPath - -The *kubernetes* plugin can be used in conjunction with the *autopath* plugin. Using this -feature enables server-side domain search path completion in kubernetes clusters. Note: `pods` must -be set to `verified` for this to function properly. - - cluster.local { - autopath @kubernetes - kubernetes { - pods verified - } - } - -## Federation - -The *kubernetes* plugin can be used in conjunction with the *federation* plugin. Using this -feature enables serving federated domains from the kubernetes clusters. - - cluster.local { - federation { - prod prod.example.org - staging staging.example.org - } - kubernetes - } - - -## Wildcards - -Some query labels accept a wildcard value to match any value. If a label is a valid wildcard (\*, -or the word "any"), then that label will match all values. The labels that accept wildcards are: - - * _endpoint_ in an `A` record request: _endpoint_.service.namespace.svc.zone, e.g. `*.nginx.ns.svc.cluster.local` - * _service_ in an `A` record request: _service_.namespace.svc.zone, e.g. `*.ns.svc.cluster.local` - * _namespace_ in an `A` record request: service._namespace_.svc.zone, e.g. `nginx.*.svc.cluster.local` - * _port and/or protocol_ in an `SRV` request: __port_.__protocol_.service.namespace.svc.zone., - e.g. `_http.*.service.ns.svc.cluster.local` - * multiple wild cards are allowed in a single query, e.g. `A` Request `*.*.svc.zone.` or `SRV` request `*.*.*.*.svc.zone.` - - For example, Wildcards can be used to resolve all Endpoints for a Service as `A` records. e.g.: `*.service.ns.svc.myzone.local` will return the Endpoint IPs in the Service `service` in namespace `default`: - ``` -*.service.default.svc.cluster.local. 5 IN A 192.168.10.10 -*.service.default.svc.cluster.local. 5 IN A 192.168.25.15 -``` - This response can be randomized using the `loadbalance` plugin diff --git a/vendor/github.com/coredns/coredns/plugin/kubernetes/apiproxy.go b/vendor/github.com/coredns/coredns/plugin/kubernetes/apiproxy.go deleted file mode 100644 index 305522cb..00000000 --- a/vendor/github.com/coredns/coredns/plugin/kubernetes/apiproxy.go +++ /dev/null @@ -1,75 +0,0 @@ -package kubernetes - -import ( - "fmt" - "io" - "net" - "net/http" - - "github.com/coredns/coredns/plugin/pkg/healthcheck" -) - -type proxyHandler struct { - healthcheck.HealthCheck -} - -type apiProxy struct { - http.Server - listener net.Listener - handler proxyHandler -} - -func (p *proxyHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { - upstream := p.Select() - network := "tcp" - address := upstream.Name - - d, err := net.Dial(network, address) - if err != nil { - log.Errorf("Unable to establish connection to upstream %s://%s: %s", network, address, err) - http.Error(w, fmt.Sprintf("Unable to establish connection to upstream %s://%s: %s", network, address, err), 500) - return - } - hj, ok := w.(http.Hijacker) - if !ok { - log.Error("Unable to establish connection: no hijacker") - http.Error(w, "Unable to establish connection: no hijacker", 500) - return - } - nc, _, err := hj.Hijack() - if err != nil { - log.Errorf("Unable to hijack connection: %s", err) - http.Error(w, fmt.Sprintf("Unable to hijack connection: %s", err), 500) - return - } - defer nc.Close() - defer d.Close() - - err = r.Write(d) - if err != nil { - log.Errorf("Unable to copy connection to upstream %s://%s: %s", network, address, err) - http.Error(w, fmt.Sprintf("Unable to copy connection to upstream %s://%s: %s", network, address, err), 500) - return - } - - errChan := make(chan error, 2) - cp := func(dst io.Writer, src io.Reader) { - _, err := io.Copy(dst, src) - errChan <- err - } - go cp(d, nc) - go cp(nc, d) - <-errChan -} - -func (p *apiProxy) Run() { - p.handler.Start() - go func() { - p.Serve(p.listener) - }() -} - -func (p *apiProxy) Stop() { - p.handler.Stop() - p.listener.Close() -} diff --git a/vendor/github.com/coredns/coredns/plugin/kubernetes/autopath.go b/vendor/github.com/coredns/coredns/plugin/kubernetes/autopath.go deleted file mode 100644 index cf5a7f06..00000000 --- a/vendor/github.com/coredns/coredns/plugin/kubernetes/autopath.go +++ /dev/null @@ -1,49 +0,0 @@ -package kubernetes - -import ( - "github.com/coredns/coredns/plugin" - "github.com/coredns/coredns/request" - - api "k8s.io/api/core/v1" -) - -// AutoPath implements the AutoPathFunc call from the autopath plugin. -// It returns a per-query search path or nil indicating no searchpathing should happen. -func (k *Kubernetes) AutoPath(state request.Request) []string { - // Check if the query falls in a zone we are actually authoritative for and thus if we want autopath. - zone := plugin.Zones(k.Zones).Matches(state.Name()) - if zone == "" { - return nil - } - - ip := state.IP() - - pod := k.podWithIP(ip) - if pod == nil { - return nil - } - - search := make([]string, 3) - if zone == "." { - search[0] = pod.Namespace + ".svc." - search[1] = "svc." - search[2] = "." - } else { - search[0] = pod.Namespace + ".svc." + zone - search[1] = "svc." + zone - search[2] = zone - } - - search = append(search, k.autoPathSearch...) - search = append(search, "") // sentinal - return search -} - -// podWithIP return the api.Pod for source IP ip. It returns nil if nothing can be found. -func (k *Kubernetes) podWithIP(ip string) *api.Pod { - ps := k.APIConn.PodIndex(ip) - if len(ps) == 0 { - return nil - } - return ps[0] -} diff --git a/vendor/github.com/coredns/coredns/plugin/kubernetes/controller.go b/vendor/github.com/coredns/coredns/plugin/kubernetes/controller.go deleted file mode 100644 index 0d7370a5..00000000 --- a/vendor/github.com/coredns/coredns/plugin/kubernetes/controller.go +++ /dev/null @@ -1,555 +0,0 @@ -package kubernetes - -import ( - "errors" - "fmt" - "sync" - "sync/atomic" - "time" - - api "k8s.io/api/core/v1" - "k8s.io/client-go/kubernetes" - "k8s.io/client-go/tools/cache" - - meta "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/watch" -) - -var namespace = api.NamespaceAll - -const ( - podIPIndex = "PodIP" - svcNameNamespaceIndex = "NameNamespace" - svcIPIndex = "ServiceIP" - epNameNamespaceIndex = "EndpointNameNamespace" - epIPIndex = "EndpointsIP" -) - -type dnsController interface { - ServiceList() []*api.Service - SvcIndex(string) []*api.Service - SvcIndexReverse(string) []*api.Service - PodIndex(string) []*api.Pod - EpIndex(string) []*api.Endpoints - EpIndexReverse(string) []*api.Endpoints - EndpointsList() []*api.Endpoints - - GetNodeByName(string) (*api.Node, error) - GetNamespaceByName(string) (*api.Namespace, error) - - Run() - HasSynced() bool - Stop() error - - // Modified returns the timestamp of the most recent changes - Modified() int64 -} - -type dnsControl struct { - // Modified tracks timestamp of the most recent changes - // It needs to be first because it is guarnteed to be 8-byte - // aligned ( we use sync.LoadAtomic with this ) - modified int64 - - client *kubernetes.Clientset - - selector labels.Selector - - svcController cache.Controller - podController cache.Controller - epController cache.Controller - nsController cache.Controller - - svcLister cache.Indexer - podLister cache.Indexer - epLister cache.Indexer - nsLister storeToNamespaceLister - - // stopLock is used to enforce only a single call to Stop is active. - // Needed because we allow stopping through an http endpoint and - // allowing concurrent stoppers leads to stack traces. - stopLock sync.Mutex - shutdown bool - stopCh chan struct{} -} - -type dnsControlOpts struct { - initPodCache bool - initEndpointsCache bool - resyncPeriod time.Duration - ignoreEmptyService bool - // Label handling. - labelSelector *meta.LabelSelector - selector labels.Selector -} - -// newDNSController creates a controller for CoreDNS. -func newdnsController(kubeClient *kubernetes.Clientset, opts dnsControlOpts) *dnsControl { - dns := dnsControl{ - client: kubeClient, - selector: opts.selector, - stopCh: make(chan struct{}), - } - - dns.svcLister, dns.svcController = cache.NewIndexerInformer( - &cache.ListWatch{ - ListFunc: serviceListFunc(dns.client, namespace, dns.selector), - WatchFunc: serviceWatchFunc(dns.client, namespace, dns.selector), - }, - &api.Service{}, - opts.resyncPeriod, - cache.ResourceEventHandlerFuncs{AddFunc: dns.Add, UpdateFunc: dns.Update, DeleteFunc: dns.Delete}, - cache.Indexers{svcNameNamespaceIndex: svcNameNamespaceIndexFunc, svcIPIndex: svcIPIndexFunc}) - - if opts.initPodCache { - dns.podLister, dns.podController = cache.NewIndexerInformer( - &cache.ListWatch{ - ListFunc: podListFunc(dns.client, namespace, dns.selector), - WatchFunc: podWatchFunc(dns.client, namespace, dns.selector), - }, - &api.Pod{}, - opts.resyncPeriod, - cache.ResourceEventHandlerFuncs{AddFunc: dns.Add, UpdateFunc: dns.Update, DeleteFunc: dns.Delete}, - cache.Indexers{podIPIndex: podIPIndexFunc}) - } - - if opts.initEndpointsCache { - dns.epLister, dns.epController = cache.NewIndexerInformer( - &cache.ListWatch{ - ListFunc: endpointsListFunc(dns.client, namespace, dns.selector), - WatchFunc: endpointsWatchFunc(dns.client, namespace, dns.selector), - }, - &api.Endpoints{}, - opts.resyncPeriod, - cache.ResourceEventHandlerFuncs{AddFunc: dns.Add, UpdateFunc: dns.Update, DeleteFunc: dns.Delete}, - cache.Indexers{epNameNamespaceIndex: epNameNamespaceIndexFunc, epIPIndex: epIPIndexFunc}) - } - - dns.nsLister.Store, dns.nsController = cache.NewInformer( - &cache.ListWatch{ - ListFunc: namespaceListFunc(dns.client, dns.selector), - WatchFunc: namespaceWatchFunc(dns.client, dns.selector), - }, - &api.Namespace{}, opts.resyncPeriod, cache.ResourceEventHandlerFuncs{}) - - return &dns -} - -// storeToNamespaceLister makes a Store that lists Namespaces. -type storeToNamespaceLister struct { - cache.Store -} - -func podIPIndexFunc(obj interface{}) ([]string, error) { - p, ok := obj.(*api.Pod) - if !ok { - return nil, errors.New("obj was not an *api.Pod") - } - return []string{p.Status.PodIP}, nil -} - -func svcIPIndexFunc(obj interface{}) ([]string, error) { - svc, ok := obj.(*api.Service) - if !ok { - return nil, errors.New("obj was not an *api.Service") - } - return []string{svc.Spec.ClusterIP}, nil -} - -func svcNameNamespaceIndexFunc(obj interface{}) ([]string, error) { - s, ok := obj.(*api.Service) - if !ok { - return nil, errors.New("obj was not an *api.Service") - } - return []string{s.ObjectMeta.Name + "." + s.ObjectMeta.Namespace}, nil -} - -func epNameNamespaceIndexFunc(obj interface{}) ([]string, error) { - s, ok := obj.(*api.Endpoints) - if !ok { - return nil, errors.New("obj was not an *api.Endpoints") - } - return []string{s.ObjectMeta.Name + "." + s.ObjectMeta.Namespace}, nil -} - -func epIPIndexFunc(obj interface{}) ([]string, error) { - ep, ok := obj.(*api.Endpoints) - if !ok { - return nil, errors.New("obj was not an *api.Endpoints") - } - var idx []string - for _, eps := range ep.Subsets { - for _, addr := range eps.Addresses { - idx = append(idx, addr.IP) - } - } - return idx, nil -} - -func serviceListFunc(c *kubernetes.Clientset, ns string, s labels.Selector) func(meta.ListOptions) (runtime.Object, error) { - return func(opts meta.ListOptions) (runtime.Object, error) { - if s != nil { - opts.LabelSelector = s.String() - } - listV1, err := c.CoreV1().Services(ns).List(opts) - if err != nil { - return nil, err - } - return listV1, err - } -} - -func podListFunc(c *kubernetes.Clientset, ns string, s labels.Selector) func(meta.ListOptions) (runtime.Object, error) { - return func(opts meta.ListOptions) (runtime.Object, error) { - if s != nil { - opts.LabelSelector = s.String() - } - listV1, err := c.CoreV1().Pods(ns).List(opts) - if err != nil { - return nil, err - } - return listV1, err - } -} - -func serviceWatchFunc(c *kubernetes.Clientset, ns string, s labels.Selector) func(options meta.ListOptions) (watch.Interface, error) { - return func(options meta.ListOptions) (watch.Interface, error) { - if s != nil { - options.LabelSelector = s.String() - } - w, err := c.CoreV1().Services(ns).Watch(options) - if err != nil { - return nil, err - } - return w, nil - } -} - -func podWatchFunc(c *kubernetes.Clientset, ns string, s labels.Selector) func(options meta.ListOptions) (watch.Interface, error) { - return func(options meta.ListOptions) (watch.Interface, error) { - if s != nil { - options.LabelSelector = s.String() - } - w, err := c.CoreV1().Pods(ns).Watch(options) - if err != nil { - return nil, err - } - return w, nil - } -} - -func endpointsListFunc(c *kubernetes.Clientset, ns string, s labels.Selector) func(meta.ListOptions) (runtime.Object, error) { - return func(opts meta.ListOptions) (runtime.Object, error) { - if s != nil { - opts.LabelSelector = s.String() - } - listV1, err := c.CoreV1().Endpoints(ns).List(opts) - if err != nil { - return nil, err - } - return listV1, err - } -} - -func endpointsWatchFunc(c *kubernetes.Clientset, ns string, s labels.Selector) func(options meta.ListOptions) (watch.Interface, error) { - return func(options meta.ListOptions) (watch.Interface, error) { - if s != nil { - options.LabelSelector = s.String() - } - w, err := c.CoreV1().Endpoints(ns).Watch(options) - if err != nil { - return nil, err - } - return w, nil - } -} - -func namespaceListFunc(c *kubernetes.Clientset, s labels.Selector) func(meta.ListOptions) (runtime.Object, error) { - return func(opts meta.ListOptions) (runtime.Object, error) { - if s != nil { - opts.LabelSelector = s.String() - } - listV1, err := c.CoreV1().Namespaces().List(opts) - if err != nil { - return nil, err - } - return listV1, err - } -} - -func namespaceWatchFunc(c *kubernetes.Clientset, s labels.Selector) func(options meta.ListOptions) (watch.Interface, error) { - return func(options meta.ListOptions) (watch.Interface, error) { - if s != nil { - options.LabelSelector = s.String() - } - w, err := c.CoreV1().Namespaces().Watch(options) - if err != nil { - return nil, err - } - return w, nil - } -} - -// Stop stops the controller. -func (dns *dnsControl) Stop() error { - dns.stopLock.Lock() - defer dns.stopLock.Unlock() - - // Only try draining the workqueue if we haven't already. - if !dns.shutdown { - close(dns.stopCh) - dns.shutdown = true - - return nil - } - - return fmt.Errorf("shutdown already in progress") -} - -// Run starts the controller. -func (dns *dnsControl) Run() { - go dns.svcController.Run(dns.stopCh) - if dns.epController != nil { - go dns.epController.Run(dns.stopCh) - } - if dns.podController != nil { - go dns.podController.Run(dns.stopCh) - } - go dns.nsController.Run(dns.stopCh) - <-dns.stopCh -} - -// HasSynced calls on all controllers. -func (dns *dnsControl) HasSynced() bool { - a := dns.svcController.HasSynced() - b := true - if dns.epController != nil { - b = dns.epController.HasSynced() - } - c := true - if dns.podController != nil { - c = dns.podController.HasSynced() - } - d := dns.nsController.HasSynced() - return a && b && c && d -} - -func (dns *dnsControl) ServiceList() (svcs []*api.Service) { - os := dns.svcLister.List() - for _, o := range os { - s, ok := o.(*api.Service) - if !ok { - continue - } - svcs = append(svcs, s) - } - return svcs -} - -func (dns *dnsControl) PodIndex(ip string) (pods []*api.Pod) { - if dns.podLister == nil { - return nil - } - os, err := dns.podLister.ByIndex(podIPIndex, ip) - if err != nil { - return nil - } - for _, o := range os { - p, ok := o.(*api.Pod) - if !ok { - continue - } - pods = append(pods, p) - } - return pods -} - -func (dns *dnsControl) SvcIndex(idx string) (svcs []*api.Service) { - if dns.svcLister == nil { - return nil - } - os, err := dns.svcLister.ByIndex(svcNameNamespaceIndex, idx) - if err != nil { - return nil - } - for _, o := range os { - s, ok := o.(*api.Service) - if !ok { - continue - } - svcs = append(svcs, s) - } - return svcs -} - -func (dns *dnsControl) SvcIndexReverse(ip string) (svcs []*api.Service) { - if dns.svcLister == nil { - return nil - } - os, err := dns.svcLister.ByIndex(svcIPIndex, ip) - if err != nil { - return nil - } - - for _, o := range os { - s, ok := o.(*api.Service) - if !ok { - continue - } - svcs = append(svcs, s) - } - return svcs -} - -func (dns *dnsControl) EpIndex(idx string) (ep []*api.Endpoints) { - if dns.epLister == nil { - return nil - } - os, err := dns.epLister.ByIndex(epNameNamespaceIndex, idx) - if err != nil { - return nil - } - for _, o := range os { - e, ok := o.(*api.Endpoints) - if !ok { - continue - } - ep = append(ep, e) - } - return ep -} - -func (dns *dnsControl) EpIndexReverse(ip string) (ep []*api.Endpoints) { - if dns.svcLister == nil { - return nil - } - os, err := dns.epLister.ByIndex(epIPIndex, ip) - if err != nil { - return nil - } - for _, o := range os { - e, ok := o.(*api.Endpoints) - if !ok { - continue - } - ep = append(ep, e) - } - return ep -} - -func (dns *dnsControl) EndpointsList() (eps []*api.Endpoints) { - if dns.epLister == nil { - return nil - } - os := dns.epLister.List() - for _, o := range os { - ep, ok := o.(*api.Endpoints) - if !ok { - continue - } - eps = append(eps, ep) - } - return eps -} - -// GetNodeByName return the node by name. If nothing is found an error is -// returned. This query causes a roundtrip to the k8s API server, so use -// sparingly. Currently this is only used for Federation. -func (dns *dnsControl) GetNodeByName(name string) (*api.Node, error) { - v1node, err := dns.client.CoreV1().Nodes().Get(name, meta.GetOptions{}) - if err != nil { - return &api.Node{}, err - } - return v1node, nil -} - -// GetNamespaceByName returns the namespace by name. If nothing is found an -// error is returned. -func (dns *dnsControl) GetNamespaceByName(name string) (*api.Namespace, error) { - os := dns.nsLister.List() - for _, o := range os { - ns, ok := o.(*api.Namespace) - if !ok { - continue - } - if name == ns.ObjectMeta.Name { - return ns, nil - } - } - return nil, fmt.Errorf("namespace not found") -} - -func (dns *dnsControl) Modified() int64 { - unix := atomic.LoadInt64(&dns.modified) - return unix -} - -// updateModified set dns.modified to the current time. -func (dns *dnsControl) updateModifed() { - unix := time.Now().Unix() - atomic.StoreInt64(&dns.modified, unix) -} - -func (dns *dnsControl) Add(obj interface{}) { dns.updateModifed() } -func (dns *dnsControl) Delete(obj interface{}) { dns.updateModifed() } - -func (dns *dnsControl) Update(objOld, newObj interface{}) { - // endpoint updates can come frequently, make sure - // it's a change we care about - if o, ok := objOld.(*api.Endpoints); ok { - n := newObj.(*api.Endpoints) - if endpointsEquivalent(o, n) { - return - } - } - dns.updateModifed() -} - -// endpointsEquivalent checks if the update to an endpoint is something -// that matters to us: ready addresses, host names, ports (including names for SRV) -func endpointsEquivalent(a, b *api.Endpoints) bool { - // supposedly we should be able to rely on - // these being sorted and able to be compared - // they are supposed to be in a canonical format - - if len(a.Subsets) != len(b.Subsets) { - return false - } - - for i, sa := range a.Subsets { - // check the Addresses and Ports. Ignore unready addresses. - sb := b.Subsets[i] - if len(sa.Addresses) != len(sb.Addresses) { - return false - } - if len(sa.Ports) != len(sb.Ports) { - return false - } - - for addr, aaddr := range sa.Addresses { - baddr := sb.Addresses[addr] - if aaddr.IP != baddr.IP { - return false - } - if aaddr.Hostname != baddr.Hostname { - return false - } - } - - for port, aport := range sa.Ports { - bport := sb.Ports[port] - if aport.Name != bport.Name { - return false - } - if aport.Port != bport.Port { - return false - } - if aport.Protocol != bport.Protocol { - return false - } - } - } - return true -} diff --git a/vendor/github.com/coredns/coredns/plugin/kubernetes/federation.go b/vendor/github.com/coredns/coredns/plugin/kubernetes/federation.go deleted file mode 100644 index df6ae948..00000000 --- a/vendor/github.com/coredns/coredns/plugin/kubernetes/federation.go +++ /dev/null @@ -1,45 +0,0 @@ -package kubernetes - -import ( - "github.com/coredns/coredns/plugin/etcd/msg" - "github.com/coredns/coredns/plugin/pkg/dnsutil" - "github.com/coredns/coredns/request" -) - -// The federation node.Labels keys used. -const ( - // TODO: Do not hardcode these labels. Pull them out of the API instead. - // - // We can get them via .... - // import metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - // metav1.LabelZoneFailureDomain - // metav1.LabelZoneRegion - // - // But importing above breaks coredns with flag collision of 'log_dir' - - LabelZone = "failure-domain.beta.kubernetes.io/zone" - LabelRegion = "failure-domain.beta.kubernetes.io/region" -) - -// Federations is used from the federations plugin to return the service that should be -// returned as a CNAME for federation(s) to work. -func (k *Kubernetes) Federations(state request.Request, fname, fzone string) (msg.Service, error) { - nodeName := k.localNodeName() - node, err := k.APIConn.GetNodeByName(nodeName) - if err != nil { - return msg.Service{}, err - } - r, err := parseRequest(state) - if err != nil { - return msg.Service{}, err - } - - lz := node.Labels[LabelZone] - lr := node.Labels[LabelRegion] - - if r.endpoint == "" { - return msg.Service{Host: dnsutil.Join([]string{r.service, r.namespace, fname, r.podOrSvc, lz, lr, fzone})}, nil - } - - return msg.Service{Host: dnsutil.Join([]string{r.endpoint, r.service, r.namespace, fname, r.podOrSvc, lz, lr, fzone})}, nil -} diff --git a/vendor/github.com/coredns/coredns/plugin/kubernetes/handler.go b/vendor/github.com/coredns/coredns/plugin/kubernetes/handler.go deleted file mode 100644 index c02bdedf..00000000 --- a/vendor/github.com/coredns/coredns/plugin/kubernetes/handler.go +++ /dev/null @@ -1,88 +0,0 @@ -package kubernetes - -import ( - "context" - - "github.com/coredns/coredns/plugin" - "github.com/coredns/coredns/request" - - "github.com/miekg/dns" -) - -// ServeDNS implements the plugin.Handler interface. -func (k Kubernetes) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (int, error) { - opt := plugin.Options{} - state := request.Request{W: w, Req: r, Context: ctx} - - m := new(dns.Msg) - m.SetReply(r) - m.Authoritative, m.RecursionAvailable = true, true - - zone := plugin.Zones(k.Zones).Matches(state.Name()) - if zone == "" { - return plugin.NextOrFailure(k.Name(), k.Next, ctx, w, r) - } - - state.Zone = zone - - var ( - records []dns.RR - extra []dns.RR - err error - ) - - switch state.QType() { - case dns.TypeA: - records, err = plugin.A(&k, zone, state, nil, opt) - case dns.TypeAAAA: - records, err = plugin.AAAA(&k, zone, state, nil, opt) - case dns.TypeTXT: - records, err = plugin.TXT(&k, zone, state, opt) - case dns.TypeCNAME: - records, err = plugin.CNAME(&k, zone, state, opt) - case dns.TypePTR: - records, err = plugin.PTR(&k, zone, state, opt) - case dns.TypeMX: - records, extra, err = plugin.MX(&k, zone, state, opt) - case dns.TypeSRV: - records, extra, err = plugin.SRV(&k, zone, state, opt) - case dns.TypeSOA: - records, err = plugin.SOA(&k, zone, state, opt) - case dns.TypeNS: - if state.Name() == zone { - records, extra, err = plugin.NS(&k, zone, state, opt) - break - } - fallthrough - case dns.TypeAXFR, dns.TypeIXFR: - k.Transfer(ctx, state) - default: - // Do a fake A lookup, so we can distinguish between NODATA and NXDOMAIN - _, err = plugin.A(&k, zone, state, nil, opt) - } - - if k.IsNameError(err) { - if k.Fall.Through(state.Name()) { - return plugin.NextOrFailure(k.Name(), k.Next, ctx, w, r) - } - return plugin.BackendError(&k, zone, dns.RcodeNameError, state, nil /* err */, opt) - } - if err != nil { - return dns.RcodeServerFailure, err - } - - if len(records) == 0 { - return plugin.BackendError(&k, zone, dns.RcodeSuccess, state, nil, opt) - } - - m.Answer = append(m.Answer, records...) - m.Extra = append(m.Extra, extra...) - - state.SizeAndDo(m) - m, _ = state.Scrub(m) - w.WriteMsg(m) - return dns.RcodeSuccess, nil -} - -// Name implements the Handler interface. -func (k Kubernetes) Name() string { return "kubernetes" } diff --git a/vendor/github.com/coredns/coredns/plugin/kubernetes/handler_ignore_emptyservice_test.go b/vendor/github.com/coredns/coredns/plugin/kubernetes/handler_ignore_emptyservice_test.go deleted file mode 100644 index 149f8423..00000000 --- a/vendor/github.com/coredns/coredns/plugin/kubernetes/handler_ignore_emptyservice_test.go +++ /dev/null @@ -1,55 +0,0 @@ -package kubernetes - -import ( - "context" - "github.com/coredns/coredns/plugin/pkg/dnstest" - "github.com/coredns/coredns/plugin/test" - "testing" - - "github.com/miekg/dns" -) - -var dnsEmptyServiceTestCases = []test.Case{ - // A Service - { - Qname: "svcempty.testns.svc.cluster.local.", Qtype: dns.TypeA, - Rcode: dns.RcodeNameError, - Ns: []dns.RR{ - test.SOA("cluster.local. 300 IN SOA ns.dns.cluster.local. hostmaster.cluster.local. 1499347823 7200 1800 86400 60"), - }, - }, -} - -func TestServeDNSEmptyService(t *testing.T) { - - k := New([]string{"cluster.local."}) - k.APIConn = &APIConnServeTest{} - k.opts.ignoreEmptyService = true - k.Next = test.NextHandler(dns.RcodeSuccess, nil) - ctx := context.TODO() - - for i, tc := range dnsEmptyServiceTestCases { - r := tc.Msg() - - w := dnstest.NewRecorder(&test.ResponseWriter{}) - - _, err := k.ServeDNS(ctx, w, r) - if err != tc.Error { - t.Errorf("Test %d expected no error, got %v", i, err) - return - } - if tc.Error != nil { - continue - } - - resp := w.Msg - if resp == nil { - t.Fatalf("Test %d, got nil message and no error for %q", i, r.Question[0].Name) - } - - // Before sorting, make sure that CNAMES do not appear after their target records - test.CNAMEOrder(t, resp) - - test.SortAndCheck(t, resp, tc) - } -} diff --git a/vendor/github.com/coredns/coredns/plugin/kubernetes/handler_pod_disabled_test.go b/vendor/github.com/coredns/coredns/plugin/kubernetes/handler_pod_disabled_test.go deleted file mode 100644 index dc1f1083..00000000 --- a/vendor/github.com/coredns/coredns/plugin/kubernetes/handler_pod_disabled_test.go +++ /dev/null @@ -1,59 +0,0 @@ -package kubernetes - -import ( - "context" - "testing" - - "github.com/coredns/coredns/plugin/pkg/dnstest" - "github.com/coredns/coredns/plugin/test" - - "github.com/miekg/dns" -) - -var podModeDisabledCases = []test.Case{ - { - Qname: "10-240-0-1.podns.pod.cluster.local.", Qtype: dns.TypeA, - Rcode: dns.RcodeNameError, - Ns: []dns.RR{ - test.SOA("cluster.local. 300 IN SOA ns.dns.cluster.local. hostmaster.cluster.local. 1499347823 7200 1800 86400 60"), - }, - }, - { - Qname: "172-0-0-2.podns.pod.cluster.local.", Qtype: dns.TypeA, - Rcode: dns.RcodeNameError, - Ns: []dns.RR{ - test.SOA("cluster.local. 300 IN SOA ns.dns.cluster.local. hostmaster.cluster.local. 1499347823 7200 1800 86400 60"), - }, - }, -} - -func TestServeDNSModeDisabled(t *testing.T) { - - k := New([]string{"cluster.local."}) - k.APIConn = &APIConnServeTest{} - k.Next = test.NextHandler(dns.RcodeSuccess, nil) - k.podMode = podModeDisabled - ctx := context.TODO() - - for i, tc := range podModeDisabledCases { - r := tc.Msg() - - w := dnstest.NewRecorder(&test.ResponseWriter{}) - - _, err := k.ServeDNS(ctx, w, r) - if err != tc.Error { - t.Errorf("Test %d got unexpected error %v", i, err) - return - } - if tc.Error != nil { - continue - } - - resp := w.Msg - if resp == nil { - t.Fatalf("Test %d, got nil message and no error for %q", i, r.Question[0].Name) - } - - test.SortAndCheck(t, resp, tc) - } -} diff --git a/vendor/github.com/coredns/coredns/plugin/kubernetes/handler_pod_insecure_test.go b/vendor/github.com/coredns/coredns/plugin/kubernetes/handler_pod_insecure_test.go deleted file mode 100644 index 160ba451..00000000 --- a/vendor/github.com/coredns/coredns/plugin/kubernetes/handler_pod_insecure_test.go +++ /dev/null @@ -1,94 +0,0 @@ -package kubernetes - -import ( - "context" - "testing" - - "github.com/coredns/coredns/plugin/pkg/dnstest" - "github.com/coredns/coredns/plugin/test" - - "github.com/miekg/dns" -) - -var podModeInsecureCases = []test.Case{ - { - Qname: "10-240-0-1.podns.pod.cluster.local.", Qtype: dns.TypeA, - Rcode: dns.RcodeSuccess, - Answer: []dns.RR{ - test.A("10-240-0-1.podns.pod.cluster.local. 5 IN A 10.240.0.1"), - }, - }, - { - Qname: "172-0-0-2.podns.pod.cluster.local.", Qtype: dns.TypeA, - Rcode: dns.RcodeSuccess, - Answer: []dns.RR{ - test.A("172-0-0-2.podns.pod.cluster.local. 5 IN A 172.0.0.2"), - }, - }, - { - Qname: "blah.podns.pod.cluster.local.", Qtype: dns.TypeA, - Rcode: dns.RcodeNameError, - Ns: []dns.RR{ - test.SOA("cluster.local. 300 IN SOA ns.dns.cluster.local. hostmaster.cluster.local. 1515173576 7200 1800 86400 30"), - }, - }, - { - Qname: "blah.podns.pod.cluster.local.", Qtype: dns.TypeAAAA, - Rcode: dns.RcodeNameError, - Ns: []dns.RR{ - test.SOA("cluster.local. 300 IN SOA ns.dns.cluster.local. hostmaster.cluster.local. 1515173576 7200 1800 86400 30"), - }, - }, - { - Qname: "blah.podns.pod.cluster.local.", Qtype: dns.TypeHINFO, - Rcode: dns.RcodeNameError, - Ns: []dns.RR{ - test.SOA("cluster.local. 300 IN SOA ns.dns.cluster.local. hostmaster.cluster.local. 1515173576 7200 1800 86400 30"), - }, - }, - { - Qname: "blah.pod-nons.pod.cluster.local.", Qtype: dns.TypeA, - Rcode: dns.RcodeNameError, - Ns: []dns.RR{ - test.SOA("cluster.local. 300 IN SOA ns.dns.cluster.local. hostmaster.cluster.local. 1515173576 7200 1800 86400 30"), - }, - }, - { - Qname: "podns.pod.cluster.local.", Qtype: dns.TypeA, - Rcode: dns.RcodeNameError, - Ns: []dns.RR{ - test.SOA("cluster.local. 300 IN SOA ns.dns.cluster.local. hostmaster.cluster.local. 1515173576 7200 1800 86400 30"), - }, - }, -} - -func TestServeDNSModeInsecure(t *testing.T) { - - k := New([]string{"cluster.local."}) - k.APIConn = &APIConnServeTest{} - k.Next = test.NextHandler(dns.RcodeSuccess, nil) - ctx := context.TODO() - k.podMode = podModeInsecure - - for i, tc := range podModeInsecureCases { - r := tc.Msg() - - w := dnstest.NewRecorder(&test.ResponseWriter{}) - - _, err := k.ServeDNS(ctx, w, r) - if err != tc.Error { - t.Errorf("Test %d expected no error, got %v", i, err) - return - } - if tc.Error != nil { - continue - } - - resp := w.Msg - if resp == nil { - t.Fatalf("Test %d, got nil message and no error for %q", i, r.Question[0].Name) - } - - test.SortAndCheck(t, resp, tc) - } -} diff --git a/vendor/github.com/coredns/coredns/plugin/kubernetes/handler_pod_verified_test.go b/vendor/github.com/coredns/coredns/plugin/kubernetes/handler_pod_verified_test.go deleted file mode 100644 index c2b73328..00000000 --- a/vendor/github.com/coredns/coredns/plugin/kubernetes/handler_pod_verified_test.go +++ /dev/null @@ -1,80 +0,0 @@ -package kubernetes - -import ( - "context" - "testing" - - "github.com/coredns/coredns/plugin/pkg/dnstest" - "github.com/coredns/coredns/plugin/test" - - "github.com/miekg/dns" -) - -var podModeVerifiedCases = []test.Case{ - { - Qname: "10-240-0-1.podns.pod.cluster.local.", Qtype: dns.TypeA, - Rcode: dns.RcodeSuccess, - Answer: []dns.RR{ - test.A("10-240-0-1.podns.pod.cluster.local. 5 IN A 10.240.0.1"), - }, - }, - { - Qname: "podns.pod.cluster.local.", Qtype: dns.TypeA, - Rcode: dns.RcodeSuccess, - Ns: []dns.RR{ - test.SOA("cluster.local. 300 IN SOA ns.dns.cluster.local. hostmaster.cluster.local. 1499347823 7200 1800 86400 60"), - }, - }, - { - Qname: "svcns.svc.cluster.local.", Qtype: dns.TypeA, - Rcode: dns.RcodeSuccess, - Ns: []dns.RR{ - test.SOA("cluster.local. 300 IN SOA ns.dns.cluster.local. hostmaster.cluster.local. 1499347823 7200 1800 86400 60"), - }, - }, - { - Qname: "pod-nons.pod.cluster.local.", Qtype: dns.TypeA, - Rcode: dns.RcodeNameError, - Ns: []dns.RR{ - test.SOA("cluster.local. 300 IN SOA ns.dns.cluster.local. hostmaster.cluster.local. 1499347823 7200 1800 86400 60"), - }, - }, - { - Qname: "172-0-0-2.podns.pod.cluster.local.", Qtype: dns.TypeA, - Rcode: dns.RcodeNameError, - Ns: []dns.RR{ - test.SOA("cluster.local. 300 IN SOA ns.dns.cluster.local. hostmaster.cluster.local. 1499347823 7200 1800 86400 60"), - }, - }, -} - -func TestServeDNSModeVerified(t *testing.T) { - - k := New([]string{"cluster.local."}) - k.APIConn = &APIConnServeTest{} - k.Next = test.NextHandler(dns.RcodeSuccess, nil) - ctx := context.TODO() - k.podMode = podModeVerified - - for i, tc := range podModeVerifiedCases { - r := tc.Msg() - - w := dnstest.NewRecorder(&test.ResponseWriter{}) - - _, err := k.ServeDNS(ctx, w, r) - if err != tc.Error { - t.Errorf("Test %d expected no error, got %v", i, err) - return - } - if tc.Error != nil { - continue - } - - resp := w.Msg - if resp == nil { - t.Fatalf("Test %d, got nil message and no error for %q", i, r.Question[0].Name) - } - - test.SortAndCheck(t, resp, tc) - } -} diff --git a/vendor/github.com/coredns/coredns/plugin/kubernetes/handler_test.go b/vendor/github.com/coredns/coredns/plugin/kubernetes/handler_test.go deleted file mode 100644 index 38890313..00000000 --- a/vendor/github.com/coredns/coredns/plugin/kubernetes/handler_test.go +++ /dev/null @@ -1,546 +0,0 @@ -package kubernetes - -import ( - "context" - "testing" - "time" - - "github.com/coredns/coredns/plugin/pkg/dnstest" - "github.com/coredns/coredns/plugin/test" - - "github.com/miekg/dns" - api "k8s.io/api/core/v1" - meta "k8s.io/apimachinery/pkg/apis/meta/v1" -) - -var dnsTestCases = []test.Case{ - // A Service - { - Qname: "svc1.testns.svc.cluster.local.", Qtype: dns.TypeA, - Rcode: dns.RcodeSuccess, - Answer: []dns.RR{ - test.A("svc1.testns.svc.cluster.local. 5 IN A 10.0.0.1"), - }, - }, - { - Qname: "svcempty.testns.svc.cluster.local.", Qtype: dns.TypeA, - Rcode: dns.RcodeSuccess, - Answer: []dns.RR{ - test.A("svcempty.testns.svc.cluster.local. 5 IN A 10.0.0.1"), - }, - }, - // A Service (wildcard) - { - Qname: "svc1.*.svc.cluster.local.", Qtype: dns.TypeA, - Rcode: dns.RcodeSuccess, - Answer: []dns.RR{ - test.A("svc1.*.svc.cluster.local. 5 IN A 10.0.0.1"), - }, - }, - { - Qname: "svc1.testns.svc.cluster.local.", Qtype: dns.TypeSRV, - Rcode: dns.RcodeSuccess, - Answer: []dns.RR{test.SRV("svc1.testns.svc.cluster.local. 5 IN SRV 0 100 80 svc1.testns.svc.cluster.local.")}, - Extra: []dns.RR{test.A("svc1.testns.svc.cluster.local. 5 IN A 10.0.0.1")}, - }, - { - Qname: "svcempty.testns.svc.cluster.local.", Qtype: dns.TypeSRV, - Rcode: dns.RcodeSuccess, - Answer: []dns.RR{test.SRV("svcempty.testns.svc.cluster.local. 5 IN SRV 0 100 80 svcempty.testns.svc.cluster.local.")}, - Extra: []dns.RR{test.A("svcempty.testns.svc.cluster.local. 5 IN A 10.0.0.1")}, - }, - { - Qname: "svc6.testns.svc.cluster.local.", Qtype: dns.TypeSRV, - Rcode: dns.RcodeSuccess, - Answer: []dns.RR{test.SRV("svc6.testns.svc.cluster.local. 5 IN SRV 0 100 80 svc6.testns.svc.cluster.local.")}, - Extra: []dns.RR{test.AAAA("svc6.testns.svc.cluster.local. 5 IN AAAA 1234:abcd::1")}, - }, - // SRV Service (wildcard) - { - Qname: "svc1.*.svc.cluster.local.", Qtype: dns.TypeSRV, - Rcode: dns.RcodeSuccess, - Answer: []dns.RR{test.SRV("svc1.*.svc.cluster.local. 5 IN SRV 0 100 80 svc1.testns.svc.cluster.local.")}, - Extra: []dns.RR{test.A("svc1.testns.svc.cluster.local. 5 IN A 10.0.0.1")}, - }, - { - Qname: "svcempty.*.svc.cluster.local.", Qtype: dns.TypeSRV, - Rcode: dns.RcodeSuccess, - Answer: []dns.RR{test.SRV("svcempty.*.svc.cluster.local. 5 IN SRV 0 100 80 svcempty.testns.svc.cluster.local.")}, - Extra: []dns.RR{test.A("svcempty.testns.svc.cluster.local. 5 IN A 10.0.0.1")}, - }, - // SRV Service (wildcards) - { - Qname: "*.any.svc1.*.svc.cluster.local.", Qtype: dns.TypeSRV, - Rcode: dns.RcodeSuccess, - Answer: []dns.RR{test.SRV("*.any.svc1.*.svc.cluster.local. 5 IN SRV 0 100 80 svc1.testns.svc.cluster.local.")}, - Extra: []dns.RR{test.A("svc1.testns.svc.cluster.local. 5 IN A 10.0.0.1")}, - }, - // A Service (wildcards) - { - Qname: "*.any.svc1.*.svc.cluster.local.", Qtype: dns.TypeA, - Rcode: dns.RcodeSuccess, - Answer: []dns.RR{ - test.A("*.any.svc1.*.svc.cluster.local. 5 IN A 10.0.0.1"), - }, - }, - // SRV Service Not udp/tcp - { - Qname: "*._not-udp-or-tcp.svc1.testns.svc.cluster.local.", Qtype: dns.TypeSRV, - Rcode: dns.RcodeNameError, - Ns: []dns.RR{ - test.SOA("cluster.local. 300 IN SOA ns.dns.cluster.local. hostmaster.cluster.local. 1499347823 7200 1800 86400 60"), - }, - }, - // SRV Service - { - Qname: "_http._tcp.svc1.testns.svc.cluster.local.", Qtype: dns.TypeSRV, - Rcode: dns.RcodeSuccess, - Answer: []dns.RR{ - test.SRV("_http._tcp.svc1.testns.svc.cluster.local. 5 IN SRV 0 100 80 svc1.testns.svc.cluster.local."), - }, - Extra: []dns.RR{ - test.A("svc1.testns.svc.cluster.local. 5 IN A 10.0.0.1"), - }, - }, - { - Qname: "_http._tcp.svcempty.testns.svc.cluster.local.", Qtype: dns.TypeSRV, - Rcode: dns.RcodeSuccess, - Answer: []dns.RR{ - test.SRV("_http._tcp.svcempty.testns.svc.cluster.local. 5 IN SRV 0 100 80 svcempty.testns.svc.cluster.local."), - }, - Extra: []dns.RR{ - test.A("svcempty.testns.svc.cluster.local. 5 IN A 10.0.0.1"), - }, - }, - // A Service (Headless) - { - Qname: "hdls1.testns.svc.cluster.local.", Qtype: dns.TypeA, - Rcode: dns.RcodeSuccess, - Answer: []dns.RR{ - test.A("hdls1.testns.svc.cluster.local. 5 IN A 172.0.0.2"), - test.A("hdls1.testns.svc.cluster.local. 5 IN A 172.0.0.3"), - test.A("hdls1.testns.svc.cluster.local. 5 IN A 172.0.0.4"), - test.A("hdls1.testns.svc.cluster.local. 5 IN A 172.0.0.5"), - }, - }, - // An Endpoint ip - { - Qname: "172-0-0-2.hdls1.testns.svc.cluster.local.", Qtype: dns.TypeA, - Rcode: dns.RcodeSuccess, - Answer: []dns.RR{ - test.A("172-0-0-2.hdls1.testns.svc.cluster.local. 5 IN A 172.0.0.2"), - }, - }, - // A Endpoint ip - { - Qname: "172-0-0-3.hdls1.testns.svc.cluster.local.", Qtype: dns.TypeA, - Rcode: dns.RcodeSuccess, - Answer: []dns.RR{ - test.A("172-0-0-3.hdls1.testns.svc.cluster.local. 5 IN A 172.0.0.3"), - }, - }, - // An Endpoint by name - { - Qname: "dup-name.hdls1.testns.svc.cluster.local.", Qtype: dns.TypeA, - Rcode: dns.RcodeSuccess, - Answer: []dns.RR{ - test.A("dup-name.hdls1.testns.svc.cluster.local. 5 IN A 172.0.0.4"), - test.A("dup-name.hdls1.testns.svc.cluster.local. 5 IN A 172.0.0.5"), - }, - }, - // SRV Service (Headless) - { - Qname: "_http._tcp.hdls1.testns.svc.cluster.local.", Qtype: dns.TypeSRV, - Rcode: dns.RcodeSuccess, - Answer: []dns.RR{ - test.SRV("_http._tcp.hdls1.testns.svc.cluster.local. 5 IN SRV 0 16 80 172-0-0-2.hdls1.testns.svc.cluster.local."), - test.SRV("_http._tcp.hdls1.testns.svc.cluster.local. 5 IN SRV 0 16 80 172-0-0-3.hdls1.testns.svc.cluster.local."), - test.SRV("_http._tcp.hdls1.testns.svc.cluster.local. 5 IN SRV 0 16 80 5678-abcd--1.hdls1.testns.svc.cluster.local."), - test.SRV("_http._tcp.hdls1.testns.svc.cluster.local. 5 IN SRV 0 16 80 5678-abcd--2.hdls1.testns.svc.cluster.local."), - test.SRV("_http._tcp.hdls1.testns.svc.cluster.local. 5 IN SRV 0 16 80 dup-name.hdls1.testns.svc.cluster.local."), - }, - Extra: []dns.RR{ - test.A("172-0-0-2.hdls1.testns.svc.cluster.local. 5 IN A 172.0.0.2"), - test.A("172-0-0-3.hdls1.testns.svc.cluster.local. 5 IN A 172.0.0.3"), - test.AAAA("5678-abcd--1.hdls1.testns.svc.cluster.local. 5 IN AAAA 5678:abcd::1"), - test.AAAA("5678-abcd--2.hdls1.testns.svc.cluster.local. 5 IN AAAA 5678:abcd::2"), - test.A("dup-name.hdls1.testns.svc.cluster.local. 5 IN A 172.0.0.4"), - test.A("dup-name.hdls1.testns.svc.cluster.local. 5 IN A 172.0.0.5"), - }, - }, - // AAAA - { - Qname: "5678-abcd--2.hdls1.testns.svc.cluster.local", Qtype: dns.TypeAAAA, - Rcode: dns.RcodeSuccess, - Answer: []dns.RR{test.AAAA("5678-abcd--2.hdls1.testns.svc.cluster.local. 5 IN AAAA 5678:abcd::2")}, - }, - // CNAME External - { - Qname: "external.testns.svc.cluster.local.", Qtype: dns.TypeCNAME, - Rcode: dns.RcodeSuccess, - Answer: []dns.RR{ - test.CNAME("external.testns.svc.cluster.local. 5 IN CNAME ext.interwebs.test."), - }, - }, - // AAAA Service (with an existing A record, but no AAAA record) - { - Qname: "svc1.testns.svc.cluster.local.", Qtype: dns.TypeAAAA, - Rcode: dns.RcodeSuccess, - Ns: []dns.RR{ - test.SOA("cluster.local. 300 IN SOA ns.dns.cluster.local. hostmaster.cluster.local. 1499347823 7200 1800 86400 60"), - }, - }, - // AAAA Service (non-existing service) - { - Qname: "svc0.testns.svc.cluster.local.", Qtype: dns.TypeAAAA, - Rcode: dns.RcodeNameError, - Ns: []dns.RR{ - test.SOA("cluster.local. 300 IN SOA ns.dns.cluster.local. hostmaster.cluster.local. 1499347823 7200 1800 86400 60"), - }, - }, - // A Service (non-existing service) - { - Qname: "svc0.testns.svc.cluster.local.", Qtype: dns.TypeA, - Rcode: dns.RcodeNameError, - Ns: []dns.RR{ - test.SOA("cluster.local. 300 IN SOA ns.dns.cluster.local. hostmaster.cluster.local. 1499347823 7200 1800 86400 60"), - }, - }, - // A Service (non-existing namespace) - { - Qname: "svc0.svc-nons.svc.cluster.local.", Qtype: dns.TypeA, - Rcode: dns.RcodeNameError, - Ns: []dns.RR{ - test.SOA("cluster.local. 300 IN SOA ns.dns.cluster.local. hostmaster.cluster.local. 1499347823 7200 1800 86400 60"), - }, - }, - // TXT Schema - { - Qname: "dns-version.cluster.local.", Qtype: dns.TypeTXT, - Rcode: dns.RcodeSuccess, - Answer: []dns.RR{ - test.TXT("dns-version.cluster.local 28800 IN TXT 1.0.1"), - }, - }, - // A Service (Headless) does not exist - { - Qname: "bogusendpoint.hdls1.testns.svc.cluster.local.", Qtype: dns.TypeA, - Rcode: dns.RcodeNameError, - Ns: []dns.RR{ - test.SOA("cluster.local. 300 IN SOA ns.dns.cluster.local. hostmaster.cluster.local. 1499347823 7200 1800 86400 60"), - }, - }, - // A Service does not exist - { - Qname: "bogusendpoint.svc0.testns.svc.cluster.local.", Qtype: dns.TypeA, - Rcode: dns.RcodeNameError, - Ns: []dns.RR{ - test.SOA("cluster.local. 300 IN SOA ns.dns.cluster.local. hostmaster.cluster.local. 1499347823 7200 1800 86400 60"), - }, - }, - // AAAA Service - { - Qname: "svc6.testns.svc.cluster.local.", Qtype: dns.TypeAAAA, - Rcode: dns.RcodeSuccess, - Answer: []dns.RR{ - test.AAAA("svc6.testns.svc.cluster.local. 5 IN AAAA 1234:abcd::1"), - }, - }, - // SRV - { - Qname: "_http._tcp.svc6.testns.svc.cluster.local.", Qtype: dns.TypeSRV, - Rcode: dns.RcodeSuccess, - Answer: []dns.RR{ - test.SRV("_http._tcp.svc6.testns.svc.cluster.local. 5 IN SRV 0 100 80 svc6.testns.svc.cluster.local."), - }, - Extra: []dns.RR{ - test.AAAA("svc6.testns.svc.cluster.local. 5 IN AAAA 1234:abcd::1"), - }, - }, - // AAAA Service (Headless) - { - Qname: "hdls1.testns.svc.cluster.local.", Qtype: dns.TypeAAAA, - Rcode: dns.RcodeSuccess, - Answer: []dns.RR{ - test.AAAA("hdls1.testns.svc.cluster.local. 5 IN AAAA 5678:abcd::1"), - test.AAAA("hdls1.testns.svc.cluster.local. 5 IN AAAA 5678:abcd::2"), - }, - }, - // AAAA Endpoint - { - Qname: "5678-abcd--1.hdls1.testns.svc.cluster.local.", Qtype: dns.TypeAAAA, - Rcode: dns.RcodeSuccess, - Answer: []dns.RR{ - test.AAAA("5678-abcd--1.hdls1.testns.svc.cluster.local. 5 IN AAAA 5678:abcd::1"), - }, - }, - - { - Qname: "svc.cluster.local.", Qtype: dns.TypeA, - Rcode: dns.RcodeSuccess, - Ns: []dns.RR{ - test.SOA("cluster.local. 303 IN SOA ns.dns.cluster.local. hostmaster.cluster.local. 1499347823 7200 1800 86400 60"), - }, - }, - { - Qname: "pod.cluster.local.", Qtype: dns.TypeA, - Rcode: dns.RcodeSuccess, - Ns: []dns.RR{ - test.SOA("cluster.local. 303 IN SOA ns.dns.cluster.local. hostmaster.cluster.local. 1499347823 7200 1800 86400 60"), - }, - }, -} - -func TestServeDNS(t *testing.T) { - - k := New([]string{"cluster.local."}) - k.APIConn = &APIConnServeTest{} - k.Next = test.NextHandler(dns.RcodeSuccess, nil) - ctx := context.TODO() - - for i, tc := range dnsTestCases { - r := tc.Msg() - - w := dnstest.NewRecorder(&test.ResponseWriter{}) - - _, err := k.ServeDNS(ctx, w, r) - if err != tc.Error { - t.Errorf("Test %d expected no error, got %v", i, err) - return - } - if tc.Error != nil { - continue - } - - resp := w.Msg - if resp == nil { - t.Fatalf("Test %d, got nil message and no error for %q", i, r.Question[0].Name) - } - - // Before sorting, make sure that CNAMES do not appear after their target records - test.CNAMEOrder(t, resp) - - test.SortAndCheck(t, resp, tc) - } -} - -type APIConnServeTest struct{} - -func (APIConnServeTest) HasSynced() bool { return true } -func (APIConnServeTest) Run() { return } -func (APIConnServeTest) Stop() error { return nil } -func (APIConnServeTest) EpIndexReverse(string) []*api.Endpoints { return nil } -func (APIConnServeTest) SvcIndexReverse(string) []*api.Service { return nil } -func (APIConnServeTest) Modified() int64 { return time.Now().Unix() } - -func (APIConnServeTest) PodIndex(string) []*api.Pod { - a := []*api.Pod{{ - ObjectMeta: meta.ObjectMeta{ - Namespace: "podns", - }, - Status: api.PodStatus{ - PodIP: "10.240.0.1", // Remote IP set in test.ResponseWriter - }, - }} - return a -} - -var svcIndex = map[string][]*api.Service{ - "svc1.testns": {{ - ObjectMeta: meta.ObjectMeta{ - Name: "svc1", - Namespace: "testns", - }, - Spec: api.ServiceSpec{ - Type: api.ServiceTypeClusterIP, - ClusterIP: "10.0.0.1", - Ports: []api.ServicePort{{ - Name: "http", - Protocol: "tcp", - Port: 80, - }}, - }, - }}, - "svcempty.testns": {{ - ObjectMeta: meta.ObjectMeta{ - Name: "svcempty", - Namespace: "testns", - }, - Spec: api.ServiceSpec{ - Type: api.ServiceTypeClusterIP, - ClusterIP: "10.0.0.1", - Ports: []api.ServicePort{{ - Name: "http", - Protocol: "tcp", - Port: 80, - }}, - }, - }}, - "svc6.testns": {{ - ObjectMeta: meta.ObjectMeta{ - Name: "svc6", - Namespace: "testns", - }, - Spec: api.ServiceSpec{ - Type: api.ServiceTypeClusterIP, - ClusterIP: "1234:abcd::1", - Ports: []api.ServicePort{{ - Name: "http", - Protocol: "tcp", - Port: 80, - }}, - }, - }}, - "hdls1.testns": {{ - ObjectMeta: meta.ObjectMeta{ - Name: "hdls1", - Namespace: "testns", - }, - Spec: api.ServiceSpec{ - Type: api.ServiceTypeClusterIP, - ClusterIP: api.ClusterIPNone, - }, - }}, - "external.testns": {{ - ObjectMeta: meta.ObjectMeta{ - Name: "external", - Namespace: "testns", - }, - Spec: api.ServiceSpec{ - ExternalName: "ext.interwebs.test", - Ports: []api.ServicePort{{ - Name: "http", - Protocol: "tcp", - Port: 80, - }}, - Type: api.ServiceTypeExternalName, - }, - }}, -} - -func (APIConnServeTest) SvcIndex(s string) []*api.Service { - return svcIndex[s] -} - -func (APIConnServeTest) ServiceList() []*api.Service { - var svcs []*api.Service - for _, svc := range svcIndex { - svcs = append(svcs, svc...) - } - return svcs -} - -var epsIndex = map[string][]*api.Endpoints{ - "svc1.testns": {{ - Subsets: []api.EndpointSubset{ - { - Addresses: []api.EndpointAddress{ - { - IP: "172.0.0.1", - Hostname: "ep1a", - }, - }, - Ports: []api.EndpointPort{ - { - Port: 80, - Protocol: "tcp", - Name: "http", - }, - }, - }, - }, - ObjectMeta: meta.ObjectMeta{ - Name: "svc1", - Namespace: "testns", - }, - }}, - "svcempty.testns": {{ - Subsets: []api.EndpointSubset{ - { - Addresses: nil, - Ports: []api.EndpointPort{ - { - Port: 80, - Protocol: "tcp", - Name: "http", - }, - }, - }, - }, - ObjectMeta: meta.ObjectMeta{ - Name: "svcempty", - Namespace: "testns", - }, - }}, - "hdls1.testns": {{ - Subsets: []api.EndpointSubset{ - { - Addresses: []api.EndpointAddress{ - { - IP: "172.0.0.2", - }, - { - IP: "172.0.0.3", - }, - { - IP: "172.0.0.4", - Hostname: "dup-name", - }, - { - IP: "172.0.0.5", - Hostname: "dup-name", - }, - { - IP: "5678:abcd::1", - }, - { - IP: "5678:abcd::2", - }, - }, - Ports: []api.EndpointPort{ - { - Port: 80, - Protocol: "tcp", - Name: "http", - }, - }, - }, - }, - ObjectMeta: meta.ObjectMeta{ - Name: "hdls1", - Namespace: "testns", - }, - }}, -} - -func (APIConnServeTest) EpIndex(s string) []*api.Endpoints { - return epsIndex[s] -} - -func (APIConnServeTest) EndpointsList() []*api.Endpoints { - var eps []*api.Endpoints - for _, ep := range epsIndex { - eps = append(eps, ep...) - } - return eps - -} - -func (APIConnServeTest) GetNodeByName(name string) (*api.Node, error) { - return &api.Node{ - ObjectMeta: meta.ObjectMeta{ - Name: "test.node.foo.bar", - }, - }, nil -} - -func (APIConnServeTest) GetNamespaceByName(name string) (*api.Namespace, error) { - if name == "pod-nons" { // handler_pod_verified_test.go uses this for non-existent namespace. - return &api.Namespace{}, nil - } - return &api.Namespace{ - ObjectMeta: meta.ObjectMeta{ - Name: name, - }, - }, nil -} diff --git a/vendor/github.com/coredns/coredns/plugin/kubernetes/health.go b/vendor/github.com/coredns/coredns/plugin/kubernetes/health.go deleted file mode 100644 index 24374921..00000000 --- a/vendor/github.com/coredns/coredns/plugin/kubernetes/health.go +++ /dev/null @@ -1,4 +0,0 @@ -package kubernetes - -// Health implements the health.Healther interface. -func (k *Kubernetes) Health() bool { return k.APIConn.HasSynced() } diff --git a/vendor/github.com/coredns/coredns/plugin/kubernetes/kubernetes.go b/vendor/github.com/coredns/coredns/plugin/kubernetes/kubernetes.go deleted file mode 100644 index af0e64ee..00000000 --- a/vendor/github.com/coredns/coredns/plugin/kubernetes/kubernetes.go +++ /dev/null @@ -1,504 +0,0 @@ -// Package kubernetes provides the kubernetes backend. -package kubernetes - -import ( - "errors" - "fmt" - "net" - "strings" - "sync/atomic" - "time" - - "github.com/coredns/coredns/plugin" - "github.com/coredns/coredns/plugin/etcd/msg" - "github.com/coredns/coredns/plugin/pkg/dnsutil" - "github.com/coredns/coredns/plugin/pkg/fall" - "github.com/coredns/coredns/plugin/pkg/healthcheck" - "github.com/coredns/coredns/plugin/pkg/upstream" - "github.com/coredns/coredns/request" - - "github.com/miekg/dns" - api "k8s.io/api/core/v1" - meta "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/client-go/kubernetes" - "k8s.io/client-go/rest" - "k8s.io/client-go/tools/clientcmd" - clientcmdapi "k8s.io/client-go/tools/clientcmd/api" -) - -// Kubernetes implements a plugin that connects to a Kubernetes cluster. -type Kubernetes struct { - Next plugin.Handler - Zones []string - Upstream upstream.Upstream - APIServerList []string - APIProxy *apiProxy - APICertAuth string - APIClientCert string - APIClientKey string - APIConn dnsController - Namespaces map[string]bool - podMode string - endpointNameMode bool - Fall fall.F - ttl uint32 - opts dnsControlOpts - - primaryZoneIndex int - interfaceAddrsFunc func() net.IP - autoPathSearch []string // Local search path from /etc/resolv.conf. Needed for autopath. - TransferTo []string -} - -// New returns a initialized Kubernetes. It default interfaceAddrFunc to return 127.0.0.1. All other -// values default to their zero value, primaryZoneIndex will thus point to the first zone. -func New(zones []string) *Kubernetes { - k := new(Kubernetes) - k.Zones = zones - k.Namespaces = make(map[string]bool) - k.interfaceAddrsFunc = func() net.IP { return net.ParseIP("127.0.0.1") } - k.podMode = podModeDisabled - k.ttl = defaultTTL - - return k -} - -const ( - // podModeDisabled is the default value where pod requests are ignored - podModeDisabled = "disabled" - // podModeVerified is where Pod requests are answered only if they exist - podModeVerified = "verified" - // podModeInsecure is where pod requests are answered without verfying they exist - podModeInsecure = "insecure" - // DNSSchemaVersion is the schema version: https://github.com/kubernetes/dns/blob/master/docs/specification.md - DNSSchemaVersion = "1.0.1" - // Svc is the DNS schema for kubernetes services - Svc = "svc" - // Pod is the DNS schema for kubernetes pods - Pod = "pod" - // defaultTTL to apply to all answers. - defaultTTL = 5 -) - -var ( - errNoItems = errors.New("no items found") - errNsNotExposed = errors.New("namespace is not exposed") - errInvalidRequest = errors.New("invalid query name") -) - -// Services implements the ServiceBackend interface. -func (k *Kubernetes) Services(state request.Request, exact bool, opt plugin.Options) (svcs []msg.Service, err error) { - // We're looking again at types, which we've already done in ServeDNS, but there are some types k8s just can't answer. - switch state.QType() { - - case dns.TypeTXT: - // 1 label + zone, label must be "dns-version". - t, _ := dnsutil.TrimZone(state.Name(), state.Zone) - - segs := dns.SplitDomainName(t) - if len(segs) != 1 { - return nil, fmt.Errorf("kubernetes: TXT query can only be for dns-version: %s", state.QName()) - } - if segs[0] != "dns-version" { - return nil, nil - } - svc := msg.Service{Text: DNSSchemaVersion, TTL: 28800, Key: msg.Path(state.QName(), "coredns")} - return []msg.Service{svc}, nil - - case dns.TypeNS: - // We can only get here if the qname equals the zone, see ServeDNS in handler.go. - ns := k.nsAddr() - svc := msg.Service{Host: ns.A.String(), Key: msg.Path(state.QName(), "coredns")} - return []msg.Service{svc}, nil - } - - if state.QType() == dns.TypeA && isDefaultNS(state.Name(), state.Zone) { - // If this is an A request for "ns.dns", respond with a "fake" record for coredns. - // SOA records always use this hardcoded name - ns := k.nsAddr() - svc := msg.Service{Host: ns.A.String(), Key: msg.Path(state.QName(), "coredns")} - return []msg.Service{svc}, nil - } - - s, e := k.Records(state, false) - - // SRV for external services is not yet implemented, so remove those records. - - if state.QType() != dns.TypeSRV { - return s, e - } - - internal := []msg.Service{} - for _, svc := range s { - if t, _ := svc.HostType(); t != dns.TypeCNAME { - internal = append(internal, svc) - } - } - - return internal, e -} - -// primaryZone will return the first non-reverse zone being handled by this plugin -func (k *Kubernetes) primaryZone() string { return k.Zones[k.primaryZoneIndex] } - -// Lookup implements the ServiceBackend interface. -func (k *Kubernetes) Lookup(state request.Request, name string, typ uint16) (*dns.Msg, error) { - return k.Upstream.Lookup(state, name, typ) -} - -// IsNameError implements the ServiceBackend interface. -func (k *Kubernetes) IsNameError(err error) bool { - return err == errNoItems || err == errNsNotExposed || err == errInvalidRequest -} - -func (k *Kubernetes) getClientConfig() (*rest.Config, error) { - loadingRules := &clientcmd.ClientConfigLoadingRules{} - overrides := &clientcmd.ConfigOverrides{} - clusterinfo := clientcmdapi.Cluster{} - authinfo := clientcmdapi.AuthInfo{} - - // Connect to API from in cluster - if len(k.APIServerList) == 0 { - cc, err := rest.InClusterConfig() - if err != nil { - return nil, err - } - cc.ContentType = "application/vnd.kubernetes.protobuf" - return cc, err - } - - // Connect to API from out of cluster - endpoint := k.APIServerList[0] - if len(k.APIServerList) > 1 { - // Use a random port for api proxy, will get the value later through listener.Addr() - listener, err := net.Listen("tcp", "127.0.0.1:0") - if err != nil { - return nil, fmt.Errorf("failed to create kubernetes api proxy: %v", err) - } - k.APIProxy = &apiProxy{ - listener: listener, - handler: proxyHandler{ - HealthCheck: healthcheck.HealthCheck{ - FailTimeout: 3 * time.Second, - MaxFails: 1, - Path: "/", - Interval: 5 * time.Second, - }, - }, - } - k.APIProxy.handler.Hosts = make([]*healthcheck.UpstreamHost, len(k.APIServerList)) - for i, entry := range k.APIServerList { - - uh := &healthcheck.UpstreamHost{ - Name: strings.TrimPrefix(entry, "http://"), - - CheckDown: func(upstream *proxyHandler) healthcheck.UpstreamHostDownFunc { - return func(uh *healthcheck.UpstreamHost) bool { - - fails := atomic.LoadInt32(&uh.Fails) - if fails >= upstream.MaxFails && upstream.MaxFails != 0 { - return true - } - return false - } - }(&k.APIProxy.handler), - } - - k.APIProxy.handler.Hosts[i] = uh - } - k.APIProxy.Handler = &k.APIProxy.handler - - // Find the random port used for api proxy - endpoint = fmt.Sprintf("http://%s", listener.Addr()) - } - clusterinfo.Server = endpoint - - if len(k.APICertAuth) > 0 { - clusterinfo.CertificateAuthority = k.APICertAuth - } - if len(k.APIClientCert) > 0 { - authinfo.ClientCertificate = k.APIClientCert - } - if len(k.APIClientKey) > 0 { - authinfo.ClientKey = k.APIClientKey - } - - overrides.ClusterInfo = clusterinfo - overrides.AuthInfo = authinfo - clientConfig := clientcmd.NewNonInteractiveDeferredLoadingClientConfig(loadingRules, overrides) - - cc, err := clientConfig.ClientConfig() - if err != nil { - return nil, err - } - cc.ContentType = "application/vnd.kubernetes.protobuf" - return cc, err - -} - -// InitKubeCache initializes a new Kubernetes cache. -func (k *Kubernetes) InitKubeCache() (err error) { - config, err := k.getClientConfig() - if err != nil { - return err - } - - kubeClient, err := kubernetes.NewForConfig(config) - if err != nil { - return fmt.Errorf("failed to create kubernetes notification controller: %q", err) - } - - if k.opts.labelSelector != nil { - var selector labels.Selector - selector, err = meta.LabelSelectorAsSelector(k.opts.labelSelector) - if err != nil { - return fmt.Errorf("unable to create Selector for LabelSelector '%s': %q", k.opts.labelSelector, err) - } - k.opts.selector = selector - } - - k.opts.initPodCache = k.podMode == podModeVerified - - k.APIConn = newdnsController(kubeClient, k.opts) - - return err -} - -// Records looks up services in kubernetes. -func (k *Kubernetes) Records(state request.Request, exact bool) ([]msg.Service, error) { - r, e := parseRequest(state) - if e != nil { - return nil, e - } - if r.podOrSvc == "" { - return nil, nil - } - - if dnsutil.IsReverse(state.Name()) > 0 { - return nil, errNoItems - } - - if !wildcard(r.namespace) && !k.namespaceExposed(r.namespace) { - return nil, errNsNotExposed - } - - if r.podOrSvc == Pod { - pods, err := k.findPods(r, state.Zone) - return pods, err - } - - services, err := k.findServices(r, state.Zone) - return services, err -} - -func endpointHostname(addr api.EndpointAddress, endpointNameMode bool) string { - if addr.Hostname != "" { - return strings.ToLower(addr.Hostname) - } - if endpointNameMode && addr.TargetRef != nil && addr.TargetRef.Name != "" { - return addr.TargetRef.Name - } - if strings.Contains(addr.IP, ".") { - return strings.Replace(addr.IP, ".", "-", -1) - } - if strings.Contains(addr.IP, ":") { - return strings.ToLower(strings.Replace(addr.IP, ":", "-", -1)) - } - return "" -} - -func (k *Kubernetes) findPods(r recordRequest, zone string) (pods []msg.Service, err error) { - if k.podMode == podModeDisabled { - return nil, errNoItems - } - - namespace := r.namespace - podname := r.service - zonePath := msg.Path(zone, "coredns") - ip := "" - - if strings.Count(podname, "-") == 3 && !strings.Contains(podname, "--") { - ip = strings.Replace(podname, "-", ".", -1) - } else { - ip = strings.Replace(podname, "-", ":", -1) - } - - if k.podMode == podModeInsecure { - if !wildcard(namespace) && !k.namespace(namespace) { // no wildcard, but namespace does not exist - return nil, errNoItems - } - - // If ip does not parse as an IP address, we return an error, otherwise we assume a CNAME and will try to resolve it in backend_lookup.go - if net.ParseIP(ip) == nil { - return nil, errNoItems - } - - return []msg.Service{{Key: strings.Join([]string{zonePath, Pod, namespace, podname}, "/"), Host: ip, TTL: k.ttl}}, err - } - - err = errNoItems - if wildcard(podname) && !wildcard(namespace) { - // If namespace exist, err should be nil, so that we return nodata instead of NXDOMAIN - if k.namespace(namespace) { - err = nil - } - } - - // PodModeVerified - for _, p := range k.APIConn.PodIndex(ip) { - // If namespace has a wildcard, filter results against Corefile namespace list. - if wildcard(namespace) && !k.namespaceExposed(p.Namespace) { - continue - } - - // exclude pods in the process of termination - if !p.ObjectMeta.DeletionTimestamp.IsZero() { - continue - } - - // check for matching ip and namespace - if ip == p.Status.PodIP && match(namespace, p.Namespace) { - s := msg.Service{Key: strings.Join([]string{zonePath, Pod, namespace, podname}, "/"), Host: ip, TTL: k.ttl} - pods = append(pods, s) - - err = nil - } - } - return pods, err -} - -// findServices returns the services matching r from the cache. -func (k *Kubernetes) findServices(r recordRequest, zone string) (services []msg.Service, err error) { - zonePath := msg.Path(zone, "coredns") - - err = errNoItems - if wildcard(r.service) && !wildcard(r.namespace) { - // If namespace exist, err should be nil, so that we return nodata instead of NXDOMAIN - if k.namespace(namespace) { - err = nil - } - } - - var ( - endpointsListFunc func() []*api.Endpoints - endpointsList []*api.Endpoints - serviceList []*api.Service - ) - - if wildcard(r.service) || wildcard(r.namespace) { - serviceList = k.APIConn.ServiceList() - endpointsListFunc = func() []*api.Endpoints { return k.APIConn.EndpointsList() } - } else { - idx := r.service + "." + r.namespace - serviceList = k.APIConn.SvcIndex(idx) - endpointsListFunc = func() []*api.Endpoints { return k.APIConn.EpIndex(idx) } - } - - for _, svc := range serviceList { - if !(match(r.namespace, svc.Namespace) && match(r.service, svc.Name)) { - continue - } - - // If namespace has a wildcard, filter results against Corefile namespace list. - // (Namespaces without a wildcard were filtered before the call to this function.) - if wildcard(r.namespace) && !k.namespaceExposed(svc.Namespace) { - continue - } - - if k.opts.ignoreEmptyService && svc.Spec.ClusterIP != api.ClusterIPNone { - // serve NXDOMAIN if no endpoint is able to answer - podsCount := 0 - for _, ep := range endpointsListFunc() { - for _, eps := range ep.Subsets { - podsCount = podsCount + len(eps.Addresses) - } - } - - if podsCount == 0 { - continue - } - } - - // Endpoint query or headless service - if svc.Spec.ClusterIP == api.ClusterIPNone || r.endpoint != "" { - if endpointsList == nil { - endpointsList = endpointsListFunc() - } - for _, ep := range endpointsList { - if ep.ObjectMeta.Name != svc.Name || ep.ObjectMeta.Namespace != svc.Namespace { - continue - } - - for _, eps := range ep.Subsets { - for _, addr := range eps.Addresses { - - // See comments in parse.go parseRequest about the endpoint handling. - - if r.endpoint != "" { - if !match(r.endpoint, endpointHostname(addr, k.endpointNameMode)) { - continue - } - } - - for _, p := range eps.Ports { - if !(match(r.port, p.Name) && match(r.protocol, string(p.Protocol))) { - continue - } - s := msg.Service{Host: addr.IP, Port: int(p.Port), TTL: k.ttl} - s.Key = strings.Join([]string{zonePath, Svc, svc.Namespace, svc.Name, endpointHostname(addr, k.endpointNameMode)}, "/") - - err = nil - - services = append(services, s) - } - } - } - } - continue - } - - // External service - if svc.Spec.Type == api.ServiceTypeExternalName { - s := msg.Service{Key: strings.Join([]string{zonePath, Svc, svc.Namespace, svc.Name}, "/"), Host: svc.Spec.ExternalName, TTL: k.ttl} - if t, _ := s.HostType(); t == dns.TypeCNAME { - s.Key = strings.Join([]string{zonePath, Svc, svc.Namespace, svc.Name}, "/") - services = append(services, s) - - err = nil - } - continue - } - - // ClusterIP service - for _, p := range svc.Spec.Ports { - if !(match(r.port, p.Name) && match(r.protocol, string(p.Protocol))) { - continue - } - - err = nil - - s := msg.Service{Host: svc.Spec.ClusterIP, Port: int(p.Port), TTL: k.ttl} - s.Key = strings.Join([]string{zonePath, Svc, svc.Namespace, svc.Name}, "/") - - services = append(services, s) - } - } - return services, err -} - -// match checks if a and b are equal taking wildcards into account. -func match(a, b string) bool { - if wildcard(a) { - return true - } - if wildcard(b) { - return true - } - return strings.EqualFold(a, b) -} - -// wildcard checks whether s contains a wildcard value defined as "*" or "any". -func wildcard(s string) bool { - return s == "*" || s == "any" -} diff --git a/vendor/github.com/coredns/coredns/plugin/kubernetes/kubernetes_apex_test.go b/vendor/github.com/coredns/coredns/plugin/kubernetes/kubernetes_apex_test.go deleted file mode 100644 index da408472..00000000 --- a/vendor/github.com/coredns/coredns/plugin/kubernetes/kubernetes_apex_test.go +++ /dev/null @@ -1,89 +0,0 @@ -package kubernetes - -import ( - "context" - "testing" - - "github.com/coredns/coredns/plugin/pkg/dnstest" - "github.com/coredns/coredns/plugin/test" - - "github.com/miekg/dns" -) - -var kubeApexCases = []test.Case{ - { - Qname: "cluster.local.", Qtype: dns.TypeSOA, - Rcode: dns.RcodeSuccess, - Answer: []dns.RR{ - test.SOA("cluster.local. 303 IN SOA ns.dns.cluster.local. hostmaster.cluster.local. 1499347823 7200 1800 86400 60"), - }, - }, - { - Qname: "cluster.local.", Qtype: dns.TypeHINFO, - Rcode: dns.RcodeSuccess, - Ns: []dns.RR{ - test.SOA("cluster.local. 303 IN SOA ns.dns.cluster.local. hostmaster.cluster.local. 1499347823 7200 1800 86400 60"), - }, - }, - { - Qname: "cluster.local.", Qtype: dns.TypeNS, - Rcode: dns.RcodeSuccess, - Answer: []dns.RR{ - test.NS("cluster.local. 303 IN NS ns.dns.cluster.local."), - }, - Extra: []dns.RR{ - test.A("ns.dns.cluster.local. 303 IN A 127.0.0.1"), - }, - }, - { - Qname: "cluster.local.", Qtype: dns.TypeA, - Rcode: dns.RcodeSuccess, - Ns: []dns.RR{ - test.SOA("cluster.local. 303 IN SOA ns.dns.cluster.local. hostmaster.cluster.local. 1499347823 7200 1800 86400 60"), - }, - }, - { - Qname: "cluster.local.", Qtype: dns.TypeAAAA, - Rcode: dns.RcodeSuccess, - Ns: []dns.RR{ - test.SOA("cluster.local. 303 IN SOA ns.dns.cluster.local. hostmaster.cluster.local. 1499347823 7200 1800 86400 60"), - }, - }, - { - Qname: "cluster.local.", Qtype: dns.TypeSRV, - Rcode: dns.RcodeSuccess, - Ns: []dns.RR{ - test.SOA("cluster.local. 303 IN SOA ns.dns.cluster.local. hostmaster.cluster.local. 1499347823 7200 1800 86400 60"), - }, - }, -} - -func TestServeDNSApex(t *testing.T) { - - k := New([]string{"cluster.local."}) - k.APIConn = &APIConnServeTest{} - k.Next = test.NextHandler(dns.RcodeSuccess, nil) - ctx := context.TODO() - - for i, tc := range kubeApexCases { - r := tc.Msg() - - w := dnstest.NewRecorder(&test.ResponseWriter{}) - - _, err := k.ServeDNS(ctx, w, r) - if err != tc.Error { - t.Errorf("Test %d, expected no error, got %v\n", i, err) - return - } - if tc.Error != nil { - continue - } - - resp := w.Msg - if resp == nil { - t.Fatalf("Test %d, got nil message and no error ford", i) - } - - test.SortAndCheck(t, resp, tc) - } -} diff --git a/vendor/github.com/coredns/coredns/plugin/kubernetes/kubernetes_test.go b/vendor/github.com/coredns/coredns/plugin/kubernetes/kubernetes_test.go deleted file mode 100644 index e10fe894..00000000 --- a/vendor/github.com/coredns/coredns/plugin/kubernetes/kubernetes_test.go +++ /dev/null @@ -1,392 +0,0 @@ -package kubernetes - -import ( - "testing" - - "github.com/coredns/coredns/plugin" - "github.com/coredns/coredns/request" - - "github.com/miekg/dns" - api "k8s.io/api/core/v1" - meta "k8s.io/apimachinery/pkg/apis/meta/v1" -) - -func TestWildcard(t *testing.T) { - var tests = []struct { - s string - expected bool - }{ - {"mynamespace", false}, - {"*", true}, - {"any", true}, - {"my*space", false}, - {"*space", false}, - {"myname*", false}, - } - - for _, te := range tests { - got := wildcard(te.s) - if got != te.expected { - t.Errorf("Expected Wildcard result '%v' for example '%v', got '%v'.", te.expected, te.s, got) - } - } -} - -func TestEndpointHostname(t *testing.T) { - var tests = []struct { - ip string - hostname string - expected string - podName string - endpointNameMode bool - }{ - {"10.11.12.13", "", "10-11-12-13", "", false}, - {"10.11.12.13", "epname", "epname", "", false}, - {"10.11.12.13", "", "10-11-12-13", "hello-abcde", false}, - {"10.11.12.13", "epname", "epname", "hello-abcde", false}, - {"10.11.12.13", "epname", "epname", "hello-abcde", true}, - {"10.11.12.13", "", "hello-abcde", "hello-abcde", true}, - } - for _, test := range tests { - result := endpointHostname(api.EndpointAddress{IP: test.ip, Hostname: test.hostname, TargetRef: &api.ObjectReference{Name: test.podName}}, test.endpointNameMode) - if result != test.expected { - t.Errorf("Expected endpoint name for (ip:%v hostname:%v) to be '%v', but got '%v'", test.ip, test.hostname, test.expected, result) - } - } -} - -type APIConnServiceTest struct{} - -func (APIConnServiceTest) HasSynced() bool { return true } -func (APIConnServiceTest) Run() { return } -func (APIConnServiceTest) Stop() error { return nil } -func (APIConnServiceTest) PodIndex(string) []*api.Pod { return nil } -func (APIConnServiceTest) SvcIndexReverse(string) []*api.Service { return nil } -func (APIConnServiceTest) EpIndexReverse(string) []*api.Endpoints { return nil } -func (APIConnServiceTest) Modified() int64 { return 0 } - -func (APIConnServiceTest) SvcIndex(string) []*api.Service { - svcs := []*api.Service{ - { - ObjectMeta: meta.ObjectMeta{ - Name: "svc1", - Namespace: "testns", - }, - Spec: api.ServiceSpec{ - ClusterIP: "10.0.0.1", - Ports: []api.ServicePort{{ - Name: "http", - Protocol: "tcp", - Port: 80, - }}, - }, - }, - { - ObjectMeta: meta.ObjectMeta{ - Name: "hdls1", - Namespace: "testns", - }, - Spec: api.ServiceSpec{ - ClusterIP: api.ClusterIPNone, - }, - }, - { - ObjectMeta: meta.ObjectMeta{ - Name: "external", - Namespace: "testns", - }, - Spec: api.ServiceSpec{ - ExternalName: "coredns.io", - Ports: []api.ServicePort{{ - Name: "http", - Protocol: "tcp", - Port: 80, - }}, - Type: api.ServiceTypeExternalName, - }, - }, - } - return svcs -} - -func (APIConnServiceTest) ServiceList() []*api.Service { - svcs := []*api.Service{ - { - ObjectMeta: meta.ObjectMeta{ - Name: "svc1", - Namespace: "testns", - }, - Spec: api.ServiceSpec{ - ClusterIP: "10.0.0.1", - Ports: []api.ServicePort{{ - Name: "http", - Protocol: "tcp", - Port: 80, - }}, - }, - }, - { - ObjectMeta: meta.ObjectMeta{ - Name: "hdls1", - Namespace: "testns", - }, - Spec: api.ServiceSpec{ - ClusterIP: api.ClusterIPNone, - }, - }, - { - ObjectMeta: meta.ObjectMeta{ - Name: "external", - Namespace: "testns", - }, - Spec: api.ServiceSpec{ - ExternalName: "coredns.io", - Ports: []api.ServicePort{{ - Name: "http", - Protocol: "tcp", - Port: 80, - }}, - Type: api.ServiceTypeExternalName, - }, - }, - } - return svcs -} - -func (APIConnServiceTest) EpIndex(string) []*api.Endpoints { - n := "test.node.foo.bar" - - eps := []*api.Endpoints{ - { - Subsets: []api.EndpointSubset{ - { - Addresses: []api.EndpointAddress{ - { - IP: "172.0.0.1", - Hostname: "ep1a", - }, - }, - Ports: []api.EndpointPort{ - { - Port: 80, - Protocol: "tcp", - Name: "http", - }, - }, - }, - }, - ObjectMeta: meta.ObjectMeta{ - Name: "svc1", - Namespace: "testns", - }, - }, - { - Subsets: []api.EndpointSubset{ - { - Addresses: []api.EndpointAddress{ - { - IP: "172.0.0.2", - }, - }, - Ports: []api.EndpointPort{ - { - Port: 80, - Protocol: "tcp", - Name: "http", - }, - }, - }, - }, - ObjectMeta: meta.ObjectMeta{ - Name: "hdls1", - Namespace: "testns", - }, - }, - { - Subsets: []api.EndpointSubset{ - { - Addresses: []api.EndpointAddress{ - { - IP: "172.0.0.3", - }, - }, - Ports: []api.EndpointPort{ - { - Port: 80, - Protocol: "tcp", - Name: "http", - }, - }, - }, - }, - ObjectMeta: meta.ObjectMeta{ - Name: "hdls1", - Namespace: "testns", - }, - }, - { - Subsets: []api.EndpointSubset{ - { - Addresses: []api.EndpointAddress{ - { - IP: "10.9.8.7", - NodeName: &n, - }, - }, - }, - }, - }, - } - return eps -} - -func (APIConnServiceTest) EndpointsList() []*api.Endpoints { - n := "test.node.foo.bar" - - eps := []*api.Endpoints{ - { - Subsets: []api.EndpointSubset{ - { - Addresses: []api.EndpointAddress{ - { - IP: "172.0.0.1", - Hostname: "ep1a", - }, - }, - Ports: []api.EndpointPort{ - { - Port: 80, - Protocol: "tcp", - Name: "http", - }, - }, - }, - }, - ObjectMeta: meta.ObjectMeta{ - Name: "svc1", - Namespace: "testns", - }, - }, - { - Subsets: []api.EndpointSubset{ - { - Addresses: []api.EndpointAddress{ - { - IP: "172.0.0.2", - }, - }, - Ports: []api.EndpointPort{ - { - Port: 80, - Protocol: "tcp", - Name: "http", - }, - }, - }, - }, - ObjectMeta: meta.ObjectMeta{ - Name: "hdls1", - Namespace: "testns", - }, - }, - { - Subsets: []api.EndpointSubset{ - { - Addresses: []api.EndpointAddress{ - { - IP: "172.0.0.3", - }, - }, - Ports: []api.EndpointPort{ - { - Port: 80, - Protocol: "tcp", - Name: "http", - }, - }, - }, - }, - ObjectMeta: meta.ObjectMeta{ - Name: "hdls1", - Namespace: "testns", - }, - }, - { - Subsets: []api.EndpointSubset{ - { - Addresses: []api.EndpointAddress{ - { - IP: "10.9.8.7", - NodeName: &n, - }, - }, - }, - }, - }, - } - return eps -} - -func (APIConnServiceTest) GetNodeByName(name string) (*api.Node, error) { - return &api.Node{ - ObjectMeta: meta.ObjectMeta{ - Name: "test.node.foo.bar", - }, - }, nil -} - -func (APIConnServiceTest) GetNamespaceByName(name string) (*api.Namespace, error) { - return &api.Namespace{ - ObjectMeta: meta.ObjectMeta{ - Name: name, - }, - }, nil -} - -func TestServices(t *testing.T) { - - k := New([]string{"interwebs.test."}) - k.APIConn = &APIConnServiceTest{} - - type svcAns struct { - host string - key string - } - type svcTest struct { - qname string - qtype uint16 - answer svcAns - } - tests := []svcTest{ - // Cluster IP Services - {qname: "svc1.testns.svc.interwebs.test.", qtype: dns.TypeA, answer: svcAns{host: "10.0.0.1", key: "/coredns/test/interwebs/svc/testns/svc1"}}, - {qname: "_http._tcp.svc1.testns.svc.interwebs.test.", qtype: dns.TypeSRV, answer: svcAns{host: "10.0.0.1", key: "/coredns/test/interwebs/svc/testns/svc1"}}, - {qname: "ep1a.svc1.testns.svc.interwebs.test.", qtype: dns.TypeA, answer: svcAns{host: "172.0.0.1", key: "/coredns/test/interwebs/svc/testns/svc1/ep1a"}}, - - // External Services - {qname: "external.testns.svc.interwebs.test.", qtype: dns.TypeCNAME, answer: svcAns{host: "coredns.io", key: "/coredns/test/interwebs/svc/testns/external"}}, - } - - for i, test := range tests { - state := request.Request{ - Req: &dns.Msg{Question: []dns.Question{{Name: test.qname, Qtype: test.qtype}}}, - Zone: "interwebs.test.", // must match from k.Zones[0] - } - svcs, e := k.Services(state, false, plugin.Options{}) - if e != nil { - t.Errorf("Test %d: got error '%v'", i, e) - continue - } - if len(svcs) != 1 { - t.Errorf("Test %d, expected expected 1 answer, got %v", i, len(svcs)) - continue - } - - if test.answer.host != svcs[0].Host { - t.Errorf("Test %d, expected host '%v', got '%v'", i, test.answer.host, svcs[0].Host) - } - if test.answer.key != svcs[0].Key { - t.Errorf("Test %d, expected key '%v', got '%v'", i, test.answer.key, svcs[0].Key) - } - } -} diff --git a/vendor/github.com/coredns/coredns/plugin/kubernetes/local.go b/vendor/github.com/coredns/coredns/plugin/kubernetes/local.go deleted file mode 100644 index 961eb941..00000000 --- a/vendor/github.com/coredns/coredns/plugin/kubernetes/local.go +++ /dev/null @@ -1,41 +0,0 @@ -package kubernetes - -import ( - "net" -) - -func localPodIP() net.IP { - addrs, err := net.InterfaceAddrs() - if err != nil { - return nil - } - - for _, addr := range addrs { - ip, _, _ := net.ParseCIDR(addr.String()) - ip = ip.To4() - if ip == nil || ip.IsLoopback() { - continue - } - return ip - } - return nil -} - -func (k *Kubernetes) localNodeName() string { - localIP := k.interfaceAddrsFunc() - if localIP == nil { - return "" - } - - // Find endpoint matching localIP - for _, ep := range k.APIConn.EpIndexReverse(localIP.String()) { - for _, eps := range ep.Subsets { - for _, addr := range eps.Addresses { - if localIP.Equal(net.ParseIP(addr.IP)) { - return *addr.NodeName - } - } - } - } - return "" -} diff --git a/vendor/github.com/coredns/coredns/plugin/kubernetes/namespace.go b/vendor/github.com/coredns/coredns/plugin/kubernetes/namespace.go deleted file mode 100644 index 7dafc7ab..00000000 --- a/vendor/github.com/coredns/coredns/plugin/kubernetes/namespace.go +++ /dev/null @@ -1,20 +0,0 @@ -package kubernetes - -// namespace checks if namespace n exists in this cluster. This returns true -// even for non exposed namespaces, see namespaceExposed. -func (k *Kubernetes) namespace(n string) bool { - ns, err := k.APIConn.GetNamespaceByName(n) - if err != nil { - return false - } - return ns.ObjectMeta.Name == n -} - -// namespaceExposed returns true when the namespace is exposed. -func (k *Kubernetes) namespaceExposed(namespace string) bool { - _, ok := k.Namespaces[namespace] - if len(k.Namespaces) > 0 && !ok { - return false - } - return true -} diff --git a/vendor/github.com/coredns/coredns/plugin/kubernetes/ns.go b/vendor/github.com/coredns/coredns/plugin/kubernetes/ns.go deleted file mode 100644 index af5c8645..00000000 --- a/vendor/github.com/coredns/coredns/plugin/kubernetes/ns.go +++ /dev/null @@ -1,61 +0,0 @@ -package kubernetes - -import ( - "net" - "strings" - - "github.com/miekg/dns" - api "k8s.io/api/core/v1" -) - -func isDefaultNS(name, zone string) bool { - return strings.Index(name, defaultNSName) == 0 && strings.Index(name, zone) == len(defaultNSName) -} - -func (k *Kubernetes) nsAddr() *dns.A { - var ( - svcName string - svcNamespace string - ) - - rr := new(dns.A) - localIP := k.interfaceAddrsFunc() - rr.A = localIP - -FindEndpoint: - for _, ep := range k.APIConn.EpIndexReverse(localIP.String()) { - for _, eps := range ep.Subsets { - for _, addr := range eps.Addresses { - if localIP.Equal(net.ParseIP(addr.IP)) { - svcNamespace = ep.ObjectMeta.Namespace - svcName = ep.ObjectMeta.Name - break FindEndpoint - } - } - } - } - - if len(svcName) == 0 { - rr.Hdr.Name = defaultNSName - rr.A = localIP - return rr - } - -FindService: - for _, svc := range k.APIConn.ServiceList() { - if svcName == svc.Name && svcNamespace == svc.Namespace { - if svc.Spec.ClusterIP == api.ClusterIPNone { - rr.A = localIP - } else { - rr.A = net.ParseIP(svc.Spec.ClusterIP) - } - break FindService - } - } - - rr.Hdr.Name = strings.Join([]string{svcName, svcNamespace, "svc."}, ".") - - return rr -} - -const defaultNSName = "ns.dns." diff --git a/vendor/github.com/coredns/coredns/plugin/kubernetes/ns_test.go b/vendor/github.com/coredns/coredns/plugin/kubernetes/ns_test.go deleted file mode 100644 index 7dcc83ee..00000000 --- a/vendor/github.com/coredns/coredns/plugin/kubernetes/ns_test.go +++ /dev/null @@ -1,78 +0,0 @@ -package kubernetes - -import ( - "testing" - - api "k8s.io/api/core/v1" - meta "k8s.io/apimachinery/pkg/apis/meta/v1" -) - -type APIConnTest struct{} - -func (APIConnTest) HasSynced() bool { return true } -func (APIConnTest) Run() { return } -func (APIConnTest) Stop() error { return nil } -func (APIConnTest) PodIndex(string) []*api.Pod { return nil } -func (APIConnTest) SvcIndex(string) []*api.Service { return nil } -func (APIConnTest) SvcIndexReverse(string) []*api.Service { return nil } -func (APIConnTest) EpIndex(string) []*api.Endpoints { return nil } -func (APIConnTest) EndpointsList() []*api.Endpoints { return nil } -func (APIConnTest) Modified() int64 { return 0 } - -func (APIConnTest) ServiceList() []*api.Service { - svcs := []*api.Service{ - { - ObjectMeta: meta.ObjectMeta{ - Name: "dns-service", - Namespace: "kube-system", - }, - Spec: api.ServiceSpec{ - ClusterIP: "10.0.0.111", - }, - }, - } - return svcs -} - -func (APIConnTest) EpIndexReverse(string) []*api.Endpoints { - eps := []*api.Endpoints{ - { - Subsets: []api.EndpointSubset{ - { - Addresses: []api.EndpointAddress{ - { - IP: "127.0.0.1", - }, - }, - }, - }, - ObjectMeta: meta.ObjectMeta{ - Name: "dns-service", - Namespace: "kube-system", - }, - }, - } - return eps -} - -func (APIConnTest) GetNodeByName(name string) (*api.Node, error) { return &api.Node{}, nil } -func (APIConnTest) GetNamespaceByName(name string) (*api.Namespace, error) { - return &api.Namespace{}, nil -} - -func TestNsAddr(t *testing.T) { - - k := New([]string{"inter.webs.test."}) - k.APIConn = &APIConnTest{} - - cdr := k.nsAddr() - expected := "10.0.0.111" - - if cdr.A.String() != expected { - t.Errorf("Expected A to be %q, got %q", expected, cdr.A.String()) - } - expected = "dns-service.kube-system.svc." - if cdr.Hdr.Name != expected { - t.Errorf("Expected Hdr.Name to be %q, got %q", expected, cdr.Hdr.Name) - } -} diff --git a/vendor/github.com/coredns/coredns/plugin/kubernetes/parse.go b/vendor/github.com/coredns/coredns/plugin/kubernetes/parse.go deleted file mode 100644 index db723982..00000000 --- a/vendor/github.com/coredns/coredns/plugin/kubernetes/parse.go +++ /dev/null @@ -1,116 +0,0 @@ -package kubernetes - -import ( - "github.com/coredns/coredns/plugin/pkg/dnsutil" - "github.com/coredns/coredns/request" - - "github.com/miekg/dns" -) - -type recordRequest struct { - // The named port from the kubernetes DNS spec, this is the service part (think _https) from a well formed - // SRV record. - port string - // The protocol is usually _udp or _tcp (if set), and comes from the protocol part of a well formed - // SRV record. - protocol string - endpoint string - // The servicename used in Kubernetes. - service string - // The namespace used in Kubernetes. - namespace string - // A each name can be for a pod or a service, here we track what we've seen, either "pod" or "service". - podOrSvc string -} - -// parseRequest parses the qname to find all the elements we need for querying k8s. Anything -// that is not parsed will have the wildcard "*" value (except r.endpoint). -// Potential underscores are stripped from _port and _protocol. -func parseRequest(state request.Request) (r recordRequest, err error) { - // 3 Possible cases: - // 1. _port._protocol.service.namespace.pod|svc.zone - // 2. (endpoint): endpoint.service.namespace.pod|svc.zone - // 3. (service): service.namespace.pod|svc.zone - // - // Federations are handled in the federation plugin. And aren't parsed here. - - base, _ := dnsutil.TrimZone(state.Name(), state.Zone) - // return NODATA for apex queries - if base == "" || base == Svc || base == Pod { - return r, nil - } - segs := dns.SplitDomainName(base) - - r.port = "*" - r.protocol = "*" - r.service = "*" - r.namespace = "*" - // r.endpoint is the odd one out, we need to know if it has been set or not. If it is - // empty we should skip the endpoint check in k.get(). Hence we cannot set if to "*". - - // start at the right and fill out recordRequest with the bits we find, so we look for - // pod|svc.namespace.service and then either - // * endpoint - // *_protocol._port - - last := len(segs) - 1 - if last < 0 { - return r, nil - } - r.podOrSvc = segs[last] - if r.podOrSvc != Pod && r.podOrSvc != Svc { - return r, errInvalidRequest - } - last-- - if last < 0 { - return r, nil - } - - r.namespace = segs[last] - last-- - if last < 0 { - return r, nil - } - - r.service = segs[last] - last-- - if last < 0 { - return r, nil - } - - // Because of ambiquity we check the labels left: 1: an endpoint. 2: port and protocol. - // Anything else is a query that is too long to answer and can safely be delegated to return an nxdomain. - switch last { - - case 0: // endpoint only - r.endpoint = segs[last] - case 1: // service and port - r.protocol = stripUnderscore(segs[last]) - r.port = stripUnderscore(segs[last-1]) - - default: // too long - return r, errInvalidRequest - } - - return r, nil -} - -// stripUnderscore removes a prefixed underscore from s. -func stripUnderscore(s string) string { - if s[0] != '_' { - return s - } - return s[1:] -} - -// String return a string representation of r, it just returns all fields concatenated with dots. -// This is mostly used in tests. -func (r recordRequest) String() string { - s := r.port - s += "." + r.protocol - s += "." + r.endpoint - s += "." + r.service - s += "." + r.namespace - s += "." + r.podOrSvc - return s -} diff --git a/vendor/github.com/coredns/coredns/plugin/kubernetes/parse_test.go b/vendor/github.com/coredns/coredns/plugin/kubernetes/parse_test.go deleted file mode 100644 index 7907afc6..00000000 --- a/vendor/github.com/coredns/coredns/plugin/kubernetes/parse_test.go +++ /dev/null @@ -1,62 +0,0 @@ -package kubernetes - -import ( - "testing" - - "github.com/coredns/coredns/request" - - "github.com/miekg/dns" -) - -func TestParseRequest(t *testing.T) { - tests := []struct { - query string - expected string // output from r.String() - }{ - // valid SRV request - {"_http._tcp.webs.mynamespace.svc.inter.webs.test.", "http.tcp..webs.mynamespace.svc"}, - // wildcard acceptance - {"*.any.*.any.svc.inter.webs.test.", "*.any..*.any.svc"}, - // A request of endpoint - {"1-2-3-4.webs.mynamespace.svc.inter.webs.test.", "*.*.1-2-3-4.webs.mynamespace.svc"}, - // bare zone - {"inter.webs.test.", "....."}, - // bare svc type - {"svc.inter.webs.test.", "....."}, - // bare pod type - {"pod.inter.webs.test.", "....."}, - } - for i, tc := range tests { - m := new(dns.Msg) - m.SetQuestion(tc.query, dns.TypeA) - state := request.Request{Zone: zone, Req: m} - - r, e := parseRequest(state) - if e != nil { - t.Errorf("Test %d, expected no error, got '%v'.", i, e) - } - rs := r.String() - if rs != tc.expected { - t.Errorf("Test %d, expected (stringyfied) recordRequest: %s, got %s", i, tc.expected, rs) - } - } -} - -func TestParseInvalidRequest(t *testing.T) { - invalid := []string{ - "webs.mynamespace.pood.inter.webs.test.", // Request must be for pod or svc subdomain. - "too.long.for.what.I.am.trying.to.pod.inter.webs.tests.", // Too long. - } - - for i, query := range invalid { - m := new(dns.Msg) - m.SetQuestion(query, dns.TypeA) - state := request.Request{Zone: zone, Req: m} - - if _, e := parseRequest(state); e == nil { - t.Errorf("Test %d: expected error from %s, got none", i, query) - } - } -} - -const zone = "inter.webs.tests." diff --git a/vendor/github.com/coredns/coredns/plugin/kubernetes/reverse.go b/vendor/github.com/coredns/coredns/plugin/kubernetes/reverse.go deleted file mode 100644 index fd783a22..00000000 --- a/vendor/github.com/coredns/coredns/plugin/kubernetes/reverse.go +++ /dev/null @@ -1,54 +0,0 @@ -package kubernetes - -import ( - "strings" - - "github.com/coredns/coredns/plugin" - "github.com/coredns/coredns/plugin/etcd/msg" - "github.com/coredns/coredns/plugin/pkg/dnsutil" - "github.com/coredns/coredns/request" -) - -// Reverse implements the ServiceBackend interface. -func (k *Kubernetes) Reverse(state request.Request, exact bool, opt plugin.Options) ([]msg.Service, error) { - - ip := dnsutil.ExtractAddressFromReverse(state.Name()) - if ip == "" { - _, e := k.Records(state, exact) - return nil, e - } - - records := k.serviceRecordForIP(ip, state.Name()) - if len(records) == 0 { - return records, errNoItems - } - return records, nil -} - -// serviceRecordForIP gets a service record with a cluster ip matching the ip argument -// If a service cluster ip does not match, it checks all endpoints -func (k *Kubernetes) serviceRecordForIP(ip, name string) []msg.Service { - // First check services with cluster ips - for _, service := range k.APIConn.SvcIndexReverse(ip) { - if len(k.Namespaces) > 0 && !k.namespaceExposed(service.Namespace) { - continue - } - domain := strings.Join([]string{service.Name, service.Namespace, Svc, k.primaryZone()}, ".") - return []msg.Service{{Host: domain, TTL: k.ttl}} - } - // If no cluster ips match, search endpoints - for _, ep := range k.APIConn.EpIndexReverse(ip) { - if len(k.Namespaces) > 0 && !k.namespaceExposed(ep.ObjectMeta.Namespace) { - continue - } - for _, eps := range ep.Subsets { - for _, addr := range eps.Addresses { - if addr.IP == ip { - domain := strings.Join([]string{endpointHostname(addr, k.endpointNameMode), ep.ObjectMeta.Name, ep.ObjectMeta.Namespace, Svc, k.primaryZone()}, ".") - return []msg.Service{{Host: domain, TTL: k.ttl}} - } - } - } - } - return nil -} diff --git a/vendor/github.com/coredns/coredns/plugin/kubernetes/reverse_test.go b/vendor/github.com/coredns/coredns/plugin/kubernetes/reverse_test.go deleted file mode 100644 index 2cf41de1..00000000 --- a/vendor/github.com/coredns/coredns/plugin/kubernetes/reverse_test.go +++ /dev/null @@ -1,234 +0,0 @@ -package kubernetes - -import ( - "context" - "testing" - - "github.com/coredns/coredns/plugin/pkg/dnstest" - "github.com/coredns/coredns/plugin/test" - - "github.com/miekg/dns" - api "k8s.io/api/core/v1" - meta "k8s.io/apimachinery/pkg/apis/meta/v1" -) - -type APIConnReverseTest struct{} - -func (APIConnReverseTest) HasSynced() bool { return true } -func (APIConnReverseTest) Run() { return } -func (APIConnReverseTest) Stop() error { return nil } -func (APIConnReverseTest) PodIndex(string) []*api.Pod { return nil } -func (APIConnReverseTest) EpIndex(string) []*api.Endpoints { return nil } -func (APIConnReverseTest) EndpointsList() []*api.Endpoints { return nil } -func (APIConnReverseTest) ServiceList() []*api.Service { return nil } -func (APIConnReverseTest) Modified() int64 { return 0 } - -func (APIConnReverseTest) SvcIndex(svc string) []*api.Service { - if svc != "svc1.testns" { - return nil - } - svcs := []*api.Service{ - { - ObjectMeta: meta.ObjectMeta{ - Name: "svc1", - Namespace: "testns", - }, - Spec: api.ServiceSpec{ - ClusterIP: "192.168.1.100", - Ports: []api.ServicePort{{ - Name: "http", - Protocol: "tcp", - Port: 80, - }}, - }, - }, - } - return svcs - -} - -func (APIConnReverseTest) SvcIndexReverse(ip string) []*api.Service { - if ip != "192.168.1.100" { - return nil - } - svcs := []*api.Service{ - { - ObjectMeta: meta.ObjectMeta{ - Name: "svc1", - Namespace: "testns", - }, - Spec: api.ServiceSpec{ - ClusterIP: "192.168.1.100", - Ports: []api.ServicePort{{ - Name: "http", - Protocol: "tcp", - Port: 80, - }}, - }, - }, - } - return svcs -} - -func (APIConnReverseTest) EpIndexReverse(ip string) []*api.Endpoints { - switch ip { - case "10.0.0.100": - case "1234:abcd::1": - case "fd00:77:30::a": - case "fd00:77:30::2:9ba6": - default: - return nil - } - eps := []*api.Endpoints{ - { - Subsets: []api.EndpointSubset{ - { - Addresses: []api.EndpointAddress{ - { - IP: "10.0.0.100", - Hostname: "ep1a", - }, - { - IP: "1234:abcd::1", - Hostname: "ep1b", - }, - { - IP: "fd00:77:30::a", - Hostname: "ip6svc1ex", - }, - { - IP: "fd00:77:30::2:9ba6", - Hostname: "ip6svc1in", - }, - }, - Ports: []api.EndpointPort{ - { - Port: 80, - Protocol: "tcp", - Name: "http", - }, - }, - }, - }, - ObjectMeta: meta.ObjectMeta{ - Name: "svc1", - Namespace: "testns", - }, - }, - } - return eps -} - -func (APIConnReverseTest) GetNodeByName(name string) (*api.Node, error) { - return &api.Node{ - ObjectMeta: meta.ObjectMeta{ - Name: "test.node.foo.bar", - }, - }, nil -} - -func (APIConnReverseTest) GetNamespaceByName(name string) (*api.Namespace, error) { - return &api.Namespace{ - ObjectMeta: meta.ObjectMeta{ - Name: name, - }, - }, nil -} - -func TestReverse(t *testing.T) { - - k := New([]string{"cluster.local.", "0.10.in-addr.arpa.", "168.192.in-addr.arpa.", "0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.d.c.b.a.4.3.2.1.ip6.arpa.", "0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.3.0.0.7.7.0.0.0.0.d.f.ip6.arpa."}) - k.APIConn = &APIConnReverseTest{} - - tests := []test.Case{ - { - Qname: "100.0.0.10.in-addr.arpa.", Qtype: dns.TypePTR, - Rcode: dns.RcodeSuccess, - Answer: []dns.RR{ - test.PTR("100.0.0.10.in-addr.arpa. 5 IN PTR ep1a.svc1.testns.svc.cluster.local."), - }, - }, - { - Qname: "100.1.168.192.in-addr.arpa.", Qtype: dns.TypePTR, - Rcode: dns.RcodeSuccess, - Answer: []dns.RR{ - test.PTR("100.1.168.192.in-addr.arpa. 5 IN PTR svc1.testns.svc.cluster.local."), - }, - }, - { // A PTR record query for an existing ipv6 endpoint should return a record - Qname: "1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.d.c.b.a.4.3.2.1.ip6.arpa.", Qtype: dns.TypePTR, - Rcode: dns.RcodeSuccess, - Answer: []dns.RR{ - test.PTR("1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.d.c.b.a.4.3.2.1.ip6.arpa. 5 IN PTR ep1b.svc1.testns.svc.cluster.local."), - }, - }, - { // A PTR record query for an existing ipv6 endpoint should return a record - Qname: "a.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.3.0.0.7.7.0.0.0.0.d.f.ip6.arpa.", Qtype: dns.TypePTR, - Rcode: dns.RcodeSuccess, - Answer: []dns.RR{ - test.PTR("a.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.3.0.0.7.7.0.0.0.0.d.f.ip6.arpa. 5 IN PTR ip6svc1ex.svc1.testns.svc.cluster.local."), - }, - }, - { // A PTR record query for an existing ipv6 endpoint should return a record - Qname: "6.a.b.9.2.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.3.0.0.7.7.0.0.0.0.d.f.ip6.arpa.", Qtype: dns.TypePTR, - Rcode: dns.RcodeSuccess, - Answer: []dns.RR{ - test.PTR("6.a.b.9.2.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.3.0.0.7.7.0.0.0.0.d.f.ip6.arpa. 5 IN PTR ip6svc1in.svc1.testns.svc.cluster.local."), - }, - }, - { - Qname: "101.0.0.10.in-addr.arpa.", Qtype: dns.TypePTR, - Rcode: dns.RcodeNameError, - Ns: []dns.RR{ - test.SOA("0.10.in-addr.arpa. 300 IN SOA ns.dns.0.10.in-addr.arpa. hostmaster.0.10.in-addr.arpa. 1502782828 7200 1800 86400 60"), - }, - }, - { - Qname: "example.org.cluster.local.", Qtype: dns.TypePTR, - Rcode: dns.RcodeNameError, - Ns: []dns.RR{ - test.SOA("cluster.local. 300 IN SOA ns.dns.cluster.local. hostmaster.cluster.local. 1502989566 7200 1800 86400 60"), - }, - }, - { - Qname: "svc1.testns.svc.cluster.local.", Qtype: dns.TypePTR, - Rcode: dns.RcodeSuccess, - Ns: []dns.RR{ - test.SOA("cluster.local. 300 IN SOA ns.dns.cluster.local. hostmaster.cluster.local. 1502989566 7200 1800 86400 60"), - }, - }, - { - Qname: "svc1.testns.svc.0.10.in-addr.arpa.", Qtype: dns.TypeA, - Rcode: dns.RcodeNameError, - Ns: []dns.RR{ - test.SOA("0.10.in-addr.arpa. 300 IN SOA ns.dns.0.10.in-addr.arpa. hostmaster.0.10.in-addr.arpa. 1502989566 7200 1800 86400 60"), - }, - }, - { - Qname: "100.0.0.10.cluster.local.", Qtype: dns.TypePTR, - Rcode: dns.RcodeNameError, - Ns: []dns.RR{ - test.SOA("cluster.local. 300 IN SOA ns.dns.cluster.local. hostmaster.cluster.local. 1502989566 7200 1800 86400 60"), - }, - }, - } - - ctx := context.TODO() - for i, tc := range tests { - r := tc.Msg() - - w := dnstest.NewRecorder(&test.ResponseWriter{}) - - _, err := k.ServeDNS(ctx, w, r) - if err != tc.Error { - t.Errorf("Test %d: expected no error, got %v", i, err) - return - } - - resp := w.Msg - if resp == nil { - t.Fatalf("Test %d: got nil message and no error for: %s %d", i, r.Question[0].Name, r.Question[0].Qtype) - } - test.SortAndCheck(t, resp, tc) - } -} diff --git a/vendor/github.com/coredns/coredns/plugin/kubernetes/setup.go b/vendor/github.com/coredns/coredns/plugin/kubernetes/setup.go deleted file mode 100644 index 9e2129f6..00000000 --- a/vendor/github.com/coredns/coredns/plugin/kubernetes/setup.go +++ /dev/null @@ -1,281 +0,0 @@ -package kubernetes - -import ( - "errors" - "flag" - "fmt" - "os" - "strconv" - "strings" - "time" - - "github.com/coredns/coredns/core/dnsserver" - "github.com/coredns/coredns/plugin" - "github.com/coredns/coredns/plugin/pkg/dnsutil" - clog "github.com/coredns/coredns/plugin/pkg/log" - "github.com/coredns/coredns/plugin/pkg/parse" - "github.com/coredns/coredns/plugin/pkg/upstream" - - "github.com/mholt/caddy" - "github.com/miekg/dns" - meta "k8s.io/apimachinery/pkg/apis/meta/v1" -) - -var log = clog.NewWithPlugin("kubernetes") - -func init() { - // Kubernetes plugin uses the kubernetes library, which uses glog (ugh), we must set this *flag*, - // so we don't log to the filesystem, which can fill up and crash CoreDNS indirectly by calling os.Exit(). - // We also set: os.Stderr = os.Stdout in the setup function below so we output to standard out; as we do for - // all CoreDNS logging. We can't do *that* in the init function, because we, when starting, also barf some - // things to stderr. - flag.Set("logtostderr", "true") - - caddy.RegisterPlugin("kubernetes", caddy.Plugin{ - ServerType: "dns", - Action: setup, - }) -} - -func setup(c *caddy.Controller) error { - // See comment in the init function. - os.Stderr = os.Stdout - - k, err := kubernetesParse(c) - if err != nil { - return plugin.Error("kubernetes", err) - } - - err = k.InitKubeCache() - if err != nil { - return plugin.Error("kubernetes", err) - } - - k.RegisterKubeCache(c) - - dnsserver.GetConfig(c).AddPlugin(func(next plugin.Handler) plugin.Handler { - k.Next = next - return k - }) - - return nil -} - -// RegisterKubeCache registers KubeCache start and stop functions with Caddy -func (k *Kubernetes) RegisterKubeCache(c *caddy.Controller) { - c.OnStartup(func() error { - go k.APIConn.Run() - if k.APIProxy != nil { - k.APIProxy.Run() - } - synced := false - for synced == false { - synced = k.APIConn.HasSynced() - time.Sleep(100 * time.Millisecond) - } - - return nil - }) - - c.OnShutdown(func() error { - if k.APIProxy != nil { - k.APIProxy.Stop() - } - return k.APIConn.Stop() - }) -} - -func kubernetesParse(c *caddy.Controller) (*Kubernetes, error) { - var ( - k8s *Kubernetes - err error - ) - - i := 0 - for c.Next() { - if i > 0 { - return nil, plugin.ErrOnce - } - i++ - - k8s, err = ParseStanza(c) - if err != nil { - return k8s, err - } - } - return k8s, nil -} - -// ParseStanza parses a kubernetes stanza -func ParseStanza(c *caddy.Controller) (*Kubernetes, error) { - - k8s := New([]string{""}) - k8s.interfaceAddrsFunc = localPodIP - k8s.autoPathSearch = searchFromResolvConf() - - opts := dnsControlOpts{ - initEndpointsCache: true, - ignoreEmptyService: false, - resyncPeriod: defaultResyncPeriod, - } - k8s.opts = opts - - zones := c.RemainingArgs() - - if len(zones) != 0 { - k8s.Zones = zones - for i := 0; i < len(k8s.Zones); i++ { - k8s.Zones[i] = plugin.Host(k8s.Zones[i]).Normalize() - } - } else { - k8s.Zones = make([]string, len(c.ServerBlockKeys)) - for i := 0; i < len(c.ServerBlockKeys); i++ { - k8s.Zones[i] = plugin.Host(c.ServerBlockKeys[i]).Normalize() - } - } - - k8s.primaryZoneIndex = -1 - for i, z := range k8s.Zones { - if dnsutil.IsReverse(z) > 0 { - continue - } - k8s.primaryZoneIndex = i - break - } - - if k8s.primaryZoneIndex == -1 { - return nil, errors.New("non-reverse zone name must be used") - } - - for c.NextBlock() { - switch c.Val() { - case "endpoint_pod_names": - args := c.RemainingArgs() - if len(args) > 0 { - return nil, c.ArgErr() - } - k8s.endpointNameMode = true - continue - case "pods": - args := c.RemainingArgs() - if len(args) == 1 { - switch args[0] { - case podModeDisabled, podModeInsecure, podModeVerified: - k8s.podMode = args[0] - default: - return nil, fmt.Errorf("wrong value for pods: %s, must be one of: disabled, verified, insecure", args[0]) - } - continue - } - return nil, c.ArgErr() - case "namespaces": - args := c.RemainingArgs() - if len(args) > 0 { - for _, a := range args { - k8s.Namespaces[a] = true - } - continue - } - return nil, c.ArgErr() - case "endpoint": - args := c.RemainingArgs() - if len(args) > 0 { - k8s.APIServerList = args - continue - } - return nil, c.ArgErr() - case "tls": // cert key cacertfile - args := c.RemainingArgs() - if len(args) == 3 { - k8s.APIClientCert, k8s.APIClientKey, k8s.APICertAuth = args[0], args[1], args[2] - continue - } - return nil, c.ArgErr() - case "resyncperiod": - args := c.RemainingArgs() - if len(args) > 0 { - rp, err := time.ParseDuration(args[0]) - if err != nil { - return nil, fmt.Errorf("unable to parse resync duration value: '%v': %v", args[0], err) - } - k8s.opts.resyncPeriod = rp - continue - } - return nil, c.ArgErr() - case "labels": - args := c.RemainingArgs() - if len(args) > 0 { - labelSelectorString := strings.Join(args, " ") - ls, err := meta.ParseToLabelSelector(labelSelectorString) - if err != nil { - return nil, fmt.Errorf("unable to parse label selector value: '%v': %v", labelSelectorString, err) - } - k8s.opts.labelSelector = ls - continue - } - return nil, c.ArgErr() - case "fallthrough": - k8s.Fall.SetZonesFromArgs(c.RemainingArgs()) - case "upstream": - args := c.RemainingArgs() - u, err := upstream.New(args) - if err != nil { - return nil, err - } - k8s.Upstream = u - case "ttl": - args := c.RemainingArgs() - if len(args) == 0 { - return nil, c.ArgErr() - } - t, err := strconv.Atoi(args[0]) - if err != nil { - return nil, err - } - if t < 5 || t > 3600 { - return nil, c.Errf("ttl must be in range [5, 3600]: %d", t) - } - k8s.ttl = uint32(t) - case "transfer": - tos, froms, err := parse.Transfer(c, false) - if err != nil { - return nil, err - } - if len(froms) != 0 { - return nil, c.Errf("transfer from is not supported with this plugin") - } - k8s.TransferTo = tos - case "noendpoints": - if len(c.RemainingArgs()) != 0 { - return nil, c.ArgErr() - } - k8s.opts.initEndpointsCache = false - case "ignore": - args := c.RemainingArgs() - if len(args) > 0 { - ignore := args[0] - if ignore == "empty_service" { - k8s.opts.ignoreEmptyService = true - continue - } else { - return nil, fmt.Errorf("unable to parse ignore value: '%v'", ignore) - } - } - default: - return nil, c.Errf("unknown property '%s'", c.Val()) - } - } - - return k8s, nil -} - -func searchFromResolvConf() []string { - rc, err := dns.ClientConfigFromFile("/etc/resolv.conf") - if err != nil { - return nil - } - plugin.Zones(rc.Search).Normalize() - return rc.Search -} - -const defaultResyncPeriod = 5 * time.Minute diff --git a/vendor/github.com/coredns/coredns/plugin/kubernetes/setup_reverse_test.go b/vendor/github.com/coredns/coredns/plugin/kubernetes/setup_reverse_test.go deleted file mode 100644 index a2c69d96..00000000 --- a/vendor/github.com/coredns/coredns/plugin/kubernetes/setup_reverse_test.go +++ /dev/null @@ -1,36 +0,0 @@ -package kubernetes - -import ( - "testing" - - "github.com/mholt/caddy" -) - -func TestKubernetesParseReverseZone(t *testing.T) { - tests := []struct { - input string // Corefile data as string - expectedZones []string // expected count of defined zones. - }{ - {`kubernetes coredns.local 10.0.0.0/16`, []string{"coredns.local.", "0.10.in-addr.arpa."}}, - {`kubernetes coredns.local 10.0.0.0/17`, []string{"coredns.local.", "0.10.in-addr.arpa."}}, - {`kubernetes coredns.local fd00:77:30::0/110`, []string{"coredns.local.", "0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.3.0.0.7.7.0.0.0.0.d.f.ip6.arpa."}}, - } - - for i, tc := range tests { - c := caddy.NewTestController("dns", tc.input) - k, err := kubernetesParse(c) - if err != nil { - t.Fatalf("Test %d: Expected no error, got %q", i, err) - } - - zl := len(k.Zones) - if zl != len(tc.expectedZones) { - t.Errorf("Test %d: Expected kubernetes to be initialized with %d zones, found %d zones", i, len(tc.expectedZones), zl) - } - for i, z := range tc.expectedZones { - if k.Zones[i] != z { - t.Errorf("Test %d: Expected zones to be %q, got %q", i, z, k.Zones[i]) - } - } - } -} diff --git a/vendor/github.com/coredns/coredns/plugin/kubernetes/setup_test.go b/vendor/github.com/coredns/coredns/plugin/kubernetes/setup_test.go deleted file mode 100644 index 94562ce6..00000000 --- a/vendor/github.com/coredns/coredns/plugin/kubernetes/setup_test.go +++ /dev/null @@ -1,687 +0,0 @@ -package kubernetes - -import ( - "strings" - "testing" - "time" - - "github.com/coredns/coredns/plugin/pkg/fall" - - "github.com/coredns/coredns/plugin/proxy" - "github.com/mholt/caddy" - meta "k8s.io/apimachinery/pkg/apis/meta/v1" -) - -func TestKubernetesParse(t *testing.T) { - tests := []struct { - input string // Corefile data as string - shouldErr bool // true if test case is exected to produce an error. - expectedErrContent string // substring from the expected error. Empty for positive cases. - expectedZoneCount int // expected count of defined zones. - expectedNSCount int // expected count of namespaces. - expectedResyncPeriod time.Duration // expected resync period value - expectedLabelSelector string // expected label selector value - expectedPodMode string - expectedFallthrough fall.F - expectedUpstreams []string - }{ - // positive - { - `kubernetes coredns.local`, - false, - "", - 1, - 0, - defaultResyncPeriod, - "", - podModeDisabled, - fall.Zero, - nil, - }, - { - `kubernetes coredns.local test.local`, - false, - "", - 2, - 0, - defaultResyncPeriod, - "", - podModeDisabled, - fall.Zero, - nil, - }, - { - `kubernetes coredns.local { -}`, - false, - "", - 1, - 0, - defaultResyncPeriod, - "", - podModeDisabled, - fall.Zero, - nil, - }, - { - `kubernetes coredns.local { - endpoint http://localhost:9090 http://localhost:9091 -}`, - false, - "", - 1, - 0, - defaultResyncPeriod, - "", - podModeDisabled, - fall.Zero, - nil, - }, - { - `kubernetes coredns.local { - namespaces demo -}`, - false, - "", - 1, - 1, - defaultResyncPeriod, - "", - podModeDisabled, - fall.Zero, - nil, - }, - { - `kubernetes coredns.local { - namespaces demo test -}`, - false, - "", - 1, - 2, - defaultResyncPeriod, - "", - podModeDisabled, - fall.Zero, - nil, - }, - { - `kubernetes coredns.local { - resyncperiod 30s -}`, - false, - "", - 1, - 0, - 30 * time.Second, - "", - podModeDisabled, - fall.Zero, - nil, - }, - { - `kubernetes coredns.local { - resyncperiod 15m -}`, - false, - "", - 1, - 0, - 15 * time.Minute, - "", - podModeDisabled, - fall.Zero, - nil, - }, - { - `kubernetes coredns.local { - labels environment=prod -}`, - false, - "", - 1, - 0, - defaultResyncPeriod, - "environment=prod", - podModeDisabled, - fall.Zero, - nil, - }, - { - `kubernetes coredns.local { - labels environment in (production, staging, qa),application=nginx -}`, - false, - "", - 1, - 0, - defaultResyncPeriod, - "application=nginx,environment in (production,qa,staging)", - podModeDisabled, - fall.Zero, - nil, - }, - { - `kubernetes coredns.local test.local { - resyncperiod 15m - endpoint http://localhost:8080 - namespaces demo test - labels environment in (production, staging, qa),application=nginx - fallthrough -}`, - false, - "", - 2, - 2, - 15 * time.Minute, - "application=nginx,environment in (production,qa,staging)", - podModeDisabled, - fall.Root, - nil, - }, - // negative - { - `kubernetes coredns.local { - endpoint -}`, - true, - "rong argument count or unexpected line ending", - -1, - -1, - defaultResyncPeriod, - "", - podModeDisabled, - fall.Zero, - nil, - }, - { - `kubernetes coredns.local { - namespaces -}`, - true, - "rong argument count or unexpected line ending", - -1, - -1, - defaultResyncPeriod, - "", - podModeDisabled, - fall.Zero, - nil, - }, - { - `kubernetes coredns.local { - resyncperiod -}`, - true, - "rong argument count or unexpected line ending", - -1, - 0, - 0 * time.Minute, - "", - podModeDisabled, - fall.Zero, - nil, - }, - { - `kubernetes coredns.local { - resyncperiod 15 -}`, - true, - "unable to parse resync duration value", - -1, - 0, - 0 * time.Second, - "", - podModeDisabled, - fall.Zero, - nil, - }, - { - `kubernetes coredns.local { - resyncperiod abc -}`, - true, - "unable to parse resync duration value", - -1, - 0, - 0 * time.Second, - "", - podModeDisabled, - fall.Zero, - nil, - }, - { - `kubernetes coredns.local { - labels -}`, - true, - "rong argument count or unexpected line ending", - -1, - 0, - 0 * time.Second, - "", - podModeDisabled, - fall.Zero, - nil, - }, - { - `kubernetes coredns.local { - labels environment in (production, qa -}`, - true, - "unable to parse label selector", - -1, - 0, - 0 * time.Second, - "", - podModeDisabled, - fall.Zero, - nil, - }, - // pods disabled - { - `kubernetes coredns.local { - pods disabled -}`, - false, - "", - 1, - 0, - defaultResyncPeriod, - "", - podModeDisabled, - fall.Zero, - nil, - }, - // pods insecure - { - `kubernetes coredns.local { - pods insecure -}`, - false, - "", - 1, - 0, - defaultResyncPeriod, - "", - podModeInsecure, - fall.Zero, - nil, - }, - // pods verified - { - `kubernetes coredns.local { - pods verified -}`, - false, - "", - 1, - 0, - defaultResyncPeriod, - "", - podModeVerified, - fall.Zero, - nil, - }, - // pods invalid - { - `kubernetes coredns.local { - pods giant_seed -}`, - true, - "rong value for pods", - -1, - 0, - defaultResyncPeriod, - "", - podModeVerified, - fall.Zero, - nil, - }, - // fallthrough with zones - { - `kubernetes coredns.local { - fallthrough ip6.arpa inaddr.arpa foo.com -}`, - false, - "rong argument count", - 1, - 0, - defaultResyncPeriod, - "", - podModeDisabled, - fall.F{Zones: []string{"ip6.arpa.", "inaddr.arpa.", "foo.com."}}, - nil, - }, - // Valid upstream - { - `kubernetes coredns.local { - upstream 13.14.15.16:53 -}`, - false, - "", - 1, - 0, - defaultResyncPeriod, - "", - podModeDisabled, - fall.Zero, - []string{"13.14.15.16:53"}, - }, - // Invalid upstream - { - `kubernetes coredns.local { - upstream 13.14.15.16orange -}`, - true, - "not an IP address or file: \"13.14.15.16orange\"", - -1, - 0, - defaultResyncPeriod, - "", - podModeDisabled, - fall.Zero, - nil, - }, - // More than one Kubernetes not allowed - { - `kubernetes coredns.local -kubernetes cluster.local`, - true, - "this plugin", - -1, - 0, - defaultResyncPeriod, - "", - podModeDisabled, - fall.Zero, - nil, - }, - } - - for i, test := range tests { - c := caddy.NewTestController("dns", test.input) - k8sController, err := kubernetesParse(c) - - if test.shouldErr && err == nil { - t.Errorf("Test %d: Expected error, but did not find error for input '%s'. Error was: '%v'", i, test.input, err) - } - - if err != nil { - if !test.shouldErr { - t.Errorf("Test %d: Expected no error but found one for input %s. Error was: %v", i, test.input, err) - continue - } - - if test.shouldErr && (len(test.expectedErrContent) < 1) { - t.Fatalf("Test %d: Test marked as expecting an error, but no expectedErrContent provided for input '%s'. Error was: '%v'", i, test.input, err) - } - - if test.shouldErr && (test.expectedZoneCount >= 0) { - t.Errorf("Test %d: Test marked as expecting an error, but provides value for expectedZoneCount!=-1 for input '%s'. Error was: '%v'", i, test.input, err) - } - - if !strings.Contains(err.Error(), test.expectedErrContent) { - t.Errorf("Test %d: Expected error to contain: %v, found error: %v, input: %s", i, test.expectedErrContent, err, test.input) - } - continue - } - - // No error was raised, so validate initialization of k8sController - // Zones - foundZoneCount := len(k8sController.Zones) - if foundZoneCount != test.expectedZoneCount { - t.Errorf("Test %d: Expected kubernetes controller to be initialized with %d zones, instead found %d zones: '%v' for input '%s'", i, test.expectedZoneCount, foundZoneCount, k8sController.Zones, test.input) - } - - // Namespaces - foundNSCount := len(k8sController.Namespaces) - if foundNSCount != test.expectedNSCount { - t.Errorf("Test %d: Expected kubernetes controller to be initialized with %d namespaces. Instead found %d namespaces: '%v' for input '%s'", i, test.expectedNSCount, foundNSCount, k8sController.Namespaces, test.input) - } - - // ResyncPeriod - foundResyncPeriod := k8sController.opts.resyncPeriod - if foundResyncPeriod != test.expectedResyncPeriod { - t.Errorf("Test %d: Expected kubernetes controller to be initialized with resync period '%s'. Instead found period '%s' for input '%s'", i, test.expectedResyncPeriod, foundResyncPeriod, test.input) - } - - // Labels - if k8sController.opts.labelSelector != nil { - foundLabelSelectorString := meta.FormatLabelSelector(k8sController.opts.labelSelector) - if foundLabelSelectorString != test.expectedLabelSelector { - t.Errorf("Test %d: Expected kubernetes controller to be initialized with label selector '%s'. Instead found selector '%s' for input '%s'", i, test.expectedLabelSelector, foundLabelSelectorString, test.input) - } - } - // Pods - foundPodMode := k8sController.podMode - if foundPodMode != test.expectedPodMode { - t.Errorf("Test %d: Expected kubernetes controller to be initialized with pod mode '%s'. Instead found pod mode '%s' for input '%s'", i, test.expectedPodMode, foundPodMode, test.input) - } - - // fallthrough - if !k8sController.Fall.Equal(test.expectedFallthrough) { - t.Errorf("Test %d: Expected kubernetes controller to be initialized with fallthrough '%v'. Instead found fallthrough '%v' for input '%s'", i, test.expectedFallthrough, k8sController.Fall, test.input) - } - // upstream - var foundUpstreams *[]proxy.Upstream - if k8sController.Upstream.Forward != nil { - foundUpstreams = k8sController.Upstream.Forward.Upstreams - } - if test.expectedUpstreams == nil { - if foundUpstreams != nil { - t.Errorf("Test %d: Expected kubernetes controller to not be initialized with upstreams for input '%s'", i, test.input) - } - } else { - if foundUpstreams == nil { - t.Errorf("Test %d: Expected kubernetes controller to be initialized with upstreams for input '%s'", i, test.input) - } else { - if len(*foundUpstreams) != len(test.expectedUpstreams) { - t.Errorf("Test %d: Expected kubernetes controller to be initialized with %d upstreams. Instead found %d upstreams for input '%s'", i, len(test.expectedUpstreams), len(*foundUpstreams), test.input) - } - for j, want := range test.expectedUpstreams { - got := (*foundUpstreams)[j].Select().Name - if got != want { - t.Errorf("Test %d: Expected kubernetes controller to be initialized with upstream '%s'. Instead found upstream '%s' for input '%s'", i, want, got, test.input) - } - } - - } - } - } -} - -func TestKubernetesParseEndpointPodNames(t *testing.T) { - tests := []struct { - input string // Corefile data as string - shouldErr bool // true if test case is exected to produce an error. - expectedErrContent string // substring from the expected error. Empty for positive cases. - expectedEndpointMode bool - }{ - // valid endpoints mode - { - `kubernetes coredns.local { - endpoint_pod_names -}`, - false, - "", - true, - }, - // endpoints invalid - { - `kubernetes coredns.local { - endpoint_pod_names giant_seed -}`, - true, - "rong argument count or unexpected", - false, - }, - // endpoint not set - { - `kubernetes coredns.local { -}`, - false, - "", - false, - }, - } - - for i, test := range tests { - c := caddy.NewTestController("dns", test.input) - k8sController, err := kubernetesParse(c) - - if test.shouldErr && err == nil { - t.Errorf("Test %d: Expected error, but did not find error for input '%s'. Error was: '%v'", i, test.input, err) - } - - if err != nil { - if !test.shouldErr { - t.Errorf("Test %d: Expected no error but found one for input %s. Error was: %v", i, test.input, err) - continue - } - - if !strings.Contains(err.Error(), test.expectedErrContent) { - t.Errorf("Test %d: Expected error to contain: %v, found error: %v, input: %s", i, test.expectedErrContent, err, test.input) - } - continue - } - - // Endpoints - foundEndpointNameMode := k8sController.endpointNameMode - if foundEndpointNameMode != test.expectedEndpointMode { - t.Errorf("Test %d: Expected kubernetes controller to be initialized with endpoints mode '%v'. Instead found endpoints mode '%v' for input '%s'", i, test.expectedEndpointMode, foundEndpointNameMode, test.input) - } - } -} - -func TestKubernetesParseNoEndpoints(t *testing.T) { - tests := []struct { - input string // Corefile data as string - shouldErr bool // true if test case is exected to produce an error. - expectedErrContent string // substring from the expected error. Empty for positive cases. - expectedEndpointsInit bool - }{ - // valid - { - `kubernetes coredns.local { - noendpoints -}`, - false, - "", - false, - }, - // invalid - { - `kubernetes coredns.local { - noendpoints ixnay on the endpointsay -}`, - true, - "rong argument count or unexpected", - true, - }, - // not set - { - `kubernetes coredns.local { -}`, - false, - "", - true, - }, - } - - for i, test := range tests { - c := caddy.NewTestController("dns", test.input) - k8sController, err := kubernetesParse(c) - - if test.shouldErr && err == nil { - t.Errorf("Test %d: Expected error, but did not find error for input '%s'. Error was: '%v'", i, test.input, err) - } - - if err != nil { - if !test.shouldErr { - t.Errorf("Test %d: Expected no error but found one for input %s. Error was: %v", i, test.input, err) - continue - } - - if !strings.Contains(err.Error(), test.expectedErrContent) { - t.Errorf("Test %d: Expected error to contain: %v, found error: %v, input: %s", i, test.expectedErrContent, err, test.input) - } - continue - } - - foundEndpointsInit := k8sController.opts.initEndpointsCache - if foundEndpointsInit != test.expectedEndpointsInit { - t.Errorf("Test %d: Expected kubernetes controller to be initialized with endpoints watch '%v'. Instead found endpoints watch '%v' for input '%s'", i, test.expectedEndpointsInit, foundEndpointsInit, test.input) - } - } -} - -func TestKubernetesParseIgnoreEmptyService(t *testing.T) { - tests := []struct { - input string // Corefile data as string - shouldErr bool // true if test case is exected to produce an error. - expectedErrContent string // substring from the expected error. Empty for positive cases. - expectedEndpointsInit bool - }{ - // valid - { - `kubernetes coredns.local { - ignore empty_service -}`, - false, - "", - true, - }, - // invalid - { - `kubernetes coredns.local { - ignore ixnay on the endpointsay -}`, - true, - "unable to parse ignore value", - false, - }, - { - `kubernetes coredns.local { - ignore empty_service ixnay on the endpointsay -}`, - false, - "", - true, - }, - // not set - { - `kubernetes coredns.local { -}`, - false, - "", - false, - }, - } - - for i, test := range tests { - c := caddy.NewTestController("dns", test.input) - k8sController, err := kubernetesParse(c) - - if test.shouldErr && err == nil { - t.Errorf("Test %d: Expected error, but did not find error for input '%s'. Error was: '%v'", i, test.input, err) - } - - if err != nil { - if !test.shouldErr { - t.Errorf("Test %d: Expected no error but found one for input %s. Error was: %v", i, test.input, err) - continue - } - - if !strings.Contains(err.Error(), test.expectedErrContent) { - t.Errorf("Test %d: Expected error to contain: %v, found error: %v, input: %s", i, test.expectedErrContent, err, test.input) - } - continue - } - - foundIgnoreEmptyService := k8sController.opts.ignoreEmptyService - if foundIgnoreEmptyService != test.expectedEndpointsInit { - t.Errorf("Test %d: Expected kubernetes controller to be initialized with ignore empty_service '%v'. Instead found ignore empty_service watch '%v' for input '%s'", i, test.expectedEndpointsInit, foundIgnoreEmptyService, test.input) - } - } -} diff --git a/vendor/github.com/coredns/coredns/plugin/kubernetes/setup_ttl_test.go b/vendor/github.com/coredns/coredns/plugin/kubernetes/setup_ttl_test.go deleted file mode 100644 index e923c784..00000000 --- a/vendor/github.com/coredns/coredns/plugin/kubernetes/setup_ttl_test.go +++ /dev/null @@ -1,45 +0,0 @@ -package kubernetes - -import ( - "testing" - - "github.com/mholt/caddy" -) - -func TestKubernetesParseTTL(t *testing.T) { - tests := []struct { - input string // Corefile data as string - expectedTTL uint32 // expected count of defined zones. - shouldErr bool - }{ - {`kubernetes cluster.local { - ttl 56 - }`, 56, false}, - {`kubernetes cluster.local`, defaultTTL, false}, - {`kubernetes cluster.local { - ttl -1 - }`, 0, true}, - {`kubernetes cluster.local { - ttl 3601 - }`, 0, true}, - } - - for i, tc := range tests { - c := caddy.NewTestController("dns", tc.input) - k, err := kubernetesParse(c) - if err != nil && !tc.shouldErr { - t.Fatalf("Test %d: Expected no error, got %q", i, err) - } - if err == nil && tc.shouldErr { - t.Fatalf("Test %d: Expected error, got none", i) - } - if err != nil && tc.shouldErr { - // input should error - continue - } - - if k.ttl != tc.expectedTTL { - t.Errorf("Test %d: Expected TTl to be %d, got %d", i, tc.expectedTTL, k.ttl) - } - } -} diff --git a/vendor/github.com/coredns/coredns/plugin/kubernetes/xfr.go b/vendor/github.com/coredns/coredns/plugin/kubernetes/xfr.go deleted file mode 100644 index afee4aa2..00000000 --- a/vendor/github.com/coredns/coredns/plugin/kubernetes/xfr.go +++ /dev/null @@ -1,206 +0,0 @@ -package kubernetes - -import ( - "context" - "math" - "net" - "strings" - - "github.com/coredns/coredns/plugin" - "github.com/coredns/coredns/plugin/etcd/msg" - "github.com/coredns/coredns/request" - - "github.com/miekg/dns" - api "k8s.io/api/core/v1" -) - -const transferLength = 2000 - -// Serial implements the Transferer interface. -func (k *Kubernetes) Serial(state request.Request) uint32 { return uint32(k.APIConn.Modified()) } - -// MinTTL implements the Transferer interface. -func (k *Kubernetes) MinTTL(state request.Request) uint32 { return 30 } - -// Transfer implements the Transferer interface. -func (k *Kubernetes) Transfer(ctx context.Context, state request.Request) (int, error) { - - // Get all services. - rrs := make(chan dns.RR) - go k.transfer(rrs, state.Zone) - - records := []dns.RR{} - for r := range rrs { - records = append(records, r) - } - - if len(records) == 0 { - return dns.RcodeServerFailure, nil - } - - ch := make(chan *dns.Envelope) - tr := new(dns.Transfer) - - soa, err := plugin.SOA(k, state.Zone, state, plugin.Options{}) - if err != nil { - return dns.RcodeServerFailure, nil - } - - records = append(soa, records...) - records = append(records, soa...) - go func(ch chan *dns.Envelope) { - j, l := 0, 0 - log.Infof("Outgoing transfer of %d records of zone %s to %s started", len(records), state.Zone, state.IP()) - for i, r := range records { - l += dns.Len(r) - if l > transferLength { - ch <- &dns.Envelope{RR: records[j:i]} - l = 0 - j = i - } - } - if j < len(records) { - ch <- &dns.Envelope{RR: records[j:]} - } - close(ch) - }(ch) - - tr.Out(state.W, state.Req, ch) - // Defer closing to the client - state.W.Hijack() - return dns.RcodeSuccess, nil -} - -func (k *Kubernetes) transfer(c chan dns.RR, zone string) { - - defer close(c) - - zonePath := msg.Path(zone, "coredns") - serviceList := k.APIConn.ServiceList() - for _, svc := range serviceList { - svcBase := []string{zonePath, Svc, svc.Namespace, svc.Name} - switch svc.Spec.Type { - case api.ServiceTypeClusterIP, api.ServiceTypeNodePort, api.ServiceTypeLoadBalancer: - clusterIP := net.ParseIP(svc.Spec.ClusterIP) - if clusterIP != nil { - for _, p := range svc.Spec.Ports { - - s := msg.Service{Host: svc.Spec.ClusterIP, Port: int(p.Port), TTL: k.ttl} - s.Key = strings.Join(svcBase, "/") - - // Change host from IP to Name for SRV records - host := emitAddressRecord(c, s) - s.Host = host - - // Need to generate this to handle use cases for peer-finder - // ref: https://github.com/coredns/coredns/pull/823 - c <- s.NewSRV(msg.Domain(s.Key), 100) - - // As per spec unnamed ports do not have a srv record - // https://github.com/kubernetes/dns/blob/master/docs/specification.md#232---srv-records - if p.Name == "" { - continue - } - - s.Key = strings.Join(append(svcBase, strings.ToLower("_"+string(p.Protocol)), strings.ToLower("_"+string(p.Name))), "/") - - c <- s.NewSRV(msg.Domain(s.Key), 100) - } - - // Skip endpoint discovery if clusterIP is defined - continue - } - - endpointsList := k.APIConn.EpIndex(svc.Name + "." + svc.Namespace) - - for _, ep := range endpointsList { - if ep.ObjectMeta.Name != svc.Name || ep.ObjectMeta.Namespace != svc.Namespace { - continue - } - - for _, eps := range ep.Subsets { - srvWeight := calcSRVWeight(len(eps.Addresses)) - for _, addr := range eps.Addresses { - s := msg.Service{Host: addr.IP, TTL: k.ttl} - s.Key = strings.Join(svcBase, "/") - // We don't need to change the msg.Service host from IP to Name yet - // so disregard the return value here - emitAddressRecord(c, s) - - s.Key = strings.Join(append(svcBase, endpointHostname(addr, k.endpointNameMode)), "/") - // Change host from IP to Name for SRV records - host := emitAddressRecord(c, s) - s.Host = host - - for _, p := range eps.Ports { - // As per spec unnamed ports do not have a srv record - // https://github.com/kubernetes/dns/blob/master/docs/specification.md#232---srv-records - if p.Name == "" { - continue - } - - s.Port = int(p.Port) - - s.Key = strings.Join(append(svcBase, strings.ToLower("_"+string(p.Protocol)), strings.ToLower("_"+string(p.Name))), "/") - c <- s.NewSRV(msg.Domain(s.Key), srvWeight) - } - } - } - } - - case api.ServiceTypeExternalName: - - s := msg.Service{Key: strings.Join(svcBase, "/"), Host: svc.Spec.ExternalName, TTL: k.ttl} - if t, _ := s.HostType(); t == dns.TypeCNAME { - c <- s.NewCNAME(msg.Domain(s.Key), s.Host) - } - } - } - return -} - -// emitAddressRecord generates a new A or AAAA record based on the msg.Service and writes it to -// a channel. -// emitAddressRecord returns the host name from the generated record. -func emitAddressRecord(c chan dns.RR, message msg.Service) string { - ip := net.ParseIP(message.Host) - var host string - dnsType, _ := message.HostType() - switch dnsType { - case dns.TypeA: - arec := message.NewA(msg.Domain(message.Key), ip) - host = arec.Hdr.Name - c <- arec - case dns.TypeAAAA: - arec := message.NewAAAA(msg.Domain(message.Key), ip) - host = arec.Hdr.Name - c <- arec - } - - return host -} - -// calcSrvWeight borrows the logic implemented in plugin.SRV for dynamically -// calculating the srv weight and priority -func calcSRVWeight(numservices int) uint16 { - var services []msg.Service - - for i := 0; i < numservices; i++ { - services = append(services, msg.Service{}) - } - - w := make(map[int]int) - for _, serv := range services { - weight := 100 - if serv.Weight != 0 { - weight = serv.Weight - } - if _, ok := w[serv.Priority]; !ok { - w[serv.Priority] = weight - continue - } - w[serv.Priority] += weight - } - - return uint16(math.Floor((100.0 / float64(w[0])) * 100)) -} diff --git a/vendor/github.com/coredns/coredns/plugin/kubernetes/xfr_test.go b/vendor/github.com/coredns/coredns/plugin/kubernetes/xfr_test.go deleted file mode 100644 index 6ce7e789..00000000 --- a/vendor/github.com/coredns/coredns/plugin/kubernetes/xfr_test.go +++ /dev/null @@ -1,202 +0,0 @@ -package kubernetes - -import ( - "context" - "strings" - "testing" - - "github.com/coredns/coredns/plugin/pkg/dnstest" - "github.com/coredns/coredns/plugin/test" - api "k8s.io/api/core/v1" - meta "k8s.io/apimachinery/pkg/apis/meta/v1" - - "github.com/miekg/dns" -) - -func TestKubernetesXFR(t *testing.T) { - k := New([]string{"cluster.local."}) - k.APIConn = &APIConnServeTest{} - k.TransferTo = []string{"127.0.0.1"} - - ctx := context.TODO() - w := dnstest.NewMultiRecorder(&test.ResponseWriter{}) - dnsmsg := &dns.Msg{} - dnsmsg.SetAxfr(k.Zones[0]) - - _, err := k.ServeDNS(ctx, w, dnsmsg) - if err != nil { - t.Error(err) - } - - if len(w.Msgs) == 0 { - t.Logf("%+v\n", w) - t.Error("Did not get back a zone response") - } - - // Ensure xfr starts with SOA - if w.Msgs[0].Answer[0].Header().Rrtype != dns.TypeSOA { - t.Error("Invalid XFR, does not start with SOA record") - } - - // Ensure xfr starts with SOA - // Last message is empty, so we need to go back one further - if w.Msgs[len(w.Msgs)-2].Answer[len(w.Msgs[len(w.Msgs)-2].Answer)-1].Header().Rrtype != dns.TypeSOA { - t.Error("Invalid XFR, does not end with SOA record") - } - - testRRs := []dns.RR{} - for _, tc := range dnsTestCases { - if tc.Rcode != dns.RcodeSuccess { - continue - } - - for _, ans := range tc.Answer { - // Exclude wildcard searches - if strings.Contains(ans.Header().Name, "*") { - continue - } - - // Exclude TXT records - if ans.Header().Rrtype == dns.TypeTXT { - continue - } - testRRs = append(testRRs, ans) - } - } - - gotRRs := []dns.RR{} - for _, resp := range w.Msgs { - for _, ans := range resp.Answer { - // Skip SOA records since these - // test cases do not exist - if ans.Header().Rrtype == dns.TypeSOA { - continue - } - - gotRRs = append(gotRRs, ans) - } - - } - - diff := difference(testRRs, gotRRs) - if len(diff) != 0 { - t.Errorf("Got back %d records that do not exist in test cases, should be 0:", len(diff)) - for _, rec := range diff { - t.Errorf("%+v", rec) - } - } - - diff = difference(gotRRs, testRRs) - if len(diff) != 0 { - t.Errorf("Found %d records we're missing tham test cases, should be 0:", len(diff)) - for _, rec := range diff { - t.Errorf("%+v", rec) - } - } - -} - -// difference shows what we're missing when comparing two RR slices -func difference(testRRs []dns.RR, gotRRs []dns.RR) []dns.RR { - expectedRRs := map[string]bool{} - for _, rr := range testRRs { - expectedRRs[rr.String()] = true - } - - foundRRs := []dns.RR{} - for _, rr := range gotRRs { - if _, ok := expectedRRs[rr.String()]; !ok { - foundRRs = append(foundRRs, rr) - } - } - return foundRRs -} - -func TestEndpointsEquivalent(t *testing.T) { - epA := api.Endpoints{ - ObjectMeta: meta.ObjectMeta{ResourceVersion: "1230"}, - Subsets: []api.EndpointSubset{{ - Addresses: []api.EndpointAddress{{IP: "1.2.3.4", Hostname: "foo"}}, - NotReadyAddresses: []api.EndpointAddress{{IP: "1.2.3.5", Hostname: "foobar"}}, - }}, - } - epB := api.Endpoints{ - ObjectMeta: meta.ObjectMeta{ResourceVersion: "1234"}, - Subsets: []api.EndpointSubset{{ - Addresses: []api.EndpointAddress{{IP: "1.2.3.4", Hostname: "foo"}}, - NotReadyAddresses: []api.EndpointAddress{{IP: "1.1.1.1", Hostname: "foobar"}}, - }}, - } - epC := api.Endpoints{ - Subsets: []api.EndpointSubset{{ - Addresses: []api.EndpointAddress{{IP: "1.2.3.5", Hostname: "foo"}}, - }}, - } - epD := api.Endpoints{ - Subsets: []api.EndpointSubset{{ - Addresses: []api.EndpointAddress{{IP: "1.2.3.5", Hostname: "foo"}}, - }, - { - Addresses: []api.EndpointAddress{{IP: "1.2.2.2", Hostname: "foofoo"}}, - }}, - } - epE := api.Endpoints{ - Subsets: []api.EndpointSubset{{ - Addresses: []api.EndpointAddress{{IP: "1.2.3.5", Hostname: "foo"}, {IP: "1.1.1.1"}}, - }}, - } - epF := api.Endpoints{ - Subsets: []api.EndpointSubset{{ - Addresses: []api.EndpointAddress{{IP: "1.2.3.4", Hostname: "foofoo"}}, - }}, - } - epG := api.Endpoints{ - Subsets: []api.EndpointSubset{{ - Addresses: []api.EndpointAddress{{IP: "1.2.3.4", Hostname: "foo"}}, - Ports: []api.EndpointPort{{Name: "http", Port: 80, Protocol: "TCP"}}, - }}, - } - epH := api.Endpoints{ - Subsets: []api.EndpointSubset{{ - Addresses: []api.EndpointAddress{{IP: "1.2.3.4", Hostname: "foo"}}, - Ports: []api.EndpointPort{{Name: "newportname", Port: 80, Protocol: "TCP"}}, - }}, - } - epI := api.Endpoints{ - Subsets: []api.EndpointSubset{{ - Addresses: []api.EndpointAddress{{IP: "1.2.3.4", Hostname: "foo"}}, - Ports: []api.EndpointPort{{Name: "http", Port: 8080, Protocol: "TCP"}}, - }}, - } - epJ := api.Endpoints{ - Subsets: []api.EndpointSubset{{ - Addresses: []api.EndpointAddress{{IP: "1.2.3.4", Hostname: "foo"}}, - Ports: []api.EndpointPort{{Name: "http", Port: 80, Protocol: "UDP"}}, - }}, - } - - tests := []struct { - equiv bool - a *api.Endpoints - b *api.Endpoints - }{ - {true, &epA, &epB}, - {false, &epA, &epC}, - {false, &epA, &epD}, - {false, &epA, &epE}, - {false, &epA, &epF}, - {false, &epF, &epG}, - {false, &epG, &epH}, - {false, &epG, &epI}, - {false, &epG, &epJ}, - } - - for i, tc := range tests { - if tc.equiv && !endpointsEquivalent(tc.a, tc.b) { - t.Errorf("Test %d: expected endpoints to be equivalent and they are not.", i) - } - if !tc.equiv && endpointsEquivalent(tc.a, tc.b) { - t.Errorf("Test %d: expected endpoints to be seen as different but they were not.", i) - } - } -} diff --git a/vendor/github.com/coredns/coredns/plugin/loadbalance/OWNERS b/vendor/github.com/coredns/coredns/plugin/loadbalance/OWNERS deleted file mode 100644 index eee46f68..00000000 --- a/vendor/github.com/coredns/coredns/plugin/loadbalance/OWNERS +++ /dev/null @@ -1,4 +0,0 @@ -reviewers: - - miekg -approvers: - - miekg diff --git a/vendor/github.com/coredns/coredns/plugin/loadbalance/README.md b/vendor/github.com/coredns/coredns/plugin/loadbalance/README.md deleted file mode 100644 index 58a7956e..00000000 --- a/vendor/github.com/coredns/coredns/plugin/loadbalance/README.md +++ /dev/null @@ -1,31 +0,0 @@ -# loadbalance - -## Name - -*loadbalance* - acts as a round-robin DNS loadbalancer by randomizing the order of A and AAAA records - in the answer. - -## Description - - See [Wikipedia](https://en.wikipedia.org/wiki/Round-robin_DNS) about the pros and cons on this - setup. It will take care to sort any CNAMEs before any address records, because some stub resolver - implementations (like glibc) are particular about that. - -## Syntax - -~~~ -loadbalance [POLICY] -~~~ - -* **POLICY** is how to balance, the default is "round_robin" - -## Examples - -Load balance replies coming back from Google Public DNS: - -~~~ corefile -. { - loadbalance round_robin - proxy . 8.8.8.8 8.8.4.4 -} -~~~ diff --git a/vendor/github.com/coredns/coredns/plugin/loadbalance/handler.go b/vendor/github.com/coredns/coredns/plugin/loadbalance/handler.go deleted file mode 100644 index 4ec79c09..00000000 --- a/vendor/github.com/coredns/coredns/plugin/loadbalance/handler.go +++ /dev/null @@ -1,24 +0,0 @@ -// Package loadbalance is plugin for rewriting responses to do "load balancing" -package loadbalance - -import ( - "context" - - "github.com/coredns/coredns/plugin" - - "github.com/miekg/dns" -) - -// RoundRobin is plugin to rewrite responses for "load balancing". -type RoundRobin struct { - Next plugin.Handler -} - -// ServeDNS implements the plugin.Handler interface. -func (rr RoundRobin) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (int, error) { - wrr := &RoundRobinResponseWriter{w} - return plugin.NextOrFailure(rr.Name(), rr.Next, ctx, wrr, r) -} - -// Name implements the Handler interface. -func (rr RoundRobin) Name() string { return "loadbalance" } diff --git a/vendor/github.com/coredns/coredns/plugin/loadbalance/loadbalance.go b/vendor/github.com/coredns/coredns/plugin/loadbalance/loadbalance.go deleted file mode 100644 index 031f841f..00000000 --- a/vendor/github.com/coredns/coredns/plugin/loadbalance/loadbalance.go +++ /dev/null @@ -1,85 +0,0 @@ -// Package loadbalance shuffles A and AAAA records. -package loadbalance - -import ( - "github.com/miekg/dns" -) - -// RoundRobinResponseWriter is a response writer that shuffles A and AAAA records. -type RoundRobinResponseWriter struct { - dns.ResponseWriter -} - -// WriteMsg implements the dns.ResponseWriter interface. -func (r *RoundRobinResponseWriter) WriteMsg(res *dns.Msg) error { - if res.Rcode != dns.RcodeSuccess { - return r.ResponseWriter.WriteMsg(res) - } - - res.Answer = roundRobin(res.Answer) - res.Ns = roundRobin(res.Ns) - res.Extra = roundRobin(res.Extra) - - return r.ResponseWriter.WriteMsg(res) -} - -func roundRobin(in []dns.RR) []dns.RR { - cname := []dns.RR{} - address := []dns.RR{} - mx := []dns.RR{} - rest := []dns.RR{} - for _, r := range in { - switch r.Header().Rrtype { - case dns.TypeCNAME: - cname = append(cname, r) - case dns.TypeA, dns.TypeAAAA: - address = append(address, r) - case dns.TypeMX: - mx = append(mx, r) - default: - rest = append(rest, r) - } - } - - roundRobinShuffle(address) - roundRobinShuffle(mx) - - out := append(cname, rest...) - out = append(out, address...) - out = append(out, mx...) - return out -} - -func roundRobinShuffle(records []dns.RR) { - switch l := len(records); l { - case 0, 1: - break - case 2: - if dns.Id()%2 == 0 { - records[0], records[1] = records[1], records[0] - } - default: - for j := 0; j < l*(int(dns.Id())%4+1); j++ { - q := int(dns.Id()) % l - p := int(dns.Id()) % l - if q == p { - p = (p + 1) % l - } - records[q], records[p] = records[p], records[q] - } - } -} - -// Write implements the dns.ResponseWriter interface. -func (r *RoundRobinResponseWriter) Write(buf []byte) (int, error) { - // Should we pack and unpack here to fiddle with the packet... Not likely. - log.Warning("RoundRobin called with Write: not shuffling records") - n, err := r.ResponseWriter.Write(buf) - return n, err -} - -// Hijack implements the dns.ResponseWriter interface. -func (r *RoundRobinResponseWriter) Hijack() { - r.ResponseWriter.Hijack() - return -} diff --git a/vendor/github.com/coredns/coredns/plugin/loadbalance/loadbalance_test.go b/vendor/github.com/coredns/coredns/plugin/loadbalance/loadbalance_test.go deleted file mode 100644 index d5f62af0..00000000 --- a/vendor/github.com/coredns/coredns/plugin/loadbalance/loadbalance_test.go +++ /dev/null @@ -1,168 +0,0 @@ -package loadbalance - -import ( - "context" - "testing" - - "github.com/coredns/coredns/plugin" - "github.com/coredns/coredns/plugin/pkg/dnstest" - "github.com/coredns/coredns/plugin/test" - - "github.com/miekg/dns" -) - -func TestLoadBalance(t *testing.T) { - rm := RoundRobin{Next: handler()} - - // the first X records must be cnames after this test - tests := []struct { - answer []dns.RR - extra []dns.RR - cnameAnswer int - cnameExtra int - addressAnswer int - addressExtra int - mxAnswer int - mxExtra int - }{ - { - answer: []dns.RR{ - test.CNAME("cname1.region2.skydns.test. 300 IN CNAME cname2.region2.skydns.test."), - test.CNAME("cname2.region2.skydns.test. 300 IN CNAME cname3.region2.skydns.test."), - test.CNAME("cname5.region2.skydns.test. 300 IN CNAME cname6.region2.skydns.test."), - test.CNAME("cname6.region2.skydns.test. 300 IN CNAME endpoint.region2.skydns.test."), - test.A("endpoint.region2.skydns.test. 300 IN A 10.240.0.1"), - test.MX("mx.region2.skydns.test. 300 IN MX 1 mx1.region2.skydns.test."), - test.MX("mx.region2.skydns.test. 300 IN MX 2 mx2.region2.skydns.test."), - test.MX("mx.region2.skydns.test. 300 IN MX 3 mx3.region2.skydns.test."), - }, - cnameAnswer: 4, - addressAnswer: 1, - mxAnswer: 3, - }, - { - answer: []dns.RR{ - test.A("endpoint.region2.skydns.test. 300 IN A 10.240.0.1"), - test.MX("mx.region2.skydns.test. 300 IN MX 1 mx1.region2.skydns.test."), - test.CNAME("cname.region2.skydns.test. 300 IN CNAME endpoint.region2.skydns.test."), - }, - cnameAnswer: 1, - addressAnswer: 1, - mxAnswer: 1, - }, - { - answer: []dns.RR{ - test.MX("mx.region2.skydns.test. 300 IN MX 1 mx1.region2.skydns.test."), - test.A("endpoint.region2.skydns.test. 300 IN A 10.240.0.1"), - test.A("endpoint.region2.skydns.test. 300 IN A 10.240.0.2"), - test.MX("mx.region2.skydns.test. 300 IN MX 1 mx2.region2.skydns.test."), - test.CNAME("cname2.region2.skydns.test. 300 IN CNAME cname3.region2.skydns.test."), - test.A("endpoint.region2.skydns.test. 300 IN A 10.240.0.3"), - test.MX("mx.region2.skydns.test. 300 IN MX 1 mx3.region2.skydns.test."), - }, - extra: []dns.RR{ - test.A("endpoint.region2.skydns.test. 300 IN A 10.240.0.1"), - test.AAAA("endpoint.region2.skydns.test. 300 IN AAAA ::1"), - test.MX("mx.region2.skydns.test. 300 IN MX 1 mx1.region2.skydns.test."), - test.CNAME("cname2.region2.skydns.test. 300 IN CNAME cname3.region2.skydns.test."), - test.MX("mx.region2.skydns.test. 300 IN MX 1 mx2.region2.skydns.test."), - test.A("endpoint.region2.skydns.test. 300 IN A 10.240.0.3"), - test.AAAA("endpoint.region2.skydns.test. 300 IN AAAA ::2"), - test.MX("mx.region2.skydns.test. 300 IN MX 1 mx3.region2.skydns.test."), - }, - cnameAnswer: 1, - cnameExtra: 1, - addressAnswer: 3, - addressExtra: 4, - mxAnswer: 3, - mxExtra: 3, - }, - } - - rec := dnstest.NewRecorder(&test.ResponseWriter{}) - - for i, test := range tests { - req := new(dns.Msg) - req.SetQuestion("region2.skydns.test.", dns.TypeSRV) - req.Answer = test.answer - req.Extra = test.extra - - _, err := rm.ServeDNS(context.TODO(), rec, req) - if err != nil { - t.Errorf("Test %d: Expected no error, but got %s", i, err) - continue - - } - - cname, address, mx, sorted := countRecords(rec.Msg.Answer) - if !sorted { - t.Errorf("Test %d: Expected CNAMEs, then AAAAs, then MX in Answer, but got mixed", i) - } - if cname != test.cnameAnswer { - t.Errorf("Test %d: Expected %d CNAMEs in Answer, but got %d", i, test.cnameAnswer, cname) - } - if address != test.addressAnswer { - t.Errorf("Test %d: Expected %d A/AAAAs in Answer, but got %d", i, test.addressAnswer, address) - } - if mx != test.mxAnswer { - t.Errorf("Test %d: Expected %d MXs in Answer, but got %d", i, test.mxAnswer, mx) - } - - cname, address, mx, sorted = countRecords(rec.Msg.Extra) - if !sorted { - t.Errorf("Test %d: Expected CNAMEs, then AAAAs, then MX in Extra, but got mixed", i) - } - if cname != test.cnameExtra { - t.Errorf("Test %d: Expected %d CNAMEs in Extra, but got %d", i, test.cnameAnswer, cname) - } - if address != test.addressExtra { - t.Errorf("Test %d: Expected %d A/AAAAs in Extra, but got %d", i, test.addressAnswer, address) - } - if mx != test.mxExtra { - t.Errorf("Test %d: Expected %d MXs in Extra, but got %d", i, test.mxAnswer, mx) - } - } -} - -func countRecords(result []dns.RR) (cname int, address int, mx int, sorted bool) { - const ( - Start = iota - CNAMERecords - ARecords - MXRecords - Any - ) - - // The order of the records is used to determine if the round-robin actually did anything. - sorted = true - cname = 0 - address = 0 - mx = 0 - state := Start - for _, r := range result { - switch r.Header().Rrtype { - case dns.TypeCNAME: - sorted = sorted && state <= CNAMERecords - state = CNAMERecords - cname++ - case dns.TypeA, dns.TypeAAAA: - sorted = sorted && state <= ARecords - state = ARecords - address++ - case dns.TypeMX: - sorted = sorted && state <= MXRecords - state = MXRecords - mx++ - default: - state = Any - } - } - return -} - -func handler() plugin.Handler { - return plugin.HandlerFunc(func(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (int, error) { - w.WriteMsg(r) - return dns.RcodeSuccess, nil - }) -} diff --git a/vendor/github.com/coredns/coredns/plugin/loadbalance/setup.go b/vendor/github.com/coredns/coredns/plugin/loadbalance/setup.go deleted file mode 100644 index 38dce630..00000000 --- a/vendor/github.com/coredns/coredns/plugin/loadbalance/setup.go +++ /dev/null @@ -1,30 +0,0 @@ -package loadbalance - -import ( - "github.com/coredns/coredns/core/dnsserver" - "github.com/coredns/coredns/plugin" - clog "github.com/coredns/coredns/plugin/pkg/log" - - "github.com/mholt/caddy" -) - -var log = clog.NewWithPlugin("loadbalance") - -func init() { - caddy.RegisterPlugin("loadbalance", caddy.Plugin{ - ServerType: "dns", - Action: setup, - }) -} - -func setup(c *caddy.Controller) error { - for c.Next() { - // TODO(miek): block and option parsing - } - - dnsserver.GetConfig(c).AddPlugin(func(next plugin.Handler) plugin.Handler { - return RoundRobin{Next: next} - }) - - return nil -} diff --git a/vendor/github.com/coredns/coredns/plugin/log/OWNERS b/vendor/github.com/coredns/coredns/plugin/log/OWNERS deleted file mode 100644 index 06032ae2..00000000 --- a/vendor/github.com/coredns/coredns/plugin/log/OWNERS +++ /dev/null @@ -1,6 +0,0 @@ -reviewers: - - miekg - - nchrisdk -approvers: - - miekg - - nchrisdk diff --git a/vendor/github.com/coredns/coredns/plugin/log/README.md b/vendor/github.com/coredns/coredns/plugin/log/README.md deleted file mode 100644 index 65cca19c..00000000 --- a/vendor/github.com/coredns/coredns/plugin/log/README.md +++ /dev/null @@ -1,140 +0,0 @@ -# log - -## Name - -*log* - enables query logging to standard output. - -## Description - -By just using *log* you dump all queries (and parts for the reply) on standard output. Options exist -to tweak the output a little. - -Note that for busy servers this will incur a performance hit. - -## Syntax - -~~~ txt -log -~~~ - -* With no arguments, a query log entry is written to *stdout* in the common log format for all requests - -Or if you want/need slightly more control: - -~~~ txt -log [NAME] [FORMAT] -~~~ - -* `NAME` is the name to match in order to be logged -* `FORMAT` is the log format to use (default is Common Log Format) - -You can further specify the classes of responses that get logged: - -~~~ txt -log [NAME] [FORMAT] { - class CLASSES... -} -~~~ - -* `CLASSES` is a space-separated list of classes of responses that should be logged - -The classes of responses have the following meaning: - -* `success`: successful response -* `denial`: either NXDOMAIN or NODATA (name exists, type does not) -* `error`: SERVFAIL, NOTIMP, REFUSED, etc. Anything that indicates the remote server is not willing to - resolve the request. -* `all`: the default - nothing is specified. Using of this class means that all messages will be logged whatever we mix together with "all". - -If no class is specified, it defaults to *all*. - -## Log Format - -You can specify a custom log format with any placeholder values. Log supports both request and -response placeholders. - -The following place holders are supported: - -* `{type}`: qtype of the request -* `{name}`: qname of the request -* `{class}`: qclass of the request -* `{proto}`: protocol used (tcp or udp) -* `{when}`: time of the query -* `{remote}`: client's IP address, for IPv6 addresses these are enclosed in brackets: `[::1]` -* `{size}`: request size in bytes -* `{port}`: client's port -* `{duration}`: response duration -* `{rcode}`: response RCODE -* `{rsize}`: response size -* `{>rflags}`: response flags, each set flag will be displayed, e.g. "aa, tc". This includes the qr - bit as well. -* `{>bufsize}`: the EDNS0 buffer size advertised in the query -* `{>do}`: is the EDNS0 DO (DNSSEC OK) bit set in the query -* `{>id}`: query ID -* `{>opcode}`: query OPCODE - -The default Common Log Format is: - -~~~ txt -`{remote}:{port} - [{when}] {>id} "{type} {class} {name} {proto} {size} {>do} {>bufsize}" {rcode} {>rflags} {rsize} {duration}` -~~~ - -## Examples - -Log all requests to stdout - -~~~ corefile -. { - log - whoami -} -~~~ - -Custom log format, for all zones (`.`) - -~~~ corefile -. { - log . "{proto} Request: {name} {type} {>id}" -} -~~~ - -Only log denials for example.org (and below to a file) - -~~~ corefile -. { - log example.org { - class denial - } -} -~~~ - -Log all queries which were not resolved successfully - -~~~ corefile -. { - log . { - class denial error - } -} -~~~ - -Log all queries on which we did not get errors - -~~~ corefile -. { - log . { - class denial success - } -} -~~~ - -Also the multiple statements can be OR-ed, for example, we can rewrite the above case as following: - -~~~ corefile -. { - log . { - class denial - class success - } -} -~~~ diff --git a/vendor/github.com/coredns/coredns/plugin/log/log.go b/vendor/github.com/coredns/coredns/plugin/log/log.go deleted file mode 100644 index f52a7034..00000000 --- a/vendor/github.com/coredns/coredns/plugin/log/log.go +++ /dev/null @@ -1,90 +0,0 @@ -// Package log implements basic but useful request (access) logging plugin. -package log - -import ( - "context" - "log" - "time" - - "github.com/coredns/coredns/plugin" - "github.com/coredns/coredns/plugin/metrics/vars" - "github.com/coredns/coredns/plugin/pkg/dnstest" - "github.com/coredns/coredns/plugin/pkg/rcode" - "github.com/coredns/coredns/plugin/pkg/replacer" - "github.com/coredns/coredns/plugin/pkg/response" - "github.com/coredns/coredns/request" - - "github.com/miekg/dns" -) - -// Logger is a basic request logging plugin. -type Logger struct { - Next plugin.Handler - Rules []Rule - ErrorFunc func(context.Context, dns.ResponseWriter, *dns.Msg, int) // failover error handler -} - -// ServeDNS implements the plugin.Handler interface. -func (l Logger) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (int, error) { - state := request.Request{W: w, Req: r} - for _, rule := range l.Rules { - if !plugin.Name(rule.NameScope).Matches(state.Name()) { - continue - } - - rrw := dnstest.NewRecorder(w) - rc, err := plugin.NextOrFailure(l.Name(), l.Next, ctx, rrw, r) - - if rc > 0 { - // There was an error up the chain, but no response has been written yet. - // The error must be handled here so the log entry will record the response size. - if l.ErrorFunc != nil { - l.ErrorFunc(ctx, rrw, r, rc) - } else { - answer := new(dns.Msg) - answer.SetRcode(r, rc) - state.SizeAndDo(answer) - - vars.Report(ctx, state, vars.Dropped, rcode.ToString(rc), answer.Len(), time.Now()) - - w.WriteMsg(answer) - } - rc = 0 - } - - tpe, _ := response.Typify(rrw.Msg, time.Now().UTC()) - class := response.Classify(tpe) - // If we don't set up a class in config, the default "all" will be added - // and we shouldn't have an empty rule.Class. - if rule.Class[response.All] || rule.Class[class] { - rep := replacer.New(r, rrw, CommonLogEmptyValue) - rule.Log.Println(rep.Replace(rule.Format)) - } - - return rc, err - - } - return plugin.NextOrFailure(l.Name(), l.Next, ctx, w, r) -} - -// Name implements the Handler interface. -func (l Logger) Name() string { return "log" } - -// Rule configures the logging plugin. -type Rule struct { - NameScope string - Class map[response.Class]bool - Format string - Log *log.Logger -} - -const ( - // CommonLogFormat is the common log format. - CommonLogFormat = `{remote}:{port} ` + CommonLogEmptyValue + ` [{when}] {>id} "{type} {class} {name} {proto} {size} {>do} {>bufsize}" {rcode} {>rflags} {rsize} {duration}` - // CommonLogEmptyValue is the common empty log value. - CommonLogEmptyValue = "-" - // CombinedLogFormat is the combined log format. - CombinedLogFormat = CommonLogFormat + ` "{>opcode}"` - // DefaultLogFormat is the default log format. - DefaultLogFormat = CommonLogFormat -) diff --git a/vendor/github.com/coredns/coredns/plugin/log/log_test.go b/vendor/github.com/coredns/coredns/plugin/log/log_test.go deleted file mode 100644 index 484135cd..00000000 --- a/vendor/github.com/coredns/coredns/plugin/log/log_test.go +++ /dev/null @@ -1,102 +0,0 @@ -package log - -import ( - "bytes" - "context" - "log" - "strings" - "testing" - - "github.com/coredns/coredns/plugin/pkg/dnstest" - "github.com/coredns/coredns/plugin/pkg/response" - "github.com/coredns/coredns/plugin/test" - - "github.com/miekg/dns" -) - -func TestLoggedStatus(t *testing.T) { - var f bytes.Buffer - rule := Rule{ - NameScope: ".", - Format: DefaultLogFormat, - Log: log.New(&f, "", 0), - Class: map[response.Class]bool{response.All: true}, - } - - logger := Logger{ - Rules: []Rule{rule}, - Next: test.ErrorHandler(), - } - - ctx := context.TODO() - r := new(dns.Msg) - r.SetQuestion("example.org.", dns.TypeA) - - rec := dnstest.NewRecorder(&test.ResponseWriter{}) - - rcode, _ := logger.ServeDNS(ctx, rec, r) - if rcode != 0 { - t.Errorf("Expected rcode to be 0 - was: %d", rcode) - } - - logged := f.String() - if !strings.Contains(logged, "A IN example.org. udp 29 false 512") { - t.Errorf("Expected it to be logged. Logged string: %s", logged) - } -} - -func TestLoggedClassDenial(t *testing.T) { - var f bytes.Buffer - rule := Rule{ - NameScope: ".", - Format: DefaultLogFormat, - Log: log.New(&f, "", 0), - Class: map[response.Class]bool{response.Denial: true}, - } - - logger := Logger{ - Rules: []Rule{rule}, - Next: test.ErrorHandler(), - } - - ctx := context.TODO() - r := new(dns.Msg) - r.SetQuestion("example.org.", dns.TypeA) - - rec := dnstest.NewRecorder(&test.ResponseWriter{}) - - logger.ServeDNS(ctx, rec, r) - - logged := f.String() - if len(logged) != 0 { - t.Errorf("Expected it not to be logged, but got string: %s", logged) - } -} - -func TestLoggedClassError(t *testing.T) { - var f bytes.Buffer - rule := Rule{ - NameScope: ".", - Format: DefaultLogFormat, - Log: log.New(&f, "", 0), - Class: map[response.Class]bool{response.Error: true}, - } - - logger := Logger{ - Rules: []Rule{rule}, - Next: test.ErrorHandler(), - } - - ctx := context.TODO() - r := new(dns.Msg) - r.SetQuestion("example.org.", dns.TypeA) - - rec := dnstest.NewRecorder(&test.ResponseWriter{}) - - logger.ServeDNS(ctx, rec, r) - - logged := f.String() - if !strings.Contains(logged, "SERVFAIL") { - t.Errorf("Expected it to be logged. Logged string: %s", logged) - } -} diff --git a/vendor/github.com/coredns/coredns/plugin/log/setup.go b/vendor/github.com/coredns/coredns/plugin/log/setup.go deleted file mode 100644 index 1f9501d6..00000000 --- a/vendor/github.com/coredns/coredns/plugin/log/setup.go +++ /dev/null @@ -1,109 +0,0 @@ -package log - -import ( - "log" - "os" - - "github.com/coredns/coredns/core/dnsserver" - "github.com/coredns/coredns/plugin" - "github.com/coredns/coredns/plugin/pkg/response" - - "github.com/mholt/caddy" - "github.com/miekg/dns" -) - -func init() { - caddy.RegisterPlugin("log", caddy.Plugin{ - ServerType: "dns", - Action: setup, - }) -} - -func setup(c *caddy.Controller) error { - rules, err := logParse(c) - if err != nil { - return plugin.Error("log", err) - } - - // Open the log files for writing when the server starts - c.OnStartup(func() error { - for i := 0; i < len(rules); i++ { - rules[i].Log = log.New(os.Stdout, "", 0) - } - - return nil - }) - - dnsserver.GetConfig(c).AddPlugin(func(next plugin.Handler) plugin.Handler { - return Logger{Next: next, Rules: rules, ErrorFunc: dnsserver.DefaultErrorFunc} - }) - - return nil -} - -func logParse(c *caddy.Controller) ([]Rule, error) { - var rules []Rule - - for c.Next() { - args := c.RemainingArgs() - - if len(args) == 0 { - // Nothing specified; use defaults - rules = append(rules, Rule{ - NameScope: ".", - Format: DefaultLogFormat, - Class: make(map[response.Class]bool), - }) - } else if len(args) == 1 { - rules = append(rules, Rule{ - NameScope: dns.Fqdn(args[0]), - Format: DefaultLogFormat, - Class: make(map[response.Class]bool), - }) - } else { - // Name scope, and maybe a format specified - format := DefaultLogFormat - - switch args[1] { - case "{common}": - format = CommonLogFormat - case "{combined}": - format = CombinedLogFormat - default: - format = args[1] - } - - rules = append(rules, Rule{ - NameScope: dns.Fqdn(args[0]), - Format: format, - Class: make(map[response.Class]bool), - }) - } - - // Class refinements in an extra block. - for c.NextBlock() { - switch c.Val() { - // class followed by combinations of all, denial, error and success. - case "class": - classes := c.RemainingArgs() - if len(classes) == 0 { - return nil, c.ArgErr() - } - for _, c := range classes { - cls, err := response.ClassFromString(c) - if err != nil { - return nil, err - } - rules[len(rules)-1].Class[cls] = true - } - default: - return nil, c.ArgErr() - } - } - if len(rules[len(rules)-1].Class) == 0 { - rules[len(rules)-1].Class[response.All] = true - } - } - - return rules, nil -} diff --git a/vendor/github.com/coredns/coredns/plugin/log/setup_test.go b/vendor/github.com/coredns/coredns/plugin/log/setup_test.go deleted file mode 100644 index bf2ac3c3..00000000 --- a/vendor/github.com/coredns/coredns/plugin/log/setup_test.go +++ /dev/null @@ -1,138 +0,0 @@ -package log - -import ( - "reflect" - "testing" - - "github.com/coredns/coredns/plugin/pkg/response" - - "github.com/mholt/caddy" -) - -func TestLogParse(t *testing.T) { - tests := []struct { - inputLogRules string - shouldErr bool - expectedLogRules []Rule - }{ - {`log`, false, []Rule{{ - NameScope: ".", - Format: DefaultLogFormat, - Class: map[response.Class]bool{response.All: true}, - }}}, - {`log example.org`, false, []Rule{{ - NameScope: "example.org.", - Format: DefaultLogFormat, - Class: map[response.Class]bool{response.All: true}, - }}}, - {`log example.org. {common}`, false, []Rule{{ - NameScope: "example.org.", - Format: CommonLogFormat, - Class: map[response.Class]bool{response.All: true}, - }}}, - {`log example.org {combined}`, false, []Rule{{ - NameScope: "example.org.", - Format: CombinedLogFormat, - Class: map[response.Class]bool{response.All: true}, - }}}, - {`log example.org. - log example.net {combined}`, false, []Rule{{ - NameScope: "example.org.", - Format: DefaultLogFormat, - Class: map[response.Class]bool{response.All: true}, - }, { - NameScope: "example.net.", - Format: CombinedLogFormat, - Class: map[response.Class]bool{response.All: true}, - }}}, - {`log example.org {host} - log example.org {when}`, false, []Rule{{ - NameScope: "example.org.", - Format: "{host}", - Class: map[response.Class]bool{response.All: true}, - }, { - NameScope: "example.org.", - Format: "{when}", - Class: map[response.Class]bool{response.All: true}, - }}}, - - {`log example.org { - class all - }`, false, []Rule{{ - NameScope: "example.org.", - Format: CommonLogFormat, - Class: map[response.Class]bool{response.All: true}, - }}}, - {`log example.org { - class denial - }`, false, []Rule{{ - NameScope: "example.org.", - Format: CommonLogFormat, - Class: map[response.Class]bool{response.Denial: true}, - }}}, - {`log { - class denial - }`, false, []Rule{{ - NameScope: ".", - Format: CommonLogFormat, - Class: map[response.Class]bool{response.Denial: true}, - }}}, - {`log { - class denial error - }`, false, []Rule{{ - NameScope: ".", - Format: CommonLogFormat, - Class: map[response.Class]bool{response.Denial: true, response.Error: true}, - }}}, - {`log { - class denial - class error - }`, false, []Rule{{ - NameScope: ".", - Format: CommonLogFormat, - Class: map[response.Class]bool{response.Denial: true, response.Error: true}, - }}}, - {`log { - class abracadabra - }`, true, []Rule{}}, - {`log { - class - }`, true, []Rule{}}, - {`log { - unknown - }`, true, []Rule{}}, - } - for i, test := range tests { - c := caddy.NewTestController("dns", test.inputLogRules) - actualLogRules, err := logParse(c) - - if err == nil && test.shouldErr { - t.Errorf("Test %d with input '%s' didn't error, but it should have", i, test.inputLogRules) - } else if err != nil && !test.shouldErr { - t.Errorf("Test %d with input '%s' errored, but it shouldn't have; got '%v'", - i, test.inputLogRules, err) - } - if len(actualLogRules) != len(test.expectedLogRules) { - t.Fatalf("Test %d expected %d no of Log rules, but got %d ", - i, len(test.expectedLogRules), len(actualLogRules)) - } - for j, actualLogRule := range actualLogRules { - - if actualLogRule.NameScope != test.expectedLogRules[j].NameScope { - t.Errorf("Test %d expected %dth LogRule NameScope for '%s' to be %s , but got %s", - i, j, test.inputLogRules, test.expectedLogRules[j].NameScope, actualLogRule.NameScope) - } - - if actualLogRule.Format != test.expectedLogRules[j].Format { - t.Errorf("Test %d expected %dth LogRule Format for '%s' to be %s , but got %s", - i, j, test.inputLogRules, test.expectedLogRules[j].Format, actualLogRule.Format) - } - - if !reflect.DeepEqual(actualLogRule.Class, test.expectedLogRules[j].Class) { - t.Errorf("Test %d expected %dth LogRule Class to be %v , but got %v", - i, j, test.expectedLogRules[j].Class, actualLogRule.Class) - } - } - } - -} diff --git a/vendor/github.com/coredns/coredns/plugin/metrics/README.md b/vendor/github.com/coredns/coredns/plugin/metrics/README.md index 2a914fe4..c8c29839 100644 --- a/vendor/github.com/coredns/coredns/plugin/metrics/README.md +++ b/vendor/github.com/coredns/coredns/plugin/metrics/README.md @@ -71,7 +71,7 @@ then: ## Bugs -When reloading, the Prometheus handler is stopped before the new server instance is started. -If that new server fails to start, then the initial server instance is still available and DNS queries still served, -but Prometheus handler stays down. +When reloading, the Prometheus handler is stopped before the new server instance is started. +If that new server fails to start, then the initial server instance is still available and DNS queries still served, +but Prometheus handler stays down. Prometheus will not reply HTTP request until a successful reload or a complete restart of CoreDNS. diff --git a/vendor/github.com/coredns/coredns/plugin/metrics/metrics_test.go b/vendor/github.com/coredns/coredns/plugin/metrics/metrics_test.go deleted file mode 100644 index 211abdb2..00000000 --- a/vendor/github.com/coredns/coredns/plugin/metrics/metrics_test.go +++ /dev/null @@ -1,83 +0,0 @@ -package metrics - -import ( - "context" - "testing" - - "github.com/coredns/coredns/plugin" - mtest "github.com/coredns/coredns/plugin/metrics/test" - "github.com/coredns/coredns/plugin/pkg/dnstest" - "github.com/coredns/coredns/plugin/test" - - "github.com/miekg/dns" -) - -func TestMetrics(t *testing.T) { - met := New("localhost:0") - if err := met.OnStartup(); err != nil { - t.Fatalf("Failed to start metrics handler: %s", err) - } - defer met.OnFinalShutdown() - - met.AddZone("example.org.") - - tests := []struct { - next plugin.Handler - qname string - qtype uint16 - metric string - expectedValue string - }{ - // This all works because 1 bucket (1 zone, 1 type) - { - next: test.NextHandler(dns.RcodeSuccess, nil), - qname: "example.org", - metric: "coredns_dns_request_count_total", - expectedValue: "1", - }, - { - next: test.NextHandler(dns.RcodeSuccess, nil), - qname: "example.org", - metric: "coredns_dns_request_count_total", - expectedValue: "2", - }, - { - next: test.NextHandler(dns.RcodeSuccess, nil), - qname: "example.org", - metric: "coredns_dns_request_type_count_total", - expectedValue: "3", - }, - { - next: test.NextHandler(dns.RcodeSuccess, nil), - qname: "example.org", - metric: "coredns_dns_response_rcode_count_total", - expectedValue: "4", - }, - } - - ctx := context.TODO() - - for i, tc := range tests { - req := new(dns.Msg) - if tc.qtype == 0 { - tc.qtype = dns.TypeA - } - req.SetQuestion(dns.Fqdn(tc.qname), tc.qtype) - met.Next = tc.next - - rec := dnstest.NewRecorder(&test.ResponseWriter{}) - _, err := met.ServeDNS(ctx, rec, req) - if err != nil { - t.Fatalf("Test %d: Expected no error, but got %s", i, err) - } - - result := mtest.Scrape(t, "http://"+ListenAddr+"/metrics") - - if tc.expectedValue != "" { - got, _ := mtest.MetricValue(tc.metric, result) - if got != tc.expectedValue { - t.Errorf("Test %d: Expected value %s for metrics %s, but got %s", i, tc.expectedValue, tc.metric, got) - } - } - } -} diff --git a/vendor/github.com/coredns/coredns/plugin/metrics/setup_test.go b/vendor/github.com/coredns/coredns/plugin/metrics/setup_test.go deleted file mode 100644 index 73555427..00000000 --- a/vendor/github.com/coredns/coredns/plugin/metrics/setup_test.go +++ /dev/null @@ -1,42 +0,0 @@ -package metrics - -import ( - "testing" - - "github.com/mholt/caddy" -) - -func TestPrometheusParse(t *testing.T) { - tests := []struct { - input string - shouldErr bool - addr string - }{ - // oks - {`prometheus`, false, "localhost:9153"}, - {`prometheus localhost:53`, false, "localhost:53"}, - // fails - {`prometheus {}`, true, ""}, - {`prometheus /foo`, true, ""}, - {`prometheus a b c`, true, ""}, - } - for i, test := range tests { - c := caddy.NewTestController("dns", test.input) - m, err := prometheusParse(c) - if test.shouldErr && err == nil { - t.Errorf("Test %v: Expected error but found nil", i) - continue - } else if !test.shouldErr && err != nil { - t.Errorf("Test %v: Expected no error but found error: %v", i, err) - continue - } - - if test.shouldErr { - continue - } - - if test.addr != m.Addr { - t.Errorf("Test %v: Expected address %s but found: %s", i, test.addr, m.Addr) - } - } -} diff --git a/vendor/github.com/coredns/coredns/plugin/metrics/test/scrape.go b/vendor/github.com/coredns/coredns/plugin/metrics/test/scrape.go deleted file mode 100644 index a21c0061..00000000 --- a/vendor/github.com/coredns/coredns/plugin/metrics/test/scrape.go +++ /dev/null @@ -1,225 +0,0 @@ -// Adapted by Miek Gieben for CoreDNS testing. -// -// License from prom2json -// Copyright 2014 Prometheus Team -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Package test will scrape a target and you can inspect the variables. -// Basic usage: -// -// result := Scrape("http://localhost:9153/metrics") -// v := MetricValue("coredns_cache_capacity", result) -// -package test - -import ( - "fmt" - "io" - "mime" - "net/http" - "testing" - - "github.com/matttproud/golang_protobuf_extensions/pbutil" - "github.com/prometheus/common/expfmt" - - dto "github.com/prometheus/client_model/go" -) - -type ( - // MetricFamily holds a prometheus metric. - MetricFamily struct { - Name string `json:"name"` - Help string `json:"help"` - Type string `json:"type"` - Metrics []interface{} `json:"metrics,omitempty"` // Either metric or summary. - } - - // metric is for all "single value" metrics. - metric struct { - Labels map[string]string `json:"labels,omitempty"` - Value string `json:"value"` - } - - summary struct { - Labels map[string]string `json:"labels,omitempty"` - Quantiles map[string]string `json:"quantiles,omitempty"` - Count string `json:"count"` - Sum string `json:"sum"` - } - - histogram struct { - Labels map[string]string `json:"labels,omitempty"` - Buckets map[string]string `json:"buckets,omitempty"` - Count string `json:"count"` - Sum string `json:"sum"` - } -) - -// Scrape returns the all the vars a []*metricFamily. -func Scrape(t *testing.T, url string) []*MetricFamily { - mfChan := make(chan *dto.MetricFamily, 1024) - - go fetchMetricFamilies(url, mfChan) - - result := []*MetricFamily{} - for mf := range mfChan { - result = append(result, newMetricFamily(mf)) - } - return result -} - -// MetricValue returns the value associated with name as a string as well as the labels. -// It only returns the first metrics of the slice. -func MetricValue(name string, mfs []*MetricFamily) (string, map[string]string) { - for _, mf := range mfs { - if mf.Name == name { - // Only works with Gauge and Counter... - return mf.Metrics[0].(metric).Value, mf.Metrics[0].(metric).Labels - } - } - return "", nil -} - -// MetricValueLabel returns the value for name *and* label *value*. -func MetricValueLabel(name, label string, mfs []*MetricFamily) (string, map[string]string) { - // bit hacky is this really handy...? - for _, mf := range mfs { - if mf.Name == name { - for _, m := range mf.Metrics { - for _, v := range m.(metric).Labels { - if v == label { - return m.(metric).Value, m.(metric).Labels - } - } - - } - } - } - return "", nil -} - -func newMetricFamily(dtoMF *dto.MetricFamily) *MetricFamily { - mf := &MetricFamily{ - Name: dtoMF.GetName(), - Help: dtoMF.GetHelp(), - Type: dtoMF.GetType().String(), - Metrics: make([]interface{}, len(dtoMF.Metric)), - } - for i, m := range dtoMF.Metric { - if dtoMF.GetType() == dto.MetricType_SUMMARY { - mf.Metrics[i] = summary{ - Labels: makeLabels(m), - Quantiles: makeQuantiles(m), - Count: fmt.Sprint(m.GetSummary().GetSampleCount()), - Sum: fmt.Sprint(m.GetSummary().GetSampleSum()), - } - } else if dtoMF.GetType() == dto.MetricType_HISTOGRAM { - mf.Metrics[i] = histogram{ - Labels: makeLabels(m), - Buckets: makeBuckets(m), - Count: fmt.Sprint(m.GetHistogram().GetSampleCount()), - Sum: fmt.Sprint(m.GetSummary().GetSampleSum()), - } - } else { - mf.Metrics[i] = metric{ - Labels: makeLabels(m), - Value: fmt.Sprint(value(m)), - } - } - } - return mf -} - -func value(m *dto.Metric) float64 { - if m.Gauge != nil { - return m.GetGauge().GetValue() - } - if m.Counter != nil { - return m.GetCounter().GetValue() - } - if m.Untyped != nil { - return m.GetUntyped().GetValue() - } - return 0. -} - -func makeLabels(m *dto.Metric) map[string]string { - result := map[string]string{} - for _, lp := range m.Label { - result[lp.GetName()] = lp.GetValue() - } - return result -} - -func makeQuantiles(m *dto.Metric) map[string]string { - result := map[string]string{} - for _, q := range m.GetSummary().Quantile { - result[fmt.Sprint(q.GetQuantile())] = fmt.Sprint(q.GetValue()) - } - return result -} - -func makeBuckets(m *dto.Metric) map[string]string { - result := map[string]string{} - for _, b := range m.GetHistogram().Bucket { - result[fmt.Sprint(b.GetUpperBound())] = fmt.Sprint(b.GetCumulativeCount()) - } - return result -} - -func fetchMetricFamilies(url string, ch chan<- *dto.MetricFamily) { - defer close(ch) - req, err := http.NewRequest("GET", url, nil) - if err != nil { - return - } - req.Header.Add("Accept", acceptHeader) - resp, err := http.DefaultClient.Do(req) - if err != nil { - return - } - defer resp.Body.Close() - if resp.StatusCode != http.StatusOK { - return - } - - mediatype, params, err := mime.ParseMediaType(resp.Header.Get("Content-Type")) - if err == nil && mediatype == "application/vnd.google.protobuf" && - params["encoding"] == "delimited" && - params["proto"] == "io.prometheus.client.MetricFamily" { - for { - mf := &dto.MetricFamily{} - if _, err = pbutil.ReadDelimited(resp.Body, mf); err != nil { - if err == io.EOF { - break - } - return - } - ch <- mf - } - } else { - // We could do further content-type checks here, but the - // fallback for now will anyway be the text format - // version 0.0.4, so just go for it and see if it works. - var parser expfmt.TextParser - metricFamilies, err := parser.TextToMetricFamilies(resp.Body) - if err != nil { - return - } - for _, mf := range metricFamilies { - ch <- mf - } - } -} - -const acceptHeader = `application/vnd.google.protobuf;proto=io.prometheus.client.MetricFamily;encoding=delimited;q=0.7,text/plain;version=0.0.4;q=0.3` diff --git a/vendor/github.com/coredns/coredns/plugin/normalize_test.go b/vendor/github.com/coredns/coredns/plugin/normalize_test.go deleted file mode 100644 index e81d3262..00000000 --- a/vendor/github.com/coredns/coredns/plugin/normalize_test.go +++ /dev/null @@ -1,112 +0,0 @@ -package plugin - -import "testing" - -func TestZoneMatches(t *testing.T) { - child := "example.org." - zones := Zones([]string{"org.", "."}) - actual := zones.Matches(child) - if actual != "org." { - t.Errorf("Expected %v, got %v", "org.", actual) - } - - child = "bla.example.org." - zones = Zones([]string{"bla.example.org.", "org.", "."}) - actual = zones.Matches(child) - - if actual != "bla.example.org." { - t.Errorf("Expected %v, got %v", "org.", actual) - } -} - -func TestZoneNormalize(t *testing.T) { - zones := Zones([]string{"example.org", "Example.ORG.", "example.org."}) - expected := "example.org." - zones.Normalize() - - for _, actual := range zones { - if actual != expected { - t.Errorf("Expected %v, got %v\n", expected, actual) - } - } -} - -func TestNameMatches(t *testing.T) { - matches := []struct { - child string - parent string - expected bool - }{ - {".", ".", true}, - {"example.org.", ".", true}, - {"example.org.", "example.org.", true}, - {"example.org.", "org.", true}, - {"org.", "example.org.", false}, - } - - for _, m := range matches { - actual := Name(m.parent).Matches(m.child) - if actual != m.expected { - t.Errorf("Expected %v for %s/%s, got %v", m.expected, m.parent, m.child, actual) - } - - } -} - -func TestNameNormalize(t *testing.T) { - names := []string{ - "example.org", "example.org.", - "Example.ORG.", "example.org."} - - for i := 0; i < len(names); i += 2 { - ts := names[i] - expected := names[i+1] - actual := Name(ts).Normalize() - if expected != actual { - t.Errorf("Expected %v, got %v\n", expected, actual) - } - } -} - -func TestHostNormalize(t *testing.T) { - hosts := []string{".:53", ".", "example.org:53", "example.org.", "example.org.:53", "example.org.", - "10.0.0.0/8:53", "10.in-addr.arpa.", "10.0.0.0/9", "10.in-addr.arpa.", - "dns://example.org", "example.org."} - - for i := 0; i < len(hosts); i += 2 { - ts := hosts[i] - expected := hosts[i+1] - actual := Host(ts).Normalize() - if expected != actual { - t.Errorf("Expected %v, got %v\n", expected, actual) - } - } -} - -func TestSplitHostPortReverse(t *testing.T) { - tests := map[string]int{ - "example.org.": 0, - "10.0.0.0/9": 32 - 9, - "10.0.0.0/8": 32 - 8, - "10.0.0.0/17": 32 - 17, - "10.0.0.0/0": 32 - 0, - "10.0.0.0/64": 0, - "10.0.0.0": 0, - "10.0.0": 0, - "2003::1/65": 128 - 65, - } - for in, expect := range tests { - _, _, n, err := SplitHostPort(in) - if err != nil { - t.Errorf("Expected no error, got %q for %s", in, err) - } - if n == nil { - continue - } - ones, bits := n.Mask.Size() - got := bits - ones - if got != expect { - t.Errorf("Expected %d, got %d for %s", expect, got, in) - } - } -} diff --git a/vendor/github.com/coredns/coredns/plugin/nsid/OWNERS b/vendor/github.com/coredns/coredns/plugin/nsid/OWNERS deleted file mode 100644 index 4e0ca6d9..00000000 --- a/vendor/github.com/coredns/coredns/plugin/nsid/OWNERS +++ /dev/null @@ -1,4 +0,0 @@ -reviewers: - - yongtang -approvers: - - yongtang diff --git a/vendor/github.com/coredns/coredns/plugin/nsid/README.md b/vendor/github.com/coredns/coredns/plugin/nsid/README.md deleted file mode 100644 index 0ff5cd76..00000000 --- a/vendor/github.com/coredns/coredns/plugin/nsid/README.md +++ /dev/null @@ -1,57 +0,0 @@ -# nsid - -## Name - -*nsid* - adds an identifier of this server to each reply. - -## Description - -This plugin implements [RFC 5001](https://tools.ietf.org/html/rfc5001) and adds an EDNS0 OPT -resource record to replies that uniquely identify the server. This is useful in anycast setups to -see which server was responsible for generating the reply and for debugging. - -This plugin can only be used once per Server Block. - - -## Syntax - -~~~ txt -nsid [DATA] -~~~ - -**DATA** is the string to use in the nsid record. - -If **DATA** is not given, the host's name is used. - -## Examples - -Enable nsid: - -~~~ corefile -. { - whoami - nsid Use The Force -} -~~~ - -And now a client with NSID support will see an OPT record with the NSID option: - -~~~ sh -% dig +nsid @localhost a whoami.example.org - -;; Got answer: -;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 46880 -;; flags: qr aa rd; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 3 - -.... - -; OPT PSEUDOSECTION: -; EDNS: version: 0, flags:; udp: 4096 -; NSID: 55 73 65 20 54 68 65 20 46 6f 72 63 65 ("Use The Force") -;; QUESTION SECTION: -;whoami.example.org. IN A -~~~ - -## Also See - -[RFC 5001](https://tools.ietf.org/html/rfc5001) diff --git a/vendor/github.com/coredns/coredns/plugin/nsid/nsid.go b/vendor/github.com/coredns/coredns/plugin/nsid/nsid.go deleted file mode 100644 index b79df75b..00000000 --- a/vendor/github.com/coredns/coredns/plugin/nsid/nsid.go +++ /dev/null @@ -1,53 +0,0 @@ -// Package nsid implements NSID protocol -package nsid - -import ( - "context" - "encoding/hex" - - "github.com/coredns/coredns/plugin" - - "github.com/miekg/dns" -) - -// Nsid plugin -type Nsid struct { - Next plugin.Handler - Data string -} - -// ResponseWriter is a response writer that adds NSID response -type ResponseWriter struct { - dns.ResponseWriter - Data string -} - -// ServeDNS implements the plugin.Handler interface. -func (n Nsid) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (int, error) { - if option := r.IsEdns0(); option != nil { - for _, o := range option.Option { - if _, ok := o.(*dns.EDNS0_NSID); ok { - nw := &ResponseWriter{ResponseWriter: w, Data: n.Data} - return plugin.NextOrFailure(n.Name(), n.Next, ctx, nw, r) - } - } - } - return plugin.NextOrFailure(n.Name(), n.Next, ctx, w, r) -} - -// WriteMsg implements the dns.ResponseWriter interface. -func (w *ResponseWriter) WriteMsg(res *dns.Msg) error { - if option := res.IsEdns0(); option != nil { - for _, o := range option.Option { - if e, ok := o.(*dns.EDNS0_NSID); ok { - e.Code = dns.EDNS0NSID - e.Nsid = hex.EncodeToString([]byte(w.Data)) - } - } - } - returned := w.ResponseWriter.WriteMsg(res) - return returned -} - -// Name implements the Handler interface. -func (n Nsid) Name() string { return "nsid" } diff --git a/vendor/github.com/coredns/coredns/plugin/nsid/nsid_test.go b/vendor/github.com/coredns/coredns/plugin/nsid/nsid_test.go deleted file mode 100644 index 32e8d8d5..00000000 --- a/vendor/github.com/coredns/coredns/plugin/nsid/nsid_test.go +++ /dev/null @@ -1,73 +0,0 @@ -package nsid - -import ( - "context" - "encoding/hex" - "testing" - - "github.com/coredns/coredns/plugin" - "github.com/coredns/coredns/plugin/pkg/dnstest" - "github.com/coredns/coredns/plugin/test" - "github.com/coredns/coredns/plugin/whoami" - - "github.com/miekg/dns" -) - -func TestNsid(t *testing.T) { - em := Nsid{ - Data: "NSID", - } - - tests := []struct { - next plugin.Handler - qname string - qtype uint16 - expectedCode int - expectedReply string - expectedErr error - }{ - { - next: whoami.Whoami{}, - qname: ".", - expectedCode: dns.RcodeSuccess, - expectedReply: hex.EncodeToString([]byte("NSID")), - expectedErr: nil, - }, - } - - ctx := context.TODO() - - for i, tc := range tests { - req := new(dns.Msg) - if tc.qtype == 0 { - tc.qtype = dns.TypeA - } - req.SetQuestion(dns.Fqdn(tc.qname), tc.qtype) - req.Question[0].Qclass = dns.ClassINET - - req.SetEdns0(4096, false) - option := req.Extra[0].(*dns.OPT) - option.Option = append(option.Option, &dns.EDNS0_NSID{Code: dns.EDNS0NSID, Nsid: ""}) - em.Next = tc.next - - rec := dnstest.NewRecorder(&test.ResponseWriter{}) - code, err := em.ServeDNS(ctx, rec, req) - - if err != tc.expectedErr { - t.Errorf("Test %d: Expected error %v, but got %v", i, tc.expectedErr, err) - } - if code != int(tc.expectedCode) { - t.Errorf("Test %d: Expected status code %d, but got %d", i, tc.expectedCode, code) - } - if tc.expectedReply != "" { - for _, extra := range rec.Msg.Extra { - if option, ok := extra.(*dns.OPT); ok { - e := option.Option[0].(*dns.EDNS0_NSID) - if e.Nsid != tc.expectedReply { - t.Errorf("Test %d: Expected answer %s, but got %s", i, tc.expectedReply, e.Nsid) - } - } - } - } - } -} diff --git a/vendor/github.com/coredns/coredns/plugin/nsid/setup.go b/vendor/github.com/coredns/coredns/plugin/nsid/setup.go deleted file mode 100644 index e6c5c5ae..00000000 --- a/vendor/github.com/coredns/coredns/plugin/nsid/setup.go +++ /dev/null @@ -1,51 +0,0 @@ -package nsid - -import ( - "os" - "strings" - - "github.com/coredns/coredns/core/dnsserver" - "github.com/coredns/coredns/plugin" - - "github.com/mholt/caddy" -) - -func init() { - caddy.RegisterPlugin("nsid", caddy.Plugin{ - ServerType: "dns", - Action: setup, - }) -} - -func setup(c *caddy.Controller) error { - nsid, err := nsidParse(c) - if err != nil { - return plugin.Error("nsid", err) - } - - dnsserver.GetConfig(c).AddPlugin(func(next plugin.Handler) plugin.Handler { - return Nsid{Next: next, Data: nsid} - }) - - return nil -} - -func nsidParse(c *caddy.Controller) (string, error) { - // Use hostname as the default - nsid, err := os.Hostname() - if err != nil { - nsid = "localhost" - } - i := 0 - for c.Next() { - if i > 0 { - return nsid, plugin.ErrOnce - } - i++ - args := c.RemainingArgs() - if len(args) > 0 { - nsid = strings.Join(args, " ") - } - } - return nsid, nil -} diff --git a/vendor/github.com/coredns/coredns/plugin/nsid/setup_test.go b/vendor/github.com/coredns/coredns/plugin/nsid/setup_test.go deleted file mode 100644 index 059b05bb..00000000 --- a/vendor/github.com/coredns/coredns/plugin/nsid/setup_test.go +++ /dev/null @@ -1,52 +0,0 @@ -package nsid - -import ( - "os" - "strings" - "testing" - - "github.com/mholt/caddy" -) - -func TestSetupNsid(t *testing.T) { - defaultNsid, err := os.Hostname() - if err != nil { - defaultNsid = "localhost" - } - tests := []struct { - input string - shouldErr bool - expectedData string - expectedErrContent string // substring from the expected error. Empty for positive cases. - }{ - {`nsid`, false, defaultNsid, ""}, - {`nsid "ps0"`, false, "ps0", ""}, - {`nsid "worker1"`, false, "worker1", ""}, - {`nsid "tf 2"`, false, "tf 2", ""}, - {`nsid - nsid`, true, "", "plugin"}, - } - - for i, test := range tests { - c := caddy.NewTestController("dns", test.input) - nsid, err := nsidParse(c) - - if test.shouldErr && err == nil { - t.Errorf("Test %d: Expected error but found %s for input %s", i, err, test.input) - } - - if err != nil { - if !test.shouldErr { - t.Errorf("Test %d: Expected no error but found one for input %s. Error was: %v", i, test.input, err) - } - - if !strings.Contains(err.Error(), test.expectedErrContent) { - t.Errorf("Test %d: Expected error to contain: %v, found error: %v, input: %s", i, test.expectedErrContent, err, test.input) - } - } - - if !test.shouldErr && nsid != test.expectedData { - t.Errorf("Nsid not correctly set for input %s. Expected: %s, actual: %s", test.input, test.expectedData, nsid) - } - } -} diff --git a/vendor/github.com/coredns/coredns/plugin/pkg/cache/cache_test.go b/vendor/github.com/coredns/coredns/plugin/pkg/cache/cache_test.go deleted file mode 100644 index 0c56bb9b..00000000 --- a/vendor/github.com/coredns/coredns/plugin/pkg/cache/cache_test.go +++ /dev/null @@ -1,41 +0,0 @@ -package cache - -import "testing" - -func TestCacheAddAndGet(t *testing.T) { - c := New(4) - c.Add(1, 1) - - if _, found := c.Get(1); !found { - t.Fatal("Failed to find inserted record") - } -} - -func TestCacheLen(t *testing.T) { - c := New(4) - - c.Add(1, 1) - if l := c.Len(); l != 1 { - t.Fatalf("Cache size should %d, got %d", 1, l) - } - - c.Add(1, 1) - if l := c.Len(); l != 1 { - t.Fatalf("Cache size should %d, got %d", 1, l) - } - - c.Add(2, 2) - if l := c.Len(); l != 2 { - t.Fatalf("Cache size should %d, got %d", 2, l) - } -} - -func BenchmarkCache(b *testing.B) { - b.ReportAllocs() - - c := New(4) - for n := 0; n < b.N; n++ { - c.Add(1, 1) - c.Get(1) - } -} diff --git a/vendor/github.com/coredns/coredns/plugin/pkg/cache/shard_test.go b/vendor/github.com/coredns/coredns/plugin/pkg/cache/shard_test.go deleted file mode 100644 index 26675cee..00000000 --- a/vendor/github.com/coredns/coredns/plugin/pkg/cache/shard_test.go +++ /dev/null @@ -1,60 +0,0 @@ -package cache - -import "testing" - -func TestShardAddAndGet(t *testing.T) { - s := newShard(4) - s.Add(1, 1) - - if _, found := s.Get(1); !found { - t.Fatal("Failed to find inserted record") - } -} - -func TestShardLen(t *testing.T) { - s := newShard(4) - - s.Add(1, 1) - if l := s.Len(); l != 1 { - t.Fatalf("Shard size should %d, got %d", 1, l) - } - - s.Add(1, 1) - if l := s.Len(); l != 1 { - t.Fatalf("Shard size should %d, got %d", 1, l) - } - - s.Add(2, 2) - if l := s.Len(); l != 2 { - t.Fatalf("Shard size should %d, got %d", 2, l) - } -} - -func TestShardEvict(t *testing.T) { - s := newShard(1) - s.Add(1, 1) - s.Add(2, 2) - // 1 should be gone - - if _, found := s.Get(1); found { - t.Fatal("Found item that should have been evicted") - } -} - -func TestShardLenEvict(t *testing.T) { - s := newShard(4) - s.Add(1, 1) - s.Add(2, 1) - s.Add(3, 1) - s.Add(4, 1) - - if l := s.Len(); l != 4 { - t.Fatalf("Shard size should %d, got %d", 4, l) - } - - // This should evict one element - s.Add(5, 1) - if l := s.Len(); l != 4 { - t.Fatalf("Shard size should %d, got %d", 4, l) - } -} diff --git a/vendor/github.com/coredns/coredns/plugin/pkg/dnstest/multirecorder_test.go b/vendor/github.com/coredns/coredns/plugin/pkg/dnstest/multirecorder_test.go deleted file mode 100644 index 756b635a..00000000 --- a/vendor/github.com/coredns/coredns/plugin/pkg/dnstest/multirecorder_test.go +++ /dev/null @@ -1,39 +0,0 @@ -package dnstest - -import ( - "testing" - - "github.com/miekg/dns" -) - -func TestMultiWriteMsg(t *testing.T) { - w := &responseWriter{} - record := NewMultiRecorder(w) - - responseTestName := "testmsg.example.org." - responseTestMsg := new(dns.Msg) - responseTestMsg.SetQuestion(responseTestName, dns.TypeA) - - record.WriteMsg(responseTestMsg) - record.WriteMsg(responseTestMsg) - - if len(record.Msgs) != 2 { - t.Fatalf("Expected 2 messages to be written, but instead found %d\n", len(record.Msgs)) - - } - if record.Len != responseTestMsg.Len()*2 { - t.Fatalf("Expected the bytes written counter to be %d, but instead found %d\n", responseTestMsg.Len()*2, record.Len) - } -} - -func TestMultiWrite(t *testing.T) { - w := &responseWriter{} - record := NewRecorder(w) - responseTest := []byte("testmsg.example.org.") - - record.Write(responseTest) - record.Write(responseTest) - if record.Len != len(responseTest)*2 { - t.Fatalf("Expected the bytes written counter to be %d, but instead found %d\n", len(responseTest)*2, record.Len) - } -} diff --git a/vendor/github.com/coredns/coredns/plugin/pkg/dnstest/recorder_test.go b/vendor/github.com/coredns/coredns/plugin/pkg/dnstest/recorder_test.go deleted file mode 100644 index 96af7b01..00000000 --- a/vendor/github.com/coredns/coredns/plugin/pkg/dnstest/recorder_test.go +++ /dev/null @@ -1,50 +0,0 @@ -package dnstest - -import ( - "testing" - - "github.com/miekg/dns" -) - -type responseWriter struct{ dns.ResponseWriter } - -func (r *responseWriter) WriteMsg(m *dns.Msg) error { return nil } -func (r *responseWriter) Write(buf []byte) (int, error) { return len(buf), nil } - -func TestNewRecorder(t *testing.T) { - w := &responseWriter{} - record := NewRecorder(w) - if record.ResponseWriter != w { - t.Fatalf("Expected Response writer in the Recording to be same as the one sent\n") - } - if record.Rcode != dns.RcodeSuccess { - t.Fatalf("Expected recorded status to be dns.RcodeSuccess (%d) , but found %d\n ", dns.RcodeSuccess, record.Rcode) - } -} - -func TestWriteMsg(t *testing.T) { - w := &responseWriter{} - record := NewRecorder(w) - responseTestName := "testmsg.example.org." - responseTestMsg := new(dns.Msg) - responseTestMsg.SetQuestion(responseTestName, dns.TypeA) - - record.WriteMsg(responseTestMsg) - if record.Len != responseTestMsg.Len() { - t.Fatalf("Expected the bytes written counter to be %d, but instead found %d\n", responseTestMsg.Len(), record.Len) - } - if x := record.Msg.Question[0].Name; x != responseTestName { - t.Fatalf("Expected Msg Qname to be %s , but found %s\n", responseTestName, x) - } -} - -func TestWrite(t *testing.T) { - w := &responseWriter{} - record := NewRecorder(w) - responseTest := []byte("testmsg.example.org.") - - record.Write(responseTest) - if record.Len != len(responseTest) { - t.Fatalf("Expected the bytes written counter to be %d, but instead found %d\n", len(responseTest), record.Len) - } -} diff --git a/vendor/github.com/coredns/coredns/plugin/pkg/dnstest/server.go b/vendor/github.com/coredns/coredns/plugin/pkg/dnstest/server.go index 8e9a2c76..bbad0f96 100644 --- a/vendor/github.com/coredns/coredns/plugin/pkg/dnstest/server.go +++ b/vendor/github.com/coredns/coredns/plugin/pkg/dnstest/server.go @@ -23,18 +23,28 @@ func NewServer(f dns.HandlerFunc) *Server { ch1 := make(chan bool) ch2 := make(chan bool) - l, _ := net.Listen("tcp", ":0") - if l == nil { - return nil + s1 := &dns.Server{} // udp + s2 := &dns.Server{} // tcp + + for i := 0; i < 5; i++ { // 5 attempts + s2.Listener, _ = net.Listen("tcp", ":0") + if s2.Listener == nil { + continue + } + + s1.PacketConn, _ = net.ListenPacket("udp", s2.Listener.Addr().String()) + if s1.PacketConn != nil { + break + } + + // perhaps UPD port is in use, try again + s2.Listener.Close() + s2.Listener = nil } - p, _ := net.ListenPacket("udp", l.Addr().String()) - if p == nil { - l.Close() - return nil // yes, this may crash some test, but this is better than hanging + if s2.Listener == nil { + panic("dnstest.NewServer(): failed to create new server") } - s1 := &dns.Server{PacketConn: p} - s2 := &dns.Server{Listener: l} s1.NotifyStartedFunc = func() { close(ch1) } s2.NotifyStartedFunc = func() { close(ch2) } go s1.ActivateAndServe() @@ -43,7 +53,7 @@ func NewServer(f dns.HandlerFunc) *Server { <-ch1 <-ch2 - return &Server{s1: s1, s2: s2, Addr: p.LocalAddr().String()} + return &Server{s1: s1, s2: s2, Addr: s2.Listener.Addr().String()} } // Close shuts down the server. diff --git a/vendor/github.com/coredns/coredns/plugin/pkg/dnstest/server_test.go b/vendor/github.com/coredns/coredns/plugin/pkg/dnstest/server_test.go deleted file mode 100644 index 41450e49..00000000 --- a/vendor/github.com/coredns/coredns/plugin/pkg/dnstest/server_test.go +++ /dev/null @@ -1,37 +0,0 @@ -package dnstest - -import ( - "testing" - - "github.com/miekg/dns" -) - -func TestNewServer(t *testing.T) { - s := NewServer(func(w dns.ResponseWriter, r *dns.Msg) { - ret := new(dns.Msg) - ret.SetReply(r) - w.WriteMsg(ret) - }) - defer s.Close() - - c := new(dns.Client) - c.Net = "tcp" - m := new(dns.Msg) - m.SetQuestion("example.org.", dns.TypeSOA) - ret, _, err := c.Exchange(m, s.Addr) - if err != nil { - t.Fatalf("Could not send message to dnstest.Server: %s", err) - } - if ret.Id != m.Id { - t.Fatalf("Msg ID's should match, expected %d, got %d", m.Id, ret.Id) - } - - c.Net = "udp" - ret, _, err = c.Exchange(m, s.Addr) - if err != nil { - t.Fatalf("Could not send message to dnstest.Server: %s", err) - } - if ret.Id != m.Id { - t.Fatalf("Msg ID's should match, expected %d, got %d", m.Id, ret.Id) - } -} diff --git a/vendor/github.com/coredns/coredns/plugin/pkg/dnsutil/cname_test.go b/vendor/github.com/coredns/coredns/plugin/pkg/dnsutil/cname_test.go deleted file mode 100644 index 5fb8d302..00000000 --- a/vendor/github.com/coredns/coredns/plugin/pkg/dnsutil/cname_test.go +++ /dev/null @@ -1,55 +0,0 @@ -package dnsutil - -import ( - "testing" - - "github.com/miekg/dns" -) - -func TestDuplicateCNAME(t *testing.T) { - tests := []struct { - cname string - records []string - expected bool - }{ - { - "1.0.0.192.IN-ADDR.ARPA. 3600 IN CNAME 1.0.0.0.192.IN-ADDR.ARPA.", - []string{ - "US. 86400 IN NSEC 0-.us. NS SOA RRSIG NSEC DNSKEY TYPE65534", - "1.0.0.192.IN-ADDR.ARPA. 3600 IN CNAME 1.0.0.0.192.IN-ADDR.ARPA.", - }, - true, - }, - { - "1.0.0.192.IN-ADDR.ARPA. 3600 IN CNAME 1.0.0.0.192.IN-ADDR.ARPA.", - []string{ - "US. 86400 IN NSEC 0-.us. NS SOA RRSIG NSEC DNSKEY TYPE65534", - }, - false, - }, - { - "1.0.0.192.IN-ADDR.ARPA. 3600 IN CNAME 1.0.0.0.192.IN-ADDR.ARPA.", - []string{}, - false, - }, - } - for i, test := range tests { - cnameRR, err := dns.NewRR(test.cname) - if err != nil { - t.Fatalf("Test %d, cname ('%s') error (%s)!", i, test.cname, err) - } - cname := cnameRR.(*dns.CNAME) - records := []dns.RR{} - for j, r := range test.records { - rr, err := dns.NewRR(r) - if err != nil { - t.Fatalf("Test %d, record %d ('%s') error (%s)!", i, j, r, err) - } - records = append(records, rr) - } - got := DuplicateCNAME(cname, records) - if got != test.expected { - t.Errorf("Test %d, expected '%v', got '%v' for CNAME ('%s') and RECORDS (%v)", i, test.expected, got, test.cname, test.records) - } - } -} diff --git a/vendor/github.com/coredns/coredns/plugin/pkg/dnsutil/host_test.go b/vendor/github.com/coredns/coredns/plugin/pkg/dnsutil/host_test.go deleted file mode 100644 index cc55f457..00000000 --- a/vendor/github.com/coredns/coredns/plugin/pkg/dnsutil/host_test.go +++ /dev/null @@ -1,85 +0,0 @@ -package dnsutil - -import ( - "io/ioutil" - "os" - "testing" -) - -func TestParseHostPortOrFile(t *testing.T) { - tests := []struct { - in string - expected string - shouldErr bool - }{ - { - "8.8.8.8", - "8.8.8.8:53", - false, - }, - { - "8.8.8.8:153", - "8.8.8.8:153", - false, - }, - { - "/etc/resolv.conf:53", - "", - true, - }, - { - "resolv.conf", - "127.0.0.1:53", - false, - }, - } - - err := ioutil.WriteFile("resolv.conf", []byte("nameserver 127.0.0.1\n"), 0600) - if err != nil { - t.Fatalf("Failed to write test resolv.conf") - } - defer os.Remove("resolv.conf") - - for i, tc := range tests { - got, err := ParseHostPortOrFile(tc.in) - if err == nil && tc.shouldErr { - t.Errorf("Test %d, expected error, got nil", i) - continue - } - if err != nil && tc.shouldErr { - continue - } - if got[0] != tc.expected { - t.Errorf("Test %d, expected %q, got %q", i, tc.expected, got[0]) - } - } -} - -func TestParseHostPort(t *testing.T) { - tests := []struct { - in string - expected string - shouldErr bool - }{ - {"8.8.8.8:53", "8.8.8.8:53", false}, - {"a.a.a.a:153", "", true}, - {"8.8.8.8", "8.8.8.8:53", false}, - {"8.8.8.8:", "8.8.8.8:53", false}, - {"8.8.8.8::53", "", true}, - {"resolv.conf", "", true}, - } - - for i, tc := range tests { - got, err := ParseHostPort(tc.in, "53") - if err == nil && tc.shouldErr { - t.Errorf("Test %d, expected error, got nil", i) - continue - } - if err != nil && !tc.shouldErr { - t.Errorf("Test %d, expected no error, got %q", i, err) - } - if got != tc.expected { - t.Errorf("Test %d, expected %q, got %q", i, tc.expected, got) - } - } -} diff --git a/vendor/github.com/coredns/coredns/plugin/pkg/dnsutil/join_test.go b/vendor/github.com/coredns/coredns/plugin/pkg/dnsutil/join_test.go deleted file mode 100644 index 26eeb589..00000000 --- a/vendor/github.com/coredns/coredns/plugin/pkg/dnsutil/join_test.go +++ /dev/null @@ -1,20 +0,0 @@ -package dnsutil - -import "testing" - -func TestJoin(t *testing.T) { - tests := []struct { - in []string - out string - }{ - {[]string{"bla", "bliep", "example", "org"}, "bla.bliep.example.org."}, - {[]string{"example", "."}, "example."}, - {[]string{"."}, "."}, - } - - for i, tc := range tests { - if x := Join(tc.in); x != tc.out { - t.Errorf("Test %d, expected %s, got %s", i, tc.out, x) - } - } -} diff --git a/vendor/github.com/coredns/coredns/plugin/pkg/dnsutil/reverse_test.go b/vendor/github.com/coredns/coredns/plugin/pkg/dnsutil/reverse_test.go deleted file mode 100644 index 3cf2f0c5..00000000 --- a/vendor/github.com/coredns/coredns/plugin/pkg/dnsutil/reverse_test.go +++ /dev/null @@ -1,71 +0,0 @@ -package dnsutil - -import ( - "testing" -) - -func TestExtractAddressFromReverse(t *testing.T) { - tests := []struct { - reverseName string - expectedAddress string - }{ - { - "54.119.58.176.in-addr.arpa.", - "176.58.119.54", - }, - { - ".58.176.in-addr.arpa.", - "", - }, - { - "b.a.9.8.7.6.5.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.8.b.d.0.1.0.0.2.in-addr.arpa.", - "", - }, - { - "b.a.9.8.7.6.5.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.8.b.d.0.1.0.0.2.ip6.arpa.", - "2001:db8::567:89ab", - }, - { - "d.0.1.0.0.2.ip6.arpa.", - "", - }, - { - "54.119.58.176.ip6.arpa.", - "", - }, - { - "NONAME", - "", - }, - { - "", - "", - }, - } - for i, test := range tests { - got := ExtractAddressFromReverse(test.reverseName) - if got != test.expectedAddress { - t.Errorf("Test %d, expected '%s', got '%s'", i, test.expectedAddress, got) - } - } -} - -func TestIsReverse(t *testing.T) { - tests := []struct { - name string - expected int - }{ - {"b.a.9.8.7.6.5.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.8.b.d.0.1.0.0.2.ip6.arpa.", 2}, - {"d.0.1.0.0.2.in-addr.arpa.", 1}, - {"example.com.", 0}, - {"", 0}, - {"in-addr.arpa.example.com.", 0}, - } - for i, tc := range tests { - got := IsReverse(tc.name) - if got != tc.expected { - t.Errorf("Test %d, got %d, expected %d for %s", i, got, tc.expected, tc.name) - } - - } -} diff --git a/vendor/github.com/coredns/coredns/plugin/pkg/dnsutil/ttl.go b/vendor/github.com/coredns/coredns/plugin/pkg/dnsutil/ttl.go new file mode 100644 index 00000000..e969fa8a --- /dev/null +++ b/vendor/github.com/coredns/coredns/plugin/pkg/dnsutil/ttl.go @@ -0,0 +1,72 @@ +package dnsutil + +import ( + "time" + + "github.com/coredns/coredns/plugin/pkg/response" + + "github.com/miekg/dns" +) + +// MinimalTTL scans the message returns the lowest TTL found taking into the response.Type of the message. +func MinimalTTL(m *dns.Msg, mt response.Type) time.Duration { + if mt != response.NoError && mt != response.NameError && mt != response.NoData { + return MinimalDefaultTTL + } + + // No data to examine, return a short ttl as a fail safe. + if len(m.Answer)+len(m.Ns)+len(m.Extra) == 0 { + return MinimalDefaultTTL + } + + minTTL := MaximumDefaulTTL + for _, r := range m.Answer { + switch mt { + case response.NameError, response.NoData: + if r.Header().Rrtype == dns.TypeSOA { + minTTL = time.Duration(r.(*dns.SOA).Minttl) * time.Second + } + case response.NoError, response.Delegation: + if r.Header().Ttl < uint32(minTTL.Seconds()) { + minTTL = time.Duration(r.Header().Ttl) * time.Second + } + } + } + for _, r := range m.Ns { + switch mt { + case response.NameError, response.NoData: + if r.Header().Rrtype == dns.TypeSOA { + minTTL = time.Duration(r.(*dns.SOA).Minttl) * time.Second + } + case response.NoError, response.Delegation: + if r.Header().Ttl < uint32(minTTL.Seconds()) { + minTTL = time.Duration(r.Header().Ttl) * time.Second + } + } + } + + for _, r := range m.Extra { + if r.Header().Rrtype == dns.TypeOPT { + // OPT records use TTL field for extended rcode and flags + continue + } + switch mt { + case response.NameError, response.NoData: + if r.Header().Rrtype == dns.TypeSOA { + minTTL = time.Duration(r.(*dns.SOA).Minttl) * time.Second + } + case response.NoError, response.Delegation: + if r.Header().Ttl < uint32(minTTL.Seconds()) { + minTTL = time.Duration(r.Header().Ttl) * time.Second + } + } + } + return minTTL +} + +const ( + // MinimalDefaultTTL is the absolute lowest TTL we use in CoreDNS. + MinimalDefaultTTL = 5 * time.Second + // MaximumDefaulTTL is the maximum TTL was use on RRsets in CoreDNS. + MaximumDefaulTTL = 1 * time.Hour +) diff --git a/vendor/github.com/coredns/coredns/plugin/pkg/dnsutil/zone_test.go b/vendor/github.com/coredns/coredns/plugin/pkg/dnsutil/zone_test.go deleted file mode 100644 index 81cd1ada..00000000 --- a/vendor/github.com/coredns/coredns/plugin/pkg/dnsutil/zone_test.go +++ /dev/null @@ -1,39 +0,0 @@ -package dnsutil - -import ( - "errors" - "testing" - - "github.com/miekg/dns" -) - -func TestTrimZone(t *testing.T) { - tests := []struct { - qname string - zone string - expected string - err error - }{ - {"a.example.org", "example.org", "a", nil}, - {"a.b.example.org", "example.org", "a.b", nil}, - {"b.", ".", "b", nil}, - {"example.org", "example.org", "", errors.New("should err")}, - {"org", "example.org", "", errors.New("should err")}, - } - - for i, tc := range tests { - got, err := TrimZone(dns.Fqdn(tc.qname), dns.Fqdn(tc.zone)) - if tc.err != nil && err == nil { - t.Errorf("Test %d, expected error got nil", i) - continue - } - if tc.err == nil && err != nil { - t.Errorf("Test %d, expected no error got %v", i, err) - continue - } - if got != tc.expected { - t.Errorf("Test %d, expected %s, got %s", i, tc.expected, got) - continue - } - } -} diff --git a/vendor/github.com/coredns/coredns/plugin/pkg/doh/doh.go b/vendor/github.com/coredns/coredns/plugin/pkg/doh/doh.go new file mode 100644 index 00000000..e0a398e9 --- /dev/null +++ b/vendor/github.com/coredns/coredns/plugin/pkg/doh/doh.go @@ -0,0 +1,119 @@ +package doh + +import ( + "bytes" + "encoding/base64" + "fmt" + "io" + "io/ioutil" + "net/http" + + "github.com/miekg/dns" +) + +// MimeType is the DoH mimetype that should be used. +const MimeType = "application/dns-message" + +// Path is the URL path that should be used. +const Path = "/dns-query" + +// NewRequest returns a new DoH request given a method, URL (without any paths, so exclude /dns-query) and dns.Msg. +func NewRequest(method, url string, m *dns.Msg) (*http.Request, error) { + buf, err := m.Pack() + if err != nil { + return nil, err + } + + switch method { + case http.MethodGet: + b64 := base64.RawURLEncoding.EncodeToString(buf) + + req, err := http.NewRequest(http.MethodGet, "https://"+url+Path+"?dns="+b64, nil) + if err != nil { + return req, err + } + + req.Header.Set("content-type", MimeType) + req.Header.Set("accept", MimeType) + return req, nil + + case http.MethodPost: + req, err := http.NewRequest(http.MethodPost, "https://"+url+Path+"?bla=foo:443", bytes.NewReader(buf)) + if err != nil { + return req, err + } + + req.Header.Set("content-type", MimeType) + req.Header.Set("accept", MimeType) + return req, nil + + default: + return nil, fmt.Errorf("method not allowed: %s", method) + } + +} + +// ResponseToMsg converts a http.Repsonse to a dns message. +func ResponseToMsg(resp *http.Response) (*dns.Msg, error) { + defer resp.Body.Close() + + return toMsg(resp.Body) +} + +// RequestToMsg converts a http.Request to a dns message. +func RequestToMsg(req *http.Request) (*dns.Msg, error) { + switch req.Method { + case http.MethodGet: + return requestToMsgGet(req) + + case http.MethodPost: + return requestToMsgPost(req) + + default: + return nil, fmt.Errorf("method not allowed: %s", req.Method) + } + +} + +// requestToMsgPost extracts the dns message from the request body. +func requestToMsgPost(req *http.Request) (*dns.Msg, error) { + defer req.Body.Close() + return toMsg(req.Body) +} + +// requestToMsgGet extract the dns message from the GET request. +func requestToMsgGet(req *http.Request) (*dns.Msg, error) { + values := req.URL.Query() + b64, ok := values["dns"] + if !ok { + return nil, fmt.Errorf("no 'dns' query parameter found") + } + if len(b64) != 1 { + return nil, fmt.Errorf("multiple 'dns' query values found") + } + return base64ToMsg(b64[0]) +} + +func toMsg(r io.ReadCloser) (*dns.Msg, error) { + buf, err := ioutil.ReadAll(r) + if err != nil { + return nil, err + } + m := new(dns.Msg) + err = m.Unpack(buf) + return m, err +} + +func base64ToMsg(b64 string) (*dns.Msg, error) { + buf, err := b64Enc.DecodeString(b64) + if err != nil { + return nil, err + } + + m := new(dns.Msg) + err = m.Unpack(buf) + + return m, err +} + +var b64Enc = base64.RawURLEncoding diff --git a/vendor/github.com/coredns/coredns/plugin/pkg/edns/edns_test.go b/vendor/github.com/coredns/coredns/plugin/pkg/edns/edns_test.go deleted file mode 100644 index a775b50f..00000000 --- a/vendor/github.com/coredns/coredns/plugin/pkg/edns/edns_test.go +++ /dev/null @@ -1,37 +0,0 @@ -package edns - -import ( - "testing" - - "github.com/miekg/dns" -) - -func TestVersion(t *testing.T) { - m := ednsMsg() - m.Extra[0].(*dns.OPT).SetVersion(2) - - _, err := Version(m) - if err == nil { - t.Errorf("Expected wrong version, but got OK") - } -} - -func TestVersionNoEdns(t *testing.T) { - m := ednsMsg() - m.Extra = nil - - _, err := Version(m) - if err != nil { - t.Errorf("Expected no error, but got one: %s", err) - } -} - -func ednsMsg() *dns.Msg { - m := new(dns.Msg) - m.SetQuestion("example.com.", dns.TypeA) - o := new(dns.OPT) - o.Hdr.Name = "." - o.Hdr.Rrtype = dns.TypeOPT - m.Extra = append(m.Extra, o) - return m -} diff --git a/vendor/github.com/coredns/coredns/plugin/pkg/fall/fall.go b/vendor/github.com/coredns/coredns/plugin/pkg/fall/fall.go deleted file mode 100644 index c8cdc6ff..00000000 --- a/vendor/github.com/coredns/coredns/plugin/pkg/fall/fall.go +++ /dev/null @@ -1,58 +0,0 @@ -// Package fall handles the fallthrough logic used in plugins that support it. -package fall - -import ( - "github.com/coredns/coredns/plugin" -) - -// F can be nil to allow for no fallthrough, empty allow all zones to fallthrough or -// contain a zone list that is checked. -type F struct { - Zones []string -} - -// Through will check if we should fallthrough for qname. Note that we've named the -// variable in each plugin "Fall", so this then reads Fall.Through(). -func (f F) Through(qname string) bool { - return plugin.Zones(f.Zones).Matches(qname) != "" -} - -// setZones will set zones in f. -func (f *F) setZones(zones []string) { - for i := range zones { - zones[i] = plugin.Host(zones[i]).Normalize() - } - f.Zones = zones -} - -// SetZonesFromArgs sets zones in f to the passed value or to "." if the slice is empty. -func (f *F) SetZonesFromArgs(zones []string) { - if len(zones) == 0 { - f.setZones(Root.Zones) - return - } - f.setZones(zones) -} - -// Equal returns true if f and g are equal. -func (f F) Equal(g F) bool { - if len(f.Zones) != len(g.Zones) { - return false - } - for i := range f.Zones { - if f.Zones[i] != g.Zones[i] { - return false - } - } - return true -} - -// Zero returns a zero valued F. -var Zero = func() F { - return F{[]string{}} -}() - -// Root returns F set to only ".". -var Root = func() F { - return F{[]string{"."}} -}() diff --git a/vendor/github.com/coredns/coredns/plugin/pkg/fall/fall_test.go b/vendor/github.com/coredns/coredns/plugin/pkg/fall/fall_test.go deleted file mode 100644 index 26cfbc2d..00000000 --- a/vendor/github.com/coredns/coredns/plugin/pkg/fall/fall_test.go +++ /dev/null @@ -1,65 +0,0 @@ -package fall - -import "testing" - -func TestEqual(t *testing.T) { - var z F - f := F{Zones: []string{"example.com."}} - g := F{Zones: []string{"example.net."}} - h := F{Zones: []string{"example.com."}} - - if !f.Equal(h) { - t.Errorf("%v should equal %v", f, h) - } - - if z.Equal(f) { - t.Errorf("%v should not be equal to %v", z, f) - } - - if f.Equal(g) { - t.Errorf("%v should not be equal to %v", f, g) - } -} - -func TestZero(t *testing.T) { - var f F - if !f.Equal(Zero) { - t.Errorf("F should be zero") - } -} - -func TestSetZonesFromArgs(t *testing.T) { - var f F - f.SetZonesFromArgs([]string{}) - if !f.Equal(Root) { - t.Errorf("F should have the root zone") - } - - f.SetZonesFromArgs([]string{"example.com", "example.net."}) - expected := F{Zones: []string{"example.com.", "example.net."}} - if !f.Equal(expected) { - t.Errorf("F should be %v but is %v", expected, f) - } -} - -func TestFallthrough(t *testing.T) { - var fall F - if fall.Through("foo.com.") { - t.Errorf("Expected false, got true for zero fallthrough") - } - - fall.SetZonesFromArgs([]string{}) - if !fall.Through("foo.net.") { - t.Errorf("Expected true, got false for all zone fallthrough") - } - - fall.SetZonesFromArgs([]string{"foo.com", "bar.com"}) - - if fall.Through("foo.net.") { - t.Errorf("Expected false, got true for non-matching fallthrough zone") - } - - if !fall.Through("bar.com.") { - t.Errorf("Expected true, got false for matching fallthrough zone") - } -} diff --git a/vendor/github.com/coredns/coredns/plugin/pkg/healthcheck/healthcheck.go b/vendor/github.com/coredns/coredns/plugin/pkg/healthcheck/healthcheck.go deleted file mode 100644 index 5a2e229c..00000000 --- a/vendor/github.com/coredns/coredns/plugin/pkg/healthcheck/healthcheck.go +++ /dev/null @@ -1,241 +0,0 @@ -package healthcheck - -import ( - "io" - "io/ioutil" - "net" - "net/http" - "net/url" - "sync" - "sync/atomic" - "time" - - "github.com/coredns/coredns/plugin/pkg/log" -) - -// UpstreamHostDownFunc can be used to customize how Down behaves. -type UpstreamHostDownFunc func(*UpstreamHost) bool - -// UpstreamHost represents a single proxy upstream -type UpstreamHost struct { - Conns int64 // must be first field to be 64-bit aligned on 32-bit systems - Name string // IP address (and port) of this upstream host - Fails int32 - FailTimeout time.Duration - CheckDown UpstreamHostDownFunc - CheckURL string - Checking bool - sync.Mutex -} - -// Down checks whether the upstream host is down or not. -// Down will try to use uh.CheckDown first, and will fall -// back to some default criteria if necessary. -func (uh *UpstreamHost) Down() bool { - if uh.CheckDown == nil { - fails := atomic.LoadInt32(&uh.Fails) - return fails > 0 - } - return uh.CheckDown(uh) -} - -// HostPool is a collection of UpstreamHosts. -type HostPool []*UpstreamHost - -// HealthCheck is used for performing healthcheck -// on a collection of upstream hosts and select -// one based on the policy. -type HealthCheck struct { - wg sync.WaitGroup // Used to wait for running goroutines to stop. - stop chan struct{} // Signals running goroutines to stop. - Hosts HostPool - Policy Policy - Spray Policy - FailTimeout time.Duration - MaxFails int32 - Path string - Port string - Interval time.Duration -} - -// Start starts the healthcheck -func (u *HealthCheck) Start() { - for i, h := range u.Hosts { - u.Hosts[i].CheckURL = u.normalizeCheckURL(h.Name) - } - - u.stop = make(chan struct{}) - if u.Path != "" { - u.wg.Add(1) - go func() { - defer u.wg.Done() - u.healthCheckWorker(u.stop) - }() - } -} - -// Stop sends a signal to all goroutines started by this staticUpstream to exit -// and waits for them to finish before returning. -func (u *HealthCheck) Stop() error { - close(u.stop) - u.wg.Wait() - return nil -} - -// This was moved into a thread so that each host could throw a health -// check at the same time. The reason for this is that if we are checking -// 3 hosts, and the first one is gone, and we spend minutes timing out to -// fail it, we would not have been doing any other health checks in that -// time. So we now have a per-host lock and a threaded health check. -// -// We use the Checking bool to avoid concurrent checks against the same -// host; if one is taking a long time, the next one will find a check in -// progress and simply return before trying. -// -// We are carefully avoiding having the mutex locked while we check, -// otherwise checks will back up, potentially a lot of them if a host is -// absent for a long time. This arrangement makes checks quickly see if -// they are the only one running and abort otherwise. - -// HealthCheckURL performs the http.Get that implements healthcheck. -func (uh *UpstreamHost) HealthCheckURL() { - // Lock for our bool check. We don't just defer the unlock because - // we don't want the lock held while http.Get runs. - uh.Lock() - - // We call HealthCheckURL from proxy.go and lookup.go, bail out when nothing - // is configured to healthcheck. Or we mid check? Don't run another one. - if uh.CheckURL == "" || uh.Checking { // nothing configured - uh.Unlock() - return - } - - uh.Checking = true - uh.Unlock() - - // default timeout (5s) - r, err := healthClient.Get(uh.CheckURL) - - defer func() { - uh.Lock() - uh.Checking = false - uh.Unlock() - }() - - if err != nil { - log.Warningf("Host %s health check probe failed: %v", uh.Name, err) - atomic.AddInt32(&uh.Fails, 1) - return - } - - if err == nil { - io.Copy(ioutil.Discard, r.Body) - r.Body.Close() - - if r.StatusCode < 200 || r.StatusCode >= 400 { - log.Warningf("Host %s health check returned HTTP code %d", uh.Name, r.StatusCode) - atomic.AddInt32(&uh.Fails, 1) - return - } - - // We are healthy again, reset fails. - atomic.StoreInt32(&uh.Fails, 0) - return - } -} - -func (u *HealthCheck) healthCheck() { - for _, host := range u.Hosts { - // locks/bools should prevent requests backing up - go host.HealthCheckURL() - } -} - -func (u *HealthCheck) healthCheckWorker(stop chan struct{}) { - ticker := time.NewTicker(u.Interval) - u.healthCheck() - for { - select { - case <-ticker.C: - u.healthCheck() - case <-stop: - ticker.Stop() - return - } - } -} - -// Select selects an upstream host based on the policy -// and the healthcheck result. -func (u *HealthCheck) Select() *UpstreamHost { - pool := u.Hosts - if len(pool) == 1 { - if pool[0].Down() && u.Spray == nil { - return nil - } - return pool[0] - } - allDown := true - for _, host := range pool { - if !host.Down() { - allDown = false - break - } - } - if allDown { - if u.Spray == nil { - return nil - } - return u.Spray.Select(pool) - } - - if u.Policy == nil { - h := (&Random{}).Select(pool) - if h != nil { - return h - } - if h == nil && u.Spray == nil { - return nil - } - return u.Spray.Select(pool) - } - - h := u.Policy.Select(pool) - if h != nil { - return h - } - - if u.Spray == nil { - return nil - } - return u.Spray.Select(pool) -} - -// normalizeCheckURL creates a proper URL for the health check. -func (u *HealthCheck) normalizeCheckURL(name string) string { - if u.Path == "" { - return "" - } - - // The DNS server might be an HTTP server. If so, extract its name. - hostName := name - ret, err := url.Parse(name) - if err == nil && len(ret.Host) > 0 { - hostName = ret.Host - } - - // Extract the port number from the parsed server name. - checkHostName, checkPort, err := net.SplitHostPort(hostName) - if err != nil { - checkHostName = hostName - } - - if u.Port != "" { - checkPort = u.Port - } - - checkURL := "http://" + net.JoinHostPort(checkHostName, checkPort) + u.Path - return checkURL -} - -var healthClient = func() *http.Client { return &http.Client{Timeout: 5 * time.Second} }() diff --git a/vendor/github.com/coredns/coredns/plugin/pkg/healthcheck/policy.go b/vendor/github.com/coredns/coredns/plugin/pkg/healthcheck/policy.go deleted file mode 100644 index beb95e7d..00000000 --- a/vendor/github.com/coredns/coredns/plugin/pkg/healthcheck/policy.go +++ /dev/null @@ -1,141 +0,0 @@ -package healthcheck - -import ( - "math/rand" - "sync/atomic" - - "github.com/coredns/coredns/plugin/pkg/log" -) - -var ( - // SupportedPolicies is the collection of policies registered - SupportedPolicies = make(map[string]func() Policy) -) - -// RegisterPolicy adds a custom policy to the proxy. -func RegisterPolicy(name string, policy func() Policy) { - SupportedPolicies[name] = policy -} - -// Policy decides how a host will be selected from a pool. When all hosts are unhealthy, it is assumed the -// healthchecking failed. In this case each policy will *randomly* return a host from the pool to prevent -// no traffic to go through at all. -type Policy interface { - Select(pool HostPool) *UpstreamHost -} - -func init() { - RegisterPolicy("random", func() Policy { return &Random{} }) - RegisterPolicy("least_conn", func() Policy { return &LeastConn{} }) - RegisterPolicy("round_robin", func() Policy { return &RoundRobin{} }) - RegisterPolicy("first", func() Policy { return &First{} }) - // 'sequential' is an alias to 'first' to maintain consistency with the forward plugin - // should probably remove 'first' in a future release - RegisterPolicy("sequential", func() Policy { return &First{} }) -} - -// Random is a policy that selects up hosts from a pool at random. -type Random struct{} - -// Select selects an up host at random from the specified pool. -func (r *Random) Select(pool HostPool) *UpstreamHost { - // instead of just generating a random index - // this is done to prevent selecting a down host - var randHost *UpstreamHost - count := 0 - for _, host := range pool { - if host.Down() { - continue - } - count++ - if count == 1 { - randHost = host - } else { - r := rand.Int() % count - if r == (count - 1) { - randHost = host - } - } - } - return randHost -} - -// Spray is a policy that selects a host from a pool at random. This should be used as a last ditch -// attempt to get a host when all hosts are reporting unhealthy. -type Spray struct{} - -// Select selects an up host at random from the specified pool. -func (r *Spray) Select(pool HostPool) *UpstreamHost { - rnd := rand.Int() % len(pool) - randHost := pool[rnd] - log.Warningf("All hosts reported as down, spraying to target: %s", randHost.Name) - return randHost -} - -// LeastConn is a policy that selects the host with the least connections. -type LeastConn struct{} - -// Select selects the up host with the least number of connections in the -// pool. If more than one host has the same least number of connections, -// one of the hosts is chosen at random. -func (r *LeastConn) Select(pool HostPool) *UpstreamHost { - var bestHost *UpstreamHost - count := 0 - leastConn := int64(1<<63 - 1) - for _, host := range pool { - if host.Down() { - continue - } - hostConns := host.Conns - if hostConns < leastConn { - bestHost = host - leastConn = hostConns - count = 1 - } else if hostConns == leastConn { - // randomly select host among hosts with least connections - count++ - if count == 1 { - bestHost = host - } else { - r := rand.Int() % count - if r == (count - 1) { - bestHost = host - } - } - } - } - return bestHost -} - -// RoundRobin is a policy that selects hosts based on round robin ordering. -type RoundRobin struct { - Robin uint32 -} - -// Select selects an up host from the pool using a round robin ordering scheme. -func (r *RoundRobin) Select(pool HostPool) *UpstreamHost { - poolLen := uint32(len(pool)) - selection := atomic.AddUint32(&r.Robin, 1) % poolLen - host := pool[selection] - // if the currently selected host is down, just ffwd to up host - for i := uint32(1); host.Down() && i < poolLen; i++ { - host = pool[(selection+i)%poolLen] - } - return host -} - -// First is a policy that selects always the first healthy host in the list order. -type First struct{} - -// Select always the first that is not Down. -func (r *First) Select(pool HostPool) *UpstreamHost { - for i := 0; i < len(pool); i++ { - host := pool[i] - if host.Down() { - continue - } - return host - } - // return the first one, anyway none is correct - return nil -} diff --git a/vendor/github.com/coredns/coredns/plugin/pkg/healthcheck/policy_test.go b/vendor/github.com/coredns/coredns/plugin/pkg/healthcheck/policy_test.go deleted file mode 100644 index a9b2dc51..00000000 --- a/vendor/github.com/coredns/coredns/plugin/pkg/healthcheck/policy_test.go +++ /dev/null @@ -1,155 +0,0 @@ -package healthcheck - -import ( - "net/http" - "net/http/httptest" - "os" - "testing" - "time" -) - -var workableServer *httptest.Server - -func TestMain(m *testing.M) { - workableServer = httptest.NewServer(http.HandlerFunc( - func(w http.ResponseWriter, r *http.Request) { - // do nothing - })) - r := m.Run() - workableServer.Close() - os.Exit(r) -} - -type customPolicy struct{} - -func (r *customPolicy) Select(pool HostPool) *UpstreamHost { - return pool[0] -} - -func testPool() HostPool { - pool := []*UpstreamHost{ - {Name: workableServer.URL}, // this should resolve (healthcheck test) - {Name: "http://shouldnot.resolve:85"}, // this shouldn't, especially on port other than 80 - {Name: "http://C"}, - } - return HostPool(pool) -} - -func TestRegisterPolicy(t *testing.T) { - name := "custom" - customPolicy := &customPolicy{} - RegisterPolicy(name, func() Policy { return customPolicy }) - if _, ok := SupportedPolicies[name]; !ok { - t.Error("Expected supportedPolicies to have a custom policy.") - } - -} - -func TestHealthCheck(t *testing.T) { - u := &HealthCheck{ - Hosts: testPool(), - Path: "/", - FailTimeout: 10 * time.Second, - MaxFails: 1, - } - - for i, h := range u.Hosts { - u.Hosts[i].CheckURL = u.normalizeCheckURL(h.Name) - } - - u.healthCheck() - time.Sleep(time.Duration(1 * time.Second)) // sleep a bit, it's async now - - if u.Hosts[0].Down() { - t.Error("Expected first host in testpool to not fail healthcheck.") - } - if !u.Hosts[1].Down() { - t.Error("Expected second host in testpool to fail healthcheck.") - } -} - -func TestHealthCheckDisabled(t *testing.T) { - u := &HealthCheck{ - Hosts: testPool(), - FailTimeout: 10 * time.Second, - MaxFails: 1, - } - - for i, h := range u.Hosts { - u.Hosts[i].CheckURL = u.normalizeCheckURL(h.Name) - } - - u.healthCheck() - time.Sleep(time.Duration(1 * time.Second)) // sleep a bit, it's async now - - for i, h := range u.Hosts { - if h.Down() { - t.Errorf("Expected host %d in testpool to not be down with healthchecks disabled.", i+1) - } - } -} - -func TestRoundRobinPolicy(t *testing.T) { - pool := testPool() - rrPolicy := &RoundRobin{} - h := rrPolicy.Select(pool) - // First selected host is 1, because counter starts at 0 - // and increments before host is selected - if h != pool[1] { - t.Error("Expected first round robin host to be second host in the pool.") - } - h = rrPolicy.Select(pool) - if h != pool[2] { - t.Error("Expected second round robin host to be third host in the pool.") - } - h = rrPolicy.Select(pool) - if h != pool[0] { - t.Error("Expected third round robin host to be first host in the pool.") - } -} - -func TestLeastConnPolicy(t *testing.T) { - pool := testPool() - lcPolicy := &LeastConn{} - pool[0].Conns = 10 - pool[1].Conns = 10 - h := lcPolicy.Select(pool) - if h != pool[2] { - t.Error("Expected least connection host to be third host.") - } - pool[2].Conns = 100 - h = lcPolicy.Select(pool) - if h != pool[0] && h != pool[1] { - t.Error("Expected least connection host to be first or second host.") - } -} - -func TestCustomPolicy(t *testing.T) { - pool := testPool() - customPolicy := &customPolicy{} - h := customPolicy.Select(pool) - if h != pool[0] { - t.Error("Expected custom policy host to be the first host.") - } -} - -func TestFirstPolicy(t *testing.T) { - pool := testPool() - rrPolicy := &First{} - h := rrPolicy.Select(pool) - // First selected host is 1, because counter starts at 0 - // and increments before host is selected - if h != pool[0] { - t.Error("Expected always first to be first host in the pool.") - } - h = rrPolicy.Select(pool) - if h != pool[0] { - t.Error("Expected always first to be first host in the pool, even in second call") - } - // set this first in pool as failed - pool[0].Fails = 1 - h = rrPolicy.Select(pool) - if h != pool[1] { - t.Error("Expected first to be he second in pool if the first one is down.") - } -} diff --git a/vendor/github.com/coredns/coredns/plugin/pkg/log/log.go b/vendor/github.com/coredns/coredns/plugin/pkg/log/log.go index 6594f593..f05dce03 100644 --- a/vendor/github.com/coredns/coredns/plugin/pkg/log/log.go +++ b/vendor/github.com/coredns/coredns/plugin/pkg/log/log.go @@ -10,10 +10,12 @@ package log import ( "fmt" + "io/ioutil" golog "log" + "os" ) -// D controls whether we should ouput debug logs. If true, we do. +// D controls whether we should output debug logs. If true, we do. var D bool // logf calls log.Printf prefixed with level. @@ -61,9 +63,21 @@ func Error(v ...interface{}) { log(err, v...) } // Errorf is equivalent to log.Printf, but prefixed with "[ERROR] ". func Errorf(format string, v ...interface{}) { logf(err, format, v...) } +// Fatal is equivalent to log.Print, but prefixed with "[FATAL] ", and calling +// os.Exit(1). +func Fatal(v ...interface{}) { log(fatal, v...); os.Exit(1) } + +// Fatalf is equivalent to log.Printf, but prefixed with "[FATAL] ", and calling +// os.Exit(1) +func Fatalf(format string, v ...interface{}) { logf(fatal, format, v...); os.Exit(1) } + +// Discard sets the log output to /dev/null. +func Discard() { golog.SetOutput(ioutil.Discard) } + const ( debug = "[DEBUG] " err = "[ERROR] " - warning = "[WARNING] " + fatal = "[FATAL] " info = "[INFO] " + warning = "[WARNING] " ) diff --git a/vendor/github.com/coredns/coredns/plugin/pkg/log/log_test.go b/vendor/github.com/coredns/coredns/plugin/pkg/log/log_test.go deleted file mode 100644 index c9ead760..00000000 --- a/vendor/github.com/coredns/coredns/plugin/pkg/log/log_test.go +++ /dev/null @@ -1,61 +0,0 @@ -package log - -import ( - "bytes" - golog "log" - "strings" - "testing" -) - -func TestDebug(t *testing.T) { - var f bytes.Buffer - golog.SetOutput(&f) - - // D == false - Debug("debug") - if x := f.String(); x != "" { - t.Errorf("Expected no debug logs, got %s", x) - } - - D = true - Debug("debug") - if x := f.String(); !strings.Contains(x, debug+"debug") { - t.Errorf("Expected debug log to be %s, got %s", debug+"debug", x) - } -} - -func TestDebugx(t *testing.T) { - var f bytes.Buffer - golog.SetOutput(&f) - - D = true - - Debugf("%s", "debug") - if x := f.String(); !strings.Contains(x, debug+"debug") { - t.Errorf("Expected debug log to be %s, got %s", debug+"debug", x) - } - - Debug("debug") - if x := f.String(); !strings.Contains(x, debug+"debug") { - t.Errorf("Expected debug log to be %s, got %s", debug+"debug", x) - } -} - -func TestLevels(t *testing.T) { - var f bytes.Buffer - const ts = "test" - golog.SetOutput(&f) - - Info(ts) - if x := f.String(); !strings.Contains(x, info+ts) { - t.Errorf("Expected log to be %s, got %s", info+ts, x) - } - Warning(ts) - if x := f.String(); !strings.Contains(x, warning+ts) { - t.Errorf("Expected log to be %s, got %s", warning+ts, x) - } - Error(ts) - if x := f.String(); !strings.Contains(x, err+ts) { - t.Errorf("Expected log to be %s, got %s", err+ts, x) - } -} diff --git a/vendor/github.com/coredns/coredns/plugin/pkg/log/plugin.go b/vendor/github.com/coredns/coredns/plugin/pkg/log/plugin.go index 354c19d3..1df30260 100644 --- a/vendor/github.com/coredns/coredns/plugin/pkg/log/plugin.go +++ b/vendor/github.com/coredns/coredns/plugin/pkg/log/plugin.go @@ -3,6 +3,7 @@ package log import ( "fmt" golog "log" + "os" ) // P is a logger that includes the plugin doing the logging. @@ -58,4 +59,10 @@ func (p P) Error(v ...interface{}) { p.log(err, v...) } // Errorf logs as log.Errorf. func (p P) Errorf(format string, v ...interface{}) { p.logf(err, format, v...) } +// Fatal logs as log.Fatal and calls os.Exit(1). +func (p P) Fatal(v ...interface{}) { p.log(fatal, v...); os.Exit(1) } + +// Fatalf logs as log.Fatalf and calls os.Exit(1). +func (p P) Fatalf(format string, v ...interface{}) { p.logf(fatal, format, v...); os.Exit(1) } + func pFormat(s string) string { return "plugin/" + s + ": " } diff --git a/vendor/github.com/coredns/coredns/plugin/pkg/log/plugin_test.go b/vendor/github.com/coredns/coredns/plugin/pkg/log/plugin_test.go deleted file mode 100644 index b24caa48..00000000 --- a/vendor/github.com/coredns/coredns/plugin/pkg/log/plugin_test.go +++ /dev/null @@ -1,21 +0,0 @@ -package log - -import ( - "bytes" - golog "log" - "strings" - "testing" -) - -func TestPlugins(t *testing.T) { - var f bytes.Buffer - const ts = "test" - golog.SetOutput(&f) - - lg := NewWithPlugin("testplugin") - - lg.Info(ts) - if x := f.String(); !strings.Contains(x, "plugin/testplugin") { - t.Errorf("Expected log to be %s, got %s", info+ts, x) - } -} diff --git a/vendor/github.com/coredns/coredns/plugin/pkg/nonwriter/nonwriter_test.go b/vendor/github.com/coredns/coredns/plugin/pkg/nonwriter/nonwriter_test.go deleted file mode 100644 index d8433af5..00000000 --- a/vendor/github.com/coredns/coredns/plugin/pkg/nonwriter/nonwriter_test.go +++ /dev/null @@ -1,19 +0,0 @@ -package nonwriter - -import ( - "testing" - - "github.com/miekg/dns" -) - -func TestNonWriter(t *testing.T) { - nw := New(nil) - m := new(dns.Msg) - m.SetQuestion("example.org.", dns.TypeA) - if err := nw.WriteMsg(m); err != nil { - t.Errorf("Got error when writing to nonwriter: %s", err) - } - if x := nw.Msg.Question[0].Name; x != "example.org." { - t.Errorf("Expacted 'example.org.' got %q:", x) - } -} diff --git a/vendor/github.com/coredns/coredns/plugin/pkg/parse/parse.go b/vendor/github.com/coredns/coredns/plugin/pkg/parse/parse.go deleted file mode 100644 index 17d2641e..00000000 --- a/vendor/github.com/coredns/coredns/plugin/pkg/parse/parse.go +++ /dev/null @@ -1,48 +0,0 @@ -// Package parse contains functions that can be used in the setup code for plugins. -package parse - -import ( - "fmt" - - "github.com/coredns/coredns/plugin/pkg/dnsutil" - "github.com/mholt/caddy" -) - -// Transfer parses transfer statements: 'transfer [to|from] [address...]'. -func Transfer(c *caddy.Controller, secondary bool) (tos, froms []string, err error) { - if !c.NextArg() { - return nil, nil, c.ArgErr() - } - value := c.Val() - switch value { - case "to": - tos = c.RemainingArgs() - for i := range tos { - if tos[i] != "*" { - normalized, err := dnsutil.ParseHostPort(tos[i], "53") - if err != nil { - return nil, nil, err - } - tos[i] = normalized - } - } - - case "from": - if !secondary { - return nil, nil, fmt.Errorf("can't use `transfer from` when not being a secondary") - } - froms = c.RemainingArgs() - for i := range froms { - if froms[i] != "*" { - normalized, err := dnsutil.ParseHostPort(froms[i], "53") - if err != nil { - return nil, nil, err - } - froms[i] = normalized - } else { - return nil, nil, fmt.Errorf("can't use '*' in transfer from") - } - } - } - return -} diff --git a/vendor/github.com/coredns/coredns/plugin/pkg/parse/parse_test.go b/vendor/github.com/coredns/coredns/plugin/pkg/parse/parse_test.go deleted file mode 100644 index b1aa3730..00000000 --- a/vendor/github.com/coredns/coredns/plugin/pkg/parse/parse_test.go +++ /dev/null @@ -1,92 +0,0 @@ -package parse - -import ( - "testing" - - "github.com/mholt/caddy" -) - -func TestTransfer(t *testing.T) { - tests := []struct { - inputFileRules string - shouldErr bool - secondary bool - expectedTo []string - expectedFrom []string - }{ - // OK transfer to - { - `to 127.0.0.1`, - false, false, []string{"127.0.0.1:53"}, []string{}, - }, - // OK transfer tos - { - `to 127.0.0.1 127.0.0.2`, - false, false, []string{"127.0.0.1:53", "127.0.0.2:53"}, []string{}, - }, - // OK transfer from - { - `from 127.0.0.1`, - false, true, []string{}, []string{"127.0.0.1:53"}, - }, - // OK transfer froms - { - `from 127.0.0.1 127.0.0.2`, - false, true, []string{}, []string{"127.0.0.1:53", "127.0.0.2:53"}, - }, - // OK transfer tos/froms - { - `to 127.0.0.1 127.0.0.2 - from 127.0.0.1 127.0.0.2`, - false, true, []string{"127.0.0.1:53", "127.0.0.2:53"}, []string{"127.0.0.1:53", "127.0.0.2:53"}, - }, - // Bad transfer from, secondary false - { - `from 127.0.0.1`, - true, false, []string{}, []string{}, - }, - // Bad transfer from garbage - { - `from !@#$%^&*()`, - true, true, []string{}, []string{}, - }, - // Bad transfer from no args - { - `from`, - true, false, []string{}, []string{}, - }, - // Bad transfer from * - { - `from *`, - true, true, []string{}, []string{}, - }, - } - - for i, test := range tests { - c := caddy.NewTestController("dns", test.inputFileRules) - tos, froms, err := Transfer(c, test.secondary) - - if err == nil && test.shouldErr { - t.Fatalf("Test %d expected errors, but got no error %+v %+v", i, err, test) - } else if err != nil && !test.shouldErr { - t.Fatalf("Test %d expected no errors, but got '%v'", i, err) - } - - if test.expectedTo != nil { - for j, got := range tos { - if got != test.expectedTo[j] { - t.Fatalf("Test %d expected %v, got %v", i, test.expectedTo[j], got) - } - } - } - if test.expectedFrom != nil { - for j, got := range froms { - if got != test.expectedFrom[j] { - t.Fatalf("Test %d expected %v, got %v", i, test.expectedFrom[j], got) - } - } - } - - } - -} diff --git a/vendor/github.com/coredns/coredns/plugin/pkg/rcode/rcode_test.go b/vendor/github.com/coredns/coredns/plugin/pkg/rcode/rcode_test.go deleted file mode 100644 index bfca32f1..00000000 --- a/vendor/github.com/coredns/coredns/plugin/pkg/rcode/rcode_test.go +++ /dev/null @@ -1,29 +0,0 @@ -package rcode - -import ( - "testing" - - "github.com/miekg/dns" -) - -func TestToString(t *testing.T) { - tests := []struct { - in int - expected string - }{ - { - dns.RcodeSuccess, - "NOERROR", - }, - { - 28, - "RCODE28", - }, - } - for i, test := range tests { - got := ToString(test.in) - if got != test.expected { - t.Errorf("Test %d, expected %s, got %s", i, test.expected, got) - } - } -} diff --git a/vendor/github.com/coredns/coredns/plugin/pkg/replacer/replacer.go b/vendor/github.com/coredns/coredns/plugin/pkg/replacer/replacer.go deleted file mode 100644 index b9e1fcaa..00000000 --- a/vendor/github.com/coredns/coredns/plugin/pkg/replacer/replacer.go +++ /dev/null @@ -1,169 +0,0 @@ -package replacer - -import ( - "strconv" - "strings" - "time" - - "github.com/coredns/coredns/plugin/pkg/dnstest" - "github.com/coredns/coredns/request" - - "github.com/miekg/dns" -) - -// Replacer is a type which can replace placeholder -// substrings in a string with actual values from a -// dns.Msg and responseRecorder. Always use -// NewReplacer to get one of these. -type Replacer interface { - Replace(string) string - Set(key, value string) -} - -type replacer struct { - replacements map[string]string - emptyValue string -} - -// New makes a new replacer based on r and rr. -// Do not create a new replacer until r and rr have all -// the needed values, because this function copies those -// values into the replacer. rr may be nil if it is not -// available. emptyValue should be the string that is used -// in place of empty string (can still be empty string). -func New(r *dns.Msg, rr *dnstest.Recorder, emptyValue string) Replacer { - req := request.Request{W: rr, Req: r} - rep := replacer{ - replacements: map[string]string{ - "{type}": req.Type(), - "{name}": req.Name(), - "{class}": req.Class(), - "{proto}": req.Proto(), - "{when}": func() string { - return time.Now().Format(timeFormat) - }(), - "{size}": strconv.Itoa(req.Len()), - "{remote}": addrToRFC3986(req.IP()), - "{port}": req.Port(), - }, - emptyValue: emptyValue, - } - if rr != nil { - rcode := dns.RcodeToString[rr.Rcode] - if rcode == "" { - rcode = strconv.Itoa(rr.Rcode) - } - rep.replacements["{rcode}"] = rcode - rep.replacements["{rsize}"] = strconv.Itoa(rr.Len) - rep.replacements["{duration}"] = strconv.FormatFloat(time.Since(rr.Start).Seconds(), 'f', -1, 64) + "s" - if rr.Msg != nil { - rep.replacements[headerReplacer+"rflags}"] = flagsToString(rr.Msg.MsgHdr) - } - } - - // Header placeholders (case-insensitive) - rep.replacements[headerReplacer+"id}"] = strconv.Itoa(int(r.Id)) - rep.replacements[headerReplacer+"opcode}"] = strconv.Itoa(r.Opcode) - rep.replacements[headerReplacer+"do}"] = boolToString(req.Do()) - rep.replacements[headerReplacer+"bufsize}"] = strconv.Itoa(req.Size()) - - return rep -} - -// Replace performs a replacement of values on s and returns -// the string with the replaced values. -func (r replacer) Replace(s string) string { - // Header replacements - these are case-insensitive, so we can't just use strings.Replace() - for strings.Contains(s, headerReplacer) { - idxStart := strings.Index(s, headerReplacer) - endOffset := idxStart + len(headerReplacer) - idxEnd := strings.Index(s[endOffset:], "}") - if idxEnd > -1 { - placeholder := strings.ToLower(s[idxStart : endOffset+idxEnd+1]) - replacement := r.replacements[placeholder] - if replacement == "" { - replacement = r.emptyValue - } - s = s[:idxStart] + replacement + s[endOffset+idxEnd+1:] - } else { - break - } - } - - // Regular replacements - these are easier because they're case-sensitive - for placeholder, replacement := range r.replacements { - if replacement == "" { - replacement = r.emptyValue - } - s = strings.Replace(s, placeholder, replacement, -1) - } - - return s -} - -// Set sets key to value in the replacements map. -func (r replacer) Set(key, value string) { - r.replacements["{"+key+"}"] = value -} - -func boolToString(b bool) string { - if b { - return "true" - } - return "false" -} - -// flagsToString checks all header flags and returns those -// that are set as a string separated with commas -func flagsToString(h dns.MsgHdr) string { - flags := make([]string, 7) - i := 0 - - if h.Response { - flags[i] = "qr" - i++ - } - - if h.Authoritative { - flags[i] = "aa" - i++ - } - if h.Truncated { - flags[i] = "tc" - i++ - } - if h.RecursionDesired { - flags[i] = "rd" - i++ - } - if h.RecursionAvailable { - flags[i] = "ra" - i++ - } - if h.Zero { - flags[i] = "z" - i++ - } - if h.AuthenticatedData { - flags[i] = "ad" - i++ - } - if h.CheckingDisabled { - flags[i] = "cd" - i++ - } - return strings.Join(flags[:i], ",") -} - -// addrToRFC3986 will add brackets to the address if it is an IPv6 address. -func addrToRFC3986(addr string) string { - if strings.Contains(addr, ":") { - return "[" + addr + "]" - } - return addr -} - -const ( - timeFormat = "02/Jan/2006:15:04:05 -0700" - headerReplacer = "{>" -) diff --git a/vendor/github.com/coredns/coredns/plugin/pkg/replacer/replacer_test.go b/vendor/github.com/coredns/coredns/plugin/pkg/replacer/replacer_test.go deleted file mode 100644 index 2fcaafc9..00000000 --- a/vendor/github.com/coredns/coredns/plugin/pkg/replacer/replacer_test.go +++ /dev/null @@ -1,65 +0,0 @@ -package replacer - -import ( - "strings" - "testing" - - "github.com/coredns/coredns/plugin/pkg/dnstest" - "github.com/coredns/coredns/plugin/test" - - "github.com/miekg/dns" -) - -func TestNewReplacer(t *testing.T) { - w := dnstest.NewRecorder(&test.ResponseWriter{}) - - r := new(dns.Msg) - r.SetQuestion("example.org.", dns.TypeHINFO) - r.MsgHdr.AuthenticatedData = true - - replaceValues := New(r, w, "") - - switch v := replaceValues.(type) { - case replacer: - - if v.replacements["{type}"] != "HINFO" { - t.Errorf("Expected type to be HINFO, got %q", v.replacements["{type}"]) - } - if v.replacements["{name}"] != "example.org." { - t.Errorf("Expected request name to be example.org., got %q", v.replacements["{name}"]) - } - if v.replacements["{size}"] != "29" { // size of request - t.Errorf("Expected size to be 29, got %q", v.replacements["{size}"]) - } - if !strings.Contains(v.replacements["{duration}"], "s") { - t.Errorf("Expected units of time to be in seconds") - } - - default: - t.Fatal("Return Value from New Replacer expected pass type assertion into a replacer type\n") - } -} - -func TestSet(t *testing.T) { - w := dnstest.NewRecorder(&test.ResponseWriter{}) - - r := new(dns.Msg) - r.SetQuestion("example.org.", dns.TypeHINFO) - r.MsgHdr.AuthenticatedData = true - - repl := New(r, w, "") - - repl.Set("name", "coredns.io.") - repl.Set("type", "A") - repl.Set("size", "20") - - if repl.Replace("This name is {name}") != "This name is coredns.io." { - t.Error("Expected name replacement failed") - } - if repl.Replace("This type is {type}") != "This type is A" { - t.Error("Expected type replacement failed") - } - if repl.Replace("The request size is {size}") != "The request size is 20" { - t.Error("Expected size replacement failed") - } -} diff --git a/vendor/github.com/coredns/coredns/plugin/pkg/response/typify_test.go b/vendor/github.com/coredns/coredns/plugin/pkg/response/typify_test.go deleted file mode 100644 index 6be9aa8f..00000000 --- a/vendor/github.com/coredns/coredns/plugin/pkg/response/typify_test.go +++ /dev/null @@ -1,84 +0,0 @@ -package response - -import ( - "testing" - "time" - - "github.com/coredns/coredns/plugin/test" - - "github.com/miekg/dns" -) - -func TestTypifyNilMsg(t *testing.T) { - var m *dns.Msg - - ty, _ := Typify(m, time.Now().UTC()) - if ty != OtherError { - t.Errorf("Message wrongly typified, expected OtherError, got %s", ty) - } -} - -func TestTypifyDelegation(t *testing.T) { - m := delegationMsg() - mt, _ := Typify(m, time.Now().UTC()) - if mt != Delegation { - t.Errorf("Message is wrongly typified, expected Delegation, got %s", mt) - } -} - -func TestTypifyRRSIG(t *testing.T) { - now, _ := time.Parse(time.UnixDate, "Fri Apr 21 10:51:21 BST 2017") - utc := now.UTC() - - m := delegationMsgRRSIGOK() - if mt, _ := Typify(m, utc); mt != Delegation { - t.Errorf("Message is wrongly typified, expected Delegation, got %s", mt) - } - - // Still a Delegation because EDNS0 OPT DO bool is not set, so we won't check the sigs. - m = delegationMsgRRSIGFail() - if mt, _ := Typify(m, utc); mt != Delegation { - t.Errorf("Message is wrongly typified, expected Delegation, got %s", mt) - } - - m = delegationMsgRRSIGFail() - m = addOpt(m) - if mt, _ := Typify(m, utc); mt != OtherError { - t.Errorf("Message is wrongly typified, expected OtherError, got %s", mt) - } -} - -func delegationMsg() *dns.Msg { - return &dns.Msg{ - Ns: []dns.RR{ - test.NS("miek.nl. 3600 IN NS linode.atoom.net."), - test.NS("miek.nl. 3600 IN NS ns-ext.nlnetlabs.nl."), - test.NS("miek.nl. 3600 IN NS omval.tednet.nl."), - }, - Extra: []dns.RR{ - test.A("omval.tednet.nl. 3600 IN A 185.49.141.42"), - test.AAAA("omval.tednet.nl. 3600 IN AAAA 2a04:b900:0:100::42"), - }, - } -} - -func delegationMsgRRSIGOK() *dns.Msg { - del := delegationMsg() - del.Ns = append(del.Ns, - test.RRSIG("miek.nl. 1800 IN RRSIG NS 8 2 1800 20170521031301 20170421031301 12051 miek.nl. PIUu3TKX/sB/N1n1E1yWxHHIcPnc2q6Wq9InShk+5ptRqChqKdZNMLDm gCq+1bQAZ7jGvn2PbwTwE65JzES7T+hEiqR5PU23DsidvZyClbZ9l0xG JtKwgzGXLtUHxp4xv/Plq+rq/7pOG61bNCxRyS7WS7i7QcCCWT1BCcv+ wZ0="), - ) - return del -} - -func delegationMsgRRSIGFail() *dns.Msg { - del := delegationMsg() - del.Ns = append(del.Ns, - test.RRSIG("miek.nl. 1800 IN RRSIG NS 8 2 1800 20160521031301 20160421031301 12051 miek.nl. PIUu3TKX/sB/N1n1E1yWxHHIcPnc2q6Wq9InShk+5ptRqChqKdZNMLDm gCq+1bQAZ7jGvn2PbwTwE65JzES7T+hEiqR5PU23DsidvZyClbZ9l0xG JtKwgzGXLtUHxp4xv/Plq+rq/7pOG61bNCxRyS7WS7i7QcCCWT1BCcv+ wZ0="), - ) - return del -} - -func addOpt(m *dns.Msg) *dns.Msg { - m.Extra = append(m.Extra, test.OPT(4096, true)) - return m -} diff --git a/vendor/github.com/coredns/coredns/plugin/pkg/singleflight/singleflight.go b/vendor/github.com/coredns/coredns/plugin/pkg/singleflight/singleflight.go deleted file mode 100644 index 365e3ef5..00000000 --- a/vendor/github.com/coredns/coredns/plugin/pkg/singleflight/singleflight.go +++ /dev/null @@ -1,64 +0,0 @@ -/* -Copyright 2012 Google Inc. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// Package singleflight provides a duplicate function call suppression -// mechanism. -package singleflight - -import "sync" - -// call is an in-flight or completed Do call -type call struct { - wg sync.WaitGroup - val interface{} - err error -} - -// Group represents a class of work and forms a namespace in which -// units of work can be executed with duplicate suppression. -type Group struct { - mu sync.Mutex // protects m - m map[uint32]*call // lazily initialized -} - -// Do executes and returns the results of the given function, making -// sure that only one execution is in-flight for a given key at a -// time. If a duplicate comes in, the duplicate caller waits for the -// original to complete and receives the same results. -func (g *Group) Do(key uint32, fn func() (interface{}, error)) (interface{}, error) { - g.mu.Lock() - if g.m == nil { - g.m = make(map[uint32]*call) - } - if c, ok := g.m[key]; ok { - g.mu.Unlock() - c.wg.Wait() - return c.val, c.err - } - c := new(call) - c.wg.Add(1) - g.m[key] = c - g.mu.Unlock() - - c.val, c.err = fn() - c.wg.Done() - - g.mu.Lock() - delete(g.m, key) - g.mu.Unlock() - - return c.val, c.err -} diff --git a/vendor/github.com/coredns/coredns/plugin/pkg/singleflight/singleflight_test.go b/vendor/github.com/coredns/coredns/plugin/pkg/singleflight/singleflight_test.go deleted file mode 100644 index a32e046d..00000000 --- a/vendor/github.com/coredns/coredns/plugin/pkg/singleflight/singleflight_test.go +++ /dev/null @@ -1,85 +0,0 @@ -/* -Copyright 2012 Google Inc. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package singleflight - -import ( - "errors" - "fmt" - "sync" - "sync/atomic" - "testing" - "time" -) - -func TestDo(t *testing.T) { - var g Group - v, err := g.Do(1, func() (interface{}, error) { - return "bar", nil - }) - if got, want := fmt.Sprintf("%v (%T)", v, v), "bar (string)"; got != want { - t.Errorf("Do = %v; want %v", got, want) - } - if err != nil { - t.Errorf("Do error = %v", err) - } -} - -func TestDoErr(t *testing.T) { - var g Group - someErr := errors.New("Some error") - v, err := g.Do(1, func() (interface{}, error) { - return nil, someErr - }) - if err != someErr { - t.Errorf("Do error = %v; want someErr", err) - } - if v != nil { - t.Errorf("Unexpected non-nil value %#v", v) - } -} - -func TestDoDupSuppress(t *testing.T) { - var g Group - c := make(chan string) - var calls int32 - fn := func() (interface{}, error) { - atomic.AddInt32(&calls, 1) - return <-c, nil - } - - const n = 10 - var wg sync.WaitGroup - for i := 0; i < n; i++ { - wg.Add(1) - go func() { - v, err := g.Do(1, fn) - if err != nil { - t.Errorf("Do error: %v", err) - } - if v.(string) != "bar" { - t.Errorf("Got %q; want %q", v, "bar") - } - wg.Done() - }() - } - time.Sleep(100 * time.Millisecond) // let goroutines above block - c <- "bar" - wg.Wait() - if got := atomic.LoadInt32(&calls); got != 1 { - t.Errorf("Number of calls = %d; want 1", got) - } -} diff --git a/vendor/github.com/coredns/coredns/plugin/pkg/tls/tls.go b/vendor/github.com/coredns/coredns/plugin/pkg/tls/tls.go deleted file mode 100644 index 6fc10dd8..00000000 --- a/vendor/github.com/coredns/coredns/plugin/pkg/tls/tls.go +++ /dev/null @@ -1,128 +0,0 @@ -package tls - -import ( - "crypto/tls" - "crypto/x509" - "fmt" - "io/ioutil" - "net" - "net/http" - "time" -) - -// NewTLSConfigFromArgs returns a TLS config based upon the passed -// in list of arguments. Typically these come straight from the -// Corefile. -// no args -// - creates a Config with no cert and using system CAs -// - use for a client that talks to a server with a public signed cert (CA installed in system) -// - the client will not be authenticated by the server since there is no cert -// one arg: the path to CA PEM file -// - creates a Config with no cert using a specific CA -// - use for a client that talks to a server with a private signed cert (CA not installed in system) -// - the client will not be authenticated by the server since there is no cert -// two args: path to cert PEM file, the path to private key PEM file -// - creates a Config with a cert, using system CAs to validate the other end -// - use for: -// - a server; or, -// - a client that talks to a server with a public cert and needs certificate-based authentication -// - the other end will authenticate this end via the provided cert -// - the cert of the other end will be verified via system CAs -// three args: path to cert PEM file, path to client private key PEM file, path to CA PEM file -// - creates a Config with the cert, using specified CA to validate the other end -// - use for: -// - a server; or, -// - a client that talks to a server with a privately signed cert and needs certificate-based -// authentication -// - the other end will authenticate this end via the provided cert -// - this end will verify the other end's cert using the specified CA -func NewTLSConfigFromArgs(args ...string) (*tls.Config, error) { - var err error - var c *tls.Config - switch len(args) { - case 0: - // No client cert, use system CA - c, err = NewTLSClientConfig("") - case 1: - // No client cert, use specified CA - c, err = NewTLSClientConfig(args[0]) - case 2: - // Client cert, use system CA - c, err = NewTLSConfig(args[0], args[1], "") - case 3: - // Client cert, use specified CA - c, err = NewTLSConfig(args[0], args[1], args[2]) - default: - err = fmt.Errorf("maximum of three arguments allowed for TLS config, found %d", len(args)) - } - if err != nil { - return nil, err - } - return c, nil -} - -// NewTLSConfig returns a TLS config that includes a certificate -// Use for server TLS config or when using a client certificate -// If caPath is empty, system CAs will be used -func NewTLSConfig(certPath, keyPath, caPath string) (*tls.Config, error) { - cert, err := tls.LoadX509KeyPair(certPath, keyPath) - if err != nil { - return nil, fmt.Errorf("could not load TLS cert: %s", err) - } - - roots, err := loadRoots(caPath) - if err != nil { - return nil, err - } - - return &tls.Config{Certificates: []tls.Certificate{cert}, RootCAs: roots}, nil -} - -// NewTLSClientConfig returns a TLS config for a client connection -// If caPath is empty, system CAs will be used -func NewTLSClientConfig(caPath string) (*tls.Config, error) { - roots, err := loadRoots(caPath) - if err != nil { - return nil, err - } - - return &tls.Config{RootCAs: roots}, nil -} - -func loadRoots(caPath string) (*x509.CertPool, error) { - if caPath == "" { - return nil, nil - } - - roots := x509.NewCertPool() - pem, err := ioutil.ReadFile(caPath) - if err != nil { - return nil, fmt.Errorf("error reading %s: %s", caPath, err) - } - ok := roots.AppendCertsFromPEM(pem) - if !ok { - return nil, fmt.Errorf("could not read root certs: %s", err) - } - return roots, nil -} - -// NewHTTPSTransport returns an HTTP transport configured using tls.Config -func NewHTTPSTransport(cc *tls.Config) *http.Transport { - // this seems like a bad idea but was here in the previous version - if cc != nil { - cc.InsecureSkipVerify = true - } - - tr := &http.Transport{ - Proxy: http.ProxyFromEnvironment, - Dial: (&net.Dialer{ - Timeout: 30 * time.Second, - KeepAlive: 30 * time.Second, - }).Dial, - TLSHandshakeTimeout: 10 * time.Second, - TLSClientConfig: cc, - MaxIdleConnsPerHost: 25, - } - - return tr -} diff --git a/vendor/github.com/coredns/coredns/plugin/pkg/tls/tls_test.go b/vendor/github.com/coredns/coredns/plugin/pkg/tls/tls_test.go deleted file mode 100644 index 8c88bfcc..00000000 --- a/vendor/github.com/coredns/coredns/plugin/pkg/tls/tls_test.go +++ /dev/null @@ -1,101 +0,0 @@ -package tls - -import ( - "path/filepath" - "testing" - - "github.com/coredns/coredns/plugin/test" -) - -func getPEMFiles(t *testing.T) (rmFunc func(), cert, key, ca string) { - tempDir, rmFunc, err := test.WritePEMFiles("") - if err != nil { - t.Fatalf("Could not write PEM files: %s", err) - } - - cert = filepath.Join(tempDir, "cert.pem") - key = filepath.Join(tempDir, "key.pem") - ca = filepath.Join(tempDir, "ca.pem") - - return -} - -func TestNewTLSConfig(t *testing.T) { - rmFunc, cert, key, ca := getPEMFiles(t) - defer rmFunc() - - _, err := NewTLSConfig(cert, key, ca) - if err != nil { - t.Errorf("Failed to create TLSConfig: %s", err) - } -} - -func TestNewTLSClientConfig(t *testing.T) { - rmFunc, _, _, ca := getPEMFiles(t) - defer rmFunc() - - _, err := NewTLSClientConfig(ca) - if err != nil { - t.Errorf("Failed to create TLSConfig: %s", err) - } -} - -func TestNewTLSConfigFromArgs(t *testing.T) { - rmFunc, cert, key, ca := getPEMFiles(t) - defer rmFunc() - - _, err := NewTLSConfigFromArgs() - if err != nil { - t.Errorf("Failed to create TLSConfig: %s", err) - } - - c, err := NewTLSConfigFromArgs(ca) - if err != nil { - t.Errorf("Failed to create TLSConfig: %s", err) - } - if c.RootCAs == nil { - t.Error("RootCAs should not be nil when one arg passed") - } - - c, err = NewTLSConfigFromArgs(cert, key) - if err != nil { - t.Errorf("Failed to create TLSConfig: %s", err) - } - if c.RootCAs != nil { - t.Error("RootCAs should be nil when two args passed") - } - if len(c.Certificates) != 1 { - t.Error("Certificates should have a single entry when two args passed") - } - args := []string{cert, key, ca} - c, err = NewTLSConfigFromArgs(args...) - if err != nil { - t.Errorf("Failed to create TLSConfig: %s", err) - } - if c.RootCAs == nil { - t.Error("RootCAs should not be nil when three args passed") - } - if len(c.Certificates) != 1 { - t.Error("Certificateis should have a single entry when three args passed") - } -} - -func TestNewHTTPSTransport(t *testing.T) { - rmFunc, _, _, ca := getPEMFiles(t) - defer rmFunc() - - cc, err := NewTLSClientConfig(ca) - if err != nil { - t.Errorf("Failed to create TLSConfig: %s", err) - } - - tr := NewHTTPSTransport(cc) - if tr == nil { - t.Errorf("Failed to create https transport with cc") - } - - tr = NewHTTPSTransport(nil) - if tr == nil { - t.Errorf("Failed to create https transport without cc") - } -} diff --git a/vendor/github.com/coredns/coredns/plugin/pkg/uniq/uniq_test.go b/vendor/github.com/coredns/coredns/plugin/pkg/uniq/uniq_test.go deleted file mode 100644 index 5d58c924..00000000 --- a/vendor/github.com/coredns/coredns/plugin/pkg/uniq/uniq_test.go +++ /dev/null @@ -1,17 +0,0 @@ -package uniq - -import "testing" - -func TestForEach(t *testing.T) { - u, i := New(), 0 - u.Set("test", func() error { i++; return nil }) - - u.ForEach() - if i != 1 { - t.Errorf("Failed to executed f for %s", "test") - } - u.ForEach() - if i != 1 { - t.Errorf("Executed f twice instead of once") - } -} diff --git a/vendor/github.com/coredns/coredns/plugin/pkg/up/up.go b/vendor/github.com/coredns/coredns/plugin/pkg/up/up.go deleted file mode 100644 index e4752ce4..00000000 --- a/vendor/github.com/coredns/coredns/plugin/pkg/up/up.go +++ /dev/null @@ -1,77 +0,0 @@ -// Package up is used to run a function for some duration. If a new function is added while a previous run is -// still ongoing, nothing new will be executed. -package up - -import ( - "sync" - "time" -) - -// Probe is used to run a single Func until it returns true (indicating a target is healthy). If an Func -// is already in progress no new one will be added, i.e. there is always a maximum of 1 checks in flight. -type Probe struct { - sync.Mutex - inprogress int - interval time.Duration -} - -// Func is used to determine if a target is alive. If so this function must return nil. -type Func func() error - -// New returns a pointer to an intialized Probe. -func New() *Probe { return &Probe{} } - -// Do will probe target, if a probe is already in progress this is a noop. -func (p *Probe) Do(f Func) { - p.Lock() - if p.inprogress != idle { - p.Unlock() - return - } - p.inprogress = active - interval := p.interval - p.Unlock() - // Passed the lock. Now run f for as long it returns false. If a true is returned - // we return from the goroutine and we can accept another Func to run. - go func() { - for { - if err := f(); err == nil { - break - } - time.Sleep(interval) - p.Lock() - if p.inprogress == stop { - p.Unlock() - return - } - p.Unlock() - } - - p.Lock() - p.inprogress = idle - p.Unlock() - }() -} - -// Stop stops the probing. -func (p *Probe) Stop() { - p.Lock() - p.inprogress = stop - p.Unlock() -} - -// Start will initialize the probe manager, after which probes can be initiated with Do. -func (p *Probe) Start(interval time.Duration) { p.SetInterval(interval) } - -// SetInterval sets the probing interval to be used by upcoming probes initiated with Do. -func (p *Probe) SetInterval(interval time.Duration) { - p.Lock() - p.interval = interval - p.Unlock() -} - -const ( - idle = iota - active - stop -) diff --git a/vendor/github.com/coredns/coredns/plugin/pkg/up/up_test.go b/vendor/github.com/coredns/coredns/plugin/pkg/up/up_test.go deleted file mode 100644 index eeaecea3..00000000 --- a/vendor/github.com/coredns/coredns/plugin/pkg/up/up_test.go +++ /dev/null @@ -1,40 +0,0 @@ -package up - -import ( - "sync" - "sync/atomic" - "testing" - "time" -) - -func TestUp(t *testing.T) { - pr := New() - wg := sync.WaitGroup{} - hits := int32(0) - - upfunc := func() error { - atomic.AddInt32(&hits, 1) - // Sleep tiny amount so that our other pr.Do() calls hit the lock. - time.Sleep(3 * time.Millisecond) - wg.Done() - return nil - } - - pr.Start(5 * time.Millisecond) - defer pr.Stop() - - // These functions AddInt32 to the same hits variable, but we only want to wait when - // upfunc finishes, as that only calls Done() on the waitgroup. - upfuncNoWg := func() error { atomic.AddInt32(&hits, 1); return nil } - wg.Add(1) - pr.Do(upfunc) - pr.Do(upfuncNoWg) - pr.Do(upfuncNoWg) - - wg.Wait() - - h := atomic.LoadInt32(&hits) - if h != 1 { - t.Errorf("Expected hits to be %d, got %d", 1, h) - } -} diff --git a/vendor/github.com/coredns/coredns/plugin/pkg/upstream/upstream.go b/vendor/github.com/coredns/coredns/plugin/pkg/upstream/upstream.go deleted file mode 100644 index 466da899..00000000 --- a/vendor/github.com/coredns/coredns/plugin/pkg/upstream/upstream.go +++ /dev/null @@ -1,58 +0,0 @@ -// Package upstream abstracts a upstream lookups so that plugins -// can handle them in an unified way. -package upstream - -import ( - "github.com/miekg/dns" - - "github.com/coredns/coredns/core/dnsserver" - "github.com/coredns/coredns/plugin/pkg/dnsutil" - "github.com/coredns/coredns/plugin/pkg/nonwriter" - "github.com/coredns/coredns/plugin/proxy" - "github.com/coredns/coredns/request" -) - -// Upstream is used to resolve CNAME targets -type Upstream struct { - self bool - Forward *proxy.Proxy -} - -// New creates a new Upstream for given destination(s). If dests is empty it default to upstreaming to -// the coredns process. -func New(dests []string) (Upstream, error) { - u := Upstream{} - if len(dests) == 0 { - u.self = true - return u, nil - } - u.self = false - ups, err := dnsutil.ParseHostPortOrFile(dests...) - if err != nil { - return u, err - } - p := proxy.NewLookup(ups) - u.Forward = &p - return u, nil -} - -// Lookup routes lookups to our selves or forward to a remote. -func (u Upstream) Lookup(state request.Request, name string, typ uint16) (*dns.Msg, error) { - if u.self { - req := new(dns.Msg) - req.SetQuestion(name, typ) - - nw := nonwriter.New(state.W) - server := state.Context.Value(dnsserver.Key{}).(*dnsserver.Server) - - server.ServeDNS(state.Context, nw, req) - - return nw.Msg, nil - } - - if u.Forward != nil { - return u.Forward.Lookup(state, name, typ) - } - - return nil, nil -} diff --git a/vendor/github.com/coredns/coredns/plugin/pkg/watch/watch.go b/vendor/github.com/coredns/coredns/plugin/pkg/watch/watch.go new file mode 100644 index 00000000..7e77bb7b --- /dev/null +++ b/vendor/github.com/coredns/coredns/plugin/pkg/watch/watch.go @@ -0,0 +1,23 @@ +package watch + +// Chan is used to inform the server of a change. Whenever +// a watched FQDN has a change in data, that FQDN should be +// sent down this channel. +type Chan chan string + +// Watchable is the interface watchable plugins should implement +type Watchable interface { + // Name returns the plugin name. + Name() string + + // SetWatchChan is called when the watch channel is created. + SetWatchChan(Chan) + + // Watch is called whenever a watch is created for a FQDN. Plugins + // should send the FQDN down the watch channel when its data may have + // changed. This is an exact match only. + Watch(qname string) error + + // StopWatching is called whenever all watches are canceled for a FQDN. + StopWatching(qname string) +} diff --git a/vendor/github.com/coredns/coredns/plugin/pkg/watch/watcher.go b/vendor/github.com/coredns/coredns/plugin/pkg/watch/watcher.go new file mode 100644 index 00000000..59474a7b --- /dev/null +++ b/vendor/github.com/coredns/coredns/plugin/pkg/watch/watcher.go @@ -0,0 +1,178 @@ +package watch + +import ( + "fmt" + "io" + "sync" + + "github.com/miekg/dns" + + "github.com/coredns/coredns/pb" + "github.com/coredns/coredns/plugin" + "github.com/coredns/coredns/plugin/pkg/log" + "github.com/coredns/coredns/request" +) + +// Watcher handles watch creation, cancellation, and processing. +type Watcher interface { + // Watch monitors a client stream and creates and cancels watches. + Watch(pb.DnsService_WatchServer) error + + // Stop cancels open watches and stops the watch processing go routine. + Stop() +} + +// Manager contains all the data needed to manage watches +type Manager struct { + changes Chan + stopper chan bool + counter int64 + watches map[string]watchlist + plugins []Watchable + mutex sync.Mutex +} + +type watchlist map[int64]pb.DnsService_WatchServer + +// NewWatcher creates a Watcher, which is used to manage watched names. +func NewWatcher(plugins []Watchable) *Manager { + w := &Manager{changes: make(Chan), stopper: make(chan bool), watches: make(map[string]watchlist), plugins: plugins} + + for _, p := range plugins { + p.SetWatchChan(w.changes) + } + + go w.process() + return w +} + +func (w *Manager) nextID() int64 { + w.mutex.Lock() + + w.counter++ + id := w.counter + + w.mutex.Unlock() + return id +} + +// Watch monitors a client stream and creates and cancels watches. +func (w *Manager) Watch(stream pb.DnsService_WatchServer) error { + for { + in, err := stream.Recv() + if err == io.EOF { + return nil + } + if err != nil { + return err + } + create := in.GetCreateRequest() + if create != nil { + msg := new(dns.Msg) + err := msg.Unpack(create.Query.Msg) + if err != nil { + log.Warningf("Could not decode watch request: %s\n", err) + stream.Send(&pb.WatchResponse{Err: "could not decode request"}) + continue + } + id := w.nextID() + if err := stream.Send(&pb.WatchResponse{WatchId: id, Created: true}); err != nil { + // if we fail to notify client of watch creation, don't create the watch + continue + } + + // Normalize qname + qname := (&request.Request{Req: msg}).Name() + + w.mutex.Lock() + if _, ok := w.watches[qname]; !ok { + w.watches[qname] = make(watchlist) + } + w.watches[qname][id] = stream + w.mutex.Unlock() + + for _, p := range w.plugins { + err := p.Watch(qname) + if err != nil { + log.Warningf("Failed to start watch for %s in plugin %s: %s\n", qname, p.Name(), err) + stream.Send(&pb.WatchResponse{Err: fmt.Sprintf("failed to start watch for %s in plugin %s", qname, p.Name())}) + } + } + continue + } + + cancel := in.GetCancelRequest() + if cancel != nil { + w.mutex.Lock() + for qname, wl := range w.watches { + ws, ok := wl[cancel.WatchId] + if !ok { + continue + } + + // only allow cancels from the client that started it + // TODO: test what happens if a stream tries to cancel a watchID that it doesn't own + if ws != stream { + continue + } + + delete(wl, cancel.WatchId) + + // if there are no more watches for this qname, we should tell the plugins + if len(wl) == 0 { + for _, p := range w.plugins { + p.StopWatching(qname) + } + delete(w.watches, qname) + } + + // let the client know we canceled the watch + stream.Send(&pb.WatchResponse{WatchId: cancel.WatchId, Canceled: true}) + } + w.mutex.Unlock() + continue + } + } +} + +func (w *Manager) process() { + for { + select { + case <-w.stopper: + return + case changed := <-w.changes: + w.mutex.Lock() + for qname, wl := range w.watches { + if plugin.Zones([]string{changed}).Matches(qname) == "" { + continue + } + for id, stream := range wl { + wr := pb.WatchResponse{WatchId: id, Qname: qname} + err := stream.Send(&wr) + if err != nil { + log.Warningf("Error sending change for %s to watch %d: %s. Removing watch.\n", qname, id, err) + delete(w.watches[qname], id) + } + } + } + w.mutex.Unlock() + } + } +} + +// Stop cancels open watches and stops the watch processing go routine. +func (w *Manager) Stop() { + w.stopper <- true + w.mutex.Lock() + for wn, wl := range w.watches { + for id, stream := range wl { + wr := pb.WatchResponse{WatchId: id, Canceled: true} + err := stream.Send(&wr) + if err != nil { + log.Warningf("Error notifiying client of cancellation: %s\n", err) + } + } + delete(w.watches, wn) + } + w.mutex.Unlock() +} diff --git a/vendor/github.com/coredns/coredns/plugin/pprof/OWNERS b/vendor/github.com/coredns/coredns/plugin/pprof/OWNERS deleted file mode 100644 index eee46f68..00000000 --- a/vendor/github.com/coredns/coredns/plugin/pprof/OWNERS +++ /dev/null @@ -1,4 +0,0 @@ -reviewers: - - miekg -approvers: - - miekg diff --git a/vendor/github.com/coredns/coredns/plugin/pprof/README.md b/vendor/github.com/coredns/coredns/plugin/pprof/README.md deleted file mode 100644 index 27d64aee..00000000 --- a/vendor/github.com/coredns/coredns/plugin/pprof/README.md +++ /dev/null @@ -1,56 +0,0 @@ -# pprof - -## Name - -*pprof* - publishes runtime profiling data at endpoints under `/debug/pprof`. - -## Description - -You can visit `/debug/pprof` on your site for an index of the available endpoints. By default it -will listen on localhost:6053. - -This is a debugging tool. Certain requests (such as collecting execution traces) can be slow. If -you use pprof on a live server, consider restricting access or enabling it only temporarily. - -This plugin can only be used once per Server Block. - -## Syntax - -~~~ -pprof [ADDRESS] -~~~ - -If not specified, ADDRESS defaults to localhost:6053. - -## Examples - -Enable pprof endpoints: - -~~~ -. { - pprof -} -~~~ - -And use the pprof tool to get statistics: `go tool pprof http://localhost:6053`. - -Listen on an alternate address: - -~~~ txt -. { - pprof 10.9.8.7:6060 -} -~~~ - -Listen on an all addresses on port 6060: - -~~~ txt -. { - pprof :6060 -} -~~~ - -## Also See - -See [Go's pprof documentation](https://golang.org/pkg/net/http/pprof/) and [Profiling Go -Programs](https://blog.golang.org/profiling-go-programs). diff --git a/vendor/github.com/coredns/coredns/plugin/pprof/pprof.go b/vendor/github.com/coredns/coredns/plugin/pprof/pprof.go deleted file mode 100644 index 6cfaa549..00000000 --- a/vendor/github.com/coredns/coredns/plugin/pprof/pprof.go +++ /dev/null @@ -1,48 +0,0 @@ -// Package pprof implement a debug endpoint for getting profiles using the -// go pprof tooling. -package pprof - -import ( - "net" - "net/http" - pp "net/http/pprof" -) - -type handler struct { - addr string - ln net.Listener - mux *http.ServeMux -} - -func (h *handler) Startup() error { - ln, err := net.Listen("tcp", h.addr) - if err != nil { - log.Errorf("Failed to start pprof handler: %s", err) - return err - } - - h.ln = ln - - h.mux = http.NewServeMux() - h.mux.HandleFunc(path+"/", pp.Index) - h.mux.HandleFunc(path+"/cmdline", pp.Cmdline) - h.mux.HandleFunc(path+"/profile", pp.Profile) - h.mux.HandleFunc(path+"/symbol", pp.Symbol) - h.mux.HandleFunc(path+"/trace", pp.Trace) - - go func() { - http.Serve(h.ln, h.mux) - }() - return nil -} - -func (h *handler) Shutdown() error { - if h.ln != nil { - return h.ln.Close() - } - return nil -} - -const ( - path = "/debug/pprof" -) diff --git a/vendor/github.com/coredns/coredns/plugin/pprof/setup.go b/vendor/github.com/coredns/coredns/plugin/pprof/setup.go deleted file mode 100644 index cdc34637..00000000 --- a/vendor/github.com/coredns/coredns/plugin/pprof/setup.go +++ /dev/null @@ -1,58 +0,0 @@ -package pprof - -import ( - "net" - "sync" - - "github.com/coredns/coredns/plugin" - clog "github.com/coredns/coredns/plugin/pkg/log" - - "github.com/mholt/caddy" -) - -var log = clog.NewWithPlugin("pprof") - -const defaultAddr = "localhost:6053" - -func init() { - caddy.RegisterPlugin("pprof", caddy.Plugin{ - ServerType: "dns", - Action: setup, - }) -} - -func setup(c *caddy.Controller) error { - h := &handler{addr: defaultAddr} - - i := 0 - for c.Next() { - if i > 0 { - return plugin.Error("pprof", plugin.ErrOnce) - } - i++ - - args := c.RemainingArgs() - if len(args) == 1 { - h.addr = args[0] - _, _, e := net.SplitHostPort(h.addr) - if e != nil { - return e - } - } - if len(args) > 1 { - return plugin.Error("pprof", c.ArgErr()) - } - if c.NextBlock() { - return plugin.Error("pprof", c.ArgErr()) - } - } - - pprofOnce.Do(func() { - c.OnStartup(h.Startup) - c.OnShutdown(h.Shutdown) - }) - - return nil -} - -var pprofOnce sync.Once diff --git a/vendor/github.com/coredns/coredns/plugin/pprof/setup_test.go b/vendor/github.com/coredns/coredns/plugin/pprof/setup_test.go deleted file mode 100644 index eaa4cb37..00000000 --- a/vendor/github.com/coredns/coredns/plugin/pprof/setup_test.go +++ /dev/null @@ -1,34 +0,0 @@ -package pprof - -import ( - "testing" - - "github.com/mholt/caddy" -) - -func TestPProf(t *testing.T) { - tests := []struct { - input string - shouldErr bool - }{ - {`pprof`, false}, - {`pprof 1.2.3.4:1234`, false}, - {`pprof :1234`, false}, - {`pprof {}`, true}, - {`pprof /foo`, true}, - {`pprof { - a b - }`, true}, - {`pprof - pprof`, true}, - } - for i, test := range tests { - c := caddy.NewTestController("dns", test.input) - err := setup(c) - if test.shouldErr && err == nil { - t.Errorf("Test %v: Expected error but found nil", i) - } else if !test.shouldErr && err != nil { - t.Errorf("Test %v: Expected no error but found error: %v", i, err) - } - } -} diff --git a/vendor/github.com/coredns/coredns/plugin/proxy/OWNERS b/vendor/github.com/coredns/coredns/plugin/proxy/OWNERS deleted file mode 100644 index fb365f40..00000000 --- a/vendor/github.com/coredns/coredns/plugin/proxy/OWNERS +++ /dev/null @@ -1,10 +0,0 @@ -reviewers: - - fturib - - grobie - - johnbelamaric - - miekg -approvers: - - fturib - - grobie - - johnbelamaric - - miekg diff --git a/vendor/github.com/coredns/coredns/plugin/proxy/README.md b/vendor/github.com/coredns/coredns/plugin/proxy/README.md deleted file mode 100644 index f9dc3493..00000000 --- a/vendor/github.com/coredns/coredns/plugin/proxy/README.md +++ /dev/null @@ -1,159 +0,0 @@ -# proxy - -## Name - -*proxy* - facilitates both a basic reverse proxy and a robust load balancer. - -## Description - -The proxy has support for multiple backends. The load balancing features include multiple policies, -health checks, and failovers. If all hosts fail their health check the proxy plugin will fail -back to randomly selecting a target and sending packets to it. - -## Syntax - -In its most basic form, a simple reverse proxy uses this syntax: - -~~~ -proxy FROM TO -~~~ - -* **FROM** is the base domain to match for the request to be proxied. -* **TO** is the destination endpoint to proxy to. - -However, advanced features including load balancing can be utilized with an expanded syntax: - -~~~ -proxy FROM TO... { - policy random|least_conn|round_robin|sequential - fail_timeout DURATION - max_fails INTEGER - health_check PATH:PORT [DURATION] - except IGNORED_NAMES... - spray - protocol [dns [force_tcp]|grpc [insecure|CACERT|KEY CERT|KEY CERT CACERT]] -} -~~~ - -* **FROM** is the name to match for the request to be proxied. -* **TO** is the destination endpoint to proxy to. At least one is required, but multiple may be - specified. **TO** may be an IP:Port pair, or may reference a file in resolv.conf format -* `policy` is the load balancing policy to use; applies only with multiple backends. May be one of - random, least_conn, round_robin or sequential. Default is random. -* `fail_timeout` specifies how long to consider a backend as down after it has failed. While it is - down, requests will not be routed to that backend. A backend is "down" if CoreDNS fails to - communicate with it. The default value is 2 seconds ("2s"). -* `max_fails` is the number of failures within fail_timeout that are needed before considering - a backend to be down. If 0, the backend will never be marked as down. Default is 1. -* `health_check` will check **PATH** (on **PORT**) on each backend. If a backend returns a status code of - 200-399, then that backend is marked healthy for double the healthcheck duration. If it doesn't, - it is marked as unhealthy and no requests are routed to it. If this option is not provided then - health checks are disabled. The default duration is 4 seconds ("4s"). -* **IGNORED_NAMES** in `except` is a space-separated list of domains to exclude from proxying. - Requests that match none of these names will be passed through. -* `spray` when all backends are unhealthy, randomly pick one to send the traffic to. (This is - a failsafe.) -* `protocol` specifies what protocol to use to speak to an upstream, `dns` (the default) is plain - old DNS. The `grpc` option will talk to a server that has implemented - the [DnsService](https://github.com/coredns/coredns/blob/master/pb/dns.proto). - -## Policies - -There are four load-balancing policies available: -* `random` (default) - Randomly select a backend -* `least_conn` - Select the backend with the fewest active connections -* `round_robin` - Select the backend in round-robin fashion -* `sequential` - Select the first available backend looking by order of declaration from left to right -* `first` - Deprecated. Use sequential instead - - -All polices implement randomly spraying packets to backend hosts when *no healthy* hosts are -available. This is to preeempt the case where the healthchecking (as a mechanism) fails. - -## Upstream Protocols - -`dns` -: uses the standard DNS exchange. You can pass `force_tcp` to make sure that the proxied connection is performed - over TCP, regardless of the inbound request's protocol. - -`grpc` -: extra options are used to control how the TLS connection is made to the gRPC server. - - * None - No client authentication is used, and the system CAs are used to verify the server certificate. - * `insecure` - TLS is not used, the connection is made in plaintext (not good in production). - * **CACERT** - No client authentication is used, and the file **CACERT** is used to verify the server certificate. - * **KEY** **CERT** - Client authentication is used with the specified key/cert pair. The server - certificate is verified with the system CAs. - * **KEY** **CERT** **CACERT** - Client authentication is used with the specified key/cert pair. The - server certificate is verified using the **CACERT** file. - -## Metrics - -If monitoring is enabled (via the *prometheus* directive) then the following metric is exported: - -* `coredns_proxy_request_duration_seconds{server, proto, proto_proxy, family, to}` - duration per - upstream interaction. -* `coredns_proxy_request_count_total{server, proto, proto_proxy, family, to}` - query count per - upstream. - -Where `proxy_proto` is the protocol used (`dns` or `grpc`) and `to` is **TO** -specified in the config, `proto` is the protocol used by the incoming query ("tcp" or "udp"), family -the transport family ("1" for IPv4, and "2" for IPv6). `Server` is the server responsible for the -request (and metric). See the documention in the metrics plugin. - -## Examples - -Proxy all requests within example.org. to a backend system: - -~~~ -proxy example.org 127.0.0.1:9005 -~~~ - -Load-balance all requests between three backends (using random policy): - -~~~ corefile -. { - proxy . 10.0.0.10:53 10.0.0.11:1053 10.0.0.12 -} -~~~ - -Same as above, but round-robin style: - -~~~ corefile -. { - proxy . 10.0.0.10:53 10.0.0.11:1053 10.0.0.12 { - policy round_robin - } -} -~~~ - -With health checks and proxy headers to pass hostname, IP, and scheme upstream: - -~~~ corefile -. { - proxy . 10.0.0.11:53 10.0.0.11:53 10.0.0.12:53 { - policy round_robin - health_check /health:8080 - } -} -~~~ - -Proxy everything except requests to miek.nl or example.org - -~~~ -. { - proxy . 10.0.0.10:1234 { - except miek.nl example.org - } -} -~~~ - -Proxy everything except `example.org` using the host's `resolv.conf`'s nameservers: - -~~~ corefile -. { - proxy . /etc/resolv.conf { - except example.org - } -} -~~~ diff --git a/vendor/github.com/coredns/coredns/plugin/proxy/dns.go b/vendor/github.com/coredns/coredns/plugin/proxy/dns.go deleted file mode 100644 index d3153bdf..00000000 --- a/vendor/github.com/coredns/coredns/plugin/proxy/dns.go +++ /dev/null @@ -1,107 +0,0 @@ -package proxy - -import ( - "context" - "net" - "time" - - "github.com/coredns/coredns/request" - - "github.com/miekg/dns" -) - -type dnsEx struct { - Timeout time.Duration - Options -} - -// Options define the options understood by dns.Exchange. -type Options struct { - ForceTCP bool // If true use TCP for upstream no matter what -} - -func newDNSEx() *dnsEx { - return newDNSExWithOption(Options{}) -} - -func newDNSExWithOption(opt Options) *dnsEx { - return &dnsEx{Timeout: defaultTimeout * time.Second, Options: opt} -} - -func (d *dnsEx) Transport() string { - if d.Options.ForceTCP { - return "tcp" - } - - // The protocol will be determined by `state.Proto()` during Exchange. - return "" -} -func (d *dnsEx) Protocol() string { return "dns" } -func (d *dnsEx) OnShutdown(p *Proxy) error { return nil } -func (d *dnsEx) OnStartup(p *Proxy) error { return nil } - -// Exchange implements the Exchanger interface. -func (d *dnsEx) Exchange(ctx context.Context, addr string, state request.Request) (*dns.Msg, error) { - proto := state.Proto() - if d.Options.ForceTCP { - proto = "tcp" - } - co, err := net.DialTimeout(proto, addr, d.Timeout) - if err != nil { - return nil, err - } - - reply, _, err := d.ExchangeConn(state.Req, co) - - co.Close() - - if reply != nil && reply.Truncated { - // Suppress proxy error for truncated responses - err = nil - } - - if err != nil { - return nil, err - } - reply.Id = state.Req.Id - // When using force_tcp the upstream can send a message that is too big for - // the udp buffer, hence we need to truncate the message to at least make it - // fit the udp buffer. - reply, _ = state.Scrub(reply) - - return reply, nil -} - -func (d *dnsEx) ExchangeConn(m *dns.Msg, co net.Conn) (*dns.Msg, time.Duration, error) { - start := time.Now() - r, err := exchange(m, co) - rtt := time.Since(start) - - return r, rtt, err -} - -func exchange(m *dns.Msg, co net.Conn) (*dns.Msg, error) { - opt := m.IsEdns0() - - udpsize := uint16(dns.MinMsgSize) - // If EDNS0 is used use that for size. - if opt != nil && opt.UDPSize() >= dns.MinMsgSize { - udpsize = opt.UDPSize() - } - - dnsco := &dns.Conn{Conn: co, UDPSize: udpsize} - - writeDeadline := time.Now().Add(defaultTimeout) - dnsco.SetWriteDeadline(writeDeadline) - dnsco.WriteMsg(m) - - readDeadline := time.Now().Add(defaultTimeout) - co.SetReadDeadline(readDeadline) - r, err := dnsco.ReadMsg() - - dnsco.Close() - if r == nil { - return nil, err - } - return r, err -} diff --git a/vendor/github.com/coredns/coredns/plugin/proxy/dnstap.go b/vendor/github.com/coredns/coredns/plugin/proxy/dnstap.go deleted file mode 100644 index 4e5a8bd4..00000000 --- a/vendor/github.com/coredns/coredns/plugin/proxy/dnstap.go +++ /dev/null @@ -1,56 +0,0 @@ -package proxy - -import ( - "context" - "time" - - "github.com/coredns/coredns/plugin/dnstap" - "github.com/coredns/coredns/plugin/dnstap/msg" - "github.com/coredns/coredns/request" - - tap "github.com/dnstap/golang-dnstap" - "github.com/miekg/dns" -) - -func toDnstap(ctx context.Context, host string, ex Exchanger, state request.Request, reply *dns.Msg, start time.Time) error { - tapper := dnstap.TapperFromContext(ctx) - if tapper == nil { - return nil - } - - // Query - b := msg.New().Time(start).HostPort(host) - - t := ex.Transport() - if t == "" { - t = state.Proto() - } - if t == "tcp" { - b.SocketProto = tap.SocketProtocol_TCP - } else { - b.SocketProto = tap.SocketProtocol_UDP - } - - if tapper.Pack() { - b.Msg(state.Req) - } - m, err := b.ToOutsideQuery(tap.Message_FORWARDER_QUERY) - if err != nil { - return err - } - tapper.TapMessage(m) - - // Response - if reply != nil { - if tapper.Pack() { - b.Msg(reply) - } - m, err := b.Time(time.Now()).ToOutsideResponse(tap.Message_FORWARDER_RESPONSE) - if err != nil { - return err - } - tapper.TapMessage(m) - } - - return nil -} diff --git a/vendor/github.com/coredns/coredns/plugin/proxy/dnstap_test.go b/vendor/github.com/coredns/coredns/plugin/proxy/dnstap_test.go deleted file mode 100644 index b07b081b..00000000 --- a/vendor/github.com/coredns/coredns/plugin/proxy/dnstap_test.go +++ /dev/null @@ -1,57 +0,0 @@ -package proxy - -import ( - "context" - "testing" - "time" - - "github.com/coredns/coredns/plugin/dnstap/msg" - "github.com/coredns/coredns/plugin/dnstap/test" - mwtest "github.com/coredns/coredns/plugin/test" - "github.com/coredns/coredns/request" - - tap "github.com/dnstap/golang-dnstap" - "github.com/miekg/dns" -) - -func testCase(t *testing.T, ex Exchanger, q, r *dns.Msg, datq, datr *msg.Builder) { - tapq, _ := datq.ToOutsideQuery(tap.Message_FORWARDER_QUERY) - tapr, _ := datr.ToOutsideResponse(tap.Message_FORWARDER_RESPONSE) - ctx := test.Context{} - err := toDnstap(&ctx, "10.240.0.1:40212", ex, - request.Request{W: &mwtest.ResponseWriter{}, Req: q}, r, time.Now()) - if err != nil { - t.Fatal(err) - } - if len(ctx.Trap) != 2 { - t.Fatalf("Messages: %d", len(ctx.Trap)) - } - if !test.MsgEqual(ctx.Trap[0], tapq) { - t.Errorf("Want: %v\nhave: %v", tapq, ctx.Trap[0]) - } - if !test.MsgEqual(ctx.Trap[1], tapr) { - t.Errorf("Want: %v\nhave: %v", tapr, ctx.Trap[1]) - } -} - -func TestDnstap(t *testing.T) { - q := mwtest.Case{Qname: "example.org", Qtype: dns.TypeA}.Msg() - r := mwtest.Case{ - Qname: "example.org.", Qtype: dns.TypeA, - Answer: []dns.RR{ - mwtest.A("example.org. 3600 IN A 10.0.0.1"), - }, - }.Msg() - tapq, tapr := test.TestingData(), test.TestingData() - testCase(t, newDNSEx(), q, r, tapq, tapr) - tapq.SocketProto = tap.SocketProtocol_TCP - tapr.SocketProto = tap.SocketProtocol_TCP - testCase(t, newDNSExWithOption(Options{ForceTCP: true}), q, r, tapq, tapr) -} - -func TestNoDnstap(t *testing.T) { - err := toDnstap(context.TODO(), "", nil, request.Request{}, nil, time.Now()) - if err != nil { - t.Fatal(err) - } -} diff --git a/vendor/github.com/coredns/coredns/plugin/proxy/down.go b/vendor/github.com/coredns/coredns/plugin/proxy/down.go deleted file mode 100644 index 11f839b4..00000000 --- a/vendor/github.com/coredns/coredns/plugin/proxy/down.go +++ /dev/null @@ -1,18 +0,0 @@ -package proxy - -import ( - "sync/atomic" - - "github.com/coredns/coredns/plugin/pkg/healthcheck" -) - -// Default CheckDown functions for use in the proxy plugin. -var checkDownFunc = func(upstream *staticUpstream) healthcheck.UpstreamHostDownFunc { - return func(uh *healthcheck.UpstreamHost) bool { - fails := atomic.LoadInt32(&uh.Fails) - if fails >= upstream.MaxFails && upstream.MaxFails != 0 { - return true - } - return false - } -} diff --git a/vendor/github.com/coredns/coredns/plugin/proxy/exchanger.go b/vendor/github.com/coredns/coredns/plugin/proxy/exchanger.go deleted file mode 100644 index e96dac5a..00000000 --- a/vendor/github.com/coredns/coredns/plugin/proxy/exchanger.go +++ /dev/null @@ -1,23 +0,0 @@ -package proxy - -import ( - "context" - - "github.com/coredns/coredns/request" - - "github.com/miekg/dns" -) - -// Exchanger is an interface that specifies a type implementing a DNS resolver that -// can use whatever transport it likes. -type Exchanger interface { - Exchange(ctx context.Context, addr string, state request.Request) (*dns.Msg, error) - Protocol() string - - // Transport returns the only transport protocol used by this Exchanger or "". - // If the return value is "", Exchange must use `state.Proto()`. - Transport() string - - OnStartup(*Proxy) error - OnShutdown(*Proxy) error -} diff --git a/vendor/github.com/coredns/coredns/plugin/proxy/fuzz.go b/vendor/github.com/coredns/coredns/plugin/proxy/fuzz.go deleted file mode 100644 index bb8e07f8..00000000 --- a/vendor/github.com/coredns/coredns/plugin/proxy/fuzz.go +++ /dev/null @@ -1,21 +0,0 @@ -// +build fuzz - -package proxy - -import ( - "github.com/coredns/coredns/plugin/pkg/fuzz" - - "github.com/mholt/caddy" -) - -// Fuzz fuzzes proxy. -func Fuzz(data []byte) int { - c := caddy.NewTestController("dns", "proxy . 8.8.8.8:53") - up, err := NewStaticUpstreams(&c.Dispenser) - if err != nil { - return 0 - } - p := &Proxy{Upstreams: &up} - - return fuzz.Do(p, data) -} diff --git a/vendor/github.com/coredns/coredns/plugin/proxy/grpc.go b/vendor/github.com/coredns/coredns/plugin/proxy/grpc.go deleted file mode 100644 index dc388c91..00000000 --- a/vendor/github.com/coredns/coredns/plugin/proxy/grpc.go +++ /dev/null @@ -1,99 +0,0 @@ -package proxy - -import ( - "context" - "crypto/tls" - "fmt" - - "github.com/coredns/coredns/pb" - "github.com/coredns/coredns/plugin/pkg/trace" - "github.com/coredns/coredns/request" - - "github.com/grpc-ecosystem/grpc-opentracing/go/otgrpc" - "github.com/miekg/dns" - opentracing "github.com/opentracing/opentracing-go" - "google.golang.org/grpc" - "google.golang.org/grpc/credentials" -) - -type grpcClient struct { - dialOpts []grpc.DialOption - clients map[string]pb.DnsServiceClient - conns []*grpc.ClientConn - upstream *staticUpstream -} - -func newGrpcClient(tls *tls.Config, u *staticUpstream) *grpcClient { - g := &grpcClient{upstream: u} - - if tls == nil { - g.dialOpts = append(g.dialOpts, grpc.WithInsecure()) - } else { - g.dialOpts = append(g.dialOpts, grpc.WithTransportCredentials(credentials.NewTLS(tls))) - } - g.clients = map[string]pb.DnsServiceClient{} - - return g -} - -func (g *grpcClient) Exchange(ctx context.Context, addr string, state request.Request) (*dns.Msg, error) { - msg, err := state.Req.Pack() - if err != nil { - return nil, err - } - - if cl, ok := g.clients[addr]; ok { - reply, err := cl.Query(ctx, &pb.DnsPacket{Msg: msg}) - if err != nil { - return nil, err - } - d := new(dns.Msg) - err = d.Unpack(reply.Msg) - if err != nil { - return nil, err - } - return d, nil - } - return nil, fmt.Errorf("grpc exchange - no connection available for host: %s ", addr) -} - -func (g *grpcClient) Transport() string { return "tcp" } - -func (g *grpcClient) Protocol() string { return "grpc" } - -func (g *grpcClient) OnShutdown(p *Proxy) error { - g.clients = map[string]pb.DnsServiceClient{} - for i, conn := range g.conns { - err := conn.Close() - if err != nil { - log.Warningf("Error closing connection %d: %s\n", i, err) - } - } - g.conns = []*grpc.ClientConn{} - return nil -} - -func (g *grpcClient) OnStartup(p *Proxy) error { - dialOpts := g.dialOpts - if p.Trace != nil { - if t, ok := p.Trace.(trace.Trace); ok { - onlyIfParent := func(parentSpanCtx opentracing.SpanContext, method string, req, resp interface{}) bool { - return parentSpanCtx != nil - } - intercept := otgrpc.OpenTracingClientInterceptor(t.Tracer(), otgrpc.IncludingSpans(onlyIfParent)) - dialOpts = append(dialOpts, grpc.WithUnaryInterceptor(intercept)) - } else { - log.Warningf("Wrong type for trace plugin reference: %s", p.Trace) - } - } - for _, host := range g.upstream.Hosts { - conn, err := grpc.Dial(host.Name, dialOpts...) - if err != nil { - log.Warningf("Skipping gRPC host '%s' due to Dial error: %s\n", host.Name, err) - } else { - g.clients[host.Name] = pb.NewDnsServiceClient(conn) - g.conns = append(g.conns, conn) - } - } - return nil -} diff --git a/vendor/github.com/coredns/coredns/plugin/proxy/grpc_test.go b/vendor/github.com/coredns/coredns/plugin/proxy/grpc_test.go deleted file mode 100644 index 8f495829..00000000 --- a/vendor/github.com/coredns/coredns/plugin/proxy/grpc_test.go +++ /dev/null @@ -1,220 +0,0 @@ -package proxy - -import ( - "context" - "fmt" - "testing" - - "github.com/coredns/coredns/plugin/pkg/healthcheck" - "github.com/coredns/coredns/plugin/pkg/tls" - "github.com/coredns/coredns/plugin/test" - "github.com/coredns/coredns/request" - - "github.com/miekg/dns" - "google.golang.org/grpc/grpclog" -) - -func init() { - grpclog.SetLoggerV2(discardV2{}) -} - -func buildPool(size int) ([]*healthcheck.UpstreamHost, func(), error) { - ups := make([]*healthcheck.UpstreamHost, size) - srvs := []*dns.Server{} - errs := []error{} - for i := 0; i < size; i++ { - srv, addr, err := test.TCPServer("localhost:0") - if err != nil { - errs = append(errs, err) - continue - } - ups[i] = &healthcheck.UpstreamHost{Name: addr} - srvs = append(srvs, srv) - } - stopIt := func() { - for _, s := range srvs { - s.Shutdown() - } - } - if len(errs) > 0 { - go stopIt() - valErr := "" - for _, e := range errs { - valErr += fmt.Sprintf("%v\n", e) - } - return nil, nil, fmt.Errorf("Error at allocation of the pool : %v", valErr) - } - return ups, stopIt, nil -} - -func TestGRPCStartupShutdown(t *testing.T) { - - pool, closePool, err := buildPool(2) - if err != nil { - t.Fatalf("Error creating the pool of upstream for the test : %s", err) - } - defer closePool() - - upstream := &staticUpstream{ - from: ".", - HealthCheck: healthcheck.HealthCheck{ - Hosts: pool, - }, - } - g := newGrpcClient(nil, upstream) - upstream.ex = g - - p := &Proxy{} - p.Upstreams = &[]Upstream{upstream} - - err = g.OnStartup(p) - if err != nil { - t.Fatalf("Error starting grpc client exchanger: %s", err) - } - if len(g.clients) != len(pool) { - t.Fatalf("Expected %d grpc clients but found %d", len(pool), len(g.clients)) - } - - err = g.OnShutdown(p) - if err != nil { - t.Fatalf("Error stopping grpc client exchanger: %s", err) - } - if len(g.clients) != 0 { - t.Errorf("Shutdown didn't remove clients, found %d", len(g.clients)) - } - if len(g.conns) != 0 { - t.Errorf("Shutdown didn't remove conns, found %d", len(g.conns)) - } -} - -func TestGRPCRunAQuery(t *testing.T) { - - pool, closePool, err := buildPool(2) - if err != nil { - t.Fatalf("Error creating the pool of upstream for the test : %s", err) - } - defer closePool() - - upstream := &staticUpstream{ - from: ".", - HealthCheck: healthcheck.HealthCheck{ - Hosts: pool, - }, - } - g := newGrpcClient(nil, upstream) - upstream.ex = g - - p := &Proxy{} - p.Upstreams = &[]Upstream{upstream} - - err = g.OnStartup(p) - if err != nil { - t.Fatalf("Error starting grpc client exchanger: %s", err) - } - // verify the client is usable, or an error is properly raised - state := request.Request{W: &test.ResponseWriter{}, Req: new(dns.Msg)} - g.Exchange(context.TODO(), "localhost:10053", state) - - // verify that you have proper error if the hostname is unknwn or not registered - _, err = g.Exchange(context.TODO(), "invalid:10055", state) - if err == nil { - t.Errorf("Expecting a proper error when querying gRPC client with invalid hostname : %s", err) - } - - err = g.OnShutdown(p) - if err != nil { - t.Fatalf("Error stopping grpc client exchanger: %s", err) - } -} - -func TestGRPCRunAQueryOnSecureLinkWithInvalidCert(t *testing.T) { - - pool, closePool, err := buildPool(1) - if err != nil { - t.Fatalf("Error creating the pool of upstream for the test : %s", err) - } - defer closePool() - - upstream := &staticUpstream{ - from: ".", - HealthCheck: healthcheck.HealthCheck{ - Hosts: pool, - }, - } - - filename, rmFunc, err := test.TempFile("", aCert) - if err != nil { - t.Errorf("Error saving file : %s", err) - return - } - defer rmFunc() - - tls, _ := tls.NewTLSClientConfig(filename) - // ignore error as the certificate is known valid - - g := newGrpcClient(tls, upstream) - upstream.ex = g - - p := &Proxy{} - p.Upstreams = &[]Upstream{upstream} - - // Although dial will not work, it is not expected to have an error - err = g.OnStartup(p) - if err != nil { - t.Fatalf("Error starting grpc client exchanger: %s", err) - } - - // verify that you have proper error if the hostname is unknwn or not registered - state := request.Request{W: &test.ResponseWriter{}, Req: new(dns.Msg)} - _, err = g.Exchange(context.TODO(), pool[0].Name+"-whatever", state) - if err == nil { - t.Errorf("Error in Exchange process : %s ", err) - } - - err = g.OnShutdown(p) - if err != nil { - t.Fatalf("Error stopping grpc client exchanger: %s", err) - } -} - -// discard is a Logger that outputs nothing. -type discardV2 struct{} - -func (d discardV2) Info(args ...interface{}) {} -func (d discardV2) Infoln(args ...interface{}) {} -func (d discardV2) Infof(format string, args ...interface{}) {} -func (d discardV2) Warning(args ...interface{}) {} -func (d discardV2) Warningln(args ...interface{}) {} -func (d discardV2) Warningf(format string, args ...interface{}) {} -func (d discardV2) Error(args ...interface{}) {} -func (d discardV2) Errorln(args ...interface{}) {} -func (d discardV2) Errorf(format string, args ...interface{}) {} -func (d discardV2) Fatal(args ...interface{}) {} -func (d discardV2) Fatalln(args ...interface{}) {} -func (d discardV2) Fatalf(format string, args ...interface{}) {} -func (d discardV2) V(l int) bool { return true } - -const ( - aCert = `-----BEGIN CERTIFICATE----- - MIIDlDCCAnygAwIBAgIJAPaRnBJUE/FVMA0GCSqGSIb3DQEBBQUAMEUxCzAJBgNV -BAYTAkFVMRMwEQYDVQQIDApTb21lLVN0YXRlMSEwHwYDVQQKDBhJbnRlcm5ldCBX -aWRnaXRzIFB0eSBMdGQwHhcNMTcxMTI0MTM0OTQ3WhcNMTgxMTI0MTM0OTQ3WjBF -MQswCQYDVQQGEwJBVTETMBEGA1UECAwKU29tZS1TdGF0ZTEhMB8GA1UECgwYSW50 -ZXJuZXQgV2lkZ2l0cyBQdHkgTHRkMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIB -CgKCAQEAuTDeAoWS6tdZVcp/Vh3FlagbC+9Ohi5VjRXgkpcn9JopbcF5s2jpl1v+ -cRpqkrmNNKLh8qOhmgdZQdh185VNe/iZ94H42qwKZ48vvnC5hLkk3MdgUT2ewgup -vZhy/Bb1bX+buCWkQa1u8SIilECMIPZHhBP4TuBUKJWK8bBEFAeUnxB5SCkX+un4 -pctRlcfg8sX/ghADnp4e//YYDqex+1wQdFqM5zWhWDZAzc5Kdkyy9r+xXNfo4s1h -fI08f6F4skz1koxG2RXOzQ7OK4YxFwT2J6V72iyzUIlRGZTbYDvair/zm1kjTF1R -B1B+XLJF9oIB4BMZbekf033ZVaQ8YwIDAQABo4GGMIGDMDMGA1UdEQQsMCqHBH8A -AAGHBDR3AQGHBDR3AQCHBDR3KmSHBDR3KGSHBDR3KmWHBDR3KtIwHQYDVR0OBBYE -FFAEccLm7D/rN3fEe1fwzH7p0spAMB8GA1UdIwQYMBaAFFAEccLm7D/rN3fEe1fw -zH7p0spAMAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEFBQADggEBAF4zqaucNcK2 -GwYfijwbbtgMqPEvbReUEXsC65riAPjksJQ9L2YxQ7K0RIugRizuD1DNQam+FSb0 -cZEMEKzvMUIexbhZNFINWXY2X9yUS/oZd5pWP0WYIhn6qhmLvzl9XpxNPVzBXYWe -duMECCigU2x5tAGmFa6g/pXXOoZCBRzFXwXiuNhSyhJEEwODjLZ6vgbySuU2jso3 -va4FKFDdVM16s1/RYOK5oM48XytCMB/JoYoSJHPfpt8LpVNAQEHMvPvHwuZBON/z -q8HFtDjT4pBpB8AfuzwtUZ/zJ5atwxa5+ahcqRnK2kX2RSINfyEy43FZjLlvjcGa -UIRTUJK1JKg= ------END CERTIFICATE-----` -) diff --git a/vendor/github.com/coredns/coredns/plugin/proxy/healthcheck_test.go b/vendor/github.com/coredns/coredns/plugin/proxy/healthcheck_test.go deleted file mode 100644 index 67f5d0f2..00000000 --- a/vendor/github.com/coredns/coredns/plugin/proxy/healthcheck_test.go +++ /dev/null @@ -1,60 +0,0 @@ -package proxy - -import ( - "fmt" - "net/http" - "net/http/httptest" - "strings" - "sync/atomic" - "testing" - "time" - - "github.com/coredns/coredns/plugin/test" - "github.com/coredns/coredns/request" - - "github.com/mholt/caddy/caddyfile" - "github.com/miekg/dns" -) - -func TestUnhealthy(t *testing.T) { - // High HC interval, we want to test the HC after failed queries. - config := "proxy . %s {\n health_check /healthcheck:%s 10s \nfail_timeout 100ms\n}" - - backend := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - r.Body.Close() - w.Write([]byte("OK")) - })) - defer backend.Close() - - port := backend.URL[17:] // Remove all crap up to the port - back := backend.URL[7:] // Remove http:// - - c := caddyfile.NewDispenser("testfile", strings.NewReader(fmt.Sprintf(config, back, port))) - upstreams, err := NewStaticUpstreams(&c) - if err != nil { - t.Errorf("Expected no error. Got: %s", err) - } - p := &Proxy{Upstreams: &upstreams} - m := new(dns.Msg) - m.SetQuestion("example.org.", dns.TypeA) - state := request.Request{W: &test.ResponseWriter{}, Req: m} - - // Should all fail. - for j := 0; j < failureCheck; j++ { - if _, err := p.Forward(state); err == nil { - t.Errorf("Expected error. Got: nil") - } - } - - fails := atomic.LoadInt32(&upstreams[0].(*staticUpstream).Hosts[0].Fails) - if fails != 3 { - t.Errorf("Expected %d fails, got %d", 3, fails) - } - // HC should be kicked off, and reset the counter to 0 - i := 0 - for fails != 0 { - fails = atomic.LoadInt32(&upstreams[0].(*staticUpstream).Hosts[0].Fails) - time.Sleep(100 * time.Microsecond) - i++ - } -} diff --git a/vendor/github.com/coredns/coredns/plugin/proxy/lookup.go b/vendor/github.com/coredns/coredns/plugin/proxy/lookup.go deleted file mode 100644 index 44bee4b0..00000000 --- a/vendor/github.com/coredns/coredns/plugin/proxy/lookup.go +++ /dev/null @@ -1,127 +0,0 @@ -package proxy - -// functions other plugin might want to use to do lookup in the same style as the proxy. - -import ( - "context" - "fmt" - "net" - "sync/atomic" - "time" - - "github.com/coredns/coredns/plugin/pkg/healthcheck" - "github.com/coredns/coredns/request" - - "github.com/miekg/dns" -) - -// NewLookup create a new proxy with the hosts in host and a Random policy. -func NewLookup(hosts []string) Proxy { return NewLookupWithOption(hosts, Options{}) } - -// NewLookupWithOption process creates a simple round robin forward with potentially forced proto for upstream. -func NewLookupWithOption(hosts []string, opts Options) Proxy { - p := Proxy{Next: nil} - - // TODO(miek): this needs to be unified with upstream.go's NewStaticUpstreams, caddy uses NewHost - // we should copy/make something similar. - upstream := &staticUpstream{ - from: ".", - HealthCheck: healthcheck.HealthCheck{ - FailTimeout: 5 * time.Second, - MaxFails: 3, - }, - ex: newDNSExWithOption(opts), - } - upstream.Hosts = make([]*healthcheck.UpstreamHost, len(hosts)) - - for i, host := range hosts { - uh := &healthcheck.UpstreamHost{ - Name: host, - FailTimeout: upstream.FailTimeout, - CheckDown: checkDownFunc(upstream), - } - - upstream.Hosts[i] = uh - } - p.Upstreams = &[]Upstream{upstream} - return p -} - -// Lookup will use name and type to forge a new message and will send that upstream. It will -// set any EDNS0 options correctly so that downstream will be able to process the reply. -func (p Proxy) Lookup(state request.Request, name string, typ uint16) (*dns.Msg, error) { - req := new(dns.Msg) - req.SetQuestion(name, typ) - state.SizeAndDo(req) - - state2 := request.Request{W: state.W, Req: req} - - return p.lookup(state2) -} - -// Forward forward the request in state as-is. Unlike Lookup that adds EDNS0 suffix to the message. -func (p Proxy) Forward(state request.Request) (*dns.Msg, error) { - return p.lookup(state) -} - -func (p Proxy) lookup(state request.Request) (*dns.Msg, error) { - upstream := p.match(state) - if upstream == nil { - return nil, errInvalidDomain - } - for { - start := time.Now() - reply := new(dns.Msg) - var backendErr error - - // Since Select() should give us "up" hosts, keep retrying - // hosts until timeout (or until we get a nil host). - for time.Since(start) < tryDuration { - host := upstream.Select() - if host == nil { - return nil, fmt.Errorf("%s: %s", errUnreachable, "no upstream host") - } - - // duplicated from proxy.go, but with a twist, we don't write the - // reply back to the client, we return it and there is no monitoring to update here. - - atomic.AddInt64(&host.Conns, 1) - - reply, backendErr = upstream.Exchanger().Exchange(context.TODO(), host.Name, state) - - atomic.AddInt64(&host.Conns, -1) - - if backendErr == nil { - - if !state.Match(reply) { - return state.ErrorMessage(dns.RcodeFormatError), nil - } - - return reply, nil - } - - if oe, ok := backendErr.(*net.OpError); ok { - if oe.Timeout() { // see proxy.go for docs. - continue - } - } - - timeout := host.FailTimeout - if timeout == 0 { - timeout = defaultFailTimeout - } - - atomic.AddInt32(&host.Fails, 1) - fails := atomic.LoadInt32(&host.Fails) - - go func(host *healthcheck.UpstreamHost, timeout time.Duration) { - time.Sleep(timeout) - atomic.AddInt32(&host.Fails, -1) - if fails%failureCheck == 0 { // Kick off healthcheck on eveyry third failure. - host.HealthCheckURL() - } - }(host, timeout) - } - return nil, fmt.Errorf("%s: %s", errUnreachable, backendErr) - } -} diff --git a/vendor/github.com/coredns/coredns/plugin/proxy/metrics.go b/vendor/github.com/coredns/coredns/plugin/proxy/metrics.go deleted file mode 100644 index e5d6139b..00000000 --- a/vendor/github.com/coredns/coredns/plugin/proxy/metrics.go +++ /dev/null @@ -1,40 +0,0 @@ -package proxy - -import ( - "sync" - - "github.com/coredns/coredns/plugin" - - "github.com/prometheus/client_golang/prometheus" -) - -// Metrics the proxy plugin exports. -var ( - RequestCount = prometheus.NewCounterVec(prometheus.CounterOpts{ - Namespace: plugin.Namespace, - Subsystem: "proxy", - Name: "request_count_total", - Help: "Counter of requests made per protocol, proxy protocol, family and upstream.", - }, []string{"server", "proto", "proxy_proto", "family", "to"}) - RequestDuration = prometheus.NewHistogramVec(prometheus.HistogramOpts{ - Namespace: plugin.Namespace, - Subsystem: "proxy", - Name: "request_duration_seconds", - Buckets: plugin.TimeBuckets, - Help: "Histogram of the time (in seconds) each request took.", - }, []string{"server", "proto", "proxy_proto", "family", "to"}) -) - -// familyToString returns the string form of either 1, or 2. Returns -// empty string is not a known family -func familyToString(f int) string { - if f == 1 { - return "1" - } - if f == 2 { - return "2" - } - return "" -} - -var once sync.Once diff --git a/vendor/github.com/coredns/coredns/plugin/proxy/proxy.go b/vendor/github.com/coredns/coredns/plugin/proxy/proxy.go deleted file mode 100644 index 2a8e3509..00000000 --- a/vendor/github.com/coredns/coredns/plugin/proxy/proxy.go +++ /dev/null @@ -1,183 +0,0 @@ -// Package proxy is plugin that proxies requests. -package proxy - -import ( - "context" - "errors" - "fmt" - "net" - "sync/atomic" - "time" - - "github.com/coredns/coredns/plugin" - "github.com/coredns/coredns/plugin/metrics" - "github.com/coredns/coredns/plugin/pkg/healthcheck" - "github.com/coredns/coredns/request" - - "github.com/miekg/dns" - ot "github.com/opentracing/opentracing-go" -) - -var ( - errUnreachable = errors.New("unreachable backend") - errInvalidProtocol = errors.New("invalid protocol") - errInvalidDomain = errors.New("invalid path for proxy") -) - -// Proxy represents a plugin instance that can proxy requests to another (DNS) server. -type Proxy struct { - Next plugin.Handler - - // Upstreams is a pointer to a slice, so we can update the upstream (used for Google) - // midway. - - Upstreams *[]Upstream - - // Trace is the Trace plugin, if it is installed - // This is used by the grpc exchanger to trace through the grpc calls - Trace plugin.Handler -} - -// Upstream manages a pool of proxy upstream hosts. Select should return a -// suitable upstream host, or nil if no such hosts are available. -type Upstream interface { - // The domain name this upstream host should be routed on. - From() string - // Selects an upstream host to be routed to. - Select() *healthcheck.UpstreamHost - // Checks if subpdomain is not an ignored. - IsAllowedDomain(string) bool - // Exchanger returns the exchanger to be used for this upstream. - Exchanger() Exchanger - // Stops the upstream from proxying requests to shutdown goroutines cleanly. - Stop() error -} - -// tryDuration is how long to try upstream hosts; failures result in -// immediate retries until this duration ends or we get a nil host. -var tryDuration = 16 * time.Second - -// ServeDNS satisfies the plugin.Handler interface. -func (p Proxy) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (int, error) { - var span, child ot.Span - span = ot.SpanFromContext(ctx) - state := request.Request{W: w, Req: r} - - upstream := p.match(state) - if upstream == nil { - return plugin.NextOrFailure(p.Name(), p.Next, ctx, w, r) - } - - for { - start := time.Now() - reply := new(dns.Msg) - var backendErr error - - // Since Select() should give us "up" hosts, keep retrying - // hosts until timeout (or until we get a nil host). - for time.Since(start) < tryDuration { - host := upstream.Select() - if host == nil { - return dns.RcodeServerFailure, fmt.Errorf("%s: %s", errUnreachable, "no upstream host") - } - - if span != nil { - child = span.Tracer().StartSpan("exchange", ot.ChildOf(span.Context())) - ctx = ot.ContextWithSpan(ctx, child) - } - - atomic.AddInt64(&host.Conns, 1) - - RequestCount.WithLabelValues(metrics.WithServer(ctx), state.Proto(), upstream.Exchanger().Protocol(), familyToString(state.Family()), host.Name).Add(1) - - reply, backendErr = upstream.Exchanger().Exchange(ctx, host.Name, state) - - atomic.AddInt64(&host.Conns, -1) - - if child != nil { - child.Finish() - } - - taperr := toDnstap(ctx, host.Name, upstream.Exchanger(), state, reply, start) - - if backendErr == nil { - - // Check if the reply is correct; if not return FormErr. - if !state.Match(reply) { - formerr := state.ErrorMessage(dns.RcodeFormatError) - w.WriteMsg(formerr) - return 0, taperr - } - - w.WriteMsg(reply) - - RequestDuration.WithLabelValues(metrics.WithServer(ctx), state.Proto(), upstream.Exchanger().Protocol(), familyToString(state.Family()), host.Name).Observe(time.Since(start).Seconds()) - - return 0, taperr - } - - // A "ANY isc.org" query is being dropped by ISC's nameserver, we see this as a i/o timeout, but - // would then mark our upstream is being broken. We should not do this if we consider the error temporary. - // Of course it could really be that our upstream is broken - if oe, ok := backendErr.(*net.OpError); ok { - // Note this keeps looping and trying until tryDuration is hit, at which point our client - // might be long gone... - if oe.Timeout() { - // Our upstream's upstream is problably messing up, continue with next selected - // host - which my be the *same* one as we don't set any uh.Fails. - continue - } - } - - timeout := host.FailTimeout - if timeout == 0 { - timeout = defaultFailTimeout - } - - atomic.AddInt32(&host.Fails, 1) - fails := atomic.LoadInt32(&host.Fails) - - go func(host *healthcheck.UpstreamHost, timeout time.Duration) { - time.Sleep(timeout) - // we may go negative here, should be rectified by the HC. - atomic.AddInt32(&host.Fails, -1) - if fails%failureCheck == 0 { // Kick off healthcheck on eveyry third failure. - host.HealthCheckURL() - } - }(host, timeout) - } - - return dns.RcodeServerFailure, fmt.Errorf("%s: %s", errUnreachable, backendErr) - } -} - -func (p Proxy) match(state request.Request) (u Upstream) { - if p.Upstreams == nil { - return nil - } - - longestMatch := 0 - for _, upstream := range *p.Upstreams { - from := upstream.From() - - if !plugin.Name(from).Matches(state.Name()) || !upstream.IsAllowedDomain(state.Name()) { - continue - } - - if lf := len(from); lf > longestMatch { - longestMatch = lf - u = upstream - } - } - return u - -} - -// Name implements the Handler interface. -func (p Proxy) Name() string { return "proxy" } - -const ( - defaultFailTimeout = 2 * time.Second - defaultTimeout = 5 * time.Second - failureCheck = 3 -) diff --git a/vendor/github.com/coredns/coredns/plugin/proxy/proxy_test.go b/vendor/github.com/coredns/coredns/plugin/proxy/proxy_test.go deleted file mode 100644 index 3057715a..00000000 --- a/vendor/github.com/coredns/coredns/plugin/proxy/proxy_test.go +++ /dev/null @@ -1,99 +0,0 @@ -package proxy - -import ( - "fmt" - "net/http" - "net/http/httptest" - "strings" - "sync/atomic" - "testing" - "time" - - "github.com/coredns/coredns/plugin/pkg/dnstest" - "github.com/coredns/coredns/plugin/test" - "github.com/coredns/coredns/request" - - "github.com/mholt/caddy/caddyfile" - "github.com/miekg/dns" -) - -func TestStop(t *testing.T) { - config := "proxy . %s {\n health_check /healthcheck:%s %dms \n}" - tests := []struct { - intervalInMilliseconds int - numHealthcheckIntervals int - }{ - {5, 1}, - {5, 2}, - {5, 3}, - } - - for i, test := range tests { - t.Run(fmt.Sprintf("Test %d", i), func(t *testing.T) { - - // Set up proxy. - var counter int64 - backend := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - r.Body.Close() - atomic.AddInt64(&counter, 1) - })) - - defer backend.Close() - - port := backend.URL[17:] // Remove all crap up to the port - back := backend.URL[7:] // Remove http:// - c := caddyfile.NewDispenser("Testfile", strings.NewReader(fmt.Sprintf(config, back, port, test.intervalInMilliseconds))) - upstreams, err := NewStaticUpstreams(&c) - if err != nil { - t.Errorf("Test %d, expected no error. Got: %s", i, err) - } - - // Give some time for healthchecks to hit the server. - time.Sleep(time.Duration(test.intervalInMilliseconds*test.numHealthcheckIntervals) * time.Millisecond) - - for _, upstream := range upstreams { - if err := upstream.Stop(); err != nil { - t.Errorf("Test %d, expected no error stopping upstream, got: %s", i, err) - } - } - - counterAfterShutdown := atomic.LoadInt64(&counter) - - // Give some time to see if healthchecks are still hitting the server. - time.Sleep(time.Duration(test.intervalInMilliseconds*test.numHealthcheckIntervals) * time.Millisecond) - - if counterAfterShutdown == 0 { - t.Errorf("Test %d, Expected healthchecks to hit test server, got none", i) - } - - // health checks are in a go routine now, so one may well occur after we shutdown, - // but we only ever expect one more - counterAfterWaiting := atomic.LoadInt64(&counter) - if counterAfterWaiting > (counterAfterShutdown + 1) { - t.Errorf("Test %d, expected no more healthchecks after shutdown. got: %d healthchecks after shutdown", i, counterAfterWaiting-counterAfterShutdown) - } - }) - } -} - -func TestProxyRefused(t *testing.T) { - s := dnstest.NewServer(func(w dns.ResponseWriter, r *dns.Msg) { - ret := new(dns.Msg) - ret.SetReply(r) - ret.Rcode = dns.RcodeRefused - w.WriteMsg(ret) - }) - defer s.Close() - - p := NewLookup([]string{s.Addr}) - - state := request.Request{W: &test.ResponseWriter{}, Req: new(dns.Msg)} - state.Req.SetQuestion("example.org.", dns.TypeA) - resp, err := p.Forward(state) - if err != nil { - t.Fatal("Expected to receive reply, but didn't") - } - if resp.Rcode != dns.RcodeRefused { - t.Errorf("Expected rcode to be %d, got %d", dns.RcodeRefused, resp.Rcode) - } -} diff --git a/vendor/github.com/coredns/coredns/plugin/proxy/response.go b/vendor/github.com/coredns/coredns/plugin/proxy/response.go deleted file mode 100644 index 2ad553c4..00000000 --- a/vendor/github.com/coredns/coredns/plugin/proxy/response.go +++ /dev/null @@ -1,21 +0,0 @@ -package proxy - -import ( - "net" - - "github.com/miekg/dns" -) - -type fakeBootWriter struct { - dns.ResponseWriter -} - -func (w *fakeBootWriter) LocalAddr() net.Addr { - local := net.ParseIP("127.0.0.1") - return &net.UDPAddr{IP: local, Port: 53} // Port is not used here -} - -func (w *fakeBootWriter) RemoteAddr() net.Addr { - remote := net.ParseIP("8.8.8.8") - return &net.UDPAddr{IP: remote, Port: 53} // Port is not used here -} diff --git a/vendor/github.com/coredns/coredns/plugin/proxy/setup.go b/vendor/github.com/coredns/coredns/plugin/proxy/setup.go deleted file mode 100644 index 279e02ca..00000000 --- a/vendor/github.com/coredns/coredns/plugin/proxy/setup.go +++ /dev/null @@ -1,53 +0,0 @@ -package proxy - -import ( - "github.com/coredns/coredns/core/dnsserver" - "github.com/coredns/coredns/plugin" - "github.com/coredns/coredns/plugin/metrics" - clog "github.com/coredns/coredns/plugin/pkg/log" - - "github.com/mholt/caddy" -) - -var log = clog.NewWithPlugin("proxy") - -func init() { - caddy.RegisterPlugin("proxy", caddy.Plugin{ - ServerType: "dns", - Action: setup, - }) -} - -func setup(c *caddy.Controller) error { - upstreams, err := NewStaticUpstreams(&c.Dispenser) - if err != nil { - return plugin.Error("proxy", err) - } - - t := dnsserver.GetConfig(c).Handler("trace") - P := &Proxy{Trace: t} - dnsserver.GetConfig(c).AddPlugin(func(next plugin.Handler) plugin.Handler { - P.Next = next - P.Upstreams = &upstreams - return P - }) - - c.OnStartup(func() error { - once.Do(func() { metrics.MustRegister(c, RequestCount, RequestDuration) }) - return nil - }) - - for i := range upstreams { - u := upstreams[i] - c.OnStartup(func() error { - return u.Exchanger().OnStartup(P) - }) - c.OnShutdown(func() error { - return u.Exchanger().OnShutdown(P) - }) - // Register shutdown handlers. - c.OnShutdown(u.Stop) - } - - return nil -} diff --git a/vendor/github.com/coredns/coredns/plugin/proxy/upstream.go b/vendor/github.com/coredns/coredns/plugin/proxy/upstream.go deleted file mode 100644 index be3e0bda..00000000 --- a/vendor/github.com/coredns/coredns/plugin/proxy/upstream.go +++ /dev/null @@ -1,205 +0,0 @@ -package proxy - -import ( - "fmt" - "net" - "strconv" - "time" - - "github.com/coredns/coredns/plugin" - "github.com/coredns/coredns/plugin/pkg/dnsutil" - "github.com/coredns/coredns/plugin/pkg/healthcheck" - "github.com/coredns/coredns/plugin/pkg/tls" - "github.com/mholt/caddy/caddyfile" - "github.com/miekg/dns" -) - -type staticUpstream struct { - from string - - healthcheck.HealthCheck - - IgnoredSubDomains []string - ex Exchanger -} - -// NewStaticUpstreams parses the configuration input and sets up -// static upstreams for the proxy plugin. -func NewStaticUpstreams(c *caddyfile.Dispenser) ([]Upstream, error) { - var upstreams []Upstream - for c.Next() { - u, err := NewStaticUpstream(c) - if err != nil { - return upstreams, err - } - upstreams = append(upstreams, u) - } - return upstreams, nil -} - -// NewStaticUpstream parses the configuration of a single upstream -// starting from the FROM -func NewStaticUpstream(c *caddyfile.Dispenser) (Upstream, error) { - upstream := &staticUpstream{ - from: ".", - HealthCheck: healthcheck.HealthCheck{ - FailTimeout: 5 * time.Second, - MaxFails: 3, - }, - ex: newDNSEx(), - } - - if !c.Args(&upstream.from) { - return upstream, c.ArgErr() - } - upstream.from = plugin.Host(upstream.from).Normalize() - - to := c.RemainingArgs() - if len(to) == 0 { - return upstream, c.ArgErr() - } - - // process the host list, substituting in any nameservers in files - toHosts, err := dnsutil.ParseHostPortOrFile(to...) - if err != nil { - return upstream, err - } - - if len(toHosts) > max { - return upstream, fmt.Errorf("more than %d TOs configured: %d", max, len(toHosts)) - } - - for c.NextBlock() { - if err := parseBlock(c, upstream); err != nil { - return upstream, err - } - } - - upstream.Hosts = make([]*healthcheck.UpstreamHost, len(toHosts)) - - for i, host := range toHosts { - uh := &healthcheck.UpstreamHost{ - Name: host, - FailTimeout: upstream.FailTimeout, - CheckDown: checkDownFunc(upstream), - } - upstream.Hosts[i] = uh - } - upstream.Start() - - return upstream, nil -} - -func parseBlock(c *caddyfile.Dispenser, u *staticUpstream) error { - switch c.Val() { - case "policy": - if !c.NextArg() { - return c.ArgErr() - } - policyCreateFunc, ok := healthcheck.SupportedPolicies[c.Val()] - if !ok { - return c.ArgErr() - } - u.Policy = policyCreateFunc() - case "fail_timeout": - if !c.NextArg() { - return c.ArgErr() - } - dur, err := time.ParseDuration(c.Val()) - if err != nil { - return err - } - u.FailTimeout = dur - case "max_fails": - if !c.NextArg() { - return c.ArgErr() - } - n, err := strconv.Atoi(c.Val()) - if err != nil { - return err - } - u.MaxFails = int32(n) - case "health_check": - if !c.NextArg() { - return c.ArgErr() - } - var err error - u.HealthCheck.Path, u.HealthCheck.Port, err = net.SplitHostPort(c.Val()) - if err != nil { - return err - } - u.HealthCheck.Interval = 4 * time.Second - if c.NextArg() { - dur, err := time.ParseDuration(c.Val()) - if err != nil { - return err - } - u.HealthCheck.Interval = dur - } - case "except": - ignoredDomains := c.RemainingArgs() - if len(ignoredDomains) == 0 { - return c.ArgErr() - } - for i := 0; i < len(ignoredDomains); i++ { - ignoredDomains[i] = plugin.Host(ignoredDomains[i]).Normalize() - } - u.IgnoredSubDomains = ignoredDomains - case "spray": - u.Spray = &healthcheck.Spray{} - case "protocol": - encArgs := c.RemainingArgs() - if len(encArgs) == 0 { - return c.ArgErr() - } - switch encArgs[0] { - case "dns": - if len(encArgs) > 1 { - if encArgs[1] == "force_tcp" { - opts := Options{ForceTCP: true} - u.ex = newDNSExWithOption(opts) - } else { - return fmt.Errorf("only force_tcp allowed as parameter to dns") - } - } else { - u.ex = newDNSEx() - } - case "https_google": - // allow the config, but make noop - case "grpc": - if len(encArgs) == 2 && encArgs[1] == "insecure" { - u.ex = newGrpcClient(nil, u) - return nil - } - tls, err := tls.NewTLSConfigFromArgs(encArgs[1:]...) - if err != nil { - return err - } - u.ex = newGrpcClient(tls, u) - default: - return fmt.Errorf("%s: %s", errInvalidProtocol, encArgs[0]) - } - - default: - return c.Errf("unknown property '%s'", c.Val()) - } - return nil -} - -func (u *staticUpstream) IsAllowedDomain(name string) bool { - if dns.Name(name) == dns.Name(u.From()) { - return true - } - - for _, ignoredSubDomain := range u.IgnoredSubDomains { - if plugin.Name(ignoredSubDomain).Matches(name) { - return false - } - } - return true -} - -func (u *staticUpstream) Exchanger() Exchanger { return u.ex } -func (u *staticUpstream) From() string { return u.from } - -const max = 15 diff --git a/vendor/github.com/coredns/coredns/plugin/proxy/upstream_test.go b/vendor/github.com/coredns/coredns/plugin/proxy/upstream_test.go deleted file mode 100644 index 6fec3e30..00000000 --- a/vendor/github.com/coredns/coredns/plugin/proxy/upstream_test.go +++ /dev/null @@ -1,327 +0,0 @@ -package proxy - -import ( - "path/filepath" - "strings" - "testing" - - "github.com/coredns/coredns/plugin/test" - - "github.com/mholt/caddy" -) - -func TestAllowedDomain(t *testing.T) { - upstream := &staticUpstream{ - from: "miek.nl.", - IgnoredSubDomains: []string{"download.miek.nl.", "static.miek.nl."}, // closing dot mandatory - } - tests := []struct { - name string - expected bool - }{ - {"miek.nl.", true}, - {"download.miek.nl.", false}, - {"static.miek.nl.", false}, - {"blaat.miek.nl.", true}, - } - - for i, test := range tests { - isAllowed := upstream.IsAllowedDomain(test.name) - if test.expected != isAllowed { - t.Errorf("Test %d: expected %v found %v for %s", i+1, test.expected, isAllowed, test.name) - } - } -} - -func TestProxyParse(t *testing.T) { - rmFunc, cert, key, ca := getPEMFiles(t) - defer rmFunc() - - grpc1 := "proxy . 8.8.8.8:53 {\n protocol grpc " + ca + "\n}" - grpc2 := "proxy . 8.8.8.8:53 {\n protocol grpc " + cert + " " + key + "\n}" - grpc3 := "proxy . 8.8.8.8:53 {\n protocol grpc " + cert + " " + key + " " + ca + "\n}" - grpc4 := "proxy . 8.8.8.8:53 {\n protocol grpc " + key + "\n}" - - tests := []struct { - inputUpstreams string - shouldErr bool - }{ - { - `proxy . 8.8.8.8:53`, - false, - }, - { - `proxy 10.0.0.0/24 8.8.8.8:53`, - false, - }, - { - ` -proxy . 8.8.8.8:53 { - policy round_robin -}`, - false, - }, - { - ` -proxy . 8.8.8.8:53 { - fail_timeout 5s -}`, - false, - }, - { - ` -proxy . 8.8.8.8:53 { - max_fails 10 -}`, - false, - }, - { - ` -proxy . 8.8.8.8:53 { - health_check /health:8080 -}`, - false, - }, - { - ` -proxy . 8.8.8.8:53 { - except miek.nl example.org 10.0.0.0/24 -}`, - false, - }, - { - ` -proxy . 8.8.8.8:53 { - spray -}`, - false, - }, - { - ` -proxy . 8.8.8.8:53 { - error_option -}`, - true, - }, - { - ` -proxy . some_bogus_filename`, - true, - }, - { - ` -proxy . 8.8.8.8:53 { - protocol dns -}`, - false, - }, - { - ` -proxy . 8.8.8.8:53 { - protocol grpc -}`, - false, - }, - { - ` -proxy . 8.8.8.8:53 { - protocol grpc insecure -}`, - false, - }, - { - ` -proxy . 8.8.8.8:53 { - protocol dns force_tcp -}`, - false, - }, - { - ` -proxy . 8.8.8.8:53 { - protocol grpc a b c d -}`, - true, - }, - { - grpc1, - false, - }, - { - grpc2, - false, - }, - { - grpc3, - false, - }, - { - grpc4, - true, - }, - { - ` -proxy . 8.8.8.8:53 { - protocol foobar -}`, - true, - }, - { - `proxy`, - true, - }, - { - ` -proxy . 8.8.8.8:53 { - protocol foobar -}`, - true, - }, - { - ` -proxy . 8.8.8.8:53 { - policy -}`, - true, - }, - { - ` -proxy . 8.8.8.8:53 { - fail_timeout -}`, - true, - }, - { - ` -proxy . 8.8.8.8:53 { - fail_timeout junky -}`, - true, - }, - { - ` -proxy . 8.8.8.8:53 { - health_check -}`, - true, - }, - { - ` -proxy . 8.8.8.8:53 { - protocol dns force -}`, - true, - }, - } - for i, test := range tests { - c := caddy.NewTestController("dns", test.inputUpstreams) - _, err := NewStaticUpstreams(&c.Dispenser) - if (err != nil) != test.shouldErr { - t.Errorf("Test %d expected no error, got %v for %s", i+1, err, test.inputUpstreams) - } - } -} - -func TestResolvParse(t *testing.T) { - tests := []struct { - inputUpstreams string - filedata string - shouldErr bool - expected []string - }{ - { - ` -proxy . FILE -`, - ` -nameserver 1.2.3.4 -nameserver 4.3.2.1 -`, - false, - []string{"1.2.3.4:53", "4.3.2.1:53"}, - }, - { - ` -proxy example.com 1.1.1.1:5000 -proxy . FILE -proxy example.org 2.2.2.2:1234 -`, - ` -nameserver 1.2.3.4 -`, - false, - []string{"1.1.1.1:5000", "1.2.3.4:53", "2.2.2.2:1234"}, - }, - { - ` -proxy example.com 1.1.1.1:5000 -proxy . FILE -proxy example.org 2.2.2.2:1234 -`, - ` -junky resolv.conf -`, - false, - []string{"1.1.1.1:5000", "2.2.2.2:1234"}, - }, - } - for i, tc := range tests { - - path, rm, err := test.TempFile(".", tc.filedata) - if err != nil { - t.Fatalf("Test %d could not creat temp file %v", i, err) - } - defer rm() - - config := strings.Replace(tc.inputUpstreams, "FILE", path, -1) - c := caddy.NewTestController("dns", config) - upstreams, err := NewStaticUpstreams(&c.Dispenser) - if (err != nil) != tc.shouldErr { - t.Errorf("Test %d expected no error, got %v", i+1, err) - } - var hosts []string - for _, u := range upstreams { - for _, h := range u.(*staticUpstream).Hosts { - hosts = append(hosts, h.Name) - } - } - if !tc.shouldErr { - if len(hosts) != len(tc.expected) { - t.Errorf("Test %d expected %d hosts got %d", i+1, len(tc.expected), len(upstreams)) - } else { - ok := true - for i, v := range tc.expected { - if v != hosts[i] { - ok = false - } - } - if !ok { - t.Errorf("Test %d expected %v got %v", i+1, tc.expected, upstreams) - } - } - } - } -} - -func TestMaxTo(t *testing.T) { - // Has 16 IP addresses. - config := `proxy . 1.1.1.1 1.1.1.1 1.1.1.1 1.1.1.1 1.1.1.1 1.1.1.1 1.1.1.1 1.1.1.1 1.1.1.1 1.1.1.1 1.1.1.1 1.1.1.1 1.1.1.1 1.1.1.1 1.1.1.1 1.1.1.1` - c := caddy.NewTestController("dns", config) - _, err := NewStaticUpstreams(&c.Dispenser) - if err == nil { - t.Error("Expected to many TOs configured, but nil") - } -} - -func getPEMFiles(t *testing.T) (rmFunc func(), cert, key, ca string) { - tempDir, rmFunc, err := test.WritePEMFiles("") - if err != nil { - t.Fatalf("Could not write PEM files: %s", err) - } - - cert = filepath.Join(tempDir, "cert.pem") - key = filepath.Join(tempDir, "key.pem") - ca = filepath.Join(tempDir, "ca.pem") - - return -} diff --git a/vendor/github.com/coredns/coredns/plugin/reload/OWNERS b/vendor/github.com/coredns/coredns/plugin/reload/OWNERS deleted file mode 100644 index f7f9ca27..00000000 --- a/vendor/github.com/coredns/coredns/plugin/reload/OWNERS +++ /dev/null @@ -1,4 +0,0 @@ -reviewers: - - johnbelamaric -approvers: - - johnbelamaric diff --git a/vendor/github.com/coredns/coredns/plugin/reload/README.md b/vendor/github.com/coredns/coredns/plugin/reload/README.md deleted file mode 100644 index 4c98b7a7..00000000 --- a/vendor/github.com/coredns/coredns/plugin/reload/README.md +++ /dev/null @@ -1,90 +0,0 @@ -# reload - -## Name - -*reload* - allows automatic reload of a changed Corefile - -## Description - -This plugin allows automatic reload of a changed _Corefile_. -To enable automatic reloading of _zone file_ changes, use the `auto` plugin. - -This plugin periodically checks if the Corefile has changed by reading -it and calculating its MD5 checksum. If the file has changed, it reloads -CoreDNS with the new Corefile. This eliminates the need to send a SIGHUP -or SIGUSR1 after changing the Corefile. - -The reloads are graceful - you should not see any loss of service when the -reload happens. Even if the new Corefile has an error, CoreDNS will continue -to run the old config and an error message will be printed to the log. But see -the Bugs section for failure modes. - -In some environments (for example, Kubernetes), there may be many CoreDNS -instances that started very near the same time and all share a common -Corefile. To prevent these all from reloading at the same time, some -jitter is added to the reload check interval. This is jitter from the -perspective of multiple CoreDNS instances; each instance still checks on a -regular interval, but all of these instances will have their reloads spread -out across the jitter duration. This isn't strictly necessary given that the -reloads are graceful, and can be disabled by setting the jitter to `0s`. - -Jitter is re-calculated whenever the Corefile is reloaded. - -This plugin can only be used once per Server Block. - -## Syntax - -~~~ txt -reload [INTERVAL] [JITTER] -~~~ - -* The plugin will check for changes every **INTERVAL**, subject to +/- the **JITTER** duration -* **INTERVAL** and **JITTER** are Golang (durations)[https://golang.org/pkg/time/#ParseDuration] -* Default **INTERVAL** is 30s, default **JITTER** is 15s -* Minimal value for **INTERVAL** is 2s, and for **JITTER** is 1s -* If **JITTER** is more than half of **INTERVAL**, it will be set to half of **INTERVAL** - -## Examples - -Check with the default intervals: - -~~~ corefile -. { - reload - erratic -} -~~~ - -Check every 10 seconds (jitter is automatically set to 10 / 2 = 5 in this case): - -~~~ corefile -. { - reload 10s - erratic -} -~~~ - -## Bugs - -The reload happens without data loss (i.e. DNS queries keep flowing), but there is a corner case -where the reload fails, and you loose functionality. Consider the following Corefile: - -~~~ txt -. { - health :8080 - whoami -} -~~~ - -CoreDNS starts and serves health from :8080. Now you change `:8080` to `:443` not knowing a process -is already listening on that port. The process reloads and performs the following steps: - -1. close the listener on 8080 -2. reload and parse the config again -3. fail to start a new listener on 443 -4. fail loading the new Corefile, abort and keep using the old process - -After the aborted attempt to reload we are left with the old proceses running, but the listener is -closed in step 1; so the health endpoint is broken. The same can hopen in the prometheus metrics plugin. - -In general be careful with assigning new port and expecting reload to work fully. diff --git a/vendor/github.com/coredns/coredns/plugin/reload/reload.go b/vendor/github.com/coredns/coredns/plugin/reload/reload.go deleted file mode 100644 index d04bb037..00000000 --- a/vendor/github.com/coredns/coredns/plugin/reload/reload.go +++ /dev/null @@ -1,75 +0,0 @@ -package reload - -import ( - "crypto/md5" - "time" - - "github.com/mholt/caddy" -) - -// reload periodically checks if the Corefile has changed, and reloads if so -const ( - unused = 0 - maybeUsed = 1 - used = 2 -) - -type reload struct { - interval time.Duration - usage int - quit chan bool -} - -func hook(event caddy.EventName, info interface{}) error { - if event != caddy.InstanceStartupEvent { - return nil - } - - // if reload is removed from the Corefile, then the hook - // is still registered but setup is never called again - // so we need a flag to tell us not to reload - if r.usage == unused { - return nil - } - - // this should be an instance. ok to panic if not - instance := info.(*caddy.Instance) - md5sum := md5.Sum(instance.Caddyfile().Body()) - log.Infof("Running configuration MD5 = %x\n", md5sum) - - go func() { - tick := time.NewTicker(r.interval) - - for { - select { - case <-tick.C: - corefile, err := caddy.LoadCaddyfile(instance.Caddyfile().ServerType()) - if err != nil { - continue - } - s := md5.Sum(corefile.Body()) - if s != md5sum { - // Let not try to restart with the same file, even though it is wrong. - md5sum = s - // now lets consider that plugin will not be reload, unless appear in next config file - // change status iof usage will be reset in setup if the plugin appears in config file - r.usage = maybeUsed - _, err := instance.Restart(corefile) - if err != nil { - log.Errorf("Corefile changed but reload failed: %s\n", err) - continue - } - // we are done, if the plugin was not set used, then it is not. - if r.usage == maybeUsed { - r.usage = unused - } - return - } - case <-r.quit: - return - } - } - }() - - return nil -} diff --git a/vendor/github.com/coredns/coredns/plugin/reload/setup.go b/vendor/github.com/coredns/coredns/plugin/reload/setup.go deleted file mode 100644 index c6b33e95..00000000 --- a/vendor/github.com/coredns/coredns/plugin/reload/setup.go +++ /dev/null @@ -1,94 +0,0 @@ -package reload - -import ( - "fmt" - "math/rand" - "sync" - "time" - - "github.com/coredns/coredns/plugin" - clog "github.com/coredns/coredns/plugin/pkg/log" - - "github.com/mholt/caddy" -) - -var log = clog.NewWithPlugin("reload") - -func init() { - caddy.RegisterPlugin("reload", caddy.Plugin{ - ServerType: "dns", - Action: setup, - }) -} - -// the info reload is global to all application, whatever number of reloads. -// it is used to transmit data between Setup and start of the hook called 'onInstanceStartup' -// channel for QUIT is never changed in purpose. -// WARNING: this data may be unsync after an invalid attempt of reload Corefile. -var r = reload{interval: defaultInterval, usage: unused, quit: make(chan bool)} -var once sync.Once -var shutOnce sync.Once - -func setup(c *caddy.Controller) error { - c.Next() // 'reload' - args := c.RemainingArgs() - - if len(args) > 2 { - return plugin.Error("reload", c.ArgErr()) - } - - i := defaultInterval - if len(args) > 0 { - d, err := time.ParseDuration(args[0]) - if err != nil { - return plugin.Error("reload", err) - } - i = d - } - if i < minInterval { - return plugin.Error("reload", fmt.Errorf("interval value must be greater or equal to %v", minInterval)) - } - - j := defaultJitter - if len(args) > 1 { - d, err := time.ParseDuration(args[1]) - if err != nil { - return plugin.Error("reload", err) - } - j = d - } - if j < minJitter { - return plugin.Error("reload", fmt.Errorf("jitter value must be greater or equal to %v", minJitter)) - } - - if j > i/2 { - j = i / 2 - } - - jitter := time.Duration(rand.Int63n(j.Nanoseconds()) - (j.Nanoseconds() / 2)) - i = i + jitter - - // prepare info for next onInstanceStartup event - r.interval = i - r.usage = used - - once.Do(func() { - caddy.RegisterEventHook("reload", hook) - }) - - // re-register on finalShutDown as the instance most-likely will be changed - shutOnce.Do(func() { - c.OnFinalShutdown(func() error { - r.quit <- true - return nil - }) - }) - return nil -} - -const ( - minJitter = 1 * time.Second - minInterval = 2 * time.Second - defaultInterval = 30 * time.Second - defaultJitter = 15 * time.Second -) diff --git a/vendor/github.com/coredns/coredns/plugin/reload/setup_test.go b/vendor/github.com/coredns/coredns/plugin/reload/setup_test.go deleted file mode 100644 index a647cd2a..00000000 --- a/vendor/github.com/coredns/coredns/plugin/reload/setup_test.go +++ /dev/null @@ -1,51 +0,0 @@ -package reload - -import ( - "testing" - - "github.com/mholt/caddy" -) - -func TestSetupReload(t *testing.T) { - c := caddy.NewTestController("dns", `reload`) - if err := setup(c); err != nil { - t.Fatalf("Expected no errors, but got: %v", err) - } - - c = caddy.NewTestController("dns", `reload 10s`) - if err := setup(c); err != nil { - t.Fatalf("Expected no errors, but got: %v", err) - } - - c = caddy.NewTestController("dns", `reload 10s 2s`) - if err := setup(c); err != nil { - t.Fatalf("Expected no errors, but got: %v", err) - } - - c = caddy.NewTestController("dns", `reload foo`) - if err := setup(c); err == nil { - t.Fatalf("Expected errors, but got: %v", err) - } - - c = caddy.NewTestController("dns", `reload 10s foo`) - if err := setup(c); err == nil { - t.Fatalf("Expected errors, but got: %v", err) - } - - c = caddy.NewTestController("dns", `reload 10s 5s foo`) - if err := setup(c); err == nil { - t.Fatalf("Expected errors, but got: %v", err) - } - c = caddy.NewTestController("dns", `reload 1s`) - if err := setup(c); err == nil { - t.Fatalf("Expected errors, but got: %v", err) - } - c = caddy.NewTestController("dns", `reload 0s`) - if err := setup(c); err == nil { - t.Fatalf("Expected errors, but got: %v", err) - } - c = caddy.NewTestController("dns", `reload 3s 0.5s`) - if err := setup(c); err == nil { - t.Fatalf("Expected errors, but got: %v", err) - } -} diff --git a/vendor/github.com/coredns/coredns/plugin/rewrite/OWNERS b/vendor/github.com/coredns/coredns/plugin/rewrite/OWNERS deleted file mode 100644 index b77031d8..00000000 --- a/vendor/github.com/coredns/coredns/plugin/rewrite/OWNERS +++ /dev/null @@ -1,6 +0,0 @@ -reviewers: - - greenpau - - johnbelamaric -approvers: - - greenpau - - johnbelamaric diff --git a/vendor/github.com/coredns/coredns/plugin/rewrite/README.md b/vendor/github.com/coredns/coredns/plugin/rewrite/README.md deleted file mode 100644 index 680e6972..00000000 --- a/vendor/github.com/coredns/coredns/plugin/rewrite/README.md +++ /dev/null @@ -1,244 +0,0 @@ -# rewrite - -## Name - -*rewrite* - performs internal message rewriting. - -## Description - -Rewrites are invisible to the client. There are simple rewrites (fast) and complex rewrites -(slower), but they're powerful enough to accommodate most dynamic back-end applications. - -## Syntax - -A simplified/easy to digest syntax for *rewrite* is... -~~~ -rewrite [continue|stop] FIELD FROM TO -~~~ - -* **FIELD** indicates what part of the request/response is being re-written. - - * `type` - the type field of the request will be rewritten. FROM/TO must be a DNS record type (`A`, `MX`, etc); -e.g., to rewrite ANY queries to HINFO, use `rewrite type ANY HINFO`. - * `class` - the class of the message will be rewritten. FROM/TO must be a DNS class type (`IN`, `CH`, or `HS`) e.g., to rewrite CH queries to IN use `rewrite class CH IN`. - * `name` - the query name in the _request_ is rewritten; by default this is a full match of the name, e.g., `rewrite name miek.nl example.org`. Other match types are supported, see the **Name Field Rewrites** section below. - * `answer name` - the query name in the _response_ is rewritten. This option has special restrictions and requirements, in particular it must always combined with a `name` rewrite. See below in the **Response Rewrites** section. - * `edns0` - an EDNS0 option can be appended to the request as described below in the **EDNS0 Options** section. - -* **FROM** is the name or type to match -* **TO** is the destination name or type to rewrite to - -If you specify multiple rules and an incoming query matches on multiple rules, the rewrite -will behave as following -* `continue` will continue apply the next rule in the rule list. -* `stop` will consider the current rule is the last rule and will not continue. Default behaviour -for not specifying this rule processing mode is `stop` - -### Name Field Rewrites - -The `rewrite` plugin offers the ability to match on the name in the question section of -a DNS request. The match could be exact, substring, or based on a prefix, suffix, or regular -expression. - -The syntax for the name re-writing is as follows: - -``` -rewrite [continue|stop] name [exact|prefix|suffix|substring|regex] STRING STRING -``` - -The match type, i.e. `exact`, `substring`, etc., triggers re-write: - -* **exact** (default): on exact match of the name in the question section of a request -* **substring**: on a partial match of the name in the question section of a request -* **prefix**: when the name begins with the matching string -* **suffix**: when the name ends with the matching string -* **regex**: when the name in the question section of a request matches a regular expression - -If the match type is omitted, the `exact` match type is being assumed. - -The following instruction allows re-writing the name in the query that -contains `service.us-west-1.example.org` substring. - -``` -rewrite name substring service.us-west-1.example.org service.us-west-1.consul -``` - -Thus: - -* Incoming Request Name: `ftp.service.us-west-1.example.org` -* Re-written Request Name: `ftp.service.us-west-1.consul` - -The following instruction uses regular expressions. The name in a request -matching `(.*)-(us-west-1)\.example\.org` regular expression is being replaces with -`{1}.service.{2}.consul`, where `{1}` and `{2}` are regular expression match groups. - -``` -rewrite name regex (.*)-(us-west-1)\.example\.org {1}.service.{2}.consul -``` - -Thus: - -* Incoming Request Name: `ftp-us-west-1.example.org` -* Re-written Request Name: `ftp.service.us-west-1.consul` - -### Response Rewrites - -When re-writing incoming DNS requests' names, CoreDNS re-writes the `QUESTION SECTION` -section of the requests. It may be necessary to re-write the `ANSWER SECTION` of the -requests, because some DNS resolvers would treat the mismatch between `QUESTION SECTION` -and `ANSWER SECTION` as a man-in-the-middle attack (MITM). - -For example, a user tries to resolve `ftp-us-west-1.coredns.rocks`. The -CoreDNS configuration file has the following rule: - -``` -rewrite name regex (.*)-(us-west-1)\.coredns\.rocks {1}.service.{2}.consul -``` - -CoreDNS instance re-wrote the request to `ftp-us-west-1.coredns.rocks` with -`ftp.service.us-west-1.consul` and ultimately resolved it to 3 records. -The resolved records, see `ANSWER SECTION`, were not from `coredns.rocks`, but -rather from `service.us-west-1.consul`. - - -``` -$ dig @10.1.1.1 ftp-us-west-1.coredns.rocks - -; <<>> DiG 9.8.3-P1 <<>> @10.1.1.1 ftp-us-west-1.coredns.rocks -; (1 server found) -;; global options: +cmd -;; Got answer: -;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 8619 -;; flags: qr aa rd ra; QUERY: 1, ANSWER: 3, AUTHORITY: 0, ADDITIONAL: 0 - -;; QUESTION SECTION: -;ftp-us-west-1.coredns.rocks. IN A - -;; ANSWER SECTION: -ftp.service.us-west-1.consul. 0 IN A 10.10.10.10 -ftp.service.us-west-1.consul. 0 IN A 10.20.20.20 -ftp.service.us-west-1.consul. 0 IN A 10.30.30.30 -``` - -The above is the mismatch. - -The following configuration snippet allows for the re-writing of the -`ANSWER SECTION`, provided that the `QUESTION SECTION` was re-written: - -``` - rewrite stop { - name regex (.*)-(us-west-1)\.coredns\.rocks {1}.service.{2}.consul - answer name (.*)\.service\.(us-west-1)\.consul {1}-{2}.coredns.rocks - } -``` - -Now, the `ANSWER SECTION` matches the `QUESTION SECTION`: - -``` -$ dig @10.1.1.1 ftp-us-west-1.coredns.rocks - -; <<>> DiG 9.8.3-P1 <<>> @10.1.1.1 ftp-us-west-1.coredns.rocks -; (1 server found) -;; global options: +cmd -;; Got answer: -;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 8619 -;; flags: qr aa rd ra; QUERY: 1, ANSWER: 3, AUTHORITY: 0, ADDITIONAL: 0 - -;; QUESTION SECTION: -;ftp-us-west-1.coredns.rocks. IN A - -;; ANSWER SECTION: -ftp-us-west-1.coredns.rocks. 0 IN A 10.10.10.10 -ftp-us-west-1.coredns.rocks. 0 IN A 10.20.20.20 -ftp-us-west-1.coredns.rocks. 0 IN A 10.30.30.30 -``` - -The syntax for the rewrite of DNS request and response is as follows: - -``` -rewrite [continue|stop] { - name regex STRING STRING - answer name STRING STRING -} -``` - -Note that the above syntax is strict. For response rewrites only `name` -rules are allowed to match the question section, and only by match type -`regex`. The answer rewrite must be after the name, as ordered in the -syntax example. There must only be two lines (a `name` follwed by an -`answer`) in the brackets, additional rules are not supported. - -An alternate syntax for the rewrite of DNS request and response is as -follows: - -``` -rewrite [continue|stop] name regex STRING STRING answer name STRING STRING -``` - -## EDNS0 Options - -Using FIELD edns0, you can set, append, or replace specific EDNS0 options on the request. - -* `replace` will modify any "matching" option with the specified option. The criteria for "matching" varies based on EDNS0 type. -* `append` will add the option only if no matching option exists -* `set` will modify a matching option or add one if none is found - -Currently supported are `EDNS0_LOCAL`, `EDNS0_NSID` and `EDNS0_SUBNET`. - -### EDNS0_LOCAL - -This has two fields, code and data. A match is defined as having the same code. Data may be a string or a variable. - -* A string data can be treated as hex if it starts with `0x`. Example: - -~~~ corefile -. { - rewrite edns0 local set 0xffee 0x61626364 - whoami -} -~~~ - -rewrites the first local option with code 0xffee, setting the data to "abcd". Equivalent: - -~~~ corefile -. { - rewrite edns0 local set 0xffee abcd -} -~~~ - -* A variable data is specified with a pair of curly brackets `{}`. Following are the supported variables: - {qname}, {qtype}, {client_ip}, {client_port}, {protocol}, {server_ip}, {server_port}. - -Example: - -~~~ -rewrite edns0 local set 0xffee {client_ip} -~~~ - -### EDNS0_NSID - -This has no fields; it will add an NSID option with an empty string for the NSID. If the option already exists -and the action is `replace` or `set`, then the NSID in the option will be set to the empty string. - -### EDNS0_SUBNET - -This has two fields, IPv4 bitmask length and IPv6 bitmask length. The bitmask -length is used to extract the client subnet from the source IP address in the query. - -Example: - -~~~ -rewrite edns0 subnet set 24 56 -~~~ - -* If the query has source IP as IPv4, the first 24 bits in the IP will be the network subnet. -* If the query has source IP as IPv6, the first 56 bits in the IP will be the network subnet. - -## Full Syntax - -The full plugin usage syntax is harder to digest... -~~~ -rewrite [continue|stop] {type|class|edns0|name [exact|prefix|suffix|substring|regex [FROM TO answer name]]} FROM TO -~~~ - -The syntax above doesn't cover the multi line block option for specifying a name request+response rewrite rule described in the **Response Rewrite** section. diff --git a/vendor/github.com/coredns/coredns/plugin/rewrite/class.go b/vendor/github.com/coredns/coredns/plugin/rewrite/class.go deleted file mode 100644 index 2e54f515..00000000 --- a/vendor/github.com/coredns/coredns/plugin/rewrite/class.go +++ /dev/null @@ -1,48 +0,0 @@ -package rewrite - -import ( - "fmt" - "strings" - - "github.com/miekg/dns" -) - -type classRule struct { - fromClass uint16 - toClass uint16 - NextAction string -} - -// newClassRule creates a class matching rule -func newClassRule(nextAction string, args ...string) (Rule, error) { - var from, to uint16 - var ok bool - if from, ok = dns.StringToClass[strings.ToUpper(args[0])]; !ok { - return nil, fmt.Errorf("invalid class %q", strings.ToUpper(args[0])) - } - if to, ok = dns.StringToClass[strings.ToUpper(args[1])]; !ok { - return nil, fmt.Errorf("invalid class %q", strings.ToUpper(args[1])) - } - return &classRule{from, to, nextAction}, nil -} - -// Rewrite rewrites the the current request. -func (rule *classRule) Rewrite(w dns.ResponseWriter, r *dns.Msg) Result { - if rule.fromClass > 0 && rule.toClass > 0 { - if r.Question[0].Qclass == rule.fromClass { - r.Question[0].Qclass = rule.toClass - return RewriteDone - } - } - return RewriteIgnored -} - -// Mode returns the processing mode -func (rule *classRule) Mode() string { - return rule.NextAction -} - -// GetResponseRule return a rule to rewrite the response with. Currently not implemented. -func (rule *classRule) GetResponseRule() ResponseRule { - return ResponseRule{} -} diff --git a/vendor/github.com/coredns/coredns/plugin/rewrite/condition.go b/vendor/github.com/coredns/coredns/plugin/rewrite/condition.go deleted file mode 100644 index 2f20d71a..00000000 --- a/vendor/github.com/coredns/coredns/plugin/rewrite/condition.go +++ /dev/null @@ -1,132 +0,0 @@ -package rewrite - -import ( - "fmt" - "regexp" - "strings" - - "github.com/coredns/coredns/plugin/pkg/replacer" - - "github.com/miekg/dns" -) - -// Operators -const ( - Is = "is" - Not = "not" - Has = "has" - NotHas = "not_has" - StartsWith = "starts_with" - EndsWith = "ends_with" - Match = "match" - NotMatch = "not_match" -) - -func operatorError(operator string) error { - return fmt.Errorf("invalid operator %v", operator) -} - -func newReplacer(r *dns.Msg) replacer.Replacer { - return replacer.New(r, nil, "") -} - -// condition is a rewrite condition. -type condition func(string, string) bool - -var conditions = map[string]condition{ - Is: isFunc, - Not: notFunc, - Has: hasFunc, - NotHas: notHasFunc, - StartsWith: startsWithFunc, - EndsWith: endsWithFunc, - Match: matchFunc, - NotMatch: notMatchFunc, -} - -// isFunc is condition for Is operator. -// It checks for equality. -func isFunc(a, b string) bool { - return a == b -} - -// notFunc is condition for Not operator. -// It checks for inequality. -func notFunc(a, b string) bool { - return a != b -} - -// hasFunc is condition for Has operator. -// It checks if b is a substring of a. -func hasFunc(a, b string) bool { - return strings.Contains(a, b) -} - -// notHasFunc is condition for NotHas operator. -// It checks if b is not a substring of a. -func notHasFunc(a, b string) bool { - return !strings.Contains(a, b) -} - -// startsWithFunc is condition for StartsWith operator. -// It checks if b is a prefix of a. -func startsWithFunc(a, b string) bool { - return strings.HasPrefix(a, b) -} - -// endsWithFunc is condition for EndsWith operator. -// It checks if b is a suffix of a. -func endsWithFunc(a, b string) bool { - // TODO(miek): IsSubDomain - return strings.HasSuffix(a, b) -} - -// matchFunc is condition for Match operator. -// It does regexp matching of a against pattern in b -// and returns if they match. -func matchFunc(a, b string) bool { - matched, _ := regexp.MatchString(b, a) - return matched -} - -// notMatchFunc is condition for NotMatch operator. -// It does regexp matching of a against pattern in b -// and returns if they do not match. -func notMatchFunc(a, b string) bool { - matched, _ := regexp.MatchString(b, a) - return !matched -} - -// If is statement for a rewrite condition. -type If struct { - A string - Operator string - B string -} - -// True returns true if the condition is true and false otherwise. -// If r is not nil, it replaces placeholders before comparison. -func (i If) True(r *dns.Msg) bool { - if c, ok := conditions[i.Operator]; ok { - a, b := i.A, i.B - if r != nil { - replacer := newReplacer(r) - a = replacer.Replace(i.A) - b = replacer.Replace(i.B) - } - return c(a, b) - } - return false -} - -// NewIf creates a new If condition. -func NewIf(a, operator, b string) (If, error) { - if _, ok := conditions[operator]; !ok { - return If{}, operatorError(operator) - } - return If{ - A: a, - Operator: operator, - B: b, - }, nil -} diff --git a/vendor/github.com/coredns/coredns/plugin/rewrite/condition_test.go b/vendor/github.com/coredns/coredns/plugin/rewrite/condition_test.go deleted file mode 100644 index 91004f9d..00000000 --- a/vendor/github.com/coredns/coredns/plugin/rewrite/condition_test.go +++ /dev/null @@ -1,102 +0,0 @@ -package rewrite - -/* -func TestConditions(t *testing.T) { - tests := []struct { - condition string - isTrue bool - }{ - {"a is b", false}, - {"a is a", true}, - {"a not b", true}, - {"a not a", false}, - {"a has a", true}, - {"a has b", false}, - {"ba has b", true}, - {"bab has b", true}, - {"bab has bb", false}, - {"a not_has a", false}, - {"a not_has b", true}, - {"ba not_has b", false}, - {"bab not_has b", false}, - {"bab not_has bb", true}, - {"bab starts_with bb", false}, - {"bab starts_with ba", true}, - {"bab starts_with bab", true}, - {"bab ends_with bb", false}, - {"bab ends_with bab", true}, - {"bab ends_with ab", true}, - {"a match *", false}, - {"a match a", true}, - {"a match .*", true}, - {"a match a.*", true}, - {"a match b.*", false}, - {"ba match b.*", true}, - {"ba match b[a-z]", true}, - {"b0 match b[a-z]", false}, - {"b0a match b[a-z]", false}, - {"b0a match b[a-z]+", false}, - {"b0a match b[a-z0-9]+", true}, - {"a not_match *", true}, - {"a not_match a", false}, - {"a not_match .*", false}, - {"a not_match a.*", false}, - {"a not_match b.*", true}, - {"ba not_match b.*", false}, - {"ba not_match b[a-z]", false}, - {"b0 not_match b[a-z]", true}, - {"b0a not_match b[a-z]", true}, - {"b0a not_match b[a-z]+", true}, - {"b0a not_match b[a-z0-9]+", false}, - } - - for i, test := range tests { - str := strings.Fields(test.condition) - ifCond, err := NewIf(str[0], str[1], str[2]) - if err != nil { - t.Error(err) - } - isTrue := ifCond.True(nil) - if isTrue != test.isTrue { - t.Errorf("Test %v: expected %v found %v", i, test.isTrue, isTrue) - } - } - - invalidOperators := []string{"ss", "and", "if"} - for _, op := range invalidOperators { - _, err := NewIf("a", op, "b") - if err == nil { - t.Errorf("Invalid operator %v used, expected error.", op) - } - } - - replaceTests := []struct { - url string - condition string - isTrue bool - }{ - {"/home", "{uri} match /home", true}, - {"/hom", "{uri} match /home", false}, - {"/hom", "{uri} starts_with /home", false}, - {"/hom", "{uri} starts_with /h", true}, - {"/home/.hiddenfile", `{uri} match \/\.(.*)`, true}, - {"/home/.hiddendir/afile", `{uri} match \/\.(.*)`, true}, - } - - for i, test := range replaceTests { - r, err := http.NewRequest("GET", test.url, nil) - if err != nil { - t.Error(err) - } - str := strings.Fields(test.condition) - ifCond, err := NewIf(str[0], str[1], str[2]) - if err != nil { - t.Error(err) - } - isTrue := ifCond.True(r) - if isTrue != test.isTrue { - t.Errorf("Test %v: expected %v found %v", i, test.isTrue, isTrue) - } - } -} -*/ diff --git a/vendor/github.com/coredns/coredns/plugin/rewrite/edns0.go b/vendor/github.com/coredns/coredns/plugin/rewrite/edns0.go deleted file mode 100644 index 2fd42cb6..00000000 --- a/vendor/github.com/coredns/coredns/plugin/rewrite/edns0.go +++ /dev/null @@ -1,464 +0,0 @@ -// Package rewrite is plugin for rewriting requests internally to something different. -package rewrite - -import ( - "encoding/binary" - "encoding/hex" - "fmt" - "net" - "strconv" - "strings" - - "github.com/coredns/coredns/request" - "github.com/miekg/dns" -) - -// edns0LocalRule is a rewrite rule for EDNS0_LOCAL options -type edns0LocalRule struct { - mode string - action string - code uint16 - data []byte -} - -// edns0VariableRule is a rewrite rule for EDNS0_LOCAL options with variable -type edns0VariableRule struct { - mode string - action string - code uint16 - variable string -} - -// ends0NsidRule is a rewrite rule for EDNS0_NSID options -type edns0NsidRule struct { - mode string - action string -} - -// setupEdns0Opt will retrieve the EDNS0 OPT or create it if it does not exist -func setupEdns0Opt(r *dns.Msg) *dns.OPT { - o := r.IsEdns0() - if o == nil { - r.SetEdns0(4096, false) - o = r.IsEdns0() - } - return o -} - -// Rewrite will alter the request EDNS0 NSID option -func (rule *edns0NsidRule) Rewrite(w dns.ResponseWriter, r *dns.Msg) Result { - result := RewriteIgnored - o := setupEdns0Opt(r) - found := false -Option: - for _, s := range o.Option { - switch e := s.(type) { - case *dns.EDNS0_NSID: - if rule.action == Replace || rule.action == Set { - e.Nsid = "" // make sure it is empty for request - result = RewriteDone - } - found = true - break Option - } - } - - // add option if not found - if !found && (rule.action == Append || rule.action == Set) { - o.Option = append(o.Option, &dns.EDNS0_NSID{Code: dns.EDNS0NSID, Nsid: ""}) - result = RewriteDone - } - - return result -} - -// Mode returns the processing mode -func (rule *edns0NsidRule) Mode() string { - return rule.mode -} - -// GetResponseRule return a rule to rewrite the response with. Currently not implemented. -func (rule *edns0NsidRule) GetResponseRule() ResponseRule { - return ResponseRule{} -} - -// Rewrite will alter the request EDNS0 local options -func (rule *edns0LocalRule) Rewrite(w dns.ResponseWriter, r *dns.Msg) Result { - result := RewriteIgnored - o := setupEdns0Opt(r) - found := false - for _, s := range o.Option { - switch e := s.(type) { - case *dns.EDNS0_LOCAL: - if rule.code == e.Code { - if rule.action == Replace || rule.action == Set { - e.Data = rule.data - result = RewriteDone - } - found = true - break - } - } - } - - // add option if not found - if !found && (rule.action == Append || rule.action == Set) { - var opt dns.EDNS0_LOCAL - opt.Code = rule.code - opt.Data = rule.data - o.Option = append(o.Option, &opt) - result = RewriteDone - } - - return result -} - -// Mode returns the processing mode -func (rule *edns0LocalRule) Mode() string { - return rule.mode -} - -// GetResponseRule return a rule to rewrite the response with. Currently not implemented. -func (rule *edns0LocalRule) GetResponseRule() ResponseRule { - return ResponseRule{} -} - -// newEdns0Rule creates an EDNS0 rule of the appropriate type based on the args -func newEdns0Rule(mode string, args ...string) (Rule, error) { - if len(args) < 2 { - return nil, fmt.Errorf("too few arguments for an EDNS0 rule") - } - - ruleType := strings.ToLower(args[0]) - action := strings.ToLower(args[1]) - switch action { - case Append: - case Replace: - case Set: - default: - return nil, fmt.Errorf("invalid action: %q", action) - } - - switch ruleType { - case "local": - if len(args) != 4 { - return nil, fmt.Errorf("EDNS0 local rules require exactly three args") - } - //Check for variable option - if strings.HasPrefix(args[3], "{") && strings.HasSuffix(args[3], "}") { - return newEdns0VariableRule(mode, action, args[2], args[3]) - } - return newEdns0LocalRule(mode, action, args[2], args[3]) - case "nsid": - if len(args) != 2 { - return nil, fmt.Errorf("EDNS0 NSID rules do not accept args") - } - return &edns0NsidRule{mode: mode, action: action}, nil - case "subnet": - if len(args) != 4 { - return nil, fmt.Errorf("EDNS0 subnet rules require exactly three args") - } - return newEdns0SubnetRule(mode, action, args[2], args[3]) - default: - return nil, fmt.Errorf("invalid rule type %q", ruleType) - } -} - -func newEdns0LocalRule(mode, action, code, data string) (*edns0LocalRule, error) { - c, err := strconv.ParseUint(code, 0, 16) - if err != nil { - return nil, err - } - - decoded := []byte(data) - if strings.HasPrefix(data, "0x") { - decoded, err = hex.DecodeString(data[2:]) - if err != nil { - return nil, err - } - } - return &edns0LocalRule{mode: mode, action: action, code: uint16(c), data: decoded}, nil -} - -// newEdns0VariableRule creates an EDNS0 rule that handles variable substitution -func newEdns0VariableRule(mode, action, code, variable string) (*edns0VariableRule, error) { - c, err := strconv.ParseUint(code, 0, 16) - if err != nil { - return nil, err - } - //Validate - if !isValidVariable(variable) { - return nil, fmt.Errorf("unsupported variable name %q", variable) - } - return &edns0VariableRule{mode: mode, action: action, code: uint16(c), variable: variable}, nil -} - -// ipToWire writes IP address to wire/binary format, 4 or 16 bytes depends on IPV4 or IPV6. -func (rule *edns0VariableRule) ipToWire(family int, ipAddr string) ([]byte, error) { - - switch family { - case 1: - return net.ParseIP(ipAddr).To4(), nil - case 2: - return net.ParseIP(ipAddr).To16(), nil - } - return nil, fmt.Errorf("invalid IP address family (i.e. version) %d", family) -} - -// uint16ToWire writes unit16 to wire/binary format -func (rule *edns0VariableRule) uint16ToWire(data uint16) []byte { - buf := make([]byte, 2) - binary.BigEndian.PutUint16(buf, uint16(data)) - return buf -} - -// portToWire writes port to wire/binary format, 2 bytes -func (rule *edns0VariableRule) portToWire(portStr string) ([]byte, error) { - - port, err := strconv.ParseUint(portStr, 10, 16) - if err != nil { - return nil, err - } - return rule.uint16ToWire(uint16(port)), nil -} - -// Family returns the family of the transport, 1 for IPv4 and 2 for IPv6. -func (rule *edns0VariableRule) family(ip net.Addr) int { - var a net.IP - if i, ok := ip.(*net.UDPAddr); ok { - a = i.IP - } - if i, ok := ip.(*net.TCPAddr); ok { - a = i.IP - } - if a.To4() != nil { - return 1 - } - return 2 -} - -// ruleData returns the data specified by the variable -func (rule *edns0VariableRule) ruleData(w dns.ResponseWriter, r *dns.Msg) ([]byte, error) { - - req := request.Request{W: w, Req: r} - switch rule.variable { - case queryName: - //Query name is written as ascii string - return []byte(req.QName()), nil - - case queryType: - return rule.uint16ToWire(req.QType()), nil - - case clientIP: - return rule.ipToWire(req.Family(), req.IP()) - - case clientPort: - return rule.portToWire(req.Port()) - - case protocol: - // Proto is written as ascii string - return []byte(req.Proto()), nil - - case serverIP: - ip, _, err := net.SplitHostPort(w.LocalAddr().String()) - if err != nil { - ip = w.RemoteAddr().String() - } - return rule.ipToWire(rule.family(w.RemoteAddr()), ip) - - case serverPort: - _, port, err := net.SplitHostPort(w.LocalAddr().String()) - if err != nil { - port = "0" - } - return rule.portToWire(port) - } - - return nil, fmt.Errorf("unable to extract data for variable %s", rule.variable) -} - -// Rewrite will alter the request EDNS0 local options with specified variables -func (rule *edns0VariableRule) Rewrite(w dns.ResponseWriter, r *dns.Msg) Result { - result := RewriteIgnored - - data, err := rule.ruleData(w, r) - if err != nil || data == nil { - return result - } - - o := setupEdns0Opt(r) - found := false - for _, s := range o.Option { - switch e := s.(type) { - case *dns.EDNS0_LOCAL: - if rule.code == e.Code { - if rule.action == Replace || rule.action == Set { - e.Data = data - result = RewriteDone - } - found = true - break - } - } - } - - // add option if not found - if !found && (rule.action == Append || rule.action == Set) { - var opt dns.EDNS0_LOCAL - opt.Code = rule.code - opt.Data = data - o.Option = append(o.Option, &opt) - result = RewriteDone - } - - return result -} - -// Mode returns the processing mode -func (rule *edns0VariableRule) Mode() string { - return rule.mode -} - -// GetResponseRule return a rule to rewrite the response with. Currently not implemented. -func (rule *edns0VariableRule) GetResponseRule() ResponseRule { - return ResponseRule{} -} - -func isValidVariable(variable string) bool { - switch variable { - case - queryName, - queryType, - clientIP, - clientPort, - protocol, - serverIP, - serverPort: - return true - } - return false -} - -// ends0SubnetRule is a rewrite rule for EDNS0 subnet options -type edns0SubnetRule struct { - mode string - v4BitMaskLen uint8 - v6BitMaskLen uint8 - action string -} - -func newEdns0SubnetRule(mode, action, v4BitMaskLen, v6BitMaskLen string) (*edns0SubnetRule, error) { - v4Len, err := strconv.ParseUint(v4BitMaskLen, 0, 16) - if err != nil { - return nil, err - } - // Validate V4 length - if v4Len > maxV4BitMaskLen { - return nil, fmt.Errorf("invalid IPv4 bit mask length %d", v4Len) - } - - v6Len, err := strconv.ParseUint(v6BitMaskLen, 0, 16) - if err != nil { - return nil, err - } - //Validate V6 length - if v6Len > maxV6BitMaskLen { - return nil, fmt.Errorf("invalid IPv6 bit mask length %d", v6Len) - } - - return &edns0SubnetRule{mode: mode, action: action, - v4BitMaskLen: uint8(v4Len), v6BitMaskLen: uint8(v6Len)}, nil -} - -// fillEcsData sets the subnet data into the ecs option -func (rule *edns0SubnetRule) fillEcsData(w dns.ResponseWriter, r *dns.Msg, - ecs *dns.EDNS0_SUBNET) error { - - req := request.Request{W: w, Req: r} - family := req.Family() - if (family != 1) && (family != 2) { - return fmt.Errorf("unable to fill data for EDNS0 subnet due to invalid IP family") - } - - ecs.Family = uint16(family) - ecs.SourceScope = 0 - - ipAddr := req.IP() - switch family { - case 1: - ipv4Mask := net.CIDRMask(int(rule.v4BitMaskLen), 32) - ipv4Addr := net.ParseIP(ipAddr) - ecs.SourceNetmask = rule.v4BitMaskLen - ecs.Address = ipv4Addr.Mask(ipv4Mask).To4() - case 2: - ipv6Mask := net.CIDRMask(int(rule.v6BitMaskLen), 128) - ipv6Addr := net.ParseIP(ipAddr) - ecs.SourceNetmask = rule.v6BitMaskLen - ecs.Address = ipv6Addr.Mask(ipv6Mask).To16() - } - return nil -} - -// Rewrite will alter the request EDNS0 subnet option -func (rule *edns0SubnetRule) Rewrite(w dns.ResponseWriter, r *dns.Msg) Result { - result := RewriteIgnored - o := setupEdns0Opt(r) - found := false - for _, s := range o.Option { - switch e := s.(type) { - case *dns.EDNS0_SUBNET: - if rule.action == Replace || rule.action == Set { - if rule.fillEcsData(w, r, e) == nil { - result = RewriteDone - } - } - found = true - break - } - } - - // add option if not found - if !found && (rule.action == Append || rule.action == Set) { - opt := dns.EDNS0_SUBNET{Code: dns.EDNS0SUBNET} - if rule.fillEcsData(w, r, &opt) == nil { - o.Option = append(o.Option, &opt) - result = RewriteDone - } - } - - return result -} - -// Mode returns the processing mode -func (rule *edns0SubnetRule) Mode() string { - return rule.mode -} - -// GetResponseRule return a rule to rewrite the response with. Currently not implemented. -func (rule *edns0SubnetRule) GetResponseRule() ResponseRule { - return ResponseRule{} -} - -// These are all defined actions. -const ( - Replace = "replace" - Set = "set" - Append = "append" -) - -// Supported local EDNS0 variables -const ( - queryName = "{qname}" - queryType = "{qtype}" - clientIP = "{client_ip}" - clientPort = "{client_port}" - protocol = "{protocol}" - serverIP = "{server_ip}" - serverPort = "{server_port}" -) - -// Subnet maximum bit mask length -const ( - maxV4BitMaskLen = 32 - maxV6BitMaskLen = 128 -) diff --git a/vendor/github.com/coredns/coredns/plugin/rewrite/fuzz.go b/vendor/github.com/coredns/coredns/plugin/rewrite/fuzz.go deleted file mode 100644 index 6de5f12c..00000000 --- a/vendor/github.com/coredns/coredns/plugin/rewrite/fuzz.go +++ /dev/null @@ -1,21 +0,0 @@ -// +build fuzz - -package rewrite - -import ( - "github.com/coredns/coredns/plugin/pkg/fuzz" - - "github.com/mholt/caddy" -) - -// Fuzz fuzzes rewrite. -func Fuzz(data []byte) int { - c := caddy.NewTestController("dns", "rewrite edns0 subnet set 24 56") - rules, err := rewriteParse(c) - if err != nil { - return 0 - } - r := Rewrite{Rules: rules} - - return fuzz.Do(r, data) -} diff --git a/vendor/github.com/coredns/coredns/plugin/rewrite/name.go b/vendor/github.com/coredns/coredns/plugin/rewrite/name.go deleted file mode 100644 index a34b4804..00000000 --- a/vendor/github.com/coredns/coredns/plugin/rewrite/name.go +++ /dev/null @@ -1,219 +0,0 @@ -package rewrite - -import ( - "fmt" - "regexp" - "strconv" - "strings" - - "github.com/coredns/coredns/plugin" - "github.com/miekg/dns" -) - -type nameRule struct { - NextAction string - From string - To string -} - -type prefixNameRule struct { - NextAction string - Prefix string - Replacement string -} - -type suffixNameRule struct { - NextAction string - Suffix string - Replacement string -} - -type substringNameRule struct { - NextAction string - Substring string - Replacement string -} - -type regexNameRule struct { - NextAction string - Pattern *regexp.Regexp - Replacement string - ResponseRule -} - -const ( - // ExactMatch matches only on exact match of the name in the question section of a request - ExactMatch = "exact" - // PrefixMatch matches when the name begins with the matching string - PrefixMatch = "prefix" - // SuffixMatch matches when the name ends with the matching string - SuffixMatch = "suffix" - // SubstringMatch matches on partial match of the name in the question section of a request - SubstringMatch = "substring" - // RegexMatch matches when the name in the question section of a request matches a regular expression - RegexMatch = "regex" -) - -// Rewrite rewrites the current request based upon exact match of the name -// in the question section of the request -func (rule *nameRule) Rewrite(w dns.ResponseWriter, r *dns.Msg) Result { - if rule.From == r.Question[0].Name { - r.Question[0].Name = rule.To - return RewriteDone - } - return RewriteIgnored -} - -// Rewrite rewrites the current request when the name begins with the matching string -func (rule *prefixNameRule) Rewrite(w dns.ResponseWriter, r *dns.Msg) Result { - if strings.HasPrefix(r.Question[0].Name, rule.Prefix) { - r.Question[0].Name = rule.Replacement + strings.TrimLeft(r.Question[0].Name, rule.Prefix) - return RewriteDone - } - return RewriteIgnored -} - -// Rewrite rewrites the current request when the name ends with the matching string -func (rule *suffixNameRule) Rewrite(w dns.ResponseWriter, r *dns.Msg) Result { - if strings.HasSuffix(r.Question[0].Name, rule.Suffix) { - r.Question[0].Name = strings.TrimRight(r.Question[0].Name, rule.Suffix) + rule.Replacement - return RewriteDone - } - return RewriteIgnored -} - -// Rewrite rewrites the current request based upon partial match of the -// name in the question section of the request -func (rule *substringNameRule) Rewrite(w dns.ResponseWriter, r *dns.Msg) Result { - if strings.Contains(r.Question[0].Name, rule.Substring) { - r.Question[0].Name = strings.Replace(r.Question[0].Name, rule.Substring, rule.Replacement, -1) - return RewriteDone - } - return RewriteIgnored -} - -// Rewrite rewrites the current request when the name in the question -// section of the request matches a regular expression -func (rule *regexNameRule) Rewrite(w dns.ResponseWriter, r *dns.Msg) Result { - regexGroups := rule.Pattern.FindStringSubmatch(r.Question[0].Name) - if len(regexGroups) == 0 { - return RewriteIgnored - } - s := rule.Replacement - for groupIndex, groupValue := range regexGroups { - groupIndexStr := "{" + strconv.Itoa(groupIndex) + "}" - if strings.Contains(s, groupIndexStr) { - s = strings.Replace(s, groupIndexStr, groupValue, -1) - } - } - r.Question[0].Name = s - return RewriteDone -} - -// newNameRule creates a name matching rule based on exact, partial, or regex match -func newNameRule(nextAction string, args ...string) (Rule, error) { - if len(args) < 2 { - return nil, fmt.Errorf("too few arguments for a name rule") - } - if len(args) == 3 { - switch strings.ToLower(args[0]) { - case ExactMatch: - return &nameRule{nextAction, plugin.Name(args[1]).Normalize(), plugin.Name(args[2]).Normalize()}, nil - case PrefixMatch: - return &prefixNameRule{nextAction, plugin.Name(args[1]).Normalize(), plugin.Name(args[2]).Normalize()}, nil - case SuffixMatch: - return &suffixNameRule{nextAction, plugin.Name(args[1]).Normalize(), plugin.Name(args[2]).Normalize()}, nil - case SubstringMatch: - return &substringNameRule{nextAction, plugin.Name(args[1]).Normalize(), plugin.Name(args[2]).Normalize()}, nil - case RegexMatch: - regexPattern, err := regexp.Compile(args[1]) - if err != nil { - return nil, fmt.Errorf("Invalid regex pattern in a name rule: %s", args[1]) - } - return ®exNameRule{nextAction, regexPattern, plugin.Name(args[2]).Normalize(), ResponseRule{}}, nil - default: - return nil, fmt.Errorf("A name rule supports only exact, prefix, suffix, substring, and regex name matching") - } - } - if len(args) == 7 { - if strings.ToLower(args[0]) == RegexMatch { - if args[3] != "answer" { - return nil, fmt.Errorf("exceeded the number of arguments for a regex name rule") - } - switch strings.ToLower(args[4]) { - case "name": - default: - return nil, fmt.Errorf("exceeded the number of arguments for a regex name rule") - } - regexPattern, err := regexp.Compile(args[1]) - if err != nil { - return nil, fmt.Errorf("Invalid regex pattern in a name rule: %s", args) - } - responseRegexPattern, err := regexp.Compile(args[5]) - if err != nil { - return nil, fmt.Errorf("Invalid regex pattern in a name rule: %s", args) - } - return ®exNameRule{ - nextAction, - regexPattern, - plugin.Name(args[2]).Normalize(), - ResponseRule{ - Active: true, - Pattern: responseRegexPattern, - Replacement: plugin.Name(args[6]).Normalize(), - }, - }, nil - } - return nil, fmt.Errorf("the rewrite of response is supported only for name regex rule") - } - if len(args) > 3 && len(args) != 7 { - return nil, fmt.Errorf("response rewrites must consist only of a name rule with 3 arguments and an answer rule with 3 arguments") - } - return &nameRule{nextAction, plugin.Name(args[0]).Normalize(), plugin.Name(args[1]).Normalize()}, nil -} - -// Mode returns the processing nextAction -func (rule *nameRule) Mode() string { - return rule.NextAction -} - -func (rule *prefixNameRule) Mode() string { - return rule.NextAction -} - -func (rule *suffixNameRule) Mode() string { - return rule.NextAction -} - -func (rule *substringNameRule) Mode() string { - return rule.NextAction -} - -func (rule *regexNameRule) Mode() string { - return rule.NextAction -} - -// GetResponseRule return a rule to rewrite the response with. Currently not implemented. -func (rule *nameRule) GetResponseRule() ResponseRule { - return ResponseRule{} -} - -// GetResponseRule return a rule to rewrite the response with. Currently not implemented. -func (rule *prefixNameRule) GetResponseRule() ResponseRule { - return ResponseRule{} -} - -// GetResponseRule return a rule to rewrite the response with. Currently not implemented. -func (rule *suffixNameRule) GetResponseRule() ResponseRule { - return ResponseRule{} -} - -// GetResponseRule return a rule to rewrite the response with. Currently not implemented. -func (rule *substringNameRule) GetResponseRule() ResponseRule { - return ResponseRule{} -} - -// GetResponseRule return a rule to rewrite the response with. -func (rule *regexNameRule) GetResponseRule() ResponseRule { - return rule.ResponseRule -} diff --git a/vendor/github.com/coredns/coredns/plugin/rewrite/reverter.go b/vendor/github.com/coredns/coredns/plugin/rewrite/reverter.go deleted file mode 100644 index 0faae608..00000000 --- a/vendor/github.com/coredns/coredns/plugin/rewrite/reverter.go +++ /dev/null @@ -1,74 +0,0 @@ -package rewrite - -import ( - "regexp" - "strconv" - "strings" - - "github.com/miekg/dns" -) - -// ResponseRule contains a rule to rewrite a response with. -type ResponseRule struct { - Active bool - Pattern *regexp.Regexp - Replacement string -} - -// ResponseReverter reverses the operations done on the question section of a packet. -// This is need because the client will otherwise disregards the response, i.e. -// dig will complain with ';; Question section mismatch: got miek.nl/HINFO/IN' -type ResponseReverter struct { - dns.ResponseWriter - originalQuestion dns.Question - ResponseRewrite bool - ResponseRules []ResponseRule -} - -// NewResponseReverter returns a pointer to a new ResponseReverter. -func NewResponseReverter(w dns.ResponseWriter, r *dns.Msg) *ResponseReverter { - return &ResponseReverter{ - ResponseWriter: w, - originalQuestion: r.Question[0], - } -} - -// WriteMsg records the status code and calls the -// underlying ResponseWriter's WriteMsg method. -func (r *ResponseReverter) WriteMsg(res *dns.Msg) error { - res.Question[0] = r.originalQuestion - if r.ResponseRewrite { - for _, rr := range res.Answer { - name := rr.Header().Name - for _, rule := range r.ResponseRules { - regexGroups := rule.Pattern.FindStringSubmatch(name) - if len(regexGroups) == 0 { - continue - } - s := rule.Replacement - for groupIndex, groupValue := range regexGroups { - groupIndexStr := "{" + strconv.Itoa(groupIndex) + "}" - if strings.Contains(s, groupIndexStr) { - s = strings.Replace(s, groupIndexStr, groupValue, -1) - } - } - name = s - } - rr.Header().Name = name - } - } - return r.ResponseWriter.WriteMsg(res) -} - -// Write is a wrapper that records the size of the message that gets written. -func (r *ResponseReverter) Write(buf []byte) (int, error) { - n, err := r.ResponseWriter.Write(buf) - return n, err -} - -// Hijack implements dns.Hijacker. It simply wraps the underlying -// ResponseWriter's Hijack method if there is one, or returns an error. -func (r *ResponseReverter) Hijack() { - r.ResponseWriter.Hijack() - return -} diff --git a/vendor/github.com/coredns/coredns/plugin/rewrite/reverter_test.go b/vendor/github.com/coredns/coredns/plugin/rewrite/reverter_test.go deleted file mode 100644 index d46180af..00000000 --- a/vendor/github.com/coredns/coredns/plugin/rewrite/reverter_test.go +++ /dev/null @@ -1,70 +0,0 @@ -package rewrite - -import ( - "context" - "testing" - - "github.com/coredns/coredns/plugin" - "github.com/coredns/coredns/plugin/pkg/dnstest" - "github.com/coredns/coredns/plugin/test" - - "github.com/miekg/dns" -) - -var tests = []struct { - from string - fromType uint16 - answer []dns.RR - to string - toType uint16 - noRevert bool -}{ - {"core.dns.rocks", dns.TypeA, []dns.RR{test.A("dns.core.rocks. 5 IN A 10.0.0.1")}, "core.dns.rocks", dns.TypeA, false}, - {"core.dns.rocks", dns.TypeSRV, []dns.RR{test.SRV("dns.core.rocks. 5 IN SRV 0 100 100 srv1.dns.core.rocks.")}, "core.dns.rocks", dns.TypeSRV, false}, - {"core.dns.rocks", dns.TypeA, []dns.RR{test.A("core.dns.rocks. 5 IN A 10.0.0.1")}, "dns.core.rocks.", dns.TypeA, true}, - {"core.dns.rocks", dns.TypeSRV, []dns.RR{test.SRV("core.dns.rocks. 5 IN SRV 0 100 100 srv1.dns.core.rocks.")}, "dns.core.rocks.", dns.TypeSRV, true}, - {"core.dns.rocks", dns.TypeHINFO, []dns.RR{test.HINFO("core.dns.rocks. 5 HINFO INTEL-64 \"RHEL 7.4\"")}, "core.dns.rocks", dns.TypeHINFO, false}, - {"core.dns.rocks", dns.TypeA, []dns.RR{ - test.A("dns.core.rocks. 5 IN A 10.0.0.1"), - test.A("dns.core.rocks. 5 IN A 10.0.0.2"), - }, "core.dns.rocks", dns.TypeA, false}, -} - -func TestResponseReverter(t *testing.T) { - - rules := []Rule{} - r, _ := newNameRule("stop", "regex", `(core)\.(dns)\.(rocks)`, "{2}.{1}.{3}", "answer", "name", `(dns)\.(core)\.(rocks)`, "{2}.{1}.{3}") - rules = append(rules, r) - - doReverterTests(rules, t) - - rules = []Rule{} - r, _ = newNameRule("continue", "regex", `(core)\.(dns)\.(rocks)`, "{2}.{1}.{3}", "answer", "name", `(dns)\.(core)\.(rocks)`, "{2}.{1}.{3}") - rules = append(rules, r) - - doReverterTests(rules, t) -} - -func doReverterTests(rules []Rule, t *testing.T) { - ctx := context.TODO() - for i, tc := range tests { - m := new(dns.Msg) - m.SetQuestion(tc.from, tc.fromType) - m.Question[0].Qclass = dns.ClassINET - m.Answer = tc.answer - rw := Rewrite{ - Next: plugin.HandlerFunc(msgPrinter), - Rules: rules, - noRevert: tc.noRevert, - } - rec := dnstest.NewRecorder(&test.ResponseWriter{}) - rw.ServeDNS(ctx, rec, m) - resp := rec.Msg - if resp.Question[0].Name != tc.to { - t.Errorf("Test %d: Expected Name to be %q but was %q", i, tc.to, resp.Question[0].Name) - } - if resp.Question[0].Qtype != tc.toType { - t.Errorf("Test %d: Expected Type to be '%d' but was '%d'", i, tc.toType, resp.Question[0].Qtype) - } - } -} diff --git a/vendor/github.com/coredns/coredns/plugin/rewrite/rewrite.go b/vendor/github.com/coredns/coredns/plugin/rewrite/rewrite.go deleted file mode 100644 index 9b61ee12..00000000 --- a/vendor/github.com/coredns/coredns/plugin/rewrite/rewrite.go +++ /dev/null @@ -1,132 +0,0 @@ -package rewrite - -import ( - "context" - "fmt" - "strings" - - "github.com/coredns/coredns/plugin" - - "github.com/miekg/dns" -) - -// Result is the result of a rewrite -type Result int - -const ( - // RewriteIgnored is returned when rewrite is not done on request. - RewriteIgnored Result = iota - // RewriteDone is returned when rewrite is done on request. - RewriteDone - // RewriteStatus is returned when rewrite is not needed and status code should be set - // for the request. - RewriteStatus -) - -// These are defined processing mode. -const ( - // Processing should stop after completing this rule - Stop = "stop" - // Processing should continue to next rule - Continue = "continue" -) - -// Rewrite is plugin to rewrite requests internally before being handled. -type Rewrite struct { - Next plugin.Handler - Rules []Rule - noRevert bool -} - -// ServeDNS implements the plugin.Handler interface. -func (rw Rewrite) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (int, error) { - wr := NewResponseReverter(w, r) - for _, rule := range rw.Rules { - switch result := rule.Rewrite(w, r); result { - case RewriteDone: - respRule := rule.GetResponseRule() - if respRule.Active == true { - wr.ResponseRewrite = true - wr.ResponseRules = append(wr.ResponseRules, respRule) - } - if rule.Mode() == Stop { - if rw.noRevert { - return plugin.NextOrFailure(rw.Name(), rw.Next, ctx, w, r) - } - return plugin.NextOrFailure(rw.Name(), rw.Next, ctx, wr, r) - } - case RewriteIgnored: - break - case RewriteStatus: - // only valid for complex rules. - // if cRule, ok := rule.(*ComplexRule); ok && cRule.Status != 0 { - // return cRule.Status, nil - // } - } - } - if rw.noRevert || len(wr.ResponseRules) == 0 { - return plugin.NextOrFailure(rw.Name(), rw.Next, ctx, w, r) - } - return plugin.NextOrFailure(rw.Name(), rw.Next, ctx, wr, r) -} - -// Name implements the Handler interface. -func (rw Rewrite) Name() string { return "rewrite" } - -// Rule describes a rewrite rule. -type Rule interface { - // Rewrite rewrites the current request. - Rewrite(dns.ResponseWriter, *dns.Msg) Result - // Mode returns the processing mode stop or continue. - Mode() string - // GetResponseRule returns the rule to rewrite response with, if any. - GetResponseRule() ResponseRule -} - -func newRule(args ...string) (Rule, error) { - if len(args) == 0 { - return nil, fmt.Errorf("no rule type specified for rewrite") - } - - arg0 := strings.ToLower(args[0]) - var ruleType string - var expectNumArgs, startArg int - mode := Stop - switch arg0 { - case Continue: - mode = Continue - ruleType = strings.ToLower(args[1]) - expectNumArgs = len(args) - 1 - startArg = 2 - case Stop: - ruleType = strings.ToLower(args[1]) - expectNumArgs = len(args) - 1 - startArg = 2 - default: - // for backward compatibility - ruleType = arg0 - expectNumArgs = len(args) - startArg = 1 - } - - if ruleType == "answer" { - return nil, fmt.Errorf("response rewrites must begin with a name rule") - } - - if ruleType != "edns0" && ruleType != "name" && expectNumArgs != 3 { - return nil, fmt.Errorf("%s rules must have exactly two arguments", ruleType) - } - - switch ruleType { - case "name": - return newNameRule(mode, args[startArg:]...) - case "class": - return newClassRule(mode, args[startArg:]...) - case "type": - return newTypeRule(mode, args[startArg:]...) - case "edns0": - return newEdns0Rule(mode, args[startArg:]...) - default: - return nil, fmt.Errorf("invalid rule type %q", args[0]) - } -} diff --git a/vendor/github.com/coredns/coredns/plugin/rewrite/rewrite_test.go b/vendor/github.com/coredns/coredns/plugin/rewrite/rewrite_test.go deleted file mode 100644 index 56c446f4..00000000 --- a/vendor/github.com/coredns/coredns/plugin/rewrite/rewrite_test.go +++ /dev/null @@ -1,648 +0,0 @@ -package rewrite - -import ( - "bytes" - "context" - "reflect" - "testing" - - "github.com/coredns/coredns/plugin" - "github.com/coredns/coredns/plugin/pkg/dnstest" - "github.com/coredns/coredns/plugin/test" - - "github.com/miekg/dns" -) - -func msgPrinter(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (int, error) { - w.WriteMsg(r) - return 0, nil -} - -func TestNewRule(t *testing.T) { - tests := []struct { - args []string - shouldError bool - expType reflect.Type - }{ - {[]string{}, true, nil}, - {[]string{"foo"}, true, nil}, - {[]string{"name"}, true, nil}, - {[]string{"name", "a.com"}, true, nil}, - {[]string{"name", "a.com", "b.com", "c.com"}, true, nil}, - {[]string{"name", "a.com", "b.com"}, false, reflect.TypeOf(&nameRule{})}, - {[]string{"name", "exact", "a.com", "b.com"}, false, reflect.TypeOf(&nameRule{})}, - {[]string{"name", "prefix", "a.com", "b.com"}, false, reflect.TypeOf(&prefixNameRule{})}, - {[]string{"name", "suffix", "a.com", "b.com"}, false, reflect.TypeOf(&suffixNameRule{})}, - {[]string{"name", "substring", "a.com", "b.com"}, false, reflect.TypeOf(&substringNameRule{})}, - {[]string{"name", "regex", "([a])\\.com", "new-{1}.com"}, false, reflect.TypeOf(®exNameRule{})}, - {[]string{"name", "regex", "([a]\\.com", "new-{1}.com"}, true, nil}, - {[]string{"name", "regex", "(dns)\\.(core)\\.(rocks)", "{2}.{1}.{3}", "answer", "name", "(core)\\.(dns)\\.(rocks)", "{2}.{1}.{3}"}, false, reflect.TypeOf(®exNameRule{})}, - {[]string{"name", "regex", "(adns)\\.(core)\\.(rocks)", "{2}.{1}.{3}", "answer", "name", "(core)\\.(adns)\\.(rocks)", "{2}.{1}.{3}", "too.long", "way.too.long"}, true, nil}, - {[]string{"name", "regex", "(bdns)\\.(core)\\.(rocks)", "{2}.{1}.{3}", "NoAnswer", "name", "(core)\\.(bdns)\\.(rocks)", "{2}.{1}.{3}"}, true, nil}, - {[]string{"name", "regex", "(cdns)\\.(core)\\.(rocks)", "{2}.{1}.{3}", "answer", "ttl", "(core)\\.(cdns)\\.(rocks)", "{2}.{1}.{3}"}, true, nil}, - {[]string{"name", "regex", "(ddns)\\.(core)\\.(rocks)", "{2}.{1}.{3}", "answer", "name", "\xecore\\.(ddns)\\.(rocks)", "{2}.{1}.{3}"}, true, nil}, - {[]string{"name", "regex", "\xedns\\.(core)\\.(rocks)", "{2}.{1}.{3}", "answer", "name", "(core)\\.(edns)\\.(rocks)", "{2}.{1}.{3}"}, true, nil}, - {[]string{"name", "substring", "fcore.dns.rocks", "dns.fcore.rocks", "answer", "name", "(fcore)\\.(dns)\\.(rocks)", "{2}.{1}.{3}"}, true, nil}, - {[]string{"name", "substring", "a.com", "b.com", "c.com"}, true, nil}, - {[]string{"type"}, true, nil}, - {[]string{"type", "a"}, true, nil}, - {[]string{"type", "any", "a", "a"}, true, nil}, - {[]string{"type", "any", "a"}, false, reflect.TypeOf(&typeRule{})}, - {[]string{"type", "XY", "WV"}, true, nil}, - {[]string{"type", "ANY", "WV"}, true, nil}, - {[]string{"class"}, true, nil}, - {[]string{"class", "IN"}, true, nil}, - {[]string{"class", "ch", "in", "in"}, true, nil}, - {[]string{"class", "ch", "in"}, false, reflect.TypeOf(&classRule{})}, - {[]string{"class", "XY", "WV"}, true, nil}, - {[]string{"class", "IN", "WV"}, true, nil}, - {[]string{"edns0"}, true, nil}, - {[]string{"edns0", "local"}, true, nil}, - {[]string{"edns0", "local", "set"}, true, nil}, - {[]string{"edns0", "local", "set", "0xffee"}, true, nil}, - {[]string{"edns0", "local", "set", "65518", "abcdefg"}, false, reflect.TypeOf(&edns0LocalRule{})}, - {[]string{"edns0", "local", "set", "0xffee", "abcdefg"}, false, reflect.TypeOf(&edns0LocalRule{})}, - {[]string{"edns0", "local", "append", "0xffee", "abcdefg"}, false, reflect.TypeOf(&edns0LocalRule{})}, - {[]string{"edns0", "local", "replace", "0xffee", "abcdefg"}, false, reflect.TypeOf(&edns0LocalRule{})}, - {[]string{"edns0", "local", "foo", "0xffee", "abcdefg"}, true, nil}, - {[]string{"edns0", "local", "set", "0xffee", "0xabcdefg"}, true, nil}, - {[]string{"edns0", "nsid", "set", "junk"}, true, nil}, - {[]string{"edns0", "nsid", "set"}, false, reflect.TypeOf(&edns0NsidRule{})}, - {[]string{"edns0", "nsid", "append"}, false, reflect.TypeOf(&edns0NsidRule{})}, - {[]string{"edns0", "nsid", "replace"}, false, reflect.TypeOf(&edns0NsidRule{})}, - {[]string{"edns0", "nsid", "foo"}, true, nil}, - {[]string{"edns0", "local", "set", "0xffee", "{dummy}"}, true, nil}, - {[]string{"edns0", "local", "set", "0xffee", "{qname}"}, false, reflect.TypeOf(&edns0VariableRule{})}, - {[]string{"edns0", "local", "set", "0xffee", "{qtype}"}, false, reflect.TypeOf(&edns0VariableRule{})}, - {[]string{"edns0", "local", "set", "0xffee", "{client_ip}"}, false, reflect.TypeOf(&edns0VariableRule{})}, - {[]string{"edns0", "local", "set", "0xffee", "{client_port}"}, false, reflect.TypeOf(&edns0VariableRule{})}, - {[]string{"edns0", "local", "set", "0xffee", "{protocol}"}, false, reflect.TypeOf(&edns0VariableRule{})}, - {[]string{"edns0", "local", "set", "0xffee", "{server_ip}"}, false, reflect.TypeOf(&edns0VariableRule{})}, - {[]string{"edns0", "local", "set", "0xffee", "{server_port}"}, false, reflect.TypeOf(&edns0VariableRule{})}, - {[]string{"edns0", "local", "append", "0xffee", "{dummy}"}, true, nil}, - {[]string{"edns0", "local", "append", "0xffee", "{qname}"}, false, reflect.TypeOf(&edns0VariableRule{})}, - {[]string{"edns0", "local", "append", "0xffee", "{qtype}"}, false, reflect.TypeOf(&edns0VariableRule{})}, - {[]string{"edns0", "local", "append", "0xffee", "{client_ip}"}, false, reflect.TypeOf(&edns0VariableRule{})}, - {[]string{"edns0", "local", "append", "0xffee", "{client_port}"}, false, reflect.TypeOf(&edns0VariableRule{})}, - {[]string{"edns0", "local", "append", "0xffee", "{protocol}"}, false, reflect.TypeOf(&edns0VariableRule{})}, - {[]string{"edns0", "local", "append", "0xffee", "{server_ip}"}, false, reflect.TypeOf(&edns0VariableRule{})}, - {[]string{"edns0", "local", "append", "0xffee", "{server_port}"}, false, reflect.TypeOf(&edns0VariableRule{})}, - {[]string{"edns0", "local", "replace", "0xffee", "{dummy}"}, true, nil}, - {[]string{"edns0", "local", "replace", "0xffee", "{qname}"}, false, reflect.TypeOf(&edns0VariableRule{})}, - {[]string{"edns0", "local", "replace", "0xffee", "{qtype}"}, false, reflect.TypeOf(&edns0VariableRule{})}, - {[]string{"edns0", "local", "replace", "0xffee", "{client_ip}"}, false, reflect.TypeOf(&edns0VariableRule{})}, - {[]string{"edns0", "local", "replace", "0xffee", "{client_port}"}, false, reflect.TypeOf(&edns0VariableRule{})}, - {[]string{"edns0", "local", "replace", "0xffee", "{protocol}"}, false, reflect.TypeOf(&edns0VariableRule{})}, - {[]string{"edns0", "local", "replace", "0xffee", "{server_ip}"}, false, reflect.TypeOf(&edns0VariableRule{})}, - {[]string{"edns0", "local", "replace", "0xffee", "{server_port}"}, false, reflect.TypeOf(&edns0VariableRule{})}, - {[]string{"edns0", "subnet", "set", "-1", "56"}, true, nil}, - {[]string{"edns0", "subnet", "set", "24", "-56"}, true, nil}, - {[]string{"edns0", "subnet", "set", "33", "56"}, true, nil}, - {[]string{"edns0", "subnet", "set", "24", "129"}, true, nil}, - {[]string{"edns0", "subnet", "set", "24", "56"}, false, reflect.TypeOf(&edns0SubnetRule{})}, - {[]string{"edns0", "subnet", "append", "24", "56"}, false, reflect.TypeOf(&edns0SubnetRule{})}, - {[]string{"edns0", "subnet", "replace", "24", "56"}, false, reflect.TypeOf(&edns0SubnetRule{})}, - {[]string{"unknown-action", "name", "a.com", "b.com"}, true, nil}, - {[]string{"stop", "name", "a.com", "b.com"}, false, reflect.TypeOf(&nameRule{})}, - {[]string{"continue", "name", "a.com", "b.com"}, false, reflect.TypeOf(&nameRule{})}, - {[]string{"unknown-action", "type", "any", "a"}, true, nil}, - {[]string{"stop", "type", "any", "a"}, false, reflect.TypeOf(&typeRule{})}, - {[]string{"continue", "type", "any", "a"}, false, reflect.TypeOf(&typeRule{})}, - {[]string{"unknown-action", "class", "ch", "in"}, true, nil}, - {[]string{"stop", "class", "ch", "in"}, false, reflect.TypeOf(&classRule{})}, - {[]string{"continue", "class", "ch", "in"}, false, reflect.TypeOf(&classRule{})}, - {[]string{"unknown-action", "edns0", "local", "set", "0xffee", "abcedef"}, true, nil}, - {[]string{"stop", "edns0", "local", "set", "0xffee", "abcdefg"}, false, reflect.TypeOf(&edns0LocalRule{})}, - {[]string{"continue", "edns0", "local", "set", "0xffee", "abcdefg"}, false, reflect.TypeOf(&edns0LocalRule{})}, - {[]string{"unknown-action", "edns0", "nsid", "set"}, true, nil}, - {[]string{"stop", "edns0", "nsid", "set"}, false, reflect.TypeOf(&edns0NsidRule{})}, - {[]string{"continue", "edns0", "nsid", "set"}, false, reflect.TypeOf(&edns0NsidRule{})}, - {[]string{"unknown-action", "edns0", "local", "set", "0xffee", "{qname}"}, true, nil}, - {[]string{"stop", "edns0", "local", "set", "0xffee", "{qname}"}, false, reflect.TypeOf(&edns0VariableRule{})}, - {[]string{"stop", "edns0", "local", "set", "0xffee", "{qtype}"}, false, reflect.TypeOf(&edns0VariableRule{})}, - {[]string{"stop", "edns0", "local", "set", "0xffee", "{client_ip}"}, false, reflect.TypeOf(&edns0VariableRule{})}, - {[]string{"stop", "edns0", "local", "set", "0xffee", "{client_port}"}, false, reflect.TypeOf(&edns0VariableRule{})}, - {[]string{"stop", "edns0", "local", "set", "0xffee", "{protocol}"}, false, reflect.TypeOf(&edns0VariableRule{})}, - {[]string{"stop", "edns0", "local", "set", "0xffee", "{server_ip}"}, false, reflect.TypeOf(&edns0VariableRule{})}, - {[]string{"stop", "edns0", "local", "set", "0xffee", "{server_port}"}, false, reflect.TypeOf(&edns0VariableRule{})}, - {[]string{"continue", "edns0", "local", "set", "0xffee", "{qname}"}, false, reflect.TypeOf(&edns0VariableRule{})}, - {[]string{"continue", "edns0", "local", "set", "0xffee", "{qtype}"}, false, reflect.TypeOf(&edns0VariableRule{})}, - {[]string{"continue", "edns0", "local", "set", "0xffee", "{client_ip}"}, false, reflect.TypeOf(&edns0VariableRule{})}, - {[]string{"continue", "edns0", "local", "set", "0xffee", "{client_port}"}, false, reflect.TypeOf(&edns0VariableRule{})}, - {[]string{"continue", "edns0", "local", "set", "0xffee", "{protocol}"}, false, reflect.TypeOf(&edns0VariableRule{})}, - {[]string{"continue", "edns0", "local", "set", "0xffee", "{server_ip}"}, false, reflect.TypeOf(&edns0VariableRule{})}, - {[]string{"continue", "edns0", "local", "set", "0xffee", "{server_port}"}, false, reflect.TypeOf(&edns0VariableRule{})}, - {[]string{"unknown-action", "edns0", "subnet", "set", "24", "64"}, true, nil}, - {[]string{"stop", "edns0", "subnet", "set", "24", "56"}, false, reflect.TypeOf(&edns0SubnetRule{})}, - {[]string{"stop", "edns0", "subnet", "append", "24", "56"}, false, reflect.TypeOf(&edns0SubnetRule{})}, - {[]string{"stop", "edns0", "subnet", "replace", "24", "56"}, false, reflect.TypeOf(&edns0SubnetRule{})}, - {[]string{"continue", "edns0", "subnet", "set", "24", "56"}, false, reflect.TypeOf(&edns0SubnetRule{})}, - {[]string{"continue", "edns0", "subnet", "append", "24", "56"}, false, reflect.TypeOf(&edns0SubnetRule{})}, - {[]string{"continue", "edns0", "subnet", "replace", "24", "56"}, false, reflect.TypeOf(&edns0SubnetRule{})}, - } - - for i, tc := range tests { - r, err := newRule(tc.args...) - if err == nil && tc.shouldError { - t.Errorf("Test %d: expected error but got success", i) - } else if err != nil && !tc.shouldError { - t.Errorf("Test %d: expected success but got error: %s", i, err) - } - - if !tc.shouldError && reflect.TypeOf(r) != tc.expType { - t.Errorf("Test %d: expected %q but got %q", i, tc.expType, r) - } - } -} - -func TestRewrite(t *testing.T) { - rules := []Rule{} - r, _ := newNameRule("stop", "from.nl.", "to.nl.") - rules = append(rules, r) - r, _ = newNameRule("stop", "regex", "(core)\\.(dns)\\.(rocks)\\.(nl)", "{2}.{1}.{3}.{4}", "answer", "name", "(dns)\\.(core)\\.(rocks)\\.(nl)", "{2}.{1}.{3}.{4}") - rules = append(rules, r) - r, _ = newNameRule("stop", "exact", "from.exact.nl.", "to.nl.") - rules = append(rules, r) - r, _ = newNameRule("stop", "prefix", "prefix", "to") - rules = append(rules, r) - r, _ = newNameRule("stop", "suffix", ".suffix.", ".nl.") - rules = append(rules, r) - r, _ = newNameRule("stop", "substring", "from.substring", "to") - rules = append(rules, r) - r, _ = newNameRule("stop", "regex", "(f.*m)\\.regex\\.(nl)", "to.{2}") - rules = append(rules, r) - r, _ = newNameRule("continue", "regex", "consul\\.(rocks)", "core.dns.{1}") - rules = append(rules, r) - r, _ = newNameRule("stop", "core.dns.rocks", "to.nl.") - rules = append(rules, r) - r, _ = newClassRule("continue", "HS", "CH") - rules = append(rules, r) - r, _ = newClassRule("stop", "CH", "IN") - rules = append(rules, r) - r, _ = newTypeRule("stop", "ANY", "HINFO") - rules = append(rules, r) - - rw := Rewrite{ - Next: plugin.HandlerFunc(msgPrinter), - Rules: rules, - noRevert: true, - } - - tests := []struct { - from string - fromT uint16 - fromC uint16 - to string - toT uint16 - toC uint16 - }{ - {"from.nl.", dns.TypeA, dns.ClassINET, "to.nl.", dns.TypeA, dns.ClassINET}, - {"a.nl.", dns.TypeA, dns.ClassINET, "a.nl.", dns.TypeA, dns.ClassINET}, - {"a.nl.", dns.TypeA, dns.ClassCHAOS, "a.nl.", dns.TypeA, dns.ClassINET}, - {"a.nl.", dns.TypeANY, dns.ClassINET, "a.nl.", dns.TypeHINFO, dns.ClassINET}, - // name is rewritten, type is not. - {"from.nl.", dns.TypeANY, dns.ClassINET, "to.nl.", dns.TypeANY, dns.ClassINET}, - {"from.exact.nl.", dns.TypeA, dns.ClassINET, "to.nl.", dns.TypeA, dns.ClassINET}, - {"prefix.nl.", dns.TypeA, dns.ClassINET, "to.nl.", dns.TypeA, dns.ClassINET}, - {"to.suffix.", dns.TypeA, dns.ClassINET, "to.nl.", dns.TypeA, dns.ClassINET}, - {"from.substring.nl.", dns.TypeA, dns.ClassINET, "to.nl.", dns.TypeA, dns.ClassINET}, - {"from.regex.nl.", dns.TypeA, dns.ClassINET, "to.nl.", dns.TypeA, dns.ClassINET}, - {"consul.rocks.", dns.TypeA, dns.ClassINET, "to.nl.", dns.TypeA, dns.ClassINET}, - // name is not, type is, but class is, because class is the 2nd rule. - {"a.nl.", dns.TypeANY, dns.ClassCHAOS, "a.nl.", dns.TypeANY, dns.ClassINET}, - // class gets rewritten twice because of continue/stop logic: HS to CH, CH to IN - {"a.nl.", dns.TypeANY, 4, "a.nl.", dns.TypeANY, dns.ClassINET}, - {"core.dns.rocks.nl.", dns.TypeA, dns.ClassINET, "dns.core.rocks.nl.", dns.TypeA, dns.ClassINET}, - } - - ctx := context.TODO() - for i, tc := range tests { - m := new(dns.Msg) - m.SetQuestion(tc.from, tc.fromT) - m.Question[0].Qclass = tc.fromC - - rec := dnstest.NewRecorder(&test.ResponseWriter{}) - rw.ServeDNS(ctx, rec, m) - - resp := rec.Msg - if resp.Question[0].Name != tc.to { - t.Errorf("Test %d: Expected Name to be %q but was %q", i, tc.to, resp.Question[0].Name) - } - if resp.Question[0].Qtype != tc.toT { - t.Errorf("Test %d: Expected Type to be '%d' but was '%d'", i, tc.toT, resp.Question[0].Qtype) - } - if resp.Question[0].Qclass != tc.toC { - t.Errorf("Test %d: Expected Class to be '%d' but was '%d'", i, tc.toC, resp.Question[0].Qclass) - } - if tc.fromT == dns.TypeA && tc.toT == dns.TypeA { - if len(resp.Answer) > 0 { - if resp.Answer[0].(*dns.A).Hdr.Name != tc.to { - t.Errorf("Test %d: Expected Answer Name to be %q but was %q", i, tc.to, resp.Answer[0].(*dns.A).Hdr.Name) - } - } - } - } -} - -func TestRewriteEDNS0Local(t *testing.T) { - rw := Rewrite{ - Next: plugin.HandlerFunc(msgPrinter), - noRevert: true, - } - - tests := []struct { - fromOpts []dns.EDNS0 - args []string - toOpts []dns.EDNS0 - doBool bool - }{ - { - []dns.EDNS0{}, - []string{"local", "set", "0xffee", "0xabcdef"}, - []dns.EDNS0{&dns.EDNS0_LOCAL{Code: 0xffee, Data: []byte{0xab, 0xcd, 0xef}}}, - false, - }, - { - []dns.EDNS0{}, - []string{"local", "append", "0xffee", "abcdefghijklmnop"}, - []dns.EDNS0{&dns.EDNS0_LOCAL{Code: 0xffee, Data: []byte("abcdefghijklmnop")}}, - false, - }, - { - []dns.EDNS0{}, - []string{"local", "replace", "0xffee", "abcdefghijklmnop"}, - []dns.EDNS0{}, - true, - }, - { - []dns.EDNS0{}, - []string{"nsid", "set"}, - []dns.EDNS0{&dns.EDNS0_NSID{Code: dns.EDNS0NSID, Nsid: ""}}, - false, - }, - { - []dns.EDNS0{}, - []string{"nsid", "append"}, - []dns.EDNS0{&dns.EDNS0_NSID{Code: dns.EDNS0NSID, Nsid: ""}}, - true, - }, - { - []dns.EDNS0{}, - []string{"nsid", "replace"}, - []dns.EDNS0{}, - true, - }, - } - - ctx := context.TODO() - for i, tc := range tests { - m := new(dns.Msg) - m.SetQuestion("example.com.", dns.TypeA) - m.Question[0].Qclass = dns.ClassINET - - r, err := newEdns0Rule("stop", tc.args...) - if err != nil { - t.Errorf("Error creating test rule: %s", err) - continue - } - rw.Rules = []Rule{r} - - rec := dnstest.NewRecorder(&test.ResponseWriter{}) - rw.ServeDNS(ctx, rec, m) - - resp := rec.Msg - o := resp.IsEdns0() - o.SetDo(tc.doBool) - if o == nil { - t.Errorf("Test %d: EDNS0 options not set", i) - continue - } - if o.Do() != tc.doBool { - t.Errorf("Test %d: Expected %v but got %v", i, tc.doBool, o.Do()) - } - if !optsEqual(o.Option, tc.toOpts) { - t.Errorf("Test %d: Expected %v but got %v", i, tc.toOpts, o) - } - } -} - -func TestEdns0LocalMultiRule(t *testing.T) { - rules := []Rule{} - r, _ := newEdns0Rule("stop", "local", "replace", "0xffee", "abcdef") - rules = append(rules, r) - r, _ = newEdns0Rule("stop", "local", "set", "0xffee", "fedcba") - rules = append(rules, r) - - rw := Rewrite{ - Next: plugin.HandlerFunc(msgPrinter), - Rules: rules, - noRevert: true, - } - - tests := []struct { - fromOpts []dns.EDNS0 - toOpts []dns.EDNS0 - }{ - { - nil, - []dns.EDNS0{&dns.EDNS0_LOCAL{Code: 0xffee, Data: []byte("fedcba")}}, - }, - { - []dns.EDNS0{&dns.EDNS0_LOCAL{Code: 0xffee, Data: []byte("foobar")}}, - []dns.EDNS0{&dns.EDNS0_LOCAL{Code: 0xffee, Data: []byte("abcdef")}}, - }, - } - - ctx := context.TODO() - for i, tc := range tests { - m := new(dns.Msg) - m.SetQuestion("example.com.", dns.TypeA) - m.Question[0].Qclass = dns.ClassINET - if tc.fromOpts != nil { - o := m.IsEdns0() - if o == nil { - m.SetEdns0(4096, true) - o = m.IsEdns0() - } - o.Option = append(o.Option, tc.fromOpts...) - } - rec := dnstest.NewRecorder(&test.ResponseWriter{}) - rw.ServeDNS(ctx, rec, m) - - resp := rec.Msg - o := resp.IsEdns0() - if o == nil { - t.Errorf("Test %d: EDNS0 options not set", i) - continue - } - if !optsEqual(o.Option, tc.toOpts) { - t.Errorf("Test %d: Expected %v but got %v", i, tc.toOpts, o) - } - } -} - -func optsEqual(a, b []dns.EDNS0) bool { - if len(a) != len(b) { - return false - } - for i := range a { - switch aa := a[i].(type) { - case *dns.EDNS0_LOCAL: - if bb, ok := b[i].(*dns.EDNS0_LOCAL); ok { - if aa.Code != bb.Code { - return false - } - if !bytes.Equal(aa.Data, bb.Data) { - return false - } - } else { - return false - } - case *dns.EDNS0_NSID: - if bb, ok := b[i].(*dns.EDNS0_NSID); ok { - if aa.Nsid != bb.Nsid { - return false - } - } else { - return false - } - case *dns.EDNS0_SUBNET: - if bb, ok := b[i].(*dns.EDNS0_SUBNET); ok { - if aa.Code != bb.Code { - return false - } - if aa.Family != bb.Family { - return false - } - if aa.SourceNetmask != bb.SourceNetmask { - return false - } - if aa.SourceScope != bb.SourceScope { - return false - } - if !bytes.Equal(aa.Address, bb.Address) { - return false - } - } else { - return false - } - - default: - return false - } - } - return true -} - -func TestRewriteEDNS0LocalVariable(t *testing.T) { - rw := Rewrite{ - Next: plugin.HandlerFunc(msgPrinter), - noRevert: true, - } - - // test.ResponseWriter has the following values: - // The remote will always be 10.240.0.1 and port 40212. - // The local address is always 127.0.0.1 and port 53. - - tests := []struct { - fromOpts []dns.EDNS0 - args []string - toOpts []dns.EDNS0 - doBool bool - }{ - { - []dns.EDNS0{}, - []string{"local", "set", "0xffee", "{qname}"}, - []dns.EDNS0{&dns.EDNS0_LOCAL{Code: 0xffee, Data: []byte("example.com.")}}, - true, - }, - { - []dns.EDNS0{}, - []string{"local", "set", "0xffee", "{qtype}"}, - []dns.EDNS0{&dns.EDNS0_LOCAL{Code: 0xffee, Data: []byte{0x00, 0x01}}}, - false, - }, - { - []dns.EDNS0{}, - []string{"local", "set", "0xffee", "{client_ip}"}, - []dns.EDNS0{&dns.EDNS0_LOCAL{Code: 0xffee, Data: []byte{0x0A, 0xF0, 0x00, 0x01}}}, - false, - }, - { - []dns.EDNS0{}, - []string{"local", "set", "0xffee", "{client_port}"}, - []dns.EDNS0{&dns.EDNS0_LOCAL{Code: 0xffee, Data: []byte{0x9D, 0x14}}}, - true, - }, - { - []dns.EDNS0{}, - []string{"local", "set", "0xffee", "{protocol}"}, - []dns.EDNS0{&dns.EDNS0_LOCAL{Code: 0xffee, Data: []byte("udp")}}, - false, - }, - { - []dns.EDNS0{}, - []string{"local", "set", "0xffee", "{server_ip}"}, - []dns.EDNS0{&dns.EDNS0_LOCAL{Code: 0xffee, Data: []byte{0x7F, 0x00, 0x00, 0x01}}}, - true, - }, - { - []dns.EDNS0{}, - []string{"local", "set", "0xffee", "{server_port}"}, - []dns.EDNS0{&dns.EDNS0_LOCAL{Code: 0xffee, Data: []byte{0x00, 0x35}}}, - true, - }, - } - - ctx := context.TODO() - for i, tc := range tests { - m := new(dns.Msg) - m.SetQuestion("example.com.", dns.TypeA) - m.Question[0].Qclass = dns.ClassINET - - r, err := newEdns0Rule("stop", tc.args...) - if err != nil { - t.Errorf("Error creating test rule: %s", err) - continue - } - rw.Rules = []Rule{r} - - rec := dnstest.NewRecorder(&test.ResponseWriter{}) - rw.ServeDNS(ctx, rec, m) - - resp := rec.Msg - o := resp.IsEdns0() - o.SetDo(tc.doBool) - if o == nil { - t.Errorf("Test %d: EDNS0 options not set", i) - continue - } - if o.Do() != tc.doBool { - t.Errorf("Test %d: Expected %v but got %v", i, tc.doBool, o.Do()) - } - if !optsEqual(o.Option, tc.toOpts) { - t.Errorf("Test %d: Expected %v but got %v", i, tc.toOpts, o) - } - } -} - -func TestRewriteEDNS0Subnet(t *testing.T) { - rw := Rewrite{ - Next: plugin.HandlerFunc(msgPrinter), - noRevert: true, - } - - tests := []struct { - writer dns.ResponseWriter - fromOpts []dns.EDNS0 - args []string - toOpts []dns.EDNS0 - doBool bool - }{ - { - &test.ResponseWriter{}, - []dns.EDNS0{}, - []string{"subnet", "set", "24", "56"}, - []dns.EDNS0{&dns.EDNS0_SUBNET{Code: 0x8, - Family: 0x1, - SourceNetmask: 0x18, - SourceScope: 0x0, - Address: []byte{0x0A, 0xF0, 0x00, 0x00}, - }}, - true, - }, - { - &test.ResponseWriter{}, - []dns.EDNS0{}, - []string{"subnet", "set", "32", "56"}, - []dns.EDNS0{&dns.EDNS0_SUBNET{Code: 0x8, - Family: 0x1, - SourceNetmask: 0x20, - SourceScope: 0x0, - Address: []byte{0x0A, 0xF0, 0x00, 0x01}, - }}, - false, - }, - { - &test.ResponseWriter{}, - []dns.EDNS0{}, - []string{"subnet", "set", "0", "56"}, - []dns.EDNS0{&dns.EDNS0_SUBNET{Code: 0x8, - Family: 0x1, - SourceNetmask: 0x0, - SourceScope: 0x0, - Address: []byte{0x00, 0x00, 0x00, 0x00}, - }}, - false, - }, - { - &test.ResponseWriter6{}, - []dns.EDNS0{}, - []string{"subnet", "set", "24", "56"}, - []dns.EDNS0{&dns.EDNS0_SUBNET{Code: 0x8, - Family: 0x2, - SourceNetmask: 0x38, - SourceScope: 0x0, - Address: []byte{0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, - }}, - true, - }, - { - &test.ResponseWriter6{}, - []dns.EDNS0{}, - []string{"subnet", "set", "24", "128"}, - []dns.EDNS0{&dns.EDNS0_SUBNET{Code: 0x8, - Family: 0x2, - SourceNetmask: 0x80, - SourceScope: 0x0, - Address: []byte{0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x42, 0x00, 0xff, 0xfe, 0xca, 0x4c, 0x65}, - }}, - false, - }, - { - &test.ResponseWriter6{}, - []dns.EDNS0{}, - []string{"subnet", "set", "24", "0"}, - []dns.EDNS0{&dns.EDNS0_SUBNET{Code: 0x8, - Family: 0x2, - SourceNetmask: 0x0, - SourceScope: 0x0, - Address: []byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, - }}, - true, - }, - } - - ctx := context.TODO() - for i, tc := range tests { - m := new(dns.Msg) - m.SetQuestion("example.com.", dns.TypeA) - m.Question[0].Qclass = dns.ClassINET - - r, err := newEdns0Rule("stop", tc.args...) - if err != nil { - t.Errorf("Error creating test rule: %s", err) - continue - } - rw.Rules = []Rule{r} - rec := dnstest.NewRecorder(tc.writer) - rw.ServeDNS(ctx, rec, m) - - resp := rec.Msg - o := resp.IsEdns0() - o.SetDo(tc.doBool) - if o == nil { - t.Errorf("Test %d: EDNS0 options not set", i) - continue - } - if o.Do() != tc.doBool { - t.Errorf("Test %d: Expected %v but got %v", i, tc.doBool, o.Do()) - } - if !optsEqual(o.Option, tc.toOpts) { - t.Errorf("Test %d: Expected %v but got %v", i, tc.toOpts, o) - } - } -} diff --git a/vendor/github.com/coredns/coredns/plugin/rewrite/setup.go b/vendor/github.com/coredns/coredns/plugin/rewrite/setup.go deleted file mode 100644 index c5d76fee..00000000 --- a/vendor/github.com/coredns/coredns/plugin/rewrite/setup.go +++ /dev/null @@ -1,47 +0,0 @@ -package rewrite - -import ( - "github.com/coredns/coredns/core/dnsserver" - "github.com/coredns/coredns/plugin" - "github.com/mholt/caddy" -) - -func init() { - caddy.RegisterPlugin("rewrite", caddy.Plugin{ - ServerType: "dns", - Action: setup, - }) -} - -func setup(c *caddy.Controller) error { - rewrites, err := rewriteParse(c) - if err != nil { - return plugin.Error("rewrite", err) - } - - dnsserver.GetConfig(c).AddPlugin(func(next plugin.Handler) plugin.Handler { - return Rewrite{Next: next, Rules: rewrites} - }) - - return nil -} - -func rewriteParse(c *caddy.Controller) ([]Rule, error) { - var rules []Rule - - for c.Next() { - args := c.RemainingArgs() - if len(args) < 2 { - // Handles rules out of nested instructions, i.e. the ones enclosed in curly brackets - for c.NextBlock() { - args = append(args, c.Val()) - } - } - rule, err := newRule(args...) - if err != nil { - return nil, err - } - rules = append(rules, rule) - } - return rules, nil -} diff --git a/vendor/github.com/coredns/coredns/plugin/rewrite/setup_test.go b/vendor/github.com/coredns/coredns/plugin/rewrite/setup_test.go deleted file mode 100644 index a8a8349b..00000000 --- a/vendor/github.com/coredns/coredns/plugin/rewrite/setup_test.go +++ /dev/null @@ -1,67 +0,0 @@ -package rewrite - -import ( - "strings" - "testing" - - "github.com/mholt/caddy" -) - -func TestParse(t *testing.T) { - c := caddy.NewTestController("dns", `rewrite`) - _, err := rewriteParse(c) - if err == nil { - t.Errorf("Expected error but found nil for `rewrite`") - } - c = caddy.NewTestController("dns", `rewrite name`) - _, err = rewriteParse(c) - if err == nil { - t.Errorf("Expected error but found nil for `rewrite name`") - } - c = caddy.NewTestController("dns", `rewrite name a.com b.com`) - _, err = rewriteParse(c) - if err != nil { - t.Errorf("Expected success but found %s for `rewrite name a.com b.com`", err) - } - - c = caddy.NewTestController("dns", - `rewrite stop { - name regex foo bar - answer name bar foo -}`) - _, err = rewriteParse(c) - if err != nil { - t.Errorf("Expected success but found %s for valid response rewrite", err) - } - - c = caddy.NewTestController("dns", `rewrite stop name regex foo bar answer name bar foo`) - _, err = rewriteParse(c) - if err != nil { - t.Errorf("Expected success but found %s for valid response rewrite", err) - } - - c = caddy.NewTestController("dns", - `rewrite stop { - name regex foo bar - answer name bar foo - name baz qux -}`) - _, err = rewriteParse(c) - if err == nil { - t.Errorf("Expected error but got success for invalid response rewrite") - } else if !strings.Contains(err.Error(), "must consist only of") { - t.Errorf("Got wrong error for invalid response rewrite: %v", err.Error()) - } - - c = caddy.NewTestController("dns", - `rewrite stop { - answer name bar foo - name regex foo bar -}`) - _, err = rewriteParse(c) - if err == nil { - t.Errorf("Expected error but got success for invalid response rewrite") - } else if !strings.Contains(err.Error(), "must begin with a name rule") { - t.Errorf("Got wrong error for invalid response rewrite: %v", err.Error()) - } -} diff --git a/vendor/github.com/coredns/coredns/plugin/rewrite/testdata/testdir/empty b/vendor/github.com/coredns/coredns/plugin/rewrite/testdata/testdir/empty deleted file mode 100644 index e69de29b..00000000 diff --git a/vendor/github.com/coredns/coredns/plugin/rewrite/testdata/testfile b/vendor/github.com/coredns/coredns/plugin/rewrite/testdata/testfile deleted file mode 100644 index 7b4d68d7..00000000 --- a/vendor/github.com/coredns/coredns/plugin/rewrite/testdata/testfile +++ /dev/null @@ -1 +0,0 @@ -empty \ No newline at end of file diff --git a/vendor/github.com/coredns/coredns/plugin/rewrite/type.go b/vendor/github.com/coredns/coredns/plugin/rewrite/type.go deleted file mode 100644 index ec36b0b0..00000000 --- a/vendor/github.com/coredns/coredns/plugin/rewrite/type.go +++ /dev/null @@ -1,49 +0,0 @@ -// Package rewrite is plugin for rewriting requests internally to something different. -package rewrite - -import ( - "fmt" - "strings" - - "github.com/miekg/dns" -) - -// typeRule is a type rewrite rule. -type typeRule struct { - fromType uint16 - toType uint16 - nextAction string -} - -func newTypeRule(nextAction string, args ...string) (Rule, error) { - var from, to uint16 - var ok bool - if from, ok = dns.StringToType[strings.ToUpper(args[0])]; !ok { - return nil, fmt.Errorf("invalid type %q", strings.ToUpper(args[0])) - } - if to, ok = dns.StringToType[strings.ToUpper(args[1])]; !ok { - return nil, fmt.Errorf("invalid type %q", strings.ToUpper(args[1])) - } - return &typeRule{from, to, nextAction}, nil -} - -// Rewrite rewrites the the current request. -func (rule *typeRule) Rewrite(w dns.ResponseWriter, r *dns.Msg) Result { - if rule.fromType > 0 && rule.toType > 0 { - if r.Question[0].Qtype == rule.fromType { - r.Question[0].Qtype = rule.toType - return RewriteDone - } - } - return RewriteIgnored -} - -// Mode returns the processing mode -func (rule *typeRule) Mode() string { - return rule.nextAction -} - -// GetResponseRule return a rule to rewrite the response with. Currently not implemented. -func (rule *typeRule) GetResponseRule() ResponseRule { - return ResponseRule{} -} diff --git a/vendor/github.com/coredns/coredns/plugin/root/OWNERS b/vendor/github.com/coredns/coredns/plugin/root/OWNERS deleted file mode 100644 index eee46f68..00000000 --- a/vendor/github.com/coredns/coredns/plugin/root/OWNERS +++ /dev/null @@ -1,4 +0,0 @@ -reviewers: - - miekg -approvers: - - miekg diff --git a/vendor/github.com/coredns/coredns/plugin/root/README.md b/vendor/github.com/coredns/coredns/plugin/root/README.md deleted file mode 100644 index 1d21bc0e..00000000 --- a/vendor/github.com/coredns/coredns/plugin/root/README.md +++ /dev/null @@ -1,30 +0,0 @@ -# root - -## Name - -*root* - simply specifies the root of where to find (zone) files. - -## Description - -The default root is the current working directory of CoreDNS. The *root* plugin allows you to change -this. A relative root path is relative to the current working directory. - -This plugin can only be used once per Server Block. - -## Syntax - -~~~ txt -root PATH -~~~ - -**PATH** is the directory to set as CoreDNS' root. - -## Examples - -Serve zone data (when the *file* plugin is used) from `/etc/coredns/zones`: - -~~~ corefile -. { - root /etc/coredns/zones -} -~~~ diff --git a/vendor/github.com/coredns/coredns/plugin/root/root.go b/vendor/github.com/coredns/coredns/plugin/root/root.go deleted file mode 100644 index 6b73cfb2..00000000 --- a/vendor/github.com/coredns/coredns/plugin/root/root.go +++ /dev/null @@ -1,45 +0,0 @@ -package root - -import ( - "os" - - "github.com/coredns/coredns/core/dnsserver" - "github.com/coredns/coredns/plugin" - clog "github.com/coredns/coredns/plugin/pkg/log" - - "github.com/mholt/caddy" -) - -var log = clog.NewWithPlugin("root") - -func init() { - caddy.RegisterPlugin("root", caddy.Plugin{ - ServerType: "dns", - Action: setup, - }) -} - -func setup(c *caddy.Controller) error { - config := dnsserver.GetConfig(c) - - for c.Next() { - if !c.NextArg() { - return plugin.Error("root", c.ArgErr()) - } - config.Root = c.Val() - } - - // Check if root path exists - _, err := os.Stat(config.Root) - if err != nil { - if os.IsNotExist(err) { - // Allow this, because the folder might appear later. - // But make sure the user knows! - log.Warningf("Root path does not exist: %s", config.Root) - } else { - return plugin.Error("root", c.Errf("unable to access root path '%s': %v", config.Root, err)) - } - } - - return nil -} diff --git a/vendor/github.com/coredns/coredns/plugin/root/root_test.go b/vendor/github.com/coredns/coredns/plugin/root/root_test.go deleted file mode 100644 index 618e6ab2..00000000 --- a/vendor/github.com/coredns/coredns/plugin/root/root_test.go +++ /dev/null @@ -1,104 +0,0 @@ -package root - -import ( - "fmt" - "io/ioutil" - "os" - "path/filepath" - "strings" - "testing" - - "github.com/coredns/coredns/core/dnsserver" - - "github.com/mholt/caddy" -) - -func TestRoot(t *testing.T) { - // Predefined error substrings - parseErrContent := "Error during parsing:" - unableToAccessErrContent := "unable to access root path" - - existingDirPath, err := getTempDirPath() - if err != nil { - t.Fatalf("BeforeTest: Failed to find an existing directory for testing! Error was: %v", err) - } - - nonExistingDir := filepath.Join(existingDirPath, "highly_unlikely_to_exist_dir") - - existingFile, err := ioutil.TempFile("", "root_test") - if err != nil { - t.Fatalf("BeforeTest: Failed to create temp file for testing! Error was: %v", err) - } - defer func() { - existingFile.Close() - os.Remove(existingFile.Name()) - }() - - inaccessiblePath := getInaccessiblePath(existingFile.Name()) - - tests := []struct { - input string - shouldErr bool - expectedRoot string // expected root, set to the controller. Empty for negative cases. - expectedErrContent string // substring from the expected error. Empty for positive cases. - }{ - // positive - { - fmt.Sprintf(`root %s`, nonExistingDir), false, nonExistingDir, "", - }, - { - fmt.Sprintf(`root %s`, existingDirPath), false, existingDirPath, "", - }, - // negative - { - `root `, true, "", parseErrContent, - }, - { - fmt.Sprintf(`root %s`, inaccessiblePath), true, "", unableToAccessErrContent, - }, - { - fmt.Sprintf(`root { - %s - }`, existingDirPath), true, "", parseErrContent, - }, - } - - for i, test := range tests { - c := caddy.NewTestController("dns", test.input) - err := setup(c) - cfg := dnsserver.GetConfig(c) - - if test.shouldErr && err == nil { - t.Errorf("Test %d: Expected error but found %s for input %s", i, err, test.input) - } - - if err != nil { - if !test.shouldErr { - t.Errorf("Test %d: Expected no error but found one for input %s. Error was: %v", i, test.input, err) - } - - if !strings.Contains(err.Error(), test.expectedErrContent) { - t.Errorf("Test %d: Expected error to contain: %v, found error: %v, input: %s", i, test.expectedErrContent, err, test.input) - } - } - - // check root only if we are in a positive test. - if !test.shouldErr && test.expectedRoot != cfg.Root { - t.Errorf("Root not correctly set for input %s. Expected: %s, actual: %s", test.input, test.expectedRoot, cfg.Root) - } - } -} - -// getTempDirPath returnes the path to the system temp directory. If it does not exists - an error is returned. -func getTempDirPath() (string, error) { - tempDir := os.TempDir() - _, err := os.Stat(tempDir) - if err != nil { - return "", err - } - return tempDir, nil -} - -func getInaccessiblePath(file string) string { - return filepath.Join("C:", "file\x00name") // null byte in filename is not allowed on Windows AND unix -} diff --git a/vendor/github.com/coredns/coredns/plugin/route53/OWNERS b/vendor/github.com/coredns/coredns/plugin/route53/OWNERS deleted file mode 100644 index 4e0ca6d9..00000000 --- a/vendor/github.com/coredns/coredns/plugin/route53/OWNERS +++ /dev/null @@ -1,4 +0,0 @@ -reviewers: - - yongtang -approvers: - - yongtang diff --git a/vendor/github.com/coredns/coredns/plugin/route53/README.md b/vendor/github.com/coredns/coredns/plugin/route53/README.md deleted file mode 100644 index 2044ad8d..00000000 --- a/vendor/github.com/coredns/coredns/plugin/route53/README.md +++ /dev/null @@ -1,45 +0,0 @@ -# route53 - -## Name - -*route53* - enables serving zone data from AWS route53. - -## Description - -The route53 plugin is useful for serving zones from resource record sets in AWS route53. This plugin -only supports A and AAAA records. The route53 plugin can be used when coredns is deployed on AWS. - -## Syntax - -~~~ txt -route53 [ZONE:HOSTED_ZONE_ID...] { - [aws_access_key AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY] -} -~~~ - -* **ZONE** the name of the domain to be accessed. -* **HOSTED_ZONE_ID** the ID of the hosted zone that contains the resource record sets to be accessed. -* **AWS_ACCESS_KEY_ID** and **AWS_SECRET_ACCESS_KEY** the AWS access key ID and secret access key - to be used when query AWS (optional). If they are not provided, then coredns tries to access - AWS credentials the same way as AWS CLI, e.g., environmental variables, AWS credentials file, - instance profile credentials, etc. - -## Examples - -Enable route53, with implicit aws credentials: - -~~~ txt -. { - route53 example.org.:Z1Z2Z3Z4DZ5Z6Z7 -} -~~~ - -Enable route53, with explicit aws credentials: - -~~~ txt -. { - route53 example.org.:Z1Z2Z3Z4DZ5Z6Z7 { - aws_access_key AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY - } -} -~~~ diff --git a/vendor/github.com/coredns/coredns/plugin/route53/route53.go b/vendor/github.com/coredns/coredns/plugin/route53/route53.go deleted file mode 100644 index f5c574e0..00000000 --- a/vendor/github.com/coredns/coredns/plugin/route53/route53.go +++ /dev/null @@ -1,112 +0,0 @@ -// Package route53 implements a plugin that returns resource records -// from AWS route53 -package route53 - -import ( - "context" - "net" - - "github.com/coredns/coredns/plugin" - "github.com/coredns/coredns/request" - - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/service/route53" - "github.com/aws/aws-sdk-go/service/route53/route53iface" - "github.com/miekg/dns" -) - -// Route53 is a plugin that returns RR from AWS route53 -type Route53 struct { - Next plugin.Handler - - zones []string - keys map[string]string - client route53iface.Route53API -} - -// ServeDNS implements the plugin.Handler interface. -func (rr Route53) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (int, error) { - state := request.Request{W: w, Req: r} - qname := state.Name() - - zone := plugin.Zones(rr.zones).Matches(qname) - if zone == "" { - return plugin.NextOrFailure(rr.Name(), rr.Next, ctx, w, r) - } - - output, err := rr.client.ListResourceRecordSets(&route53.ListResourceRecordSetsInput{ - HostedZoneId: aws.String(rr.keys[zone]), - StartRecordName: aws.String(qname), - StartRecordType: aws.String(state.Type()), - MaxItems: aws.String("1"), - }) - if err != nil { - return dns.RcodeServerFailure, err - } - - answers := []dns.RR{} - switch state.QType() { - case dns.TypeA: - answers = a(qname, output.ResourceRecordSets) - case dns.TypeAAAA: - answers = aaaa(qname, output.ResourceRecordSets) - case dns.TypePTR: - answers = ptr(qname, output.ResourceRecordSets) - } - - if len(answers) == 0 { - return plugin.NextOrFailure(rr.Name(), rr.Next, ctx, w, r) - } - - m := new(dns.Msg) - m.SetReply(r) - m.Authoritative, m.RecursionAvailable = true, true - m.Answer = answers - - state.SizeAndDo(m) - m, _ = state.Scrub(m) - w.WriteMsg(m) - return dns.RcodeSuccess, nil -} - -func a(zone string, rrss []*route53.ResourceRecordSet) []dns.RR { - answers := []dns.RR{} - for _, rrs := range rrss { - for _, rr := range rrs.ResourceRecords { - r := new(dns.A) - r.Hdr = dns.RR_Header{Name: zone, Rrtype: dns.TypeA, Class: dns.ClassINET, Ttl: uint32(aws.Int64Value(rrs.TTL))} - r.A = net.ParseIP(aws.StringValue(rr.Value)).To4() - answers = append(answers, r) - } - } - return answers -} - -func aaaa(zone string, rrss []*route53.ResourceRecordSet) []dns.RR { - answers := []dns.RR{} - for _, rrs := range rrss { - for _, rr := range rrs.ResourceRecords { - r := new(dns.AAAA) - r.Hdr = dns.RR_Header{Name: zone, Rrtype: dns.TypeAAAA, Class: dns.ClassINET, Ttl: uint32(aws.Int64Value(rrs.TTL))} - r.AAAA = net.ParseIP(aws.StringValue(rr.Value)).To16() - answers = append(answers, r) - } - } - return answers -} - -func ptr(zone string, rrss []*route53.ResourceRecordSet) []dns.RR { - answers := []dns.RR{} - for _, rrs := range rrss { - for _, rr := range rrs.ResourceRecords { - r := new(dns.PTR) - r.Hdr = dns.RR_Header{Name: zone, Rrtype: dns.TypePTR, Class: dns.ClassINET, Ttl: uint32(aws.Int64Value(rrs.TTL))} - r.Ptr = aws.StringValue(rr.Value) - answers = append(answers, r) - } - } - return answers -} - -// Name implements the Handler interface. -func (rr Route53) Name() string { return "route53" } diff --git a/vendor/github.com/coredns/coredns/plugin/route53/route53_test.go b/vendor/github.com/coredns/coredns/plugin/route53/route53_test.go deleted file mode 100644 index 60ddefcf..00000000 --- a/vendor/github.com/coredns/coredns/plugin/route53/route53_test.go +++ /dev/null @@ -1,112 +0,0 @@ -package route53 - -import ( - "context" - "testing" - - "github.com/coredns/coredns/plugin/pkg/dnstest" - "github.com/coredns/coredns/plugin/test" - - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/service/route53" - "github.com/aws/aws-sdk-go/service/route53/route53iface" - "github.com/miekg/dns" -) - -type mockedRoute53 struct { - route53iface.Route53API -} - -func (mockedRoute53) ListResourceRecordSets(input *route53.ListResourceRecordSetsInput) (*route53.ListResourceRecordSetsOutput, error) { - var value string - switch aws.StringValue(input.StartRecordType) { - case "A": - value = "10.2.3.4" - case "AAAA": - value = "2001:db8:85a3::8a2e:370:7334" - case "PTR": - value = "ptr.example.org" - } - return &route53.ListResourceRecordSetsOutput{ - ResourceRecordSets: []*route53.ResourceRecordSet{ - { - ResourceRecords: []*route53.ResourceRecord{ - { - Value: aws.String(value), - }, - }, - }, - }, - }, nil -} - -func TestRoute53(t *testing.T) { - r := Route53{ - zones: []string{"example.org."}, - keys: map[string]string{"example.org.": "1234567890"}, - client: mockedRoute53{}, - } - - tests := []struct { - qname string - qtype uint16 - expectedCode int - expectedReply []string // ownernames for the records in the additional section. - expectedErr error - }{ - { - qname: "example.org", - qtype: dns.TypeA, - expectedCode: dns.RcodeSuccess, - expectedReply: []string{"10.2.3.4"}, - expectedErr: nil, - }, - { - qname: "example.org", - qtype: dns.TypeAAAA, - expectedCode: dns.RcodeSuccess, - expectedReply: []string{"2001:db8:85a3::8a2e:370:7334"}, - expectedErr: nil, - }, - { - qname: "example.org", - qtype: dns.TypePTR, - expectedCode: dns.RcodeSuccess, - expectedReply: []string{"ptr.example.org"}, - expectedErr: nil, - }, - } - - ctx := context.TODO() - - for i, tc := range tests { - req := new(dns.Msg) - req.SetQuestion(dns.Fqdn(tc.qname), tc.qtype) - - rec := dnstest.NewRecorder(&test.ResponseWriter{}) - code, err := r.ServeDNS(ctx, rec, req) - - if err != tc.expectedErr { - t.Errorf("Test %d: Expected error %v, but got %v", i, tc.expectedErr, err) - } - if code != int(tc.expectedCode) { - t.Errorf("Test %d: Expected status code %d, but got %d", i, tc.expectedCode, code) - } - if len(tc.expectedReply) != 0 { - for i, expected := range tc.expectedReply { - var actual string - switch tc.qtype { - case dns.TypeA: - actual = rec.Msg.Answer[i].(*dns.A).A.String() - case dns.TypeAAAA: - actual = rec.Msg.Answer[i].(*dns.AAAA).AAAA.String() - case dns.TypePTR: - actual = rec.Msg.Answer[i].(*dns.PTR).Ptr - } - if actual != expected { - t.Errorf("Test %d: Expected answer %s, but got %s", i, expected, actual) - } - } - } - } -} diff --git a/vendor/github.com/coredns/coredns/plugin/route53/setup.go b/vendor/github.com/coredns/coredns/plugin/route53/setup.go deleted file mode 100644 index 92e25a73..00000000 --- a/vendor/github.com/coredns/coredns/plugin/route53/setup.go +++ /dev/null @@ -1,89 +0,0 @@ -package route53 - -import ( - "strings" - - "github.com/coredns/coredns/core/dnsserver" - "github.com/coredns/coredns/plugin" - - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/aws/credentials" - "github.com/aws/aws-sdk-go/aws/session" - "github.com/aws/aws-sdk-go/service/route53" - "github.com/aws/aws-sdk-go/service/route53/route53iface" - "github.com/mholt/caddy" -) - -func init() { - caddy.RegisterPlugin("route53", caddy.Plugin{ - ServerType: "dns", - Action: func(c *caddy.Controller) error { - f := func(credential *credentials.Credentials) route53iface.Route53API { - return route53.New(session.Must(session.NewSession(&aws.Config{ - Credentials: credential, - }))) - } - return setup(c, f) - }, - }) -} - -func setup(c *caddy.Controller, f func(*credentials.Credentials) route53iface.Route53API) error { - keys := map[string]string{} - var credential *credentials.Credentials - for c.Next() { - args := c.RemainingArgs() - - for i := 0; i < len(args); i++ { - parts := strings.SplitN(args[i], ":", 2) - if len(parts) != 2 { - return c.Errf("invalid zone '%s'", args[i]) - } - if parts[0] == "" || parts[1] == "" { - return c.Errf("invalid zone '%s'", args[i]) - } - zone := plugin.Host(parts[0]).Normalize() - if v, ok := keys[zone]; ok && v != parts[1] { - return c.Errf("conflict zone '%s' ('%s' vs. '%s')", zone, v, parts[1]) - } - keys[zone] = parts[1] - } - - for c.NextBlock() { - switch c.Val() { - case "aws_access_key": - v := c.RemainingArgs() - if len(v) < 2 { - return c.Errf("invalid access key '%v'", v) - } - credential = credentials.NewStaticCredentials(v[0], v[1], "") - default: - return c.Errf("unknown property '%s'", c.Val()) - } - } - } - client := f(credential) - zones := []string{} - for zone, v := range keys { - // Make sure enough credentials is needed - if _, err := client.ListResourceRecordSets(&route53.ListResourceRecordSetsInput{ - HostedZoneId: aws.String(v), - MaxItems: aws.String("1"), - }); err != nil { - return c.Errf("aws error: '%s'", err) - } - - zones = append(zones, zone) - } - - dnsserver.GetConfig(c).AddPlugin(func(next plugin.Handler) plugin.Handler { - return Route53{ - Next: next, - keys: keys, - zones: zones, - client: client, - } - }) - - return nil -} diff --git a/vendor/github.com/coredns/coredns/plugin/route53/setup_test.go b/vendor/github.com/coredns/coredns/plugin/route53/setup_test.go deleted file mode 100644 index 8e90e996..00000000 --- a/vendor/github.com/coredns/coredns/plugin/route53/setup_test.go +++ /dev/null @@ -1,37 +0,0 @@ -package route53 - -import ( - "testing" - - "github.com/aws/aws-sdk-go/aws/credentials" - "github.com/aws/aws-sdk-go/service/route53/route53iface" - "github.com/mholt/caddy" -) - -func TestSetupRoute53(t *testing.T) { - f := func(credential *credentials.Credentials) route53iface.Route53API { - return mockedRoute53{} - } - - c := caddy.NewTestController("dns", `route53`) - if err := setup(c, f); err != nil { - t.Fatalf("Expected no errors, but got: %v", err) - } - - c = caddy.NewTestController("dns", `route53 :`) - if err := setup(c, f); err == nil { - t.Fatalf("Expected errors, but got: %v", err) - } - - c = caddy.NewTestController("dns", `route53 example.org:12345678`) - if err := setup(c, f); err != nil { - t.Fatalf("Expected no errors, but got: %v", err) - } - - c = caddy.NewTestController("dns", `route53 example.org:12345678 { - aws_access_key -}`) - if err := setup(c, f); err == nil { - t.Fatalf("Expected errors, but got: %v", err) - } -} diff --git a/vendor/github.com/coredns/coredns/plugin/secondary/OWNERS b/vendor/github.com/coredns/coredns/plugin/secondary/OWNERS deleted file mode 100644 index 252bba86..00000000 --- a/vendor/github.com/coredns/coredns/plugin/secondary/OWNERS +++ /dev/null @@ -1,6 +0,0 @@ -reviewers: - - bradbeam - - miekg -approvers: - - bradbeam - - miekg diff --git a/vendor/github.com/coredns/coredns/plugin/secondary/README.md b/vendor/github.com/coredns/coredns/plugin/secondary/README.md deleted file mode 100644 index 59ac23ae..00000000 --- a/vendor/github.com/coredns/coredns/plugin/secondary/README.md +++ /dev/null @@ -1,69 +0,0 @@ -# secondary - -## Name - -*secondary* - enables serving a zone retrieved from a primary server. - -## Description - -With *secondary* you can transfer (via AXFR) a zone from another server. The retrieved zone is -*not committed* to disk (a violation of the RFC). This means restarting CoreDNS will cause it to - retrieve all secondary zones. - -~~~ -secondary [ZONES...] -~~~ - -* **ZONES** zones it should be authoritative for. If empty, the zones from the configuration block - are used. Note that without a remote address to *get* the zone from, the above is not that useful. - -A working syntax would be: - -~~~ -secondary [zones...] { - transfer from ADDRESS - transfer to ADDRESS - upstream [ADDRESS...] -} -~~~ - -* `transfer from` specifies from which address to fetch the zone. It can be specified multiple times; - if one does not work, another will be tried. -* `transfer to` can be enabled to allow this secondary zone to be transferred again. -* `upstream` defines upstream resolvers to be used resolve external names found (think CNAMEs) - pointing to external names. This is only really useful when CoreDNS is configured as a proxy, for - normal authoritative serving you don't need *or* want to use this. **ADDRESS** can be an IP - address, and IP:port or a string pointing to a file that is structured as /etc/resolv.conf. - If no **ADDRESS** is given, CoreDNS will resolve CNAMEs against itself. - -When a zone is due to be refreshed (Refresh timer fires) a random jitter of 5 seconds is -applied, before fetching. In the case of retry this will be 2 seconds. If there are any errors -during the transfer the transfer fails; this will be logged. - -## Examples - -Transfer `example.org` from 10.0.1.1, and if that fails try 10.1.2.1. - -~~~ corefile -example.org { - secondary { - transfer from 10.0.1.1 - transfer from 10.1.2.1 - } -} -~~~ - -Or re-export the retrieved zone to other secondaries. - -~~~ corefile -. { - secondary example.net { - transfer from 10.1.2.1 - transfer to * - } -} -~~~ - -## Bugs - -Only AXFR is supported and the retrieved zone is not committed to disk. diff --git a/vendor/github.com/coredns/coredns/plugin/secondary/secondary.go b/vendor/github.com/coredns/coredns/plugin/secondary/secondary.go deleted file mode 100644 index 43934e80..00000000 --- a/vendor/github.com/coredns/coredns/plugin/secondary/secondary.go +++ /dev/null @@ -1,10 +0,0 @@ -// Package secondary implements a secondary plugin. -package secondary - -import "github.com/coredns/coredns/plugin/file" - -// Secondary implements a secondary plugin that allows CoreDNS to retrieve (via AXFR) -// zone information from a primary server. -type Secondary struct { - file.File -} diff --git a/vendor/github.com/coredns/coredns/plugin/secondary/setup.go b/vendor/github.com/coredns/coredns/plugin/secondary/setup.go deleted file mode 100644 index 1a411583..00000000 --- a/vendor/github.com/coredns/coredns/plugin/secondary/setup.go +++ /dev/null @@ -1,105 +0,0 @@ -package secondary - -import ( - "github.com/coredns/coredns/core/dnsserver" - "github.com/coredns/coredns/plugin" - "github.com/coredns/coredns/plugin/file" - "github.com/coredns/coredns/plugin/pkg/parse" - "github.com/coredns/coredns/plugin/pkg/upstream" - - "github.com/mholt/caddy" -) - -func init() { - caddy.RegisterPlugin("secondary", caddy.Plugin{ - ServerType: "dns", - Action: setup, - }) -} - -func setup(c *caddy.Controller) error { - zones, err := secondaryParse(c) - if err != nil { - return plugin.Error("secondary", err) - } - - // Add startup functions to retrieve the zone and keep it up to date. - for _, n := range zones.Names { - z := zones.Z[n] - if len(z.TransferFrom) > 0 { - c.OnStartup(func() error { - z.StartupOnce.Do(func() { - z.TransferIn() - go func() { - z.Update() - }() - }) - return nil - }) - } - } - - dnsserver.GetConfig(c).AddPlugin(func(next plugin.Handler) plugin.Handler { - return Secondary{file.File{Next: next, Zones: zones}} - }) - - return nil -} - -func secondaryParse(c *caddy.Controller) (file.Zones, error) { - z := make(map[string]*file.Zone) - names := []string{} - origins := []string{} - upstr := upstream.Upstream{} - for c.Next() { - - if c.Val() == "secondary" { - // secondary [origin] - origins = make([]string, len(c.ServerBlockKeys)) - copy(origins, c.ServerBlockKeys) - args := c.RemainingArgs() - if len(args) > 0 { - origins = args - } - for i := range origins { - origins[i] = plugin.Host(origins[i]).Normalize() - z[origins[i]] = file.NewZone(origins[i], "stdin") - names = append(names, origins[i]) - } - - for c.NextBlock() { - - t, f := []string{}, []string{} - var e error - - switch c.Val() { - case "transfer": - t, f, e = parse.Transfer(c, true) - if e != nil { - return file.Zones{}, e - } - case "upstream": - args := c.RemainingArgs() - var err error - upstr, err = upstream.New(args) - if err != nil { - return file.Zones{}, err - } - default: - return file.Zones{}, c.Errf("unknown property '%s'", c.Val()) - } - - for _, origin := range origins { - if t != nil { - z[origin].TransferTo = append(z[origin].TransferTo, t...) - } - if f != nil { - z[origin].TransferFrom = append(z[origin].TransferFrom, f...) - } - z[origin].Upstream = upstr - } - } - } - } - return file.Zones{Z: z, Names: names}, nil -} diff --git a/vendor/github.com/coredns/coredns/plugin/secondary/setup_test.go b/vendor/github.com/coredns/coredns/plugin/secondary/setup_test.go deleted file mode 100644 index bf2b203a..00000000 --- a/vendor/github.com/coredns/coredns/plugin/secondary/setup_test.go +++ /dev/null @@ -1,65 +0,0 @@ -package secondary - -import ( - "testing" - - "github.com/mholt/caddy" -) - -func TestSecondaryParse(t *testing.T) { - tests := []struct { - inputFileRules string - shouldErr bool - transferFrom string - zones []string - }{ - { - `secondary`, - false, // TODO(miek): should actually be true, because without transfer lines this does not make sense - "", - nil, - }, - { - `secondary { - transfer from 127.0.0.1 - transfer to 127.0.0.1 - }`, - false, - "127.0.0.1:53", - nil, - }, - { - `secondary example.org { - transfer from 127.0.0.1 - transfer to 127.0.0.1 - }`, - false, - "127.0.0.1:53", - []string{"example.org."}, - }, - } - - for i, test := range tests { - c := caddy.NewTestController("dns", test.inputFileRules) - s, err := secondaryParse(c) - - if err == nil && test.shouldErr { - t.Fatalf("Test %d expected errors, but got no error", i) - } else if err != nil && !test.shouldErr { - t.Fatalf("Test %d expected no errors, but got '%v'", i, err) - } - - for i, name := range test.zones { - if x := s.Names[i]; x != name { - t.Fatalf("Test %d zone names don't match expected %q, but got %q", i, name, x) - } - } - - // This is only set *iff* we have a zone (i.e. not in all tests above) - for _, v := range s.Z { - if x := v.TransferFrom[0]; x != test.transferFrom { - t.Fatalf("Test %d transform from names don't match expected %q, but got %q", i, test.transferFrom, x) - } - } - } -} diff --git a/vendor/github.com/coredns/coredns/plugin/template/OWNERS b/vendor/github.com/coredns/coredns/plugin/template/OWNERS deleted file mode 100644 index b97eccf6..00000000 --- a/vendor/github.com/coredns/coredns/plugin/template/OWNERS +++ /dev/null @@ -1,4 +0,0 @@ -reviewers: - - rtreffer -approvers: - - rtreffer diff --git a/vendor/github.com/coredns/coredns/plugin/template/README.md b/vendor/github.com/coredns/coredns/plugin/template/README.md deleted file mode 100644 index 17dedbfa..00000000 --- a/vendor/github.com/coredns/coredns/plugin/template/README.md +++ /dev/null @@ -1,257 +0,0 @@ -# template - -## Name - -*template* - allows for dynamic responses based on the incoming query. - -## Description - -The *template* plugin allows you to dynamically respond to queries by just writing a (Go) template. - -## Syntax - -~~~ -template CLASS TYPE [ZONE...] { - [match REGEX...] - [answer RR] - [additional RR] - [authority RR] - [...] - [rcode CODE] - [upstream [ADDRESS...]] - [fallthrough [ZONE...]] -} -~~~ - -* **CLASS** the query class (usually IN or ANY). -* **TYPE** the query type (A, PTR, ... can be ANY to match all types). -* **ZONE** the zone scope(s) for this template. Defaults to the server zones. -* **REGEX** [Go regexp](https://golang.org/pkg/regexp/) that are matched against the incoming question name. Specifying no regex matches everything (default: `.*`). First matching regex wins. -* `answer|additional|authority` **RR** A [RFC 1035](https://tools.ietf.org/html/rfc1035#section-5) style resource record fragment - built by a [Go template](https://golang.org/pkg/text/template/) that contains the reply. -* `rcode` **CODE** A response code (`NXDOMAIN, SERVFAIL, ...`). The default is `SUCCESS`. -* `upstream` [**ADDRESS**...] defines the upstream resolvers used for resolving CNAME. - If no **ADDRESS** is given, CoreDNS will resolve CNAMEs against itself. **ADDRESS** - can be an IP, an IP:port, or a path to a file structured like resolv.conf. -* `fallthrough` Continue with the next plugin if the zone matched but no regex matched. - If specific zones are listed (for example `in-addr.arpa` and `ip6.arpa`), then only queries for - those zones will be subject to fallthrough. - -At least one `answer` or `rcode` directive is needed (e.g. `rcode NXDOMAIN`). - -[Also see](#also-see) contains an additional reading list. - -## Templates - -Each resource record is a full-featured [Go template](https://golang.org/pkg/text/template/) with the following predefined data - -* `.Zone` the matched zone string (e.g. `example.`). -* `.Name` the query name, as a string (lowercased). -* `.Class` the query class (usually `IN`). -* `.Type` the RR type requested (e.g. `PTR`). -* `.Match` an array of all matches. `index .Match 0` refers to the whole match. -* `.Group` a map of the named capture groups. -* `.Message` the complete incoming DNS message. -* `.Question` the matched question section. - -The output of the template must be a [RFC 1035](https://tools.ietf.org/html/rfc1035) style resource record (commonly referred to as a "zone file"). - -**WARNING** there is a syntactical problem with Go templates and CoreDNS config files. Expressions - like `{{$var}}` will be interpreted as a reference to an environment variable by CoreDNS (and - Caddy) while `{{ $var }}` will work. See [Bugs](#bugs) and corefile(5). - -## Metrics - -If monitoring is enabled (via the *prometheus* directive) then the following metrics are exported: - -* `coredns_template_matches_total{server, regex}` the total number of matched requests by regex. -* `coredns_template_template_failures_total{server, regex,section,template}` the number of times the Go templating failed. Regex, section and template label values can be used to map the error back to the config file. -* `coredns_template_rr_failures_total{server, regex,section,template}` the number of times the templated resource record was invalid and could not be parsed. Regex, section and template label values can be used to map the error back to the config file. - -Both failure cases indicate a problem with the template configuration. The `server` label indicates -the server incrementing the metric, see the *metrics* plugin for details. - -## Examples - -### Resolve everything to NXDOMAIN - -The most simplistic template is - -~~~ corefile -. { - template ANY ANY { - rcode NXDOMAIN - } -} -~~~ - -1. This template uses the default zone (`.` or all queries) -2. All queries will be answered (no `fallthrough`) -3. The answer is always NXDOMAIN - -### Resolve .invalid as NXDOMAIN - -The `.invalid` domain is a reserved TLD (see [RFC 2606 Reserved Top Level DNS Names](https://tools.ietf.org/html/rfc2606#section-2)) to indicate invalid domains. - -~~~ corefile -. { - proxy . 8.8.8.8 - - template ANY ANY invalid { - rcode NXDOMAIN - authority "invalid. 60 {{ .Class }} SOA ns.invalid. hostmaster.invalid. (1 60 60 60 60)" - } -} -~~~ - -1. A query to .invalid will result in NXDOMAIN (rcode) -2. A dummy SOA record is sent to hand out a TTL of 60s for caching purposes -3. Querying `.invalid` in the `CH` class will also cause a NXDOMAIN/SOA response -4. The default regex is `.*` - -### Block invalid search domain completions - -Imagine you run `example.com` with a datacenter `dc1.example.com`. The datacenter domain -is part of the DNS search domain. -However `something.example.com.dc1.example.com` would indicate a fully qualified -domain name (`something.example.com`) that inadvertently has the default domain or search -path (`dc1.example.com`) added. - -~~~ corefile -. { - proxy . 8.8.8.8 - - template IN ANY example.com.dc1.example.com { - rcode NXDOMAIN - authority "{{ .Zone }} 60 IN SOA ns.example.com hostmaster.example.com (1 60 60 60 60)" - } -} -~~~ - -A more verbose regex based equivalent would be - -~~~ corefile -. { - proxy . 8.8.8.8 - - template IN ANY example.com { - match "example\.com\.(dc1\.example\.com\.)$" - rcode NXDOMAIN - authority "{{ index .Match 1 }} 60 IN SOA ns.{{ index .Match 1 }} hostmaster.{{ index .Match 1 }} (1 60 60 60 60)" - fallthrough - } -} -~~~ - -The regex-based version can do more complex matching/templating while zone-based templating is easier to read and use. - -### Resolve A/PTR for .example - -~~~ corefile -. { - proxy . 8.8.8.8 - - # ip-a-b-c-d.example.com A a.b.c.d - - template IN A example { - match (^|[.])ip-10-(?P[0-9]*)-(?P[0-9]*)-(?P[0-9]*)[.]example[.]$ - answer "{{ .Name }} 60 IN A 10.{{ .Group.b }}.{{ .Group.c }}.{{ .Group.d }}" - fallthrough - } - - # d.c.b.a.in-addr.arpa PTR ip-a-b-c-d.example - - template IN PTR 10.in-addr.arpa. { - match ^(?P[0-9]*)[.](?P[0-9]*)[.](?P[0-9]*)[.]10[.]in-addr[.]arpa[.]$ - answer "{{ .Name }} 60 IN PTR ip-10-{{ .Group.b }}-{{ .Group.c }}-{{ .Group.d }}.example.com." - } -} -~~~ - -An IPv4 address consists of 4 bytes, `a.b.c.d`. Named groups make it less error-prone to reverse the -IP address in the PTR case. Try to use named groups to explain what your regex and template are doing. - -Note that the A record is actually a wildcard: any subdomain of the IP address will resolve to the IP address. - -Having templates to map certain PTR/A pairs is a common pattern. - -Fallthrough is needed for mixed domains where only some responses are templated. - -### Resolve multiple ip patterns - -~~~ corefile -. { - proxy . 8.8.8.8 - - template IN A example { - match "^ip-(?P10)-(?P[0-9]*)-(?P[0-9]*)-(?P[0-9]*)[.]dc[.]example[.]$" - match "^(?P[0-9]*)[.](?P[0-9]*)[.](?P[0-9]*)[.](?P[0-9]*)[.]ext[.]example[.]$" - answer "{{ .Name }} 60 IN A {{ .Group.a}}.{{ .Group.b }}.{{ .Group.c }}.{{ .Group.d }}" - fallthrough - } -} -~~~ - -Named capture groups can be used to template one response for multiple patterns. - -### Resolve A and MX records for IP templates in .example - -~~~ corefile -. { - proxy . 8.8.8.8 - - template IN A example { - match ^ip-10-(?P[0-9]*)-(?P[0-9]*)-(?P[0-9]*)[.]example[.]$ - answer "{{ .Name }} 60 IN A 10.{{ .Group.b }}.{{ .Group.c }}.{{ .Group.d }}" - fallthrough - } - template IN MX example { - match ^ip-10-(?P[0-9]*)-(?P[0-9]*)-(?P[0-9]*)[.]example[.]$ - answer "{{ .Name }} 60 IN MX 10 {{ .Name }}" - additional "{{ .Name }} 60 IN A 10.{{ .Group.b }}.{{ .Group.c }}.{{ .Group.d }}" - fallthrough - } -} -~~~ - -### Adding authoritative nameservers to the response - -~~~ corefile -. { - proxy . 8.8.8.8 - - template IN A example { - match ^ip-10-(?P[0-9]*)-(?P[0-9]*)-(?P[0-9]*)[.]example[.]$ - answer "{{ .Name }} 60 IN A 10.{{ .Group.b }}.{{ .Group.c }}.{{ .Group.d }}" - authority "example. 60 IN NS ns0.example." - authority "example. 60 IN NS ns1.example." - additional "ns0.example. 60 IN A 203.0.113.8" - additional "ns1.example. 60 IN A 198.51.100.8" - fallthrough - } - template IN MX example { - match ^ip-10-(?P[0-9]*)-(?P[0-9]*)-(?P[0-9]*)[.]example[.]$ - answer "{{ .Name }} 60 IN MX 10 {{ .Name }}" - additional "{{ .Name }} 60 IN A 10.{{ .Group.b }}.{{ .Group.c }}.{{ .Group.d }}" - authority "example. 60 IN NS ns0.example." - authority "example. 60 IN NS ns1.example." - additional "ns0.example. 60 IN A 203.0.113.8" - additional "ns1.example. 60 IN A 198.51.100.8" - fallthrough - } -} -~~~ - -## Also see - -* [Go regexp](https://golang.org/pkg/regexp/) for details about the regex implementation -* [RE2 syntax reference](https://github.com/google/re2/wiki/Syntax) for details about the regex syntax -* [RFC 1034](https://tools.ietf.org/html/rfc1034#section-3.6.1) and [RFC 1035](https://tools.ietf.org/html/rfc1035#section-5) for the resource record format -* [Go template](https://golang.org/pkg/text/template/) for the template language reference - -## Bugs - -CoreDNS supports [caddyfile environment variables](https://caddyserver.com/docs/caddyfile#env) -with notion of `{$ENV_VAR}`. This parser feature will break [Go template variables](https://golang.org/pkg/text/template/#hdr-Variables) notations like`{{$variable}}`. -The equivalent notation `{{ $variable }}` will work. -Try to avoid Go template variables in the context of this plugin. diff --git a/vendor/github.com/coredns/coredns/plugin/template/metrics.go b/vendor/github.com/coredns/coredns/plugin/template/metrics.go deleted file mode 100644 index 25474fc6..00000000 --- a/vendor/github.com/coredns/coredns/plugin/template/metrics.go +++ /dev/null @@ -1,46 +0,0 @@ -package template - -import ( - "sync" - - "github.com/coredns/coredns/plugin" - "github.com/coredns/coredns/plugin/metrics" - - "github.com/mholt/caddy" - "github.com/prometheus/client_golang/prometheus" -) - -var ( - templateMatchesCount = prometheus.NewCounterVec(prometheus.CounterOpts{ - Namespace: plugin.Namespace, - Subsystem: "template", - Name: "matches_total", - Help: "Counter of template regex matches.", - }, []string{"server", "zone", "class", "type"}) - templateFailureCount = prometheus.NewCounterVec(prometheus.CounterOpts{ - Namespace: plugin.Namespace, - Subsystem: "template", - Name: "template_failures_total", - Help: "Counter of go template failures.", - }, []string{"server", "zone", "class", "type", "section", "template"}) - templateRRFailureCount = prometheus.NewCounterVec(prometheus.CounterOpts{ - Namespace: plugin.Namespace, - Subsystem: "template", - Name: "rr_failures_total", - Help: "Counter of mis-templated RRs.", - }, []string{"server", "zone", "class", "type", "section", "template"}) -) - -// OnStartupMetrics sets up the metrics on startup. -func setupMetrics(c *caddy.Controller) error { - c.OnStartup(func() error { - metricsOnce.Do(func() { - metrics.MustRegister(c, templateMatchesCount, templateFailureCount, templateRRFailureCount) - }) - return nil - }) - - return nil -} - -var metricsOnce sync.Once diff --git a/vendor/github.com/coredns/coredns/plugin/template/setup.go b/vendor/github.com/coredns/coredns/plugin/template/setup.go deleted file mode 100644 index cd4cc1b9..00000000 --- a/vendor/github.com/coredns/coredns/plugin/template/setup.go +++ /dev/null @@ -1,170 +0,0 @@ -package template - -import ( - "regexp" - gotmpl "text/template" - - "github.com/coredns/coredns/core/dnsserver" - "github.com/coredns/coredns/plugin" - "github.com/coredns/coredns/plugin/pkg/upstream" - - "github.com/mholt/caddy" - "github.com/miekg/dns" -) - -func init() { - caddy.RegisterPlugin("template", caddy.Plugin{ - ServerType: "dns", - Action: setupTemplate, - }) -} - -func setupTemplate(c *caddy.Controller) error { - handler, err := templateParse(c) - if err != nil { - return plugin.Error("template", err) - } - - if err := setupMetrics(c); err != nil { - return plugin.Error("template", err) - } - - dnsserver.GetConfig(c).AddPlugin(func(next plugin.Handler) plugin.Handler { - handler.Next = next - return handler - }) - - return nil -} - -func templateParse(c *caddy.Controller) (handler Handler, err error) { - handler.Templates = make([]template, 0) - - for c.Next() { - - if !c.NextArg() { - return handler, c.ArgErr() - } - class, ok := dns.StringToClass[c.Val()] - if !ok { - return handler, c.Errf("invalid query class %s", c.Val()) - } - - if !c.NextArg() { - return handler, c.ArgErr() - } - qtype, ok := dns.StringToType[c.Val()] - if !ok { - return handler, c.Errf("invalid RR class %s", c.Val()) - } - - zones := c.RemainingArgs() - if len(zones) == 0 { - zones = make([]string, len(c.ServerBlockKeys)) - copy(zones, c.ServerBlockKeys) - } - for i, str := range zones { - zones[i] = plugin.Host(str).Normalize() - } - handler.Zones = append(handler.Zones, zones...) - - t := template{qclass: class, qtype: qtype, zones: zones} - - t.regex = make([]*regexp.Regexp, 0) - templatePrefix := "" - - t.answer = make([]*gotmpl.Template, 0) - - for c.NextBlock() { - switch c.Val() { - case "match": - args := c.RemainingArgs() - if len(args) == 0 { - return handler, c.ArgErr() - } - for _, regex := range args { - r, err := regexp.Compile(regex) - if err != nil { - return handler, c.Errf("could not parse regex: %s, %v", regex, err) - } - templatePrefix = templatePrefix + regex + " " - t.regex = append(t.regex, r) - } - - case "answer": - args := c.RemainingArgs() - if len(args) == 0 { - return handler, c.ArgErr() - } - for _, answer := range args { - tmpl, err := gotmpl.New("answer").Parse(answer) - if err != nil { - return handler, c.Errf("could not compile template: %s, %v", c.Val(), err) - } - t.answer = append(t.answer, tmpl) - } - - case "additional": - args := c.RemainingArgs() - if len(args) == 0 { - return handler, c.ArgErr() - } - for _, additional := range args { - tmpl, err := gotmpl.New("additional").Parse(additional) - if err != nil { - return handler, c.Errf("could not compile template: %s, %v\n", c.Val(), err) - } - t.additional = append(t.additional, tmpl) - } - - case "authority": - args := c.RemainingArgs() - if len(args) == 0 { - return handler, c.ArgErr() - } - for _, authority := range args { - tmpl, err := gotmpl.New("authority").Parse(authority) - if err != nil { - return handler, c.Errf("could not compile template: %s, %v\n", c.Val(), err) - } - t.authority = append(t.authority, tmpl) - } - - case "rcode": - if !c.NextArg() { - return handler, c.ArgErr() - } - rcode, ok := dns.StringToRcode[c.Val()] - if !ok { - return handler, c.Errf("unknown rcode %s", c.Val()) - } - t.rcode = rcode - - case "fallthrough": - t.fall.SetZonesFromArgs(c.RemainingArgs()) - - case "upstream": - args := c.RemainingArgs() - u, err := upstream.New(args) - if err != nil { - return handler, err - } - t.upstream = u - default: - return handler, c.ArgErr() - } - } - - if len(t.regex) == 0 { - t.regex = append(t.regex, regexp.MustCompile(".*")) - } - - if len(t.answer) == 0 && len(t.authority) == 0 && t.rcode == dns.RcodeSuccess { - return handler, c.Errf("no answer section for template found: %v", handler) - } - - handler.Templates = append(handler.Templates, t) - } - - return -} diff --git a/vendor/github.com/coredns/coredns/plugin/template/setup_test.go b/vendor/github.com/coredns/coredns/plugin/template/setup_test.go deleted file mode 100644 index 7581bd30..00000000 --- a/vendor/github.com/coredns/coredns/plugin/template/setup_test.go +++ /dev/null @@ -1,170 +0,0 @@ -package template - -import ( - "testing" - - "github.com/mholt/caddy" -) - -func TestSetup(t *testing.T) { - c := caddy.NewTestController("dns", `template ANY ANY { - rcode - }`) - err := setupTemplate(c) - if err == nil { - t.Errorf("Expected setupTemplate to fail on broken template, got no error") - } - c = caddy.NewTestController("dns", `template ANY ANY { - rcode NXDOMAIN - }`) - err = setupTemplate(c) - if err != nil { - t.Errorf("Expected no errors, got: %v", err) - } -} - -func TestSetupParse(t *testing.T) { - - serverBlockKeys := []string{"domain.com.:8053", "dynamic.domain.com.:8053"} - - tests := []struct { - inputFileRules string - shouldErr bool - }{ - // parse errors - {`template`, true}, - {`template X`, true}, - {`template ANY`, true}, - {`template ANY X`, true}, - {`template ANY ANY (?P`, true}, - { - `template ANY ANY { - - }`, - true, - }, - { - `template ANY ANY .* { - notavailable - }`, - true, - }, - { - `template ANY ANY { - answer - }`, - true, - }, - { - `template ANY ANY { - additional - }`, - true, - }, - { - `template ANY ANY { - rcode - }`, - true, - }, - { - `template ANY ANY { - rcode UNDEFINED - }`, - true, - }, - { - `template ANY ANY { - answer "{{" - }`, - true, - }, - { - `template ANY ANY { - additional "{{" - }`, - true, - }, - { - `template ANY ANY { - authority "{{" - }`, - true, - }, - // examples - { - `template ANY A example.com { - match ip-(?P[0-9]*)-(?P[0-9]*)-(?P[0-9]*)-(?P[0-9]*)[.]example[.]com - answer "{{ .Name }} A {{ .Group.a }}.{{ .Group.b }}.{{ .Group.c }}.{{ .Grup.d }}." - fallthrough - }`, - false, - }, - { - `template ANY AAAA example.com { - match ip-(?P[0-9]*)-(?P[0-9]*)-(?P[0-9]*)-(?P[0-9]*)[.]example[.]com - authority "example.com 60 IN SOA ns.example.com hostmaster.example.com (1 60 60 60 60)" - fallthrough - }`, - false, - }, - { - `template IN ANY example.com { - match "[.](example[.]com[.]dc1[.]example[.]com[.])$" - rcode NXDOMAIN - authority "{{ index .Match 1 }} 60 IN SOA ns.{{ index .Match 1 }} hostmaster.example.com (1 60 60 60 60)" - fallthrough example.com - }`, - false, - }, - { - `template IN A example { - match ^ip-10-(?P[0-9]*)-(?P[0-9]*)-(?P[0-9]*)[.]example[.]$ - answer "{{ .Name }} 60 IN A 10.{{ .Group.b }}.{{ .Group.c }}.{{ .Group.d }}" - } - template IN MX example. { - match ^ip-10-(?P[0-9]*)-(?P[0-9]*)-(?P[0-9]*)[.]example[.]$ - answer "{{ .Name }} 60 IN MX 10 {{ .Name }}" - additional "{{ .Name }} 60 IN A 10.{{ .Group.b }}.{{ .Group.c }}.{{ .Group.d }}" - }`, - false, - }, - { - `template IN MX example { - match ^ip-10-(?P[0-9]*)-(?P[0-9]*)-(?P[0-9]*)[.]example[.]$ - answer "{{ .Name }} 60 IN MX 10 {{ .Name }}" - additional "{{ .Name }} 60 IN A 10.{{ .Group.b }}.{{ .Group.c }}.{{ .Group.d }}" - authority "example. 60 IN NS ns0.example." - authority "example. 60 IN NS ns1.example." - additional "ns0.example. 60 IN A 203.0.113.8" - additional "ns1.example. 60 IN A 198.51.100.8" - }`, - false, - }, - { - `template ANY ANY up.stream.local { - answer "up.stream.local 5 IN CNAME up.river.local" - upstream - }`, - false, - }, - { - `template ANY ANY up.stream.local { - answer "up.stream.local 5 IN CNAME up.river.local" - upstream invalid-upstream-argument - }`, - true, - }, - } - for i, test := range tests { - c := caddy.NewTestController("dns", test.inputFileRules) - c.ServerBlockKeys = serverBlockKeys - templates, err := templateParse(c) - - if err == nil && test.shouldErr { - t.Fatalf("Test %d expected errors, but got no error\n---\n%s\n---\n%v", i, test.inputFileRules, templates) - } else if err != nil && !test.shouldErr { - t.Fatalf("Test %d expected no errors, but got '%v'", i, err) - } - } -} diff --git a/vendor/github.com/coredns/coredns/plugin/template/template.go b/vendor/github.com/coredns/coredns/plugin/template/template.go deleted file mode 100644 index 9bf5f8dd..00000000 --- a/vendor/github.com/coredns/coredns/plugin/template/template.go +++ /dev/null @@ -1,189 +0,0 @@ -package template - -import ( - "bytes" - "context" - "regexp" - "strconv" - gotmpl "text/template" - - "github.com/coredns/coredns/plugin" - "github.com/coredns/coredns/plugin/metrics" - "github.com/coredns/coredns/plugin/pkg/fall" - "github.com/coredns/coredns/plugin/pkg/upstream" - "github.com/coredns/coredns/request" - - "github.com/miekg/dns" -) - -// Handler is a plugin handler that takes a query and templates a response. -type Handler struct { - Zones []string - - Next plugin.Handler - Templates []template -} - -type template struct { - zones []string - rcode int - regex []*regexp.Regexp - answer []*gotmpl.Template - additional []*gotmpl.Template - authority []*gotmpl.Template - qclass uint16 - qtype uint16 - fall fall.F - upstream upstream.Upstream -} - -type templateData struct { - Zone string - Name string - Regex string - Match []string - Group map[string]string - Class string - Type string - Message *dns.Msg - Question *dns.Question -} - -// ServeDNS implements the plugin.Handler interface. -func (h Handler) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (int, error) { - state := request.Request{W: w, Req: r, Context: ctx} - - zone := plugin.Zones(h.Zones).Matches(state.Name()) - if zone == "" { - return plugin.NextOrFailure(h.Name(), h.Next, ctx, w, r) - } - - for _, template := range h.Templates { - data, match, fthrough := template.match(state, zone) - if !match { - if !fthrough { - return dns.RcodeNameError, nil - } - continue - } - - templateMatchesCount.WithLabelValues(metrics.WithServer(ctx), data.Zone, data.Class, data.Type).Inc() - - if template.rcode == dns.RcodeServerFailure { - return template.rcode, nil - } - - msg := new(dns.Msg) - msg.SetReply(r) - msg.Authoritative, msg.RecursionAvailable = true, true - msg.Rcode = template.rcode - - for _, answer := range template.answer { - rr, err := executeRRTemplate(metrics.WithServer(ctx), "answer", answer, data) - if err != nil { - return dns.RcodeServerFailure, err - } - msg.Answer = append(msg.Answer, rr) - if rr.Header().Rrtype == dns.TypeCNAME { - up, _ := template.upstream.Lookup(state, rr.(*dns.CNAME).Target, dns.TypeA) - msg.Answer = append(msg.Answer, up.Answer...) - } - } - for _, additional := range template.additional { - rr, err := executeRRTemplate(metrics.WithServer(ctx), "additional", additional, data) - if err != nil { - return dns.RcodeServerFailure, err - } - msg.Extra = append(msg.Extra, rr) - } - for _, authority := range template.authority { - rr, err := executeRRTemplate(metrics.WithServer(ctx), "authority", authority, data) - if err != nil { - return dns.RcodeServerFailure, err - } - msg.Ns = append(msg.Ns, rr) - } - - state.SizeAndDo(msg) - state.Scrub(msg) - w.WriteMsg(msg) - return template.rcode, nil - } - - return h.Next.ServeDNS(ctx, w, r) -} - -// Name implements the plugin.Handler interface. -func (h Handler) Name() string { return "template" } - -func executeRRTemplate(server, section string, template *gotmpl.Template, data templateData) (dns.RR, error) { - buffer := &bytes.Buffer{} - err := template.Execute(buffer, data) - if err != nil { - templateFailureCount.WithLabelValues(server, data.Zone, data.Class, data.Type, section, template.Tree.Root.String()).Inc() - return nil, err - } - rr, err := dns.NewRR(buffer.String()) - if err != nil { - templateRRFailureCount.WithLabelValues(server, data.Zone, data.Class, data.Type, section, template.Tree.Root.String()).Inc() - return rr, err - } - return rr, nil -} - -func (t template) match(state request.Request, zone string) (templateData, bool, bool) { - q := state.Req.Question[0] - data := templateData{} - - zone = plugin.Zones(t.zones).Matches(state.Name()) - if zone == "" { - return data, false, true - } - - if t.qclass != dns.ClassANY && q.Qclass != dns.ClassANY && q.Qclass != t.qclass { - return data, false, true - } - if t.qtype != dns.TypeANY && q.Qtype != dns.TypeANY && q.Qtype != t.qtype { - return data, false, true - } - - for _, regex := range t.regex { - if !regex.MatchString(state.Name()) { - continue - } - - data.Zone = zone - data.Regex = regex.String() - data.Name = state.Name() - data.Question = &q - data.Message = state.Req - if q.Qclass != dns.ClassANY { - data.Class = dns.ClassToString[q.Qclass] - } else { - data.Class = dns.ClassToString[t.qclass] - } - if q.Qtype != dns.TypeANY { - data.Type = dns.TypeToString[q.Qtype] - } else { - data.Type = dns.TypeToString[t.qtype] - } - - matches := regex.FindStringSubmatch(state.Name()) - data.Match = make([]string, len(matches)) - data.Group = make(map[string]string) - groupNames := regex.SubexpNames() - for i, m := range matches { - data.Match[i] = m - data.Group[strconv.Itoa(i)] = m - } - for i, m := range matches { - if len(groupNames[i]) > 0 { - data.Group[groupNames[i]] = m - } - } - - return data, true, false - } - - return data, false, t.fall.Through(state.Name()) -} diff --git a/vendor/github.com/coredns/coredns/plugin/template/template_test.go b/vendor/github.com/coredns/coredns/plugin/template/template_test.go deleted file mode 100644 index 288d833e..00000000 --- a/vendor/github.com/coredns/coredns/plugin/template/template_test.go +++ /dev/null @@ -1,441 +0,0 @@ -package template - -import ( - "context" - "fmt" - "regexp" - "testing" - gotmpl "text/template" - - "github.com/coredns/coredns/plugin/pkg/dnstest" - "github.com/coredns/coredns/plugin/pkg/fall" - "github.com/coredns/coredns/plugin/test" - - "github.com/mholt/caddy" - "github.com/miekg/dns" -) - -func TestHandler(t *testing.T) { - exampleDomainATemplate := template{ - regex: []*regexp.Regexp{regexp.MustCompile("(^|[.])ip-10-(?P[0-9]*)-(?P[0-9]*)-(?P[0-9]*)[.]example[.]$")}, - answer: []*gotmpl.Template{gotmpl.Must(gotmpl.New("answer").Parse("{{ .Name }} 60 IN A 10.{{ .Group.b }}.{{ .Group.c }}.{{ .Group.d }}"))}, - qclass: dns.ClassANY, - qtype: dns.TypeANY, - fall: fall.Root, - zones: []string{"."}, - } - exampleDomainANSTemplate := template{ - regex: []*regexp.Regexp{regexp.MustCompile("(^|[.])ip-10-(?P[0-9]*)-(?P[0-9]*)-(?P[0-9]*)[.]example[.]$")}, - answer: []*gotmpl.Template{gotmpl.Must(gotmpl.New("answer").Parse("{{ .Name }} 60 IN A 10.{{ .Group.b }}.{{ .Group.c }}.{{ .Group.d }}"))}, - additional: []*gotmpl.Template{gotmpl.Must(gotmpl.New("additional").Parse("ns0.example. IN A 203.0.113.8"))}, - authority: []*gotmpl.Template{gotmpl.Must(gotmpl.New("authority").Parse("example. IN NS ns0.example.com."))}, - qclass: dns.ClassANY, - qtype: dns.TypeANY, - fall: fall.Root, - zones: []string{"."}, - } - exampleDomainMXTemplate := template{ - regex: []*regexp.Regexp{regexp.MustCompile("(^|[.])ip-10-(?P[0-9]*)-(?P[0-9]*)-(?P[0-9]*)[.]example[.]$")}, - answer: []*gotmpl.Template{gotmpl.Must(gotmpl.New("answer").Parse("{{ .Name }} 60 MX 10 {{ .Name }}"))}, - additional: []*gotmpl.Template{gotmpl.Must(gotmpl.New("additional").Parse("{{ .Name }} 60 IN A 10.{{ .Group.b }}.{{ .Group.c }}.{{ .Group.d }}"))}, - qclass: dns.ClassANY, - qtype: dns.TypeANY, - fall: fall.Root, - zones: []string{"."}, - } - invalidDomainTemplate := template{ - regex: []*regexp.Regexp{regexp.MustCompile("[.]invalid[.]$")}, - rcode: dns.RcodeNameError, - answer: []*gotmpl.Template{gotmpl.Must(gotmpl.New("answer").Parse("invalid. 60 {{ .Class }} SOA a.invalid. b.invalid. (1 60 60 60 60)"))}, - qclass: dns.ClassANY, - qtype: dns.TypeANY, - fall: fall.Root, - zones: []string{"."}, - } - rcodeServfailTemplate := template{ - regex: []*regexp.Regexp{regexp.MustCompile(".*")}, - rcode: dns.RcodeServerFailure, - qclass: dns.ClassANY, - qtype: dns.TypeANY, - fall: fall.Root, - zones: []string{"."}, - } - brokenTemplate := template{ - regex: []*regexp.Regexp{regexp.MustCompile("[.]example[.]$")}, - answer: []*gotmpl.Template{gotmpl.Must(gotmpl.New("answer").Parse("{{ .Name }} 60 IN TXT \"{{ index .Match 2 }}\""))}, - qclass: dns.ClassANY, - qtype: dns.TypeANY, - fall: fall.Root, - zones: []string{"."}, - } - nonRRTemplate := template{ - regex: []*regexp.Regexp{regexp.MustCompile("[.]example[.]$")}, - answer: []*gotmpl.Template{gotmpl.Must(gotmpl.New("answer").Parse("{{ .Name }}"))}, - qclass: dns.ClassANY, - qtype: dns.TypeANY, - fall: fall.Root, - zones: []string{"."}, - } - nonRRAdditionalTemplate := template{ - regex: []*regexp.Regexp{regexp.MustCompile("[.]example[.]$")}, - additional: []*gotmpl.Template{gotmpl.Must(gotmpl.New("answer").Parse("{{ .Name }}"))}, - qclass: dns.ClassANY, - qtype: dns.TypeANY, - fall: fall.Root, - zones: []string{"."}, - } - nonRRAuthoritativeTemplate := template{ - regex: []*regexp.Regexp{regexp.MustCompile("[.]example[.]$")}, - authority: []*gotmpl.Template{gotmpl.Must(gotmpl.New("authority").Parse("{{ .Name }}"))}, - qclass: dns.ClassANY, - qtype: dns.TypeANY, - fall: fall.Root, - zones: []string{"."}, - } - - tests := []struct { - tmpl template - qname string - name string - qclass uint16 - qtype uint16 - expectedCode int - expectedErr string - verifyResponse func(*dns.Msg) error - }{ - { - name: "RcodeServFail", - tmpl: rcodeServfailTemplate, - qname: "test.invalid.", - expectedCode: dns.RcodeServerFailure, - verifyResponse: func(r *dns.Msg) error { - return nil - }, - }, - { - name: "ExampleDomainNameMismatch", - tmpl: exampleDomainATemplate, - qclass: dns.ClassINET, - qtype: dns.TypeA, - qname: "test.invalid.", - expectedCode: rcodeFallthrough, - }, - { - name: "BrokenTemplate", - tmpl: brokenTemplate, - qclass: dns.ClassINET, - qtype: dns.TypeANY, - qname: "test.example.", - expectedCode: dns.RcodeServerFailure, - expectedErr: `template: answer:1:26: executing "answer" at : error calling index: index out of range: 2`, - verifyResponse: func(r *dns.Msg) error { - return nil - }, - }, - { - name: "NonRRTemplate", - tmpl: nonRRTemplate, - qclass: dns.ClassINET, - qtype: dns.TypeANY, - qname: "test.example.", - expectedCode: dns.RcodeServerFailure, - expectedErr: `dns: not a TTL: "test.example." at line: 1:13`, - verifyResponse: func(r *dns.Msg) error { - return nil - }, - }, - { - name: "NonRRAdditionalTemplate", - tmpl: nonRRAdditionalTemplate, - qclass: dns.ClassINET, - qtype: dns.TypeANY, - qname: "test.example.", - expectedCode: dns.RcodeServerFailure, - expectedErr: `dns: not a TTL: "test.example." at line: 1:13`, - verifyResponse: func(r *dns.Msg) error { - return nil - }, - }, - { - name: "NonRRAuthorityTemplate", - tmpl: nonRRAuthoritativeTemplate, - qclass: dns.ClassINET, - qtype: dns.TypeANY, - qname: "test.example.", - expectedCode: dns.RcodeServerFailure, - expectedErr: `dns: not a TTL: "test.example." at line: 1:13`, - verifyResponse: func(r *dns.Msg) error { - return nil - }, - }, - { - name: "ExampleDomainMatch", - tmpl: exampleDomainATemplate, - qclass: dns.ClassINET, - qtype: dns.TypeA, - qname: "ip-10-95-12-8.example.", - verifyResponse: func(r *dns.Msg) error { - if len(r.Answer) != 1 { - return fmt.Errorf("expected 1 answer, got %v", len(r.Answer)) - } - if r.Answer[0].Header().Rrtype != dns.TypeA { - return fmt.Errorf("expected an A record anwser, got %v", dns.TypeToString[r.Answer[0].Header().Rrtype]) - } - if r.Answer[0].(*dns.A).A.String() != "10.95.12.8" { - return fmt.Errorf("expected an A record for 10.95.12.8, got %v", r.Answer[0].String()) - } - return nil - }, - }, - { - name: "ExampleDomainMXMatch", - tmpl: exampleDomainMXTemplate, - qclass: dns.ClassINET, - qtype: dns.TypeMX, - qname: "ip-10-95-12-8.example.", - verifyResponse: func(r *dns.Msg) error { - if len(r.Answer) != 1 { - return fmt.Errorf("expected 1 answer, got %v", len(r.Answer)) - } - if r.Answer[0].Header().Rrtype != dns.TypeMX { - return fmt.Errorf("expected an A record anwser, got %v", dns.TypeToString[r.Answer[0].Header().Rrtype]) - } - if len(r.Extra) != 1 { - return fmt.Errorf("expected 1 extra record, got %v", len(r.Extra)) - } - if r.Extra[0].Header().Rrtype != dns.TypeA { - return fmt.Errorf("expected an additional A record, got %v", dns.TypeToString[r.Extra[0].Header().Rrtype]) - } - return nil - }, - }, - { - name: "ExampleDomainANSMatch", - tmpl: exampleDomainANSTemplate, - qclass: dns.ClassINET, - qtype: dns.TypeA, - qname: "ip-10-95-12-8.example.", - verifyResponse: func(r *dns.Msg) error { - if len(r.Answer) != 1 { - return fmt.Errorf("expected 1 answer, got %v", len(r.Answer)) - } - if r.Answer[0].Header().Rrtype != dns.TypeA { - return fmt.Errorf("expected an A record anwser, got %v", dns.TypeToString[r.Answer[0].Header().Rrtype]) - } - if len(r.Extra) != 1 { - return fmt.Errorf("expected 1 extra record, got %v", len(r.Extra)) - } - if r.Extra[0].Header().Rrtype != dns.TypeA { - return fmt.Errorf("expected an additional A record, got %v", dns.TypeToString[r.Extra[0].Header().Rrtype]) - } - if len(r.Ns) != 1 { - return fmt.Errorf("expected 1 authoritative record, got %v", len(r.Extra)) - } - if r.Ns[0].Header().Rrtype != dns.TypeNS { - return fmt.Errorf("expected an authoritative NS record, got %v", dns.TypeToString[r.Extra[0].Header().Rrtype]) - } - return nil - }, - }, - { - name: "ExampleInvalidNXDOMAIN", - tmpl: invalidDomainTemplate, - qclass: dns.ClassINET, - qtype: dns.TypeMX, - qname: "test.invalid.", - expectedCode: dns.RcodeNameError, - verifyResponse: func(r *dns.Msg) error { - if len(r.Answer) != 1 { - return fmt.Errorf("expected 1 answer, got %v", len(r.Answer)) - } - if r.Answer[0].Header().Rrtype != dns.TypeSOA { - return fmt.Errorf("expected an SOA record anwser, got %v", dns.TypeToString[r.Answer[0].Header().Rrtype]) - } - return nil - }, - }, - } - - ctx := context.TODO() - - for _, tr := range tests { - handler := Handler{ - Next: test.NextHandler(rcodeFallthrough, nil), - Zones: []string{"."}, - Templates: []template{tr.tmpl}, - } - req := &dns.Msg{ - Question: []dns.Question{{ - Name: tr.qname, - Qclass: tr.qclass, - Qtype: tr.qtype, - }}, - } - rec := dnstest.NewRecorder(&test.ResponseWriter{}) - code, err := handler.ServeDNS(ctx, rec, req) - if err == nil && tr.expectedErr != "" { - t.Errorf("Test %v expected error: %v, got nothing", tr.name, tr.expectedErr) - } - if err != nil && tr.expectedErr == "" { - t.Errorf("Test %v expected no error got: %v", tr.name, err) - } - if err != nil && tr.expectedErr != "" && err.Error() != tr.expectedErr { - t.Errorf("Test %v expected error: %v, got: %v", tr.name, tr.expectedErr, err) - } - if code != tr.expectedCode { - t.Errorf("Test %v expected response code %v, got %v", tr.name, tr.expectedCode, code) - } - if err == nil && code != rcodeFallthrough { - // only verify if we got no error and expected no error - if err := tr.verifyResponse(rec.Msg); err != nil { - t.Errorf("Test %v could not verify the response: %v", tr.name, err) - } - } - } -} - -// TestMultiSection verfies that a corefile with multiple but different template sections works -func TestMultiSection(t *testing.T) { - ctx := context.TODO() - - multisectionConfig := ` - # Implicit section (see c.ServerBlockKeys) - # test.:8053 { - - # REFUSE IN A for the server zone (test.) - template IN A { - rcode REFUSED - } - # Fallthrough everything IN TXT for test. - template IN TXT { - match "$^" - rcode SERVFAIL - fallthrough - } - # Answer CH TXT *.coredns.invalid. / coredns.invalid. - template CH TXT coredns.invalid { - answer "{{ .Name }} 60 CH TXT \"test\"" - } - # Anwser example. ip templates and fallthrough otherwise - template IN A example { - match ^ip-10-(?P[0-9]*)-(?P[0-9]*)-(?P[0-9]*)[.]example[.]$ - answer "{{ .Name }} 60 IN A 10.{{ .Group.b }}.{{ .Group.c }}.{{ .Group.d }}" - fallthrough - } - # Answer MX record requests for ip templates in example. and never fall through - template IN MX example { - match ^ip-10-(?P[0-9]*)-(?P[0-9]*)-(?P[0-9]*)[.]example[.]$ - answer "{{ .Name }} 60 IN MX 10 {{ .Name }}" - additional "{{ .Name }} 60 IN A 10.{{ .Group.b }}.{{ .Group.c }}.{{ .Group.d }}" - } - ` - c := caddy.NewTestController("dns", multisectionConfig) - c.ServerBlockKeys = []string{"test.:8053"} - - handler, err := templateParse(c) - if err != nil { - t.Fatalf("TestMultiSection could not parse config: %v", err) - } - - handler.Next = test.NextHandler(rcodeFallthrough, nil) - - rec := dnstest.NewRecorder(&test.ResponseWriter{}) - - // Asking for test. IN A -> REFUSED - - req := &dns.Msg{Question: []dns.Question{{Name: "some.test.", Qclass: dns.ClassINET, Qtype: dns.TypeA}}} - code, err := handler.ServeDNS(ctx, rec, req) - if err != nil { - t.Fatalf("TestMultiSection expected no error resolving some.test. A, got: %v", err) - } - if code != dns.RcodeRefused { - t.Fatalf("TestMultiSection expected response code REFUSED got: %v", code) - } - - // Asking for test. IN TXT -> fallthrough - - req = &dns.Msg{Question: []dns.Question{{Name: "some.test.", Qclass: dns.ClassINET, Qtype: dns.TypeTXT}}} - code, err = handler.ServeDNS(ctx, rec, req) - if err != nil { - t.Fatalf("TestMultiSection expected no error resolving some.test. TXT, got: %v", err) - } - if code != rcodeFallthrough { - t.Fatalf("TestMultiSection expected response code fallthrough got: %v", code) - } - - // Asking for coredns.invalid. CH TXT -> TXT "test" - - req = &dns.Msg{Question: []dns.Question{{Name: "coredns.invalid.", Qclass: dns.ClassCHAOS, Qtype: dns.TypeTXT}}} - code, err = handler.ServeDNS(ctx, rec, req) - if err != nil { - t.Fatalf("TestMultiSection expected no error resolving coredns.invalid. TXT, got: %v", err) - } - if code != dns.RcodeSuccess { - t.Fatalf("TestMultiSection expected success response for coredns.invalid. TXT got: %v", code) - } - if len(rec.Msg.Answer) != 1 { - t.Fatalf("TestMultiSection expected one answer for coredns.invalid. TXT got: %v", rec.Msg.Answer) - } - if rec.Msg.Answer[0].Header().Rrtype != dns.TypeTXT || rec.Msg.Answer[0].(*dns.TXT).Txt[0] != "test" { - t.Fatalf("TestMultiSection a \"test\" answer for coredns.invalid. TXT got: %v", rec.Msg.Answer[0]) - } - - // Asking for an ip template in example - - req = &dns.Msg{Question: []dns.Question{{Name: "ip-10-11-12-13.example.", Qclass: dns.ClassINET, Qtype: dns.TypeA}}} - code, err = handler.ServeDNS(ctx, rec, req) - if err != nil { - t.Fatalf("TestMultiSection expected no error resolving ip-10-11-12-13.example. IN A, got: %v", err) - } - if code != dns.RcodeSuccess { - t.Fatalf("TestMultiSection expected success response ip-10-11-12-13.example. IN A got: %v, %v", code, dns.RcodeToString[code]) - } - if len(rec.Msg.Answer) != 1 { - t.Fatalf("TestMultiSection expected one answer for ip-10-11-12-13.example. IN A got: %v", rec.Msg.Answer) - } - if rec.Msg.Answer[0].Header().Rrtype != dns.TypeA { - t.Fatalf("TestMultiSection an A RR answer for ip-10-11-12-13.example. IN A got: %v", rec.Msg.Answer[0]) - } - - // Asking for an MX ip template in example - - req = &dns.Msg{Question: []dns.Question{{Name: "ip-10-11-12-13.example.", Qclass: dns.ClassINET, Qtype: dns.TypeMX}}} - code, err = handler.ServeDNS(ctx, rec, req) - if err != nil { - t.Fatalf("TestMultiSection expected no error resolving ip-10-11-12-13.example. IN MX, got: %v", err) - } - if code != dns.RcodeSuccess { - t.Fatalf("TestMultiSection expected success response ip-10-11-12-13.example. IN MX got: %v, %v", code, dns.RcodeToString[code]) - } - if len(rec.Msg.Answer) != 1 { - t.Fatalf("TestMultiSection expected one answer for ip-10-11-12-13.example. IN MX got: %v", rec.Msg.Answer) - } - if rec.Msg.Answer[0].Header().Rrtype != dns.TypeMX { - t.Fatalf("TestMultiSection an A RR answer for ip-10-11-12-13.example. IN MX got: %v", rec.Msg.Answer[0]) - } - - // Test that something.example. A does fall through but something.example. MX does not - - req = &dns.Msg{Question: []dns.Question{{Name: "something.example.", Qclass: dns.ClassINET, Qtype: dns.TypeA}}} - code, err = handler.ServeDNS(ctx, rec, req) - if err != nil { - t.Fatalf("TestMultiSection expected no error resolving something.example. IN A, got: %v", err) - } - if code != rcodeFallthrough { - t.Fatalf("TestMultiSection expected a fall through resolving something.example. IN A, got: %v, %v", code, dns.RcodeToString[code]) - } - - req = &dns.Msg{Question: []dns.Question{{Name: "something.example.", Qclass: dns.ClassINET, Qtype: dns.TypeMX}}} - code, err = handler.ServeDNS(ctx, rec, req) - if err != nil { - t.Fatalf("TestMultiSection expected no error resolving something.example. IN MX, got: %v", err) - } - if code == rcodeFallthrough { - t.Fatalf("TestMultiSection expected no fall through resolving something.example. IN MX") - } - if code != dns.RcodeNameError { - t.Fatalf("TestMultiSection expected NXDOMAIN resolving something.example. IN MX, got %v, %v", code, dns.RcodeToString[code]) - } -} - -const rcodeFallthrough = 3841 // reserved for private use, used to indicate a fallthrough diff --git a/vendor/github.com/coredns/coredns/plugin/test/file_test.go b/vendor/github.com/coredns/coredns/plugin/test/file_test.go deleted file mode 100644 index b225ace7..00000000 --- a/vendor/github.com/coredns/coredns/plugin/test/file_test.go +++ /dev/null @@ -1,11 +0,0 @@ -package test - -import "testing" - -func TestTempFile(t *testing.T) { - _, f, e := TempFile(".", "test") - if e != nil { - t.Fatalf("Failed to create temp file: %s", e) - } - defer f() -} diff --git a/vendor/github.com/coredns/coredns/plugin/test/responsewriter.go b/vendor/github.com/coredns/coredns/plugin/test/responsewriter.go index 4db5728e..77c01411 100644 --- a/vendor/github.com/coredns/coredns/plugin/test/responsewriter.go +++ b/vendor/github.com/coredns/coredns/plugin/test/responsewriter.go @@ -9,19 +9,27 @@ import ( // ResponseWriter is useful for writing tests. It uses some fixed values for the client. The // remote will always be 10.240.0.1 and port 40212. The local address is always 127.0.0.1 and // port 53. -type ResponseWriter struct{} +type ResponseWriter struct { + TCP bool // if TCP is true we return an TCP connection instead of an UDP one. +} -// LocalAddr returns the local address, always 127.0.0.1:53 (UDP). +// LocalAddr returns the local address, 127.0.0.1:53 (UDP, TCP if t.TCP is true). func (t *ResponseWriter) LocalAddr() net.Addr { ip := net.ParseIP("127.0.0.1") port := 53 + if t.TCP { + return &net.TCPAddr{IP: ip, Port: port, Zone: ""} + } return &net.UDPAddr{IP: ip, Port: port, Zone: ""} } -// RemoteAddr returns the remote address, always 10.240.0.1:40212 (UDP). +// RemoteAddr returns the remote address, always 10.240.0.1:40212 (UDP, TCP is t.TCP is true). func (t *ResponseWriter) RemoteAddr() net.Addr { ip := net.ParseIP("10.240.0.1") port := 40212 + if t.TCP { + return &net.TCPAddr{IP: ip, Port: port, Zone: ""} + } return &net.UDPAddr{IP: ip, Port: port, Zone: ""} } @@ -44,18 +52,23 @@ func (t *ResponseWriter) TsigTimersOnly(bool) { return } func (t *ResponseWriter) Hijack() { return } // ResponseWriter6 returns fixed client and remote address in IPv6. The remote -// address is always fe80::42:ff:feca:4c65 and port 40212. The local address -// is always ::1 and port 53. +// address is always fe80::42:ff:feca:4c65 and port 40212. The local address is always ::1 and port 53. type ResponseWriter6 struct { ResponseWriter } -// LocalAddr returns the local address, always ::1, port 53 (UDP). +// LocalAddr returns the local address, always ::1, port 53 (UDP, TCP is t.TCP is true). func (t *ResponseWriter6) LocalAddr() net.Addr { + if t.TCP { + return &net.TCPAddr{IP: net.ParseIP("::1"), Port: 53, Zone: ""} + } return &net.UDPAddr{IP: net.ParseIP("::1"), Port: 53, Zone: ""} } -// RemoteAddr returns the remote address, always fe80::42:ff:feca:4c65 port 40212 (UDP). +// RemoteAddr returns the remote address, always fe80::42:ff:feca:4c65 port 40212 (UDP, TCP is t.TCP is true). func (t *ResponseWriter6) RemoteAddr() net.Addr { + if t.TCP { + return &net.TCPAddr{IP: net.ParseIP("fe80::42:ff:feca:4c65"), Port: 40212, Zone: ""} + } return &net.UDPAddr{IP: net.ParseIP("fe80::42:ff:feca:4c65"), Port: 40212, Zone: ""} } diff --git a/vendor/github.com/coredns/coredns/plugin/tls/OWNERS b/vendor/github.com/coredns/coredns/plugin/tls/OWNERS deleted file mode 100644 index f7f9ca27..00000000 --- a/vendor/github.com/coredns/coredns/plugin/tls/OWNERS +++ /dev/null @@ -1,4 +0,0 @@ -reviewers: - - johnbelamaric -approvers: - - johnbelamaric diff --git a/vendor/github.com/coredns/coredns/plugin/tls/README.md b/vendor/github.com/coredns/coredns/plugin/tls/README.md deleted file mode 100644 index 8a985cec..00000000 --- a/vendor/github.com/coredns/coredns/plugin/tls/README.md +++ /dev/null @@ -1,57 +0,0 @@ -# tls - -## Name - -*tls* - allows you to configure the server certificates for the TLS and gRPC servers. - -## Description - -CoreDNS supports queries that are encrypted using TLS (DNS over Transport Layer Security, RFC 7858) -or are using gRPC (https://grpc.io/, not an IETF standard). Normally DNS traffic isn't encrypted at -all (DNSSEC only signs resource records). - -The *proxy* plugin also support gRPC (`protocol gRPC`), meaning you can chain CoreDNS servers -using this protocol. - -The *tls* "plugin" allows you to configure the cryptographic keys that are needed for both -DNS-over-TLS and DNS-over-gRPC. If the `tls` directive is omitted, then no encryption takes place. - -The gRPC protobuffer is defined in `pb/dns.proto`. It defines the proto as a simple wrapper for the -wire data of a DNS message. - -## Syntax - -~~~ txt -tls CERT KEY [CA] -~~~ - -Parameter CA is optional. If not set, system CAs can be used to verify the client certificate - -## Examples - -Start a DNS-over-TLS server that picks up incoming DNS-over-TLS queries on port 5553 and uses the -nameservers defined in `/etc/resolv.conf` to resolve the query. This proxy path uses plain old DNS. - -~~~ -tls://.:5553 { - tls cert.pem key.pem ca.pem - proxy . /etc/resolv.conf -} -~~~ - -Start a DNS-over-gRPC server that is similar to the previous example, but using DNS-over-gRPC for -incoming queries. - -~~~ -grpc://. { - tls cert.pem key.pem ca.pem - proxy . /etc/resolv.conf -} -~~~ - -Only Knot DNS' `kdig` supports DNS-over-TLS queries, no command line client supports gRPC making -debugging these transports harder than it should be. - -## Also See - -RFC 7858 and https://grpc.io. diff --git a/vendor/github.com/coredns/coredns/plugin/tls/tls.go b/vendor/github.com/coredns/coredns/plugin/tls/tls.go deleted file mode 100644 index e08e522a..00000000 --- a/vendor/github.com/coredns/coredns/plugin/tls/tls.go +++ /dev/null @@ -1,37 +0,0 @@ -package tls - -import ( - "github.com/coredns/coredns/core/dnsserver" - "github.com/coredns/coredns/plugin" - "github.com/coredns/coredns/plugin/pkg/tls" - - "github.com/mholt/caddy" -) - -func init() { - caddy.RegisterPlugin("tls", caddy.Plugin{ - ServerType: "dns", - Action: setup, - }) -} - -func setup(c *caddy.Controller) error { - config := dnsserver.GetConfig(c) - - if config.TLSConfig != nil { - return plugin.Error("tls", c.Errf("TLS already configured for this server instance")) - } - - for c.Next() { - args := c.RemainingArgs() - if len(args) < 2 || len(args) > 3 { - return plugin.Error("tls", c.ArgErr()) - } - tls, err := tls.NewTLSConfigFromArgs(args...) - if err != nil { - return plugin.Error("tls", err) - } - config.TLSConfig = tls - } - return nil -} diff --git a/vendor/github.com/coredns/coredns/plugin/tls/tls_test.go b/vendor/github.com/coredns/coredns/plugin/tls/tls_test.go deleted file mode 100644 index 0bbba18a..00000000 --- a/vendor/github.com/coredns/coredns/plugin/tls/tls_test.go +++ /dev/null @@ -1,40 +0,0 @@ -package tls - -import ( - "strings" - "testing" - - "github.com/mholt/caddy" -) - -func TestTLS(t *testing.T) { - tests := []struct { - input string - shouldErr bool - expectedRoot string // expected root, set to the controller. Empty for negative cases. - expectedErrContent string // substring from the expected error. Empty for positive cases. - }{ - // positive - // negative - } - - for i, test := range tests { - c := caddy.NewTestController("dns", test.input) - err := setup(c) - //cfg := dnsserver.GetConfig(c) - - if test.shouldErr && err == nil { - t.Errorf("Test %d: Expected error but found %s for input %s", i, err, test.input) - } - - if err != nil { - if !test.shouldErr { - t.Errorf("Test %d: Expected no error but found one for input %s. Error was: %v", i, test.input, err) - } - - if !strings.Contains(err.Error(), test.expectedErrContent) { - t.Errorf("Test %d: Expected error to contain: %v, found error: %v, input: %s", i, test.expectedErrContent, err, test.input) - } - } - } -} diff --git a/vendor/github.com/coredns/coredns/plugin/trace/OWNERS b/vendor/github.com/coredns/coredns/plugin/trace/OWNERS deleted file mode 100644 index f7f9ca27..00000000 --- a/vendor/github.com/coredns/coredns/plugin/trace/OWNERS +++ /dev/null @@ -1,4 +0,0 @@ -reviewers: - - johnbelamaric -approvers: - - johnbelamaric diff --git a/vendor/github.com/coredns/coredns/plugin/trace/README.md b/vendor/github.com/coredns/coredns/plugin/trace/README.md deleted file mode 100644 index 31e74ea7..00000000 --- a/vendor/github.com/coredns/coredns/plugin/trace/README.md +++ /dev/null @@ -1,86 +0,0 @@ -# trace - -## Name - -*trace* - enables OpenTracing-based tracing of DNS requests as they go through the plugin chain. - -## Description - -With *trace* you enable OpenTracing of how a request flows through CoreDNS. - -## Syntax - -The simplest form is just: - -~~~ -trace [ENDPOINT-TYPE] [ENDPOINT] -~~~ - -* **ENDPOINT-TYPE** is the type of tracing destination. Currently only `zipkin` and `datadog` are supported. - Defaults to `zipkin`. -* **ENDPOINT** is the tracing destination, and defaults to `localhost:9411`. For Zipkin, if - ENDPOINT does not begin with `http`, then it will be transformed to `http://ENDPOINT/api/v1/spans`. - -With this form, all queries will be traced. - -Additional features can be enabled with this syntax: - -~~~ -trace [ENDPOINT-TYPE] [ENDPOINT] { - every AMOUNT - service NAME - client_server -} -~~~ - -* `every` **AMOUNT** will only trace one query of each AMOUNT queries. For example, to trace 1 in every - 100 queries, use AMOUNT of 100. The default is 1. -* `service` **NAME** allows you to specify the service name reported to the tracing server. - Default is `coredns`. -* `client_server` will enable the `ClientServerSameSpan` OpenTracing feature. - -## Zipkin -You can run Zipkin on a Docker host like this: - -``` -docker run -d -p 9411:9411 openzipkin/zipkin -``` - -## Examples - -Use an alternative Zipkin address: - -~~~ -trace tracinghost:9253 -~~~ - -or - -~~~ corefile -. { - trace zipkin tracinghost:9253 -} -~~~ - -If for some reason you are using an API reverse proxy or something and need to remap -the standard Zipkin URL you can do something like: - -~~~ -trace http://tracinghost:9411/zipkin/api/v1/spans -~~~ - -Using DataDog: - -~~~ -trace datadog localhost:8125 -~~~ - -Trace one query every 10000 queries, rename the service, and enable same span: - -~~~ -trace tracinghost:9411 { - every 10000 - service dnsproxy - client_server -} -~~~ diff --git a/vendor/github.com/coredns/coredns/plugin/trace/setup.go b/vendor/github.com/coredns/coredns/plugin/trace/setup.go deleted file mode 100644 index 1614cc17..00000000 --- a/vendor/github.com/coredns/coredns/plugin/trace/setup.go +++ /dev/null @@ -1,124 +0,0 @@ -package trace - -import ( - "fmt" - "strconv" - "strings" - - "github.com/coredns/coredns/core/dnsserver" - "github.com/coredns/coredns/plugin" - - "github.com/mholt/caddy" -) - -func init() { - caddy.RegisterPlugin("trace", caddy.Plugin{ - ServerType: "dns", - Action: setup, - }) -} - -func setup(c *caddy.Controller) error { - t, err := traceParse(c) - if err != nil { - return plugin.Error("trace", err) - } - - dnsserver.GetConfig(c).AddPlugin(func(next plugin.Handler) plugin.Handler { - t.Next = next - return t - }) - - c.OnStartup(t.OnStartup) - - return nil -} - -func traceParse(c *caddy.Controller) (*trace, error) { - var ( - tr = &trace{every: 1, serviceName: defServiceName} - err error - ) - - cfg := dnsserver.GetConfig(c) - tr.serviceEndpoint = cfg.ListenHosts[0] + ":" + cfg.Port - - for c.Next() { // trace - var err error - args := c.RemainingArgs() - switch len(args) { - case 0: - tr.EndpointType, tr.Endpoint, err = normalizeEndpoint(defEpType, "") - case 1: - tr.EndpointType, tr.Endpoint, err = normalizeEndpoint(defEpType, args[0]) - case 2: - epType := strings.ToLower(args[0]) - tr.EndpointType, tr.Endpoint, err = normalizeEndpoint(epType, args[1]) - default: - err = c.ArgErr() - } - if err != nil { - return tr, err - } - for c.NextBlock() { - switch c.Val() { - case "every": - args := c.RemainingArgs() - if len(args) != 1 { - return nil, c.ArgErr() - } - tr.every, err = strconv.ParseUint(args[0], 10, 64) - if err != nil { - return nil, err - } - case "service": - args := c.RemainingArgs() - if len(args) != 1 { - return nil, c.ArgErr() - } - tr.serviceName = args[0] - case "client_server": - args := c.RemainingArgs() - if len(args) > 1 { - return nil, c.ArgErr() - } - tr.clientServer = true - if len(args) == 1 { - tr.clientServer, err = strconv.ParseBool(args[0]) - } - if err != nil { - return nil, err - } - } - } - } - return tr, err -} - -func normalizeEndpoint(epType, ep string) (string, string, error) { - if _, ok := supportedProviders[epType]; !ok { - return "", "", fmt.Errorf("tracing endpoint type '%s' is not supported", epType) - } - - if ep == "" { - ep = supportedProviders[epType] - } - - if epType == "zipkin" { - if !strings.Contains(ep, "http") { - ep = "http://" + ep + "/api/v1/spans" - } - } - - return epType, ep, nil -} - -var supportedProviders = map[string]string{ - "zipkin": "localhost:9411", - "datadog": "localhost:8126", -} - -const ( - defEpType = "zipkin" - defServiceName = "coredns" -) diff --git a/vendor/github.com/coredns/coredns/plugin/trace/setup_test.go b/vendor/github.com/coredns/coredns/plugin/trace/setup_test.go deleted file mode 100644 index 06a1b21b..00000000 --- a/vendor/github.com/coredns/coredns/plugin/trace/setup_test.go +++ /dev/null @@ -1,61 +0,0 @@ -package trace - -import ( - "testing" - - "github.com/mholt/caddy" -) - -func TestTraceParse(t *testing.T) { - tests := []struct { - input string - shouldErr bool - endpoint string - every uint64 - serviceName string - clientServer bool - }{ - // oks - {`trace`, false, "http://localhost:9411/api/v1/spans", 1, `coredns`, false}, - {`trace localhost:1234`, false, "http://localhost:1234/api/v1/spans", 1, `coredns`, false}, - {`trace http://localhost:1234/somewhere/else`, false, "http://localhost:1234/somewhere/else", 1, `coredns`, false}, - {`trace zipkin localhost:1234`, false, "http://localhost:1234/api/v1/spans", 1, `coredns`, false}, - {`trace datadog localhost`, false, "localhost", 1, `coredns`, false}, - {`trace datadog http://localhost:8127`, false, "http://localhost:8127", 1, `coredns`, false}, - {"trace {\n every 100\n}", false, "http://localhost:9411/api/v1/spans", 100, `coredns`, false}, - {"trace {\n every 100\n service foobar\nclient_server\n}", false, "http://localhost:9411/api/v1/spans", 100, `foobar`, true}, - {"trace {\n every 2\n client_server true\n}", false, "http://localhost:9411/api/v1/spans", 2, `coredns`, true}, - {"trace {\n client_server false\n}", false, "http://localhost:9411/api/v1/spans", 1, `coredns`, false}, - // fails - {`trace footype localhost:4321`, true, "", 1, "", false}, - {"trace {\n every 2\n client_server junk\n}", true, "", 1, "", false}, - } - for i, test := range tests { - c := caddy.NewTestController("dns", test.input) - m, err := traceParse(c) - if test.shouldErr && err == nil { - t.Errorf("Test %v: Expected error but found nil", i) - continue - } else if !test.shouldErr && err != nil { - t.Errorf("Test %v: Expected no error but found error: %v", i, err) - continue - } - - if test.shouldErr { - continue - } - - if test.endpoint != m.Endpoint { - t.Errorf("Test %v: Expected endpoint %s but found: %s", i, test.endpoint, m.Endpoint) - } - if test.every != m.every { - t.Errorf("Test %v: Expected every %d but found: %d", i, test.every, m.every) - } - if test.serviceName != m.serviceName { - t.Errorf("Test %v: Expected service name %s but found: %s", i, test.serviceName, m.serviceName) - } - if test.clientServer != m.clientServer { - t.Errorf("Test %v: Expected client_server %t but found: %t", i, test.clientServer, m.clientServer) - } - } -} diff --git a/vendor/github.com/coredns/coredns/plugin/trace/trace.go b/vendor/github.com/coredns/coredns/plugin/trace/trace.go deleted file mode 100644 index a0a2071e..00000000 --- a/vendor/github.com/coredns/coredns/plugin/trace/trace.go +++ /dev/null @@ -1,103 +0,0 @@ -// Package trace implements OpenTracing-based tracing -package trace - -import ( - "context" - "fmt" - "strings" - "sync" - "sync/atomic" - - "github.com/coredns/coredns/plugin" - "github.com/coredns/coredns/plugin/metrics" - // Plugin the trace package. - _ "github.com/coredns/coredns/plugin/pkg/trace" - - ddtrace "github.com/DataDog/dd-trace-go/opentracing" - "github.com/miekg/dns" - ot "github.com/opentracing/opentracing-go" - zipkin "github.com/openzipkin/zipkin-go-opentracing" -) - -type trace struct { - Next plugin.Handler - Endpoint string - EndpointType string - tracer ot.Tracer - serviceEndpoint string - serviceName string - clientServer bool - every uint64 - count uint64 - Once sync.Once -} - -func (t *trace) Tracer() ot.Tracer { - return t.tracer -} - -// OnStartup sets up the tracer -func (t *trace) OnStartup() error { - var err error - t.Once.Do(func() { - switch t.EndpointType { - case "zipkin": - err = t.setupZipkin() - case "datadog": - err = t.setupDatadog() - default: - err = fmt.Errorf("unknown endpoint type: %s", t.EndpointType) - } - }) - return err -} - -func (t *trace) setupZipkin() error { - - collector, err := zipkin.NewHTTPCollector(t.Endpoint) - if err != nil { - return err - } - - recorder := zipkin.NewRecorder(collector, false, t.serviceEndpoint, t.serviceName) - t.tracer, err = zipkin.NewTracer(recorder, zipkin.ClientServerSameSpan(t.clientServer)) - - return err -} - -func (t *trace) setupDatadog() error { - config := ddtrace.NewConfiguration() - config.ServiceName = t.serviceName - - host := strings.Split(t.Endpoint, ":") - config.AgentHostname = host[0] - - if len(host) == 2 { - config.AgentPort = host[1] - } - - tracer, _, err := ddtrace.NewTracer(config) - t.tracer = tracer - return err -} - -// Name implements the Handler interface. -func (t *trace) Name() string { return "trace" } - -// ServeDNS implements the plugin.Handle interface. -func (t *trace) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (int, error) { - trace := false - if t.every > 0 { - queryNr := atomic.AddUint64(&t.count, 1) - - if queryNr%t.every == 0 { - trace = true - } - } - if span := ot.SpanFromContext(ctx); span == nil && trace { - span := t.Tracer().StartSpan("servedns:" + metrics.WithServer(ctx)) - defer span.Finish() - ctx = ot.ContextWithSpan(ctx, span) - } - return plugin.NextOrFailure(t.Name(), t.Next, ctx, w, r) -} diff --git a/vendor/github.com/coredns/coredns/plugin/trace/trace_test.go b/vendor/github.com/coredns/coredns/plugin/trace/trace_test.go deleted file mode 100644 index b006009c..00000000 --- a/vendor/github.com/coredns/coredns/plugin/trace/trace_test.go +++ /dev/null @@ -1,33 +0,0 @@ -package trace - -import ( - "testing" - - "github.com/mholt/caddy" -) - -// createTestTrace creates a trace plugin to be used in tests -func createTestTrace(config string) (*caddy.Controller, *trace, error) { - c := caddy.NewTestController("dns", config) - m, err := traceParse(c) - return c, m, err -} - -func TestTrace(t *testing.T) { - _, m, err := createTestTrace(`trace`) - if err != nil { - t.Errorf("Error parsing test input: %s", err) - return - } - if m.Name() != "trace" { - t.Errorf("Wrong name from GetName: %s", m.Name()) - } - err = m.OnStartup() - if err != nil { - t.Errorf("Error starting tracing plugin: %s", err) - return - } - if m.Tracer() == nil { - t.Errorf("Error, no tracer created") - } -} diff --git a/vendor/github.com/coredns/coredns/plugin/whoami/OWNERS b/vendor/github.com/coredns/coredns/plugin/whoami/OWNERS deleted file mode 100644 index eee46f68..00000000 --- a/vendor/github.com/coredns/coredns/plugin/whoami/OWNERS +++ /dev/null @@ -1,4 +0,0 @@ -reviewers: - - miekg -approvers: - - miekg diff --git a/vendor/github.com/coredns/coredns/plugin/whoami/README.md b/vendor/github.com/coredns/coredns/plugin/whoami/README.md deleted file mode 100644 index 1df6df13..00000000 --- a/vendor/github.com/coredns/coredns/plugin/whoami/README.md +++ /dev/null @@ -1,58 +0,0 @@ -# whoami - -## Name - -*whoami* - returns your resolver's local IP address, port and transport. - -## Description - -The *whoami* plugin is not really that useful, but can be used for having a simple (fast) endpoint -to test clients against. When *whoami* returns a response it will have your client's IP address the -additional section as either an A or AAAA record. - -The reply always has an empty answer section. The port and transport are included in the additional -section as a SRV record, transport can be "tcp" or "udp". - -~~~ txt -._.qname. 0 IN SRV 0 0 . -~~~ - -The *whoami* plugin will respond to every A or AAAA query, regardless of the query name. - -If CoreDNS can't find a Corefile on startup this is the _default_ plugin that gets loaded. As such -it can be used to check that CoreDNS is responding to queries. Other than that this plugin is of -limited use in production. - -## Syntax - -~~~ txt -whoami -~~~ - -## Examples - -Start a server on the default port and load the *whoami* plugin. - -~~~ corefile -. { - whoami -} -~~~ - -When queried for "example.org A", CoreDNS will respond with: - -~~~ txt -;; QUESTION SECTION: -;example.org. IN A - -;; ADDITIONAL SECTION: -example.org. 0 IN A 10.240.0.1 -_udp.example.org. 0 IN SRV 0 0 40212 -~~~ - -## See Also - -[Read the blog post][blog] on how this plugin is built, or [explore the source code][code]. - -[blog]: https://coredns.io/2017/03/01/how-to-add-plugins-to-coredns/ -[code]: https://github.com/coredns/coredns/blob/master/plugin/whoami/ diff --git a/vendor/github.com/coredns/coredns/plugin/whoami/setup.go b/vendor/github.com/coredns/coredns/plugin/whoami/setup.go deleted file mode 100644 index bd4971ae..00000000 --- a/vendor/github.com/coredns/coredns/plugin/whoami/setup.go +++ /dev/null @@ -1,28 +0,0 @@ -package whoami - -import ( - "github.com/coredns/coredns/core/dnsserver" - "github.com/coredns/coredns/plugin" - - "github.com/mholt/caddy" -) - -func init() { - caddy.RegisterPlugin("whoami", caddy.Plugin{ - ServerType: "dns", - Action: setup, - }) -} - -func setup(c *caddy.Controller) error { - c.Next() // 'whoami' - if c.NextArg() { - return plugin.Error("whoami", c.ArgErr()) - } - - dnsserver.GetConfig(c).AddPlugin(func(next plugin.Handler) plugin.Handler { - return Whoami{} - }) - - return nil -} diff --git a/vendor/github.com/coredns/coredns/plugin/whoami/setup_test.go b/vendor/github.com/coredns/coredns/plugin/whoami/setup_test.go deleted file mode 100644 index c4fa58fe..00000000 --- a/vendor/github.com/coredns/coredns/plugin/whoami/setup_test.go +++ /dev/null @@ -1,19 +0,0 @@ -package whoami - -import ( - "testing" - - "github.com/mholt/caddy" -) - -func TestSetup(t *testing.T) { - c := caddy.NewTestController("dns", `whoami`) - if err := setup(c); err != nil { - t.Fatalf("Expected no errors, but got: %v", err) - } - - c = caddy.NewTestController("dns", `whoami example.org`) - if err := setup(c); err == nil { - t.Fatalf("Expected errors, but got: %v", err) - } -} diff --git a/vendor/github.com/coredns/coredns/plugin/whoami/whoami.go b/vendor/github.com/coredns/coredns/plugin/whoami/whoami.go deleted file mode 100644 index b2ba25e5..00000000 --- a/vendor/github.com/coredns/coredns/plugin/whoami/whoami.go +++ /dev/null @@ -1,59 +0,0 @@ -// Package whoami implements a plugin that returns details about the resolving -// querying it. -package whoami - -import ( - "context" - "net" - "strconv" - - "github.com/coredns/coredns/request" - - "github.com/miekg/dns" -) - -// Whoami is a plugin that returns your IP address, port and the protocol used for connecting -// to CoreDNS. -type Whoami struct{} - -// ServeDNS implements the plugin.Handler interface. -func (wh Whoami) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (int, error) { - state := request.Request{W: w, Req: r} - - a := new(dns.Msg) - a.SetReply(r) - a.Authoritative = true - - ip := state.IP() - var rr dns.RR - - switch state.Family() { - case 1: - rr = new(dns.A) - rr.(*dns.A).Hdr = dns.RR_Header{Name: state.QName(), Rrtype: dns.TypeA, Class: state.QClass()} - rr.(*dns.A).A = net.ParseIP(ip).To4() - case 2: - rr = new(dns.AAAA) - rr.(*dns.AAAA).Hdr = dns.RR_Header{Name: state.QName(), Rrtype: dns.TypeAAAA, Class: state.QClass()} - rr.(*dns.AAAA).AAAA = net.ParseIP(ip) - } - - srv := new(dns.SRV) - srv.Hdr = dns.RR_Header{Name: "_" + state.Proto() + "." + state.QName(), Rrtype: dns.TypeSRV, Class: state.QClass()} - if state.QName() == "." { - srv.Hdr.Name = "_" + state.Proto() + state.QName() - } - port, _ := strconv.Atoi(state.Port()) - srv.Port = uint16(port) - srv.Target = "." - - a.Extra = []dns.RR{rr, srv} - - state.SizeAndDo(a) - w.WriteMsg(a) - - return 0, nil -} - -// Name implements the Handler interface. -func (wh Whoami) Name() string { return "whoami" } diff --git a/vendor/github.com/coredns/coredns/plugin/whoami/whoami_test.go b/vendor/github.com/coredns/coredns/plugin/whoami/whoami_test.go deleted file mode 100644 index 0db20758..00000000 --- a/vendor/github.com/coredns/coredns/plugin/whoami/whoami_test.go +++ /dev/null @@ -1,64 +0,0 @@ -package whoami - -import ( - "context" - "testing" - - "github.com/coredns/coredns/plugin/pkg/dnstest" - "github.com/coredns/coredns/plugin/test" - - "github.com/miekg/dns" -) - -func TestWhoami(t *testing.T) { - wh := Whoami{} - - tests := []struct { - qname string - qtype uint16 - expectedCode int - expectedReply []string // ownernames for the records in the additional section. - expectedErr error - }{ - { - qname: "example.org", - qtype: dns.TypeA, - expectedCode: dns.RcodeSuccess, - expectedReply: []string{"example.org.", "_udp.example.org."}, - expectedErr: nil, - }, - // Case insensitive and case preserving - { - qname: "Example.ORG", - qtype: dns.TypeA, - expectedCode: dns.RcodeSuccess, - expectedReply: []string{"Example.ORG.", "_udp.Example.ORG."}, - expectedErr: nil, - }, - } - - ctx := context.TODO() - - for i, tc := range tests { - req := new(dns.Msg) - req.SetQuestion(dns.Fqdn(tc.qname), tc.qtype) - - rec := dnstest.NewRecorder(&test.ResponseWriter{}) - code, err := wh.ServeDNS(ctx, rec, req) - - if err != tc.expectedErr { - t.Errorf("Test %d: Expected error %v, but got %v", i, tc.expectedErr, err) - } - if code != int(tc.expectedCode) { - t.Errorf("Test %d: Expected status code %d, but got %d", i, tc.expectedCode, code) - } - if len(tc.expectedReply) != 0 { - for i, expected := range tc.expectedReply { - actual := rec.Msg.Extra[i].Header().Name - if actual != expected { - t.Errorf("Test %d: Expected answer %s, but got %s", i, expected, actual) - } - } - } - } -} diff --git a/vendor/github.com/coredns/coredns/request/request.go b/vendor/github.com/coredns/coredns/request/request.go index ac6e9866..06f840f8 100644 --- a/vendor/github.com/coredns/coredns/request/request.go +++ b/vendor/github.com/coredns/coredns/request/request.go @@ -26,8 +26,13 @@ type Request struct { do *bool // nil: nothing, otherwise *do value // TODO(miek): opt record itself as well? - // Cache lowercase qname. - name string + // Caches + name string // lowercase qname. + ip string // client's ip. + port string // client's port. + family int // transport's family. + localPort string // server's port. + localIP string // server's ip. } // NewWithQuestion returns a new request based on the old, but with a new question @@ -40,26 +45,73 @@ func (r *Request) NewWithQuestion(name string, typ uint16) Request { // IP gets the (remote) IP address of the client making the request. func (r *Request) IP() string { + if r.ip != "" { + return r.ip + } + ip, _, err := net.SplitHostPort(r.W.RemoteAddr().String()) if err != nil { - return r.W.RemoteAddr().String() + r.ip = r.W.RemoteAddr().String() + return r.ip } - return ip + + r.ip = ip + return r.ip } -// Port gets the (remote) Port of the client making the request. +// LocalIP gets the (local) IP address of server handling the request. +func (r *Request) LocalIP() string { + if r.localIP != "" { + return r.localIP + } + + ip, _, err := net.SplitHostPort(r.W.LocalAddr().String()) + if err != nil { + r.localIP = r.W.LocalAddr().String() + return r.localIP + } + + r.localIP = ip + return r.localIP +} + +// Port gets the (remote) port of the client making the request. func (r *Request) Port() string { + if r.port != "" { + return r.port + } + _, port, err := net.SplitHostPort(r.W.RemoteAddr().String()) if err != nil { - return "0" + r.port = "0" + return r.port } - return port + + r.port = port + return r.port +} + +// LocalPort gets the local port of the server handling the request. +func (r *Request) LocalPort() string { + if r.localPort != "" { + return r.localPort + } + + _, port, err := net.SplitHostPort(r.W.LocalAddr().String()) + if err != nil { + r.localPort = "0" + return r.localPort + } + + r.localPort = port + return r.localPort } // RemoteAddr returns the net.Addr of the client that sent the current request. -func (r *Request) RemoteAddr() string { - return r.W.RemoteAddr().String() -} +func (r *Request) RemoteAddr() string { return r.W.RemoteAddr().String() } + +// LocalAddr returns the net.Addr of the server handling the current request. +func (r *Request) LocalAddr() string { return r.W.LocalAddr().String() } // Proto gets the protocol used as the transport. This will be udp or tcp. func (r *Request) Proto() string { return Proto(r.W) } @@ -78,6 +130,10 @@ func Proto(w dns.ResponseWriter) string { // Family returns the family of the transport, 1 for IPv4 and 2 for IPv6. func (r *Request) Family() int { + if r.family != 0 { + return r.family + } + var a net.IP ip := r.W.RemoteAddr() if i, ok := ip.(*net.UDPAddr); ok { @@ -88,9 +144,11 @@ func (r *Request) Family() int { } if a.To4() != nil { - return 1 + r.family = 1 + return r.family } - return 2 + r.family = 2 + return r.family } // Do returns if the request has the DO (DNSSEC OK) bit set. @@ -371,6 +429,11 @@ func (r *Request) ErrorMessage(rcode int) *dns.Msg { // Clear clears all caching from Request s. func (r *Request) Clear() { r.name = "" + r.ip = "" + r.localIP = "" + r.port = "" + r.localPort = "" + r.family = 0 } // Match checks if the reply matches the qname and qtype from the request, it returns diff --git a/vendor/github.com/coredns/coredns/request/request_test.go b/vendor/github.com/coredns/coredns/request/request_test.go deleted file mode 100644 index f99e5cd8..00000000 --- a/vendor/github.com/coredns/coredns/request/request_test.go +++ /dev/null @@ -1,204 +0,0 @@ -package request - -import ( - "fmt" - "testing" - - "github.com/coredns/coredns/plugin/test" - - "github.com/miekg/dns" -) - -func TestRequestDo(t *testing.T) { - st := testRequest() - - st.Do() - if st.do == nil { - t.Fatalf("Expected st.do to be set") - } -} - -func TestRequestRemote(t *testing.T) { - st := testRequest() - if st.IP() != "10.240.0.1" { - t.Fatalf("Wrong IP from request") - } - p := st.Port() - if p == "" { - t.Fatalf("Failed to get Port from request") - } - if p != "40212" { - t.Fatalf("Wrong port from request") - } -} - -func TestRequestMalformed(t *testing.T) { - m := new(dns.Msg) - st := Request{Req: m} - - if x := st.QType(); x != 0 { - t.Errorf("Expected 0 Qtype, got %d", x) - } - - if x := st.QClass(); x != 0 { - t.Errorf("Expected 0 QClass, got %d", x) - } - - if x := st.QName(); x != "." { - t.Errorf("Expected . Qname, got %s", x) - } - - if x := st.Name(); x != "." { - t.Errorf("Expected . Name, got %s", x) - } - - if x := st.Type(); x != "" { - t.Errorf("Expected empty Type, got %s", x) - } - - if x := st.Class(); x != "" { - t.Errorf("Expected empty Class, got %s", x) - } -} - -func TestRequestScrubAnswer(t *testing.T) { - m := new(dns.Msg) - m.SetQuestion("large.example.com.", dns.TypeSRV) - req := Request{W: &test.ResponseWriter{}, Req: m} - - reply := new(dns.Msg) - reply.SetReply(m) - for i := 1; i < 200; i++ { - reply.Answer = append(reply.Answer, test.SRV( - fmt.Sprintf("large.example.com. 10 IN SRV 0 0 80 10-0-0-%d.default.pod.k8s.example.com.", i))) - } - - _, got := req.Scrub(reply) - if want := ScrubAnswer; want != got { - t.Errorf("Want scrub result %d, got %d", want, got) - } - if want, got := req.Size(), reply.Len(); want < got { - t.Errorf("Want scrub to reduce message length below %d bytes, got %d bytes", want, got) - } - if !reply.Truncated { - t.Errorf("Want scrub to set truncated bit") - } -} - -func TestRequestScrubExtra(t *testing.T) { - m := new(dns.Msg) - m.SetQuestion("large.example.com.", dns.TypeSRV) - req := Request{W: &test.ResponseWriter{}, Req: m} - - reply := new(dns.Msg) - reply.SetReply(m) - for i := 1; i < 200; i++ { - reply.Extra = append(reply.Extra, test.SRV( - fmt.Sprintf("large.example.com. 10 IN SRV 0 0 80 10-0-0-%d.default.pod.k8s.example.com.", i))) - } - - _, got := req.Scrub(reply) - if want := ScrubExtra; want != got { - t.Errorf("Want scrub result %d, got %d", want, got) - } - if want, got := req.Size(), reply.Len(); want < got { - t.Errorf("Want scrub to reduce message length below %d bytes, got %d bytes", want, got) - } - if reply.Truncated { - t.Errorf("Want scrub to not set truncated bit") - } -} - -func TestRequestScrubExtraEdns0(t *testing.T) { - m := new(dns.Msg) - m.SetQuestion("large.example.com.", dns.TypeSRV) - m.SetEdns0(4096, true) - req := Request{W: &test.ResponseWriter{}, Req: m} - - reply := new(dns.Msg) - reply.SetReply(m) - for i := 1; i < 200; i++ { - reply.Extra = append(reply.Extra, test.SRV( - fmt.Sprintf("large.example.com. 10 IN SRV 0 0 80 10-0-0-%d.default.pod.k8s.example.com.", i))) - } - - _, got := req.Scrub(reply) - if want := ScrubExtra; want != got { - t.Errorf("Want scrub result %d, got %d", want, got) - } - if want, got := req.Size(), reply.Len(); want < got { - t.Errorf("Want scrub to reduce message length below %d bytes, got %d bytes", want, got) - } - if reply.Truncated { - t.Errorf("Want scrub to not set truncated bit") - } - opt := reply.Extra[len(reply.Extra)-1] - if opt.Header().Rrtype != dns.TypeOPT { - t.Errorf("Last RR must be OPT record") - } -} - -func TestRequestScrubAnswerExact(t *testing.T) { - m := new(dns.Msg) - m.SetQuestion("large.example.com.", dns.TypeSRV) - m.SetEdns0(867, false) // Bit fiddly, but this hits the rl == size break clause in Scrub, 52 RRs should remain. - req := Request{W: &test.ResponseWriter{}, Req: m} - - reply := new(dns.Msg) - reply.SetReply(m) - for i := 1; i < 200; i++ { - reply.Answer = append(reply.Answer, test.A(fmt.Sprintf("large.example.com. 10 IN A 127.0.0.%d", i))) - } - - _, got := req.Scrub(reply) - if want := ScrubAnswer; want != got { - t.Errorf("Want scrub result %d, got %d", want, got) - } - if want, got := req.Size(), reply.Len(); want < got { - t.Errorf("Want scrub to reduce message length below %d bytes, got %d bytes", want, got) - } -} - -func TestRequestMatch(t *testing.T) { - st := testRequest() - reply := new(dns.Msg) - reply.Response = true - - reply.SetQuestion("example.com.", dns.TypeMX) - if b := st.Match(reply); b { - t.Errorf("Failed to match %s %d, got %t, expected %t", "example.com.", dns.TypeMX, b, false) - } - - reply.SetQuestion("example.com.", dns.TypeA) - if b := st.Match(reply); !b { - t.Errorf("Failed to match %s %d, got %t, expected %t", "example.com.", dns.TypeA, b, true) - } - - reply.SetQuestion("example.org.", dns.TypeA) - if b := st.Match(reply); b { - t.Errorf("Failed to match %s %d, got %t, expected %t", "example.org.", dns.TypeA, b, false) - } -} - -func BenchmarkRequestDo(b *testing.B) { - st := testRequest() - - for i := 0; i < b.N; i++ { - st.Do() - } -} - -func BenchmarkRequestSize(b *testing.B) { - st := testRequest() - - for i := 0; i < b.N; i++ { - st.Size() - } -} - -func testRequest() Request { - m := new(dns.Msg) - m.SetQuestion("example.com.", dns.TypeA) - m.SetEdns0(4097, true) - return Request{W: &test.ResponseWriter{}, Req: m} -} diff --git a/vendor/github.com/coredns/coredns/test/auto_test.go b/vendor/github.com/coredns/coredns/test/auto_test.go deleted file mode 100644 index ff130188..00000000 --- a/vendor/github.com/coredns/coredns/test/auto_test.go +++ /dev/null @@ -1,173 +0,0 @@ -package test - -import ( - "io/ioutil" - "log" - "os" - "path" - "testing" - "time" - - "github.com/coredns/coredns/plugin/proxy" - "github.com/coredns/coredns/plugin/test" - "github.com/coredns/coredns/request" - - "github.com/miekg/dns" -) - -func TestAuto(t *testing.T) { - t.Parallel() - tmpdir, err := ioutil.TempDir(os.TempDir(), "coredns") - if err != nil { - t.Fatal(err) - } - - corefile := `org:0 { - auto { - directory ` + tmpdir + ` db\.(.*) {1} 1 - } - } -` - - i, udp, _, err := CoreDNSServerAndPorts(corefile) - if err != nil { - t.Fatalf("Could not get CoreDNS serving instance: %s", err) - } - defer i.Stop() - - log.SetOutput(ioutil.Discard) - - p := proxy.NewLookup([]string{udp}) - state := request.Request{W: &test.ResponseWriter{}, Req: new(dns.Msg)} - - resp, err := p.Lookup(state, "www.example.org.", dns.TypeA) - if err != nil { - t.Fatal("Expected to receive reply, but didn't") - } - if resp.Rcode != dns.RcodeServerFailure { - t.Fatalf("Expected reply to be a SERVFAIL, got %d", resp.Rcode) - } - - // Write db.example.org to get example.org. - if err = ioutil.WriteFile(path.Join(tmpdir, "db.example.org"), []byte(zoneContent), 0644); err != nil { - t.Fatal(err) - } - - time.Sleep(1500 * time.Millisecond) // wait for it to be picked up - - resp, err = p.Lookup(state, "www.example.org.", dns.TypeA) - if err != nil { - t.Fatal("Expected to receive reply, but didn't") - } - if len(resp.Answer) != 1 { - t.Fatalf("Expected 1 RR in the answer section, got %d", len(resp.Answer)) - } - - // Remove db.example.org again. - os.Remove(path.Join(tmpdir, "db.example.org")) - - time.Sleep(1100 * time.Millisecond) // wait for it to be picked up - resp, err = p.Lookup(state, "www.example.org.", dns.TypeA) - if err != nil { - t.Fatal("Expected to receive reply, but didn't") - } - if resp.Rcode != dns.RcodeServerFailure { - t.Fatalf("Expected reply to be a SERVFAIL, got %d", resp.Rcode) - } -} - -func TestAutoNonExistentZone(t *testing.T) { - t.Parallel() - tmpdir, err := ioutil.TempDir(os.TempDir(), "coredns") - if err != nil { - t.Fatal(err) - } - log.SetOutput(ioutil.Discard) - - corefile := `.:0 { - auto { - directory ` + tmpdir + ` (.*) {1} 1 - } - errors stdout - } -` - - i, err := CoreDNSServer(corefile) - if err != nil { - t.Fatalf("Could not get CoreDNS serving instance: %s", err) - } - - udp, _ := CoreDNSServerPorts(i, 0) - if udp == "" { - t.Fatal("Could not get UDP listening port") - } - defer i.Stop() - - p := proxy.NewLookup([]string{udp}) - state := request.Request{W: &test.ResponseWriter{}, Req: new(dns.Msg)} - - resp, err := p.Lookup(state, "example.org.", dns.TypeA) - if err != nil { - t.Fatal("Expected to receive reply, but didn't") - } - if resp.Rcode != dns.RcodeServerFailure { - t.Fatalf("Expected reply to be a SERVFAIL, got %d", resp.Rcode) - } -} - -func TestAutoAXFR(t *testing.T) { - t.Parallel() - log.SetOutput(ioutil.Discard) - - tmpdir, err := ioutil.TempDir(os.TempDir(), "coredns") - if err != nil { - t.Fatal(err) - } - - corefile := `org:0 { - auto { - directory ` + tmpdir + ` db\.(.*) {1} 1 - transfer to * - } - } -` - - i, err := CoreDNSServer(corefile) - if err != nil { - t.Fatalf("Could not get CoreDNS serving instance: %s", err) - } - - udp, _ := CoreDNSServerPorts(i, 0) - if udp == "" { - t.Fatal("Could not get UDP listening port") - } - defer i.Stop() - - // Write db.example.org to get example.org. - if err = ioutil.WriteFile(path.Join(tmpdir, "db.example.org"), []byte(zoneContent), 0644); err != nil { - t.Fatal(err) - } - - time.Sleep(1100 * time.Millisecond) // wait for it to be picked up - - p := proxy.NewLookup([]string{udp}) - m := new(dns.Msg) - m.SetAxfr("example.org.") - state := request.Request{W: &test.ResponseWriter{}, Req: m} - - resp, err := p.Lookup(state, "example.org.", dns.TypeAXFR) - if err != nil { - t.Fatal("Expected to receive reply, but didn't") - } - if len(resp.Answer) != 5 { - t.Fatalf("Expected response with %d RRs, got %d", 5, len(resp.Answer)) - } -} - -const zoneContent = `; testzone -@ IN SOA sns.dns.icann.org. noc.dns.icann.org. 2016082534 7200 3600 1209600 3600 - NS a.iana-servers.net. - NS b.iana-servers.net. - -www IN A 127.0.0.1 -` diff --git a/vendor/github.com/coredns/coredns/test/cache_test.go b/vendor/github.com/coredns/coredns/test/cache_test.go deleted file mode 100644 index 6271d5c1..00000000 --- a/vendor/github.com/coredns/coredns/test/cache_test.go +++ /dev/null @@ -1,59 +0,0 @@ -package test - -import ( - "testing" - - "github.com/coredns/coredns/plugin/proxy" - "github.com/coredns/coredns/plugin/test" - "github.com/coredns/coredns/request" - - "github.com/miekg/dns" -) - -func TestLookupCache(t *testing.T) { - // Start auth. CoreDNS holding the auth zone. - name, rm, err := test.TempFile(".", exampleOrg) - if err != nil { - t.Fatalf("Failed to create zone: %s", err) - } - defer rm() - - corefile := `example.org:0 { - file ` + name + ` -} -` - i, udp, _, err := CoreDNSServerAndPorts(corefile) - if err != nil { - t.Fatalf("Could not get CoreDNS serving instance: %s", err) - } - defer i.Stop() - - // Start caching proxy CoreDNS that we want to test. - corefile = `example.org:0 { - proxy . ` + udp + ` - cache 10 -} -` - i, udp, _, err = CoreDNSServerAndPorts(corefile) - if err != nil { - t.Fatalf("Could not get CoreDNS serving instance: %s", err) - } - defer i.Stop() - - p := proxy.NewLookup([]string{udp}) - state := request.Request{W: &test.ResponseWriter{}, Req: new(dns.Msg)} - - resp, err := p.Lookup(state, "example.org.", dns.TypeA) - if err != nil { - t.Fatal("Expected to receive reply, but didn't") - } - // expect answer section with A record in it - if len(resp.Answer) == 0 { - t.Fatal("Expected to at least one RR in the answer section, got none") - } - - ttl := resp.Answer[0].Header().Ttl - if ttl != 10 { // as set in the Corefile - t.Errorf("Expected TTL to be %d, got %d", 10, ttl) - } -} diff --git a/vendor/github.com/coredns/coredns/test/chaos_test.go b/vendor/github.com/coredns/coredns/test/chaos_test.go deleted file mode 100644 index 991b6aa8..00000000 --- a/vendor/github.com/coredns/coredns/test/chaos_test.go +++ /dev/null @@ -1,42 +0,0 @@ -package test - -import ( - "io/ioutil" - "log" - "testing" - - // Plug in CoreDNS, needed for AppVersion and AppName in this test. - _ "github.com/coredns/coredns/coremain" - - "github.com/mholt/caddy" - "github.com/miekg/dns" -) - -func TestChaos(t *testing.T) { - corefile := `.:0 { - chaos -} -` - - i, udp, _, err := CoreDNSServerAndPorts(corefile) - if err != nil { - t.Fatalf("Could not get CoreDNS serving instance: %s", err) - } - defer i.Stop() - - log.SetOutput(ioutil.Discard) - - m := new(dns.Msg) - m.SetQuestion("version.bind.", dns.TypeTXT) - m.Question[0].Qclass = dns.ClassCHAOS - - resp, err := dns.Exchange(m, udp) - if err != nil { - t.Fatalf("Expected to receive reply, but didn't: %v", err) - } - chTxt := resp.Answer[0].(*dns.TXT).Txt[0] - version := caddy.AppName + "-" + caddy.AppVersion - if chTxt != version { - t.Fatalf("Expected version to bo %s, got %s", version, chTxt) - } -} diff --git a/vendor/github.com/coredns/coredns/test/doc.go b/vendor/github.com/coredns/coredns/test/doc.go deleted file mode 100644 index ba09e877..00000000 --- a/vendor/github.com/coredns/coredns/test/doc.go +++ /dev/null @@ -1,2 +0,0 @@ -// Package test contains function and types useful for writing tests -package test diff --git a/vendor/github.com/coredns/coredns/test/ds_file_test.go b/vendor/github.com/coredns/coredns/test/ds_file_test.go deleted file mode 100644 index 356fd2b0..00000000 --- a/vendor/github.com/coredns/coredns/test/ds_file_test.go +++ /dev/null @@ -1,65 +0,0 @@ -package test - -import ( - "io/ioutil" - "log" - "testing" - - "github.com/coredns/coredns/plugin/proxy" - mtest "github.com/coredns/coredns/plugin/test" - "github.com/coredns/coredns/request" - - "github.com/miekg/dns" -) - -// Using miek.nl here because this is the easiest zone to get access to and it's masters -// run both NSD and BIND9, making checks like "what should we actually return" super easy. -var dsTestCases = []mtest.Case{ - { - Qname: "_udp.miek.nl.", Qtype: dns.TypeDS, - Rcode: dns.RcodeNameError, - Ns: []dns.RR{ - mtest.SOA("miek.nl. 1800 IN SOA linode.atoom.net. miek.miek.nl. 1282630057 14400 3600 604800 14400"), - }, - }, - { - Qname: "miek.nl.", Qtype: dns.TypeDS, - Ns: []dns.RR{ - mtest.SOA("miek.nl. 1800 IN SOA linode.atoom.net. miek.miek.nl. 1282630057 14400 3600 604800 14400"), - }, - }, -} - -func TestLookupDS(t *testing.T) { - t.Parallel() - name, rm, err := TempFile(".", miekNL) - if err != nil { - t.Fatalf("Failed to create zone: %s", err) - } - defer rm() - - corefile := `miek.nl:0 { - file ` + name + ` -} -` - - i, udp, _, err := CoreDNSServerAndPorts(corefile) - if err != nil { - t.Fatalf("Could not get CoreDNS serving instance: %s", err) - } - defer i.Stop() - - log.SetOutput(ioutil.Discard) - - p := proxy.NewLookup([]string{udp}) - state := request.Request{W: &mtest.ResponseWriter{}, Req: new(dns.Msg)} - - for _, tc := range dsTestCases { - resp, err := p.Lookup(state, tc.Qname, tc.Qtype) - if err != nil || resp == nil { - t.Fatalf("Expected to receive reply, but didn't for %s %d", tc.Qname, tc.Qtype) - } - - mtest.SortAndCheck(t, resp, tc) - } -} diff --git a/vendor/github.com/coredns/coredns/test/erratic_autopath_test.go b/vendor/github.com/coredns/coredns/test/erratic_autopath_test.go deleted file mode 100644 index 215928b0..00000000 --- a/vendor/github.com/coredns/coredns/test/erratic_autopath_test.go +++ /dev/null @@ -1,80 +0,0 @@ -package test - -import ( - "testing" - - "github.com/miekg/dns" -) - -func TestLookupAutoPathErratic(t *testing.T) { - corefile := `.:0 { - erratic - autopath @erratic - proxy . 8.8.8.8:53 - debug - } -` - i, udp, _, err := CoreDNSServerAndPorts(corefile) - if err != nil { - t.Fatalf("Could not get CoreDNS serving instance: %s", err) - } - defer i.Stop() - - tests := []struct { - qname string - expectedAnswer string - expectedType uint16 - }{ - {"google.com.a.example.org.", "google.com.a.example.org.", dns.TypeCNAME}, - {"google.com.", "google.com.", dns.TypeA}, - } - - for i, tc := range tests { - m := new(dns.Msg) - // erratic always returns this search path: "a.example.org.", "b.example.org.", "". - m.SetQuestion(tc.qname, dns.TypeA) - - r, err := dns.Exchange(m, udp) - if err != nil { - t.Fatalf("Test %d, failed to sent query: %q", i, err) - } - if len(r.Answer) == 0 { - t.Fatalf("Test %d, answer section should have RRs", i) - } - if x := r.Answer[0].Header().Name; x != tc.expectedAnswer { - t.Fatalf("Test %d, expected answer %s, got %s", i, tc.expectedAnswer, x) - } - if x := r.Answer[0].Header().Rrtype; x != tc.expectedType { - t.Fatalf("Test %d, expected answer type %d, got %d", i, tc.expectedType, x) - } - } -} - -func TestAutoPathErraticNotLoaded(t *testing.T) { - corefile := `.:0 { - autopath @erratic - proxy . 8.8.8.8:53 - debug - } -` - i, err := CoreDNSServer(corefile) - if err != nil { - t.Fatalf("Could not get CoreDNS serving instance: %s", err) - } - - udp, _ := CoreDNSServerPorts(i, 0) - if udp == "" { - t.Fatalf("Could not get UDP listening port") - } - defer i.Stop() - - m := new(dns.Msg) - m.SetQuestion("google.com.a.example.org.", dns.TypeA) - r, err := dns.Exchange(m, udp) - if err != nil { - t.Fatalf("Failed to sent query: %q", err) - } - if r.Rcode != dns.RcodeNameError { - t.Fatalf("Expected NXDOMAIN, got %d", r.Rcode) - } -} diff --git a/vendor/github.com/coredns/coredns/test/etcd_cache_test.go b/vendor/github.com/coredns/coredns/test/etcd_cache_test.go deleted file mode 100644 index a0be86dc..00000000 --- a/vendor/github.com/coredns/coredns/test/etcd_cache_test.go +++ /dev/null @@ -1,77 +0,0 @@ -// +build etcd - -package test - -import ( - "context" - "io/ioutil" - "log" - "testing" - - "github.com/coredns/coredns/plugin/etcd/msg" - "github.com/coredns/coredns/plugin/proxy" - "github.com/coredns/coredns/plugin/test" - "github.com/coredns/coredns/request" - - "github.com/miekg/dns" -) - -// uses some stuff from etcd_tests.go - -func TestEtcdCache(t *testing.T) { - corefile := `.:0 { - etcd skydns.test { - path /skydns - } - cache skydns.test -}` - - ex, udp, _, err := CoreDNSServerAndPorts(corefile) - if err != nil { - t.Fatalf("Could not get CoreDNS serving instance: %s", err) - } - defer ex.Stop() - - etc := etcdPlugin() - log.SetOutput(ioutil.Discard) - - var ctx = context.TODO() - for _, serv := range servicesCacheTest { - set(ctx, t, etc, serv.Key, 0, serv) - defer delete(ctx, t, etc, serv.Key) - } - - p := proxy.NewLookup([]string{udp}) - state := request.Request{W: &test.ResponseWriter{}, Req: new(dns.Msg)} - - resp, err := p.Lookup(state, "b.example.skydns.test.", dns.TypeA) - if err != nil { - t.Errorf("Expected to receive reply, but didn't: %s", err) - } - checkResponse(t, resp) - - resp, err = p.Lookup(state, "b.example.skydns.test.", dns.TypeA) - if err != nil { - t.Errorf("Expected to receive reply, but didn't: %s", err) - } - checkResponse(t, resp) - if len(resp.Extra) != 0 { - t.Errorf("Expected no RRs in additional section, got: %d", len(resp.Extra)) - } -} - -func checkResponse(t *testing.T, resp *dns.Msg) { - if len(resp.Answer) == 0 { - t.Fatal("Expected to at least one RR in the answer section, got none") - } - if resp.Answer[0].Header().Rrtype != dns.TypeA { - t.Errorf("Expected RR to A, got: %d", resp.Answer[0].Header().Rrtype) - } - if resp.Answer[0].(*dns.A).A.String() != "127.0.0.1" { - t.Errorf("Expected 127.0.0.1, got: %s", resp.Answer[0].(*dns.A).A.String()) - } -} - -var servicesCacheTest = []*msg.Service{ - {Host: "127.0.0.1", Port: 666, Key: "b.example.skydns.test."}, -} diff --git a/vendor/github.com/coredns/coredns/test/etcd_test.go b/vendor/github.com/coredns/coredns/test/etcd_test.go deleted file mode 100644 index da9992a0..00000000 --- a/vendor/github.com/coredns/coredns/test/etcd_test.go +++ /dev/null @@ -1,104 +0,0 @@ -// +build etcd - -package test - -import ( - "context" - "encoding/json" - "io/ioutil" - "log" - "testing" - "time" - - "github.com/coredns/coredns/plugin/etcd" - "github.com/coredns/coredns/plugin/etcd/msg" - "github.com/coredns/coredns/plugin/proxy" - "github.com/coredns/coredns/plugin/test" - "github.com/coredns/coredns/request" - - etcdc "github.com/coreos/etcd/client" - "github.com/miekg/dns" -) - -func etcdPlugin() *etcd.Etcd { - etcdCfg := etcdc.Config{ - Endpoints: []string{"http://localhost:2379"}, - } - cli, _ := etcdc.New(etcdCfg) - client := etcdc.NewKeysAPI(cli) - return &etcd.Etcd{Client: client, PathPrefix: "/skydns"} -} - -// This test starts two coredns servers (and needs etcd). Configure a stubzones in both (that will loop) and -// will then test if we detect this loop. -func TestEtcdStubLoop(t *testing.T) { - // TODO(miek) -} - -func TestEtcdStubAndProxyLookup(t *testing.T) { - corefile := `.:0 { - etcd skydns.local { - stubzones - path /skydns - endpoint http://localhost:2379 - upstream 8.8.8.8:53 8.8.4.4:53 - fallthrough - } - proxy . 8.8.8.8:53 -}` - - ex, udp, _, err := CoreDNSServerAndPorts(corefile) - if err != nil { - t.Fatalf("Could not get CoreDNS serving instance: %s", err) - } - defer ex.Stop() - - etc := etcdPlugin() - log.SetOutput(ioutil.Discard) - - var ctx = context.TODO() - for _, serv := range servicesStub { // adds example.{net,org} as stubs - set(ctx, t, etc, serv.Key, 0, serv) - defer delete(ctx, t, etc, serv.Key) - } - - p := proxy.NewLookup([]string{udp}) // use udp port from the server - state := request.Request{W: &test.ResponseWriter{}, Req: new(dns.Msg)} - resp, err := p.Lookup(state, "example.com.", dns.TypeA) - if err != nil { - t.Fatalf("Expected to receive reply, but didn't: %v", err) - } - if len(resp.Answer) == 0 { - t.Fatalf("Expected to at least one RR in the answer section, got none") - } - if resp.Answer[0].Header().Rrtype != dns.TypeA { - t.Errorf("Expected RR to A, got: %d", resp.Answer[0].Header().Rrtype) - } - if resp.Answer[0].(*dns.A).A.String() != "93.184.216.34" { - t.Errorf("Expected 93.184.216.34, got: %s", resp.Answer[0].(*dns.A).A.String()) - } -} - -var servicesStub = []*msg.Service{ - // Two tests, ask a question that should return servfail because remote it no accessible - // and one with edns0 option added, that should return refused. - {Host: "127.0.0.1", Port: 666, Key: "b.example.org.stub.dns.skydns.test."}, - // Actual test that goes out to the internet. - {Host: "199.43.132.53", Key: "a.example.net.stub.dns.skydns.test."}, -} - -// Copied from plugin/etcd/setup_test.go -func set(ctx context.Context, t *testing.T, e *etcd.Etcd, k string, ttl time.Duration, m *msg.Service) { - b, err := json.Marshal(m) - if err != nil { - t.Fatal(err) - } - path, _ := msg.PathWithWildcard(k, e.PathPrefix) - e.Client.Set(ctx, path, string(b), &etcdc.SetOptions{TTL: ttl}) -} - -// Copied from plugin/etcd/setup_test.go -func delete(ctx context.Context, t *testing.T, e *etcd.Etcd, k string) { - path, _ := msg.PathWithWildcard(k, e.PathPrefix) - e.Client.Delete(ctx, path, &etcdc.DeleteOptions{Recursive: false}) -} diff --git a/vendor/github.com/coredns/coredns/test/example_test.go b/vendor/github.com/coredns/coredns/test/example_test.go deleted file mode 100644 index 39d4ec49..00000000 --- a/vendor/github.com/coredns/coredns/test/example_test.go +++ /dev/null @@ -1,15 +0,0 @@ -package test - -const exampleOrg = `; example.org test file -$TTL 3600 -example.org. IN SOA sns.dns.icann.org. noc.dns.icann.org. 2015082541 7200 3600 1209600 3600 -example.org. IN NS b.iana-servers.net. -example.org. IN NS a.iana-servers.net. -example.org. IN A 127.0.0.1 -example.org. IN A 127.0.0.2 -*.w.example.org. IN TXT "Wildcard" -a.b.c.w.example.org. IN TXT "Not a wildcard" -cname.example.org. IN CNAME www.example.net. - -service.example.org. IN SRV 8080 10 10 example.org. -` diff --git a/vendor/github.com/coredns/coredns/test/external_test.go b/vendor/github.com/coredns/coredns/test/external_test.go deleted file mode 100644 index f5737e17..00000000 --- a/vendor/github.com/coredns/coredns/test/external_test.go +++ /dev/null @@ -1,72 +0,0 @@ -package test - -import ( - "fmt" - "os" - "os/exec" - "strings" - "testing" -) - -// Go get external example plugin, compile it into CoreDNS -// and check if it is really there, but running coredns -plugins. - -// Dangerous test as it messes with your git tree, maybe use tag? -func testExternalPluginCompile(t *testing.T) { - if err := addExamplePlugin(); err != nil { - t.Fatal(err) - } - defer run(t, gitReset) - - if _, err := run(t, goGet); err != nil { - t.Fatal(err) - } - - if _, err := run(t, goGen); err != nil { - t.Fatal(err) - } - - if _, err := run(t, goBuild); err != nil { - t.Fatal(err) - } - - out, err := run(t, coredns) - if err != nil { - t.Fatal(err) - } - - if !strings.Contains(string(out), "dns.example") { - t.Fatal("Plugin dns.example should be there") - } -} - -func run(t *testing.T, c *exec.Cmd) ([]byte, error) { - c.Dir = ".." - out, err := c.Output() - if err != nil { - return nil, fmt.Errorf("Run: failed to run %s %s: %q", c.Args[0], c.Args[1], err) - } - return out, nil - -} - -func addExamplePlugin() error { - f, err := os.OpenFile("../plugin.cfg", os.O_APPEND|os.O_WRONLY, os.ModeAppend) - if err != nil { - return err - } - defer f.Close() - - _, err = f.WriteString(example) - return err -} - -var ( - goBuild = exec.Command("go", "build") - goGen = exec.Command("go", "generate") - goGet = exec.Command("go", "get", "github.com/coredns/example") - gitReset = exec.Command("git", "checkout", "core/*") - coredns = exec.Command("./coredns", "-plugins") -) - -const example = "1001:example:github.com/coredns/example" diff --git a/vendor/github.com/coredns/coredns/test/file.go b/vendor/github.com/coredns/coredns/test/file.go deleted file mode 100644 index 626224ca..00000000 --- a/vendor/github.com/coredns/coredns/test/file.go +++ /dev/null @@ -1,19 +0,0 @@ -package test - -import ( - "io/ioutil" - "os" -) - -// TempFile will create a temporary file on disk and returns the name and a cleanup function to remove it later. -func TempFile(dir, content string) (string, func(), error) { - f, err := ioutil.TempFile(dir, "go-test-tmpfile") - if err != nil { - return "", nil, err - } - if err := ioutil.WriteFile(f.Name(), []byte(content), 0644); err != nil { - return "", nil, err - } - rmFunc := func() { os.Remove(f.Name()) } - return f.Name(), rmFunc, nil -} diff --git a/vendor/github.com/coredns/coredns/test/file_cname_proxy_test.go b/vendor/github.com/coredns/coredns/test/file_cname_proxy_test.go deleted file mode 100644 index b0adcf20..00000000 --- a/vendor/github.com/coredns/coredns/test/file_cname_proxy_test.go +++ /dev/null @@ -1,84 +0,0 @@ -package test - -import ( - "io/ioutil" - "log" - "testing" - - "github.com/coredns/coredns/plugin/proxy" - "github.com/coredns/coredns/plugin/test" - "github.com/coredns/coredns/request" - - "github.com/miekg/dns" -) - -func TestZoneExternalCNAMELookupWithoutProxy(t *testing.T) { - t.Parallel() - log.SetOutput(ioutil.Discard) - - name, rm, err := TempFile(".", exampleOrg) - if err != nil { - t.Fatalf("Failed to create zone: %s", err) - } - defer rm() - - // Corefile with for example without proxy section. - corefile := `example.org:0 { - file ` + name + ` -} -` - i, udp, _, err := CoreDNSServerAndPorts(corefile) - if err != nil { - t.Fatalf("Could not get CoreDNS serving instance: %s", err) - } - defer i.Stop() - - p := proxy.NewLookup([]string{udp}) - state := request.Request{W: &test.ResponseWriter{}, Req: new(dns.Msg)} - - resp, err := p.Lookup(state, "cname.example.org.", dns.TypeA) - if err != nil { - t.Fatalf("Expected to receive reply, but didn't: %s", err) - } - // There should only be a CNAME in the answer section. - if len(resp.Answer) != 1 { - t.Fatalf("Expected 1 RR in answer section got %d", len(resp.Answer)) - } -} - -func TestZoneExternalCNAMELookupWithProxy(t *testing.T) { - t.Parallel() - log.SetOutput(ioutil.Discard) - - name, rm, err := TempFile(".", exampleOrg) - if err != nil { - t.Fatalf("Failed to create zone: %s", err) - } - defer rm() - - // Corefile with for example without proxy section. - corefile := `example.org:0 { - file ` + name + ` { - upstream 8.8.8.8 - } -} -` - i, udp, _, err := CoreDNSServerAndPorts(corefile) - if err != nil { - t.Fatalf("Could not get CoreDNS serving instance: %s", err) - } - defer i.Stop() - - p := proxy.NewLookup([]string{udp}) - state := request.Request{W: &test.ResponseWriter{}, Req: new(dns.Msg)} - - resp, err := p.Lookup(state, "cname.example.org.", dns.TypeA) - if err != nil { - t.Fatalf("Expected to receive reply, but didn't: %s", err) - } - // There should be a CNAME *and* an IP address in the answer section. - // For now, just check that we have 2 RRs - if len(resp.Answer) != 2 { - t.Fatalf("Expected 2 RRs in answer section got %d", len(resp.Answer)) - } -} diff --git a/vendor/github.com/coredns/coredns/test/file_reload_test.go b/vendor/github.com/coredns/coredns/test/file_reload_test.go deleted file mode 100644 index 01877f69..00000000 --- a/vendor/github.com/coredns/coredns/test/file_reload_test.go +++ /dev/null @@ -1,71 +0,0 @@ -package test - -import ( - "io/ioutil" - "testing" - "time" - - "github.com/coredns/coredns/plugin/file" - "github.com/coredns/coredns/plugin/proxy" - "github.com/coredns/coredns/plugin/test" - "github.com/coredns/coredns/request" - - "github.com/miekg/dns" -) - -func TestZoneReload(t *testing.T) { - file.TickTime = 1 * time.Second - - name, rm, err := TempFile(".", exampleOrg) - if err != nil { - t.Fatalf("Failed to create zone: %s", err) - } - defer rm() - - // Corefile with two stanzas - corefile := `example.org:0 { - file ` + name + ` -} - -example.net:0 { - file ` + name + ` -} -` - i, udp, _, err := CoreDNSServerAndPorts(corefile) - if err != nil { - t.Fatalf("Could not get CoreDNS serving instance: %s", err) - } - defer i.Stop() - - p := proxy.NewLookup([]string{udp}) - state := request.Request{W: &test.ResponseWriter{}, Req: new(dns.Msg)} - - resp, err := p.Lookup(state, "example.org.", dns.TypeA) - if err != nil { - t.Fatalf("Expected to receive reply, but didn't: %s", err) - } - if len(resp.Answer) != 2 { - t.Fatalf("Expected two RR in answer section got %d", len(resp.Answer)) - } - - // Remove RR from the Apex - ioutil.WriteFile(name, []byte(exampleOrgUpdated), 0644) - - time.Sleep(2 * time.Second) // reload time - - resp, err = p.Lookup(state, "example.org.", dns.TypeA) - if err != nil { - t.Fatal("Expected to receive reply, but didn't") - } - - if len(resp.Answer) != 1 { - t.Fatalf("Expected two RR in answer section got %d", len(resp.Answer)) - } -} - -const exampleOrgUpdated = `; example.org test file -example.org. IN SOA sns.dns.icann.org. noc.dns.icann.org. 2016082541 7200 3600 1209600 3600 -example.org. IN NS b.iana-servers.net. -example.org. IN NS a.iana-servers.net. -example.org. IN A 127.0.0.2 -` diff --git a/vendor/github.com/coredns/coredns/test/file_serve_test.go b/vendor/github.com/coredns/coredns/test/file_serve_test.go deleted file mode 100644 index 3aca45bf..00000000 --- a/vendor/github.com/coredns/coredns/test/file_serve_test.go +++ /dev/null @@ -1,102 +0,0 @@ -package test - -import ( - "io/ioutil" - "log" - "testing" - - "github.com/miekg/dns" -) - -func TestZoneEDNS0Lookup(t *testing.T) { - t.Parallel() - log.SetOutput(ioutil.Discard) - - name, rm, err := TempFile(".", `$ORIGIN example.org. -@ 3600 IN SOA sns.dns.icann.org. noc.dns.icann.org. ( - 2017042745 ; serial - 7200 ; refresh (2 hours) - 3600 ; retry (1 hour) - 1209600 ; expire (2 weeks) - 3600 ; minimum (1 hour) - ) - - 3600 IN NS a.iana-servers.net. - 3600 IN NS b.iana-servers.net. - -www IN A 127.0.0.1 -www IN AAAA ::1 -`) - if err != nil { - t.Fatalf("Failed to create zone: %s", err) - } - defer rm() - - // Corefile with for example without proxy section. - corefile := `example.org:0 { - file ` + name + ` -} -` - i, udp, _, err := CoreDNSServerAndPorts(corefile) - if err != nil { - t.Fatalf("Could not get CoreDNS serving instance: %s", err) - } - defer i.Stop() - - m := new(dns.Msg) - m.SetQuestion("example.org.", dns.TypeMX) - m.SetEdns0(4096, true) - - r, err := dns.Exchange(m, udp) - if err != nil { - t.Fatalf("Could not exchange msg: %s", err) - } - if r.Rcode == dns.RcodeServerFailure { - t.Fatalf("Rcode should not be dns.RcodeServerFailure") - } -} - -func TestZoneNoNS(t *testing.T) { - t.Parallel() - log.SetOutput(ioutil.Discard) - - name, rm, err := TempFile(".", `$ORIGIN example.org. -@ 3600 IN SOA sns.dns.icann.org. noc.dns.icann.org. ( - 2017042745 ; serial - 7200 ; refresh (2 hours) - 3600 ; retry (1 hour) - 1209600 ; expire (2 weeks) - 3600 ; minimum (1 hour) - ) - -www IN A 127.0.0.1 -www IN AAAA ::1 -`) - if err != nil { - t.Fatalf("Failed to create zone: %s", err) - } - defer rm() - - // Corefile with for example without proxy section. - corefile := `example.org:0 { - file ` + name + ` -} -` - i, udp, _, err := CoreDNSServerAndPorts(corefile) - if err != nil { - t.Fatalf("Could not get CoreDNS serving instance: %s", err) - } - defer i.Stop() - - m := new(dns.Msg) - m.SetQuestion("example.org.", dns.TypeMX) - m.SetEdns0(4096, true) - - r, err := dns.Exchange(m, udp) - if err != nil { - t.Fatalf("Could not exchange msg: %s", err) - } - if r.Rcode == dns.RcodeServerFailure { - t.Fatalf("Rcode should not be dns.RcodeServerFailure") - } -} diff --git a/vendor/github.com/coredns/coredns/test/file_srv_additional_test.go b/vendor/github.com/coredns/coredns/test/file_srv_additional_test.go deleted file mode 100644 index 26ae1f9a..00000000 --- a/vendor/github.com/coredns/coredns/test/file_srv_additional_test.go +++ /dev/null @@ -1,48 +0,0 @@ -package test - -import ( - "io/ioutil" - "log" - "testing" - - "github.com/coredns/coredns/plugin/proxy" - "github.com/coredns/coredns/plugin/test" - "github.com/coredns/coredns/request" - - "github.com/miekg/dns" -) - -func TestZoneSRVAdditional(t *testing.T) { - t.Parallel() - log.SetOutput(ioutil.Discard) - - name, rm, err := TempFile(".", exampleOrg) - if err != nil { - t.Fatalf("Failed to create zone: %s", err) - } - defer rm() - - // Corefile with for example without proxy section. - corefile := `example.org:0 { - file ` + name + ` -} -` - i, udp, _, err := CoreDNSServerAndPorts(corefile) - if err != nil { - t.Fatalf("Could not get CoreDNS serving instance: %s", err) - } - defer i.Stop() - - p := proxy.NewLookup([]string{udp}) - state := request.Request{W: &test.ResponseWriter{}, Req: new(dns.Msg)} - - resp, err := p.Lookup(state, "service.example.org.", dns.TypeSRV) - if err != nil { - t.Fatalf("Expected to receive reply, but didn't: %s", err) - } - - // There should be 2 A records in the additional section. - if len(resp.Extra) != 2 { - t.Fatalf("Expected 2 RR in additional section got %d", len(resp.Extra)) - } -} diff --git a/vendor/github.com/coredns/coredns/test/file_test.go b/vendor/github.com/coredns/coredns/test/file_test.go deleted file mode 100644 index 891e9d90..00000000 --- a/vendor/github.com/coredns/coredns/test/file_test.go +++ /dev/null @@ -1,12 +0,0 @@ -package test - -import "testing" - -func TestTempFile(t *testing.T) { - t.Parallel() - _, f, e := TempFile(".", "test") - if e != nil { - t.Fatalf("Failed to create temp file: %s", e) - } - defer f() -} diff --git a/vendor/github.com/coredns/coredns/test/file_upstream_test.go b/vendor/github.com/coredns/coredns/test/file_upstream_test.go deleted file mode 100644 index 36f2bbc5..00000000 --- a/vendor/github.com/coredns/coredns/test/file_upstream_test.go +++ /dev/null @@ -1,119 +0,0 @@ -package test - -import ( - "testing" - - "github.com/miekg/dns" -) - -func TestFileUpstream(t *testing.T) { - name, rm, err := TempFile(".", `$ORIGIN example.org. -@ 3600 IN SOA sns.dns.icann.org. noc.dns.icann.org. ( - 2017042745 ; serial - 7200 ; refresh (2 hours) - 3600 ; retry (1 hour) - 1209600 ; expire (2 weeks) - 3600 ; minimum (1 hour) - ) - - 3600 IN NS a.iana-servers.net. - 3600 IN NS b.iana-servers.net. - -www 3600 IN CNAME www.example.net. -`) - if err != nil { - t.Fatalf("Failed to create zone: %s", err) - } - defer rm() - - corefile := `.:0 { - file ` + name + ` example.org { - upstream - } - hosts { - 10.0.0.1 www.example.net. - fallthrough - } -} -` - i, udp, _, err := CoreDNSServerAndPorts(corefile) - if err != nil { - t.Fatalf("Could not get CoreDNS serving instance: %s", err) - } - defer i.Stop() - - m := new(dns.Msg) - m.SetQuestion("www.example.org.", dns.TypeA) - m.SetEdns0(4096, true) - - r, err := dns.Exchange(m, udp) - if err != nil { - t.Fatalf("Could not exchange msg: %s", err) - } - if r.Rcode == dns.RcodeServerFailure { - t.Fatalf("Rcode should not be dns.RcodeServerFailure") - } - if x := r.Answer[1].(*dns.A).A.String(); x != "10.0.0.1" { - t.Errorf("Failed to get address for CNAME, expected 10.0.0.1 got %s", x) - } -} - -// TestFileUpstreamAdditional runs two CoreDNS servers that serve example.org and foo.example.org. -// example.org contains a cname to foo.example.org; this should be resolved via upstream.Self. -func TestFileUpstreamAdditional(t *testing.T) { - name, rm, err := TempFile(".", `$ORIGIN example.org. -@ 3600 IN SOA sns.dns.icann.org. noc.dns.icann.org. 2017042745 7200 3600 1209600 3600 - - 3600 IN NS b.iana-servers.net. - -www 3600 IN CNAME www.foo -`) - if err != nil { - t.Fatalf("Failed to create zone: %s", err) - } - defer rm() - - name2, rm2, err2 := TempFile(".", `$ORIGIN foo.example.org. -@ 3600 IN SOA sns.dns.icann.org. noc.dns.icann.org. 2017042745 7200 3600 1209600 3600 - - 3600 IN NS b.iana-servers.net. - -www 3600 IN A 127.0.0.53 -`) - if err2 != nil { - t.Fatalf("Failed to create zone: %s", err2) - } - defer rm2() - - corefile := `.:0 { - file ` + name + ` example.org { - upstream - } - file ` + name2 + ` foo.example.org { - upstream - } -} -` - i, udp, _, err := CoreDNSServerAndPorts(corefile) - if err != nil { - t.Fatalf("Could not get CoreDNS serving instance: %s", err) - } - defer i.Stop() - - m := new(dns.Msg) - m.SetQuestion("www.example.org.", dns.TypeA) - - r, err := dns.Exchange(m, udp) - if err != nil { - t.Fatalf("Could not exchange msg: %s", err) - } - if r.Rcode == dns.RcodeServerFailure { - t.Fatalf("Rcode should not be dns.RcodeServerFailure") - } - if x := len(r.Answer); x != 2 { - t.Errorf("Expected 2 RR in reply, got %d", x) - } - if x := r.Answer[1].(*dns.A).A.String(); x != "127.0.0.53" { - t.Errorf("Failed to get address for CNAME, expected 127.0.0.53, got %s", x) - } -} diff --git a/vendor/github.com/coredns/coredns/test/grpc_test.go b/vendor/github.com/coredns/coredns/test/grpc_test.go deleted file mode 100644 index acbd822d..00000000 --- a/vendor/github.com/coredns/coredns/test/grpc_test.go +++ /dev/null @@ -1,59 +0,0 @@ -package test - -import ( - "context" - "io/ioutil" - "log" - "testing" - "time" - - "github.com/miekg/dns" - "google.golang.org/grpc" - - "github.com/coredns/coredns/pb" -) - -func TestGrpc(t *testing.T) { - log.SetOutput(ioutil.Discard) - - corefile := `grpc://.:0 { - whoami -} -` - g, _, tcp, err := CoreDNSServerAndPorts(corefile) - if err != nil { - t.Fatalf("Could not get CoreDNS serving instance: %s", err) - } - defer g.Stop() - - conn, err := grpc.Dial(tcp, grpc.WithInsecure(), grpc.WithBlock(), grpc.WithTimeout(5*time.Second)) - if err != nil { - t.Fatalf("Expected no error but got: %s", err) - } - defer conn.Close() - - client := pb.NewDnsServiceClient(conn) - - m := new(dns.Msg) - m.SetQuestion("whoami.example.org.", dns.TypeA) - msg, _ := m.Pack() - - reply, err := client.Query(context.TODO(), &pb.DnsPacket{Msg: msg}) - if err != nil { - t.Errorf("Expected no error but got: %s", err) - } - - d := new(dns.Msg) - err = d.Unpack(reply.Msg) - if err != nil { - t.Errorf("Expected no error but got: %s", err) - } - - if d.Rcode != dns.RcodeSuccess { - t.Errorf("Expected success but got %d", d.Rcode) - } - - if len(d.Extra) != 2 { - t.Errorf("Expected 2 RRs in additional section, but got %d", len(d.Extra)) - } -} diff --git a/vendor/github.com/coredns/coredns/test/hosts_file_test.go b/vendor/github.com/coredns/coredns/test/hosts_file_test.go deleted file mode 100644 index fa50233f..00000000 --- a/vendor/github.com/coredns/coredns/test/hosts_file_test.go +++ /dev/null @@ -1,48 +0,0 @@ -package test - -import ( - "io/ioutil" - "log" - "testing" - - "github.com/coredns/coredns/plugin/proxy" - "github.com/coredns/coredns/plugin/test" - "github.com/coredns/coredns/request" - - "github.com/miekg/dns" -) - -func TestHostsInlineLookup(t *testing.T) { - corefile := `example.org:0 { - hosts highly_unlikely_to_exist_hosts_file example.org { - 10.0.0.1 example.org - fallthrough - } - }` - - i, udp, _, err := CoreDNSServerAndPorts(corefile) - if err != nil { - t.Fatalf("Could not get CoreDNS serving instance: %s", err) - } - defer i.Stop() - - log.SetOutput(ioutil.Discard) - - p := proxy.NewLookup([]string{udp}) - state := request.Request{W: &test.ResponseWriter{}, Req: new(dns.Msg)} - - resp, err := p.Lookup(state, "example.org.", dns.TypeA) - if err != nil { - t.Fatal("Expected to receive reply, but didn't") - } - // expect answer section with A record in it - if len(resp.Answer) == 0 { - t.Fatal("Expected to at least one RR in the answer section, got none") - } - if resp.Answer[0].Header().Rrtype != dns.TypeA { - t.Errorf("Expected RR to A, got: %d", resp.Answer[0].Header().Rrtype) - } - if resp.Answer[0].(*dns.A).A.String() != "10.0.0.1" { - t.Errorf("Expected 10.0.0.1, got: %s", resp.Answer[0].(*dns.A).A.String()) - } -} diff --git a/vendor/github.com/coredns/coredns/test/metrics_test.go b/vendor/github.com/coredns/coredns/test/metrics_test.go deleted file mode 100644 index 4a1665c5..00000000 --- a/vendor/github.com/coredns/coredns/test/metrics_test.go +++ /dev/null @@ -1,187 +0,0 @@ -package test - -import ( - "io/ioutil" - "log" - "os" - "path" - "testing" - "time" - - "github.com/coredns/coredns/plugin/cache" - "github.com/coredns/coredns/plugin/metrics" - mtest "github.com/coredns/coredns/plugin/metrics/test" - "github.com/coredns/coredns/plugin/metrics/vars" - - "github.com/miekg/dns" -) - -// fail when done in parallel - -// Start test server that has metrics enabled. Then tear it down again. -func TestMetricsServer(t *testing.T) { - corefile := `example.org:0 { - chaos CoreDNS-001 miek@miek.nl - prometheus localhost:0 -} - -example.com:0 { - proxy . 8.8.4.4:53 - prometheus localhost:0 -} -` - srv, err := CoreDNSServer(corefile) - if err != nil { - t.Fatalf("Could not get CoreDNS serving instance: %s", err) - } - defer srv.Stop() -} - -func TestMetricsRefused(t *testing.T) { - metricName := "coredns_dns_response_rcode_count_total" - - corefile := `example.org:0 { - proxy . 8.8.8.8:53 - prometheus localhost:0 -} -` - srv, udp, _, err := CoreDNSServerAndPorts(corefile) - if err != nil { - t.Fatalf("Could not get CoreDNS serving instance: %s", err) - } - defer srv.Stop() - - m := new(dns.Msg) - m.SetQuestion("google.com.", dns.TypeA) - - if _, err = dns.Exchange(m, udp); err != nil { - t.Fatalf("Could not send message: %s", err) - } - - data := mtest.Scrape(t, "http://"+metrics.ListenAddr+"/metrics") - got, labels := mtest.MetricValue(metricName, data) - - if got != "1" { - t.Errorf("Expected value %s for refused, but got %s", "1", got) - } - if labels["zone"] != vars.Dropped { - t.Errorf("Expected zone value %s for refused, but got %s", vars.Dropped, labels["zone"]) - } - if labels["rcode"] != "REFUSED" { - t.Errorf("Expected zone value %s for refused, but got %s", "REFUSED", labels["rcode"]) - } -} - -// TODO(miek): disabled for now - fails in weird ways in travis. -func testMetricsCache(t *testing.T) { - cacheSizeMetricName := "coredns_cache_size" - cacheHitMetricName := "coredns_cache_hits_total" - - corefile := `www.example.net:0 { - proxy . 8.8.8.8:53 - prometheus localhost:0 - cache -} -` - srv, err := CoreDNSServer(corefile) - if err != nil { - t.Fatalf("Could not get CoreDNS serving instance: %s", err) - } - defer srv.Stop() - - udp, _ := CoreDNSServerPorts(srv, 0) - - m := new(dns.Msg) - m.SetQuestion("www.example.net.", dns.TypeA) - - if _, err = dns.Exchange(m, udp); err != nil { - t.Fatalf("Could not send message: %s", err) - } - - data := mtest.Scrape(t, "http://"+metrics.ListenAddr+"/metrics") - // Get the value for the cache size metric where the one of the labels values matches "success". - got, _ := mtest.MetricValueLabel(cacheSizeMetricName, cache.Success, data) - - if got != "1" { - t.Errorf("Expected value %s for %s, but got %s", "1", cacheSizeMetricName, got) - } - - // Second request for the same response to test hit counter. - if _, err = dns.Exchange(m, udp); err != nil { - t.Fatalf("Could not send message: %s", err) - } - - data = mtest.Scrape(t, "http://"+metrics.ListenAddr+"/metrics") - // Get the value for the cache hit counter where the one of the labels values matches "success". - got, _ = mtest.MetricValueLabel(cacheHitMetricName, cache.Success, data) - - if got != "2" { - t.Errorf("Expected value %s for %s, but got %s", "2", cacheHitMetricName, got) - } -} - -func TestMetricsAuto(t *testing.T) { - tmpdir, err := ioutil.TempDir(os.TempDir(), "coredns") - if err != nil { - t.Fatal(err) - } - - corefile := `org:0 { - auto { - directory ` + tmpdir + ` db\.(.*) {1} 1 - } - prometheus localhost:0 - } -` - - i, err := CoreDNSServer(corefile) - if err != nil { - t.Fatalf("Could not get CoreDNS serving instance: %s", err) - } - - udp, _ := CoreDNSServerPorts(i, 0) - if udp == "" { - t.Fatalf("Could not get UDP listening port") - } - defer i.Stop() - - log.SetOutput(ioutil.Discard) - - // Write db.example.org to get example.org. - if err = ioutil.WriteFile(path.Join(tmpdir, "db.example.org"), []byte(zoneContent), 0644); err != nil { - t.Fatal(err) - } - // TODO(miek): make the auto sleep even less. - time.Sleep(1100 * time.Millisecond) // wait for it to be picked up - - m := new(dns.Msg) - m.SetQuestion("www.example.org.", dns.TypeA) - - if _, err := dns.Exchange(m, udp); err != nil { - t.Fatalf("Could not send message: %s", err) - } - - metricName := "coredns_dns_request_count_total" //{zone, proto, family} - - data := mtest.Scrape(t, "http://"+metrics.ListenAddr+"/metrics") - // Get the value for the metrics where the one of the labels values matches "example.org." - got, _ := mtest.MetricValueLabel(metricName, "example.org.", data) - - if got != "1" { - t.Errorf("Expected value %s for %s, but got %s", "1", metricName, got) - } - - // Remove db.example.org again. And see if the metric stops increasing. - os.Remove(path.Join(tmpdir, "db.example.org")) - time.Sleep(1100 * time.Millisecond) // wait for it to be picked up - if _, err := dns.Exchange(m, udp); err != nil { - t.Fatalf("Could not send message: %s", err) - } - - data = mtest.Scrape(t, "http://"+metrics.ListenAddr+"/metrics") - got, _ = mtest.MetricValueLabel(metricName, "example.org.", data) - - if got != "1" { - t.Errorf("Expected value %s for %s, but got %s", "1", metricName, got) - } -} diff --git a/vendor/github.com/coredns/coredns/test/miek_test.go b/vendor/github.com/coredns/coredns/test/miek_test.go deleted file mode 100644 index 2778817a..00000000 --- a/vendor/github.com/coredns/coredns/test/miek_test.go +++ /dev/null @@ -1,31 +0,0 @@ -package test - -const miekNL = `; miek.nl test zone -$TTL 30M -$ORIGIN miek.nl. -@ IN SOA linode.atoom.net. miek.miek.nl. ( - 1282630059 ; Serial - 4H ; Refresh - 1H ; Retry - 7D ; Expire - 4H ) ; Negative Cache TTL - IN NS linode.atoom.net. - IN NS ns-ext.nlnetlabs.nl. - IN NS omval.tednet.nl. - IN NS ext.ns.whyscream.net. - - IN MX 1 aspmx.l.google.com. - IN MX 5 alt1.aspmx.l.google.com. - IN MX 5 alt2.aspmx.l.google.com. - IN MX 10 aspmx2.googlemail.com. - IN MX 10 aspmx3.googlemail.com. - - IN A 176.58.119.54 - IN AAAA 2a01:7e00::f03c:91ff:fe79:234c - IN HINFO "Please stop asking for ANY" "See draft-ietf-dnsop-refuse-any" - -a IN A 176.58.119.54 - IN AAAA 2a01:7e00::f03c:91ff:fe79:234c -www IN CNAME a -archive IN CNAME a -` diff --git a/vendor/github.com/coredns/coredns/test/plugin_dnssec_test.go b/vendor/github.com/coredns/coredns/test/plugin_dnssec_test.go deleted file mode 100644 index 3f8157b2..00000000 --- a/vendor/github.com/coredns/coredns/test/plugin_dnssec_test.go +++ /dev/null @@ -1,78 +0,0 @@ -package test - -import ( - "io/ioutil" - "log" - "os" - "testing" - - "github.com/coredns/coredns/plugin/test" - - "github.com/miekg/dns" -) - -func TestLookupBalanceRewriteCacheDnssec(t *testing.T) { - t.Parallel() - name, rm, err := test.TempFile(".", exampleOrg) - if err != nil { - t.Fatalf("Failed to create zone: %s", err) - } - defer rm() - rm1 := createKeyFile(t) - defer rm1() - - corefile := `example.org:0 { - file ` + name + ` - rewrite type ANY HINFO - dnssec { - key file ` + base + ` - } - loadbalance -} -` - ex, udp, _, err := CoreDNSServerAndPorts(corefile) - if err != nil { - t.Fatalf("Could not get CoreDNS serving instance: %s", err) - } - defer ex.Stop() - - log.SetOutput(ioutil.Discard) - c := new(dns.Client) - m := new(dns.Msg) - m.SetQuestion("example.org.", dns.TypeA) - m.SetEdns0(4096, true) - res, _, err := c.Exchange(m, udp) - if err != nil { - t.Fatalf("Could not send query: %s", err) - } - sig := 0 - for _, a := range res.Answer { - if a.Header().Rrtype == dns.TypeRRSIG { - sig++ - } - } - if sig == 0 { - t.Errorf("Expected RRSIGs, got none") - t.Logf("%v\n", res) - } -} - -func createKeyFile(t *testing.T) func() { - ioutil.WriteFile(base+".key", - []byte(`example.org. IN DNSKEY 256 3 13 tDyI0uEIDO4SjhTJh1AVTFBLpKhY3He5BdAlKztewiZ7GecWj94DOodg ovpN73+oJs+UfZ+p9zOSN5usGAlHrw==`), - 0644) - ioutil.WriteFile(base+".private", - []byte(`Private-key-format: v1.3 -Algorithm: 13 (ECDSAP256SHA256) -PrivateKey: HPmldSNfrkj/aDdUMFwuk/lgzaC5KIsVEG3uoYvF4pQ= -Created: 20160426083115 -Publish: 20160426083115 -Activate: 20160426083115`), - 0644) - return func() { - os.Remove(base + ".key") - os.Remove(base + ".private") - } -} - -const base = "Kexample.org.+013+44563" diff --git a/vendor/github.com/coredns/coredns/test/plugin_test.go b/vendor/github.com/coredns/coredns/test/plugin_test.go deleted file mode 100644 index cf1680d7..00000000 --- a/vendor/github.com/coredns/coredns/test/plugin_test.go +++ /dev/null @@ -1,46 +0,0 @@ -package test - -import ( - "io/ioutil" - "log" - "testing" - - "github.com/coredns/coredns/plugin/test" - - "github.com/miekg/dns" - - // Load all managed plugins in github.com/coredns/coredns - _ "github.com/coredns/coredns/core/plugin" -) - -func benchmarkLookupBalanceRewriteCache(b *testing.B) { - t := new(testing.T) - name, rm, err := test.TempFile(".", exampleOrg) - if err != nil { - t.Fatalf("Failed to create zone: %s", err) - } - defer rm() - - corefile := `example.org:0 { - file ` + name + ` - rewrite type ANY HINFO - loadbalance -} -` - - ex, udp, _, err := CoreDNSServerAndPorts(corefile) - if err != nil { - t.Fatalf("Could not get CoreDNS serving instance: %s", err) - } - defer ex.Stop() - - log.SetOutput(ioutil.Discard) - c := new(dns.Client) - m := new(dns.Msg) - m.SetQuestion("example.org.", dns.TypeA) - - b.ResetTimer() - for i := 0; i < b.N; i++ { - c.Exchange(m, udp) - } -} diff --git a/vendor/github.com/coredns/coredns/test/proxy_health_test.go b/vendor/github.com/coredns/coredns/test/proxy_health_test.go deleted file mode 100644 index 8d7c229b..00000000 --- a/vendor/github.com/coredns/coredns/test/proxy_health_test.go +++ /dev/null @@ -1,111 +0,0 @@ -package test - -import ( - "io/ioutil" - "log" - "testing" - - "github.com/coredns/coredns/plugin/proxy" - "github.com/coredns/coredns/plugin/test" - "github.com/coredns/coredns/request" - - "github.com/miekg/dns" -) - -func TestProxyErratic(t *testing.T) { - log.SetOutput(ioutil.Discard) - - corefile := `example.org:0 { - erratic { - drop 2 - } - } -` - - backend, udp, _, err := CoreDNSServerAndPorts(corefile) - if err != nil { - t.Fatalf("Could not get CoreDNS serving instance: %s", err) - } - defer backend.Stop() - - p := proxy.NewLookup([]string{udp}) - state := request.Request{W: &test.ResponseWriter{}, Req: new(dns.Msg)} - - // We do one lookup that should not time out. - // After this the backend is marked unhealthy anyway. So basically this - // tests that it times out. - p.Lookup(state, "example.org.", dns.TypeA) -} - -func TestProxyThreeWay(t *testing.T) { - // Run 3 CoreDNS server, 2 upstream ones and a proxy. 1 Upstream is unhealthy after 1 query, but after - // that we should still be able to send to the other one - log.SetOutput(ioutil.Discard) - - // Backend CoreDNS's. - corefileUp1 := `example.org:0 { - erratic { - drop 2 - } - } -` - - up1, err := CoreDNSServer(corefileUp1) - if err != nil { - t.Fatalf("Could not get CoreDNS serving instance: %s", err) - } - defer up1.Stop() - - corefileUp2 := `example.org:0 { - whoami - } -` - - up2, err := CoreDNSServer(corefileUp2) - if err != nil { - t.Fatalf("Could not get CoreDNS serving instance: %s", err) - } - defer up2.Stop() - - addr1, _ := CoreDNSServerPorts(up1, 0) - if addr1 == "" { - t.Fatalf("Could not get UDP listening port") - } - addr2, _ := CoreDNSServerPorts(up2, 0) - if addr2 == "" { - t.Fatalf("Could not get UDP listening port") - } - - // Proxying CoreDNS. - corefileProxy := `example.org:0 { - proxy . ` + addr1 + " " + addr2 + ` { - max_fails 1 - } - }` - - prx, err := CoreDNSServer(corefileProxy) - if err != nil { - t.Fatalf("Could not get CoreDNS serving instance: %s", err) - } - defer prx.Stop() - addr, _ := CoreDNSServerPorts(prx, 0) - if addr == "" { - t.Fatalf("Could not get UDP listening port") - } - - m := new(dns.Msg) - m.SetQuestion("example.org.", dns.TypeA) - - for i := 0; i < 10; i++ { - r, err := dns.Exchange(m, addr) - if err != nil { - continue - } - // We would previously get SERVFAIL, so just getting answers here - // is a good sign. The actuall timeouts are handled in the err != nil case - // above. - if r.Rcode != dns.RcodeSuccess { - t.Fatalf("Expected success rcode, got %d", r.Rcode) - } - } -} diff --git a/vendor/github.com/coredns/coredns/test/proxy_http_health_test.go b/vendor/github.com/coredns/coredns/test/proxy_http_health_test.go deleted file mode 100644 index 8ea77886..00000000 --- a/vendor/github.com/coredns/coredns/test/proxy_http_health_test.go +++ /dev/null @@ -1,90 +0,0 @@ -package test - -import ( - "io" - "io/ioutil" - "log" - "net" - "net/http" - "net/http/httptest" - "net/url" - "testing" - - "github.com/coredns/coredns/plugin/proxy" - "github.com/coredns/coredns/plugin/test" - "github.com/coredns/coredns/request" - "github.com/miekg/dns" -) - -func TestProxyWithHTTPCheckOK(t *testing.T) { - log.SetOutput(ioutil.Discard) - - healthCheckServer := httptest.NewServer(http.HandlerFunc( - func(w http.ResponseWriter, r *http.Request) { - w.WriteHeader(http.StatusOK) - io.WriteString(w, "OK\n") - })) - defer healthCheckServer.Close() - - healthCheckURL, err := url.Parse(healthCheckServer.URL) - if err != nil { - t.Fatal(err) - } - // TODO: use URL.Port() (Go 1.8+) once we've deprecated Go 1.7 support - var healthCheckPort string - if _, healthCheckPort, err = net.SplitHostPort(healthCheckURL.Host); err != nil { - healthCheckPort = "80" - } - - name, rm, err := test.TempFile(".", exampleOrg) - if err != nil { - t.Fatalf("Failed to create zone: %s", err) - } - defer rm() - - // We have to bind to 127.0.0.1 because the server started by - // httptest.NewServer does, and the IP addresses of the backend - // DNS and HTTP servers must match. - authoritativeCorefile := `example.org:0 { - bind 127.0.0.1 - file ` + name + ` -} -` - - authoritativeInstance, authoritativeAddr, _, err := CoreDNSServerAndPorts(authoritativeCorefile) - if err != nil { - t.Fatalf("Could not get CoreDNS authoritative instance: %s", err) - } - defer authoritativeInstance.Stop() - - proxyCorefile := `example.org:0 { - proxy . ` + authoritativeAddr + ` { - health_check /health:` + healthCheckPort + ` 1s - - } -} -` - - proxyInstance, proxyAddr, _, err := CoreDNSServerAndPorts(proxyCorefile) - if err != nil { - t.Fatalf("Could not get CoreDNS proxy instance: %s", err) - } - defer proxyInstance.Stop() - - p := proxy.NewLookup([]string{proxyAddr}) - state := request.Request{W: &test.ResponseWriter{}, Req: new(dns.Msg)} - resp, err := p.Lookup(state, "example.org.", dns.TypeA) - if err != nil { - t.Fatal("Expected to receive reply, but didn't") - } - // expect answer section with A record in it - if len(resp.Answer) == 0 { - t.Fatalf("Expected to at least one RR in the answer section, got none: %s", resp) - } - if resp.Answer[0].Header().Rrtype != dns.TypeA { - t.Errorf("Expected RR to A, got: %d", resp.Answer[0].Header().Rrtype) - } - if resp.Answer[0].(*dns.A).A.String() != "127.0.0.1" { - t.Errorf("Expected 127.0.0.1, got: %s", resp.Answer[0].(*dns.A).A.String()) - } -} diff --git a/vendor/github.com/coredns/coredns/test/proxy_test.go b/vendor/github.com/coredns/coredns/test/proxy_test.go deleted file mode 100644 index d25ace68..00000000 --- a/vendor/github.com/coredns/coredns/test/proxy_test.go +++ /dev/null @@ -1,129 +0,0 @@ -package test - -import ( - "io/ioutil" - "log" - "testing" - - "github.com/coredns/coredns/plugin/proxy" - "github.com/coredns/coredns/plugin/test" - "github.com/coredns/coredns/request" - - "github.com/miekg/dns" -) - -func TestLookupProxy(t *testing.T) { - t.Parallel() - name, rm, err := test.TempFile(".", exampleOrg) - if err != nil { - t.Fatalf("Failed to create zone: %s", err) - } - defer rm() - - corefile := `example.org:0 { - file ` + name + ` -} -` - - i, udp, _, err := CoreDNSServerAndPorts(corefile) - if err != nil { - t.Fatalf("Could not get CoreDNS serving instance: %s", err) - } - defer i.Stop() - - log.SetOutput(ioutil.Discard) - - p := proxy.NewLookup([]string{udp}) - state := request.Request{W: &test.ResponseWriter{}, Req: new(dns.Msg)} - resp, err := p.Lookup(state, "example.org.", dns.TypeA) - if err != nil { - t.Fatal("Expected to receive reply, but didn't") - } - // expect answer section with A record in it - if len(resp.Answer) == 0 { - t.Fatalf("Expected to at least one RR in the answer section, got none: %s", resp) - } - if resp.Answer[0].Header().Rrtype != dns.TypeA { - t.Errorf("Expected RR to A, got: %d", resp.Answer[0].Header().Rrtype) - } - if resp.Answer[0].(*dns.A).A.String() != "127.0.0.1" { - t.Errorf("Expected 127.0.0.1, got: %s", resp.Answer[0].(*dns.A).A.String()) - } -} - -func TestLookupDnsWithForcedTcp(t *testing.T) { - t.Parallel() - name, rm, err := test.TempFile(".", exampleOrg) - if err != nil { - t.Fatalf("Failed to create zone: %s", err) - } - defer rm() - - corefile := `example.org:0 { - file ` + name + ` -} -` - - i, _, tcp, err := CoreDNSServerAndPorts(corefile) - if err != nil { - t.Fatalf("Could not get CoreDNS serving instance: %s", err) - } - defer i.Stop() - - log.SetOutput(ioutil.Discard) - - p := proxy.NewLookupWithOption([]string{tcp}, proxy.Options{ForceTCP: true}) - state := request.Request{W: &test.ResponseWriter{}, Req: new(dns.Msg)} - resp, err := p.Lookup(state, "example.org.", dns.TypeA) - if err != nil { - t.Fatal("Expected to receive reply, but didn't") - } - // expect answer section with A record in it - if len(resp.Answer) == 0 { - t.Fatalf("Expected to at least one RR in the answer section, got none: %s", resp) - } - if resp.Answer[0].Header().Rrtype != dns.TypeA { - t.Errorf("Expected RR to A, got: %d", resp.Answer[0].Header().Rrtype) - } - if resp.Answer[0].(*dns.A).A.String() != "127.0.0.1" { - t.Errorf("Expected 127.0.0.1, got: %s", resp.Answer[0].(*dns.A).A.String()) - } -} - -func BenchmarkProxyLookup(b *testing.B) { - t := new(testing.T) - name, rm, err := test.TempFile(".", exampleOrg) - if err != nil { - t.Fatalf("Failed to created zone: %s", err) - } - defer rm() - - corefile := `example.org:0 { - file ` + name + ` -} -` - - i, err := CoreDNSServer(corefile) - if err != nil { - t.Fatalf("Could not get CoreDNS serving instance: %s", err) - } - - udp, _ := CoreDNSServerPorts(i, 0) - if udp == "" { - t.Fatalf("Could not get udp listening port") - } - defer i.Stop() - - log.SetOutput(ioutil.Discard) - - p := proxy.NewLookup([]string{udp}) - state := request.Request{W: &test.ResponseWriter{}, Req: new(dns.Msg)} - - b.ResetTimer() - for i := 0; i < b.N; i++ { - _, err := p.Lookup(state, "example.org.", dns.TypeA) - if err != nil { - b.Fatal("Expected to receive reply, but didn't") - } - } -} diff --git a/vendor/github.com/coredns/coredns/test/readme_test.go b/vendor/github.com/coredns/coredns/test/readme_test.go deleted file mode 100644 index f8ae0e34..00000000 --- a/vendor/github.com/coredns/coredns/test/readme_test.go +++ /dev/null @@ -1,134 +0,0 @@ -package test - -import ( - "bufio" - "io/ioutil" - "log" - "os" - "path/filepath" - "strconv" - "testing" - - "github.com/coredns/coredns/core/dnsserver" - - "github.com/mholt/caddy" -) - -// As we use the filesystem as-is, these files need to exist ON DISK for the readme test to work. This is especially -// useful for the *file* and *dnssec* plugins as their Corefiles are now tested as well. We create files in the -// current dir for all these, meaning the example READMEs MUST use relative path in their READMEs. -var contents = map[string]string{ - "Kexample.org.+013+45330.key": examplePub, - "Kexample.org.+013+45330.private": examplePriv, - "example.org.signed": exampleOrg, // not signed, but does not matter for this test. -} - -const ( - examplePub = `example.org. IN DNSKEY 256 3 13 eNMYFZYb6e0oJOV47IPo5f/UHy7wY9aBebotvcKakIYLyyGscBmXJQhbKLt/LhrMNDE2Q96hQnI5PdTBeOLzhQ== -` - examplePriv = `Private-key-format: v1.3 -Algorithm: 13 (ECDSAP256SHA256) -PrivateKey: f03VplaIEA+KHI9uizlemUSbUJH86hPBPjmcUninPoM= -` -) - -// TestReadme parses all README.mds of the plugins and checks if every example Corefile -// actually works. Each corefile snippet is only used if the language is set to 'corefile': -// -// ~~~ corefile -// . { -// # check-this-please -// } -// ~~~ -func TestReadme(t *testing.T) { - port := 30053 - caddy.Quiet = true - dnsserver.Quiet = true - - create(contents) - defer remove(contents) - - log.SetOutput(ioutil.Discard) - - middle := filepath.Join("..", "plugin") - dirs, err := ioutil.ReadDir(middle) - if err != nil { - t.Fatalf("Could not read %s: %q", middle, err) - } - for _, d := range dirs { - if !d.IsDir() { - continue - } - readme := filepath.Join(middle, d.Name()) - readme = filepath.Join(readme, "README.md") - - inputs, err := corefileFromReadme(readme) - if err != nil { - continue - } - - // Test each snippet. - for _, in := range inputs { - dnsserver.Port = strconv.Itoa(port) - server, err := caddy.Start(in) - if err != nil { - t.Errorf("Failed to start server with %s, for input %q:\n%s", readme, err, in.Body()) - } - server.Stop() - port++ - } - } -} - -// corefileFromReadme parses a readme and returns all fragments that -// have ~~~ corefile (or ``` corefile). -func corefileFromReadme(readme string) ([]*Input, error) { - f, err := os.Open(readme) - if err != nil { - return nil, err - } - defer f.Close() - - s := bufio.NewScanner(f) - input := []*Input{} - corefile := false - temp := "" - - for s.Scan() { - line := s.Text() - if line == "~~~ corefile" || line == "``` corefile" { - corefile = true - continue - } - - if corefile && (line == "~~~" || line == "```") { - // last line - input = append(input, NewInput(temp)) - - temp = "" - corefile = false - continue - } - - if corefile { - temp += line + "\n" // readd newline stripped by s.Text() - } - } - - if err := s.Err(); err != nil { - return nil, err - } - return input, nil -} - -func create(c map[string]string) { - for name, content := range c { - ioutil.WriteFile(name, []byte(content), 0644) - } -} - -func remove(c map[string]string) { - for name := range c { - os.Remove(name) - } -} diff --git a/vendor/github.com/coredns/coredns/test/reload_test.go b/vendor/github.com/coredns/coredns/test/reload_test.go deleted file mode 100644 index 18639ff0..00000000 --- a/vendor/github.com/coredns/coredns/test/reload_test.go +++ /dev/null @@ -1,128 +0,0 @@ -package test - -import ( - "bytes" - "io/ioutil" - "net/http" - "strings" - "testing" - "time" - - "github.com/miekg/dns" -) - -func TestReload(t *testing.T) { - corefile := `.:0 { - whoami -} -` - coreInput := NewInput(corefile) - - c, err := CoreDNSServer(corefile) - if err != nil { - t.Fatalf("Could not get CoreDNS serving instance: %s", err) - } - - udp, _ := CoreDNSServerPorts(c, 0) - - send(t, udp) - - c1, err := c.Restart(coreInput) - if err != nil { - t.Fatal(err) - } - udp, _ = CoreDNSServerPorts(c1, 0) - - send(t, udp) - - c1.Stop() -} - -func send(t *testing.T, server string) { - m := new(dns.Msg) - m.SetQuestion("whoami.example.org.", dns.TypeSRV) - - r, err := dns.Exchange(m, server) - if err != nil { - // This seems to fail a lot on travis, quick'n dirty: redo - r, err = dns.Exchange(m, server) - if err != nil { - return - } - } - if r.Rcode != dns.RcodeSuccess { - t.Fatalf("Expected successful reply, got %s", dns.RcodeToString[r.Rcode]) - } - if len(r.Extra) != 2 { - t.Fatalf("Expected 2 RRs in additional, got %d", len(r.Extra)) - } -} - -func TestReloadHealth(t *testing.T) { - corefile := ` -.:0 { - health 127.0.0.1:52182 - whoami -}` - c, err := CoreDNSServer(corefile) - if err != nil { - if strings.Contains(err.Error(), inUse) { - return // meh, but don't error - } - t.Fatalf("Could not get service instance: %s", err) - } - - if c1, err := c.Restart(NewInput(corefile)); err != nil { - t.Fatal(err) - } else { - c1.Stop() - } -} - -func TestReloadMetricsHealth(t *testing.T) { - corefile := ` -.:0 { - prometheus 127.0.0.1:53183 - health 127.0.0.1:53184 - whoami -}` - c, err := CoreDNSServer(corefile) - if err != nil { - if strings.Contains(err.Error(), inUse) { - return // meh, but don't error - } - t.Fatalf("Could not get service instance: %s", err) - } - - c1, err := c.Restart(NewInput(corefile)) - if err != nil { - t.Fatal(err) - } - defer c1.Stop() - - time.Sleep(1 * time.Second) - - // Health - resp, err := http.Get("http://localhost:53184/health") - if err != nil { - t.Fatal(err) - } - ok, _ := ioutil.ReadAll(resp.Body) - resp.Body.Close() - if string(ok) != "OK" { - t.Errorf("Failed to receive OK, got %s", ok) - } - - // Metrics - resp, err = http.Get("http://localhost:53183/metrics") - if err != nil { - t.Fatal(err) - } - const proc = "process_virtual_memory_bytes" - metrics, _ := ioutil.ReadAll(resp.Body) - if !bytes.Contains(metrics, []byte(proc)) { - t.Errorf("Failed to see %s in metric output", proc) - } -} - -const inUse = "address already in use" diff --git a/vendor/github.com/coredns/coredns/test/reverse_test.go b/vendor/github.com/coredns/coredns/test/reverse_test.go deleted file mode 100644 index 4ff74c73..00000000 --- a/vendor/github.com/coredns/coredns/test/reverse_test.go +++ /dev/null @@ -1,50 +0,0 @@ -package test - -import ( - "io/ioutil" - "log" - "testing" - - "github.com/coredns/coredns/plugin/proxy" - "github.com/coredns/coredns/plugin/test" - "github.com/coredns/coredns/request" - - "github.com/miekg/dns" -) - -func TestReverseCorefile(t *testing.T) { - corefile := `10.0.0.0/24:0 { - whoami - }` - - i, err := CoreDNSServer(corefile) - if err != nil { - t.Fatalf("Could not get CoreDNS serving instance: %s", err) - } - defer i.Stop() - - udp, _ := CoreDNSServerPorts(i, 0) - if udp == "" { - t.Fatalf("Could not get UDP listening port") - } - - log.SetOutput(ioutil.Discard) - - p := proxy.NewLookup([]string{udp}) - state := request.Request{W: &test.ResponseWriter{}, Req: new(dns.Msg)} - resp, err := p.Lookup(state, "17.0.0.10.in-addr.arpa.", dns.TypePTR) - if err != nil { - t.Fatal("Expected to receive reply, but didn't") - } - - if len(resp.Extra) != 2 { - t.Fatal("Expected to at least two RRs in the extra section, got none") - } - // Second one is SRV, first one can be A or AAAA depending on system. - if resp.Extra[1].Header().Rrtype != dns.TypeSRV { - t.Errorf("Expected RR to SRV, got: %d", resp.Extra[1].Header().Rrtype) - } - if resp.Extra[1].Header().Name != "_udp.17.0.0.10.in-addr.arpa." { - t.Errorf("Expected _udp.17.0.0.10.in-addr.arpa. got: %s", resp.Extra[1].Header().Name) - } -} diff --git a/vendor/github.com/coredns/coredns/test/rewrite_test.go b/vendor/github.com/coredns/coredns/test/rewrite_test.go deleted file mode 100644 index 0ec3a9a7..00000000 --- a/vendor/github.com/coredns/coredns/test/rewrite_test.go +++ /dev/null @@ -1,90 +0,0 @@ -package test - -import ( - "bytes" - "io/ioutil" - "log" - "testing" - - "github.com/miekg/dns" -) - -func TestRewrite(t *testing.T) { - t.Parallel() - corefile := `.:0 { - rewrite type MX a - rewrite edns0 local set 0xffee hello-world - erratic . { - drop 0 - } -}` - - i, udp, _, err := CoreDNSServerAndPorts(corefile) - if err != nil { - t.Fatalf("Could not get CoreDNS serving instance: %s", err) - } - - defer i.Stop() - - log.SetOutput(ioutil.Discard) - - testMX(t, udp) - testEdns0(t, udp) -} - -func testMX(t *testing.T, server string) { - m := new(dns.Msg) - m.SetQuestion("example.com.", dns.TypeMX) - - r, err := dns.Exchange(m, server) - if err != nil { - t.Fatalf("Expected to receive reply, but didn't: %s", err) - } - - // expect answer section with A record in it - if len(r.Answer) == 0 { - t.Error("Expected to at least one RR in the answer section, got none") - } - if r.Answer[0].Header().Rrtype != dns.TypeA { - t.Errorf("Expected RR to A, got: %d", r.Answer[0].Header().Rrtype) - } - if r.Answer[0].(*dns.A).A.String() != "192.0.2.53" { - t.Errorf("Expected 192.0.2.53, got: %s", r.Answer[0].(*dns.A).A.String()) - } -} - -func testEdns0(t *testing.T, server string) { - m := new(dns.Msg) - m.SetQuestion("example.com.", dns.TypeA) - - r, err := dns.Exchange(m, server) - if err != nil { - t.Fatalf("Expected to receive reply, but didn't: %s", err) - } - - // expect answer section with A record in it - if len(r.Answer) == 0 { - t.Error("Expected to at least one RR in the answer section, got none") - } - if r.Answer[0].Header().Rrtype != dns.TypeA { - t.Errorf("Expected RR to A, got: %d", r.Answer[0].Header().Rrtype) - } - if r.Answer[0].(*dns.A).A.String() != "192.0.2.53" { - t.Errorf("Expected 192.0.2.53, got: %s", r.Answer[0].(*dns.A).A.String()) - } - o := r.IsEdns0() - if o == nil || len(o.Option) == 0 { - t.Error("Expected EDNS0 options but got none") - } else { - if e, ok := o.Option[0].(*dns.EDNS0_LOCAL); ok { - if e.Code != 0xffee { - t.Errorf("Expected EDNS_LOCAL code 0xffee but got %x", e.Code) - } - if !bytes.Equal(e.Data, []byte("hello-world")) { - t.Errorf("Expected EDNS_LOCAL data 'hello-world' but got %q", e.Data) - } - } else { - t.Errorf("Expected EDNS0_LOCAL but got %v", o.Option[0]) - } - } -} diff --git a/vendor/github.com/coredns/coredns/test/secondary_test.go b/vendor/github.com/coredns/coredns/test/secondary_test.go deleted file mode 100644 index 18bfd8f1..00000000 --- a/vendor/github.com/coredns/coredns/test/secondary_test.go +++ /dev/null @@ -1,83 +0,0 @@ -package test - -import ( - "testing" - - "github.com/coredns/coredns/plugin/proxy" - "github.com/coredns/coredns/plugin/test" - "github.com/coredns/coredns/request" - - "github.com/miekg/dns" -) - -func TestEmptySecondaryZone(t *testing.T) { - // Corefile that fails to transfer example.org. - corefile := `example.org:0 { - secondary { - transfer from 127.0.0.1:1717 - } - } -` - - i, udp, _, err := CoreDNSServerAndPorts(corefile) - if err != nil { - t.Fatalf("Could not get CoreDNS serving instance: %s", err) - } - defer i.Stop() - - p := proxy.NewLookup([]string{udp}) - state := request.Request{W: &test.ResponseWriter{}, Req: new(dns.Msg)} - - resp, err := p.Lookup(state, "www.example.org.", dns.TypeA) - if err != nil { - t.Fatal("Expected to receive reply, but didn't") - } - if resp.Rcode != dns.RcodeServerFailure { - t.Fatalf("Expected reply to be a SERVFAIL, got %d", resp.Rcode) - } -} - -func TestSecondaryZoneTransfer(t *testing.T) { - name, rm, err := test.TempFile(".", exampleOrg) - if err != nil { - t.Fatalf("Failed to create zone: %s", err) - } - defer rm() - - corefile := `example.org:0 { - file ` + name + ` { - transfer to * - } -} -` - - i, _, tcp, err := CoreDNSServerAndPorts(corefile) - if err != nil { - t.Fatalf("Could not get CoreDNS serving instance: %s", err) - } - defer i.Stop() - - corefile = `example.org:0 { - secondary { - transfer from ` + tcp + ` - } -} -` - i1, udp, _, err := CoreDNSServerAndPorts(corefile) - if err != nil { - t.Fatalf("Could not get CoreDNS serving instance: %s", err) - } - defer i1.Stop() - - m := new(dns.Msg) - m.SetQuestion("example.org.", dns.TypeSOA) - - r, err := dns.Exchange(m, udp) - if err != nil { - t.Fatalf("Expected to receive reply, but didn't: %s", err) - } - - if len(r.Answer) == 0 { - t.Fatalf("Expected answer section") - } -} diff --git a/vendor/github.com/coredns/coredns/test/server.go b/vendor/github.com/coredns/coredns/test/server.go deleted file mode 100644 index 4a0c200e..00000000 --- a/vendor/github.com/coredns/coredns/test/server.go +++ /dev/null @@ -1,79 +0,0 @@ -package test - -import ( - "io/ioutil" - "log" - "sync" - - "github.com/coredns/coredns/core/dnsserver" - - // Hook in CoreDNS. - _ "github.com/coredns/coredns/core" - - "github.com/mholt/caddy" -) - -var mu sync.Mutex - -// CoreDNSServer returns a CoreDNS test server. It just takes a normal Corefile as input. -func CoreDNSServer(corefile string) (*caddy.Instance, error) { - mu.Lock() - defer mu.Unlock() - caddy.Quiet = true - dnsserver.Quiet = true - log.SetOutput(ioutil.Discard) - - return caddy.Start(NewInput(corefile)) -} - -// CoreDNSServerStop stops a server. -func CoreDNSServerStop(i *caddy.Instance) { i.Stop() } - -// CoreDNSServerPorts returns the ports the instance is listening on. The integer k indicates -// which ServerListener you want. -func CoreDNSServerPorts(i *caddy.Instance, k int) (udp, tcp string) { - srvs := i.Servers() - if len(srvs) < k+1 { - return "", "" - } - u := srvs[k].LocalAddr() - t := srvs[k].Addr() - - if u != nil { - udp = u.String() - } - if t != nil { - tcp = t.String() - } - return -} - -// CoreDNSServerAndPorts combines CoreDNSServer and CoreDNSServerPorts to start a CoreDNS -// server and returns the udp and tcp ports of the first instance. -func CoreDNSServerAndPorts(corefile string) (i *caddy.Instance, udp, tcp string, err error) { - i, err = CoreDNSServer(corefile) - if err != nil { - return nil, "", "", err - } - udp, tcp = CoreDNSServerPorts(i, 0) - return i, udp, tcp, nil -} - -// Input implements the caddy.Input interface and acts as an easy way to use a string as a Corefile. -type Input struct { - corefile []byte -} - -// NewInput returns a pointer to Input, containing the corefile string as input. -func NewInput(corefile string) *Input { - return &Input{corefile: []byte(corefile)} -} - -// Body implements the Input interface. -func (i *Input) Body() []byte { return i.corefile } - -// Path implements the Input interface. -func (i *Input) Path() string { return "Corefile" } - -// ServerType implements the Input interface. -func (i *Input) ServerType() string { return "dns" } diff --git a/vendor/github.com/coredns/coredns/test/server_reverse_test.go b/vendor/github.com/coredns/coredns/test/server_reverse_test.go deleted file mode 100644 index 6434d867..00000000 --- a/vendor/github.com/coredns/coredns/test/server_reverse_test.go +++ /dev/null @@ -1,145 +0,0 @@ -package test - -import ( - "strings" - "testing" - - "github.com/miekg/dns" -) - -func TestClasslessReverse(t *testing.T) { - // 25 -> so anything above 1.127 won't be answered, below is OK. - corefile := `192.168.1.0/25:0 { - whoami -} -` - s, udp, _, err := CoreDNSServerAndPorts(corefile) - if err != nil { - t.Fatalf("Could not get CoreDNS serving instance: %s", err) - } - defer s.Stop() - - tests := []struct { - addr string - rcode int - }{ - {"192.168.1.0", dns.RcodeSuccess}, // in range - {"192.168.1.1", dns.RcodeSuccess}, // in range - {"192.168.1.127", dns.RcodeSuccess}, // in range - - {"192.168.1.128", dns.RcodeRefused}, // out of range - {"192.168.1.129", dns.RcodeRefused}, // out of range - {"192.168.1.255", dns.RcodeRefused}, // out of range - {"192.168.2.0", dns.RcodeRefused}, // different zone - } - - m := new(dns.Msg) - for i, tc := range tests { - inaddr, _ := dns.ReverseAddr(tc.addr) - m.SetQuestion(inaddr, dns.TypeA) - - r, e := dns.Exchange(m, udp) - if e != nil { - t.Errorf("Test %d, expected no error, got %q", i, e) - } - if r.Rcode != tc.rcode { - t.Errorf("Test %d, expected %d, got %d for %s", i, tc.rcode, r.Rcode, tc.addr) - } - } -} - -func TestReverse(t *testing.T) { - corefile := `192.168.1.0/24:0 { - whoami -} -` - s, udp, _, err := CoreDNSServerAndPorts(corefile) - if err != nil { - t.Fatalf("Could not get CoreDNS serving instance: %s", err) - } - defer s.Stop() - - tests := []struct { - addr string - rcode int - }{ - {"192.168.1.0", dns.RcodeSuccess}, - {"192.168.1.1", dns.RcodeSuccess}, - {"192.168.1.127", dns.RcodeSuccess}, - {"192.168.1.128", dns.RcodeSuccess}, - {"1.168.192.in-addr.arpa.", dns.RcodeSuccess}, - - {"2.168.192.in-addr.arpa.", dns.RcodeRefused}, - } - - m := new(dns.Msg) - for i, tc := range tests { - inaddr := tc.addr - var err error - if !strings.HasSuffix(tc.addr, ".arpa.") { - inaddr, err = dns.ReverseAddr(tc.addr) - if err != nil { - t.Fatalf("Test %d, failed to convert %s", i, tc.addr) - } - tc.addr = inaddr - } - - m.SetQuestion(tc.addr, dns.TypeA) - - r, e := dns.Exchange(m, udp) - if e != nil { - t.Errorf("Test %d, expected no error, got %q", i, e) - } - if r.Rcode != tc.rcode { - t.Errorf("Test %d, expected %d, got %d for %s", i, tc.rcode, r.Rcode, tc.addr) - } - } -} - -func TestReverseInAddr(t *testing.T) { - corefile := `1.168.192.in-addr.arpa:0 { - whoami -} -` - s, udp, _, err := CoreDNSServerAndPorts(corefile) - if err != nil { - t.Fatalf("Could not get CoreDNS serving instance: %s", err) - } - defer s.Stop() - - tests := []struct { - addr string - rcode int - }{ - {"192.168.1.0", dns.RcodeSuccess}, - {"192.168.1.1", dns.RcodeSuccess}, - {"192.168.1.127", dns.RcodeSuccess}, - {"192.168.1.128", dns.RcodeSuccess}, - {"1.168.192.in-addr.arpa.", dns.RcodeSuccess}, - - {"2.168.192.in-addr.arpa.", dns.RcodeRefused}, - } - - m := new(dns.Msg) - for i, tc := range tests { - inaddr := tc.addr - var err error - if !strings.HasSuffix(tc.addr, ".arpa.") { - inaddr, err = dns.ReverseAddr(tc.addr) - if err != nil { - t.Fatalf("Test %d, failed to convert %s", i, tc.addr) - } - tc.addr = inaddr - } - - m.SetQuestion(tc.addr, dns.TypeA) - - r, e := dns.Exchange(m, udp) - if e != nil { - t.Errorf("Test %d, expected no error, got %q", i, e) - } - if r.Rcode != tc.rcode { - t.Errorf("Test %d, expected %d, got %d for %s", i, tc.rcode, r.Rcode, tc.addr) - } - } -} diff --git a/vendor/github.com/coredns/coredns/test/server_test.go b/vendor/github.com/coredns/coredns/test/server_test.go deleted file mode 100644 index a0dfed7d..00000000 --- a/vendor/github.com/coredns/coredns/test/server_test.go +++ /dev/null @@ -1,55 +0,0 @@ -package test - -import ( - "testing" - - "github.com/miekg/dns" -) - -// Start 2 tests server, server A will proxy to B, server B is an CH server. -func TestProxyToChaosServer(t *testing.T) { - t.Parallel() - corefile := `.:0 { - chaos CoreDNS-001 miek@miek.nl -} -` - chaos, udpChaos, _, err := CoreDNSServerAndPorts(corefile) - if err != nil { - t.Fatalf("Could not get CoreDNS serving instance: %s", err) - } - - defer chaos.Stop() - - corefileProxy := `.:0 { - proxy . ` + udpChaos + ` -} -` - proxy, udp, _, err := CoreDNSServerAndPorts(corefileProxy) - if err != nil { - t.Fatalf("Could not get CoreDNS serving instance") - } - defer proxy.Stop() - - chaosTest(t, udpChaos) - - chaosTest(t, udp) - // chaosTest(t, tcp, "tcp"), commented out because we use the original transport to reach the - // proxy and we only forward to the udp port. -} - -func chaosTest(t *testing.T, server string) { - m := new(dns.Msg) - m.Question = make([]dns.Question, 1) - m.Question[0] = dns.Question{Qclass: dns.ClassCHAOS, Name: "version.bind.", Qtype: dns.TypeTXT} - - r, err := dns.Exchange(m, server) - if err != nil { - t.Fatalf("Could not send message: %s", err) - } - if r.Rcode != dns.RcodeSuccess || len(r.Answer) == 0 { - t.Fatalf("Expected successful reply, got %s", dns.RcodeToString[r.Rcode]) - } - if r.Answer[0].String() != `version.bind. 0 CH TXT "CoreDNS-001"` { - t.Fatalf("Expected version.bind. reply, got %s", r.Answer[0].String()) - } -} diff --git a/vendor/github.com/coredns/coredns/test/wildcard_test.go b/vendor/github.com/coredns/coredns/test/wildcard_test.go deleted file mode 100644 index f34b5c0e..00000000 --- a/vendor/github.com/coredns/coredns/test/wildcard_test.go +++ /dev/null @@ -1,96 +0,0 @@ -package test - -import ( - "io/ioutil" - "log" - "testing" - - "github.com/coredns/coredns/plugin/proxy" - "github.com/coredns/coredns/plugin/test" - "github.com/coredns/coredns/request" - - "github.com/miekg/dns" -) - -func TestLookupWildcard(t *testing.T) { - t.Parallel() - name, rm, err := test.TempFile(".", exampleOrg) - if err != nil { - t.Fatalf("Failed to create zone: %s", err) - } - defer rm() - - corefile := `example.org:0 { - file ` + name + ` -} -` - - i, udp, _, err := CoreDNSServerAndPorts(corefile) - if err != nil { - t.Fatalf("Could not get CoreDNS serving instance: %s", err) - } - defer i.Stop() - - log.SetOutput(ioutil.Discard) - - p := proxy.NewLookup([]string{udp}) - state := request.Request{W: &test.ResponseWriter{}, Req: new(dns.Msg)} - - for _, lookup := range []string{"a.w.example.org.", "a.a.w.example.org."} { - resp, err := p.Lookup(state, lookup, dns.TypeTXT) - if err != nil || resp == nil { - t.Fatalf("Expected to receive reply, but didn't for %s", lookup) - } - - // ;; ANSWER SECTION: - // a.w.example.org. 1800 IN TXT "Wildcard" - if resp.Rcode != dns.RcodeSuccess { - t.Errorf("Expected NOERROR RCODE, got %s for %s", dns.RcodeToString[resp.Rcode], lookup) - continue - } - if len(resp.Answer) == 0 { - t.Errorf("Expected to at least one RR in the answer section, got none for %s TXT", lookup) - t.Logf("%s", resp) - continue - } - if resp.Answer[0].Header().Name != lookup { - t.Errorf("Expected name to be %s, got: %s for TXT", lookup, resp.Answer[0].Header().Name) - continue - } - if resp.Answer[0].Header().Rrtype != dns.TypeTXT { - t.Errorf("Expected RR to be TXT, got: %d, for %s TXT", resp.Answer[0].Header().Rrtype, lookup) - continue - } - if resp.Answer[0].(*dns.TXT).Txt[0] != "Wildcard" { - t.Errorf("Expected Wildcard, got: %s, for %s TXT", resp.Answer[0].(*dns.TXT).Txt[0], lookup) - continue - } - } - - for _, lookup := range []string{"w.example.org.", "a.w.example.org.", "a.a.w.example.org."} { - resp, err := p.Lookup(state, lookup, dns.TypeSRV) - if err != nil || resp == nil { - t.Fatal("Expected to receive reply, but didn't", lookup) - } - - // ;; AUTHORITY SECTION: - // example.org. 1800 IN SOA linode.atoom.net. miek.miek.nl. 1454960557 14400 3600 604800 14400 - if resp.Rcode != dns.RcodeSuccess { - t.Errorf("Expected NOERROR RCODE, got %s for %s", dns.RcodeToString[resp.Rcode], lookup) - continue - } - if len(resp.Answer) != 0 { - t.Errorf("Expected zero RRs in the answer section, got some, for %s SRV", lookup) - continue - } - if len(resp.Ns) == 0 { - t.Errorf("Expected to at least one RR in the authority section, got none, for %s SRV", lookup) - continue - } - if resp.Ns[0].Header().Rrtype != dns.TypeSOA { - t.Errorf("Expected RR to be SOA, got: %d, for %s SRV", resp.Ns[0].Header().Rrtype, lookup) - continue - } - } - -} diff --git a/vendor/github.com/coreos/go-systemd/.travis.yml b/vendor/github.com/coreos/go-systemd/.travis.yml deleted file mode 100644 index 98c041c7..00000000 --- a/vendor/github.com/coreos/go-systemd/.travis.yml +++ /dev/null @@ -1,29 +0,0 @@ -language: shell # We do everything inside Docker and don't want travis fiddling with steps or environment variables - -sudo: required - -services: - - docker - -env: - global: - - GOPATH=/opt - - BUILD_DIR=/opt/src/github.com/coreos/go-systemd - matrix: - - DOCKER_BASE=ubuntu:18.04 - - DOCKER_BASE=debian:stretch - -before_install: - - docker pull ${DOCKER_BASE} - - docker run --privileged -e GOPATH=${GOPATH} --cidfile=/tmp/cidfile ${DOCKER_BASE} /bin/bash -c "apt-get update && apt-get install -y build-essential git golang dbus libsystemd-dev libpam-systemd systemd-container && go get github.com/coreos/pkg/dlopen && go get github.com/godbus/dbus" - - docker commit `cat /tmp/cidfile` go-systemd/container-tests - - rm -f /tmp/cidfile - -install: - - docker run -d --cidfile=/tmp/cidfile --privileged -e GOPATH=${GOPATH} -v ${PWD}:${BUILD_DIR} go-systemd/container-tests /bin/systemd --system - -script: - - docker exec `cat /tmp/cidfile` /bin/bash -c "cd ${BUILD_DIR} && ./test" - -after_script: - - docker kill `cat /tmp/cidfile` diff --git a/vendor/github.com/coreos/go-systemd/CONTRIBUTING.md b/vendor/github.com/coreos/go-systemd/CONTRIBUTING.md deleted file mode 100644 index 0551ed53..00000000 --- a/vendor/github.com/coreos/go-systemd/CONTRIBUTING.md +++ /dev/null @@ -1,77 +0,0 @@ -# How to Contribute - -CoreOS projects are [Apache 2.0 licensed](LICENSE) and accept contributions via -GitHub pull requests. This document outlines some of the conventions on -development workflow, commit message formatting, contact points and other -resources to make it easier to get your contribution accepted. - -# Certificate of Origin - -By contributing to this project you agree to the Developer Certificate of -Origin (DCO). This document was created by the Linux Kernel community and is a -simple statement that you, as a contributor, have the legal right to make the -contribution. See the [DCO](DCO) file for details. - -# Email and Chat - -The project currently uses the general CoreOS email list and IRC channel: -- Email: [coreos-dev](https://groups.google.com/forum/#!forum/coreos-dev) -- IRC: #[coreos](irc://irc.freenode.org:6667/#coreos) IRC channel on freenode.org - -Please avoid emailing maintainers found in the MAINTAINERS file directly. They -are very busy and read the mailing lists. - -## Getting Started - -- Fork the repository on GitHub -- Read the [README](README.md) for build and test instructions -- Play with the project, submit bugs, submit patches! - -## Contribution Flow - -This is a rough outline of what a contributor's workflow looks like: - -- Create a topic branch from where you want to base your work (usually master). -- Make commits of logical units. -- Make sure your commit messages are in the proper format (see below). -- Push your changes to a topic branch in your fork of the repository. -- Make sure the tests pass, and add any new tests as appropriate. -- Submit a pull request to the original repository. - -Thanks for your contributions! - -### Coding Style - -CoreOS projects written in Go follow a set of style guidelines that we've documented -[here](https://github.com/coreos/docs/tree/master/golang). Please follow them when -working on your contributions. - -### Format of the Commit Message - -We follow a rough convention for commit messages that is designed to answer two -questions: what changed and why. The subject line should feature the what and -the body of the commit should describe the why. - -``` -scripts: add the test-cluster command - -this uses tmux to setup a test cluster that you can easily kill and -start for debugging. - -Fixes #38 -``` - -The format can be described more formally as follows: - -``` -: - - - -