mirror of https://github.com/caddyserver/caddy.git
Minor cleanups/improvements
This commit is contained in:
parent
1c443beb9c
commit
70c788ce0c
|
@ -203,15 +203,14 @@ func (app *App) automaticHTTPS() error {
|
||||||
for _, m := range matcherSet {
|
for _, m := range matcherSet {
|
||||||
if hm, ok := m.(*MatchHost); ok {
|
if hm, ok := m.(*MatchHost); ok {
|
||||||
for _, d := range *hm {
|
for _, d := range *hm {
|
||||||
if !certmagic.HostQualifies(d) {
|
if certmagic.HostQualifies(d) {
|
||||||
continue
|
|
||||||
}
|
|
||||||
domainSet[d] = struct{}{}
|
domainSet[d] = struct{}{}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if len(domainSet) > 0 {
|
if len(domainSet) > 0 {
|
||||||
// marshal the domains into a slice
|
// marshal the domains into a slice
|
||||||
|
|
|
@ -117,12 +117,8 @@ func (c templateContext) Cookie(name string) string {
|
||||||
return ""
|
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.
|
// Hostname gets the (remote) hostname of the client making the request.
|
||||||
|
// Performance warning: This involves a DNS lookup.
|
||||||
func (c templateContext) Hostname() string {
|
func (c templateContext) Hostname() string {
|
||||||
ip := c.IP()
|
ip := c.IP()
|
||||||
|
|
||||||
|
@ -134,8 +130,8 @@ func (c templateContext) Hostname() string {
|
||||||
return hostnameList[0]
|
return hostnameList[0]
|
||||||
}
|
}
|
||||||
|
|
||||||
// IP gets the (remote) IP address of the client making the request.
|
// RemoteIP gets the IP address of the client making the request.
|
||||||
func (c templateContext) IP() string {
|
func (c templateContext) RemoteIP() string {
|
||||||
ip, _, err := net.SplitHostPort(c.Req.RemoteAddr)
|
ip, _, err := net.SplitHostPort(c.Req.RemoteAddr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return c.Req.RemoteAddr
|
return c.Req.RemoteAddr
|
||||||
|
|
Loading…
Reference in New Issue