Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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 = []
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
31 changes: 26 additions & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -104,7 +104,7 @@ impl CloudCheck {
let providers_data: HashMap<String, ProviderData> =
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<String, Vec<CloudProvider>> = HashMap::new();

for (_, provider) in providers_data {
Expand All @@ -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())
Expand All @@ -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())
Expand Down
2 changes: 1 addition & 1 deletion uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.