]> source.dussan.org Git - rspamd.git/commitdiff
Add versions to rspamd modules and workers
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 12 Feb 2016 13:34:17 +0000 (13:34 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 12 Feb 2016 13:34:17 +0000 (13:34 +0000)
16 files changed:
CMakeLists.txt
config.h.in
src/controller.c
src/fuzzy_storage.c
src/hs_helper.c
src/http_proxy.c
src/lmtp.c
src/lua_worker.c
src/plugins/chartable.c
src/plugins/dkim_check.c
src/plugins/fuzzy_check.c
src/plugins/surbl.c
src/rspamd.h
src/smtp.c
src/smtp_proxy.c
src/worker.c

index 33dcf5cbf0cd5378a703cdbbb6c6333fd7ebffda..55611a75ab6b8c33cb3968c2e4966db1062bfb5c 100644 (file)
@@ -14,6 +14,11 @@ SET(RSPAMD_VERSION_MAJOR 1)
 SET(RSPAMD_VERSION_MINOR 2)
 SET(RSPAMD_VERSION_PATCH 0)
 
+# Keep two digits all the time
+SET(RSPAMD_VERSION_MAJOR_NUM ${RSPAMD_VERSION_MAJOR}0)
+SET(RSPAMD_VERSION_MINOR_NUM ${RSPAMD_VERSION_MINOR}0)
+SET(RSPAMD_VERSION_PATCH_NUM ${RSPAMD_VERSION_PATCH}0)
+
 IF(GIT_ID)
        SET(GIT_VERSION 1)
        SET(RSPAMD_ID "${GIT_ID}")
index bae4efdb9c935bae22eff55c1672bc0cb4fd6a60..4505c87bcb5bedfb33147936c47d3ed5995cc446 100644 (file)
 #define RSPAMD_PREFIX "${CMAKE_INSTALL_PREFIX}"
 
 
-#ifdef GIT_VERSION
+#if defined(GIT_VERSION) && GIT_VERSION == 1
 # define RVERSION         "${RSPAMD_VERSION}"
 # define RID              "${RSPAMD_ID}"
+# define RSPAMD_VERSION_NUM 0x${RSPAMD_VERSION_MAJOR_NUM}${RSPAMD_VERSION_MINOR_NUM}${RSPAMD_VERSION_PATCH_NUM}${RSPAMD_ID}ULL
 #else
 # define RVERSION          "${RSPAMD_VERSION}"
+# define RSPAMD_VERSION_NUM 0x${RSPAMD_VERSION_MAJOR_NUM}${RSPAMD_VERSION_MINOR_NUM}${RSPAMD_VERSION_PATCH_NUM}0000000ULL
 # define RID "release"
 #endif
 
index c88e51ef25b90014cdd9d2bc6fb5d4121d96db7e..59388ba1b22ce7f6fd21f6e1425e8c74b0e85988 100644 (file)
@@ -109,7 +109,8 @@ worker_t controller_worker = {
        TRUE,                   /* Non unique */
        FALSE,                  /* Non threaded */
        TRUE,                   /* Killable */
-       SOCK_STREAM             /* TCP socket */
+       SOCK_STREAM,            /* TCP socket */
+       RSPAMD_WORKER_VER       /* Version info */
 };
 /*
  * Worker's context
index c4814c6d40cbadaf0ecc2c04b6e1f0e9aefc9752..b852dbb85edd69584f1a1999646884e6caa8afb0 100644 (file)
@@ -56,7 +56,8 @@ worker_t fuzzy_worker = {
        FALSE,                      /* Unique */
        FALSE,                      /* Threaded */
        FALSE,                      /* Non killable */
-       SOCK_DGRAM                  /* UDP socket */
+       SOCK_DGRAM,                 /* UDP socket */
+       RSPAMD_WORKER_VER           /* Version info */
 };
 
 /* For evtimer */
index 6e496f28c6b6c0c732ccf56a6b99cbdcfc40fa62..a34d1d8859a81cec3aab38da31e432c8ab7726a0 100644 (file)
@@ -36,7 +36,8 @@ worker_t hs_helper_worker = {
                TRUE,                       /* Unique */
                FALSE,                      /* Non threaded */
                TRUE,                       /* Killable */
-               SOCK_STREAM                 /* TCP socket */
+               SOCK_STREAM,                /* TCP socket */
+               RSPAMD_WORKER_VER           /* Version info */
 };
 
 static const gdouble default_max_time = 1.0;
index 1af159f48c8fe428dfeb95033c21b2b04643e826..02f6769455fe160a936d9d37f8c535bd8806bc27 100644 (file)
@@ -42,7 +42,8 @@ worker_t http_proxy_worker = {
        FALSE,                      /* Non unique */
        FALSE,                      /* Non threaded */
        TRUE,                       /* Killable */
-       SOCK_STREAM                 /* TCP socket */
+       SOCK_STREAM,                /* TCP socket */
+       RSPAMD_WORKER_VER
 };
 
 struct rspamd_http_upstream {
index cb8a6718dd85cd1d8cecd9beb04b8401279f1300..09c1f467c8d98280b0936134452ac99a4b04b92d 100644 (file)
@@ -37,7 +37,8 @@ worker_t lmtp_worker = {
        TRUE,                       /* Has socket */
        FALSE,                      /* Non unique */
        FALSE,                      /* Non threaded */
-       TRUE                        /* Killable */
+       TRUE,                       /* Killable */
+       RSPAMD_WORKER_VER           /* Version info */
 };
 
 #ifndef HAVE_SA_SIGINFO
index 6aba9e64f86eada8c34a035dbe609ba0bece76a7..5f8c96fa99a5af48223b9d73ac5bfe495494e671 100644 (file)
@@ -46,7 +46,8 @@ worker_t lua_worker = {
        FALSE,                  /* Non unique */
        FALSE,                  /* Non threaded */
        TRUE,                   /* Killable */
-       SOCK_STREAM             /* TCP socket */
+       SOCK_STREAM,            /* TCP socket */
+       RSPAMD_WORKER_VER       /* Version info */
 };
 
 /*
index 50d4adb90de0e778d6ee26440df4d33d8f23e76d..0ef9efff6cb6db0b9a61b69fafe5e8eebfb3ac83 100644 (file)
@@ -39,7 +39,8 @@ module_t chartable_module = {
        chartable_module_init,
        chartable_module_config,
        chartable_module_reconfig,
-       NULL
+       NULL,
+       RSPAMD_MODULE_VER
 };
 
 struct chartable_ctx {
index 5813d1acd7de61ef0867010eb763e2790e19cdb6..24f08e9b1b17ccdc2876df4846942f5760ba41d6 100644 (file)
@@ -83,7 +83,8 @@ module_t dkim_module = {
        dkim_module_init,
        dkim_module_config,
        dkim_module_reconfig,
-       NULL
+       NULL,
+       RSPAMD_MODULE_VER
 };
 
 static void
index 9edf7fc9def58049c2482d0b533ce1473b69e83a..85c147a523b8bc17c332fff91acc26fc4a02f6d5 100644 (file)
@@ -151,7 +151,8 @@ module_t fuzzy_check_module = {
        fuzzy_check_module_init,
        fuzzy_check_module_config,
        fuzzy_check_module_reconfig,
-       fuzzy_attach_controller
+       fuzzy_attach_controller,
+       RSPAMD_MODULE_VER
 };
 
 static void
index ca565f3432b5f2eacc953f0fc4c65d6a7891f48e..cbd5f0f2bee67e4f161f50031ce5ac8b56250fe1 100644 (file)
@@ -73,7 +73,8 @@ module_t surbl_module = {
        surbl_module_init,
        surbl_module_config,
        surbl_module_reconfig,
-       NULL
+       NULL,
+       RSPAMD_MODULE_VER
 };
 
 static void
index df52393578cd89719fd37a2fdfbd26e1ac65c214..e5c7bb4db4e03875051343f9bc9019abb7ab0931 100644 (file)
@@ -96,6 +96,40 @@ struct module_ctx {
        gboolean enabled;                                                                                       /**< true if module is enabled in configuration         */
 };
 
+#ifndef WITH_HYPERSCAN
+#define RSPAMD_FEATURE_HYPERSCAN "0"
+#else
+#define RSPAMD_FEATURE_HYPERSCAN "1"
+#endif
+#ifndef WITH_PCRE2
+#define RSPAMD_FEATURE_PCRE2 "0"
+#else
+#define RSPAMD_FEATURE_PCRE2 "1"
+#endif
+#ifndef WITH_FANN
+#define RSPAMD_FEATURE_FANN "0"
+#else
+#define RSPAMD_FEATURE_FANN "1"
+#endif
+#ifndef WITH_SNOWBALL
+#define RSPAMD_FEATURE_SNOWBALL "0"
+#else
+#define RSPAMD_FEATURE_SNOWBALL "1"
+#endif
+
+#define RSPAMD_FEATURES \
+               RSPAMD_FEATURE_HYPERSCAN RSPAMD_FEATURE_PCRE2 \
+               RSPAMD_FEATURE_FANN RSPAMD_FEATURE_SNOWBALL
+
+#define RSPAMD_MODULE_VER \
+               0x1, /* Module version */ \
+               RSPAMD_VERSION_NUM, /* Rspamd version */ \
+               RSPAMD_FEATURES /* Compilation features */ \
+
+#define RSPAMD_WORKER_VER \
+               0x1, /* Worker version */ \
+               RSPAMD_VERSION_NUM, /* Rspamd version */ \
+               RSPAMD_FEATURES /* Compilation features */ \
 /**
  * Module
  */
@@ -106,6 +140,9 @@ typedef struct module_s {
        int (*module_reconfig_func)(struct rspamd_config *cfg);
        int (*module_attach_controller_func)(struct module_ctx *ctx,
                GHashTable *custom_commands);
+       guint module_version;
+       guint64 rspamd_version;
+       const gchar *rspamd_features;
 } module_t;
 
 typedef struct worker_s {
@@ -117,6 +154,9 @@ typedef struct worker_s {
        gboolean threaded;
        gboolean killable;
        gint listen_type;
+       guint module_version;
+       guint64 rspamd_version;
+       const gchar *rspamd_features;
 } worker_t;
 
 struct pidfh;
index 71e0da0611d500285d403fa0bb650c5d3af04023..07e28a4de0b2680765e1bac6048c5adef1969938 100644 (file)
@@ -51,7 +51,8 @@ worker_t smtp_worker = {
        FALSE,                      /* Non unique */
        FALSE,                      /* Non threaded */
        TRUE,                       /* Killable */
-       SOCK_STREAM                 /* TCP socket */
+       SOCK_STREAM,                /* TCP socket */
+       RSPAMD_WORKER_VER           /* Version info */
 };
 
 static gboolean
index 0698802a2662afa3275f3a1047316c4aa6d429a4..1a1e628b8a5711ef9072699114a2633daf48a4be 100644 (file)
@@ -47,7 +47,8 @@ worker_t smtp_proxy_worker = {
        FALSE,                      /* Non unique */
        FALSE,                      /* Non threaded */
        TRUE,                       /* Killable */
-       SOCK_STREAM                 /* TCP socket */
+       SOCK_STREAM,                /* TCP socket */
+       RSPAMD_WORKER_VER           /* Version info */
 };
 
 struct smtp_proxy_ctx {
index ab038f63f15430b5fbf9c815c0bf6f46e4578c36..91f570b62081ddeb5d4208847b4fa144018abaff 100644 (file)
@@ -50,7 +50,8 @@ worker_t normal_worker = {
        FALSE,                      /* Non unique */
        FALSE,                      /* Non threaded */
        TRUE,                       /* Killable */
-       SOCK_STREAM                 /* TCP socket */
+       SOCK_STREAM,                /* TCP socket */
+       RSPAMD_WORKER_VER           /* Version info */
 };
 
 #define msg_err_ctx(...) rspamd_default_log_function(G_LOG_LEVEL_CRITICAL, \