Refactor: Fully migrated parser to full prost crate, auto-fmt; Fix: Remove no more needed tests
This commit is contained in:
parent
c1bf670152
commit
0d81bae32a
8 changed files with 75 additions and 96 deletions
|
|
@ -1,5 +1,5 @@
|
|||
use nsc::geoparsers::v2ray::parsing::GeoSiteService;
|
||||
use nsc::geoparsers::v2ray::types::Domain;
|
||||
use nsc::geoparsers::geosite::GeoSiteService;
|
||||
use nsc::geoparsers::v2ray::types::{Domain, domain};
|
||||
use std::fs;
|
||||
use std::path::PathBuf;
|
||||
|
||||
|
|
@ -7,11 +7,11 @@ fn download_geosite() -> Result<PathBuf, Box<dyn std::error::Error>> {
|
|||
let tmp_dir = std::env::temp_dir().join("seccontrol_test");
|
||||
fs::create_dir_all(&tmp_dir)?;
|
||||
|
||||
let geosite_path = tmp_dir.join("geosite.dat");
|
||||
let geosite_path = tmp_dir.join("dlc.dat");
|
||||
|
||||
if !geosite_path.exists() {
|
||||
// Use v2fly domain-list-community which has standard protobuf format
|
||||
let url = "https://github.com/v2fly/domain-list-community/releases/latest/download/dlc.dat";
|
||||
let url = "https://github.com/v2fly/domain-list-community/releases/download/20260330021310/dlc.dat";
|
||||
let response = ureq::get(url).call()?;
|
||||
let mut file = fs::File::create(&geosite_path)?;
|
||||
let mut reader = response.into_reader();
|
||||
|
|
@ -41,6 +41,16 @@ fn geosite_service_creation() {
|
|||
fn lookup_existing_domain() {
|
||||
let service = get_geosite_service().expect("Failed to create service");
|
||||
|
||||
let domain = Domain {
|
||||
r#type: nsc::geoparsers::v2ray::types::domain::Type::Full as i32,
|
||||
value: "google.com".to_string(),
|
||||
attribute: vec![],
|
||||
};
|
||||
|
||||
let result = service.lookup(domain.value.as_str());
|
||||
assert!(result.is_some(), "Should return GeoSite categs");
|
||||
println!("{:?}", result);
|
||||
|
||||
assert!(!service.is_empty(), "Service should have entries");
|
||||
println!("Loaded {} GeoSite entries", service.len());
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue