summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Fifield <david@bamsoftware.com>2020-02-19 10:44:35 -0700
committerDavid Fifield <david@bamsoftware.com>2020-02-22 16:16:03 -0700
commit924593615c5a8fca7e0d9b4c0fafbd143db1bb62 (patch)
treed6c87bcac75d875e696c6bedc7456dea2510e0b6
parent42c07f2c140e4c6f1f752329a67fdf15cd6bd8c5 (diff)
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
-rw-r--r--server/server.go5
-rw-r--r--server/server_test.go2
2 files changed, 7 insertions, 0 deletions
diff --git a/server/server.go b/server/server.go
index 96904f8..7db36d1 100644
--- a/server/server.go
+++ b/server/server.go
@@ -113,6 +113,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 != "" {