feat: addtional cidrs
Some checks failed
Create Scripts / Build (push) Failing after 3m10s

This commit is contained in:
椰子 2024-02-22 21:55:45 +08:00
parent 3a6b7fc451
commit cea6584760
2 changed files with 28 additions and 22 deletions

15
additional.txt Normal file
View 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

View File

@ -1,6 +1,7 @@
use std::error::Error;
use std::fs::File;
use std::io::Write;
use std::io::{BufRead, BufReader, Write};
use reqwest;
#[tokio::main]
@ -19,33 +20,23 @@ async fn create() -> Result<(), Box<dyn Error>> {
let list = "chn_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();
// 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
let text = reqwest::get(url).await?
.text().await?;
let lines = text.lines();
let lines = lines.collect::<Vec<&str>>();
write_to_file(&mut dest, list, &lines);
// Apple push notifications
// entire block
let apns = vec!["17.0.0.0/8"];
// network ranges
// 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"];
write_to_file(&mut dest, list, &apns);
// additional network
let additional = File::open("additional.txt").unwrap();
let lines = BufReader::new(additional).lines();
for x in lines {
let cidr = x.unwrap();
let cidr = cidr.trim();
if !cidr.is_empty() && !cidr.starts_with("#") {
let vec1 = vec![cidr];
write_to_file(&mut dest, list, &vec1);
};
}
Ok(())
}