usiem/components/dataset/geo_ip/
mod.rs1#[cfg(not(feature = "slow_geoip"))]
2mod fast;
3#[cfg(feature = "slow_geoip")]
4mod slow;
5
6use serde::{Deserialize, Serialize};
7#[cfg(feature = "slow_geoip")]
8use sled::IVec;
9
10use crate::prelude::types::LogString;
11
12#[derive(Serialize, Deserialize, Debug, Default, Clone)]
13pub struct GeoIpInfo {
14 pub country: LogString,
15 pub country_iso: LogString,
16 pub city: LogString,
17 pub latitude: f32,
18 pub longitude: f32,
19 pub isp: LogString, pub asn: u32,
21}
22#[cfg(feature = "slow_geoip")]
23impl Into<IVec> for GeoIpInfo {
24 fn into(self) -> IVec {
25 IVec::from(serde_json::to_string(&self).unwrap().as_bytes())
26 }
27}
28#[cfg(feature = "slow_geoip")]
29impl From<IVec> for GeoIpInfo {
30 fn from(value: IVec) -> Self {
31 let s: GeoIpInfo = serde_json::from_slice(&value).unwrap();
32 s
33 }
34}
35#[cfg(not(feature = "slow_geoip"))]
36pub use fast::{GeoIpDataset, GeoIpSynDataset, UpdateGeoIp};
37
38#[cfg(feature = "slow_geoip")]
39pub use slow::{
40 SlowGeoIpDataset as GeoIpDataset, SlowGeoIpSynDataset as GeoIpSynDataset,
41 UpdateSlowGeoIp as UpdateGeoIp,
42};