shutdown WIP
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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<()> {
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user