Skip to content

Commit

Permalink
命名
Browse files Browse the repository at this point in the history
  • Loading branch information
golangboy committed Feb 9, 2024
1 parent 60694cb commit c37c6b7
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,20 @@ use ipnetwork::Ipv4Network;
use reqwest::header;

pub async fn get_all_ipv4() -> Result<Vec<String>, Box<dyn std::error::Error>> {
let cidrs = get_cidr_from_cf().await?;
let _cidrs_arr = cidrs.split("\n");
let mut res = Vec::<String>::new();
for cidr in _cidrs_arr {
let temps: Ipv4Network = cidr.parse().unwrap();
for temp in temps.iter() {
res.push(String::from(temp.to_string()));

let cidr_strings = get_cidr_from_cf().await?;
let cidr_list = cidr_strings.split("\n");
let mut ipv4_addresses = Vec::<String>::new();
for cidr in cidr_list {
let network: Ipv4Network = cidr.parse().unwrap();
for address in network.iter() {
ipv4_addresses.push(String::from(address.to_string()));
}
}
return Ok(res);
return Ok(ipv4_addresses);
}


pub async fn get_cidr_from_cf() -> Result<String, Box<dyn std::error::Error>> {
let mut headers = header::HeaderMap::new();
headers.insert("authority", "www.cloudflare.com".parse().unwrap());
Expand Down

0 comments on commit c37c6b7

Please sign in to comment.