Compare commits
31 Commits
a982950203
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
9dfcc401ed
|
|||
| a8e430cdf2 | |||
| b83c1a79bd | |||
| 2fa102ce19 | |||
| f1ff0bafc4 | |||
| 73f6331f03 | |||
| 86879ffcfe | |||
| 273a0ab858 | |||
| ce3982c4d9 | |||
| 83bb0462f9 | |||
| 9270c08445 | |||
| 6da68306fb | |||
| 3f8bbe6fed | |||
| b2ef0f640e | |||
| 2b9b53525e | |||
| c6ed8ba411 | |||
| 2550a944f0 | |||
| b334b5d891 | |||
| cca6efd831 | |||
| 441ee65b84 | |||
| 4d23124eb9 | |||
| 8f57e6f821 | |||
| a7ed2ca9a0 | |||
| 3c314f10af | |||
| 7840b338f8 | |||
| fab61e686b | |||
| e19003ecb7 | |||
| c03002b250 | |||
| 3cd4320d8e | |||
| 069b470473 | |||
| 20bdacbbea |
@@ -0,0 +1,35 @@
|
|||||||
|
name: Code coverage
|
||||||
|
concurrency:
|
||||||
|
group: "${{ github.workflow }}-${{ github.ref }}"
|
||||||
|
cancel-in-progress: "${{ github.ref != 'refs/heads/master' }}"
|
||||||
|
"on":
|
||||||
|
workflow_dispatch:
|
||||||
|
merge_group:
|
||||||
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
codedov:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v6
|
||||||
|
- uses: taiki-e/install-action@cargo-llvm-cov
|
||||||
|
- run: cargo llvm-cov --all-features --lcov --output-path lcov.info
|
||||||
|
env:
|
||||||
|
RUSTC_WRAPPER:
|
||||||
|
- uses: actions/upload-artifact@v7
|
||||||
|
with:
|
||||||
|
name: lcov.info
|
||||||
|
path: lcov.info
|
||||||
|
if-no-files-found: error
|
||||||
|
- name: Upload to codecov
|
||||||
|
env:
|
||||||
|
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
|
||||||
|
run: |
|
||||||
|
curl -Os https://uploader.codecov.io/latest/linux/codecov
|
||||||
|
chmod +x codecov
|
||||||
|
./codecov -f lcov.info -Z
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
# This workflow will run `cargo-deny`, checking for dependency issues related to licensing, known vulnerabilities, and more.
|
||||||
|
# The configuration file is in [deny.toml](../../deny.toml).
|
||||||
|
name: Cargo Deny
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
pull_request:
|
||||||
|
merge_group:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
cargo-deny:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v6
|
||||||
|
- uses: EmbarkStudios/cargo-deny-action@v2
|
||||||
+10
-30
@@ -14,18 +14,18 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Cancel Previous Runs
|
- name: Cancel Previous Runs
|
||||||
uses: styfle/cancel-workflow-action@0.11.0
|
uses: styfle/cancel-workflow-action@0.13.1
|
||||||
with:
|
with:
|
||||||
access_token: ${{ github.token }}
|
access_token: ${{ github.token }}
|
||||||
- name: Checkout Sources
|
- name: Checkout Sources
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v6
|
||||||
- name: Install Toolchain
|
- name: Install Toolchain
|
||||||
uses: actions-rs/toolchain@v1
|
uses: actions-rs/toolchain@v1
|
||||||
with:
|
with:
|
||||||
toolchain: stable
|
toolchain: stable
|
||||||
profile: minimal
|
profile: minimal
|
||||||
- name: Rust Cache
|
- name: Rust Cache
|
||||||
uses: Swatinem/rust-cache@v2.5.1
|
uses: Swatinem/rust-cache@v2.9.1
|
||||||
- name: Run tests
|
- name: Run tests
|
||||||
run: cargo test --verbose
|
run: cargo test --verbose
|
||||||
|
|
||||||
@@ -35,11 +35,11 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Cancel Previous Runs
|
- name: Cancel Previous Runs
|
||||||
uses: styfle/cancel-workflow-action@0.11.0
|
uses: styfle/cancel-workflow-action@0.13.1
|
||||||
with:
|
with:
|
||||||
access_token: ${{ github.token }}
|
access_token: ${{ github.token }}
|
||||||
- name: Checkout Sources
|
- name: Checkout Sources
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v6
|
||||||
- name: Install Toolchain
|
- name: Install Toolchain
|
||||||
uses: actions-rs/toolchain@v1
|
uses: actions-rs/toolchain@v1
|
||||||
with:
|
with:
|
||||||
@@ -50,52 +50,32 @@ jobs:
|
|||||||
- name: Install RustFmt
|
- name: Install RustFmt
|
||||||
run: rustup component add rustfmt
|
run: rustup component add rustfmt
|
||||||
- name: Rust Cache
|
- name: Rust Cache
|
||||||
uses: Swatinem/rust-cache@v2.5.1
|
uses: Swatinem/rust-cache@v2.9.1
|
||||||
- name: Run format check
|
- name: Run format check
|
||||||
run: cargo fmt --all --check
|
run: cargo fmt --all --check
|
||||||
- name: Run clippy
|
- name: Run clippy
|
||||||
run: cargo clippy --all --all-targets -- -D warnings
|
run: cargo clippy --all --all-targets -- -D warnings
|
||||||
|
|
||||||
audit:
|
|
||||||
name: Audit
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- name: Checkout Sources
|
|
||||||
uses: actions/checkout@v3
|
|
||||||
- name: Install Toolchain
|
|
||||||
uses: actions-rs/toolchain@v1
|
|
||||||
with:
|
|
||||||
toolchain: stable
|
|
||||||
profile: minimal
|
|
||||||
- name: Install Audit
|
|
||||||
run: cargo install cargo-audit
|
|
||||||
- name: Rust Cache
|
|
||||||
uses: Swatinem/rust-cache@v2.5.1
|
|
||||||
- name: Run Audit
|
|
||||||
uses: actions-rs/cargo@v1
|
|
||||||
with:
|
|
||||||
command: audit
|
|
||||||
|
|
||||||
build:
|
build:
|
||||||
name: Build
|
name: Build
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
os: [ubuntu-latest, macos-latest]
|
os: [ubuntu-latest, macos-latest, ubuntu-24.04-arm]
|
||||||
rv: [stable, beta, nightly]
|
rv: [stable, beta, nightly]
|
||||||
steps:
|
steps:
|
||||||
- name: Cancel Previous Runs
|
- name: Cancel Previous Runs
|
||||||
uses: styfle/cancel-workflow-action@0.11.0
|
uses: styfle/cancel-workflow-action@0.13.1
|
||||||
with:
|
with:
|
||||||
access_token: ${{ github.token }}
|
access_token: ${{ github.token }}
|
||||||
- name: Checkout Sources
|
- name: Checkout Sources
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v6
|
||||||
- name: Install Toolchain
|
- name: Install Toolchain
|
||||||
uses: actions-rs/toolchain@v1
|
uses: actions-rs/toolchain@v1
|
||||||
with:
|
with:
|
||||||
toolchain: ${{ matrix.rv }}
|
toolchain: ${{ matrix.rv }}
|
||||||
- name: Rust Cache
|
- name: Rust Cache
|
||||||
uses: Swatinem/rust-cache@v2.5.1
|
uses: Swatinem/rust-cache@v2.9.1
|
||||||
- name: Cargo Build
|
- name: Cargo Build
|
||||||
uses: actions-rs/cargo@v1
|
uses: actions-rs/cargo@v1
|
||||||
with:
|
with:
|
||||||
|
|||||||
@@ -5,6 +5,20 @@ All notable changes to this project will be documented in this file.
|
|||||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||||
|
|
||||||
|
## [0.4.1] - 2026-03-02
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- Added link to the README in the changelog for better visibility.
|
||||||
|
|
||||||
|
## [0.4.0] - 2026-03-02
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- Bumped Rust edition to 2024 and Rust version to 1.93.1
|
||||||
|
|
||||||
|
- `WolPacket::into_inner` now has `must_use` attribute to prevent accidentally consuming the packet without using the inner data.
|
||||||
|
|
||||||
## [0.3.0] - 2023-01-06
|
## [0.3.0] - 2023-01-06
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
[workspace]
|
[workspace]
|
||||||
|
resolver = "2"
|
||||||
members = [
|
members = [
|
||||||
"wakey",
|
"wakey",
|
||||||
"wakey-wake"
|
"wakey-wake"
|
||||||
|
|||||||
@@ -2,8 +2,9 @@
|
|||||||
[](https://github.com/LesnyRumcajs/wakey/actions/workflows/rust.yml)
|
[](https://github.com/LesnyRumcajs/wakey/actions/workflows/rust.yml)
|
||||||
[](https://crates.io/crates/wakey)
|
[](https://crates.io/crates/wakey)
|
||||||
[](https://docs.rs/wakey)
|
[](https://docs.rs/wakey)
|
||||||
|
[](https://codecov.io/github/LesnyRumcajs/wakey)
|
||||||
|
|
||||||
Library for managing Wake-on-LAN packets. It supports:
|
Library for managing [Wake-on-LAN packets](https://en.wikipedia.org/wiki/Wake-on-LAN). It supports:
|
||||||
* creating magic packets,
|
* creating magic packets,
|
||||||
* broadcasting them via UDP.
|
* broadcasting them via UDP.
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
[advisories]
|
||||||
|
ignore = []
|
||||||
|
|
||||||
|
[licenses]
|
||||||
|
allow = [
|
||||||
|
"Apache-2.0",
|
||||||
|
"MIT",
|
||||||
|
"Unicode-3.0"
|
||||||
|
]
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
[toolchain]
|
||||||
|
channel = "1.93.1"
|
||||||
|
components = ["clippy", "llvm-tools-preview", "rustfmt"]
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "wakey-wake"
|
name = "wakey-wake"
|
||||||
version = "0.3.0"
|
version = "0.4.1"
|
||||||
|
|
||||||
authors = ["Hubert Bugaj<lesny.rumcajs@gmail.com>"]
|
authors = ["Hubert Bugaj<lesny.rumcajs@gmail.com>"]
|
||||||
edition = "2021"
|
edition = "2024"
|
||||||
|
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
repository = "https://github.com/LesnyRumcajs/wakey"
|
repository = "https://github.com/LesnyRumcajs/wakey"
|
||||||
@@ -15,3 +15,6 @@ categories = ["network-programming"]
|
|||||||
[dependencies]
|
[dependencies]
|
||||||
wakey = { path = "../wakey" }
|
wakey = { path = "../wakey" }
|
||||||
clap = { version = "4.0", features = ["derive"] }
|
clap = { version = "4.0", features = ["derive"] }
|
||||||
|
|
||||||
|
[profile.release]
|
||||||
|
strip = true
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ fn main() -> wakey::Result<()> {
|
|||||||
.expect("Invalid MAC address format. Please use one of the separators: [:, -, /]");
|
.expect("Invalid MAC address format. Please use one of the separators: [:, -, /]");
|
||||||
let wol = wakey::WolPacket::from_string(&mac_adress, sep)?;
|
let wol = wakey::WolPacket::from_string(&mac_adress, sep)?;
|
||||||
if wol.send_magic().is_ok() {
|
if wol.send_magic().is_ok() {
|
||||||
println!("Sent the magic packet.");
|
println!("Sent the magic packet to {mac_adress}");
|
||||||
} else {
|
} else {
|
||||||
println!("Failed to send the magic packet.");
|
println!("Failed to send the magic packet.");
|
||||||
}
|
}
|
||||||
|
|||||||
+6
-4
@@ -1,9 +1,10 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "wakey"
|
name = "wakey"
|
||||||
version = "0.3.0"
|
version = "0.4.1"
|
||||||
|
readme = "../README.md"
|
||||||
|
|
||||||
authors = ["Hubert Bugaj<lesny.rumcajs@gmail.com>"]
|
authors = ["Hubert Bugaj<lesny.rumcajs@gmail.com>"]
|
||||||
edition = "2021"
|
edition = "2024"
|
||||||
|
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
repository = "https://github.com/LesnyRumcajs/wakey"
|
repository = "https://github.com/LesnyRumcajs/wakey"
|
||||||
@@ -13,5 +14,6 @@ keywords = ["wol", "wake-on-lan"]
|
|||||||
categories = ["network-programming"]
|
categories = ["network-programming"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
hex = "~0.4"
|
hex = "0.4"
|
||||||
arrayvec = "0.7.2"
|
arrayvec = "0.7"
|
||||||
|
tokio = { version = "1.52.3", features = ["net"] }
|
||||||
|
|||||||
+9
-7
@@ -10,10 +10,11 @@
|
|||||||
//! ```
|
//! ```
|
||||||
|
|
||||||
use std::error::Error;
|
use std::error::Error;
|
||||||
use std::net::{SocketAddr, ToSocketAddrs, UdpSocket};
|
use std::net::SocketAddr;
|
||||||
use std::{fmt, iter};
|
use std::{fmt, iter};
|
||||||
|
|
||||||
use arrayvec::ArrayVec;
|
use arrayvec::ArrayVec;
|
||||||
|
use tokio::net::{ToSocketAddrs, UdpSocket};
|
||||||
|
|
||||||
const MAC_SIZE: usize = 6;
|
const MAC_SIZE: usize = 6;
|
||||||
const MAC_PER_MAGIC: usize = 16;
|
const MAC_PER_MAGIC: usize = 16;
|
||||||
@@ -95,11 +96,12 @@ impl WolPacket {
|
|||||||
/// let wol = wakey::WolPacket::from_bytes(&vec![0x00, 0x01, 0x02, 0x03, 0x04, 0x05]).unwrap();
|
/// let wol = wakey::WolPacket::from_bytes(&vec![0x00, 0x01, 0x02, 0x03, 0x04, 0x05]).unwrap();
|
||||||
/// wol.send_magic();
|
/// wol.send_magic();
|
||||||
/// ```
|
/// ```
|
||||||
pub fn send_magic(&self) -> Result<()> {
|
pub async fn send_magic(&self) -> Result<()> {
|
||||||
self.send_magic_to(
|
self.send_magic_to(
|
||||||
SocketAddr::from(([0, 0, 0, 0], 0)),
|
SocketAddr::from(([0, 0, 0, 0], 0)),
|
||||||
SocketAddr::from(([255, 255, 255, 255], 9)),
|
SocketAddr::from(([255, 255, 255, 255], 9)),
|
||||||
)
|
)
|
||||||
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Broadcasts the magic packet from / to specified address.
|
/// Broadcasts the magic packet from / to specified address.
|
||||||
@@ -111,15 +113,16 @@ impl WolPacket {
|
|||||||
/// let dst = SocketAddr::from(([255,255,255,255], 9));
|
/// let dst = SocketAddr::from(([255,255,255,255], 9));
|
||||||
/// wol.send_magic_to(src, dst);
|
/// wol.send_magic_to(src, dst);
|
||||||
/// ```
|
/// ```
|
||||||
pub fn send_magic_to<A: ToSocketAddrs>(&self, src: A, dst: A) -> Result<()> {
|
pub async fn send_magic_to<A: ToSocketAddrs>(&self, src: A, dst: A) -> Result<()> {
|
||||||
let udp_sock = UdpSocket::bind(src)?;
|
let udp_sock = UdpSocket::bind(src).await?;
|
||||||
udp_sock.set_broadcast(true)?;
|
udp_sock.set_broadcast(true)?;
|
||||||
udp_sock.send_to(&self.packet, dst)?;
|
udp_sock.send_to(&self.packet, dst).await?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the underlying WoL packet bytes
|
/// Returns the underlying WoL packet bytes
|
||||||
|
#[must_use]
|
||||||
pub fn into_inner(self) -> Packet {
|
pub fn into_inner(self) -> Packet {
|
||||||
self.packet
|
self.packet
|
||||||
}
|
}
|
||||||
@@ -149,8 +152,7 @@ impl WolPacket {
|
|||||||
|
|
||||||
/// Extends the MAC address to fill the magic packet
|
/// Extends the MAC address to fill the magic packet
|
||||||
fn extend_mac(mac: &[u8]) -> ArrayVec<u8, { MAC_SIZE * MAC_PER_MAGIC }> {
|
fn extend_mac(mac: &[u8]) -> ArrayVec<u8, { MAC_SIZE * MAC_PER_MAGIC }> {
|
||||||
let magic = iter::repeat(mac)
|
let magic = iter::repeat_n(mac, MAC_PER_MAGIC)
|
||||||
.take(MAC_PER_MAGIC)
|
|
||||||
.flatten()
|
.flatten()
|
||||||
.copied()
|
.copied()
|
||||||
.collect::<ArrayVec<u8, { MAC_SIZE * MAC_PER_MAGIC }>>();
|
.collect::<ArrayVec<u8, { MAC_SIZE * MAC_PER_MAGIC }>>();
|
||||||
|
|||||||
Reference in New Issue
Block a user