commit c124e8c643f2de5730af9079d326b9cabc3b264a Author: David Fifield david@bamsoftware.com Date: Wed Feb 19 10:44:35 2020 -0700
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 --- server/server.go | 5 +++++ server/server_test.go | 2 ++ 2 files changed, 7 insertions(+)
diff --git a/server/server.go b/server/server.go index c484a19..6e9fb19 100644 --- a/server/server.go +++ b/server/server.go @@ -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() } diff --git a/server/server_test.go b/server/server_test.go index d4ada6e..ba00d16 100644 --- a/server/server_test.go +++ b/server/server_test.go @@ -46,6 +46,8 @@ func TestClientAddr(t *testing.T) { "abc", "1.2.3.4.5", "[12::34]", + "0.0.0.0", + "[::]", } { useraddr := clientAddr(input) if useraddr != "" {
tor-commits@lists.torproject.org