Skip to content

A simple .NET Standard library for sending Wake On Lan packets (Magic packet) over ethernet

License

Notifications You must be signed in to change notification settings

Derungsoft/WolSharp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WolSharp

A simple .NET Standard library for sending WakeOnLan packets (Magic packet) over ethernet

Prerequisites

To wake up computers using this library they need to have WakeOnLan enabled and must be in the same local network

Installation

Install the NuGet package of this library using

Install-Package Derungsoft.WolSharp

ARM32 Wake on Lan Server for Docker (Raspberry Pi)

You can set up your own Wake On Lan Server running inside Docker on a Raspberry Pi!

Just install Docker on your Pi and then execute the following command:

sudo docker run --name WolSharp -d -it --restart unless-stopped --network=host derungsoft/wolsharp:0.1

This command will download and run the WOL Server which runs on port 80.

If you don't want the Server to automatically start on boot, you can remove "--restart unless-stopped"

Then wake up other computers by calling this URL:

 http://192.168.1.123/api/wake/55-33-44-55-AA-BB

Just replace the IP and MAC address and you're good to go.

Usage

Basic usage

using Derungsoft.WolSharp;
// ...

// Create awakener instance with default PhysicalAddressParser
var awakener = new Awakener();

// Send WoL to "AA-00-BB-11-CC-22"
awakener.Wake("AA-00-BB-11-CC-22");

Async using await

using Derungsoft.WolSharp;
// ...

// Create awakener instance with default PhysicalAddressParser
var awakener = new Awakener();

// Send WoL to "AA-00-BB-11-CC-22"
await awakener.WakeAsync("AA-00-BB-11-CC-22");

Using custom PhysicalAddressParser

Create custom PhysicalAddressParser class

public class MyPhysicalAddressParser : IPhysicalAddressParser
{
    //Implement Parse methods
    //...
}

Pass parser to Awakener constructor

// Create custom PhysicalAddressParser
var physicalAddressParser = new MyPhysicalAddressParser();

// Pass custom parser to constructor
var awakener = new Awakener(physicalAddressParser);

await awakener.WakeAsync("AA-00-BB-11-CC-22");

Dependency injection

  1. Register IAwakener using Awakener
  2. Register IPhysicalAddressParser using DefaultPhysicalAddressParser or a custom implementation

About

A simple .NET Standard library for sending Wake On Lan packets (Magic packet) over ethernet

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published