diff options
Diffstat (limited to 'src/core/service.c')
| -rw-r--r-- | src/core/service.c | 42 |
1 files changed, 37 insertions, 5 deletions
diff --git a/src/core/service.c b/src/core/service.c index 6cf2b16..20934a7 100644 --- a/src/core/service.c +++ b/src/core/service.c @@ -7,6 +7,7 @@ #include "storage_private.h" #include "hybbx/registry.h" #include "hybbx/config.h" +#include "hybbx/command.h" #include "hybbx/crypto_config.h" #include "hybbx/traffic.h" #include "hybbx/circuit_tcp.h" @@ -26,7 +27,6 @@ void hybbx_mains_proxy_plugin_tick(void); #include "hybbx/instance.h" #include "hybbx/log.h" #include "hybbx/monitor.h" -#include "hybbx/chess.h" #include <errno.h> #include "hybbx/security.h" #include "hybbx/security_ban.h" @@ -168,7 +168,6 @@ void hybbx_service_destroy(hybbx_service_t *service) } hybbx_monitor_shutdown(); - hybbx_chess_init(); hybbx_log_shutdown(); hybbx_security_log_shutdown(); hybbx_security_ban_shutdown(); @@ -989,13 +988,22 @@ hybbx_result_t hybbx_service_run(hybbx_service_t *service) health_tick++; if (health_tick >= 300u) { health_tick = 0; - hybbx_log_info("[service] health: running=%d transports=%u sessions_active (tick)", + hybbx_log_info("[service] health: running=%d transports=%zu sessions_active (tick)", svc->running, svc->transport_count); } hybbx_security_ban_tick(); hybbx_monitor_tick(service); - hybbx_chess_tick(service); + /* Plugin ticks — iterate all registered plugins */ + { + size_t pi; + for (pi = 0; pi < svc->transport_count; pi++) { + const hybbx_transport_plugin_t *p = svc->transports[pi].plugin; + if (p != NULL && p->tick != NULL) { + p->tick(service); + } + } + } hybbx_broadcast_ax25_tick(service); #ifdef HYBBX_HAVE_PLUGIN_MAINS_PROXY hybbx_mains_proxy_plugin_tick(); @@ -1016,6 +1024,31 @@ hybbx_result_t hybbx_service_run(hybbx_service_t *service) return HYBBX_OK; } +hybbx_result_t hybbx_service_try_plugin_command(hybbx_service_t *service, + struct hybbx_session *session, + const struct hybbx_parsed_command *cmd) +{ + struct hybbx_service_internal *svc = + (struct hybbx_service_internal *)service; + size_t i; + + if (svc == NULL || cmd == NULL) { + return HYBBX_ERR_NOT_FOUND; + } + + for (i = 0; i < svc->transport_count; i++) { + const hybbx_transport_plugin_t *p = svc->transports[i].plugin; + if (p != NULL && p->on_command != NULL) { + hybbx_result_t rc = p->on_command(service, session, cmd); + if (rc == HYBBX_OK) { + return HYBBX_OK; + } + } + } + + return HYBBX_ERR_NOT_FOUND; +} + void hybbx_service_stop(hybbx_service_t *service) { struct hybbx_service_internal *svc = @@ -1223,7 +1256,6 @@ hybbx_result_t hybbx_service_apply_config(hybbx_service_t *service, hybbx_log_config_apply(config); hybbx_security_log_config_apply(config); hybbx_monitor_config_apply(config); - hybbx_chess_config_apply(config); hybbx_security_ban_config_apply(config); service_apply_texts(svc, config); hybbx_chat_config_apply(&svc->chat, config); |
