Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scouting accepts IPv6 addresses #1345

Merged
merged 1 commit into from
Sep 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions zenoh/src/net/runtime/orchestrator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,7 @@ impl Runtime {
ifaces: &[IpAddr],
multicast_ttl: u32,
) -> ZResult<UdpSocket> {
let socket = match Socket::new(Domain::IPV4, Type::DGRAM, None) {
let socket = match Socket::new(Domain::for_address(*sockaddr), Type::DGRAM, None) {
Ok(socket) => socket,
Err(err) => {
tracing::error!("Unable to create datagram socket: {}", err);
Expand Down Expand Up @@ -704,21 +704,22 @@ impl Runtime {
}

pub fn bind_ucast_port(addr: IpAddr, multicast_ttl: u32) -> ZResult<UdpSocket> {
let socket = match Socket::new(Domain::IPV4, Type::DGRAM, None) {
let sockaddr = || SocketAddr::new(addr, 0);
let socket = match Socket::new(Domain::for_address(sockaddr()), Type::DGRAM, None) {
Ok(socket) => socket,
Err(err) => {
tracing::warn!("Unable to create datagram socket: {}", err);
bail!(err=> "Unable to create datagram socket");
}
};
match socket.bind(&SocketAddr::new(addr, 0).into()) {
match socket.bind(&sockaddr().into()) {
Ok(()) => {
#[allow(clippy::or_fun_call)]
let local_addr = socket
.local_addr()
.unwrap_or(SocketAddr::new(addr, 0).into())
.unwrap_or(sockaddr().into())
.as_socket()
.unwrap_or(SocketAddr::new(addr, 0));
.unwrap_or(sockaddr());
tracing::debug!("UDP port bound to {}", local_addr);
}
Err(err) => {
Expand Down
Loading