Okay I found the cause of the stats bug and it's unrelated to the memory bug. It happens because we're calling the
clientAddr function twice:
The first time we call this function, it turns
188.8.131.52 into a
ClientMapAddr that wraps a
net.TCPAddr. When we call
String() on this, it produces something like
184.108.40.206:1 (note the port). Then when we call
clientAddr(220.127.116.11:1) it returns an empty string because the call to
nil because it's not an IP address.
There are multiple ways to solve this issue. I opted to just store values in the clientIDMap as
net.Addr instead of strings, since we convert them to
net.Addr before storing them in the map, and after we take them out of the map we convert them back into a
net.Addr anyway. However, we could solve this by changing how the
clientAddr function works instead.