diff --git a/Cargo.lock b/Cargo.lock index 8312ca8..ae41a86 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -56,7 +56,7 @@ checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801" [[package]] name = "cloudcheck" -version = "8.1.3" +version = "8.2.0" dependencies = [ "openssl", "pyo3", @@ -881,9 +881,9 @@ checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f" [[package]] name = "radixtarget" -version = "4.1.2" +version = "4.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80958c58de95970f17dcfef05f5f731ea82899e4f977be1b84b2f3fd18560521" +checksum = "bbc64e3d7f89cd81c5b90bebc4fc719b215d894d4e664ec2d06c5ebf7a58fa1a" dependencies = [ "idna", "ipnet", diff --git a/Cargo.toml b/Cargo.toml index 3ebe4b6..e886e58 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cloudcheck" -version = "8.1.3" +version = "8.2.0" edition = "2024" description = "CloudCheck is a simple Rust tool to check whether an IP address or hostname belongs to a cloud provider." license = "GPL-3.0" @@ -13,7 +13,7 @@ reqwest = { version = "0.12", features = ["json"] } openssl = { version = "0.10", features = ["vendored"] } pyo3 = { version = "0.27", optional = true } pyo3-async-runtimes = { version = "0.27", features = ["tokio-runtime"], optional = true } -radixtarget = "4.1" +radixtarget = "4.2" [features] default = [] diff --git a/pyproject.toml b/pyproject.toml index e5f6ac7..8f59ff0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "maturin" [project] name = "cloudcheck" -version = "8.1.3" +version = "8.2.0" description = "Detailed database of cloud providers. Instantly look up a domain or IP address" readme = "README.md" requires-python = ">=3.9" diff --git a/src/lib.rs b/src/lib.rs index 65d3f7c..1f38b67 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -9,7 +9,7 @@ use tokio::sync::OnceCell; #[cfg(feature = "py")] mod python; -const CLOUDCHECK_SIGNATURE_URL: &str = "https://raw.githubusercontent.com/blacklanternsecurity/cloudcheck/refs/heads/cloudcheck-v8/cloud_providers_v2.json"; +const CLOUDCHECK_SIGNATURE_URL: &str = "https://raw.githubusercontent.com/blacklanternsecurity/cloudcheck/refs/heads/stable/cloud_providers_v2.json"; #[derive(Debug, Clone, Serialize, Deserialize)] pub struct CloudProvider { @@ -104,7 +104,7 @@ impl CloudCheck { let providers_data: HashMap = serde_json::from_str(&json_data)?; - let mut radix = RadixTarget::new(&[], ScopeMode::Normal); + let mut radix = RadixTarget::new(&[], ScopeMode::Normal)?; let mut providers_map: HashMap> = HashMap::new(); for (_, provider) in providers_data { @@ -116,7 +116,14 @@ impl CloudCheck { for cidr in provider.cidrs { let normalized = match radix.get(&cidr) { Some(n) => n, - None => radix.insert(&cidr).unwrap(), + None => match radix.insert(&cidr) { + Ok(Some(n)) => n, + Ok(None) => continue, + Err(e) => { + eprintln!("Error inserting CIDR '{}': {}", cidr, e); + continue; + } + }, }; providers_map .entry(normalized.clone()) @@ -125,9 +132,23 @@ impl CloudCheck { } for domain in provider.domains { - let normalized = match radix.get(&domain) { + // Clean domain: strip comments (everything after #) and trim whitespace + let cleaned_domain = domain.split('#').next().unwrap_or(&domain).trim(); + + if cleaned_domain.is_empty() { + continue; + } + + let normalized = match radix.get(cleaned_domain) { Some(n) => n, - None => radix.insert(&domain).unwrap(), + None => match radix.insert(cleaned_domain) { + Ok(Some(n)) => n, + Ok(None) => continue, + Err(e) => { + eprintln!("Error inserting domain '{}': {}", cleaned_domain, e); + continue; + } + }, }; providers_map .entry(normalized.clone()) diff --git a/uv.lock b/uv.lock index ceb4b76..fc70d1a 100644 --- a/uv.lock +++ b/uv.lock @@ -140,7 +140,7 @@ wheels = [ [[package]] name = "cloudcheck" -version = "8.1.3" +version = "8.2.0" source = { editable = "." } [package.dev-dependencies]