Skip to content

Commit 052dcf2

Browse files
Merge pull request #199 from blacklanternsecurity/dev
Update radixtarget
2 parents e9d4468 + 27857a3 commit 052dcf2

File tree

5 files changed

+33
-12
lines changed

5 files changed

+33
-12
lines changed

Cargo.lock

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "cloudcheck"
3-
version = "8.1.3"
3+
version = "8.2.0"
44
edition = "2024"
55
description = "CloudCheck is a simple Rust tool to check whether an IP address or hostname belongs to a cloud provider."
66
license = "GPL-3.0"
@@ -13,7 +13,7 @@ reqwest = { version = "0.12", features = ["json"] }
1313
openssl = { version = "0.10", features = ["vendored"] }
1414
pyo3 = { version = "0.27", optional = true }
1515
pyo3-async-runtimes = { version = "0.27", features = ["tokio-runtime"], optional = true }
16-
radixtarget = "4.1"
16+
radixtarget = "4.2"
1717

1818
[features]
1919
default = []

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "maturin"
44

55
[project]
66
name = "cloudcheck"
7-
version = "8.1.3"
7+
version = "8.2.0"
88
description = "Detailed database of cloud providers. Instantly look up a domain or IP address"
99
readme = "README.md"
1010
requires-python = ">=3.9"

src/lib.rs

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use tokio::sync::OnceCell;
99
#[cfg(feature = "py")]
1010
mod python;
1111

12-
const CLOUDCHECK_SIGNATURE_URL: &str = "https://raw.githubusercontent.com/blacklanternsecurity/cloudcheck/refs/heads/cloudcheck-v8/cloud_providers_v2.json";
12+
const CLOUDCHECK_SIGNATURE_URL: &str = "https://raw.githubusercontent.com/blacklanternsecurity/cloudcheck/refs/heads/stable/cloud_providers_v2.json";
1313

1414
#[derive(Debug, Clone, Serialize, Deserialize)]
1515
pub struct CloudProvider {
@@ -104,7 +104,7 @@ impl CloudCheck {
104104
let providers_data: HashMap<String, ProviderData> =
105105
serde_json::from_str(&json_data)?;
106106

107-
let mut radix = RadixTarget::new(&[], ScopeMode::Normal);
107+
let mut radix = RadixTarget::new(&[], ScopeMode::Normal)?;
108108
let mut providers_map: HashMap<String, Vec<CloudProvider>> = HashMap::new();
109109

110110
for (_, provider) in providers_data {
@@ -116,7 +116,14 @@ impl CloudCheck {
116116
for cidr in provider.cidrs {
117117
let normalized = match radix.get(&cidr) {
118118
Some(n) => n,
119-
None => radix.insert(&cidr).unwrap(),
119+
None => match radix.insert(&cidr) {
120+
Ok(Some(n)) => n,
121+
Ok(None) => continue,
122+
Err(e) => {
123+
eprintln!("Error inserting CIDR '{}': {}", cidr, e);
124+
continue;
125+
}
126+
},
120127
};
121128
providers_map
122129
.entry(normalized.clone())
@@ -125,9 +132,23 @@ impl CloudCheck {
125132
}
126133

127134
for domain in provider.domains {
128-
let normalized = match radix.get(&domain) {
135+
// Clean domain: strip comments (everything after #) and trim whitespace
136+
let cleaned_domain = domain.split('#').next().unwrap_or(&domain).trim();
137+
138+
if cleaned_domain.is_empty() {
139+
continue;
140+
}
141+
142+
let normalized = match radix.get(cleaned_domain) {
129143
Some(n) => n,
130-
None => radix.insert(&domain).unwrap(),
144+
None => match radix.insert(cleaned_domain) {
145+
Ok(Some(n)) => n,
146+
Ok(None) => continue,
147+
Err(e) => {
148+
eprintln!("Error inserting domain '{}': {}", cleaned_domain, e);
149+
continue;
150+
}
151+
},
131152
};
132153
providers_map
133154
.entry(normalized.clone())

uv.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)