blob: 9e8f29de134dad5092178aefa5baa51da61c5976 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
use ipnet::IpNet;
use crate::config::NSCConfig;
/// Enum for declaring GeoSite/IP routing
pub enum RouteType {
/// GeoSite MMDB type, like `category-ads-all`
GeoSite(String),
/// Subnet
GeoIp(IpNet),
}
/// Routing actions
pub enum RouteAction {
Block,
Proxy,
Direct,
}
/// Type for declaring the routing rules like:
/// ```toml
/// [rule]
/// action = enum RouteAction
/// target = enum RouteType
///
/// [rule]
/// target = "geosite:category-ads-all"
/// action = "block"
/// ```
pub struct Rule {
pub target: RouteType,
pub action: RouteAction,
}
pub fn parse_ruleset(config: NSCConfig) -> Result<Vec<Rule>, Box<dyn std::error::Error>> {
let reader = maxminddb::Reader::open_readfile(config.geo_files[0].clone())?;
// Ok(())
todo!();
}
|