shutdown WIP

This commit is contained in:
2026-07-09 17:22:32 +05:30
parent 0cd38d041e
commit 0d9af8f605
7 changed files with 123 additions and 5 deletions
+2 -2
View File
@@ -11,7 +11,7 @@ pub enum WError {
InvalidConfigDir(String),
ConfigDirInitError(String),
ConfigFileFormatError(String),
UdpSocketError(String),
UdpSocketBindError(String),
}
impl Display for WError {
@@ -24,7 +24,7 @@ impl Display for WError {
WError::InvalidConfigDir(s) => format!("{}", s),
WError::ConfigDirInitError(s) => format!("{}", s),
WError::ConfigFileFormatError(s) => format!("{}", s),
WError::UdpSocketError(s) => format!("{}", s),
WError::UdpSocketBindError(s) => format!("{}", s),
};
write!(f, "{}", to_write)
+7
View File
@@ -68,9 +68,16 @@ impl Nick {
}
}
pub(crate) struct IpV4 {
original_string: String,
ip: [u8; 4],
port: u32,
}
pub(crate) enum Device {
Mac(Mac),
Nick(Nick),
IpV4(IpV4),
}
impl Device {
+6 -3
View File
@@ -21,13 +21,16 @@ impl Wolz {
mac.copy_magic_bytes(&mut magic_bytes);
let socket = UdpSocket::bind("0.0.0.0:0")
.map_err(|e| WError::UdpSocketError(format!("couldn't bind to socket because {}", e)))?;
.map_err(|e| WError::UdpSocketBindError(format!("couldn't bind to socket because {}", e)))?;
socket.set_broadcast(true)
.map_err(|e| WError::UdpSocketError(format!("couldn't set broadcast because {}", e)))?;
.map_err(|e| WError::UdpSocketBindError(format!("couldn't set broadcast because {}", e)))?;
socket
.send_to(&magic_bytes, "255.255.255.255:9")
.map_err(|e| WError::UdpSocketError(format!("couldn't send data because {}", e)))?;
.map_err(|e| WError::UdpSocketBindError(format!("couldn't send data because {}", e)))?;
println!("Magic packet sent to 255.255.255.255:9 for Mac {:}", mac);
Ok(())
}
pub fn shutdown(&self, ip_or_nick: &str) -> WResult<()> {
}
}