mirror of
https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake.git
synced 2025-10-13 20:11:19 -04:00
change regexes for ipv6 addresses to catch url-encoded addresses
This commit is contained in:
parent
4ebd85e5d1
commit
90d1a56719
2 changed files with 10 additions and 2 deletions
|
@ -11,8 +11,11 @@ import (
|
|||
)
|
||||
|
||||
const ipv4Address = `\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}`
|
||||
const ipv6Address = `([0-9a-fA-F]{0,4}:){5,7}([0-9a-fA-F]{0,4})?`
|
||||
const ipv6Compressed = `([0-9a-fA-F]{0,4}:){0,5}([0-9a-fA-F]{0,4})?(::)([0-9a-fA-F]{0,4}:){0,5}([0-9a-fA-F]{0,4})?`
|
||||
|
||||
// %3A and %3a are for matching : in URL-encoded IPv6 addresses
|
||||
const colon = `(:|%3a|%3A)`
|
||||
const ipv6Address = `([0-9a-fA-F]{0,4}` + colon + `){5,7}([0-9a-fA-F]{0,4})?`
|
||||
const ipv6Compressed = `([0-9a-fA-F]{0,4}` + colon + `){0,5}([0-9a-fA-F]{0,4})?(` + colon + `){2}([0-9a-fA-F]{0,4}` + colon + `){0,5}([0-9a-fA-F]{0,4})?`
|
||||
const ipv6Full = `(` + ipv6Address + `(` + ipv4Address + `))` +
|
||||
`|(` + ipv6Compressed + `(` + ipv4Address + `))` +
|
||||
`|(` + ipv6Address + `)` + `|(` + ipv6Compressed + `)`
|
||||
|
|
|
@ -77,6 +77,11 @@ func TestLogScrubberMessages(t *testing.T) {
|
|||
"2019/05/08 15:37:31 starting",
|
||||
"2019/05/08 15:37:31 starting\n",
|
||||
},
|
||||
{
|
||||
//Make sure ipv6 addresses where : are encoded as %3A or %3a are scrubbed
|
||||
"error dialing relay: wss://snowflake.torproject.net/?client_ip=6201%3ac8%3A3004%3A%3A1234",
|
||||
"error dialing relay: wss://snowflake.torproject.net/?client_ip=[scrubbed]\n",
|
||||
},
|
||||
} {
|
||||
var buff bytes.Buffer
|
||||
log.SetFlags(0) //remove all extra log output for test comparisons
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue