forked from j62/ctbrec
1
0
Fork 0

Add event processing system to the server

Similar to the events and actions in the client you can add event
listeners on the server. Easiest way to create them is to run ctbrec in
standalone mode and then create the event on the settings tab.
Afterwards you can copy the event handler from the client settings file
to the server settings.
This commit is contained in:
0xboobface 2018-12-10 15:44:15 +01:00
parent 1d409fa1d4
commit bcb89ef009
1 changed files with 14 additions and 0 deletions

View File

@ -17,6 +17,9 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import ctbrec.Config;
import ctbrec.event.EventBusHolder;
import ctbrec.event.EventHandler;
import ctbrec.event.EventHandlerConfiguration;
import ctbrec.recorder.LocalRecorder;
import ctbrec.recorder.OnlineMonitor;
import ctbrec.recorder.Recorder;
@ -51,6 +54,8 @@ public class HttpServer {
addShutdownHook(); // for graceful termination
registerAlertSystem();
config = Config.getInstance();
if(config.getSettings().key != null) {
LOG.info("HMAC authentication is enabled");
@ -133,6 +138,15 @@ public class HttpServer {
}
}
private void registerAlertSystem() {
for (EventHandlerConfiguration config : Config.getInstance().getSettings().eventHandlers) {
EventHandler handler = new EventHandler(config);
EventBusHolder.register(handler);
LOG.debug("Registered event handler for {} {}", config.getEvent(), config.getName());
}
LOG.debug("Alert System registered");
}
public static void main(String[] args) throws Exception {
new HttpServer();
}