@ -23,7 +23,29 @@ import (
"github.com/caddyserver/caddy/v2/modules/caddytls"
"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
var httpPort int
for d . Next ( ) {
for d . Next ( ) {
var httpPortStr string
var httpPortStr string
@ -39,7 +61,7 @@ func parseOptHTTPPort(d *caddyfile.Dispenser) (int, error) {
return httpPort , nil
return httpPort , nil
}
}
func parseOptHTTPSPort ( d * caddyfile . Dispenser ) ( int , error ) {
func parseOptHTTPSPort ( d * caddyfile . Dispenser ) ( interface { } , error ) {
var httpsPort int
var httpsPort int
for d . Next ( ) {
for d . Next ( ) {
var httpsPortStr string
var httpsPortStr string
@ -55,11 +77,7 @@ func parseOptHTTPSPort(d *caddyfile.Dispenser) (int, error) {
return httpsPort , nil
return httpsPort , nil
}
}
func parseOptExperimentalHTTP3 ( d * caddyfile . Dispenser ) ( bool , error ) {
func parseOptOrder ( d * caddyfile . Dispenser ) ( interface { } , error ) {
return true , nil
}
func parseOptOrder ( d * caddyfile . Dispenser ) ( [ ] string , error ) {
newOrder := directiveOrder
newOrder := directiveOrder
for d . Next ( ) {
for d . Next ( ) {
@ -135,7 +153,7 @@ func parseOptOrder(d *caddyfile.Dispenser) ([]string, error) {
return newOrder , nil
return newOrder , nil
}
}
func parseOptStorage ( d * caddyfile . Dispenser ) ( caddy . StorageConverter , error ) {
func parseOptStorage ( d * caddyfile . Dispenser ) ( interface { } , error ) {
if ! d . Next ( ) { // consume option name
if ! d . Next ( ) { // consume option name
return nil , d . ArgErr ( )
return nil , d . ArgErr ( )
}
}
@ -162,7 +180,7 @@ func parseOptStorage(d *caddyfile.Dispenser) (caddy.StorageConverter, error) {
return storage , nil
return storage , nil
}
}
func parseOptSingleString ( d * caddyfile . Dispenser ) ( string , error ) {
func parseOptSingleString ( d * caddyfile . Dispenser ) ( interface { } , error ) {
d . Next ( ) // consume parameter name
d . Next ( ) // consume parameter name
if ! d . Next ( ) {
if ! d . Next ( ) {
return "" , d . ArgErr ( )
return "" , d . ArgErr ( )
@ -174,7 +192,7 @@ func parseOptSingleString(d *caddyfile.Dispenser) (string, error) {
return val , nil
return val , nil
}
}
func parseOptAdmin ( d * caddyfile . Dispenser ) ( string , error ) {
func parseOptAdmin ( d * caddyfile . Dispenser ) ( interface { } , error ) {
if d . Next ( ) {
if d . Next ( ) {
var listenAddress string
var listenAddress string
if ! d . AllArgs ( & listenAddress ) {
if ! d . AllArgs ( & listenAddress ) {
@ -188,7 +206,7 @@ func parseOptAdmin(d *caddyfile.Dispenser) (string, error) {
return "" , nil
return "" , nil
}
}
func parseOptOnDemand ( d * caddyfile . Dispenser ) ( * caddytls . OnDemandConfig , error ) {
func parseOptOnDemand ( d * caddyfile . Dispenser ) ( interface { } , error ) {
var ond * caddytls . OnDemandConfig
var ond * caddytls . OnDemandConfig
for d . Next ( ) {
for d . Next ( ) {
if d . NextArg ( ) {
if d . NextArg ( ) {