mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-04 03:50:31 +00:00
chan_sip: Allow websockets to be disabled.
This patch adds a new setting "websockets_enabled" to sip.conf. Setting this to false allows chan_sip to be used without causing conflicts with res_pjsip_transport_websocket. ASTERISK-24106 #close Reported by: Andrew Nagy Change-Id: I04fe8c4f2d57b2d7375e0e25826c91a72e93bea7
This commit is contained in:
@@ -31261,6 +31261,7 @@ static int reload_config(enum channelreloadreason reason)
|
||||
int bindport = 0;
|
||||
int acl_change_subscription_needed = 0;
|
||||
int min_subexpiry_set = 0, max_subexpiry_set = 0;
|
||||
int websocket_was_enabled = sip_cfg.websocket_enabled;
|
||||
|
||||
run_start = time(0);
|
||||
ast_unload_realtime("sipregs");
|
||||
@@ -32047,6 +32048,8 @@ static int reload_config(enum channelreloadreason reason)
|
||||
ast_log(LOG_WARNING, "'%s' is not a valid websocket_write_timeout value at line %d. Using default '%d'.\n", v->value, v->lineno, AST_DEFAULT_WEBSOCKET_WRITE_TIMEOUT);
|
||||
sip_cfg.websocket_write_timeout = AST_DEFAULT_WEBSOCKET_WRITE_TIMEOUT;
|
||||
}
|
||||
} else if (!strcasecmp(v->name, "websocket_enabled")) {
|
||||
sip_cfg.websocket_enabled = ast_true(v->value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32392,6 +32395,15 @@ static int reload_config(enum channelreloadreason reason)
|
||||
notify_types = NULL;
|
||||
}
|
||||
|
||||
/* If the module is loading it's not time to enable websockets yet. */
|
||||
if (reason != CHANNEL_MODULE_LOAD && websocket_was_enabled != sip_cfg.websocket_enabled) {
|
||||
if (sip_cfg.websocket_enabled) {
|
||||
ast_websocket_add_protocol("sip", sip_websocket_callback);
|
||||
} else {
|
||||
ast_websocket_remove_protocol("sip", sip_websocket_callback);
|
||||
}
|
||||
}
|
||||
|
||||
run_end = time(0);
|
||||
ast_debug(4, "SIP reload_config done...Runtime= %d sec\n", (int)(run_end-run_start));
|
||||
|
||||
@@ -34573,7 +34585,9 @@ static int load_module(void)
|
||||
sip_register_tests();
|
||||
network_change_stasis_subscribe();
|
||||
|
||||
ast_websocket_add_protocol("sip", sip_websocket_callback);
|
||||
if (sip_cfg.websocket_enabled) {
|
||||
ast_websocket_add_protocol("sip", sip_websocket_callback);
|
||||
}
|
||||
|
||||
return AST_MODULE_LOAD_SUCCESS;
|
||||
}
|
||||
@@ -34588,7 +34602,9 @@ static int unload_module(void)
|
||||
|
||||
ast_sip_api_provider_unregister();
|
||||
|
||||
ast_websocket_remove_protocol("sip", sip_websocket_callback);
|
||||
if (sip_cfg.websocket_enabled) {
|
||||
ast_websocket_remove_protocol("sip", sip_websocket_callback);
|
||||
}
|
||||
|
||||
network_change_stasis_unsubscribe();
|
||||
acl_change_event_stasis_unsubscribe();
|
||||
|
@@ -774,6 +774,7 @@ struct sip_settings {
|
||||
int tcp_enabled;
|
||||
int default_max_forwards; /*!< Default max forwards (SIP Anti-loop) */
|
||||
int websocket_write_timeout; /*!< Socket write timeout for websocket transports, in ms */
|
||||
int websocket_enabled; /*!< Are websockets enabled? */
|
||||
};
|
||||
|
||||
struct ast_websocket;
|
||||
|
Reference in New Issue
Block a user