save
This commit is contained in:
@@ -1,12 +1,14 @@
|
||||
use crate::http::header_config::HeadersConfig;
|
||||
use crate::http::simple::HttpSwardArray;
|
||||
use crate::http::{RandomUrlGenerator, SimpleHttpSward};
|
||||
use crate::utils::multiplexed::MultiplexedSward;
|
||||
use crate::http::{RandomUrlGenerator, SimpleHttpRequest, SimpleHttpSward};
|
||||
use crate::utils::multiplexed::{MultiplexedSward, MultiplexedSwardError};
|
||||
use rand::Rng;
|
||||
use reqwest::Method;
|
||||
use std::net::{IpAddr, SocketAddr};
|
||||
use std::sync::Arc;
|
||||
use thiserror::Error;
|
||||
use tower::ServiceExt;
|
||||
use tower::Service;
|
||||
use url::Url;
|
||||
use wyrand::WyRand;
|
||||
|
||||
@@ -21,6 +23,22 @@ pub struct IntegratedHttpSward {
|
||||
request_sender: MultiplexedSward<HttpSwardArray<Box<[SimpleHttpSward]>>>,
|
||||
}
|
||||
|
||||
impl IntegratedHttpSward {
|
||||
pub async fn oneshot(&mut self) -> Result<reqwest::Response, HttpSwardError> {
|
||||
let url = match &mut self.attack_target {
|
||||
AttackTarget::Random(random) => random.generate_url()?,
|
||||
AttackTarget::Fixed(url) => url.clone()
|
||||
};
|
||||
let request = SimpleHttpRequest {
|
||||
body: None,
|
||||
url
|
||||
};
|
||||
let res = self.request_sender.ready()?.call(request);
|
||||
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
||||
impl IntegratedHttpSward {
|
||||
pub fn builder() -> IntegratedHttpSwardBuilder {
|
||||
IntegratedHttpSwardBuilder::new()
|
||||
@@ -180,3 +198,15 @@ pub enum HttpSwardBuildError {
|
||||
#[error("Failed to build reqwest client {0}")]
|
||||
ReqwestBuildError(#[from] reqwest::Error),
|
||||
}
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum HttpSwardError {
|
||||
#[error("Http Response: {0}")]
|
||||
HttpCode(u8),
|
||||
|
||||
#[error(transparent)]
|
||||
MultiplexError(#[from] MultiplexedSwardError<reqwest::Error>),
|
||||
|
||||
#[error(transparent)]
|
||||
BadUrl(#[from] url::ParseError)
|
||||
}
|
||||
Reference in New Issue
Block a user