diff options
Diffstat (limited to 'src/console.rs')
-rw-r--r-- | src/console.rs | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/src/console.rs b/src/console.rs index 912ace2..008109c 100644 --- a/src/console.rs +++ b/src/console.rs @@ -36,8 +36,8 @@ impl ToString for LogMessage { Method::OPTIONS => "#423fe0", _ => "white", }; - format!("<div><span class='ip'>{}</span> <span class='method' style='color: {};'>{}</span> <span class='path'>{}{}</span> <span class='body'>{}</span></div>", - ip, color, self.method, self.path, sanatize(self.uri.to_string()), self.body) + format!("<div class='msg'><span class='ip'>{}</span> <span class='method' style='color: {};'>{}</span> <span class='path'>{}{}</span> <span class='body'>{}</span></div>", + ip, color, self.method, self.path, sanatize(&self.uri.to_string()), self.body) } } @@ -46,12 +46,11 @@ lazy_static! { } pub async fn log(ip: IpAddr, method: Method, uri: Uri, path: Option<String>, body: Option<String>) { - let path = path.unwrap_or_default(); let body = body.unwrap_or_default(); if path == "/api/admin" { - return + return; } tracing::info!("{} {} {}{} {}", &ip, &method, &path, &uri, &body); @@ -61,7 +60,7 @@ pub async fn log(ip: IpAddr, method: Method, uri: Uri, path: Option<String>, bod method, uri, path, - body: beautify(body), + body: beautify(&body), }; let mut lock = LOG.lock().await; @@ -205,14 +204,14 @@ impl Formatter for HtmlFormatter { } } -pub fn sanatize(input: String) -> String { +pub fn sanatize(input: &str) -> String { input .replace('&', "&") .replace('<', "<") .replace('>', ">") } -pub fn beautify(body: String) -> String { +pub fn beautify(body: &str) -> String { let body = sanatize(body); if body.is_empty() { @@ -240,10 +239,18 @@ pub async fn generate() -> Response { <head> <meta charset="UTF-8"> <meta http-equiv="refresh" content="5"> + <link rel="stylesheet" href="/css/main.css"> <link rel="stylesheet" href="css/console.css"> + <link rel="stylesheet" href="css/header.css"> + <link rel="stylesheet" href="/css/admin.css"> <title>XSSBook - Console</title> </head> <body> + <div id="header"> + <span class="logo"><a href="/">xssbook</a></span> + <span class="gtext desc" style="margin-left: 6em; font-size: 2em">Console</span> + </div> + <div style="margin-botton: 4.25em"></div> "# .to_string(); |