Compare commits
No commits in common. "39a2590be8a1393c54798adfb3ea373d777caef4" and "26588b6de77c855ae046e8dbeb24704e6fc4fa44" have entirely different histories.
39a2590be8
...
26588b6de7
@ -1,33 +0,0 @@
|
|||||||
use std::fs::OpenOptions;
|
|
||||||
use std::io::prelude::*;
|
|
||||||
use std::path::Path;
|
|
||||||
|
|
||||||
enum LoggerType {
|
|
||||||
Local(&'static str),
|
|
||||||
}
|
|
||||||
|
|
||||||
pub struct Logger {
|
|
||||||
l_type: LoggerType,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Logger {
|
|
||||||
pub fn new(path: &'static str) -> Logger {
|
|
||||||
Logger {
|
|
||||||
l_type: LoggerType::Local(path),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn write_log_line(&self, data: String) {
|
|
||||||
match self.l_type {
|
|
||||||
LoggerType::Local(path) => {
|
|
||||||
let mut file = OpenOptions::new()
|
|
||||||
.write(true)
|
|
||||||
.append(true)
|
|
||||||
.create(true)
|
|
||||||
.open(path)
|
|
||||||
.unwrap();
|
|
||||||
writeln!(file, "{}", data).unwrap();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
10
src/main.rs
10
src/main.rs
@ -17,8 +17,6 @@ mod whois;
|
|||||||
use whois::default;
|
use whois::default;
|
||||||
use whois::selector::*;
|
use whois::selector::*;
|
||||||
|
|
||||||
mod logger;
|
|
||||||
|
|
||||||
use crossterm::event::{
|
use crossterm::event::{
|
||||||
self, DisableMouseCapture, EnableMouseCapture, Event, KeyCode, KeyEventKind,
|
self, DisableMouseCapture, EnableMouseCapture, Event, KeyCode, KeyEventKind,
|
||||||
};
|
};
|
||||||
@ -29,14 +27,14 @@ use crossterm::terminal::{
|
|||||||
use ratatui::backend::{Backend, CrosstermBackend};
|
use ratatui::backend::{Backend, CrosstermBackend};
|
||||||
use ratatui::Terminal;
|
use ratatui::Terminal;
|
||||||
use std::error::Error;
|
use std::error::Error;
|
||||||
use std::io::{self, stdout};
|
use std::io::{self, stderr};
|
||||||
|
|
||||||
fn main() -> Result<(), Box<dyn Error>> {
|
fn main() -> Result<(), Box<dyn Error>> {
|
||||||
enable_raw_mode()?;
|
enable_raw_mode()?;
|
||||||
let mut stdout = stdout();
|
let mut stderr = stderr();
|
||||||
execute!(stdout, EnterAlternateScreen)?;
|
execute!(stderr, EnterAlternateScreen)?;
|
||||||
|
|
||||||
let backend = CrosstermBackend::new(stdout);
|
let backend = CrosstermBackend::new(stderr);
|
||||||
let mut terminal = Terminal::new(backend)?;
|
let mut terminal = Terminal::new(backend)?;
|
||||||
|
|
||||||
// Initialise the App and config
|
// Initialise the App and config
|
||||||
|
|||||||
@ -27,12 +27,6 @@ impl Whois for _Whois {
|
|||||||
registrar.push_str(&self.base.registrar.clone().unwrap());
|
registrar.push_str(&self.base.registrar.clone().unwrap());
|
||||||
ret_vec.push(registrar);
|
ret_vec.push(registrar);
|
||||||
|
|
||||||
for nameserver in &self.base.nameservers.clone().unwrap() {
|
|
||||||
let mut tmp = String::from("Nameserver: ");
|
|
||||||
tmp.push_str(&nameserver.host);
|
|
||||||
ret_vec.push(tmp);
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret_vec;
|
return ret_vec;
|
||||||
}
|
}
|
||||||
fn lookup(&mut self, domain: String) -> Vec<String> {
|
fn lookup(&mut self, domain: String) -> Vec<String> {
|
||||||
@ -41,16 +35,14 @@ impl Whois for _Whois {
|
|||||||
.lookup(WhoIsLookupOptions::from_string(domain).unwrap())
|
.lookup(WhoIsLookupOptions::from_string(domain).unwrap())
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let registrar_regex = RegexQuery::new(String::from(r"(?mi)(.*registrar:.*\n)(.*)"));
|
let registrar_regex = RegexQuery::new(String::from(r"(?mi)(.*registrar:.*\n)(.*?\[)"));
|
||||||
let nameserver_regex =
|
let nameserver_regex =
|
||||||
RegexQuery::new(String::from(r"(?miR)(.*name servers:\r\n)((.+\.+.+)+)"));
|
RegexQuery::new(String::from(r"(?mi)(.*name servers:\r\n)((.*\r\n))"));
|
||||||
|
|
||||||
let registrar = WhoisData::return_regex(registrar_regex.get_matches(&result), 0);
|
let registrar = WhoisData::return_regex(registrar_regex.get_matches(&result), 0);
|
||||||
let nameservers = nameserver_regex.captures(&result);
|
// let nameserver_regex = WhoisData::return_regex(self.get_matches(&result), 0);
|
||||||
// println!("{:?}", nameservers);
|
|
||||||
|
|
||||||
self.base.registrar = Some(registrar.clone());
|
self.base.registrar = Some(registrar.clone());
|
||||||
self.base.nameservers = Some(nameservers.clone());
|
|
||||||
|
|
||||||
self.to_vec()
|
self.to_vec()
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,3 @@
|
|||||||
use crate::logger::Logger;
|
|
||||||
use core::fmt;
|
use core::fmt;
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
|
|
||||||
@ -35,24 +34,6 @@ impl RegexQuery {
|
|||||||
}
|
}
|
||||||
results
|
results
|
||||||
}
|
}
|
||||||
pub fn captures(&self, haystack: &str) -> Vec<NameServer> {
|
|
||||||
// let logger = Logger::new("log.txt");
|
|
||||||
let mut results: Vec<NameServer> = vec![];
|
|
||||||
match self.re.captures(haystack) {
|
|
||||||
Some(rex) => {
|
|
||||||
for x in 1..rex.len() {
|
|
||||||
if x == 1 {
|
|
||||||
continue;
|
|
||||||
};
|
|
||||||
results.push(NameServer::new(String::from(
|
|
||||||
rex.get(x).unwrap().as_str().trim(),
|
|
||||||
)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
None => {}
|
|
||||||
}
|
|
||||||
results
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user