Skip to content

feat: add per-user unique IPs metric for key sharing detection#320

Open
oruchkin wants to merge 1 commit intoalexbers:masterfrom
oruchkin:feature/per-user-unique-ips
Open

feat: add per-user unique IPs metric for key sharing detection#320
oruchkin wants to merge 1 commit intoalexbers:masterfrom
oruchkin:feature/per-user-unique-ips

Conversation

@oruchkin
Copy link
Copy Markdown

@oruchkin oruchkin commented Mar 5, 2026

Add mtprotoproxy_user_unique_ips gauge metric that tracks the number of unique source IPs currently connected per user/secret.

This helps proxy operators detect key sharing - if a single secret has connections from many different IPs, it likely means the key was shared with multiple people.

Changes:

  • Track active connections per (user, source_ip) pair
  • Export user_unique_ips gauge via Prometheus metrics endpoint
  • Zero overhead: single dict lookup per connect/disconnect

Usage

Prometheus / Grafana

Query to monitor unique IPs per user:

mtprotoproxy_user_unique_ips

Add mtprotoproxy_user_unique_ips gauge metric that tracks the number
of unique source IPs currently connected per user/secret.

This helps proxy operators detect key sharing - if a single secret
has connections from many different IPs, it likely means the key
was shared with multiple people.

Changes:
- Track active connections per (user, source_ip) pair
- Export user_unique_ips gauge via Prometheus metrics endpoint
- Zero overhead: single dict lookup per connect/disconnect
@oruchkin
Copy link
Copy Markdown
Author

oruchkin commented Mar 5, 2026

This is how it works in Grafana:
Screenshot 2026-03-05 at 12 24 48

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant