This commit is contained in:
parent
3a6b7fc451
commit
cea6584760
15
additional.txt
Normal file
15
additional.txt
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
# private address list
|
||||||
|
10.0.0.0/8
|
||||||
|
127.0.0.0/8
|
||||||
|
0.0.0.0/8
|
||||||
|
172.16.0.0/12
|
||||||
|
169.254.0.0/16
|
||||||
|
192.168.0.0/16
|
||||||
|
|
||||||
|
# isp private address block
|
||||||
|
100.64.0.0/10
|
||||||
|
|
||||||
|
# Apple push notifications
|
||||||
|
17.0.0.0/8
|
||||||
|
|
||||||
|
dl.simaek.com
|
35
src/main.rs
35
src/main.rs
@ -1,6 +1,7 @@
|
|||||||
use std::error::Error;
|
use std::error::Error;
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io::Write;
|
use std::io::{BufRead, BufReader, Write};
|
||||||
|
|
||||||
use reqwest;
|
use reqwest;
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
@ -19,33 +20,23 @@ async fn create() -> Result<(), Box<dyn Error>> {
|
|||||||
let list = "chn_list";
|
let list = "chn_list";
|
||||||
let clean_command = format!(":foreach i in=[/ip/firewall/address-list/find list=\"{}\"] do={{remove numbers=$i}}\n", list);
|
let clean_command = format!(":foreach i in=[/ip/firewall/address-list/find list=\"{}\"] do={{remove numbers=$i}}\n", list);
|
||||||
dest.write(clean_command.as_bytes()).unwrap();
|
dest.write(clean_command.as_bytes()).unwrap();
|
||||||
|
|
||||||
// private address list
|
|
||||||
let class_a = vec!["10.0.0.0/8", "127.0.0.0/8", "0.0.0.0/8"];
|
|
||||||
let class_b = vec!["172.16.0.0/12", "169.254.0.0/16"];
|
|
||||||
let class_c = vec!["192.168.0.0/16"];
|
|
||||||
write_to_file(&mut dest, list, &class_a);
|
|
||||||
write_to_file(&mut dest, list, &class_b);
|
|
||||||
write_to_file(&mut dest, list, &class_c);
|
|
||||||
|
|
||||||
// isp private address block
|
|
||||||
let isp = vec!["100.64.0.0/10"];
|
|
||||||
write_to_file(&mut dest, list, &isp);
|
|
||||||
|
|
||||||
// request china cidr from network
|
// request china cidr from network
|
||||||
let text = reqwest::get(url).await?
|
let text = reqwest::get(url).await?
|
||||||
.text().await?;
|
.text().await?;
|
||||||
let lines = text.lines();
|
let lines = text.lines();
|
||||||
let lines = lines.collect::<Vec<&str>>();
|
let lines = lines.collect::<Vec<&str>>();
|
||||||
write_to_file(&mut dest, list, &lines);
|
write_to_file(&mut dest, list, &lines);
|
||||||
|
// additional network
|
||||||
// Apple push notifications
|
let additional = File::open("additional.txt").unwrap();
|
||||||
// entire block
|
let lines = BufReader::new(additional).lines();
|
||||||
let apns = vec!["17.0.0.0/8"];
|
for x in lines {
|
||||||
// network ranges
|
let cidr = x.unwrap();
|
||||||
// let apns = vec!["17.249.0.0/16", "17.252.0.0/16", "17.57.144.0/22", "17.188.128.0/18", "17.188.20.0/23"];
|
let cidr = cidr.trim();
|
||||||
write_to_file(&mut dest, list, &apns);
|
if !cidr.is_empty() && !cidr.starts_with("#") {
|
||||||
|
let vec1 = vec![cidr];
|
||||||
|
write_to_file(&mut dest, list, &vec1);
|
||||||
|
};
|
||||||
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user