From 2d81eded1e64737d2ecca278efc2a84be7dbd8f5 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Fri, 14 Sep 2012 20:59:23 +0400 Subject: * Initial approach to RESTful controller. Fix security issues in fstring handling. --- src/main.h | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'src/main.h') diff --git a/src/main.h b/src/main.h index f90edf1d2..9a28793cd 100644 --- a/src/main.h +++ b/src/main.h @@ -131,10 +131,15 @@ union sa_union { /** * Control session object */ +struct controller_command; +struct controller_session; +typedef void (*controller_func_t)(gchar **args, struct controller_session *session); + struct controller_session { struct rspamd_worker *worker; /**< pointer to worker structure (controller in fact) */ enum { STATE_COMMAND, + STATE_HEADER, STATE_LEARN, STATE_LEARN_SPAM_PRE, STATE_LEARN_SPAM, @@ -146,7 +151,10 @@ struct controller_session { } state; /**< current session state */ gint sock; /**< socket descriptor */ /* Access to authorized commands */ - gint authorized; /**< whether this session is authorized */ + gboolean authorized; /**< whether this session is authorized */ + gboolean restful; /**< whether this session is a restful session */ + GHashTable *kwargs; /**< keyword arguments for restful command */ + struct controller_command *cmd; /**< real command */ memory_pool_t *session_pool; /**< memory pool for session */ struct config_file *cfg; /**< pointer to config file */ gchar *learn_rcpt; /**< recipient for learning */ @@ -161,14 +169,13 @@ struct controller_session { void (*other_handler)(struct controller_session *session, f_str_t *in); /**< other command handler to execute at the end of processing */ void *other_data; /**< and its data */ + controller_func_t custom_handler; /**< custom command handler */ struct rspamd_async_session* s; /**< async session object */ struct worker_task *learn_task; struct rspamd_dns_resolver *resolver; /**< DNS resolver */ struct event_base *ev_base; /**< Event base */ }; -typedef void (*controller_func_t)(gchar **args, struct controller_session *session); - /** * Worker task structure */ -- cgit v1.2.3