From 70c788ce0c7f81f87d19850164031ce2e8158e72 Mon Sep 17 00:00:00 2001 From: Matthew Holt Date: Fri, 21 Jun 2019 08:08:26 -0600 Subject: [PATCH] Minor cleanups/improvements --- modules/caddyhttp/caddyhttp.go | 5 ++--- modules/caddyhttp/templates/tplcontext.go | 10 +++------- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/modules/caddyhttp/caddyhttp.go b/modules/caddyhttp/caddyhttp.go index ffd7d0fd..009e564d 100644 --- a/modules/caddyhttp/caddyhttp.go +++ b/modules/caddyhttp/caddyhttp.go @@ -203,10 +203,9 @@ func (app *App) automaticHTTPS() error { for _, m := range matcherSet { if hm, ok := m.(*MatchHost); ok { for _, d := range *hm { - if !certmagic.HostQualifies(d) { - continue + if certmagic.HostQualifies(d) { + domainSet[d] = struct{}{} } - domainSet[d] = struct{}{} } } } diff --git a/modules/caddyhttp/templates/tplcontext.go b/modules/caddyhttp/templates/tplcontext.go index 83fe19e8..d89f1066 100644 --- a/modules/caddyhttp/templates/tplcontext.go +++ b/modules/caddyhttp/templates/tplcontext.go @@ -117,12 +117,8 @@ func (c templateContext) Cookie(name string) string { return "" } -// ReqHeader gets the value of a request header with field name. -func (c templateContext) ReqHeader(name string) string { - return c.Req.Header.Get(name) -} - // Hostname gets the (remote) hostname of the client making the request. +// Performance warning: This involves a DNS lookup. func (c templateContext) Hostname() string { ip := c.IP() @@ -134,8 +130,8 @@ func (c templateContext) Hostname() string { return hostnameList[0] } -// IP gets the (remote) IP address of the client making the request. -func (c templateContext) IP() string { +// RemoteIP gets the IP address of the client making the request. +func (c templateContext) RemoteIP() string { ip, _, err := net.SplitHostPort(c.Req.RemoteAddr) if err != nil { return c.Req.RemoteAddr