|
| 1 | +use std::process::Command; |
| 2 | +use tracing; |
| 3 | + |
| 4 | +use crate::{config::db::Pool, constants, models::{ |
| 5 | + user::{LoginDTO}, |
| 6 | + response::ResponseBody, |
| 7 | +}}; |
| 8 | +use actix_web::{web, HttpRequest, HttpResponse, Result}; |
| 9 | + |
| 10 | +pub async fn scan_online(req: HttpRequest) -> Result<HttpResponse> { |
| 11 | + |
| 12 | + debug!("req: {:?}", req); |
| 13 | + |
| 14 | + let output = |
| 15 | + Command::new("ls") |
| 16 | + .arg("-l") |
| 17 | + .arg("-a") |
| 18 | + .output() |
| 19 | + .expect("ls command failed to start"); |
| 20 | + debug!("status: {:?}", output.status); |
| 21 | + debug!("stdout: {:?}", String::from_utf8_lossy(&output.stdout)); |
| 22 | + debug!("stderr: {:?}", String::from_utf8_lossy(&output.stderr)); |
| 23 | + |
| 24 | + let response = String::from_utf8_lossy(&output.stdout).to_string(); |
| 25 | + Ok(HttpResponse::Ok().json(ResponseBody::new(constants::EMPTY, response))) |
| 26 | + |
| 27 | +} |
| 28 | + |
| 29 | +pub async fn scan_ssl(req: HttpRequest) -> Result<HttpResponse> { |
| 30 | + |
| 31 | + debug!("req: {:?}", req); |
| 32 | + |
| 33 | + let output = |
| 34 | + Command::new("ls") |
| 35 | + .arg("-l") |
| 36 | + .arg("-a") |
| 37 | + .output() |
| 38 | + .expect("ls command failed to start"); |
| 39 | + |
| 40 | + debug!("status: {:?}", output.status); |
| 41 | + debug!("stdout: {:?}", String::from_utf8_lossy(&output.stdout)); |
| 42 | + debug!("stderr: {:?}", String::from_utf8_lossy(&output.stderr)); |
| 43 | + |
| 44 | + let response = String::from_utf8_lossy(&output.stdout).to_string(); |
| 45 | + Ok(HttpResponse::Ok().json(ResponseBody::new(constants::EMPTY, response))) |
| 46 | +} |
0 commit comments