Make necessary maps in non-empty names before copy

This commit is contained in:
RPRX 2021-01-15 11:36:31 +00:00 committed by GitHub
parent f0efc0cfde
commit 88f6537540
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -109,6 +109,17 @@ func New(ctx context.Context, config *Config, dc dns.Client) (*Handler, error) {
} }
*/ */
} }
if handler.fallbacks[""] != nil {
for name, apfb := range handler.fallbacks {
if name != "" {
for alpn := range handler.fallbacks[""] {
if apfb[alpn] == nil {
apfb[alpn] = make(map[string]*Fallback)
}
}
}
}
}
for _, apfb := range handler.fallbacks { for _, apfb := range handler.fallbacks {
if apfb[""] != nil { if apfb[""] != nil {
for alpn, pfb := range apfb { for alpn, pfb := range apfb {
@ -126,9 +137,6 @@ func New(ctx context.Context, config *Config, dc dns.Client) (*Handler, error) {
for name, apfb := range handler.fallbacks { for name, apfb := range handler.fallbacks {
if name != "" { if name != "" {
for alpn, pfb := range handler.fallbacks[""] { for alpn, pfb := range handler.fallbacks[""] {
if apfb[alpn] == nil {
apfb[alpn] = make(map[string]*Fallback)
}
for path, fb := range pfb { for path, fb := range pfb {
if apfb[alpn][path] == nil { if apfb[alpn][path] == nil {
apfb[alpn][path] = fb apfb[alpn][path] = fb