aboutsummaryrefslogtreecommitdiff
path: root/middleware/proxy/upstream.go
diff options
context:
space:
mode:
Diffstat (limited to 'middleware/proxy/upstream.go')
-rw-r--r--middleware/proxy/upstream.go34
1 files changed, 11 insertions, 23 deletions
diff --git a/middleware/proxy/upstream.go b/middleware/proxy/upstream.go
index e6a19ca58..b02c08a42 100644
--- a/middleware/proxy/upstream.go
+++ b/middleware/proxy/upstream.go
@@ -37,13 +37,7 @@ type staticUpstream struct {
}
WithoutPathPrefix string
IgnoredSubDomains []string
- options Options
- Protocol protocol
-}
-
-// Options ...
-type Options struct {
- Ecs []*net.IPNet // EDNS0 CLIENT SUBNET address (v4/v6) to add in CIDR notaton.
+ ex Exchanger
}
// NewStaticUpstreams parses the configuration input and sets up
@@ -58,7 +52,7 @@ func NewStaticUpstreams(c *caddyfile.Dispenser) ([]Upstream, error) {
Spray: nil,
FailTimeout: 10 * time.Second,
MaxFails: 1,
- Protocol: dnsProto,
+ ex: newDNSEx(),
}
if !c.Args(&upstream.from) {
@@ -89,7 +83,6 @@ func NewStaticUpstreams(c *caddyfile.Dispenser) ([]Upstream, error) {
Fails: 0,
FailTimeout: upstream.FailTimeout,
Unhealthy: false,
- Exchanger: newDNSEx(host),
CheckDown: func(upstream *staticUpstream) UpstreamHostDownFunc {
return func(uh *UpstreamHost) bool {
@@ -106,14 +99,6 @@ func NewStaticUpstreams(c *caddyfile.Dispenser) ([]Upstream, error) {
}(upstream),
WithoutPathPrefix: upstream.WithoutPathPrefix,
}
- switch upstream.Protocol {
- // case https_google:
-
- case dnsProto:
- fallthrough
- default:
- // Already done in the initialization above.
- }
upstream.Hosts[i] = uh
}
@@ -135,10 +120,6 @@ func (u *staticUpstream) From() string {
return u.from
}
-func (u *staticUpstream) Options() Options {
- return u.options
-}
-
func parseBlock(c *caddyfile.Dispenser, u *staticUpstream) error {
switch c.Val() {
case "policy":
@@ -208,9 +189,14 @@ func parseBlock(c *caddyfile.Dispenser, u *staticUpstream) error {
}
switch encArgs[0] {
case "dns":
- u.Protocol = dnsProto
+ u.ex = newDNSEx()
case "https_google":
- // Nothing yet.
+ boot := []string{"8.8.8.8:53", "8.8.4.4:53"}
+ if len(encArgs) > 2 && encArgs[1] == "bootstrap" {
+ boot = encArgs[2:]
+ }
+
+ u.ex = newGoogle("", boot) // "" for default in google.go
default:
return fmt.Errorf("%s: %s", errInvalidProtocol, encArgs[0])
}
@@ -305,3 +291,5 @@ func (u *staticUpstream) IsAllowedPath(name string) bool {
}
return true
}
+
+func (u *staticUpstream) Exchanger() Exchanger { return u.ex }