Compare commits
14 Commits
chore/clea
...
feat/st_te
| Author | SHA1 | Date | |
|---|---|---|---|
| c631b3aef9 | |||
| 3e2d94cff0 | |||
| c9e39d11ad | |||
| 5ed14b75ed | |||
| 25a45096f8 | |||
| 74252ded5c | |||
| 0ecadbfb97 | |||
| eb492f3ca9 | |||
| de3c8e9a41 | |||
| 2ef2d9f064 | |||
| d2d18205e9 | |||
| 0b55a6fb53 | |||
| 001dd5269c | |||
| 9978acf16d |
80
Cargo.lock
generated
80
Cargo.lock
generated
@@ -1970,6 +1970,25 @@ dependencies = [
|
||||
"url",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "example-opnsense-node-exporter"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"async-trait",
|
||||
"cidr",
|
||||
"env_logger",
|
||||
"harmony",
|
||||
"harmony_cli",
|
||||
"harmony_macros",
|
||||
"harmony_secret",
|
||||
"harmony_secret_derive",
|
||||
"harmony_types",
|
||||
"log",
|
||||
"serde",
|
||||
"tokio",
|
||||
"url",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "example-postgresql"
|
||||
version = "0.1.0"
|
||||
@@ -2000,25 +2019,6 @@ dependencies = [
|
||||
"url",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "example-opnsense-node-exporter"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"async-trait",
|
||||
"cidr",
|
||||
"env_logger",
|
||||
"harmony",
|
||||
"harmony_cli",
|
||||
"harmony_macros",
|
||||
"harmony_secret",
|
||||
"harmony_secret_derive",
|
||||
"harmony_types",
|
||||
"log",
|
||||
"serde",
|
||||
"tokio",
|
||||
"url",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "example-pxe"
|
||||
version = "0.1.0"
|
||||
@@ -3482,6 +3482,25 @@ dependencies = [
|
||||
"thiserror 1.0.69",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "json-prompt"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"brocade",
|
||||
"cidr",
|
||||
"env_logger",
|
||||
"harmony",
|
||||
"harmony_cli",
|
||||
"harmony_macros",
|
||||
"harmony_secret",
|
||||
"harmony_secret_derive",
|
||||
"harmony_types",
|
||||
"log",
|
||||
"serde",
|
||||
"tokio",
|
||||
"url",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "jsonpath-rust"
|
||||
version = "0.7.5"
|
||||
@@ -6080,6 +6099,25 @@ dependencies = [
|
||||
"syn 2.0.106",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sttest"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"brocade",
|
||||
"cidr",
|
||||
"env_logger",
|
||||
"harmony",
|
||||
"harmony_cli",
|
||||
"harmony_macros",
|
||||
"harmony_secret",
|
||||
"harmony_secret_derive",
|
||||
"harmony_types",
|
||||
"log",
|
||||
"serde",
|
||||
"tokio",
|
||||
"url",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "subtle"
|
||||
version = "2.6.1"
|
||||
@@ -7375,7 +7413,7 @@ checksum = "cfe53a6657fd280eaa890a3bc59152892ffa3e30101319d168b781ed6529b049"
|
||||
[[package]]
|
||||
name = "yaserde"
|
||||
version = "0.12.0"
|
||||
source = "git+https://github.com/jggc/yaserde.git#adfdb1c5f4d054f114e5bd0ea7bda9c07a369def"
|
||||
source = "git+https://github.com/jggc/yaserde.git#2eacb304113beee7270a10b81046d40ed3a99550"
|
||||
dependencies = [
|
||||
"log",
|
||||
"xml-rs",
|
||||
@@ -7384,7 +7422,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "yaserde_derive"
|
||||
version = "0.12.0"
|
||||
source = "git+https://github.com/jggc/yaserde.git#adfdb1c5f4d054f114e5bd0ea7bda9c07a369def"
|
||||
source = "git+https://github.com/jggc/yaserde.git#2eacb304113beee7270a10b81046d40ed3a99550"
|
||||
dependencies = [
|
||||
"heck",
|
||||
"log",
|
||||
|
||||
@@ -3,12 +3,13 @@ use std::{
|
||||
sync::{Arc, OnceLock},
|
||||
};
|
||||
|
||||
use brocade::BrocadeOptions;
|
||||
use cidr::Ipv4Cidr;
|
||||
use harmony::{
|
||||
config::secret::SshKeyPair,
|
||||
data::{FileContent, FilePath},
|
||||
hardware::{HostCategory, Location, PhysicalHost, SwitchGroup},
|
||||
infra::{brocade::UnmanagedSwitch, opnsense::OPNSenseManagementInterface},
|
||||
infra::{brocade::BrocadeSwitchClient, opnsense::OPNSenseManagementInterface},
|
||||
inventory::Inventory,
|
||||
modules::{
|
||||
http::StaticFilesHttpScore,
|
||||
@@ -22,11 +23,10 @@ use harmony::{
|
||||
topology::{LogicalHost, UnmanagedRouter},
|
||||
};
|
||||
use harmony_macros::{ip, mac_address};
|
||||
use harmony_secret::SecretManager;
|
||||
use harmony_secret::{Secret, SecretManager};
|
||||
use harmony_types::net::Url;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
/// This example can be run this way
|
||||
/// KUBECONFIG=~/path/to/ncd/kubeconfig HARMONY_USE_LOCAL_K3D=false HARMONY_SECRET_STORE=file HARMONY_SECRET_NAMESPACE=ncd0 cargo run
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
let firewall = harmony::topology::LogicalHost {
|
||||
@@ -34,7 +34,24 @@ async fn main() {
|
||||
name: String::from("fw0"),
|
||||
};
|
||||
|
||||
let switch_client = UnmanagedSwitch {};
|
||||
let switch_auth = SecretManager::get_or_prompt::<BrocadeSwitchAuth>()
|
||||
.await
|
||||
.expect("Failed to get credentials");
|
||||
|
||||
let switches: Vec<IpAddr> = vec![ip!("192.168.33.101")];
|
||||
let brocade_options = BrocadeOptions {
|
||||
dry_run: *harmony::config::DRY_RUN,
|
||||
..Default::default()
|
||||
};
|
||||
let switch_client = BrocadeSwitchClient::init(
|
||||
&switches,
|
||||
&switch_auth.username,
|
||||
&switch_auth.password,
|
||||
brocade_options,
|
||||
)
|
||||
.await
|
||||
.expect("Failed to connect to switch");
|
||||
|
||||
let switch_client = Arc::new(switch_client);
|
||||
|
||||
let opnsense = Arc::new(
|
||||
@@ -174,3 +191,9 @@ async fn main() {
|
||||
.await
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
#[derive(Secret, Serialize, Deserialize, Debug)]
|
||||
pub struct BrocadeSwitchAuth {
|
||||
pub username: String,
|
||||
pub password: String,
|
||||
}
|
||||
|
||||
22
examples/sttest/Cargo.toml
Normal file
22
examples/sttest/Cargo.toml
Normal file
@@ -0,0 +1,22 @@
|
||||
[package]
|
||||
name = "sttest"
|
||||
edition = "2024"
|
||||
version.workspace = true
|
||||
readme.workspace = true
|
||||
license.workspace = true
|
||||
publish = false
|
||||
|
||||
[dependencies]
|
||||
harmony = { path = "../../harmony" }
|
||||
harmony_cli = { path = "../../harmony_cli" }
|
||||
harmony_types = { path = "../../harmony_types" }
|
||||
cidr = { workspace = true }
|
||||
tokio = { workspace = true }
|
||||
harmony_macros = { path = "../../harmony_macros" }
|
||||
harmony_secret = { path = "../../harmony_secret" }
|
||||
harmony_secret_derive = { path = "../../harmony_secret_derive" }
|
||||
log = { workspace = true }
|
||||
env_logger = { workspace = true }
|
||||
url = { workspace = true }
|
||||
serde = { workspace = true }
|
||||
brocade = { path = "../../brocade" }
|
||||
1
examples/sttest/data
Symbolic link
1
examples/sttest/data
Symbolic link
@@ -0,0 +1 @@
|
||||
../../data/
|
||||
4
examples/sttest/env.sh
Normal file
4
examples/sttest/env.sh
Normal file
@@ -0,0 +1,4 @@
|
||||
export HARMONY_SECRET_NAMESPACE=sttest0
|
||||
export HARMONY_SECRET_STORE=file
|
||||
export HARMONY_DATABASE_URL=sqlite://harmony_sttest0.sqlite
|
||||
export RUST_LOG=info
|
||||
41
examples/sttest/src/main.rs
Normal file
41
examples/sttest/src/main.rs
Normal file
@@ -0,0 +1,41 @@
|
||||
mod topology;
|
||||
|
||||
use crate::topology::{get_inventory, get_topology};
|
||||
use harmony::{
|
||||
config::secret::SshKeyPair,
|
||||
data::{FileContent, FilePath},
|
||||
modules::{
|
||||
inventory::HarmonyDiscoveryStrategy,
|
||||
okd::{installation::OKDInstallationPipeline, ipxe::OKDIpxeScore},
|
||||
},
|
||||
score::Score,
|
||||
topology::HAClusterTopology,
|
||||
};
|
||||
use harmony_secret::SecretManager;
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
// env_logger::init();
|
||||
|
||||
let inventory = get_inventory();
|
||||
let topology = get_topology().await;
|
||||
|
||||
let ssh_key = SecretManager::get_or_prompt::<SshKeyPair>().await.unwrap();
|
||||
|
||||
let mut scores: Vec<Box<dyn Score<HAClusterTopology>>> = vec![Box::new(OKDIpxeScore {
|
||||
kickstart_filename: "inventory.kickstart".to_string(),
|
||||
harmony_inventory_agent: "harmony_inventory_agent".to_string(),
|
||||
cluster_pubkey: FileContent {
|
||||
path: FilePath::Relative("cluster_ssh_key.pub".to_string()),
|
||||
content: ssh_key.public,
|
||||
},
|
||||
})];
|
||||
|
||||
// let mut scores: Vec<Box<dyn Score<HAClusterTopology>>> = vec![];
|
||||
scores
|
||||
.append(&mut OKDInstallationPipeline::get_all_scores(HarmonyDiscoveryStrategy::MDNS).await);
|
||||
|
||||
harmony_cli::run(inventory, topology, scores, None)
|
||||
.await
|
||||
.unwrap();
|
||||
}
|
||||
99
examples/sttest/src/topology.rs
Normal file
99
examples/sttest/src/topology.rs
Normal file
@@ -0,0 +1,99 @@
|
||||
use cidr::Ipv4Cidr;
|
||||
use harmony::{
|
||||
hardware::{Location, SwitchGroup},
|
||||
infra::{brocade::UnmanagedSwitch, opnsense::OPNSenseManagementInterface},
|
||||
inventory::Inventory,
|
||||
topology::{HAClusterTopology, LogicalHost, UnmanagedRouter},
|
||||
};
|
||||
use harmony_macros::{ip, ipv4};
|
||||
use harmony_secret::{Secret, SecretManager};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::{
|
||||
net::IpAddr,
|
||||
sync::{Arc, OnceLock},
|
||||
};
|
||||
|
||||
#[derive(Secret, Serialize, Deserialize, Debug, PartialEq)]
|
||||
struct OPNSenseFirewallConfig {
|
||||
username: String,
|
||||
password: String,
|
||||
}
|
||||
|
||||
pub async fn get_topology() -> HAClusterTopology {
|
||||
let firewall = harmony::topology::LogicalHost {
|
||||
ip: ip!("192.168.40.1"),
|
||||
name: String::from("fw0"),
|
||||
};
|
||||
|
||||
let switch_client = UnmanagedSwitch::init()
|
||||
.await
|
||||
.expect("Failed to connect to switch");
|
||||
|
||||
let switch_client = Arc::new(switch_client);
|
||||
|
||||
let config = SecretManager::get_or_prompt::<OPNSenseFirewallConfig>().await;
|
||||
let config = config.unwrap();
|
||||
|
||||
let opnsense = Arc::new(
|
||||
harmony::infra::opnsense::OPNSenseFirewall::new(
|
||||
firewall,
|
||||
None,
|
||||
&config.username,
|
||||
&config.password,
|
||||
)
|
||||
.await,
|
||||
);
|
||||
let lan_subnet = ipv4!("192.168.40.0");
|
||||
let gateway_ipv4 = ipv4!("192.168.40.1");
|
||||
let gateway_ip = IpAddr::V4(gateway_ipv4);
|
||||
harmony::topology::HAClusterTopology {
|
||||
kubeconfig: None,
|
||||
domain_name: "sttest0.harmony.mcd".to_string(),
|
||||
router: Arc::new(UnmanagedRouter::new(
|
||||
gateway_ip,
|
||||
Ipv4Cidr::new(lan_subnet, 24).unwrap(),
|
||||
)),
|
||||
load_balancer: opnsense.clone(),
|
||||
firewall: opnsense.clone(),
|
||||
tftp_server: opnsense.clone(),
|
||||
http_server: opnsense.clone(),
|
||||
dhcp_server: opnsense.clone(),
|
||||
dns_server: opnsense.clone(),
|
||||
control_plane: vec![
|
||||
LogicalHost {
|
||||
ip: ip!("192.168.40.20"),
|
||||
name: "cp0".to_string(),
|
||||
},
|
||||
LogicalHost {
|
||||
ip: ip!("192.168.40.21"),
|
||||
name: "cp1".to_string(),
|
||||
},
|
||||
LogicalHost {
|
||||
ip: ip!("192.168.40.22"),
|
||||
name: "cp2".to_string(),
|
||||
},
|
||||
],
|
||||
bootstrap_host: LogicalHost {
|
||||
ip: ip!("192.168.40.10"),
|
||||
name: "bootstrap".to_string(),
|
||||
},
|
||||
workers: vec![LogicalHost {
|
||||
ip: ip!("192.168.40.30"),
|
||||
name: "wk0".to_string(),
|
||||
}],
|
||||
node_exporter: opnsense.clone(),
|
||||
switch_client: switch_client.clone(),
|
||||
network_manager: OnceLock::new(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_inventory() -> Inventory {
|
||||
Inventory {
|
||||
location: Location::new("Sylvain's basement".to_string(), "Charlesbourg".to_string()),
|
||||
switch: SwitchGroup::from([]),
|
||||
firewall_mgmt: Box::new(OPNSenseManagementInterface::new()),
|
||||
storage_host: vec![],
|
||||
worker_host: vec![],
|
||||
control_plane_host: vec![],
|
||||
}
|
||||
}
|
||||
@@ -21,9 +21,7 @@ use serde::Serialize;
|
||||
// -------------------------------------------------------------------------------------------------
|
||||
|
||||
#[derive(Debug, Clone, Serialize, new)]
|
||||
pub struct OKDSetup01InventoryScore {
|
||||
discovery_strategy: HarmonyDiscoveryStrategy,
|
||||
}
|
||||
pub struct OKDSetup01InventoryScore {}
|
||||
|
||||
impl Score<HAClusterTopology> for OKDSetup01InventoryScore {
|
||||
fn create_interpret(&self) -> Box<dyn Interpret<HAClusterTopology>> {
|
||||
@@ -79,8 +77,6 @@ impl Interpret<HAClusterTopology> for OKDSetup01InventoryInterpret {
|
||||
info!("Setting up base DNS config for OKD");
|
||||
let cluster_domain = &topology.domain_name;
|
||||
let load_balancer_ip = &topology.load_balancer.get_ip();
|
||||
// TODO reactivate automatic dns config when migration from unbound to dnsmasq is done
|
||||
// For now we output the instruction for the user to do it manually
|
||||
inquire::Confirm::new(&format!(
|
||||
"Set hostnames manually in your opnsense dnsmasq config :
|
||||
*.apps.{cluster_domain} -> {load_balancer_ip}
|
||||
@@ -92,6 +88,7 @@ When you can dig them, confirm to continue.
|
||||
))
|
||||
.prompt()
|
||||
.expect("Prompt error");
|
||||
// TODO reactivate automatic dns config when migration from unbound to dnsmasq is done
|
||||
// OKDDnsScore::new(topology)
|
||||
// .interpret(inventory, topology)
|
||||
// .await?;
|
||||
@@ -108,7 +105,7 @@ When you can dig them, confirm to continue.
|
||||
DiscoverHostForRoleScore {
|
||||
role: HostRole::Bootstrap,
|
||||
number_desired_hosts: 1,
|
||||
discovery_strategy: self.score.discovery_strategy.clone(),
|
||||
discovery_strategy: HarmonyDiscoveryStrategy::MDNS,
|
||||
}
|
||||
.interpret(inventory, topology)
|
||||
.await?;
|
||||
|
||||
@@ -76,8 +76,6 @@ impl OKDSetup02BootstrapInterpret {
|
||||
}
|
||||
}
|
||||
|
||||
/// Runs the openshift-install commands locally to prepare ignition files
|
||||
/// Uploads the ignition files to the statis http server
|
||||
async fn prepare_ignition_files(
|
||||
&self,
|
||||
inventory: &Inventory,
|
||||
|
||||
@@ -22,7 +22,7 @@ pub struct OKDSetup04WorkersScore {
|
||||
impl Score<HAClusterTopology> for OKDSetup04WorkersScore {
|
||||
fn create_interpret(&self) -> Box<dyn Interpret<HAClusterTopology>> {
|
||||
Box::new(OKDNodeInterpret::new(
|
||||
HostRole::ControlPlane,
|
||||
HostRole::Worker,
|
||||
self.discovery_strategy.clone(),
|
||||
))
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ impl OKDInstallationPipeline {
|
||||
discovery_strategy: HarmonyDiscoveryStrategy,
|
||||
) -> Vec<Box<dyn Score<HAClusterTopology>>> {
|
||||
vec![
|
||||
Box::new(OKDSetup01InventoryScore::new(discovery_strategy.clone())),
|
||||
Box::new(OKDSetup01InventoryScore::new()),
|
||||
Box::new(OKDSetup02BootstrapScore::new()),
|
||||
Box::new(OKDSetup03ControlPlaneScore {
|
||||
discovery_strategy: discovery_strategy.clone(),
|
||||
|
||||
@@ -9,6 +9,7 @@ license.workspace = true
|
||||
serde = { version = "1.0.123", features = [ "derive" ] }
|
||||
log = { workspace = true }
|
||||
env_logger = { workspace = true }
|
||||
#yaserde = { path = "../../yaserde/yaserde" }
|
||||
yaserde = { git = "https://github.com/jggc/yaserde.git" }
|
||||
yaserde_derive = { git = "https://github.com/jggc/yaserde.git" }
|
||||
xml-rs = "0.8"
|
||||
|
||||
@@ -8,6 +8,8 @@ pub struct Pischem {
|
||||
|
||||
#[derive(Default, PartialEq, Debug, YaSerialize, YaDeserialize)]
|
||||
pub struct Caddy {
|
||||
#[yaserde(attribute = true)]
|
||||
pub version: Option<String>,
|
||||
pub general: CaddyGeneral,
|
||||
pub reverseproxy: MaybeString,
|
||||
}
|
||||
|
||||
@@ -8,6 +8,8 @@ pub struct DnsMasq {
|
||||
pub version: String,
|
||||
#[yaserde(attribute = true)]
|
||||
pub persisted_at: Option<String>,
|
||||
#[yaserde(attribute = true)]
|
||||
pub description: Option<String>,
|
||||
|
||||
pub enable: u8,
|
||||
pub regdhcp: u8,
|
||||
@@ -23,7 +25,7 @@ pub struct DnsMasq {
|
||||
pub dnssec: u8,
|
||||
pub regdhcpdomain: MaybeString,
|
||||
pub interface: Option<String>,
|
||||
pub port: Option<u32>,
|
||||
pub port: Option<MaybeString>,
|
||||
pub dns_forward_max: MaybeString,
|
||||
pub cache_size: MaybeString,
|
||||
pub local_ttl: MaybeString,
|
||||
@@ -73,6 +75,8 @@ pub struct Dhcp {
|
||||
pub reply_delay: MaybeString,
|
||||
pub enable_ra: u8,
|
||||
pub nosync: u8,
|
||||
pub log_dhcp: Option<u8>,
|
||||
pub log_quiet: Option<u8>,
|
||||
}
|
||||
|
||||
// Represents a single <dhcp_ranges> element.
|
||||
|
||||
@@ -598,7 +598,7 @@ pub struct HAProxyServer {
|
||||
pub ssl_client_certificate: MaybeString,
|
||||
#[yaserde(rename = "maxConnections")]
|
||||
pub max_connections: MaybeString,
|
||||
pub weight: Option<u32>,
|
||||
pub weight: Option<MaybeString>,
|
||||
#[yaserde(rename = "checkInterval")]
|
||||
pub check_interval: MaybeString,
|
||||
#[yaserde(rename = "checkDownInterval")]
|
||||
|
||||
@@ -30,6 +30,7 @@ pub struct OPNsense {
|
||||
pub staticroutes: StaticRoutes,
|
||||
pub ca: MaybeString,
|
||||
pub gateways: Option<RawXml>,
|
||||
pub hostwatch: Option<RawXml>,
|
||||
pub cert: Vec<Cert>,
|
||||
pub dhcpdv6: DhcpDv6,
|
||||
pub virtualip: VirtualIp,
|
||||
@@ -162,11 +163,15 @@ pub struct Username {
|
||||
|
||||
#[derive(Default, PartialEq, Debug, YaSerialize, YaDeserialize)]
|
||||
pub struct Sysctl {
|
||||
#[yaserde(attribute = true)]
|
||||
pub version: Option<String>,
|
||||
pub item: Vec<SysctlItem>,
|
||||
}
|
||||
|
||||
#[derive(Default, PartialEq, Debug, YaSerialize, YaDeserialize)]
|
||||
pub struct SysctlItem {
|
||||
#[yaserde(attribute = true)]
|
||||
pub uuid: Option<String>,
|
||||
pub descr: Option<MaybeString>,
|
||||
pub tunable: Option<String>,
|
||||
pub value: Option<MaybeString>,
|
||||
@@ -174,6 +179,8 @@ pub struct SysctlItem {
|
||||
|
||||
#[derive(Default, PartialEq, Debug, YaSerialize, YaDeserialize)]
|
||||
pub struct System {
|
||||
#[yaserde(attribute = true)]
|
||||
pub uuid: Option<String>,
|
||||
pub use_mfs_tmp: Option<MaybeString>,
|
||||
pub use_mfs_var: Option<MaybeString>,
|
||||
pub serialspeed: u32,
|
||||
@@ -268,6 +275,8 @@ pub struct Bogons {
|
||||
|
||||
#[derive(Default, PartialEq, Debug, YaSerialize, YaDeserialize)]
|
||||
pub struct Group {
|
||||
#[yaserde(attribute = true)]
|
||||
pub uuid: Option<String>,
|
||||
pub name: String,
|
||||
pub description: Option<String>,
|
||||
pub scope: String,
|
||||
@@ -280,6 +289,8 @@ pub struct Group {
|
||||
|
||||
#[derive(Default, PartialEq, Debug, YaSerialize, YaDeserialize)]
|
||||
pub struct User {
|
||||
#[yaserde(attribute = true)]
|
||||
pub uuid: Option<String>,
|
||||
pub name: String,
|
||||
pub descr: MaybeString,
|
||||
pub scope: String,
|
||||
@@ -463,6 +474,8 @@ pub struct OPNsenseXmlSection {
|
||||
pub openvpn: ConfigOpenVPN,
|
||||
#[yaserde(rename = "Gateways")]
|
||||
pub gateways: RawXml,
|
||||
#[yaserde(rename = "Hostwatch")]
|
||||
pub hostwatch: Option<RawXml>,
|
||||
#[yaserde(rename = "HAProxy")]
|
||||
pub haproxy: Option<HAProxy>,
|
||||
}
|
||||
@@ -1143,9 +1156,9 @@ pub struct UnboundGeneral {
|
||||
pub dns64: MaybeString,
|
||||
pub dns64prefix: MaybeString,
|
||||
pub noarecords: MaybeString,
|
||||
pub regdhcp: Option<i8>,
|
||||
pub regdhcp: Option<MaybeString>,
|
||||
pub regdhcpdomain: MaybeString,
|
||||
pub regdhcpstatic: Option<i8>,
|
||||
pub regdhcpstatic: Option<MaybeString>,
|
||||
pub noreglladdr6: MaybeString,
|
||||
pub noregrecords: MaybeString,
|
||||
pub txtsupport: MaybeString,
|
||||
@@ -1153,27 +1166,27 @@ pub struct UnboundGeneral {
|
||||
pub local_zone_type: String,
|
||||
pub outgoing_interface: MaybeString,
|
||||
pub enable_wpad: MaybeString,
|
||||
pub safesearch: MaybeString,
|
||||
pub safesearch: Option<MaybeString>,
|
||||
}
|
||||
|
||||
#[derive(Default, PartialEq, Debug, YaSerialize, YaDeserialize)]
|
||||
pub struct Advanced {
|
||||
pub hideidentity: Option<i8>,
|
||||
pub hideversion: Option<i8>,
|
||||
pub prefetch: Option<i8>,
|
||||
pub prefetchkey: Option<i8>,
|
||||
pub dnssecstripped: Option<i8>,
|
||||
pub hideidentity: Option<MaybeString>,
|
||||
pub hideversion: Option<MaybeString>,
|
||||
pub prefetch: Option<MaybeString>,
|
||||
pub prefetchkey: Option<MaybeString>,
|
||||
pub dnssecstripped: Option<MaybeString>,
|
||||
pub aggressivensec: Option<i8>,
|
||||
pub serveexpired: Option<i8>,
|
||||
pub serveexpired: Option<MaybeString>,
|
||||
pub serveexpiredreplyttl: MaybeString,
|
||||
pub serveexpiredttl: MaybeString,
|
||||
pub serveexpiredttlreset: Option<i32>,
|
||||
pub serveexpiredttlreset: Option<MaybeString>,
|
||||
pub serveexpiredclienttimeout: MaybeString,
|
||||
pub qnameminstrict: Option<i32>,
|
||||
pub extendedstatistics: Option<i32>,
|
||||
pub logqueries: Option<i32>,
|
||||
pub logreplies: Option<i32>,
|
||||
pub logtagqueryreply: Option<i32>,
|
||||
pub qnameminstrict: Option<MaybeString>,
|
||||
pub extendedstatistics: Option<MaybeString>,
|
||||
pub logqueries: Option<MaybeString>,
|
||||
pub logreplies: Option<MaybeString>,
|
||||
pub logtagqueryreply: Option<MaybeString>,
|
||||
pub logservfail: MaybeString,
|
||||
pub loglocalactions: MaybeString,
|
||||
pub logverbosity: i32,
|
||||
@@ -1216,12 +1229,12 @@ pub struct Dnsbl {
|
||||
pub blocklists: Option<MaybeString>,
|
||||
pub wildcards: Option<MaybeString>,
|
||||
pub address: Option<MaybeString>,
|
||||
pub nxdomain: Option<i32>,
|
||||
pub nxdomain: Option<MaybeString>,
|
||||
}
|
||||
|
||||
#[derive(Default, PartialEq, Debug, YaSerialize, YaDeserialize)]
|
||||
pub struct Forwarding {
|
||||
pub enabled: Option<i32>,
|
||||
pub enabled: Option<MaybeString>,
|
||||
}
|
||||
|
||||
#[derive(Default, PartialEq, Debug, YaSerialize, YaDeserialize)]
|
||||
@@ -1243,7 +1256,7 @@ pub struct Host {
|
||||
pub ttl: Option<MaybeString>,
|
||||
pub server: String,
|
||||
pub description: Option<String>,
|
||||
pub txtdata: MaybeString,
|
||||
pub txtdata: Option<MaybeString>,
|
||||
}
|
||||
|
||||
impl Host {
|
||||
@@ -1259,7 +1272,7 @@ impl Host {
|
||||
ttl: Some(MaybeString::default()),
|
||||
mx: MaybeString::default(),
|
||||
description: None,
|
||||
txtdata: MaybeString::default(),
|
||||
txtdata: Some(MaybeString::default()),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1421,7 +1434,7 @@ pub struct StaticRoutes {
|
||||
#[yaserde(attribute = true)]
|
||||
pub version: String,
|
||||
#[yaserde(rename = "route")]
|
||||
pub route: Option<MaybeString>,
|
||||
pub route: Option<RawXml>,
|
||||
}
|
||||
|
||||
#[derive(Default, PartialEq, Debug, YaSerialize, YaDeserialize)]
|
||||
|
||||
@@ -234,14 +234,15 @@ mod tests {
|
||||
#[tokio::test]
|
||||
async fn test_load_config_from_local_file() {
|
||||
for path in [
|
||||
// "src/tests/data/config-opnsense-25.1.xml",
|
||||
// "src/tests/data/config-vm-test.xml",
|
||||
"src/tests/data/config-opnsense-25.1.xml",
|
||||
"src/tests/data/config-vm-test.xml",
|
||||
"src/tests/data/config-structure.xml",
|
||||
"src/tests/data/config-full-1.xml",
|
||||
// "src/tests/data/config-full-ncd0.xml",
|
||||
// "src/tests/data/config-full-25.7.xml",
|
||||
// "src/tests/data/config-full-25.7-dummy-dnsmasq-options.xml",
|
||||
"src/tests/data/config-25.7-dnsmasq-static-host.xml",
|
||||
"src/tests/data/config-full-25.7.11_2.xml",
|
||||
] {
|
||||
let mut test_file_path = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
|
||||
test_file_path.push(path);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use opnsense_config_xml::{Host, OPNsense};
|
||||
use opnsense_config_xml::{Host, MaybeString, OPNsense};
|
||||
|
||||
pub struct UnboundDnsConfig<'a> {
|
||||
opnsense: &'a mut OPNsense,
|
||||
@@ -31,7 +31,8 @@ impl<'a> UnboundDnsConfig<'a> {
|
||||
None => todo!("Handle case where unboundplus is not used"),
|
||||
};
|
||||
|
||||
unbound.general.regdhcp = Some(register as i8);
|
||||
unbound.general.regdhcpstatic = Some(register as i8);
|
||||
unbound.general.regdhcp = Some(MaybeString::from_bool_as_int("regdhcp", register));
|
||||
unbound.general.regdhcpstatic =
|
||||
Some(MaybeString::from_bool_as_int("regdhcpstatic", register));
|
||||
}
|
||||
}
|
||||
|
||||
2376
opnsense-config/src/tests/data/config-full-25.7.11_2.xml
Normal file
2376
opnsense-config/src/tests/data/config-full-25.7.11_2.xml
Normal file
File diff suppressed because it is too large
Load Diff
@@ -271,7 +271,6 @@
|
||||
</firmware>
|
||||
<language>en_US</language>
|
||||
<dnsserver>1.1.1.1</dnsserver>
|
||||
<dnsserver>8.8.8.8</dnsserver>
|
||||
<dns1gw>none</dns1gw>
|
||||
<dns2gw>none</dns2gw>
|
||||
<dns3gw>none</dns3gw>
|
||||
|
||||
@@ -30,28 +30,17 @@
|
||||
<item uuid="b6b18051-830f-4b27-81ec-f772b14681e2">
|
||||
<tunable>net.inet.ip.sourceroute</tunable>
|
||||
<value>default</value>
|
||||
<descr>
|
||||
Source routing is another way for an attacker to try to reach non-routable addresses behind your box.
|
||||
It can also be used to probe for information about your internal networks. These functions come enabled
|
||||
as part of the standard FreeBSD core system.
|
||||
</descr>
|
||||
<descr>Source routing is another way for an attacker to try to reach non-routable addresses behind your box. It can also be used to probe for information about your internal networks. These functions come enabled as part of the standard FreeBSD core system.</descr>
|
||||
</item>
|
||||
<item uuid="ea21409c-62d6-4040-aa2b-36bd01af5578">
|
||||
<tunable>net.inet.ip.accept_sourceroute</tunable>
|
||||
<value>default</value>
|
||||
<descr>
|
||||
Source routing is another way for an attacker to try to reach non-routable addresses behind your box.
|
||||
It can also be used to probe for information about your internal networks. These functions come enabled
|
||||
as part of the standard FreeBSD core system.
|
||||
</descr>
|
||||
<descr>Source routing is another way for an attacker to try to reach non-routable addresses behind your box. It can also be used to probe for information about your internal networks. These functions come enabled as part of the standard FreeBSD core system.</descr>
|
||||
</item>
|
||||
<item uuid="1613256c-ef7e-4b53-a44c-234440046293">
|
||||
<tunable>net.inet.icmp.log_redirect</tunable>
|
||||
<value>default</value>
|
||||
<descr>
|
||||
This option turns off the logging of redirect packets because there is no limit and this could fill
|
||||
up your logs consuming your whole hard drive.
|
||||
</descr>
|
||||
<descr>This option turns off the logging of redirect packets because there is no limit and this could fill up your logs consuming your whole hard drive.</descr>
|
||||
</item>
|
||||
<item uuid="1ba88c72-6e5b-4f19-abba-351c2b76d5dc">
|
||||
<tunable>net.inet.tcp.drop_synfin</tunable>
|
||||
@@ -181,9 +170,7 @@
|
||||
<item uuid="2c42ae2f-a7bc-48cb-b27d-db72e738e80b">
|
||||
<tunable>net.inet.ip.redirect</tunable>
|
||||
<value>default</value>
|
||||
<descr>Enable/disable sending of ICMP redirects in response to IP packets for which a better,
|
||||
and for the sender directly reachable, route and next hop is known.
|
||||
</descr>
|
||||
<descr>Enable/disable sending of ICMP redirects in response to IP packets for which a better, and for the sender directly reachable, route and next hop is known.</descr>
|
||||
</item>
|
||||
<item uuid="7d315fb1-c638-4b79-9f6c-240b41e6d643">
|
||||
<tunable>net.local.dgram.maxdgram</tunable>
|
||||
@@ -938,4 +925,3 @@
|
||||
</cert>
|
||||
<syslog/>
|
||||
</opnsense>
|
||||
|
||||
|
||||
@@ -28,28 +28,17 @@
|
||||
<value>default</value>
|
||||
</item>
|
||||
<item>
|
||||
<descr>
|
||||
Source routing is another way for an attacker to try to reach non-routable addresses behind your box.
|
||||
It can also be used to probe for information about your internal networks. These functions come enabled
|
||||
as part of the standard FreeBSD core system.
|
||||
</descr>
|
||||
<descr>Source routing is another way for an attacker to try to reach non-routable addresses behind your box. It can also be used to probe for information about your internal networks. These functions come enabled as part of the standard FreeBSD core system.</descr>
|
||||
<tunable>net.inet.ip.sourceroute</tunable>
|
||||
<value>default</value>
|
||||
</item>
|
||||
<item>
|
||||
<descr>
|
||||
Source routing is another way for an attacker to try to reach non-routable addresses behind your box.
|
||||
It can also be used to probe for information about your internal networks. These functions come enabled
|
||||
as part of the standard FreeBSD core system.
|
||||
</descr>
|
||||
<descr>Source routing is another way for an attacker to try to reach non-routable addresses behind your box. It can also be used to probe for information about your internal networks. These functions come enabled as part of the standard FreeBSD core system.</descr>
|
||||
<tunable>net.inet.ip.accept_sourceroute</tunable>
|
||||
<value>default</value>
|
||||
</item>
|
||||
<item>
|
||||
<descr>
|
||||
This option turns off the logging of redirect packets because there is no limit and this could fill
|
||||
up your logs consuming your whole hard drive.
|
||||
</descr>
|
||||
<descr>This option turns off the logging of redirect packets because there is no limit and this could fill up your logs consuming your whole hard drive.</descr>
|
||||
<tunable>net.inet.icmp.log_redirect</tunable>
|
||||
<value>default</value>
|
||||
</item>
|
||||
@@ -179,9 +168,7 @@
|
||||
<value>default</value>
|
||||
</item>
|
||||
<item>
|
||||
<descr>Enable/disable sending of ICMP redirects in response to IP packets for which a better,
|
||||
and for the sender directly reachable, route and next hop is known.
|
||||
</descr>
|
||||
<descr>Enable/disable sending of ICMP redirects in response to IP packets for which a better, and for the sender directly reachable, route and next hop is known.</descr>
|
||||
<tunable>net.inet.ip.redirect</tunable>
|
||||
<value>default</value>
|
||||
</item>
|
||||
|
||||
Reference in New Issue
Block a user