In server, treat a client IP address of 0.0.0.0 as missing.

Some proxies currently send ?client_ip=0.0.0.0 because of an error in
how they attempt to grep the address from the client's SDP. That's
inflating our "%d/%d connections had client_ip" logs. Instead, treat
these cases as if the IP address were absent.
https://bugs.torproject.org/33157
https://bugs.torproject.org/33385
This commit is contained in:
David Fifield 2020-02-19 10:44:35 -07:00
parent 380b133155
commit c124e8c643
2 changed files with 7 additions and 0 deletions

View file

@ -88,6 +88,11 @@ func clientAddr(clientIPParam string) string {
if clientIP == nil {
return ""
}
// Check if client addr is 0.0.0.0 or [::]. Some proxies erroneously
// report an address of 0.0.0.0: https://bugs.torproject.org/33157.
if clientIP.IsUnspecified() {
return ""
}
// Add a dummy port number. USERADDR requires a port number.
return (&net.TCPAddr{IP: clientIP, Port: 1, Zone: ""}).String()
}