use `tun` crate examope for starters, to map all traffic through tun virtual interface, in next commits will push these packets to sniffing module which will deciede further modifications of proxies based by user's Config.
42 lines
807 B
Rust
42 lines
807 B
Rust
use ipnet::IpNet;
|
|
use crate::config::Config;
|
|
|
|
/// 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 Rules = Vec<Rule>;
|
|
|
|
/// 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: Config) -> Result<Rules, Box<dyn std::error::Error>> {
|
|
let reader = maxminddb::Reader::open_readfile(config.geo_files[0].clone())?;
|
|
|
|
// Ok(())
|
|
todo!();
|
|
}
|
|
|