diff options
Diffstat (limited to 'caddyconfig/httpcaddyfile/httptype.go')
-rw-r--r-- | caddyconfig/httpcaddyfile/httptype.go | 44 |
1 files changed, 30 insertions, 14 deletions
diff --git a/caddyconfig/httpcaddyfile/httptype.go b/caddyconfig/httpcaddyfile/httptype.go index aaec2e9..d880d97 100644 --- a/caddyconfig/httpcaddyfile/httptype.go +++ b/caddyconfig/httpcaddyfile/httptype.go @@ -42,6 +42,7 @@ func (st ServerType) Setup(originalServerBlocks []caddyfile.ServerBlock, options map[string]interface{}) (*caddy.Config, []caddyconfig.Warning, error) { var warnings []caddyconfig.Warning gc := counter{new(int)} + state := make(map[string]interface{}) // load all the server blocks and associate them with a "pile" // of config values; also prohibit duplicate keys because they @@ -133,14 +134,17 @@ func (st ServerType) Setup(originalServerBlocks []caddyfile.ServerBlock, return nil, warnings, fmt.Errorf("%s:%d: unrecognized directive: %s", tkn.File, tkn.Line, dir) } - results, err := dirFunc(Helper{ + h := Helper{ Dispenser: caddyfile.NewDispenser(segment), options: options, warnings: &warnings, matcherDefs: matcherDefs, parentBlock: sb.block, groupCounter: gc, - }) + State: state, + } + + results, err := dirFunc(h) if err != nil { return nil, warnings, fmt.Errorf("parsing caddyfile tokens for '%s': %v", dir, err) } @@ -169,9 +173,10 @@ func (st ServerType) Setup(originalServerBlocks []caddyfile.ServerBlock, // now that each server is configured, make the HTTP app httpApp := caddyhttp.App{ - HTTPPort: tryInt(options["http_port"], &warnings), - HTTPSPort: tryInt(options["https_port"], &warnings), - Servers: servers, + HTTPPort: tryInt(options["http_port"], &warnings), + HTTPSPort: tryInt(options["https_port"], &warnings), + DefaultSNI: tryString(options["default_sni"], &warnings), + Servers: servers, } // now for the TLS app! (TODO: refactor into own func) @@ -326,7 +331,23 @@ func (st ServerType) Setup(originalServerBlocks []caddyfile.ServerBlock, &warnings) } if adminConfig, ok := options["admin"].(string); ok && adminConfig != "" { - cfg.Admin = &caddy.AdminConfig{Listen: adminConfig} + if adminConfig == "off" { + cfg.Admin = &caddy.AdminConfig{Disabled: true} + } else { + cfg.Admin = &caddy.AdminConfig{Listen: adminConfig} + } + } + if len(customLogs) > 0 { + if cfg.Logging == nil { + cfg.Logging = &caddy.Logging{ + Logs: make(map[string]*caddy.CustomLog), + } + } + for _, ncl := range customLogs { + if ncl.name != "" { + cfg.Logging.Logs[ncl.name] = ncl.log + } + } } if len(customLogs) > 0 { if cfg.Logging == nil { @@ -985,12 +1006,12 @@ func sliceContains(haystack []string, needle string) bool { return false } -// specifity returns len(s) minus any wildcards (*) and +// specificity returns len(s) minus any wildcards (*) and // placeholders ({...}). Basically, it's a length count // that penalizes the use of wildcards and placeholders. // This is useful for comparing hostnames and paths. // However, wildcards in paths are not a sure answer to -// the question of specificity. For exmaple, +// the question of specificity. For example, // '*.example.com' is clearly less specific than // 'a.example.com', but is '/a' more or less specific // than '/a*'? @@ -1021,17 +1042,12 @@ func (c counter) nextGroup() string { return name } -type matcherSetAndTokens struct { - matcherSet caddy.ModuleMap - tokens []caddyfile.Token -} - type namedCustomLog struct { name string log *caddy.CustomLog } -// sbAddrAssocation is a mapping from a list of +// sbAddrAssociation is a mapping from a list of // addresses to a list of server blocks that are // served on those addresses. type sbAddrAssociation struct { |