Table of Contents

Class DaemonController

Namespace
FishMMO.ControlPanel.Controllers
Assembly
FishMMO-ControlPanel.dll

The daemon control plane: what each host is supervising, and start, stop and restart.

[ApiController]
[Route("api/daemon")]
public sealed class DaemonController : ControllerBase
Inheritance
DaemonController
Inherited Members

Remarks

This is the most dangerous surface in the panel, well past banning an account: it is the only one that can cause a process to run on another machine. Everything about it is shaped by containing that.

A command carries a verb from a closed enumeration and the name of an application some daemon already reported supervising. It carries no path, no arguments and no shell. The daemon then looks that name up in its own configuration file on disk and refuses anything it does not recognise. So the worst an attacker with this endpoint — or with the database password — can do is restart a FishMMO process that was already configured to run. They cannot make a game host run something new.

Queued, not executed. The panel writes a row; the daemon collects it on its next poll. Every acknowledgement here says so, for the same reason the server board does: an operator who believes a process has restarted, when the row has not been collected, will press the button again.

Operator plus a step-up, and every command is audited. A queued command that nobody can attribute is the one thing worse than not having the capability at all.

Constructors

DaemonController(IDaemonService, AuditScope, ILogger<DaemonController>)

public DaemonController(IDaemonService daemon, AuditScope audit, ILogger<DaemonController> log)

Parameters

daemon IDaemonService
audit AuditScope
log ILogger<DaemonController>

Methods

AppEvents(string, string, int?, DateTime?, DateTime?, int, int)

The supervision history: what the daemons observed changing, newest first.

[HttpGet("app-events")]
[Authorize(Policy = "Operator")]
public Task<IActionResult> AppEvents(string hostName, string appName, int? status, DateTime? from, DateTime? to, int page = 1, int pageSize = 50)

Parameters

hostName string
appName string
status int?
from DateTime?
to DateTime?
page int
pageSize int

Returns

Task<IActionResult>

Remarks

The sibling of the command log, and not the same thing. That route lists what operators asked this panel for. This lists what the supervisors saw happen by themselves — a process that died overnight, the restarts that followed, and whether it came back — which nobody asked for and which nothing else records. The row in daemon_apps behind the hosts page is overwritten on every heartbeat, so a fault that has already been recovered from is otherwise invisible in every view there is.

It is not process output, and it must never become it. Nothing a supervised process wrote reaches here: every row is derived in the database service by comparing one heartbeat against the stored one, from two status values and two integers, and the sentence describing the transition is composed from those. Server logs carry connection strings, tokens and paths inside exception messages, so a route that relayed them would turn this read-only view into a way of reading secrets out of a game host — and would let a compromised daemon put text of its choosing in front of an administrator.

A read, at the same policy as the other two reads here, and deliberately not audited — looking at a history is not an action taken on anything.

Commands(string, int, int)

The command history, newest first.

[HttpGet("commands")]
[Authorize(Policy = "Operator")]
public Task<IActionResult> Commands(string hostName, int page = 1, int pageSize = 50)

Parameters

hostName string
page int
pageSize int

Returns

Task<IActionResult>

Hosts()

Every daemon host and what it supervises.

[HttpGet("hosts")]
[Authorize(Policy = "Operator")]
public Task<IActionResult> Hosts()

Returns

Task<IActionResult>

Queue(CommandRequest)

Queues a start, stop or restart.

[HttpPost("commands")]
[Authorize(Policy = "Operator.StepUp")]
[Audited("daemon.command", TargetType = "daemon")]
public Task<IActionResult> Queue(DaemonController.CommandRequest request)

Parameters

request DaemonController.CommandRequest

Returns

Task<IActionResult>

Remarks

The verb is bounded against the enumeration here as well as in the service. It arrives as an integer in a JSON body, and a value outside the enum must never be stored: a daemon reading a command it cannot name would have to decide what to do with it, and there is no safe answer to that question.