Increase `clientIDAddrMapCapacity` in snowflake-server
The snowflake PT server has a data structure clientIDAddrMap
that conveys client IP addresses from the outer HTTPS "transport" layer and the inner KCP layer that actually talks to tor.
// clientIDAddrMap stores short-term mappings from ClientIDs to IP addresses.
// When we call pt.DialOr, tor wants us to provide a USERADDR string that
// represents the remote IP address of the client (for metrics purposes, etc.).
// This data structure bridges the gap between ServeHTTP, which knows about IP
// addresses, and handleStream, which is what calls pt.DialOr. The common piece
// of information linking both ends of the chain is the ClientID, which is
// attached to the WebSocket connection and every session.
var clientIDAddrMap = newClientIDMap(clientIDAddrMapCapacity)
With the recent increase in Snowflake users, the number of client is tending to exceed the capacity of the map. The server is logging the following error, which is from here:
2021/12/21 17:04:59 no address in clientID-to-IP map (capacity 1024)
So we need to increase the fixed size of the mapping, clientIDAddrMapCapacity
. Maybe from 1k to 10k.
The occurrences of the log message seem to be increasing. I initially thought this problem might be the cause of the apparent dip in users from #40060 (comment 2767868), but I don't see an especially large count on 2021/12/19. The large count on 2021/12/21 may be because of the restart in #40060 (comment 2767868).
# zgrep -h clientID-to-IP /var/log/tor/snowflake-server.log* | awk '{print $1}' | sort | uniq -c | tail -n 20
1 2021/12/02
14 2021/12/03
10 2021/12/04
20 2021/12/05
8 2021/12/06
15 2021/12/07
26 2021/12/08
30 2021/12/09
6 2021/12/10
8 2021/12/11
31 2021/12/12
36 2021/12/13
46 2021/12/14
52 2021/12/15
47 2021/12/16
48 2021/12/17
33 2021/12/18
49 2021/12/19
63 2021/12/20
464 2021/12/21
Our current log rotation has logs going back to 2021/06/21, but the first occurrence of the clientID-to-IP log message is on 2021/07/23.
1 2021/07/23
2 2021/07/29
2 2021/07/30
5 2021/07/31
1 2021/08/01
6 2021/08/03
8 2021/08/05
14 2021/08/10
2 2021/08/14
1 2021/08/15
1 2021/08/18