Compare commits
3 Commits
b0d438c274
...
0a790ccaaa
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0a790ccaaa | ||
|
|
4bca336048 | ||
|
|
7f32f34ca3 |
1
Cargo.lock
generated
1
Cargo.lock
generated
@@ -1289,6 +1289,7 @@ dependencies = [
|
||||
"tokio-tungstenite",
|
||||
"tracing",
|
||||
"tracing-subscriber",
|
||||
"url",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
||||
@@ -11,3 +11,4 @@ tracing-subscriber = { version = "0.3", features = ["fmt"] }
|
||||
clap = { version = "4", features = ["derive"] }
|
||||
futures-util = "0.3"
|
||||
chrono = "0.4"
|
||||
url = "2"
|
||||
|
||||
42
src/main.rs
42
src/main.rs
@@ -3,6 +3,7 @@ use std::path::PathBuf;
|
||||
|
||||
use chrono::Local;
|
||||
use clap::Parser;
|
||||
use url::{form_urlencoded, Url};
|
||||
use futures_util::StreamExt;
|
||||
use tokio::task::JoinSet;
|
||||
use tokio_tungstenite::{
|
||||
@@ -30,6 +31,10 @@ struct Args {
|
||||
/// Enable debug logging (shows request/response headers)
|
||||
#[arg(long)]
|
||||
debug: bool,
|
||||
|
||||
/// Query string parameters to add to all URLs (pre-encoded, e.g., "name=First%20Last&key=value")
|
||||
#[arg(short = 'q', long = "query-string-all")]
|
||||
query_string_all: Option<String>,
|
||||
}
|
||||
|
||||
#[tokio::main]
|
||||
@@ -53,9 +58,44 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
fs::create_dir_all(&session_dir)?;
|
||||
info!("Created session directory: {}", session_dir.display());
|
||||
|
||||
// Parse extra query params once if specified
|
||||
let extra_params: Vec<(String, String)> = args
|
||||
.query_string_all
|
||||
.as_ref()
|
||||
.map(|qs| {
|
||||
form_urlencoded::parse(qs.as_bytes())
|
||||
.map(|(k, v)| (k.into_owned(), v.into_owned()))
|
||||
.collect()
|
||||
})
|
||||
.unwrap_or_default();
|
||||
|
||||
// Process URLs and add query string parameters if specified
|
||||
let mut processed_urls = Vec::new();
|
||||
for url_str in &args.urls {
|
||||
let mut url = Url::parse(url_str)?;
|
||||
|
||||
if !extra_params.is_empty() {
|
||||
let existing: Vec<(String, String)> = url
|
||||
.query_pairs()
|
||||
.map(|(k, v)| (k.into_owned(), v.into_owned()))
|
||||
.collect();
|
||||
|
||||
let mut query_pairs = url.query_pairs_mut();
|
||||
query_pairs.clear();
|
||||
for (k, v) in &existing {
|
||||
query_pairs.append_pair(k, v);
|
||||
}
|
||||
for (k, v) in &extra_params {
|
||||
query_pairs.append_pair(k, v);
|
||||
}
|
||||
}
|
||||
|
||||
processed_urls.push(url.to_string());
|
||||
}
|
||||
|
||||
// Connect to all URLs simultaneously
|
||||
let mut connect_futures = Vec::new();
|
||||
for (idx, url) in args.urls.iter().enumerate() {
|
||||
for (idx, url) in processed_urls.iter().enumerate() {
|
||||
let letter = (b'A' + idx as u8) as char;
|
||||
let bearer_token = args.bearer_token.clone();
|
||||
let url = url.clone();
|
||||
|
||||
Reference in New Issue
Block a user