diff options
| author | namilsk <namilsk@namilsk.tech> | 2026-03-14 19:15:14 +0300 |
|---|---|---|
| committer | namilsk <namilsk@namilsk.tech> | 2026-03-14 19:17:16 +0300 |
| commit | bc8bc0c2e4fb09070d82aab1f922ef8160c66528 (patch) | |
| tree | c7d36233840007a638bffe3ffa9e503325a51794 /src/geoparsers/geoip2.rs | |
| parent | 7019867411cdca87b394f38dfc589958e09a2b73 (diff) | |
First minimal commit
Diffstat (limited to 'src/geoparsers/geoip2.rs')
| -rw-r--r-- | src/geoparsers/geoip2.rs | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/src/geoparsers/geoip2.rs b/src/geoparsers/geoip2.rs new file mode 100644 index 0000000..9e8f29d --- /dev/null +++ b/src/geoparsers/geoip2.rs @@ -0,0 +1,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!(); +} + |
