mirror of
https://codeberg.org/icewind/palantir.git
synced 2026-06-03 18:24:08 +02:00
limit mdns addresses
This commit is contained in:
parent
4e0095e7f4
commit
70bba8ed2c
3 changed files with 11 additions and 2 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
|
@ -852,6 +852,7 @@ dependencies = [
|
||||||
"futures-util",
|
"futures-util",
|
||||||
"hostname",
|
"hostname",
|
||||||
"iai",
|
"iai",
|
||||||
|
"if-addrs",
|
||||||
"libc",
|
"libc",
|
||||||
"libmdns",
|
"libmdns",
|
||||||
"nvml-wrapper",
|
"nvml-wrapper",
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@ libmdns = "0.7.0"
|
||||||
tracing = "0.1.35"
|
tracing = "0.1.35"
|
||||||
tracing-subscriber = "0.3.11"
|
tracing-subscriber = "0.3.11"
|
||||||
nvml-wrapper = "0.8.0"
|
nvml-wrapper = "0.8.0"
|
||||||
|
if-addrs = "0.7.0"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
iai = "0.1.1"
|
iai = "0.1.1"
|
||||||
|
|
|
||||||
11
src/main.rs
11
src/main.rs
|
|
@ -11,7 +11,7 @@ use std::time::Duration;
|
||||||
use tokio::runtime::Handle;
|
use tokio::runtime::Handle;
|
||||||
use tokio::spawn;
|
use tokio::spawn;
|
||||||
use tokio::time::sleep;
|
use tokio::time::sleep;
|
||||||
use tracing::warn;
|
use tracing::{info, warn};
|
||||||
use warp::reject::Reject;
|
use warp::reject::Reject;
|
||||||
use warp::{Filter, Rejection};
|
use warp::{Filter, Rejection};
|
||||||
|
|
||||||
|
|
@ -88,8 +88,15 @@ async fn main() -> Result<()> {
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn setup_mdns(hostname: String, port: u16) {
|
async fn setup_mdns(hostname: String, port: u16) {
|
||||||
|
let interfaces = if_addrs::get_if_addrs().unwrap_or_default();
|
||||||
|
let ip_list: Vec<_> = interfaces
|
||||||
|
.into_iter()
|
||||||
|
.filter(|interface| !interface.name.contains("docker") && !interface.name.contains("br-"))
|
||||||
|
.map(|interface| interface.addr.ip())
|
||||||
|
.collect();
|
||||||
|
|
||||||
let mdns = loop {
|
let mdns = loop {
|
||||||
match Responder::spawn(&Handle::current()) {
|
match Responder::spawn_with_ip_list(&Handle::current(), ip_list.clone()) {
|
||||||
Ok(mdns) => break mdns,
|
Ok(mdns) => break mdns,
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
warn!(error = display(e), "Failed to register mdns responder");
|
warn!(error = display(e), "Failed to register mdns responder");
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue