From 26cf1dfaef205bc01fe3c720c49aa54c4073890c Mon Sep 17 00:00:00 2001 From: Erin Power Date: Mon, 21 Feb 2022 07:48:35 +0100 Subject: [PATCH] Update capture --- src/filters/capture/affix.rs | 4 ++-- src/filters/capture/config.rs | 4 ++-- src/filters/capture/regex.rs | 3 ++- src/main.rs | 3 +-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/filters/capture/affix.rs b/src/filters/capture/affix.rs index d1ae743ec0..1bc2525cf5 100644 --- a/src/filters/capture/affix.rs +++ b/src/filters/capture/affix.rs @@ -18,7 +18,7 @@ fn is_valid_size(contents: &[u8], size: u32, metrics: &Metrics) -> bool { } /// Capture from the start of the packet. -#[derive(serde::Serialize, serde::Deserialize, Debug, PartialEq)] +#[derive(serde::Serialize, serde::Deserialize, Debug, PartialEq, schemars::JsonSchema)] pub struct Prefix { /// Whether captured bytes are removed from the original packet. #[serde(default)] @@ -40,7 +40,7 @@ impl super::CaptureStrategy for Prefix { } /// Capture from the end of the packet. -#[derive(serde::Serialize, serde::Deserialize, Debug, PartialEq)] +#[derive(serde::Serialize, serde::Deserialize, Debug, PartialEq, schemars::JsonSchema)] pub struct Suffix { /// Whether captured bytes are removed from the original packet. pub size: u32, diff --git a/src/filters/capture/config.rs b/src/filters/capture/config.rs index 139b826f65..42df80818d 100644 --- a/src/filters/capture/config.rs +++ b/src/filters/capture/config.rs @@ -22,7 +22,7 @@ use super::{proto, Prefix, Regex, Suffix}; use crate::filters::{metadata::CAPTURED_BYTES, ConvertProtoConfigError}; /// Strategy to apply for acquiring a set of bytes in the UDP packet -#[derive(Serialize, Deserialize, Debug, PartialEq)] +#[derive(Serialize, Deserialize, Debug, PartialEq, schemars::JsonSchema)] #[serde(tag = "kind")] pub enum Strategy { /// Looks for the set of bytes at the beginning of the packet @@ -46,7 +46,7 @@ impl Strategy { } } -#[derive(Debug, PartialEq)] +#[derive(Debug, PartialEq, schemars::JsonSchema)] pub struct Config { /// The key to use when storing the captured value in the filter context. /// If a match was found it is available diff --git a/src/filters/capture/regex.rs b/src/filters/capture/regex.rs index e8ee3da42f..0f52c0d3a5 100644 --- a/src/filters/capture/regex.rs +++ b/src/filters/capture/regex.rs @@ -3,10 +3,11 @@ use crate::metadata::Value; use super::Metrics; /// Capture from the start of the packet. -#[derive(serde::Serialize, serde::Deserialize, Debug)] +#[derive(serde::Serialize, serde::Deserialize, Debug, schemars::JsonSchema)] pub struct Regex { /// The regular expression to use for capture. #[serde(with = "serde_regex")] + #[schemars(with = "String")] pub pattern: regex::bytes::Regex, } diff --git a/src/main.rs b/src/main.rs index 1b284341ff..35d28ef012 100644 --- a/src/main.rs +++ b/src/main.rs @@ -14,9 +14,8 @@ * limitations under the License. */ -use std::{sync::Arc, path::PathBuf}; +use std::path::PathBuf; -use clap::{Arg, Command}; use tracing::info; const VERSION: &str = env!("CARGO_PKG_VERSION");