cherrypicked from b6a8590c34 its v6 its better
This commit is contained in:
+5
-1
@@ -7,9 +7,11 @@ use crate::route::api::Status; */
|
||||
use crate::utils::parse::mac::{des_opm, ser_opm};
|
||||
use crate::utils::wake::wake_one;
|
||||
use axum::{extract::Json, http::StatusCode, response::IntoResponse};
|
||||
use futures::TryFutureExt;
|
||||
use macaddr::MacAddr;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_with::skip_serializing_none;
|
||||
use tokio::net::UdpSocket;
|
||||
|
||||
#[skip_serializing_none]
|
||||
#[derive(Debug, Default, Serialize, Clone)]
|
||||
@@ -75,7 +77,9 @@ pub async fn wake_multi(Json(req): Json<Vec<WakeTarget>>) -> impl IntoResponse {
|
||||
pub async fn wake_multi_split(
|
||||
targets: impl IntoIterator<Item = WakeTarget>,
|
||||
) -> io::Result<Vec<WakeTargetResult>> {
|
||||
let sock = tokio::net::UdpSocket::bind("0.0.0.0:0").await?;
|
||||
let sock = UdpSocket::bind("[::]:0")
|
||||
.or_else(|_| UdpSocket::bind(":0"))
|
||||
.await?;
|
||||
sock.set_broadcast(true)?;
|
||||
|
||||
Ok(
|
||||
|
||||
+4
-1
@@ -1,6 +1,7 @@
|
||||
pub mod impls;
|
||||
use std::{io, net::IpAddr};
|
||||
|
||||
use futures::TryFutureExt;
|
||||
use macaddr::MacAddr;
|
||||
use tokio::net::UdpSocket;
|
||||
|
||||
@@ -74,7 +75,9 @@ impl WakeTargetResult {
|
||||
pub async fn _wake_multi(
|
||||
targets: impl IntoIterator<Item = WakeTarget>,
|
||||
) -> io::Result<Vec<WakeTargetResult>> {
|
||||
let sock = UdpSocket::bind(":0").await?;
|
||||
let sock = UdpSocket::bind("[::]:0")
|
||||
.or_else(|_| UdpSocket::bind(":0"))
|
||||
.await?;
|
||||
sock.set_broadcast(true)?;
|
||||
let fs = targets.into_iter().map(|t| wake_one(&sock, t));
|
||||
Ok(futures::future::join_all(fs).await)
|
||||
|
||||
Reference in New Issue
Block a user