feat(args): add option to specify log file to parse

This commit is contained in:
Miguel Nogueira 2024-05-19 17:25:39 +01:00
parent 690de4bad6
commit 4cd97100eb
Signed by: miguel456
GPG Key ID: 43EF15DB0CC86DDD
1 changed files with 11 additions and 1 deletions

12
main.rb
View File

@ -4,10 +4,20 @@ require 'date'
require_relative 'utils/http_codes'
require_relative 'utils/date_for_humans'
logfile = File.open('teambuilder.pt.log')
args = ARGV
if args[0] == '--parse' || args[0] == '-p'
puts("[!] Opening log file at #{args[1]}")
logfile = File.open(args[1])
else
puts('[!] Log file path not provided, assuming default access.log')
logfile = File.open('access.log', 'a')
end
data = logfile.read
lines = data.split("\n")
# Gets the IP address from the string
# Note: sometimes the function can fetch the UA version as an IP address
def get_line_ip(line)