mirror of
https://github.com/speatzle/nfsense.git
synced 2025-05-07 17:18:21 +00:00
Add Clone Traits
This commit is contained in:
parent
7c2210e26c
commit
bb1b4d78e4
6 changed files with 30 additions and 30 deletions
|
@ -1,14 +1,14 @@
|
|||
use serde::{Deserialize, Serialize};
|
||||
use validator::Validate;
|
||||
|
||||
#[derive(Serialize, Deserialize, Validate, Default, Debug)]
|
||||
#[derive(Serialize, Deserialize, Clone, Validate, Default, Debug)]
|
||||
pub struct Firewall {
|
||||
forward_rules: Vec<ForwardRule>,
|
||||
destination_nat_rules: Vec<DestinationNATRule>,
|
||||
source_nat_rules: Vec<SourceNATRule>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Validate, Debug)]
|
||||
#[derive(Serialize, Deserialize, Clone, Validate, Debug)]
|
||||
pub struct ForwardRule {
|
||||
pub name: String,
|
||||
pub services: Vec<String>,
|
||||
|
@ -19,7 +19,7 @@ pub struct ForwardRule {
|
|||
pub verdict: Verdict,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Validate, Debug)]
|
||||
#[derive(Serialize, Deserialize, Clone, Validate, Debug)]
|
||||
pub struct DestinationNATRule {
|
||||
pub name: String,
|
||||
pub services: Vec<String>,
|
||||
|
@ -31,7 +31,7 @@ pub struct DestinationNATRule {
|
|||
pub dnat_service: String,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Validate, Debug)]
|
||||
#[derive(Serialize, Deserialize, Clone, Validate, Debug)]
|
||||
pub struct SourceNATRule {
|
||||
pub name: String,
|
||||
pub services: Vec<String>,
|
||||
|
@ -42,7 +42,7 @@ pub struct SourceNATRule {
|
|||
pub snat_type: SNATType,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
#[derive(Serialize, Deserialize, Clone, Debug)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum Verdict {
|
||||
Accept,
|
||||
|
@ -50,7 +50,7 @@ pub enum Verdict {
|
|||
Continue,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
#[derive(Serialize, Deserialize, Clone, Debug)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum SNATType {
|
||||
SNAT {
|
||||
|
|
|
@ -3,13 +3,13 @@ use serde::{Deserialize, Serialize};
|
|||
use std::{collections::HashMap, net::IpAddr};
|
||||
use validator::Validate;
|
||||
|
||||
#[derive(Serialize, Deserialize, Validate, Default, Debug)]
|
||||
#[derive(Serialize, Deserialize, Clone, Validate, Default, Debug)]
|
||||
pub struct Network {
|
||||
pub interfaces: HashMap<String, NetworkInterface>,
|
||||
pub static_routes: Vec<StaticRoute>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Validate, Debug)]
|
||||
#[derive(Serialize, Deserialize, Clone, Validate, Debug)]
|
||||
pub struct NetworkInterface {
|
||||
pub alias: String,
|
||||
pub comment: String,
|
||||
|
@ -17,7 +17,7 @@ pub struct NetworkInterface {
|
|||
pub addressing_mode: AddressingMode,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
#[derive(Serialize, Deserialize, Clone, Debug)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum NetworkInterfaceType {
|
||||
Hardware { device: String },
|
||||
|
@ -26,7 +26,7 @@ pub enum NetworkInterfaceType {
|
|||
Bridge { members: Vec<String> },
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
#[derive(Serialize, Deserialize, Clone, Debug)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum AddressingMode {
|
||||
None,
|
||||
|
@ -34,7 +34,7 @@ pub enum AddressingMode {
|
|||
DHCP,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Validate, Debug)]
|
||||
#[derive(Serialize, Deserialize, Clone, Validate, Debug)]
|
||||
pub struct StaticRoute {
|
||||
pub name: String,
|
||||
pub interface: String,
|
||||
|
|
|
@ -3,19 +3,19 @@ use serde::{Deserialize, Serialize};
|
|||
use std::{collections::HashMap, net::IpAddr};
|
||||
use validator::Validate;
|
||||
|
||||
#[derive(Serialize, Deserialize, Validate, Default, Debug)]
|
||||
#[derive(Serialize, Deserialize, Clone, Validate, Default, Debug)]
|
||||
pub struct Object {
|
||||
pub addresses: HashMap<String, Address>,
|
||||
pub services: HashMap<String, Service>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Validate, Debug)]
|
||||
#[derive(Serialize, Deserialize, Clone, Validate, Debug)]
|
||||
pub struct Address {
|
||||
pub address_type: AddressType,
|
||||
pub comment: String,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
#[derive(Serialize, Deserialize, Clone, Debug)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum AddressType {
|
||||
Host { host: String },
|
||||
|
@ -24,13 +24,13 @@ pub enum AddressType {
|
|||
Group { children: Vec<String> },
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Validate, Debug)]
|
||||
#[derive(Serialize, Deserialize, Clone, Validate, Debug)]
|
||||
pub struct Service {
|
||||
pub service_type: ServiceType,
|
||||
pub comment: String,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
#[derive(Serialize, Deserialize, Clone, Debug)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum ServiceType {
|
||||
TCP {
|
||||
|
|
|
@ -4,14 +4,14 @@ use serde::{Deserialize, Serialize};
|
|||
use std::net::IpAddr;
|
||||
use validator::Validate;
|
||||
|
||||
#[derive(Serialize, Deserialize, Validate, Default, Debug)]
|
||||
#[derive(Serialize, Deserialize, Clone, Validate, Default, Debug)]
|
||||
pub struct Service {
|
||||
pub dhcp_servers: Vec<DHCPServer>,
|
||||
pub dns_servers: Vec<DNSServer>,
|
||||
pub ntp_servers: Vec<NTPServer>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Validate, Debug)]
|
||||
#[derive(Serialize, Deserialize, Clone, Validate, Debug)]
|
||||
pub struct DHCPServer {
|
||||
pub interface: String,
|
||||
pub pool: Vec<String>,
|
||||
|
@ -23,19 +23,19 @@ pub struct DHCPServer {
|
|||
pub comment: String,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Validate, Debug)]
|
||||
#[derive(Serialize, Deserialize, Clone, Validate, Default, Debug)]
|
||||
pub struct DNSServer {
|
||||
pub interface: String,
|
||||
pub comment: String,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Validate, Debug)]
|
||||
#[derive(Serialize, Deserialize, Clone, Validate, Default, Debug)]
|
||||
pub struct NTPServer {
|
||||
pub interface: String,
|
||||
pub comment: String,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
#[derive(Serialize, Deserialize, Clone, Debug)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum GatewayMode {
|
||||
None,
|
||||
|
@ -43,7 +43,7 @@ pub enum GatewayMode {
|
|||
Specify { gateway: String },
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
#[derive(Serialize, Deserialize, Clone, Debug)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum DNSServerMode {
|
||||
None,
|
||||
|
@ -51,7 +51,7 @@ pub enum DNSServerMode {
|
|||
Specify { dns_servers: Vec<String> },
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
#[derive(Serialize, Deserialize, Clone, Debug)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum NTPServerMode {
|
||||
None,
|
||||
|
@ -59,7 +59,7 @@ pub enum NTPServerMode {
|
|||
Specify { ntp_servers: Vec<String> },
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
#[derive(Serialize, Deserialize, Clone, Debug)]
|
||||
pub struct Reservation {
|
||||
pub ip_address: IpAddr,
|
||||
pub hardware_address: MacAddr8,
|
||||
|
|
|
@ -2,12 +2,12 @@ use serde::{Deserialize, Serialize};
|
|||
use std::collections::HashMap;
|
||||
use validator::Validate;
|
||||
|
||||
#[derive(Serialize, Deserialize, Validate, Default, Debug)]
|
||||
#[derive(Serialize, Deserialize, Clone, Validate, Default, Debug)]
|
||||
pub struct System {
|
||||
pub users: HashMap<String, User>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Validate, Default, Debug)]
|
||||
#[derive(Serialize, Deserialize, Clone, Validate, Default, Debug)]
|
||||
pub struct User {
|
||||
pub comment: String,
|
||||
pub hash: String,
|
||||
|
|
|
@ -2,18 +2,18 @@ use serde::{Deserialize, Serialize};
|
|||
use std::collections::HashMap;
|
||||
use validator::Validate;
|
||||
|
||||
#[derive(Serialize, Deserialize, Validate, Default, Debug)]
|
||||
#[derive(Serialize, Deserialize, Clone, Validate, Default, Debug)]
|
||||
pub struct VPN {
|
||||
pub wireguard: Wireguard,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Validate, Default, Debug)]
|
||||
#[derive(Serialize, Deserialize, Clone, Validate, Default, Debug)]
|
||||
pub struct Wireguard {
|
||||
pub interfaces: HashMap<String, WireguardInterface>,
|
||||
pub peers: HashMap<String, WireguardPeer>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Validate, Debug)]
|
||||
#[derive(Serialize, Deserialize, Clone, Validate, Debug)]
|
||||
pub struct WireguardInterface {
|
||||
pub public_key: String,
|
||||
pub private_key: String,
|
||||
|
@ -22,7 +22,7 @@ pub struct WireguardInterface {
|
|||
pub comment: String,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Validate, Debug)]
|
||||
#[derive(Serialize, Deserialize, Clone, Validate, Debug)]
|
||||
pub struct WireguardPeer {
|
||||
pub public_key: String,
|
||||
pub preshared_key: Option<String>,
|
||||
|
|
Loading…
Add table
Reference in a new issue