added optional timestamp support
This commit is contained in:
parent
d9b0eef4df
commit
d94ca7688c
71
Cargo.lock
generated
71
Cargo.lock
generated
@ -17,6 +17,21 @@ version = "1.0.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe"
|
||||
|
||||
[[package]]
|
||||
name = "android-tzdata"
|
||||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0"
|
||||
|
||||
[[package]]
|
||||
name = "android_system_properties"
|
||||
version = "0.1.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311"
|
||||
dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "anstream"
|
||||
version = "0.6.13"
|
||||
@ -143,6 +158,20 @@ version = "1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
||||
|
||||
[[package]]
|
||||
name = "chrono"
|
||||
version = "0.4.38"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a21f936df1771bf62b77f047b726c4625ff2e8aa607c01ec06e5a05bd8463401"
|
||||
dependencies = [
|
||||
"android-tzdata",
|
||||
"iana-time-zone",
|
||||
"js-sys",
|
||||
"num-traits",
|
||||
"wasm-bindgen",
|
||||
"windows-targets 0.52.5",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "clap"
|
||||
version = "4.5.4"
|
||||
@ -539,6 +568,29 @@ dependencies = [
|
||||
"tracing",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "iana-time-zone"
|
||||
version = "0.1.60"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e7ffbb5a1b541ea2561f8c41c087286cc091e21e556a4f09a8f6cbf17b69b141"
|
||||
dependencies = [
|
||||
"android_system_properties",
|
||||
"core-foundation-sys",
|
||||
"iana-time-zone-haiku",
|
||||
"js-sys",
|
||||
"wasm-bindgen",
|
||||
"windows-core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "iana-time-zone-haiku"
|
||||
version = "0.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f"
|
||||
dependencies = [
|
||||
"cc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "idna"
|
||||
version = "0.5.0"
|
||||
@ -702,6 +754,15 @@ version = "1.0.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "650eef8c711430f1a879fdd01d4745a7deea475becfb90269c06775983bbf086"
|
||||
|
||||
[[package]]
|
||||
name = "num-traits"
|
||||
version = "0.2.19"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num_cpus"
|
||||
version = "1.16.0"
|
||||
@ -1164,6 +1225,7 @@ dependencies = [
|
||||
name = "speedboat"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"chrono",
|
||||
"clap",
|
||||
"colored",
|
||||
"futures",
|
||||
@ -1540,6 +1602,15 @@ dependencies = [
|
||||
"wasm-bindgen",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-core"
|
||||
version = "0.52.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9"
|
||||
dependencies = [
|
||||
"windows-targets 0.52.5",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-sys"
|
||||
version = "0.48.0"
|
||||
|
@ -6,9 +6,10 @@ edition = "2021"
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
chrono = "0.4.38"
|
||||
clap = { version = "4.5.4", features = ["derive"] }
|
||||
colored = "2.1.0"
|
||||
futures = "0.3.30"
|
||||
reqwest = "0.12.4"
|
||||
select = "0.6.0"
|
||||
tokio = { version = "1", features = ["full"] }
|
||||
tokio = { version = "1", features = ["full"] }
|
@ -41,6 +41,10 @@ pub struct Config {
|
||||
#[clap(default_value_t = 0, long = "body")]
|
||||
/// read n bytes of the response document body
|
||||
pub bodysize: usize,
|
||||
|
||||
#[clap(long = "ts")]
|
||||
/// include timestamps of requests
|
||||
pub timestamps: bool,
|
||||
}
|
||||
|
||||
pub fn load() -> Config {
|
||||
|
@ -1,4 +1,5 @@
|
||||
use colored::{ColoredString, Colorize};
|
||||
use chrono::Local;
|
||||
use std::process;
|
||||
|
||||
use super::conf::VERSION;
|
||||
@ -22,7 +23,7 @@ pub fn fmtwhitespace(s: String) -> String {
|
||||
|
||||
pub fn fmtcode(code: u16) -> ColoredString {
|
||||
match code {
|
||||
200..=299 => code.to_string().green(),
|
||||
200..=299 => code.to_string().green().bold(),
|
||||
300..=399 => code.to_string().yellow(),
|
||||
400..=499 => code.to_string().bright_red(),
|
||||
500..=599 => code.to_string().red().bold(),
|
||||
@ -30,6 +31,13 @@ pub fn fmtcode(code: u16) -> ColoredString {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn tstamp() -> String {
|
||||
let date = Local::now();
|
||||
|
||||
let datestr = format!("{}", date.format("[%Y-%m-%d][%H:%M:%S}"));
|
||||
format!("{}", datestr.bright_blue())
|
||||
}
|
||||
|
||||
pub fn parsetitle(s: String) -> String {
|
||||
let title = fmtwhitespace(s);
|
||||
|
||||
|
@ -31,6 +31,7 @@ pub async fn takeoff(args: Config, params: Params) {
|
||||
scodes,
|
||||
params.exclude,
|
||||
args.pulltitles,
|
||||
args.timestamps,
|
||||
args.bodysize
|
||||
)
|
||||
.await;
|
||||
|
@ -1,7 +1,7 @@
|
||||
use reqwest::{redirect::Policy, Client};
|
||||
use std::time::Duration;
|
||||
|
||||
use super::console::parsehit;
|
||||
use super::console::{parsehit, tstamp};
|
||||
use super::modules::*;
|
||||
|
||||
pub fn mkclient(redir: bool) -> Result<Client, reqwest::Error> {
|
||||
@ -30,6 +30,7 @@ pub async fn query(
|
||||
codes: Vec<u16>,
|
||||
exclude: bool,
|
||||
titles: bool,
|
||||
timestamps: bool,
|
||||
bodysize: usize,
|
||||
) -> Result<(), reqwest::Error> {
|
||||
let response: reqwest::Response;
|
||||
@ -57,6 +58,10 @@ pub async fn query(
|
||||
|
||||
let mut out = parsehit(sc, url);
|
||||
|
||||
if timestamps {
|
||||
out = format!("{} {}", tstamp(), out);
|
||||
}
|
||||
|
||||
if titles {
|
||||
out = format!("{} {}", out, get_title(&body));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user