Yneth/distress-releases

targets-path

Closed this issue · 2 comments

Could you please describe config file format for "targets-path"&

Yneth commented

target models:

#[enum_dispatch]
#[serde(tag = "kind", rename_all = "snake_case")]
pub enum Target {
    HttpFlood(HttpTarget),
    HttpStress(HttpTarget),
    SynFlood(IpTarget), // unsupported
    TcpFlood(IpTarget),
    UdpFlood(IpTarget), // unsupported
}

pub struct HttpTarget {
    pub method: String,
    pub ip: String,
    pub port: u16,
    pub url: Option<Uri>,
    pub body: Option<Body>,
    pub headers: Option<HashMap<String, String>>,
}

pub struct IpTarget {
    pub ip: String,
    pub port: u16,
}

pub enum Body {
    Fixed(String),
    Template(TemplateString),  // such strings start with `template:` prefix
}

json examples:

[
  {"kind":"http_flood","method":"POST","ip":"127.0.0.1","port": 443, "url": "https://google.com","headers":{"Content-Type": "application/json"}, "body": "template:{{ random(256) }}"},
  {"kind":"http_flood","method":"GET","ip":"127.0.0.1","port": 443, "url": "https://google.com", "body": "fixed_string"},
  {"kind":"http_stress","method":"GET","ip":"127.0.0.1","port": 443, "url": "https://google.com"},
  {"kind":"tcp_flood","ip":"127.0.0.1","port": 443}
]

Yneth commented

@truesysadmin extended format to the following:

pub struct HttpTarget {
    pub method: String,
    pub ip: String,
    pub port: u16,
    pub url: Option<Uri>,
>>>     pub path_and_query: Option<PathAndQuery>,
    pub body: Option<Body>,
    pub headers: Option<HashMap<String, String>>,
}

Added support for repeat_rand(str,max_count) command - randomly repeats str 1 or max_count times.

Json example:

[
  {"kind":"http_flood",
    "method":"POST",
    "ip":"127.0.0.1",
    "port": 443, 
    "url": "https://google.com",
    "path_and_query": "template:/url{{repeat_rand(xX,10)}}"
  }
]