mirror of
https://github.com/coredns/coredns.git
synced 2026-03-03 03:13:10 -05:00
plugin/forward: fix parsing error when handling TLS+IPv6 address (#7848)
This commit is contained in:
@@ -99,17 +99,28 @@ func parseForward(c *caddy.Controller) ([]*Forward, error) {
|
||||
|
||||
// Splits the zone, preserving any port that comes after the zone
|
||||
func splitZone(host string) (newHost string, zone string) {
|
||||
trans, host, found := strings.Cut(host, "://")
|
||||
if !found {
|
||||
host, trans = trans, ""
|
||||
}
|
||||
newHost = host
|
||||
if strings.Contains(host, "%") {
|
||||
lastPercent := strings.LastIndex(host, "%")
|
||||
newHost = host[:lastPercent]
|
||||
if strings.HasPrefix(newHost, "[") {
|
||||
newHost = newHost + "]"
|
||||
}
|
||||
zone = host[lastPercent+1:]
|
||||
if strings.Contains(zone, ":") {
|
||||
lastColon := strings.LastIndex(zone, ":")
|
||||
newHost += zone[lastColon:]
|
||||
zone = zone[:lastColon]
|
||||
zone = strings.TrimSuffix(zone, "]")
|
||||
}
|
||||
}
|
||||
if trans != "" {
|
||||
newHost = trans + "://" + newHost
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user