mirror of
https://github.com/caddyserver/caddy.git
synced 2026-07-10 10:54:28 +00:00
Move fallbackHosts to vhostTrie
This commit is contained in:
parent
4991d702fd
commit
a197c864e8
3 changed files with 20 additions and 11 deletions
|
|
@ -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
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue