diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2016-05-09 18:19:49 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2016-05-09 18:19:49 +0100 |
commit | f847ed39344b3ca0ed0345963b7ff2a6e0335ec2 (patch) | |
tree | f6cdfa31454b005baa1607fcd0b1798a63260a61 /src/libutil/map_private.h | |
parent | 4ef507e1592efbe33ca948f6bc76e4f100921184 (diff) | |
download | rspamd-f847ed39344b3ca0ed0345963b7ff2a6e0335ec2.tar.gz rspamd-f847ed39344b3ca0ed0345963b7ff2a6e0335ec2.zip |
[Rework] Start the complete maps rework
Issue: #616
Diffstat (limited to 'src/libutil/map_private.h')
-rw-r--r-- | src/libutil/map_private.h | 65 |
1 files changed, 51 insertions, 14 deletions
diff --git a/src/libutil/map_private.h b/src/libutil/map_private.h index c26517574..2f0889d2a 100644 --- a/src/libutil/map_private.h +++ b/src/libutil/map_private.h @@ -24,30 +24,57 @@ typedef void (*rspamd_map_dtor) (gpointer p); +#define msg_err_map(...) rspamd_default_log_function (G_LOG_LEVEL_CRITICAL, \ + "map", map->tag, \ + G_STRFUNC, \ + __VA_ARGS__) +#define msg_warn_map(...) rspamd_default_log_function (G_LOG_LEVEL_WARNING, \ + "map", map->tag, \ + G_STRFUNC, \ + __VA_ARGS__) +#define msg_info_map(...) rspamd_default_log_function (G_LOG_LEVEL_INFO, \ + "map", map->tag, \ + G_STRFUNC, \ + __VA_ARGS__) +#define msg_debug_map(...) rspamd_default_log_function (G_LOG_LEVEL_DEBUG, \ + "map", map->tag, \ + G_STRFUNC, \ + __VA_ARGS__) + enum fetch_proto { MAP_PROTO_FILE, MAP_PROTO_HTTP, }; -struct rspamd_map { - rspamd_mempool_t *pool; - struct rspamd_dns_resolver *r; + +struct rspamd_map_backend { + enum fetch_proto protocol; gboolean is_signed; struct rspamd_cryptobox_pubkey *trusted_pubkey; + union { + struct file_map_data *fd; + struct http_map_data *hd; + } data; + gchar *uri; + ref_entry_t ref; +}; + +struct rspamd_map { + struct rspamd_dns_resolver *r; struct rspamd_config *cfg; - enum fetch_proto protocol; + GPtrArray *backends; map_cb_t read_callback; map_fin_cb_t fin_callback; void **user_data; - struct event ev; - struct timeval tv; struct event_base *ev_base; - void *map_data; - gchar *uri; gchar *description; + gchar *name; guint32 id; - guint32 checksum; + struct event ev; + struct timeval tv; + guint poll_timeout; /* Shared lock for temporary disabling of map reading (e.g. when this map is written by UI) */ gint *locked; + gchar tag[MEMPOOL_UID_LEN]; rspamd_map_dtor dtor; gpointer dtor_data; }; @@ -56,7 +83,7 @@ struct rspamd_map { * Data specific to file maps */ struct file_map_data { - const gchar *filename; + gchar *filename; struct stat st; }; @@ -64,12 +91,12 @@ struct file_map_data { * Data specific to HTTP maps */ struct http_map_data { - struct addrinfo *addr; - guint16 port; gchar *path; gchar *host; + gchar *last_signature; time_t last_checked; gboolean request_sent; + guint16 port; }; enum rspamd_map_http_stage { @@ -80,20 +107,30 @@ enum rspamd_map_http_stage { map_load_signature }; +struct map_periodic_cbdata { + struct rspamd_map *map; + struct map_cb_data cbdata; + gboolean need_modify; + gboolean errored; + guint cur_backend; +}; + struct http_callback_data { struct event_base *ev_base; struct rspamd_http_connection *conn; rspamd_inet_addr_t *addr; - struct timeval tv; struct rspamd_map *map; + struct rspamd_map_backend *bk; struct http_map_data *data; - struct map_cb_data cbdata; + struct map_periodic_cbdata *periodic; struct rspamd_cryptobox_pubkey *pk; + gboolean check; gchar *tmpfile; enum rspamd_map_http_stage stage; gint out_fd; gint fd; + struct timeval tv; ref_entry_t ref; }; |