LUA_FUNCTION_DEF (task, get_client_ip_num);
LUA_FUNCTION_DEF (task, get_helo);
LUA_FUNCTION_DEF (task, set_helo);
+LUA_FUNCTION_DEF (task, get_hostname);
+LUA_FUNCTION_DEF (task, set_hostname);
LUA_FUNCTION_DEF (task, get_images);
LUA_FUNCTION_DEF (task, get_symbol);
LUA_FUNCTION_DEF (task, get_date);
LUA_INTERFACE_DEF (task, get_client_ip_num),
LUA_INTERFACE_DEF (task, get_helo),
LUA_INTERFACE_DEF (task, set_helo),
+ LUA_INTERFACE_DEF (task, get_hostname),
+ LUA_INTERFACE_DEF (task, set_hostname),
LUA_INTERFACE_DEF (task, get_images),
LUA_INTERFACE_DEF (task, get_symbol),
LUA_INTERFACE_DEF (task, get_date),
return 0;
}
+static gint
+lua_task_get_hostname (lua_State *L)
+{
+ struct worker_task *task = lua_check_task (L);
+
+ if (task) {
+ if (task->hostname != NULL) {
+ lua_pushstring (L, (gchar *)task->hostname);
+ return 1;
+ }
+ }
+
+ lua_pushnil (L);
+ return 1;
+}
+
+static gint
+lua_task_set_hostname (lua_State *L)
+{
+ struct worker_task *task = lua_check_task (L);
+ const gchar *new_hostname;
+
+ if (task) {
+ new_hostname = luaL_checkstring (L, 2);
+ if (new_hostname) {
+ task->hostname = memory_pool_strdup (task->task_pool, new_hostname);
+ }
+ }
+
+ return 0;
+}
+
static gint
lua_task_get_images (lua_State *L)
{
gchar *deliver_to; /**< address to deliver */
gchar *user; /**< user to deliver */
gchar *subject; /**< subject (for non-mime) */
+ gchar *hostname; /**< hostname reported by MTA */
gchar *statfile; /**< statfile for learning */
f_str_t *msg; /**< message buffer */
rspamd_io_dispatcher_t *dispatcher; /**< IO dispatcher object */
#define USER_HEADER "User"
#define PASS_HEADER "Pass"
#define JSON_HEADER "Json"
+#define HOSTNAME_HEADER "Hostname"
#define DELIVER_TO_HEADER "Deliver-To"
static GList *custom_commands = NULL;
task->helo = memory_pool_fstrdup (task->task_pool, line);
debug_task ("read helo header, value: %s", task->helo);
}
+ else if (g_ascii_strncasecmp (headern, HOSTNAME_HEADER, sizeof (HOSTNAME_HEADER) - 1) == 0) {
+ task->hostname = memory_pool_fstrdup (task->task_pool, line);
+ debug_task ("read hostname header, value: %s", task->hostname);
+ }
else {
msg_info ("wrong header: %s", headern);
res = FALSE;
err_socket (GError * err, void *arg)
{
struct worker_task *task = (struct worker_task *) arg;
- struct rspamd_worker_ctx *ctx;
-
- ctx = task->worker->ctx;
msg_info ("abnormally closing connection from: %s, error: %s", inet_ntoa (task->client_addr), err->message);
/* Free buffers */