Make TCP/UDP Port Single/Range an Enum

This commit is contained in:
Samuel Lorch 2023-11-01 04:47:52 +01:00
parent 94f580996c
commit 0d5505597d

View file

@ -34,16 +34,12 @@ pub struct Service {
#[serde(rename_all = "snake_case")] #[serde(rename_all = "snake_case")]
pub enum ServiceType { pub enum ServiceType {
TCP { TCP {
source_port: u64, source: PortDefinition,
source_port_end: Option<u64>, destination: PortDefinition,
destination_port: u64,
destination_port_end: Option<u64>,
}, },
UDP { UDP {
source_port: u64, source: PortDefinition,
source_port_end: Option<u64>, destination: PortDefinition,
destination_port: u64,
destination_port_end: Option<u64>,
}, },
ICMP { ICMP {
code: u8, code: u8,
@ -52,3 +48,10 @@ pub enum ServiceType {
children: Vec<String>, children: Vec<String>,
}, },
} }
#[derive(Serialize, Deserialize, Clone, Debug)]
#[serde(rename_all = "snake_case")]
pub enum PortDefinition {
Single { port: u64 },
Range { start_port: u64, end_port: u64 },
}