kitten/hints/marks support for IPv6 addresses ending in ::

IPv6 addresses can end in zeros, and for example ifconfig.me is at
2600:1901:0:b2bd::.
This commit is contained in:
Carl Lei
2025-11-27 09:34:12 +08:00
parent 438114d880
commit 505a0e15cd
2 changed files with 2 additions and 1 deletions

View File

@@ -375,7 +375,7 @@ func functions_for(opts *Options) (pattern string, post_processors []PostProcess
// IPv4 with no validation
`((?:\d{1,3}\.){3}\d{1,3}` + "|" +
// IPv6 with no validation
`(?:[a-fA-F0-9]{0,4}:){2,7}[a-fA-F0-9]{1,4})`)
`(?:[a-fA-F0-9]{0,4}:){2,7}[a-fA-F0-9]{0,4})`)
post_processors = append(post_processors, PostProcessorMap()["ip"])
default:
pattern = opts.Regex

View File

@@ -104,6 +104,7 @@ func TestHintMarking(t *testing.T) {
r(`2001:db8::ff00:42:8329`, `2001:db8::ff00:42:8329`)
r(`2001:DB8::FF00:42:8329`, `2001:DB8::FF00:42:8329`)
r(`0000:0000:0000:0000:0000:0000:0000:0001`, `0000:0000:0000:0000:0000:0000:0000:0001`)
r(`2600:1901:0:b2bd::`, `2600:1901:0:b2bd::`) // ifconfig.me
r(`::1`, `::1`)
r(`255.255.255.256`)
r(`:1`)