105 lines
4.1 KiB
Markdown
105 lines
4.1 KiB
Markdown
# Network Resurrector
|
|
|
|
Everything should be manageable remotely—even powered-off servers. This need led to the creation of **Network Resurrector**, a tool I developed to wake up machines that don't need to be powered on at all times.
|
|
|
|
The system consists of five core components that provide essential functionality. Additional components can be integrated to enhance features like notifications and logging.
|
|
|
|
## Core Components
|
|
|
|
### Frontend
|
|
The [frontend](https://lab.code-rove.com/gitea/tudor.stanciu/network-resurrector-frontend) is a **React.js**-based web application that provides a user-friendly interface for managing the system.
|
|
|
|
### API
|
|
The API is a **.NET 8 REST API** responsible for handling communication between the frontend, database, and server components. It facilitates data exchange and enables actions such as waking or shutting down machines.
|
|
|
|
### Server
|
|
The server component is a **.NET 8** service that performs **Wake-on-LAN**, **Ping**, and **Shutdown** actions for machines within its network or any accessible network.
|
|
|
|
### Agent
|
|
The agent is a **.NET 8** service that can execute various power-related actions on the host machine, including:
|
|
- **Shutdown**
|
|
- **Restart**
|
|
- **Sleep**
|
|
- **Logout**
|
|
- **Lock**
|
|
|
|
These actions can be executed immediately or scheduled with a delay, allowing cancellation before execution.
|
|
|
|
#### How It Works
|
|
1. A user triggers an action (e.g., wake or shutdown) via the UI.
|
|
2. The frontend sends the request to the API.
|
|
3. The API determines whether the **Agent** or **Server** should execute the action and forwards the request.
|
|
4. The responsible component executes the action and returns the result.
|
|
|
|
The agent can be installed on multiple machines as needed.
|
|
|
|
### Tuitio
|
|
[Tuitio](https://lab.code-rove.com/gitea/tudor.stanciu/tuitio) is my personal identity server, handling user authentication and request authorization. For more details, refer to the [Tuitio documentation](https://lab.code-rove.com/gitea/tudor.stanciu/tuitio/src/branch/master/README.md).
|
|
|
|
All communication between the core components is done via **HTTP**.
|
|
|
|
## Secondary Components
|
|
|
|
- **NATS Streaming**: Publishes notifications regarding executed actions.
|
|
- **Correo**: Handles email notifications.
|
|
- **Seq**: Collects and displays system logs.
|
|
|
|
## Notification System
|
|
|
|
The notification system is designed to inform users about system actions (e.g., wake, shutdown). Notifications are configurable and follow a customizable template structure, as shown below:
|
|
|
|
```json
|
|
{
|
|
"To": [ "user@homelab.com" ],
|
|
"Subject": "Network Resurrector: Machine {MACHINE_NAME} has been powered on. Status: {ACTION_STATUS}",
|
|
"Body": "Hello,{NEWLINE:2}Network Resurrector processed a command to start machine {MACHINE_FULLNAME} with IP {MACHINE_IP} at {SYSTEM_DATETIME}.{NEWLINE}The assigned performer for this action was {ACTION_PERFORMER}.{NEWLINE}Action status: {ACTION_STATUS}{NEWLINE:2}Best regards,{NEWLINE}Network Resurrector Notification System."
|
|
}
|
|
```
|
|
|
|
### Placeholders
|
|
|
|
Users can customize notification texts using the following placeholders:
|
|
|
|
- `{MACHINE_NAME}`
|
|
- `{MACHINE_FULLNAME}`
|
|
- `{MACHINE_IP}`
|
|
- `{ACTION_STATUS}`
|
|
- `{ACTION_PERFORMER}`
|
|
- `{SYSTEM_DATETIME}`
|
|
- `{ERROR_MESSAGE}`
|
|
- `{NEWLINE}` (Adds a single newline)
|
|
- `{NEWLINE:x}` (Adds `x` new lines)
|
|
|
|
## Database
|
|
|
|
Currently, **Microsoft SQL Server** is the only supported database. Future versions will include support for **PostgreSQL** and **SQLite**.
|
|
|
|
## Logging
|
|
|
|
Logging is managed with **Serilog**, configurable via `appsettings.json`. Logs can be stored in:
|
|
- **SQL Server**
|
|
- **Seq**
|
|
|
|
These logging destinations can be enabled or disabled based on requirements. If console logging is sufficient, all additional logging can be disabled.
|
|
|
|
### Configuration Example
|
|
|
|
```json
|
|
"Logs": {
|
|
"SqlServer": {
|
|
"Enabled": false,
|
|
"Connection": "Server=<server>;Database=<database>;User Id=<user>;Password=<password>;"
|
|
},
|
|
"Seq": {
|
|
"Enabled": false,
|
|
"Url": "",
|
|
"ApiKey": ""
|
|
}
|
|
}
|
|
```
|
|
|
|
## Hosting
|
|
|
|
All components of **Network Resurrector** are built using cross-platform technologies, allowing deployment in any environment that supports them.
|
|
|