IPv6 upstream support

This commit is contained in:
Michael Egner 2020-05-08 16:06:14 +02:00
parent 313b8af18b
commit cc87d1507d
2 changed files with 5 additions and 1 deletions

View File

@ -53,7 +53,7 @@ func ParseUpstream(upstream string) (result Upstream, err error) {
return Upstream{}, nil
}
r := regexp.MustCompile(`(?P<Net>[^\s:]*):/?/?(?P<Host>[^\s/:]*):?(?P<Port>[^\s/:]*)?(?P<Path>/[^\s]*)?`)
r := regexp.MustCompile(`(?P<Net>[^\s:]*):/?/?(?P<Host>(?:\[[^\]]+\])|[^\s/:]+):?(?P<Port>[^\s/:]*)?(?P<Path>/[^\s]*)?`)
match := r.FindStringSubmatch(upstream)

View File

@ -131,6 +131,10 @@ var _ = Describe("Config", func() {
"",
Upstream{Net: ""},
false),
Entry("udpIpv6WithPort",
"udp:[fd00::6cd4:d7e0:d99d:2952]:53",
Upstream{Net: "udp", Host: "[fd00::6cd4:d7e0:d99d:2952]", Port: 53},
false),
Entry("without host",
"tcp::53",
nil,