Skip to content

Commit

Permalink
fixed bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
QpxDesign committed Mar 8, 2024
1 parent 391e1d5 commit 87d74c6
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
workspace = { members = [ "tests","tests/obfuscate_access_log_ips"] }
[package]
name = "ngxav"
version = "0.4.8"
version = "0.4.9"
edition = "2021"
license = "MIT"
description = "Search through NGINX logs with advanced filters and support for displaying analytics about your selected log entries"
Expand Down
8 changes: 5 additions & 3 deletions src/utils/read_folder_conserve_memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,13 @@ use std::fs::File;
use std::io::{BufRead, BufReader};

pub fn read_folder_conserve_memory(file_path: String, isUnique: Option<bool>) {
println!("{}", "step zero");
let mut paths: Vec<_> = fs::read_dir(file_path).unwrap().collect();
paths.sort_by_key(|x| {
metadata(x.as_ref().unwrap().path().to_str().unwrap())
.unwrap()
.modified()
.unwrap()
});
println!("{}", "step one");
let mut occurrences: HashMap<String, bool> = HashMap::new();
for path in paths {
let p: String = path.unwrap().path().to_str().unwrap().to_string();
Expand All @@ -28,7 +26,11 @@ pub fn read_folder_conserve_memory(file_path: String, isUnique: Option<bool>) {
Ok(line) => {
let ip: String =
line.clone().split(" ").collect::<Vec<&str>>()[0].to_string();
if keep_line(&parse_line(&line), true) {

if line.chars().filter(|c| *c == '"').count() > 4
&& line.len() > 20
&& keep_line(&parse_line(&line), true)
{
if isUnique.is_some() && isUnique.unwrap() == true {
if !occurrences.contains_key(&ip) {
println!("{}", line.clone() + "\n");
Expand Down

0 comments on commit 87d74c6

Please sign in to comment.