aboutsummaryrefslogtreecommitdiff
path: root/plugin/proxy
diff options
context:
space:
mode:
Diffstat (limited to 'plugin/proxy')
-rw-r--r--plugin/proxy/down.go30
-rw-r--r--plugin/proxy/google.go25
-rw-r--r--plugin/proxy/lookup.go23
-rw-r--r--plugin/proxy/upstream.go30
-rw-r--r--plugin/proxy/upstream_test.go7
5 files changed, 33 insertions, 82 deletions
diff --git a/plugin/proxy/down.go b/plugin/proxy/down.go
new file mode 100644
index 000000000..5dc8b678d
--- /dev/null
+++ b/plugin/proxy/down.go
@@ -0,0 +1,30 @@
+package proxy
+
+import (
+ "sync/atomic"
+ "time"
+
+ "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 {
+
+ down := false
+
+ uh.Lock()
+ until := uh.OkUntil
+ uh.Unlock()
+
+ if !until.IsZero() && time.Now().After(until) {
+ down = true
+ }
+
+ fails := atomic.LoadInt32(&uh.Fails)
+ if fails >= upstream.MaxFails && upstream.MaxFails != 0 {
+ down = true
+ }
+ return down
+ }
+}
diff --git a/plugin/proxy/google.go b/plugin/proxy/google.go
index ecc5e6dfd..d7248e149 100644
--- a/plugin/proxy/google.go
+++ b/plugin/proxy/google.go
@@ -10,7 +10,6 @@ import (
"net"
"net/http"
"net/url"
- "sync/atomic"
"time"
"github.com/coredns/coredns/plugin/pkg/healthcheck"
@@ -198,7 +197,6 @@ func newUpstream(hosts []string, old *staticUpstream) Upstream {
Future: 60 * time.Second,
},
ex: old.ex,
- WithoutPathPrefix: old.WithoutPathPrefix,
IgnoredSubDomains: old.IgnoredSubDomains,
}
@@ -209,28 +207,7 @@ func newUpstream(hosts []string, old *staticUpstream) Upstream {
Conns: 0,
Fails: 0,
FailTimeout: upstream.FailTimeout,
-
- CheckDown: func(upstream *staticUpstream) healthcheck.UpstreamHostDownFunc {
- return func(uh *healthcheck.UpstreamHost) bool {
-
- down := false
-
- uh.CheckMu.Lock()
- until := uh.OkUntil
- uh.CheckMu.Unlock()
-
- if !until.IsZero() && time.Now().After(until) {
- down = true
- }
-
- fails := atomic.LoadInt32(&uh.Fails)
- if fails >= upstream.MaxFails && upstream.MaxFails != 0 {
- down = true
- }
- return down
- }
- }(upstream),
- WithoutPathPrefix: upstream.WithoutPathPrefix,
+ CheckDown: checkDownFunc(upstream),
}
upstream.Hosts[i] = uh
diff --git a/plugin/proxy/lookup.go b/plugin/proxy/lookup.go
index 9be62edd5..238666608 100644
--- a/plugin/proxy/lookup.go
+++ b/plugin/proxy/lookup.go
@@ -40,28 +40,7 @@ func NewLookupWithOption(hosts []string, opts Options) Proxy {
Conns: 0,
Fails: 0,
FailTimeout: upstream.FailTimeout,
-
- CheckDown: func(upstream *staticUpstream) healthcheck.UpstreamHostDownFunc {
- return func(uh *healthcheck.UpstreamHost) bool {
-
- down := false
-
- uh.CheckMu.Lock()
- until := uh.OkUntil
- uh.CheckMu.Unlock()
-
- if !until.IsZero() && time.Now().After(until) {
- down = true
- }
-
- fails := atomic.LoadInt32(&uh.Fails)
- if fails >= upstream.MaxFails && upstream.MaxFails != 0 {
- down = true
- }
- return down
- }
- }(upstream),
- WithoutPathPrefix: upstream.WithoutPathPrefix,
+ CheckDown: checkDownFunc(upstream),
}
upstream.Hosts[i] = uh
diff --git a/plugin/proxy/upstream.go b/plugin/proxy/upstream.go
index b60b6ff58..f7ad58ea8 100644
--- a/plugin/proxy/upstream.go
+++ b/plugin/proxy/upstream.go
@@ -4,7 +4,6 @@ import (
"fmt"
"net"
"strconv"
- "sync/atomic"
"time"
"github.com/coredns/coredns/plugin"
@@ -20,7 +19,6 @@ type staticUpstream struct {
healthcheck.HealthCheck
- WithoutPathPrefix string
IgnoredSubDomains []string
ex Exchanger
}
@@ -69,28 +67,7 @@ func NewStaticUpstreams(c *caddyfile.Dispenser) ([]Upstream, error) {
Conns: 0,
Fails: 0,
FailTimeout: upstream.FailTimeout,
-
- CheckDown: func(upstream *staticUpstream) healthcheck.UpstreamHostDownFunc {
- return func(uh *healthcheck.UpstreamHost) bool {
-
- down := false
-
- uh.CheckMu.Lock()
- until := uh.OkUntil
- uh.CheckMu.Unlock()
-
- if !until.IsZero() && time.Now().After(until) {
- down = true
- }
-
- fails := atomic.LoadInt32(&uh.Fails)
- if fails >= upstream.MaxFails && upstream.MaxFails != 0 {
- down = true
- }
- return down
- }
- }(upstream),
- WithoutPathPrefix: upstream.WithoutPathPrefix,
+ CheckDown: checkDownFunc(upstream),
}
upstream.Hosts[i] = uh
@@ -158,11 +135,6 @@ func parseBlock(c *caddyfile.Dispenser, u *staticUpstream) error {
u.Future = 3 * time.Second
}
}
- case "without":
- if !c.NextArg() {
- return c.ArgErr()
- }
- u.WithoutPathPrefix = c.Val()
case "except":
ignoredDomains := c.RemainingArgs()
if len(ignoredDomains) == 0 {
diff --git a/plugin/proxy/upstream_test.go b/plugin/proxy/upstream_test.go
index 42d50cac3..98509f738 100644
--- a/plugin/proxy/upstream_test.go
+++ b/plugin/proxy/upstream_test.go
@@ -85,13 +85,6 @@ proxy . 8.8.8.8:53 {
{
`
proxy . 8.8.8.8:53 {
- without without
-}`,
- false,
- },
- {
- `
-proxy . 8.8.8.8:53 {
except miek.nl example.org 10.0.0.0/24
}`,
false,