Compare commits
2 commits
4b6f469a58
...
295609a57d
Author | SHA1 | Date | |
---|---|---|---|
snow flurry | 295609a57d | ||
snow flurry | 1023fdca8c |
1068
Cargo.lock
generated
1068
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
|
@ -1,6 +1,3 @@
|
|||
[workspace]
|
||||
members = [
|
||||
"nzrd",
|
||||
"api",
|
||||
"client",
|
||||
]
|
||||
members = ["nzrd", "api", "client"]
|
||||
resolver = "2"
|
||||
|
|
|
@ -8,8 +8,9 @@ edition = "2021"
|
|||
[dependencies]
|
||||
figment = { version = "0.10.8", features = ["json", "toml", "env"] }
|
||||
serde = { version = "1", features = ["derive"] }
|
||||
tarpc = { version = "0.31", features = ["tokio1", "unix"] }
|
||||
tarpc = { version = "0.34", features = ["tokio1", "unix"] }
|
||||
tokio = { version = "1.0", features = ["macros"] }
|
||||
uuid = "1.2.2"
|
||||
trust-dns-proto = { version = "0.22.0", features = ["serde-config"] }
|
||||
# trust-dns-proto = { version = "0.23", features = ["serde-config"] }
|
||||
hickory-proto = { version = "0.24", features = ["serde-config"] }
|
||||
log = "0.4.17"
|
|
@ -4,8 +4,8 @@ use figment::{
|
|||
providers::{Env, Format, Json, Toml},
|
||||
Figment, Metadata, Provider,
|
||||
};
|
||||
use hickory_proto::rr::Name;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use trust_dns_proto::rr::Name;
|
||||
|
||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||
pub struct StorageConfig {
|
||||
|
|
|
@ -5,7 +5,7 @@ pub mod config;
|
|||
pub mod model;
|
||||
pub mod net;
|
||||
|
||||
pub use trust_dns_proto;
|
||||
pub use hickory_proto;
|
||||
|
||||
#[tarpc::service]
|
||||
pub trait Nazrin {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use hickory_proto::rr::Name;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::{fmt, net::Ipv4Addr};
|
||||
use trust_dns_proto::rr::Name;
|
||||
|
||||
use crate::net::{cidr::CidrV4, mac::MacAddr};
|
||||
|
||||
|
|
|
@ -10,9 +10,14 @@ nzr-api = { path = "../api" }
|
|||
clap = { version = "4.0.26", features = ["derive"] }
|
||||
home = "0.5.4"
|
||||
tokio = { version = "1.0", features = ["macros", "rt-multi-thread"] }
|
||||
tokio-serde = { version = "0.8.0", features = ["bincode"] }
|
||||
tarpc = { version = "0.31", features = ["tokio1", "unix", "serde-transport", "serde-transport-bincode"] }
|
||||
tabled = "0.10.0"
|
||||
tokio-serde = { version = "0.9", features = ["bincode"] }
|
||||
tarpc = { version = "0.34", features = [
|
||||
"tokio1",
|
||||
"unix",
|
||||
"serde-transport",
|
||||
"serde-transport-bincode",
|
||||
] }
|
||||
tabled = "0.15"
|
||||
serde_json = "1"
|
||||
log = "0.4.17"
|
||||
env_logger = "0.10.0"
|
||||
env_logger = "0.11"
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use clap::{CommandFactory, FromArgMatches, Parser, Subcommand};
|
||||
use nzr_api::hickory_proto::rr::Name;
|
||||
use nzr_api::model;
|
||||
use nzr_api::net::cidr::CidrV4;
|
||||
use nzr_api::trust_dns_proto::rr::Name;
|
||||
use nzr_api::{config, NazrinClient};
|
||||
use std::any::{Any, TypeId};
|
||||
use std::path::PathBuf;
|
||||
|
@ -328,8 +328,8 @@ async fn handle_command() -> Result<(), Box<dyn std::error::Error>> {
|
|||
|
||||
let tabular: Vec<table::Instance> =
|
||||
instances?.iter().map(table::Instance::from).collect();
|
||||
let mut table = tabled::Table::new(&tabular);
|
||||
println!("{}", table.with(tabled::Style::psql()));
|
||||
let mut table = tabled::Table::new(tabular);
|
||||
println!("{}", table.with(tabled::settings::Style::psql()));
|
||||
}
|
||||
InstanceCmd::Prune => (client.garbage_collect(tarpc::context::current()).await?)?,
|
||||
},
|
||||
|
@ -423,8 +423,8 @@ async fn handle_command() -> Result<(), Box<dyn std::error::Error>> {
|
|||
|
||||
let tabular: Vec<table::Subnet> =
|
||||
subnets?.iter().map(table::Subnet::from).collect();
|
||||
let mut table = tabled::Table::new(&tabular);
|
||||
println!("{}", table.with(tabled::Style::psql()));
|
||||
let mut table = tabled::Table::new(tabular);
|
||||
println!("{}", table.with(tabled::settings::Style::psql()));
|
||||
}
|
||||
},
|
||||
};
|
||||
|
|
|
@ -6,35 +6,49 @@ edition = "2021"
|
|||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
tarpc = { version = "0.31", features = ["tokio1", "unix", "serde-transport", "serde-transport-bincode"] }
|
||||
tokio = { version = "1.0", features = ["macros", "rt-multi-thread", "process"] }
|
||||
tokio-serde = { version = "0.8.0", features = ["bincode"] }
|
||||
tarpc = { version = "0.34", features = [
|
||||
"tokio1",
|
||||
"unix",
|
||||
"serde-transport",
|
||||
"serde-transport-bincode",
|
||||
] }
|
||||
tokio = { version = "1", features = ["macros", "rt-multi-thread", "process"] }
|
||||
tokio-serde = { version = "0.9", features = ["bincode"] }
|
||||
sled = "0.34.7"
|
||||
# virt = "0.2.11"
|
||||
virt = { path = "../../libvirt-rust" }
|
||||
virt = "0.4"
|
||||
# virt = { path = "../../libvirt-rust" }
|
||||
fatfs = "0.3"
|
||||
uuid = { version = "1.2.2", features = ["v4", "fast-rng", "serde", "macro-diagnostics"] }
|
||||
uuid = { version = "1.2.2", features = [
|
||||
"v4",
|
||||
"fast-rng",
|
||||
"serde",
|
||||
"macro-diagnostics",
|
||||
] }
|
||||
clap = { version = "4.0.26", features = ["derive"] }
|
||||
serde = { version = "1", features = ["derive"] }
|
||||
# for new @attr support, awaiting 0.27.0
|
||||
quick-xml = { git = "https://github.com/tafia/quick-xml", rev = "fb079b6714d7238d5180aaa098c5f9b02dbcc7da", features = ["serialize"] }
|
||||
serde_with = "2.1.0"
|
||||
quick-xml = { version = "0.36", features = ["serialize"] }
|
||||
# quick-xml = { git = "https://github.com/tafia/quick-xml", rev = "fb079b6714d7238d5180aaa098c5f9b02dbcc7da", features = [
|
||||
# "serialize",
|
||||
# ] }
|
||||
serde_with = "2"
|
||||
serde_yaml = "0.9.14"
|
||||
rand = "0.8.5"
|
||||
libc = "0.2.137"
|
||||
home = "0.5.4"
|
||||
stdext = "0.3.1"
|
||||
zerocopy = "0.6.1"
|
||||
zerocopy = "0.7"
|
||||
nzr-api = { path = "../api" }
|
||||
futures = "0.3"
|
||||
async-trait = "0.1.60"
|
||||
ciborium = "0.2.0"
|
||||
ciborium-io = "0.2.0"
|
||||
trust-dns-server = "0.22.0"
|
||||
hickory-server = "0.24"
|
||||
hickory-proto = { version = "0.24", features = ["serde-config"] }
|
||||
async-trait = "0.1"
|
||||
log = "0.4.17"
|
||||
syslog = "6.0.1"
|
||||
nix = "0.26.1"
|
||||
tempdir = "0.3.7"
|
||||
syslog = "7"
|
||||
nix = { version = "0.29", features = ["user", "fs"] }
|
||||
tempfile = "3"
|
||||
|
||||
[dev-dependencies]
|
||||
regex = "1"
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
use std::net::Ipv4Addr;
|
||||
|
||||
use fatfs::FsOptions;
|
||||
use hickory_server::proto::rr::Name;
|
||||
use serde::Serialize;
|
||||
use serde_with::skip_serializing_none;
|
||||
use std::collections::HashMap;
|
||||
use std::io::{prelude::*, Cursor};
|
||||
use trust_dns_server::proto::rr::Name;
|
||||
|
||||
use nzr_api::net::{cidr::CidrV4, mac::MacAddr};
|
||||
|
||||
|
|
|
@ -11,11 +11,11 @@ use crate::ctrl::Storable;
|
|||
use crate::ctx::Context;
|
||||
use crate::prelude::*;
|
||||
use crate::virt::VirtVolume;
|
||||
use hickory_server::proto::rr::Name;
|
||||
use log::*;
|
||||
use nzr_api::args;
|
||||
use nzr_api::net::mac::MacAddr;
|
||||
use std::sync::Arc;
|
||||
use trust_dns_server::proto::rr::Name;
|
||||
|
||||
const VIRT_MAC_OUI: &[u8] = &[0x02, 0xf1, 0x0f];
|
||||
|
||||
|
@ -37,13 +37,10 @@ pub async fn new_instance(
|
|||
// find the subnet corresponding to the interface
|
||||
let subnet = Subnet::get_by_key(ctx.db.clone(), args.subnet.as_bytes())
|
||||
.map_err(|er| cmd_error!("Unable to get interface: {}", er))?
|
||||
.map_or(
|
||||
Err(cmd_error!(
|
||||
"Subnet {} wasn't found in database",
|
||||
&args.subnet
|
||||
)),
|
||||
Ok,
|
||||
)?;
|
||||
.ok_or(cmd_error!(
|
||||
"Subnet {} wasn't found in database",
|
||||
&args.subnet
|
||||
))?;
|
||||
|
||||
// bail if a domain already exists
|
||||
if let Ok(dom) = virt::domain::Domain::lookup_by_name(&ctx.virt.conn, &args.name) {
|
||||
|
|
|
@ -19,7 +19,7 @@ impl DomainBuilder {
|
|||
/// > used to form the filename for storing the persistent
|
||||
/// > configuration file.
|
||||
pub fn name(mut self, name: &str) -> Self {
|
||||
self.domain.name = name.to_owned();
|
||||
name.clone_into(&mut self.domain.name);
|
||||
self
|
||||
}
|
||||
|
||||
|
@ -175,7 +175,7 @@ impl IfaceBuilder {
|
|||
/// qemu-system-x86_64 -net nic,model=? /dev/null
|
||||
/// ```
|
||||
pub fn model(mut self, model: &str) -> Self {
|
||||
self.iface.model.r#type = model.to_owned();
|
||||
model.clone_into(&mut self.iface.model.r#type);
|
||||
self
|
||||
}
|
||||
|
||||
|
@ -233,8 +233,8 @@ impl DiskBuilder {
|
|||
|
||||
/// Set the target for the disk to attach to.
|
||||
pub fn target(mut self, dev: &str, bus: &str) -> Self {
|
||||
self.disk.target.bus = bus.to_owned();
|
||||
self.disk.target.dev = dev.to_owned();
|
||||
bus.clone_into(&mut self.disk.target.bus);
|
||||
dev.clone_into(&mut self.disk.target.dev);
|
||||
self
|
||||
}
|
||||
|
||||
|
|
|
@ -69,7 +69,7 @@ impl std::error::Error for ContextError {}
|
|||
impl InnerCtx {
|
||||
fn new(config: Config) -> Result<Self, ContextError> {
|
||||
let zones = ZoneData::new(&config.dns);
|
||||
let conn = Connect::open(&config.libvirt_uri).map_err(ContextError::Virt)?;
|
||||
let conn = Connect::open(Some(&config.libvirt_uri)).map_err(ContextError::Virt)?;
|
||||
virt::error::clear_error_callback();
|
||||
|
||||
let pools = PoolRefs {
|
||||
|
|
|
@ -9,14 +9,12 @@ use std::str::FromStr;
|
|||
use std::sync::Arc;
|
||||
use tokio::sync::{Mutex, RwLock};
|
||||
|
||||
use trust_dns_server::authority::{AuthorityObject, Catalog};
|
||||
use trust_dns_server::client::rr::{LowerName, RrKey};
|
||||
use trust_dns_server::proto::rr::{rdata::soa, RData, RecordSet};
|
||||
use trust_dns_server::server::{Request, RequestHandler, ResponseHandler, ResponseInfo};
|
||||
use trust_dns_server::{
|
||||
proto::rr::{Name, Record},
|
||||
store::in_memory::InMemoryAuthority,
|
||||
};
|
||||
use hickory_proto::rr::Name;
|
||||
use hickory_server::authority::{AuthorityObject, Catalog};
|
||||
use hickory_server::proto::rr::{rdata::soa, RData, RecordSet};
|
||||
use hickory_server::proto::rr::{LowerName, RrKey};
|
||||
use hickory_server::server::{Request, RequestHandler, ResponseHandler, ResponseInfo};
|
||||
use hickory_server::{proto::rr::Record, store::in_memory::InMemoryAuthority};
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct CatalogRef(Arc<RwLock<Catalog>>);
|
||||
|
@ -32,12 +30,14 @@ macro_rules! make_serial {
|
|||
}};
|
||||
}
|
||||
|
||||
// hickory_dns 0.24 still requires async_trait
|
||||
#[async_trait::async_trait]
|
||||
impl RequestHandler for CatalogRef {
|
||||
async fn handle_request<R>(&self, request: &Request, response_handle: R) -> ResponseInfo
|
||||
where
|
||||
R: ResponseHandler,
|
||||
{
|
||||
async fn handle_request<R: ResponseHandler>(
|
||||
&self,
|
||||
request: &Request,
|
||||
response_handle: R,
|
||||
) -> ResponseInfo {
|
||||
self.0
|
||||
.read()
|
||||
.await
|
||||
|
@ -74,7 +74,7 @@ pub fn make_rectree_with_soa(name: &Name, config: &DNSConfig) -> BTreeMap<RrKey,
|
|||
let mut records: BTreeMap<RrKey, RecordSet> = BTreeMap::new();
|
||||
let soa_key = RrKey::new(
|
||||
LowerName::from(name),
|
||||
trust_dns_server::proto::rr::RecordType::SOA,
|
||||
hickory_server::proto::rr::RecordType::SOA,
|
||||
);
|
||||
let soa_rec = Record::from_rdata(
|
||||
name.clone(),
|
||||
|
@ -100,7 +100,7 @@ impl InnerZD {
|
|||
InMemoryAuthority::new(
|
||||
dns_config.default_zone.clone(),
|
||||
records,
|
||||
trust_dns_server::authority::ZoneType::Primary,
|
||||
hickory_server::authority::ZoneType::Primary,
|
||||
false,
|
||||
)
|
||||
.unwrap()
|
||||
|
@ -123,7 +123,7 @@ impl InnerZD {
|
|||
let auth = InMemoryAuthority::new(
|
||||
name.clone(),
|
||||
make_rectree_with_soa(name, &self.config),
|
||||
trust_dns_server::authority::ZoneType::Primary,
|
||||
hickory_server::authority::ZoneType::Primary,
|
||||
false,
|
||||
)?;
|
||||
self.import(&subnet.ifname.to_string(), auth).await;
|
||||
|
@ -174,7 +174,7 @@ impl InnerZD {
|
|||
zone.origin()
|
||||
);
|
||||
|
||||
let record = Record::from_rdata(fqdn, 3600, RData::A(addr));
|
||||
let record = Record::from_rdata(fqdn, 3600, RData::A(addr.into()));
|
||||
zone.upsert(record, 0).await;
|
||||
self.catalog()
|
||||
.0
|
||||
|
@ -194,7 +194,7 @@ impl InnerZD {
|
|||
if let Some(zone) = zones.get_mut(interface) {
|
||||
let hostname: LowerName = hostname.into();
|
||||
self.catalog.0.write().await.remove(&hostname);
|
||||
let key = RrKey::new(hostname, trust_dns_server::proto::rr::RecordType::A);
|
||||
let key = RrKey::new(hostname, hickory_server::proto::rr::RecordType::A);
|
||||
Ok(zone.records_mut().await.remove(&key).is_some())
|
||||
} else {
|
||||
Ok(false)
|
||||
|
|
|
@ -5,7 +5,7 @@ use std::{
|
|||
};
|
||||
|
||||
use std::future::Future;
|
||||
use tempdir::TempDir;
|
||||
use tempfile::TempDir;
|
||||
use tokio::process::Command;
|
||||
|
||||
use crate::ctrl::virtxml::SizeInfo;
|
||||
|
@ -101,7 +101,7 @@ where
|
|||
Fut: Future<Output = std::io::Result<std::process::Output>>,
|
||||
{
|
||||
let qi_path = qemu_img_path()?;
|
||||
let img_dir = TempDir::new("nazrin")?;
|
||||
let img_dir = TempDir::with_prefix("nazrin")?;
|
||||
let img_path = img_dir.path().join("img");
|
||||
|
||||
let qi_out = func(Command::new(&qi_path), &img_path)
|
||||
|
|
|
@ -11,12 +11,12 @@ mod test;
|
|||
mod virt;
|
||||
|
||||
use crate::ctrl::{net::Subnet, Storable};
|
||||
use hickory_server::ServerFuture;
|
||||
use log::LevelFilter;
|
||||
use log::*;
|
||||
use nzr_api::config;
|
||||
use std::str::FromStr;
|
||||
use tokio::net::UdpSocket;
|
||||
use trust_dns_server::ServerFuture;
|
||||
|
||||
#[tokio::main(flavor = "multi_thread")]
|
||||
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
use futures::{future, StreamExt};
|
||||
use nzr_api::{args, model, Nazrin};
|
||||
use std::borrow::Borrow;
|
||||
use std::sync::Arc;
|
||||
|
@ -35,7 +36,6 @@ impl NzrServer {
|
|||
}
|
||||
}
|
||||
|
||||
#[tarpc::server]
|
||||
impl Nazrin for NzrServer {
|
||||
async fn new_instance(
|
||||
self,
|
||||
|
@ -55,7 +55,7 @@ impl Nazrin for NzrServer {
|
|||
|
||||
{
|
||||
let mut pt = prog_task.write().await;
|
||||
pt.status_text = "Starting instance...".to_owned();
|
||||
"Starting instance...".clone_into(&mut pt.status_text);
|
||||
pt.percentage = 90.0;
|
||||
}
|
||||
if let Some(addr) = addr {
|
||||
|
@ -281,6 +281,10 @@ pub async fn serve(ctx: Context, zones: ZoneData) -> Result<(), Box<dyn std::err
|
|||
let transport = tarpc::serde_transport::new(framed, Bincode::default());
|
||||
BaseChannel::with_defaults(transport)
|
||||
.execute(NzrServer::new(ctx, zones).serve())
|
||||
.for_each(|rpc| {
|
||||
tokio::spawn(rpc);
|
||||
future::ready(())
|
||||
})
|
||||
.await;
|
||||
});
|
||||
}
|
||||
|
|
|
@ -75,7 +75,7 @@ impl VirtVolume {
|
|||
let svol = StorageVol::create_xml(pool, &xml, flags)?;
|
||||
|
||||
if xmldata.vol_type() == Some(VolType::Qcow2) {
|
||||
let size = xmldata.capacity.unwrap().clone();
|
||||
let size = xmldata.capacity.unwrap();
|
||||
let src_img = img::create_qcow2(size).await?;
|
||||
|
||||
let stream = match Stream::new(&svol.get_connect().map_err(PoolError::VirtError)?, 0) {
|
||||
|
@ -93,7 +93,7 @@ impl VirtVolume {
|
|||
return Err(Box::new(PoolError::CantUpload(er)));
|
||||
}
|
||||
|
||||
Self::upload_img(&*src_img, stream)?;
|
||||
Self::upload_img(&src_img, stream)?;
|
||||
}
|
||||
|
||||
Ok(Self {
|
||||
|
@ -125,7 +125,7 @@ impl VirtVolume {
|
|||
|
||||
let src_path = self.get_path().map_err(PoolError::NoPath)?;
|
||||
|
||||
let src_img = img::clone_qcow2(src_path, size.clone())
|
||||
let src_img = img::clone_qcow2(src_path, size)
|
||||
.await
|
||||
.map_err(PoolError::QemuError)?;
|
||||
|
||||
|
@ -177,7 +177,7 @@ impl VirtVolume {
|
|||
return Err(PoolError::CantUpload(er));
|
||||
}
|
||||
|
||||
Self::upload_img(&*src_img, stream)?;
|
||||
Self::upload_img(&src_img, stream)?;
|
||||
|
||||
Ok(Self {
|
||||
inner: cloned,
|
||||
|
|
Loading…
Reference in a new issue