summaryrefslogtreecommitdiff
path: root/res/ari
diff options
context:
space:
mode:
Diffstat (limited to 'res/ari')
-rw-r--r--res/ari/ari_websockets.c10
-rw-r--r--res/ari/config.c4
-rw-r--r--res/ari/internal.h2
3 files changed, 16 insertions, 0 deletions
diff --git a/res/ari/ari_websockets.c b/res/ari/ari_websockets.c
index 90d6f0fdb..ff0a53c4f 100644
--- a/res/ari/ari_websockets.c
+++ b/res/ari/ari_websockets.c
@@ -56,11 +56,16 @@ struct ast_ari_websocket_session *ast_ari_websocket_session_create(
struct ast_websocket *ws_session, int (*validator)(struct ast_json *))
{
RAII_VAR(struct ast_ari_websocket_session *, session, NULL, ao2_cleanup);
+ RAII_VAR(struct ast_ari_conf *, config, ast_ari_config_get(), ao2_cleanup);
if (ws_session == NULL) {
return NULL;
}
+ if (config == NULL || config->general == NULL) {
+ return NULL;
+ }
+
if (validator == NULL) {
validator = null_validator;
}
@@ -72,6 +77,11 @@ struct ast_ari_websocket_session *ast_ari_websocket_session_create(
return NULL;
}
+ if (ast_websocket_set_timeout(ws_session, config->general->write_timeout)) {
+ ast_log(LOG_WARNING, "Failed to set write timeout %d on ARI web socket\n",
+ config->general->write_timeout);
+ }
+
session = ao2_alloc(sizeof(*session), websocket_session_dtor);
if (!session) {
return NULL;
diff --git a/res/ari/config.c b/res/ari/config.c
index 59c4d7d94..667d91ac0 100644
--- a/res/ari/config.c
+++ b/res/ari/config.c
@@ -27,6 +27,7 @@
ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include "asterisk/config_options.h"
+#include "asterisk/http_websocket.h"
#include "internal.h"
/*! \brief Locking container for safe configuration access. */
@@ -320,6 +321,9 @@ int ast_ari_config_init(void)
aco_option_register(&cfg_info, "allowed_origins", ACO_EXACT, general_options,
"", OPT_STRINGFIELD_T, 0,
STRFLDSET(struct ast_ari_conf_general, allowed_origins));
+ aco_option_register(&cfg_info, "websocket_write_timeout", ACO_EXACT, general_options,
+ AST_DEFAULT_WEBSOCKET_WRITE_TIMEOUT_STR, OPT_INT_T, PARSE_IN_RANGE,
+ FLDSET(struct ast_ari_conf_general, write_timeout), 1, INT_MAX);
aco_option_register(&cfg_info, "type", ACO_EXACT, user, NULL,
OPT_NOOP_T, 0, 0);
diff --git a/res/ari/internal.h b/res/ari/internal.h
index 8453747f1..93ea0b773 100644
--- a/res/ari/internal.h
+++ b/res/ari/internal.h
@@ -65,6 +65,8 @@ struct ast_ari_conf {
struct ast_ari_conf_general {
/*! Enabled by default, disabled if false. */
int enabled;
+ /*! Write timeout for websocket connections */
+ int write_timeout;
/*! Encoding format used during output (default compact). */
enum ast_json_encoding_format format;
/*! Authentication realm */