Skip to content

Commit b49add1

Browse files
committed
feat: remove support for geolocation since it's no longer needed
1 parent 92c061c commit b49add1

File tree

10 files changed

+10
-132
lines changed

10 files changed

+10
-132
lines changed

.cspell.json

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,9 @@
55
"chrono",
66
"consts",
77
"ddgsyslog",
8-
"geodb",
9-
"geoip",
10-
"geolocation",
11-
"geolocator",
12-
"geoname",
138
"getopts",
149
"Hasher",
1510
"libc",
16-
"maxminddb",
1711
"optflag",
1812
"optopt",
1913
"premaster",
@@ -23,4 +17,4 @@
2317
"sslkeylog",
2418
"Zagorodnikov"
2519
]
26-
}
20+
}

Cargo.lock

Lines changed: 5 additions & 45 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ hex = "0.4.3"
1414
lazy_static = "1.5.0"
1515
getopts = "0.2.21"
1616
url = "2.5.4"
17-
maxminddb = "0.26.0"
1817

1918
[target.'cfg(unix)'.dependencies]
2019
signal-hook = "0.3.17"

README.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ Then just use:
2222
## Usage
2323
Run the built binary to determine the command-line options.
2424
On Windows, file names support [wildcard expansion](https://docs.rs/glob/), on other OSes shell expansion is expected to take care of that.
25-
The tool optionally supports [MaxMind geolocation database](https://www.maxmind.com/en/geoip2-databases) to store [GeoNames](https://www.geonames.org/) identifier.
2625

2726
## Schema
2827
All keys are placed in the collections named `<sni>@<server_ip>:<server_port>_<year><month><day>` with the following schemas:
@@ -36,7 +35,6 @@ All keys are placed in the collections named `<sni>@<server_ip>:<server_port>_<y
3635
"p": <client_port>:int,
3736
"c": <cipher_id>:int,
3837
"k": <premaster>:BinData,
39-
["g": <geoname_id>:int],
4038
}
4139

4240
// TLS 1.3:
@@ -51,7 +49,6 @@ All keys are placed in the collections named `<sni>@<server_ip>:<server_port>_<y
5149
"f": <client_handshake>:BinData,
5250
"z": <server_0>:BinData,
5351
"s": <client_0>:BinData,
54-
["g": <geoname_id>:int],
5552
}
5653
```
5754

src/configuration.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ pub(crate) struct Configuration {
1313
pub options: mongodb::options::ClientOptions,
1414
pub db_name: String,
1515
pub filter: Option<Regex>,
16-
pub geodb_path: Option<String>,
1716
pub input_format: InputFormat,
1817
}
1918

@@ -37,7 +36,6 @@ where
3736
"set filter regex, strict (/^...$/)",
3837
"www\\.domain\\.(com|net):443",
3938
);
40-
opts.optopt("g", "geo-db", "set geolocation database path", "/path/to/GeoLite2-City.mmdb");
4139
opts.optopt(
4240
"i",
4341
"input-format",
@@ -80,8 +78,6 @@ where
8078
.transpose()
8179
.context("Invalid filter")?;
8280

83-
let geodb_path = matches.opt_str("g");
84-
8581
let input_format = matches
8682
.opt_str("i")
8783
.map(|f| InputFormat::try_from(f.as_str()))
@@ -123,7 +119,6 @@ where
123119
options,
124120
db_name,
125121
filter,
126-
geodb_path,
127122
input_format,
128123
}))
129124
}

src/data_model.rs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -242,16 +242,6 @@ fn tls13_from_ddg_syslog(value: &str) -> Result<Tls13Record, anyhow::Error> {
242242
})
243243
}
244244

245-
pub(crate) struct GeoMetadata {
246-
pub geoname_id: u32,
247-
}
248-
249-
impl BsonSerializable for GeoMetadata {
250-
fn serialize(&self, document: &mut bson::Document) {
251-
document.insert("g", self.geoname_id);
252-
}
253-
}
254-
255245
pub(crate) fn get_index_model() -> Vec<bson::Document> {
256246
vec![
257247
doc! {

src/geolocator.rs

Lines changed: 0 additions & 28 deletions
This file was deleted.

src/main.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
mod configuration;
22
mod data_model;
33
mod errors;
4-
mod geolocator;
54
mod logging;
65
mod process;
76
mod processor;

src/process.rs

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,12 @@
11
use std::sync::{atomic::AtomicBool, Arc};
22

3-
use anyhow::{Context, Result};
3+
use anyhow::Result;
44

5-
use crate::{configuration, geolocator, processor, storage};
5+
use crate::{configuration, processor, storage};
66

77
pub(crate) fn process(args: &configuration::Configuration, term_token: &Arc<AtomicBool>) -> Result<()> {
88
let db = mongodb::sync::Client::with_options(args.options.clone())?.database(&args.db_name);
99
let mut store = storage::Store::new(&db);
10-
let geolocator = args
11-
.geodb_path
12-
.as_ref()
13-
.map(|path| {
14-
geolocator::Geolocator::new(path).with_context(|| format!("Failed to create geolocator with database path {:?}", path))
15-
})
16-
.transpose()?;
17-
let mut context = processor::Processor::new(
18-
args.filter.as_ref(),
19-
term_token,
20-
&mut store,
21-
geolocator.as_ref(),
22-
args.input_format,
23-
);
10+
let mut context = processor::Processor::new(args.filter.as_ref(), term_token, &mut store, args.input_format);
2411
context.process(&args.files)
2512
}

src/processor.rs

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,12 @@ use mongodb::bson;
1515
use regex::Regex;
1616
use time::{format_description::FormatItem, macros::format_description, Duration};
1717

18-
use crate::{data_model::*, errors, geolocator::Geolocator, logging, storage::Store};
18+
use crate::{data_model::*, errors, logging, storage::Store};
1919

2020
pub(crate) struct Processor<'a> {
2121
filter: Option<&'a Regex>,
2222
term_token: &'a Arc<AtomicBool>,
2323
store: &'a mut Store<'a>,
24-
geolocator: Option<&'a Geolocator>,
2524
input_format: InputFormat,
2625
}
2726

@@ -30,14 +29,12 @@ impl<'a> Processor<'a> {
3029
filter: Option<&'a Regex>,
3130
term_token: &'a Arc<AtomicBool>,
3231
store: &'a mut Store<'a>,
33-
geolocator: Option<&'a Geolocator>,
3432
input_format: InputFormat,
3533
) -> Self {
3634
Self {
3735
filter,
3836
term_token,
3937
store,
40-
geolocator,
4138
input_format,
4239
}
4340
}
@@ -169,20 +166,8 @@ impl<'a> Processor<'a> {
169166
return Ok(None);
170167
}
171168

172-
let geolocation = self
173-
.geolocator
174-
.map(|g| {
175-
g.locate(metadata.client_ip)
176-
.with_context(|| format!("Failed to locate client {} at {}", metadata.client_ip, location))
177-
})
178-
.transpose()?
179-
.flatten();
180-
181169
let mut document = bson::Document::new();
182170
record.serialize(&mut document);
183-
if let Some(geoname_id) = geolocation {
184-
GeoMetadata { geoname_id }.serialize(&mut document);
185-
};
186171

187172
const SUFFIX_FORMAT: &[FormatItem] = format_description!("[year][month][day]");
188173
let collection_name = format!(

0 commit comments

Comments
 (0)