summaryrefslogtreecommitdiff
path: root/caddyconfig/httpcaddyfile/tlsapp.go
diff options
context:
space:
mode:
authorMatthew Holt <mholt@users.noreply.github.com>2020-04-02 14:20:30 -0600
committerMatthew Holt <mholt@users.noreply.github.com>2020-04-02 14:24:53 -0600
commit1c190b001b95e57d21dc63c01ae3c6de2a3fec57 (patch)
tree762fca56efffb3cedc7de7128f42c6c479e3a34f /caddyconfig/httpcaddyfile/tlsapp.go
parent3634c4593f2d9999dca2d7a02e23edc29bf7bd11 (diff)
httpcaddyfile: Refactor site key parsing; detect conflicting schemes
We now store the parsed site/server block keys with the server block, rather than parsing the addresses every time we read them. Also detect conflicting schemes, i.e. TLS and non-TLS cannot be served from the same server (natively -- modules could be built for it). Also do not add site subroutes (subroutes generated specifically from site blocks in the Caddyfile) that are empty.
Diffstat (limited to 'caddyconfig/httpcaddyfile/tlsapp.go')
-rw-r--r--caddyconfig/httpcaddyfile/tlsapp.go23
1 files changed, 5 insertions, 18 deletions
diff --git a/caddyconfig/httpcaddyfile/tlsapp.go b/caddyconfig/httpcaddyfile/tlsapp.go
index db3d13b..6214d61 100644
--- a/caddyconfig/httpcaddyfile/tlsapp.go
+++ b/caddyconfig/httpcaddyfile/tlsapp.go
@@ -43,26 +43,16 @@ func (st ServerType) buildTLSApp(
hostsSharedWithHostlessKey := make(map[string]struct{})
for _, pair := range pairings {
for _, sb := range pair.serverBlocks {
- for _, key := range sb.block.Keys {
- addr, err := ParseAddress(key)
- if err != nil {
- return nil, warnings, err
- }
- addr = addr.Normalize()
+ for _, addr := range sb.keys {
if addr.Host == "" {
serverBlocksWithHostlessKey++
// this server block has a hostless key, now
// go through and add all the hosts to the set
- for _, otherKey := range sb.block.Keys {
- if otherKey == key {
+ for _, otherAddr := range sb.keys {
+ if otherAddr.Original == addr.Original {
continue
}
- addr, err := ParseAddress(otherKey)
- if err != nil {
- return nil, warnings, err
- }
- addr = addr.Normalize()
- if addr.Host != "" {
+ if otherAddr.Host != "" {
hostsSharedWithHostlessKey[addr.Host] = struct{}{}
}
}
@@ -82,10 +72,7 @@ func (st ServerType) buildTLSApp(
// get values that populate an automation policy for this block
var ap *caddytls.AutomationPolicy
- sblockHosts, err := st.hostsFromServerBlockKeys(sblock.block, false, false)
- if err != nil {
- return nil, warnings, err
- }
+ sblockHosts := sblock.hostsFromKeys(false, false)
if len(sblockHosts) == 0 {
ap = catchAllAP
}