File tree 1 file changed +18
-5
lines changed
1 file changed +18
-5
lines changed Original file line number Diff line number Diff line change @@ -297,13 +297,26 @@ where
297
297
} ;
298
298
299
299
if let MdnsResponse :: Reply { data, delay } = response {
300
- if delay {
301
- self . delay ( ) . await ;
302
- }
300
+ if remote . port ( ) != PORT {
301
+ // Support one-shot legacy queries by replying privately
302
+ // to the remote address, if the query was not sent from the mDNS port (as per the spec)
303
303
304
- info ! ( "Replying to mDNS query from {remote}" ) ;
304
+ info ! ( "Replying privately to a one-shot mDNS query from {remote}" ) ;
305
305
306
- self . broadcast_once ( send, data) . await ?;
306
+ if let Err ( err) = send. send ( remote, data) . await {
307
+ warn ! ( "Failed to reply privately to {remote}: {err:?}" ) ;
308
+ }
309
+ } else {
310
+ // Otherwise, re-broadcast the response
311
+
312
+ if delay {
313
+ self . delay ( ) . await ;
314
+ }
315
+
316
+ info ! ( "Re-broadcasting due to mDNS query from {remote}" ) ;
317
+
318
+ self . broadcast_once ( send, data) . await ?;
319
+ }
307
320
}
308
321
}
309
322
}
You can’t perform that action at this time.
0 commit comments