Bevy+Ratutui powered Monitoring of Pico-Strike devices

Only accept authorative mdns answers

+21 -18
+21 -18
src/net.rs
··· 69 69 continue; 70 70 }; 71 71 72 - if resp.answers.iter().any(|answer| { 73 - if let Record::PTR(_) = &answer.record { 74 - answer.name == "_picostrike._tcp.local" 75 - } else { 76 - false 77 - } 78 - }) && let Some(instance) = resp.additional.iter().find_map(|answer| { 79 - if let Record::SRV(srv) = &answer.record { 80 - Some(InstanceDetails { 81 - host: answer.name.to_string(), 82 - address: srv.target.to_string(), 83 - port: srv.port, 84 - ip: socket.ip(), 85 - }) 86 - } else { 87 - None 88 - } 89 - }) { 72 + if resp.flags.is_authoritative() 73 + && resp.answers.iter().any(|answer| { 74 + if let Record::PTR(_) = &answer.record { 75 + answer.name == "_picostrike._tcp.local" 76 + } else { 77 + false 78 + } 79 + }) 80 + && let Some(instance) = resp.additional.iter().find_map(|answer| { 81 + if let Record::SRV(srv) = &answer.record { 82 + Some(InstanceDetails { 83 + host: answer.name.to_string(), 84 + address: srv.target.to_string(), 85 + port: srv.port, 86 + ip: socket.ip(), 87 + }) 88 + } else { 89 + None 90 + } 91 + }) 92 + { 90 93 resp_tx.send(instance).await.ok(); 91 94 } 92 95 }