deadserver.handlers package

Submodules

deadserver.handlers.alog module

Handler for ALOG requests: receive access logs

deadserver.handlers.alog.handle(controller, data, ctx)[source]

Handles the ALOG message.

Messages are idempotent, which in this case means that every particular (controller, time, card_id, allowed) combination will be recorded at most once, even if such a packet is received multiple times.

deadserver.handlers.ask module

Handler for ASK requests: should I allow access now?

deadserver.handlers.ask.handle(controller, data, ctx)[source]

deadserver.handlers.defs module

Provides functions for defining request handlers, such as the handles(msg_type) decorator.

deadserver.handlers.defs.get_handler_for(msg_type)[source]
deadserver.handlers.defs.handles(msg_type)[source]

deadserver.handlers.echotest module

Handler for ECHOTEST requests: echo for testing purposes

deadserver.handlers.echotest.handle_echotest(controller, data, ctx)[source]

deadserver.handlers.ping module

Handler for PING requests: keepalive, DB and FW version info

deadserver.handlers.ping.get_latest_or_0(cf, ftype, controller)[source]
deadserver.handlers.ping.handle(controller, req, ctx)[source]

deadserver.handlers.xfer module

Handler for XFER requests: transfer a file chunk

deadserver.handlers.xfer.handle(controller, req, ctx)[source]

Module contents

Collects request handlers for the various message types.

How to write a request handler:

Your module must define function(controller_id, request_data) -> status, response_data. This must be registered as a handler for a request type using the @handles(deadserver.protocol.MsgType) decorator. See below for note on importing.

Hello world example:

```python from deadserver.protocol import MsgType, ResponseStatus

@handles(deadserver.protocol.MsgType.HELLO) # actually, this doesn’t exist, but if it did... def handle_hello(controller_id, data):

return ResponseStatus.OK, b’Hello ‘ + controller_id + b’! You sent: ‘ + data

```

See ./open.py for a real-world example.


In order to be executed (and therefore registered), your handler module must be imported somewhere. This file is a good place for that, as it is imported by deadserver.api. Unless you have a reason to do this differently, add your handlers below.