diff options
author | Francis Lavoie <[email protected]> | 2020-05-11 17:00:35 -0400 |
---|---|---|
committer | GitHub <[email protected]> | 2020-05-11 15:00:35 -0600 |
commit | dc9f4f13fc1cc102c713c69ded295b3fcf685e96 (patch) | |
tree | cbc2bc158947509b222908bbad862ac5581f1cb4 /caddyconfig/httpcaddyfile/options.go | |
parent | 4c55d26f11329243591d04ca5a52298b38bca9a8 (diff) | |
download | caddy-dc9f4f13fc1cc102c713c69ded295b3fcf685e96.tar.gz caddy-dc9f4f13fc1cc102c713c69ded295b3fcf685e96.zip |
httpcaddyfile: Make global options pluggable (#3265)
* httpcaddyfile: Make global options pluggable
* httpcaddyfile: Add a global options adapt test
* httpcaddyfile: Wrap err
Co-Authored-By: Dave Henderson <[email protected]>
* httpcaddyfile: Revert wrap err
Co-authored-by: Dave Henderson <[email protected]>
Diffstat (limited to 'caddyconfig/httpcaddyfile/options.go')
-rw-r--r-- | caddyconfig/httpcaddyfile/options.go | 40 |
1 files changed, 29 insertions, 11 deletions
diff --git a/caddyconfig/httpcaddyfile/options.go b/caddyconfig/httpcaddyfile/options.go index 2ab73b24c..de288db91 100644 --- a/caddyconfig/httpcaddyfile/options.go +++ b/caddyconfig/httpcaddyfile/options.go @@ -23,7 +23,29 @@ import ( "github.com/caddyserver/caddy/v2/modules/caddytls" ) -func parseOptHTTPPort(d *caddyfile.Dispenser) (int, error) { +func init() { + RegisterGlobalOption("debug", parseOptTrue) + RegisterGlobalOption("http_port", parseOptHTTPPort) + RegisterGlobalOption("https_port", parseOptHTTPSPort) + RegisterGlobalOption("default_sni", parseOptSingleString) + RegisterGlobalOption("order", parseOptOrder) + RegisterGlobalOption("experimental_http3", parseOptTrue) + RegisterGlobalOption("storage", parseOptStorage) + RegisterGlobalOption("acme_ca", parseOptSingleString) + RegisterGlobalOption("acme_dns", parseOptSingleString) + RegisterGlobalOption("acme_ca_root", parseOptSingleString) + RegisterGlobalOption("email", parseOptSingleString) + RegisterGlobalOption("admin", parseOptAdmin) + RegisterGlobalOption("on_demand_tls", parseOptOnDemand) + RegisterGlobalOption("local_certs", parseOptTrue) + RegisterGlobalOption("key_type", parseOptSingleString) +} + +func parseOptTrue(d *caddyfile.Dispenser) (interface{}, error) { + return true, nil +} + +func parseOptHTTPPort(d *caddyfile.Dispenser) (interface{}, error) { var httpPort int for d.Next() { var httpPortStr string @@ -39,7 +61,7 @@ func parseOptHTTPPort(d *caddyfile.Dispenser) (int, error) { return httpPort, nil } -func parseOptHTTPSPort(d *caddyfile.Dispenser) (int, error) { +func parseOptHTTPSPort(d *caddyfile.Dispenser) (interface{}, error) { var httpsPort int for d.Next() { var httpsPortStr string @@ -55,11 +77,7 @@ func parseOptHTTPSPort(d *caddyfile.Dispenser) (int, error) { return httpsPort, nil } -func parseOptExperimentalHTTP3(d *caddyfile.Dispenser) (bool, error) { - return true, nil -} - -func parseOptOrder(d *caddyfile.Dispenser) ([]string, error) { +func parseOptOrder(d *caddyfile.Dispenser) (interface{}, error) { newOrder := directiveOrder for d.Next() { @@ -135,7 +153,7 @@ func parseOptOrder(d *caddyfile.Dispenser) ([]string, error) { return newOrder, nil } -func parseOptStorage(d *caddyfile.Dispenser) (caddy.StorageConverter, error) { +func parseOptStorage(d *caddyfile.Dispenser) (interface{}, error) { if !d.Next() { // consume option name return nil, d.ArgErr() } @@ -162,7 +180,7 @@ func parseOptStorage(d *caddyfile.Dispenser) (caddy.StorageConverter, error) { return storage, nil } -func parseOptSingleString(d *caddyfile.Dispenser) (string, error) { +func parseOptSingleString(d *caddyfile.Dispenser) (interface{}, error) { d.Next() // consume parameter name if !d.Next() { return "", d.ArgErr() @@ -174,7 +192,7 @@ func parseOptSingleString(d *caddyfile.Dispenser) (string, error) { return val, nil } -func parseOptAdmin(d *caddyfile.Dispenser) (string, error) { +func parseOptAdmin(d *caddyfile.Dispenser) (interface{}, error) { if d.Next() { var listenAddress string if !d.AllArgs(&listenAddress) { @@ -188,7 +206,7 @@ func parseOptAdmin(d *caddyfile.Dispenser) (string, error) { return "", nil } -func parseOptOnDemand(d *caddyfile.Dispenser) (*caddytls.OnDemandConfig, error) { +func parseOptOnDemand(d *caddyfile.Dispenser) (interface{}, error) { var ond *caddytls.OnDemandConfig for d.Next() { if d.NextArg() { |