fix(8201): restore old behavior forward plugin continue on empty conf file (#8203)

This commit is contained in:
Antoine
2026-07-02 08:11:37 +02:00
committed by GitHub
parent 8d94712f99
commit 3a4b87bdb4
4 changed files with 34 additions and 10 deletions

View File

@@ -54,7 +54,7 @@ func HostPortOrFile(s ...string) ([]string, error) {
servers = append(servers, ss...)
continue
}
return servers, fmt.Errorf("not an IP address or file: %q", host)
return servers, fmt.Errorf("not an IP address or file %q: %w", host, err)
}
var ss string
switch trans {
@@ -79,7 +79,7 @@ func HostPortOrFile(s ...string) ([]string, error) {
servers = append(servers, ss...)
continue
}
return servers, fmt.Errorf("not an IP address or file: %q", host)
return servers, fmt.Errorf("not an IP address or file %q: %w", host, err)
}
servers = append(servers, h)
}
@@ -92,13 +92,13 @@ func HostPortOrFile(s ...string) ([]string, error) {
// Try to open this is a file first.
func tryFile(s string) ([]string, error) {
c, err := dns.ClientConfigFromFile(s)
if err == os.ErrNotExist {
if errors.Is(err, os.ErrNotExist) {
return nil, fmt.Errorf("failed to open file %q: %q", s, err)
} else if err != nil {
return nil, err
}
servers := []string{}
var servers []string
for _, s := range c.Servers {
servers = append(servers, net.JoinHostPort(stripZone(s), c.Port))
}