nzrdhcp: don't depend on tarpc
No longer needed, with nzr-api exposing the client bits.
This commit is contained in:
parent
da51722c54
commit
51e72fed93
|
@ -11,11 +11,5 @@ tokio = { version = "1.39.2", features = ["rt-multi-thread", "net", "macros"] }
|
|||
nzr-api = { path = "../nzr-api" }
|
||||
tracing = { version = "0.1.40", features = ["log"] }
|
||||
tracing-subscriber = "0.3.18"
|
||||
tarpc = { version = "0.34", features = [
|
||||
"tokio1",
|
||||
"unix",
|
||||
"serde-transport",
|
||||
"serde-transport-bincode",
|
||||
] }
|
||||
moka = { version = "0.12.8", features = ["future"] }
|
||||
anyhow = "1.0.86"
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
use std::hash::RandomState;
|
||||
use std::net::IpAddr;
|
||||
use std::net::SocketAddr;
|
||||
|
||||
use anyhow::Context as _;
|
||||
|
@ -10,7 +11,6 @@ use nzr_api::{
|
|||
net::mac::MacAddr,
|
||||
NazrinClient,
|
||||
};
|
||||
use tarpc::{tokio_serde::formats::Bincode, tokio_util::codec::LengthDelimitedCodec};
|
||||
use tokio::net::UdpSocket;
|
||||
use tokio::net::UnixStream;
|
||||
|
||||
|
@ -26,7 +26,7 @@ impl Context {
|
|||
async fn hydrate_hosts(&self) -> Result<()> {
|
||||
let instances = self
|
||||
.api_client
|
||||
.get_instances(tarpc::context::current(), false)
|
||||
.get_instances(nzr_api::default_ctx(), false)
|
||||
.await?
|
||||
.map_err(|e| anyhow::anyhow!("nzrd error: {e}"))?;
|
||||
|
||||
|
@ -52,7 +52,7 @@ impl Context {
|
|||
async fn hydrate_nets(&self) -> Result<()> {
|
||||
let subnets = self
|
||||
.api_client
|
||||
.get_subnets(tarpc::context::current())
|
||||
.get_subnets(nzr_api::default_ctx())
|
||||
.await?
|
||||
.map_err(|e| anyhow::anyhow!("nzrd error: {e}"))?;
|
||||
|
||||
|
@ -68,21 +68,19 @@ impl Context {
|
|||
let sock = UnixStream::connect(&cfg.rpc.socket_path)
|
||||
.await
|
||||
.context("Connection to nzrd failed")?;
|
||||
let framed_io = LengthDelimitedCodec::builder()
|
||||
.length_field_type::<u32>()
|
||||
.new_framed(sock);
|
||||
let transport = tarpc::serde_transport::new(framed_io, Bincode::default());
|
||||
NazrinClient::new(Default::default(), transport)
|
||||
}
|
||||
.spawn();
|
||||
nzr_api::new_client(sock)
|
||||
};
|
||||
|
||||
let listen_addr: SocketAddr = cfg
|
||||
.dhcp
|
||||
.listen_addr
|
||||
.parse()
|
||||
.context("Malformed listen address")?;
|
||||
let listen_addr: SocketAddr = {
|
||||
let ip: IpAddr = cfg
|
||||
.dhcp
|
||||
.listen_addr
|
||||
.parse()
|
||||
.context("Malformed listen address")?;
|
||||
(ip, cfg.dhcp.port).into()
|
||||
};
|
||||
|
||||
let server_sock = UdpSocket::bind(&listen_addr)
|
||||
let server_sock = UdpSocket::bind(listen_addr)
|
||||
.await
|
||||
.context("Unable to listen")?;
|
||||
|
||||
|
|
Loading…
Reference in a new issue