electrs
electrs copied to clipboard
Feat: Log client IP during REST and Electrum requests
This PR adds the ability to log client IPs proxied through nginx during the REST and RPC logs.
- For RPC, we use the PROXY protocol. (nginx only supports v1, but electrum RPC supports parsing (and discarding) v1 and v2 PROXY headers.
- For REST, we use X-Forwarded-For request header that is added by nginx. Following the spec, it joins together all instances of the header values with a comma, then splits all the entries by commas, and returns the first valid IP address. (I think nginx should put its header first, so there should be no problem with clients adding dishonest XFF headers.
There are also some minor bug fixes related to dead locks in the RPC logic.