2015-05-04 12:04:17 -05:00
|
|
|
package server
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net"
|
|
|
|
|
|
|
|
"github.com/mholt/caddy/middleware"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Config configuration for a single server.
|
|
|
|
type Config struct {
|
|
|
|
// The hostname or IP on which to serve
|
|
|
|
Host string
|
|
|
|
|
2015-05-05 00:58:08 -05:00
|
|
|
// The host address to bind on - defaults to (virtual) Host if empty
|
|
|
|
BindHost string
|
2015-05-04 23:38:49 -05:00
|
|
|
|
2015-05-04 12:04:17 -05:00
|
|
|
// The port to listen on
|
|
|
|
Port string
|
|
|
|
|
|
|
|
// The directory from which to serve files
|
|
|
|
Root string
|
|
|
|
|
|
|
|
// HTTPS configuration
|
|
|
|
TLS TLSConfig
|
|
|
|
|
|
|
|
// Middleware stack; map of path scope to middleware -- TODO: Support path scope?
|
|
|
|
Middleware map[string][]middleware.Middleware
|
|
|
|
|
|
|
|
// Functions (or methods) to execute at server start; these
|
|
|
|
// are executed before any parts of the server are configured,
|
|
|
|
// and the functions are blocking
|
|
|
|
Startup []func() error
|
|
|
|
|
|
|
|
// Functions (or methods) to execute when the server quits;
|
|
|
|
// these are executed in response to SIGINT and are blocking
|
|
|
|
Shutdown []func() error
|
|
|
|
|
|
|
|
// The path to the configuration file from which this was loaded
|
|
|
|
ConfigFile string
|
2015-05-04 17:23:16 -05:00
|
|
|
|
|
|
|
// The name of the application
|
|
|
|
AppName string
|
|
|
|
|
|
|
|
// The application's version
|
|
|
|
AppVersion string
|
2015-05-04 12:04:17 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
// Address returns the host:port of c as a string.
|
|
|
|
func (c Config) Address() string {
|
|
|
|
return net.JoinHostPort(c.Host, c.Port)
|
|
|
|
}
|
|
|
|
|
2015-10-16 12:38:56 -05:00
|
|
|
// TLSConfig describes how TLS should be configured and used.
|
2015-05-04 12:04:17 -05:00
|
|
|
type TLSConfig struct {
|
2015-05-21 11:37:39 -05:00
|
|
|
Enabled bool
|
|
|
|
Certificate string
|
|
|
|
Key string
|
2015-10-16 12:38:56 -05:00
|
|
|
LetsEncryptEmail string
|
2015-10-23 21:36:54 -05:00
|
|
|
OCSPStaple []byte
|
2015-05-21 11:37:39 -05:00
|
|
|
Ciphers []uint16
|
|
|
|
ProtocolMinVersion uint16
|
|
|
|
ProtocolMaxVersion uint16
|
|
|
|
PreferServerCipherSuites bool
|
2015-06-02 00:22:11 -05:00
|
|
|
ClientCerts []string
|
2015-05-04 12:04:17 -05:00
|
|
|
}
|