mirror of
https://github.com/caddyserver/caddy.git
synced 2026-05-25 00:46:07 -04:00
Move fallbackHosts to vhostTrie
This commit is contained in:
@@ -57,6 +57,16 @@ func makeTLSConfig(group []*SiteConfig) (*tls.Config, error) {
|
||||
return caddytls.MakeTLSConfig(tlsConfigs)
|
||||
}
|
||||
|
||||
func getFallbacks(sites []*SiteConfig) []string {
|
||||
fallbacks := []string{}
|
||||
for _, sc := range sites {
|
||||
if sc.FallbackSite {
|
||||
fallbacks = append(fallbacks, sc.Addr.Host)
|
||||
}
|
||||
}
|
||||
return fallbacks
|
||||
}
|
||||
|
||||
// NewServer creates a new Server instance that will listen on addr
|
||||
// and will serve the sites configured in group.
|
||||
func NewServer(addr string, group []*SiteConfig) (*Server, error) {
|
||||
@@ -66,6 +76,7 @@ func NewServer(addr string, group []*SiteConfig) (*Server, error) {
|
||||
sites: group,
|
||||
connTimeout: GracefulTimeout,
|
||||
}
|
||||
s.vhosts.fallbackHosts = append(s.vhosts.fallbackHosts, getFallbacks(group)...)
|
||||
s.Server = makeHTTPServerWithHeaderLimit(s.Server, group)
|
||||
s.Server.Handler = s // this is weird, but whatever
|
||||
|
||||
|
||||
Reference in New Issue
Block a user