Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: Log client IP during REST and Electrum requests #55

Open
wants to merge 6 commits into
base: mempool
Choose a base branch
from

Conversation

junderw
Copy link
Sponsor Member

@junderw junderw commented Sep 30, 2023

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.

@junderw junderw force-pushed the junderw/log-client-ip branch 7 times, most recently from 904419c to 6855c56 Compare October 7, 2023 08:21
@junderw junderw marked this pull request as draft October 7, 2023 08:37
@junderw junderw marked this pull request as ready for review October 7, 2023 23:45
@junderw junderw force-pushed the junderw/log-client-ip branch 3 times, most recently from 255767b to 353cb93 Compare October 9, 2023 01:36
src/electrum/server.rs Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants