Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7247e85762 |
No files matched your search
+43
-14
@@ -865,23 +865,52 @@ impl AppState {
|
||||
}
|
||||
"parse_scope" => {
|
||||
let mut general_path = self.projects[self.selected_project].notes.clone();
|
||||
let mut scope_path = self.projects[self.selected_project].notes.clone();
|
||||
scope_path.push("scope.md");
|
||||
general_path.push("general.md");
|
||||
let general_string = read_to_string(general_path)?;
|
||||
if let Some((_, scope_section)) = general_string.split_once("# Scope") {
|
||||
if let Some((scope_section, _)) = scope_section.split_once("#") {
|
||||
scope_section.lines().into_iter().for_each(|line| {
|
||||
if line.contains("|") {
|
||||
if !line.contains("Subnet") {
|
||||
if !line.contains("--") {
|
||||
let host =
|
||||
line.split("|").collect::<Vec<&str>>()[1].to_string();
|
||||
self.projects[self.selected_project].add_scope(host);
|
||||
}
|
||||
}
|
||||
let mut scope_file = OpenOptions::new()
|
||||
.create(true)
|
||||
.truncate(true)
|
||||
.write(true)
|
||||
.open(scope_path)?;
|
||||
general_string
|
||||
.split_whitespace()
|
||||
.into_iter()
|
||||
.for_each(|word| {
|
||||
if let Ok(_) = word.trim().parse::<IpNet>() {
|
||||
if let Err(e) = write!(scope_file, "{}\n", word) {
|
||||
let _ = self.main_tx.send(ToolMessage::Output((
|
||||
rid,
|
||||
format!("Error writing scope file! {e}"),
|
||||
)));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
} else if let Ok(_) = word.trim().parse::<IpAddr>() {
|
||||
if let Err(e) = write!(scope_file, "{}\n", word) {
|
||||
let _ = self.main_tx.send(ToolMessage::Output((
|
||||
rid,
|
||||
format!("Error writing scope file! {e}"),
|
||||
)));
|
||||
}
|
||||
} else if word.contains(".com")
|
||||
|| word.contains(".org")
|
||||
|| word.contains(".gov")
|
||||
|| word.contains(".site")
|
||||
|| word.contains(".local")
|
||||
|| word.contains(".ad")
|
||||
{
|
||||
if let Err(e) = write!(scope_file, "{}\n", word) {
|
||||
let _ = self.main_tx.send(ToolMessage::Output((
|
||||
rid,
|
||||
format!("Error writing scope file! {e}"),
|
||||
)));
|
||||
}
|
||||
}
|
||||
});
|
||||
let _ = self.main_tx.send(ToolMessage::Output((
|
||||
rid,
|
||||
"[success] scope parsed and scope.md written!".to_string(),
|
||||
)));
|
||||
}
|
||||
"show_config" | "sc" => {
|
||||
let _ = self
|
||||
|
||||
@@ -1086,6 +1086,9 @@ pub fn run_tui(
|
||||
server_lock.action_que.push("disconnect".to_string());
|
||||
}
|
||||
});
|
||||
println!("saving state information");
|
||||
let _ = state.save_all();
|
||||
println!("SAVED!");
|
||||
for handle in handles {
|
||||
handle.join().unwrap();
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user