mirror of
https://github.com/caddyserver/caddy.git
synced 2024-12-02 05:33:38 +08:00
d8391d6fbd
Addresses which fail to resolve are handled more gracefully in the two most common cases: the hostname doesn't resolve or the port is unknown (like "http" on a system that doesn't support that port name). If the hostname doesn't resolve, the host is served on the listener at host 0.0.0.0. If the port is unknown, we attempt to rewrite it as a number manually and try again.
66 lines
1.6 KiB
Go
66 lines
1.6 KiB
Go
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
|
|
|
|
// The host address to bind on - defaults to (virtual) Host if empty
|
|
BindHost string
|
|
|
|
// 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
|
|
|
|
// The name of the application
|
|
AppName string
|
|
|
|
// The application's version
|
|
AppVersion string
|
|
}
|
|
|
|
// Address returns the host:port of c as a string.
|
|
func (c Config) Address() string {
|
|
return net.JoinHostPort(c.Host, c.Port)
|
|
}
|
|
|
|
// TLSConfig describes how TLS should be configured and used,
|
|
// if at all. A certificate and key are both required.
|
|
// The rest is optional.
|
|
type TLSConfig struct {
|
|
Enabled bool
|
|
Certificate string
|
|
Key string
|
|
Ciphers []uint16
|
|
ProtocolMinVersion uint16
|
|
ProtocolMaxVersion uint16
|
|
PreferServerCipherSuites bool
|
|
ClientCerts []string
|
|
}
|