lan discovery, refact mac
Signed-off-by: fufesou <shuanglongchen@yeah.net>
This commit is contained in:
parent
1759d7f762
commit
5dc0917ea9
1 changed files with 13 additions and 6 deletions
19
src/lan.rs
19
src/lan.rs
|
|
@ -207,11 +207,7 @@ fn wait_response(
|
|||
Err(..) => true,
|
||||
Ok(addr) => addr.ip().is_unspecified(),
|
||||
};
|
||||
let mac = if let Ok(local_addr) = local_addr {
|
||||
get_mac(&local_addr.ip())
|
||||
} else {
|
||||
"".to_owned()
|
||||
};
|
||||
let mut mac: Option<String> = None;
|
||||
|
||||
socket.set_read_timeout(timeout)?;
|
||||
loop {
|
||||
|
|
@ -229,7 +225,18 @@ fn wait_response(
|
|||
"".to_owned()
|
||||
}
|
||||
} else {
|
||||
mac.clone()
|
||||
match mac.as_ref() {
|
||||
Some(m) => m.clone(),
|
||||
None => {
|
||||
let m = if let Ok(local_addr) = local_addr {
|
||||
get_mac(&local_addr.ip())
|
||||
} else {
|
||||
"".to_owned()
|
||||
};
|
||||
mac = Some(m.clone());
|
||||
m
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
if local_mac.is_empty() && p.mac.is_empty() || local_mac != p.mac {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue