aboutsummaryrefslogtreecommitdiffstats
path: root/src/lua
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2016-10-21 15:06:47 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2016-10-21 15:06:47 +0100
commitd1a07ee03b620115e509c84c67745929a30e8212 (patch)
treefeb410f67c961a17372d3886e9f8196af12ae683 /src/lua
parent0b3a5af70014ab9894149bb78e74891429efd5b8 (diff)
downloadrspamd-d1a07ee03b620115e509c84c67745929a30e8212.tar.gz
rspamd-d1a07ee03b620115e509c84c67745929a30e8212.zip
[Feature] Allow HTTPS requests in lua_http
Diffstat (limited to 'src/lua')
-rw-r--r--src/lua/lua_http.c40
1 files changed, 33 insertions, 7 deletions
diff --git a/src/lua/lua_http.c b/src/lua/lua_http.c
index 711248fb4..ab3cf3810 100644
--- a/src/lua/lua_http.c
+++ b/src/lua/lua_http.c
@@ -61,6 +61,7 @@ struct lua_http_cbdata {
struct rspamd_async_watcher *w;
struct rspamd_http_message *msg;
struct event_base *ev_base;
+ struct rspamd_config *cfg;
struct timeval tv;
rspamd_inet_addr_t *addr;
gchar *mime_type;
@@ -205,13 +206,25 @@ lua_http_make_connection (struct lua_http_cbdata *cbd)
return FALSE;
}
cbd->fd = fd;
- cbd->conn = rspamd_http_connection_new (NULL,
- lua_http_error_handler,
- lua_http_finish_handler,
- RSPAMD_HTTP_CLIENT_SIMPLE,
- RSPAMD_HTTP_CLIENT,
- NULL,
- NULL);
+
+ if (cbd->cfg) {
+ cbd->conn = rspamd_http_connection_new (NULL,
+ lua_http_error_handler,
+ lua_http_finish_handler,
+ RSPAMD_HTTP_CLIENT_SIMPLE,
+ RSPAMD_HTTP_CLIENT,
+ NULL,
+ cbd->cfg->libs_ctx->ssl_ctx);
+ }
+ else {
+ cbd->conn = rspamd_http_connection_new (NULL,
+ lua_http_error_handler,
+ lua_http_finish_handler,
+ RSPAMD_HTTP_CLIENT_SIMPLE,
+ RSPAMD_HTTP_CLIENT,
+ NULL,
+ NULL);
+ }
rspamd_http_connection_write_message (cbd->conn, cbd->msg,
cbd->host, cbd->mime_type, cbd, fd,
@@ -298,6 +311,7 @@ lua_http_request (lua_State *L)
struct rspamd_async_session *session;
struct rspamd_lua_text *t;
struct rspamd_task *task = NULL;
+ struct rspamd_config *cfg = NULL;
gdouble timeout = default_http_timeout;
gchar *mime_type = NULL;
@@ -362,6 +376,7 @@ lua_http_request (lua_State *L)
ev_base = task->ev_base;
resolver = task->resolver;
session = task->s;
+ cfg = task->cfg;
}
lua_pop (L, 1);
@@ -395,6 +410,16 @@ lua_http_request (lua_State *L)
session = NULL;
}
lua_pop (L, 1);
+
+ lua_pushstring (L, "config");
+ lua_gettable (L, -2);
+ if (rspamd_lua_check_udata_maybe (L, -1, "rspamd{config}")) {
+ cfg = *(struct rspamd_config **)lua_touserdata (L, -1);
+ }
+ else {
+ cfg = NULL;
+ }
+ lua_pop (L, 1);
}
msg = rspamd_http_message_from_url (url);
@@ -456,6 +481,7 @@ lua_http_request (lua_State *L)
cbd->mime_type = mime_type;
msec_to_tv (timeout, &cbd->tv);
cbd->fd = -1;
+ cbd->cfg = cfg;
if (msg->host) {
cbd->host = rspamd_fstring_cstr (msg->host);