fix(ext/node): implement dgram setBroadcast (#29195)

This commit is contained in:
Divy Srivastava 2025-05-08 09:03:43 +05:30 committed by GitHub
parent d67da9d4e7
commit 802826e54e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 71 additions and 4 deletions

View file

@ -390,6 +390,23 @@ pub async fn op_net_set_multi_ttl_udp(
Ok(())
}
#[op2(async)]
pub async fn op_net_set_broadcast_udp(
state: Rc<RefCell<OpState>>,
#[smi] rid: ResourceId,
broadcast: bool,
) -> Result<(), NetError> {
let resource = state
.borrow_mut()
.resource_table
.get::<UdpSocketResource>(rid)
.map_err(|_| NetError::SocketClosed)?;
let socket = RcRef::map(&resource, |r| &r.socket).borrow().await;
socket.set_broadcast(broadcast)?;
Ok(())
}
/// If this token is present in op_net_connect_tcp call and
/// the hostname matches with one of the resolved IPs, then
/// the permission check is performed against the original hostname.