Use new MaxMind env vars on Labrinth (#4573)

* Bring in modrinth-maxmind

* integrate modrinth-maxmind into labrinth

* Fix CI
This commit is contained in:
aecsocket
2025-10-18 11:38:19 -07:00
committed by GitHub
parent d1ffed564d
commit fa7d1d7942
17 changed files with 655 additions and 111 deletions

View File

@@ -0,0 +1,35 @@
//! Example/testing binary for checking if a MaxMind database can be loaded from
//! the current environment.
use std::net::IpAddr;
use eyre::Result;
use maxminddb::geoip2;
use modrinth_util::Context;
use tracing::info;
/// Looks up country details for an IP using the MaxMind database
#[derive(Debug, clap::Parser)]
struct Args {
/// IP address to look up
ip: IpAddr,
}
#[tokio::main]
async fn main() -> Result<()> {
let args = <Args as clap::Parser>::parse();
tracing_subscriber::fmt().init();
let maxmind = modrinth_maxmind::init_reader()
.await
.wrap_err("failed to create reader")?;
let ip = args.ip;
let country = maxmind
.lookup::<geoip2::Country>(ip)
.wrap_err("failed to lookup country")?;
info!("Country details for {ip:?}:\n{country:#?}");
Ok(())
}