diff --git a/src/handlers.rs b/src/handlers.rs index ce8bf56..657eeed 100644 --- a/src/handlers.rs +++ b/src/handlers.rs @@ -6,13 +6,13 @@ use axum::extract::{Path, Query, State}; use axum::http::{HeaderMap, StatusCode, header}; use axum::response::{Html, IntoResponse, Redirect, Response}; -use crate::ua_detect::is_plain_text_agent; use crate::db::{self, SharedDb}; use crate::error::AppError; use crate::i18n::{self, Locale}; use crate::ip_validate; use crate::models::{IpInfo, get_localized_name}; use crate::static_assets; +use crate::ua_detect::is_plain_text_agent; #[derive(serde::Deserialize)] pub struct IpQuery { @@ -228,7 +228,10 @@ fn format_city(info: &IpInfo, locale: Locale) -> &str { fn build_translations(locale: Locale) -> Translations { Translations { - t_title: i18n::translate(locale, "Accurate IP proxy information and geographic location"), + t_title: i18n::translate( + locale, + "Accurate IP proxy information and geographic location", + ), t_description: i18n::translate( locale, "Find your public IP address instantly. Look up geolocation, ASN, organization, and proxy/VPN/Tor detection for any IP address.", @@ -257,10 +260,7 @@ fn build_translations(locale: Locale) -> Translations { t_faq_cli_query_own: i18n::translate(locale, "Look up information about your own IP:"), t_faq_cli_json: i18n::translate(locale, "Or get everything in JSON format:"), t_faq_cli_specific: i18n::translate(locale, "Look up information about a specific IP:"), - t_faq_ipv46_q: i18n::translate( - locale, - "How do I force IPv4 or IPv6?", - ), + t_faq_ipv46_q: i18n::translate(locale, "How do I force IPv4 or IPv6?"), t_faq_ipv46_a: i18n::translate( locale, "Use curl -4 or curl -6 to specifically check your IPv4 or IPv6 address.", @@ -270,10 +270,7 @@ fn build_translations(locale: Locale) -> Translations { locale, "Send a request to the /json endpoint, or send a request with the application/json header.", ), - t_faq_automate_q: i18n::translate( - locale, - "Can I call your service programmatically?", - ), + t_faq_automate_q: i18n::translate(locale, "Can I call your service programmatically?"), t_faq_automate_a1: i18n::translate( locale, "Sure, but please respect our rate limits. Normally it's 30 RPM, and under heavy load we may drop it to 10 or 5 RPM.", @@ -318,10 +315,7 @@ fn build_translations(locale: Locale) -> Translations { locale, "It costs me $18.00/month to run, which is pretty cheap. I'm not going to shut it down over hosting costs anytime soon, and there won't be any ads.", ), - t_faq_stable_a3: i18n::translate( - locale, - "This service is not going to rug pull on you.", - ), + t_faq_stable_a3: i18n::translate(locale, "This service is not going to rug pull on you."), t_faq_sponsor_q: i18n::translate(locale, "How can I support this service?"), t_faq_sponsor_a: i18n::translate( locale, @@ -882,7 +876,10 @@ pub async fn manifest(State(state): State) -> Response { let body = serde_json::to_string_pretty(&manifest).expect("manifest serialization cannot fail"); ( - [(header::CONTENT_TYPE, "application/manifest+json; charset=utf-8")], + [( + header::CONTENT_TYPE, + "application/manifest+json; charset=utf-8", + )], body, ) .into_response() diff --git a/src/lib.rs b/src/lib.rs index 1745419..7c8d796 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,4 +1,3 @@ -pub mod ua_detect; pub mod config; pub mod db; pub mod error; @@ -9,4 +8,5 @@ pub mod middleware; pub mod models; pub mod routes; pub mod static_assets; +pub mod ua_detect; pub mod updater; diff --git a/src/routes.rs b/src/routes.rs index 0b65ffb..6d43331 100644 --- a/src/routes.rs +++ b/src/routes.rs @@ -1,6 +1,6 @@ +use axum::Router; use axum::middleware; use axum::routing::get; -use axum::Router; use crate::handlers::{self, AppState}; use crate::middleware::security_headers; diff --git a/tests/integration.rs b/tests/integration.rs index 93b945e..711d179 100644 --- a/tests/integration.rs +++ b/tests/integration.rs @@ -1118,7 +1118,10 @@ async fn html_contains_jsonld_on_landing_page() { &app, "/en", vec![ - ("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36"), + ( + "User-Agent", + "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36", + ), ("CF-Connecting-IP", "45.77.77.77"), ], ) @@ -1156,7 +1159,10 @@ async fn html_query_result_has_no_jsonld() { let (status, body) = get_with_headers( &app, "/en?ip=45.77.77.77", - vec![("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36")], + vec![( + "User-Agent", + "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36", + )], ) .await; assert_eq!(status, StatusCode::OK); @@ -1172,7 +1178,10 @@ async fn html_contains_microdata_faq() { let (status, body) = get_with_headers( &app, "/en?ip=45.77.77.77", - vec![("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36")], + vec![( + "User-Agent", + "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36", + )], ) .await; assert_eq!(status, StatusCode::OK); @@ -1208,7 +1217,10 @@ async fn html_contains_microdata_ip_result() { let (status, body) = get_with_headers( &app, "/en?ip=45.77.77.77", - vec![("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36")], + vec![( + "User-Agent", + "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36", + )], ) .await; assert_eq!(status, StatusCode::OK); @@ -1237,7 +1249,10 @@ async fn jsonld_contains_available_languages() { &app, "/en", vec![ - ("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36"), + ( + "User-Agent", + "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36", + ), ("CF-Connecting-IP", "45.77.77.77"), ], )