|
1 | 1 | use anyhow::Result;
|
2 |
| -use caracat::high_level::Config; |
3 | 2 | use caracat::models::Probe;
|
| 3 | +use caracat::rate_limiter::RateLimitingMethod; |
4 | 4 | use log::{info, warn};
|
5 | 5 | use rdkafka::message::BorrowedMessage;
|
6 | 6 | use rdkafka::message::{Headers, Message};
|
7 | 7 | use std::net::IpAddr;
|
| 8 | +use std::net::Ipv4Addr; |
| 9 | +use std::net::Ipv6Addr; |
8 | 10 | use std::time::Duration;
|
9 | 11 | use tokio::task;
|
10 | 12 |
|
11 | 13 | use crate::prober::probe;
|
12 | 14 |
|
| 15 | +/// Probing configuration. |
| 16 | +#[derive(Debug)] |
| 17 | +pub struct Config { |
| 18 | + /// Number of probes to send before calling the rate limiter. |
| 19 | + pub batch_size: u64, |
| 20 | + /// Identifier encoded in the probes (random by default). |
| 21 | + pub instance_id: u16, |
| 22 | + /// Whether to actually send the probes on the network or not. |
| 23 | + pub dry_run: bool, |
| 24 | + /// Do not send probes with ttl < min_ttl. |
| 25 | + pub min_ttl: Option<u8>, |
| 26 | + /// Do not send probes with ttl > max_ttl. |
| 27 | + pub max_ttl: Option<u8>, |
| 28 | + /// Check that replies match valid probes. |
| 29 | + pub integrity_check: bool, |
| 30 | + /// Interface from which to send the packets. |
| 31 | + pub interface: String, |
| 32 | + /// Source IPv4 address |
| 33 | + pub src_ipv4_addr: Option<Ipv4Addr>, |
| 34 | + /// Source IPv6 address |
| 35 | + pub src_ipv6_addr: Option<Ipv6Addr>, |
| 36 | + /// Maximum number of probes to send (unlimited by default). |
| 37 | + pub max_probes: Option<u64>, |
| 38 | + /// Number of packets to send per probe. |
| 39 | + pub packets: u64, |
| 40 | + /// Probing rate in packets per second. |
| 41 | + pub probing_rate: u64, |
| 42 | + /// Method to use to limit the packets rate. |
| 43 | + pub rate_limiting_method: RateLimitingMethod, |
| 44 | + /// Time in seconds to wait after sending the probes to stop the receiver. |
| 45 | + pub receiver_wait_time: Duration, |
| 46 | +} |
| 47 | + |
13 | 48 | fn create_config() -> Config {
|
14 | 49 | Config {
|
15 |
| - allowed_prefixes_file: None, |
16 |
| - blocked_prefixes_file: None, |
17 | 50 | batch_size: 128,
|
18 | 51 | dry_run: false,
|
19 |
| - extra_string: None, |
20 | 52 | min_ttl: None,
|
21 | 53 | max_ttl: None,
|
22 | 54 | integrity_check: true,
|
23 | 55 | instance_id: 0,
|
24 | 56 | interface: caracat::utilities::get_default_interface(),
|
| 57 | + src_ipv4_addr: None, |
| 58 | + src_ipv6_addr: None, |
25 | 59 | max_probes: None,
|
26 | 60 | packets: 1,
|
27 | 61 | probing_rate: 100,
|
|
0 commit comments