forked from TrueCloudLab/distribution
registry: support ipv6 addresses
Current registry reference use a subset of dns and IPv4 addresses to represent a registry domain. Since registries are mostly compatible with rfc3986, that defines the URI generic syntax, this adds support for IPv6 enclosed in squared brackets based on the mentioned rfc. The regexp is only expanded to match on IPv6 addreses enclosed between square brackets, considering only regular IPv6 addresses represented as compressed or uncompressed, excluding special IPv6 address representations. Signed-off-by: Antonio Ojea <antonio.ojea.garcia@gmail.com>
This commit is contained in:
parent
3e4f8a0ab1
commit
53a6f7d7aa
5 changed files with 181 additions and 7 deletions
|
@ -115,6 +115,46 @@ func TestDomainRegexp(t *testing.T) {
|
|||
input: "Asdf.com", // uppercase character
|
||||
match: true,
|
||||
},
|
||||
{
|
||||
input: "192.168.1.1:75050", // ipv4
|
||||
match: true,
|
||||
},
|
||||
{
|
||||
input: "192.168.1.1:750050", // port with more than 5 digits, it will fail on validation
|
||||
match: true,
|
||||
},
|
||||
{
|
||||
input: "[fd00:1:2::3]:75050", // ipv6 compressed
|
||||
match: true,
|
||||
},
|
||||
{
|
||||
input: "[fd00:1:2::3]75050", // ipv6 wrong port separator
|
||||
match: false,
|
||||
},
|
||||
{
|
||||
input: "[fd00:1:2::3]::75050", // ipv6 wrong port separator
|
||||
match: false,
|
||||
},
|
||||
{
|
||||
input: "[fd00:1:2::3%eth0]:75050", // ipv6 with zone
|
||||
match: false,
|
||||
},
|
||||
{
|
||||
input: "[fd00123123123]:75050", // ipv6 wrong format, will fail in validation
|
||||
match: true,
|
||||
},
|
||||
{
|
||||
input: "[2001:0db8:85a3:0000:0000:8a2e:0370:7334]:75050", // ipv6 long format
|
||||
match: true,
|
||||
},
|
||||
{
|
||||
input: "[2001:0db8:85a3:0000:0000:8a2e:0370:7334]:750505", // ipv6 long format and invalid port, it will fail in validation
|
||||
match: true,
|
||||
},
|
||||
{
|
||||
input: "fd00:1:2::3:75050", // bad ipv6 without square brackets
|
||||
match: false,
|
||||
},
|
||||
}
|
||||
r := regexp.MustCompile(`^` + DomainRegexp.String() + `$`)
|
||||
for i := range hostcases {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue