mirror of
https://mirror.suhoan.cn/https://github.com/EasyTier/EasyTier.git
synced 2025-12-12 12:47:25 +08:00
fix macos bind failed when addr is v6 (#1398)
This commit is contained in:
@@ -384,7 +384,11 @@ pub(crate) fn setup_sokcet2_ext(
|
|||||||
unsafe {
|
unsafe {
|
||||||
let dev_idx = nix::libc::if_nametoindex(dev_name.as_str().as_ptr() as *const i8);
|
let dev_idx = nix::libc::if_nametoindex(dev_name.as_str().as_ptr() as *const i8);
|
||||||
tracing::warn!(?dev_idx, ?dev_name, "bind device");
|
tracing::warn!(?dev_idx, ?dev_name, "bind device");
|
||||||
socket2_socket.bind_device_by_index_v4(std::num::NonZeroU32::new(dev_idx))?;
|
if bind_addr.is_ipv4() {
|
||||||
|
socket2_socket.bind_device_by_index_v4(std::num::NonZeroU32::new(dev_idx))?;
|
||||||
|
} else {
|
||||||
|
socket2_socket.bind_device_by_index_v6(std::num::NonZeroU32::new(dev_idx))?;
|
||||||
|
}
|
||||||
tracing::warn!(?dev_idx, ?dev_name, "bind device doen");
|
tracing::warn!(?dev_idx, ?dev_name, "bind device doen");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user