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" }
|
nzr-api = { path = "../nzr-api" }
|
||||||
tracing = { version = "0.1.40", features = ["log"] }
|
tracing = { version = "0.1.40", features = ["log"] }
|
||||||
tracing-subscriber = "0.3.18"
|
tracing-subscriber = "0.3.18"
|
||||||
tarpc = { version = "0.34", features = [
|
|
||||||
"tokio1",
|
|
||||||
"unix",
|
|
||||||
"serde-transport",
|
|
||||||
"serde-transport-bincode",
|
|
||||||
] }
|
|
||||||
moka = { version = "0.12.8", features = ["future"] }
|
moka = { version = "0.12.8", features = ["future"] }
|
||||||
anyhow = "1.0.86"
|
anyhow = "1.0.86"
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
use std::hash::RandomState;
|
use std::hash::RandomState;
|
||||||
|
use std::net::IpAddr;
|
||||||
use std::net::SocketAddr;
|
use std::net::SocketAddr;
|
||||||
|
|
||||||
use anyhow::Context as _;
|
use anyhow::Context as _;
|
||||||
|
@ -10,7 +11,6 @@ use nzr_api::{
|
||||||
net::mac::MacAddr,
|
net::mac::MacAddr,
|
||||||
NazrinClient,
|
NazrinClient,
|
||||||
};
|
};
|
||||||
use tarpc::{tokio_serde::formats::Bincode, tokio_util::codec::LengthDelimitedCodec};
|
|
||||||
use tokio::net::UdpSocket;
|
use tokio::net::UdpSocket;
|
||||||
use tokio::net::UnixStream;
|
use tokio::net::UnixStream;
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@ impl Context {
|
||||||
async fn hydrate_hosts(&self) -> Result<()> {
|
async fn hydrate_hosts(&self) -> Result<()> {
|
||||||
let instances = self
|
let instances = self
|
||||||
.api_client
|
.api_client
|
||||||
.get_instances(tarpc::context::current(), false)
|
.get_instances(nzr_api::default_ctx(), false)
|
||||||
.await?
|
.await?
|
||||||
.map_err(|e| anyhow::anyhow!("nzrd error: {e}"))?;
|
.map_err(|e| anyhow::anyhow!("nzrd error: {e}"))?;
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ impl Context {
|
||||||
async fn hydrate_nets(&self) -> Result<()> {
|
async fn hydrate_nets(&self) -> Result<()> {
|
||||||
let subnets = self
|
let subnets = self
|
||||||
.api_client
|
.api_client
|
||||||
.get_subnets(tarpc::context::current())
|
.get_subnets(nzr_api::default_ctx())
|
||||||
.await?
|
.await?
|
||||||
.map_err(|e| anyhow::anyhow!("nzrd error: {e}"))?;
|
.map_err(|e| anyhow::anyhow!("nzrd error: {e}"))?;
|
||||||
|
|
||||||
|
@ -68,21 +68,19 @@ impl Context {
|
||||||
let sock = UnixStream::connect(&cfg.rpc.socket_path)
|
let sock = UnixStream::connect(&cfg.rpc.socket_path)
|
||||||
.await
|
.await
|
||||||
.context("Connection to nzrd failed")?;
|
.context("Connection to nzrd failed")?;
|
||||||
let framed_io = LengthDelimitedCodec::builder()
|
nzr_api::new_client(sock)
|
||||||
.length_field_type::<u32>()
|
};
|
||||||
.new_framed(sock);
|
|
||||||
let transport = tarpc::serde_transport::new(framed_io, Bincode::default());
|
|
||||||
NazrinClient::new(Default::default(), transport)
|
|
||||||
}
|
|
||||||
.spawn();
|
|
||||||
|
|
||||||
let listen_addr: SocketAddr = cfg
|
let listen_addr: SocketAddr = {
|
||||||
.dhcp
|
let ip: IpAddr = cfg
|
||||||
.listen_addr
|
.dhcp
|
||||||
.parse()
|
.listen_addr
|
||||||
.context("Malformed listen address")?;
|
.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
|
.await
|
||||||
.context("Unable to listen")?;
|
.context("Unable to listen")?;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue