diff options
author | 2022-02-10 08:59:34 -0500 | |
---|---|---|
committer | 2022-02-10 08:59:34 -0500 | |
commit | c5eb7d04601ebbd9400274cb77eaabf431fd7d49 (patch) | |
tree | 4979c4aeada4be178d5bda83d8d9dc8ffb3f42a6 | |
parent | d6743531ad9005051a9375eda80949a40606d5d0 (diff) | |
download | coredns-c5eb7d04601ebbd9400274cb77eaabf431fd7d49.tar.gz coredns-c5eb7d04601ebbd9400274cb77eaabf431fd7d49.tar.zst coredns-c5eb7d04601ebbd9400274cb77eaabf431fd7d49.zip |
dont panic when from-zone cannot be normalized (#5171)
Signed-off-by: Chris O'Haver <cohaver@infoblox.com>
-rw-r--r-- | plugin/grpc/setup.go | 6 | ||||
-rw-r--r-- | plugin/grpc/setup_test.go | 1 |
2 files changed, 6 insertions, 1 deletions
diff --git a/plugin/grpc/setup.go b/plugin/grpc/setup.go index 44527ca5b..1325438f6 100644 --- a/plugin/grpc/setup.go +++ b/plugin/grpc/setup.go @@ -56,7 +56,11 @@ func parseStanza(c *caddy.Controller) (*GRPC, error) { if !c.Args(&g.from) { return g, c.ArgErr() } - g.from = plugin.Host(g.from).NormalizeExact()[0] // only the first is used. + normalized := plugin.Host(g.from).NormalizeExact() + if len(normalized) == 0 { + return g, fmt.Errorf("unable to normalize '%s'", g.from) + } + g.from = normalized[0] // only the first is used. to := c.RemainingArgs() if len(to) == 0 { diff --git a/plugin/grpc/setup_test.go b/plugin/grpc/setup_test.go index 9f571a598..1d9e93b7f 100644 --- a/plugin/grpc/setup_test.go +++ b/plugin/grpc/setup_test.go @@ -30,6 +30,7 @@ func TestSetup(t *testing.T) { {"grpc . 127.0.0.1 {\nblaatl\n}\n", true, "", nil, "unknown property"}, {`grpc . ::1 grpc com ::2`, true, "", nil, "plugin"}, + {"grpc xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 127.0.0.1", true, "", nil, "unable to normalize 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'"}, } for i, test := range tests { |