mirror of
https://github.com/renorris/openfsd
synced 2026-03-23 07:15:34 +08:00
Changes:
- Implement bootstrapping library for managing several concurrent internal services
- Refactor concurrency model for connections/logical clients and their associated I/O
- Refactor server context singleton
- Refactor error handling
- Most errors are now gracefully sent to the FSD client directly encoded as an $ER packet,
enhancing visibility and debugging
- Most errors are now rightfully treated as non-fatal
- Refactor package/dependency graph
- Refactor calling conventions/interfaces for many packages
- Refactor database package
- Refactor post office
Features:
- Add VATSIM-esque HTTP/JSON "data feed"
- Add ephemeral in-memory database option
- Add user management REST API
- Add improved web interface
- Add MySQL support (drop SQLite support)
45 lines
1.0 KiB
Go
45 lines
1.0 KiB
Go
package handler
|
|
|
|
import (
|
|
"github.com/renorris/openfsd/protocol"
|
|
"github.com/renorris/openfsd/servercontext"
|
|
"strconv"
|
|
)
|
|
|
|
func killRequestHandler(invoker Invoker, packet string) (result Result, err error) {
|
|
// Parse packet
|
|
pdu := protocol.KillRequestPDU{}
|
|
if err = pdu.Parse(packet); err != nil {
|
|
return
|
|
}
|
|
|
|
// Verify source callsign
|
|
if pdu.From != invoker.Callsign() {
|
|
return pduSourceInvalidResult()
|
|
}
|
|
|
|
// Check if user has permission
|
|
if invoker.NetworkRating() < protocol.NetworkRatingSUP {
|
|
err = protocol.NewGenericFSDError(protocol.SyntaxError, strconv.Itoa(int(invoker.NetworkRating())), "insufficient permission to kill")
|
|
return
|
|
}
|
|
|
|
replyPDU := protocol.TextMessagePDU{
|
|
From: protocol.ServerCallsign,
|
|
To: invoker.Callsign(),
|
|
Message: "",
|
|
}
|
|
|
|
if err = servercontext.PostOffice().Kill(&pdu); err != nil {
|
|
replyPDU.Message = err.Error()
|
|
result.addReply(replyPDU.Serialize())
|
|
return result, nil
|
|
}
|
|
|
|
replyPDU.Message = "killed " + pdu.To
|
|
|
|
result.addReply(replyPDU.Serialize())
|
|
|
|
return
|
|
}
|