feat(cli): add --geo flag for client location tracking#166
feat(cli): add --geo flag for client location tracking#166ssmirr wants to merge 1 commit intoPsiphon-Inc:mainfrom
Conversation
* feat(cli): add --geo flag for client location tracking
Adds optional geo tracking via tcpdump + geoiplookup.
When enabled, stats.json includes country breakdown.
Usage: conduit start --geo --stats-file
* fix: simplify isPrivateIP check
* Replace tcpdump-based geo tracking with GeoIP2 database
Replaces external tcpdump + geoiplookup dependencies with pure Go
implementation using MaxMind GeoLite2 database. No sudo required,
cross-platform, all 249 countries supported.
Connection tracking flow:
Connect ──► OnConnectionEstablished ──► ConnectIP(ip)
│
▼
GeoIP2 lookup + live++
│
│ (connection active...)
│
Close ───► OnConnectionClosed ──► DisconnectIP(ip, bytesUp, bytesDown)
│
▼
live-- + accumulate bytes
Stats per country:
- count: currently connected (live)
- count_total: unique IPs since start
- bytes_up/down: total bandwidth since start
TURN relay connections tracked as code=RELAY (country unknown).
Example stats.json geo output:
{
"geo": [
{
"code": "IR",
"country": "Iran",
"count": 3,
"count_total": 47,
"bytes_up": 524288000,
"bytes_down": 2684354560
},
{
"code": "RELAY",
"country": "Unknown (TURN Relay)",
"count": 1,
"count_total": 8,
"bytes_up": 52428800,
"bytes_down": 268435456
}
]
}
* Update README: geo tracking no longer requires tcpdump/sudo
* Document geo stats behavior and remove debug logging
---------
Co-authored-by: Samim Mirhosseini <ssmirr@users.noreply.github.com>
| # Using ssmirr fork with OnConnectionEstablished callback until upstreamed | ||
| PSIPHON_BRANCH ?= feat/inproxy-client-connected-callback | ||
| PSIPHON_REPO := https://github.com/ssmirr/psiphon-tunnel-core.git |
There was a problem hiding this comment.
Please note this PR requires a few (mostly minimal changes) in the psiphon-tunnel-core repo. Here you can see the changes: https://github.com/Psiphon-Labs/psiphon-tunnel-core/compare/staging-client...ssmirr:psiphon-tunnel-core:feat/inproxy-client-connected-callback?expand=1
If you are interested in merging this geo PR. we will need those changes to be also merged. I don't seem to have access for opening a pull request on that repository, so will need help.
|
wonder what the path is to getting OnInproxyConnectionEstablished / OnInproxyConnectionClosed merged upstream |
|
Much needed feature! |
|
Hi, thanks for preparing this. We can actually achieve this without needing to do a conduit-side Geo-IP lookup, we just need to thread some more stats through from the brokers. We are working on this. I will update here when it is ready for integration in this repo. |
|
That makes sense and I agree that's a better place for it if it can be added! Looking forward to your update, and then happy to integrate it in the cli and prom metrics. |
Hey team! Would you be interested in something like this?
This adds an optional
--geoflag that enables tracking which countries connected clients are from using a GeoIP2 database. It's useful for proxy operators who want visibility into who they're helping.Key points:
--geoflag - no behavior change without itHappy to iterate on the implementation if there's interest!
//cc @tmgrask
PS. already signed CLA in a previous contribution.