Merge branch 'signalwire:master' into execute_on_hold

This commit is contained in:
wmasilva 2023-04-19 09:18:25 +01:00 committed by GitHub
commit d2f745ffd7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
19 changed files with 243 additions and 149 deletions

View File

@ -86,7 +86,6 @@ typedef union {
static uint32_t index_from_float(float f); static uint32_t index_from_float(float f);
static float float_from_index(uint32_t d); static float float_from_index(uint32_t d);
static float *acos_table = NULL; static float *acos_table = NULL;
static int acos_fd = -1;
#ifdef FAST_ACOSF_TESTING #ifdef FAST_ACOSF_TESTING
@ -112,6 +111,10 @@ extern int compute_table(void)
acos_table_file = fopen(ACOS_TABLE_FILENAME, "w"); acos_table_file = fopen(ACOS_TABLE_FILENAME, "w");
if (!acos_table_file) {
return -3;
}
for (i = 0; i < ACOS_TABLE_LENGTH; i++) { for (i = 0; i < ACOS_TABLE_LENGTH; i++) {
f = acosf(float_from_index(i)); f = acosf(float_from_index(i));
res = fwrite(&f, sizeof(f), 1, acos_table_file); res = fwrite(&f, sizeof(f), 1, acos_table_file);
@ -124,10 +127,12 @@ extern int compute_table(void)
if (res != 0) { if (res != 0) {
return -2; return -2;
} }
return 0; return 0;
fail: fail:
fclose(acos_table_file); fclose(acos_table_file);
return -1; return -1;
} }
@ -144,8 +149,9 @@ extern int init_fast_acosf(void)
* or some other error occured */ * or some other error occured */
errsv = errno; errsv = errno;
strerror_r(errsv, err, 150); strerror_r(errsv, err, 150);
if (errsv != ENOENT) return -1; if (errsv != ENOENT) {
else { return -1;
} else {
switch_log_printf( switch_log_printf(
SWITCH_CHANNEL_LOG, SWITCH_CHANNEL_LOG,
SWITCH_LOG_NOTICE, SWITCH_LOG_NOTICE,
@ -166,10 +172,10 @@ extern int init_fast_acosf(void)
acos_fp = fopen(ACOS_TABLE_FILENAME, "r"); acos_fp = fopen(ACOS_TABLE_FILENAME, "r");
if (acos_fp == NULL) return -3; if (acos_fp == NULL) return -3;
/* can't fail */ /* can't fail */
acos_fd = fileno(acos_fp);
acos_table = (float *) mmap( acos_table = (float *) mmap(
NULL, /* kernel chooses the address at which to create the mapping */ NULL, /* kernel chooses the address at which to create the mapping */
ACOS_TABLE_LENGTH * sizeof(float), PROT_READ, MAP_SHARED, acos_fd, 0); ACOS_TABLE_LENGTH * sizeof(float), PROT_READ, MAP_SHARED, fileno(acos_fp), 0);
fclose(acos_fp);
if (acos_table == MAP_FAILED) return -4; if (acos_table == MAP_FAILED) return -4;
return 0; return 0;
@ -178,9 +184,7 @@ extern int init_fast_acosf(void)
extern int destroy_fast_acosf(void) extern int destroy_fast_acosf(void)
{ {
if (munmap(acos_table, ACOS_TABLE_LENGTH) == -1) return -1; if (munmap(acos_table, ACOS_TABLE_LENGTH) == -1) return -1;
if (acos_fd != -1) {
if (close(acos_fd) == -1) return -2;
}
/* disable use of fast arc cosine file */ /* disable use of fast arc cosine file */
acos_table = NULL; acos_table = NULL;

View File

@ -1138,6 +1138,13 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_avmd_load) {
switch_application_interface_t *app_interface; switch_application_interface_t *app_interface;
switch_api_interface_t *api_interface; switch_api_interface_t *api_interface;
if (pool == NULL) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No memory pool assigned!\n");
return SWITCH_STATUS_TERM;
}
/* connect my internal structure to the blank pointer passed to me */ /* connect my internal structure to the blank pointer passed to me */
*module_interface = switch_loadable_module_create_module_interface(pool, modname); *module_interface = switch_loadable_module_create_module_interface(pool, modname);
@ -1147,10 +1154,6 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_avmd_load) {
} }
memset(&avmd_globals, 0, sizeof(avmd_globals)); memset(&avmd_globals, 0, sizeof(avmd_globals));
if (pool == NULL) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No memory pool assigned!\n");
return SWITCH_STATUS_TERM;
}
switch_mutex_init(&avmd_globals.mutex, SWITCH_MUTEX_NESTED, pool); switch_mutex_init(&avmd_globals.mutex, SWITCH_MUTEX_NESTED, pool);
avmd_globals.pool = pool; avmd_globals.pool = pool;
@ -1622,9 +1625,6 @@ SWITCH_STANDARD_APP(avmd_start_function) {
SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_avmd_shutdown) { SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_avmd_shutdown) {
size_t session_n; size_t session_n;
#ifndef WIN32
int res;
#endif
switch_mutex_lock(avmd_globals.mutex); switch_mutex_lock(avmd_globals.mutex);
@ -1638,18 +1638,8 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_avmd_shutdown) {
#ifndef WIN32 #ifndef WIN32
if (avmd_globals.settings.fast_math == 1) { if (avmd_globals.settings.fast_math == 1) {
res = destroy_fast_acosf(); if (destroy_fast_acosf()) {
if (res != 0) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed unmap arc cosine table\n");
switch (res) {
case -1:
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed unmap arc cosine table\n");
break;
case -2:
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed closing arc cosine table\n");
break;
default:
break;
}
} }
} }
#endif #endif
@ -1658,6 +1648,7 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_avmd_shutdown) {
switch_mutex_unlock(avmd_globals.mutex); switch_mutex_unlock(avmd_globals.mutex);
switch_mutex_destroy(avmd_globals.mutex); switch_mutex_destroy(avmd_globals.mutex);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Advanced voicemail detection disabled\n"); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Advanced voicemail detection disabled\n");
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
} }

View File

@ -3225,6 +3225,7 @@ SWITCH_STANDARD_API(uuid_capture_text)
} else { } else {
if ((tsession = switch_core_session_locate(uuid))) { if ((tsession = switch_core_session_locate(uuid))) {
switch_ivr_capture_text(tsession, switch_true(onoff)); switch_ivr_capture_text(tsession, switch_true(onoff));
switch_core_session_rwunlock(tsession);
} else { } else {
stream->write_function(stream, "-ERR No such channel %s!\n", uuid); stream->write_function(stream, "-ERR No such channel %s!\n", uuid);
} }

View File

@ -4584,7 +4584,7 @@ SWITCH_STANDARD_APP(wait_for_silence_function)
timeout_ms = switch_atoui(argv[3]); timeout_ms = switch_atoui(argv[3]);
} }
if (thresh > 0 && silence_hits > 0 && listen_hits >= 0) { if (thresh > 0 && silence_hits > 0) {
switch_ivr_wait_for_silence(session, thresh, silence_hits, listen_hits, timeout_ms, argv[4]); switch_ivr_wait_for_silence(session, thresh, silence_hits, listen_hits, timeout_ms, argv[4]);
return; return;
} }

View File

@ -228,7 +228,7 @@ static ks_status_t load_credentials_from_json(ks_json_t *json)
const char *relay_connector_id = NULL; const char *relay_connector_id = NULL;
#if SIGNALWIRE_CLIENT_C_VERSION_MAJOR >= 2 #if SIGNALWIRE_CLIENT_C_VERSION_MAJOR >= 2
if ((bootstrap = ks_json_get_string(json, "bootstrap")) == NULL) { if ((bootstrap = ks_json_get_object_string(json, "bootstrap", NULL)) == NULL) {
#else #else
if ((bootstrap = ks_json_get_object_cstr(json, "bootstrap")) == NULL) { if ((bootstrap = ks_json_get_object_cstr(json, "bootstrap")) == NULL) {
#endif #endif
@ -238,7 +238,7 @@ static ks_status_t load_credentials_from_json(ks_json_t *json)
} }
#if SIGNALWIRE_CLIENT_C_VERSION_MAJOR >= 2 #if SIGNALWIRE_CLIENT_C_VERSION_MAJOR >= 2
if ((relay_connector_id = ks_json_get_string(json, "relay_connector_id")) == NULL) { if ((relay_connector_id = ks_json_get_object_string(json, "relay_connector_id", NULL)) == NULL) {
#else #else
if ((relay_connector_id = ks_json_get_object_cstr(json, "relay_connector_id")) == NULL) { if ((relay_connector_id = ks_json_get_object_cstr(json, "relay_connector_id")) == NULL) {
#endif #endif
@ -797,6 +797,7 @@ static ks_status_t load_credentials(void)
status = KS_STATUS_FAIL; status = KS_STATUS_FAIL;
goto done; goto done;
} }
fclose(fp); fclose(fp);
json = ks_json_parse(data); json = ks_json_parse(data);
@ -805,6 +806,7 @@ static ks_status_t load_credentials(void)
status = KS_STATUS_FAIL; status = KS_STATUS_FAIL;
goto done; goto done;
} }
status = load_credentials_from_json(json); status = load_credentials_from_json(json);
ks_json_delete(&json); ks_json_delete(&json);
@ -981,7 +983,6 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_signalwire_load)
#ifdef WIN32 #ifdef WIN32
sslLoadWindowsCACertificate(); sslLoadWindowsCACertificate();
#endif #endif
// Configuration // Configuration
swclt_config_create(&globals.config); swclt_config_create(&globals.config);
load_config(); load_config();
@ -1206,6 +1207,7 @@ static void mod_signalwire_state_configure(void)
#if SIGNALWIRE_CLIENT_C_VERSION_MAJOR >= 2 #if SIGNALWIRE_CLIENT_C_VERSION_MAJOR >= 2
if (!swclt_sess_provisioning_configure(globals.signalwire_session, "freeswitch", local_endpoint, external_endpoint, globals.relay_connector_id, &reply)) { if (!swclt_sess_provisioning_configure(globals.signalwire_session, "freeswitch", local_endpoint, external_endpoint, globals.relay_connector_id, &reply)) {
if (reply->type == SWCLT_CMD_TYPE_RESULT) { if (reply->type == SWCLT_CMD_TYPE_RESULT) {
ks_json_t *result;
#else #else
if (!swclt_sess_provisioning_configure(globals.signalwire_session, "freeswitch", local_endpoint, external_endpoint, globals.relay_connector_id, &cmd)) { if (!swclt_sess_provisioning_configure(globals.signalwire_session, "freeswitch", local_endpoint, external_endpoint, globals.relay_connector_id, &cmd)) {
SWCLT_CMD_TYPE cmd_type; SWCLT_CMD_TYPE cmd_type;
@ -1215,7 +1217,8 @@ static void mod_signalwire_state_configure(void)
#endif #endif
signalwire_provisioning_configure_response_t *configure_res; signalwire_provisioning_configure_response_t *configure_res;
#if SIGNALWIRE_CLIENT_C_VERSION_MAJOR >= 2 #if SIGNALWIRE_CLIENT_C_VERSION_MAJOR >= 2
if (!SIGNALWIRE_PROVISIONING_CONFIGURE_RESPONSE_PARSE(reply->pool, reply->json, &configure_res)) { result = ks_json_get_object_item(reply->json, "result");
if (!SIGNALWIRE_PROVISIONING_CONFIGURE_RESPONSE_PARSE(reply->pool, result, &configure_res)) {
#else #else
swclt_cmd_result(cmd, &result); swclt_cmd_result(cmd, &result);
result = ks_json_get_object_item(result, "result"); result = ks_json_get_object_item(result, "result");
@ -1223,7 +1226,7 @@ static void mod_signalwire_state_configure(void)
#endif #endif
ks_json_t *configuration = configure_res->configuration; ks_json_t *configuration = configure_res->configuration;
#if SIGNALWIRE_CLIENT_C_VERSION_MAJOR >= 2 #if SIGNALWIRE_CLIENT_C_VERSION_MAJOR >= 2
const char *configuration_profile = ks_json_get_string(configuration, "profile"); const char *configuration_profile = ks_json_get_object_string(configuration, "profile", NULL);
#else #else
const char *configuration_profile = ks_json_get_object_cstr(configuration, "profile"); const char *configuration_profile = ks_json_get_object_cstr(configuration, "profile");
#endif #endif
@ -1231,6 +1234,7 @@ static void mod_signalwire_state_configure(void)
switch_xml_free(globals.signalwire_profile); switch_xml_free(globals.signalwire_profile);
globals.signalwire_profile = NULL; globals.signalwire_profile = NULL;
} }
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "\"%s\"\n", configuration_profile); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "\"%s\"\n", configuration_profile);
globals.signalwire_profile = switch_xml_parse_str_dynamic((char *)configuration_profile, SWITCH_TRUE); globals.signalwire_profile = switch_xml_parse_str_dynamic((char *)configuration_profile, SWITCH_TRUE);
if (!globals.signalwire_profile) { if (!globals.signalwire_profile) {

View File

@ -130,6 +130,7 @@ static void translate_number(char *number, char *profile, char **translated, swi
hi = switch_core_hash_find_rdlock(globals.translate_profiles, (const char *)profile, globals.profile_hash_rwlock); hi = switch_core_hash_find_rdlock(globals.translate_profiles, (const char *)profile, globals.profile_hash_rwlock);
if (!hi) { if (!hi) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "can't find key for profile matching [%s]\n", profile); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "can't find key for profile matching [%s]\n", profile);
return; return;
} }
@ -142,6 +143,7 @@ static void translate_number(char *number, char *profile, char **translated, swi
switch_regex_safe_free(re); switch_regex_safe_free(re);
goto end; goto end;
} }
memset(substituted, 0, len); memset(substituted, 0, len);
switch_perform_substitution(re, proceed, rule->replace, number, substituted, len, ovector); switch_perform_substitution(re, proceed, rule->replace, number, substituted, len, ovector);
@ -153,16 +155,21 @@ static void translate_number(char *number, char *profile, char **translated, swi
} else if (event) { } else if (event) {
subbed = switch_event_expand_headers(event, substituted); subbed = switch_event_expand_headers(event, substituted);
} }
if (subbed != substituted) {
switch_safe_free(substituted);
}
if (session) { if (session) {
substituted = switch_core_session_strdup(session, subbed); substituted = switch_core_session_strdup(session, subbed);
} else { } else {
substituted = switch_core_strdup(pool, subbed); substituted = switch_core_strdup(pool, subbed);
} }
if (subbed != substituted) {
switch_safe_free(subbed); switch_safe_free(subbed);
}
} }
switch_regex_safe_free(re);
break; break;
} }
} }

View File

@ -815,8 +815,12 @@ sres_record_t ** dig_addr_simple(struct dig *dig,
uint16_t type) uint16_t type)
{ {
sres_record_t **answers = NULL; sres_record_t **answers = NULL;
int error;
sres_blocking_query(dig->sres, type, host, 0, &answers); error = sres_blocking_query(dig->sres, type, host, 0, &answers);
if (error < 0) {
return NULL;
}
return answers; return answers;
} }

View File

@ -1998,7 +1998,7 @@ SWITCH_MODULE_RUNTIME_FUNCTION(mod_erlang_event_runtime)
struct ei_cnode_s ec; struct ei_cnode_s ec;
ErlConnect conn; ErlConnect conn;
int clientfd; int clientfd;
switch_os_socket_t epmdfd; switch_os_socket_t epmdfd = SWITCH_SOCK_INVALID;
switch_socket_t *epmd_sock = NULL; switch_socket_t *epmd_sock = NULL;
if (switch_core_new_memory_pool(&pool) != SWITCH_STATUS_SUCCESS) { if (switch_core_new_memory_pool(&pool) != SWITCH_STATUS_SUCCESS) {

View File

@ -564,13 +564,16 @@ switch_status_t kazoo_config_fetch_handler(kazoo_config_ptr definitions, kazoo_c
switch_memory_pool_t *pool = NULL; switch_memory_pool_t *pool = NULL;
char *name = (char *) switch_xml_attr_soft(cfg, "name"); char *name = (char *) switch_xml_attr_soft(cfg, "name");
if (zstr(name)) { if (zstr(name)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "missing name in profile\n"); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "missing name in profile\n");
return SWITCH_STATUS_GENERR; return SWITCH_STATUS_GENERR;
} }
if (switch_core_new_memory_pool(&pool) != SWITCH_STATUS_SUCCESS) { if (switch_core_new_memory_pool(&pool) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "error allocation pool for new profile : %s\n", name); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "error allocation pool for new profile : %s\n", name);
return SWITCH_STATUS_GENERR; return SWITCH_STATUS_GENERR;
} }
@ -582,6 +585,7 @@ switch_status_t kazoo_config_fetch_handler(kazoo_config_ptr definitions, kazoo_c
fetch_section = switch_xml_parse_section_string(name); fetch_section = switch_xml_parse_section_string(name);
if ((params = switch_xml_child(cfg, "params")) != NULL) { if ((params = switch_xml_child(cfg, "params")) != NULL) {
for (param = switch_xml_child(params, "param"); param; param = param->next) { for (param = switch_xml_child(params, "param"); param; param = param->next) {
char *var = (char *) switch_xml_attr_soft(param, "name"); char *var = (char *) switch_xml_attr_soft(param, "name");
char *val = (char *) switch_xml_attr_soft(param, "value"); char *val = (char *) switch_xml_attr_soft(param, "value");
@ -605,7 +609,9 @@ switch_status_t kazoo_config_fetch_handler(kazoo_config_ptr definitions, kazoo_c
} }
if (fetch_section == SWITCH_XML_SECTION_RESULT) { if (fetch_section == SWITCH_XML_SECTION_RESULT) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Fetch Profile[%s] invalid fetch-section: %s\n", name, switch_xml_toxml(cfg, SWITCH_FALSE)); char *tmp = switch_xml_toxml(cfg, SWITCH_FALSE);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Fetch Profile[%s] invalid fetch-section: %s\n", name, tmp);
free(tmp);
goto err; goto err;
} }
@ -622,17 +628,20 @@ switch_status_t kazoo_config_fetch_handler(kazoo_config_ptr definitions, kazoo_c
} }
} }
if(ptr) if (ptr) {
*ptr = profile; *ptr = profile;
}
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "fetch handler profile %s successfully configured\n", name); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "fetch handler profile %s successfully configured\n", name);
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
err: err:
/* Cleanup */ /* Cleanup */
if(pool) { if(pool) {
switch_core_destroy_memory_pool(&pool); switch_core_destroy_memory_pool(&pool);
} }
return SWITCH_STATUS_GENERR; return SWITCH_STATUS_GENERR;
} }

View File

@ -233,9 +233,11 @@ cJSON * kazoo_event_add_field_to_json(cJSON *dst, switch_event_t *src, kazoo_fie
} else if((header = switch_event_get_header_ptr(src, field->name)) != NULL) { } else if((header = switch_event_get_header_ptr(src, field->name)) != NULL) {
if (header->idx) { if (header->idx) {
item = cJSON_CreateArray(); item = cJSON_CreateArray();
for(i = 0; i < header->idx; i++) { for(i = 0; i < header->idx; i++) {
cJSON_AddItemToArray(item, kazoo_event_json_value(field->out_type, header->array[i])); cJSON_AddItemToArray(item, kazoo_event_json_value(field->out_type, header->array[i]));
} }
kazoo_cJSON_AddItemToObject(dst, field->as ? field->as : field->name, item); kazoo_cJSON_AddItemToObject(dst, field->as ? field->as : field->name, item);
} else if (field->out_type_as_array) { } else if (field->out_type_as_array) {
item = cJSON_CreateArray(); item = cJSON_CreateArray();
@ -251,13 +253,16 @@ cJSON * kazoo_event_add_field_to_json(cJSON *dst, switch_event_t *src, kazoo_fie
expanded = kz_event_expand_headers(src, field->value); expanded = kz_event_expand_headers(src, field->value);
if(expanded != NULL && !zstr(expanded)) { if(expanded != NULL && !zstr(expanded)) {
item = kazoo_event_add_json_value(dst, field, field->as ? field->as : field->name, expanded); item = kazoo_event_add_json_value(dst, field, field->as ? field->as : field->name, expanded);
if(expanded != field->value) {
free(expanded);
}
} }
if (expanded != field->value) {
switch_safe_free(expanded);
}
break; break;
case FIELD_FIRST_OF: case FIELD_FIRST_OF:
for(n = 0; n < field->list.size; n++) { for(n = 0; n < field->list.size; n++) {
if(*field->list.value[n] == '#') { if(*field->list.value[n] == '#') {
item = kazoo_event_add_json_value(dst, field, field->as ? field->as : field->name, ++field->list.value[n]); item = kazoo_event_add_json_value(dst, field, field->as ? field->as : field->name, ++field->list.value[n]);
@ -267,33 +272,41 @@ cJSON * kazoo_event_add_field_to_json(cJSON *dst, switch_event_t *src, kazoo_fie
if(header) { if(header) {
if (header->idx) { if (header->idx) {
item = cJSON_CreateArray(); item = cJSON_CreateArray();
for(i = 0; i < header->idx; i++) { for(i = 0; i < header->idx; i++) {
cJSON_AddItemToArray(item, kazoo_event_json_value(field->out_type, header->array[i])); cJSON_AddItemToArray(item, kazoo_event_json_value(field->out_type, header->array[i]));
} }
kazoo_cJSON_AddItemToObject(dst, field->as ? field->as : field->name, item); kazoo_cJSON_AddItemToObject(dst, field->as ? field->as : field->name, item);
} else { } else {
item = kazoo_event_add_json_value(dst, field, field->as ? field->as : field->name, header->value); item = kazoo_event_add_json_value(dst, field, field->as ? field->as : field->name, header->value);
} }
break; break;
} }
} }
} }
break; break;
case FIELD_PREFIX: case FIELD_PREFIX:
for (header = src->headers; header; header = header->next) { for (header = src->headers; header; header = header->next) {
if(!strncmp(header->name, field->name, strlen(field->name))) { if(!strncmp(header->name, field->name, strlen(field->name))) {
if (header->idx) { if (header->idx) {
cJSON *array = cJSON_CreateArray(); cJSON *array = cJSON_CreateArray();
for(i = 0; i < header->idx; i++) { for(i = 0; i < header->idx; i++) {
cJSON_AddItemToArray(array, kazoo_event_json_value(field->out_type, header->array[i])); cJSON_AddItemToArray(array, kazoo_event_json_value(field->out_type, header->array[i]));
} }
kazoo_cJSON_AddItemToObject(dst, field->exclude_prefix ? header->name+strlen(field->name) : header->name, array); kazoo_cJSON_AddItemToObject(dst, field->exclude_prefix ? header->name+strlen(field->name) : header->name, array);
} else { } else {
kazoo_event_add_json_value(dst, field, field->exclude_prefix ? header->name+strlen(field->name) : header->name, header->value); kazoo_event_add_json_value(dst, field, field->exclude_prefix ? header->name+strlen(field->name) : header->name, header->value);
} }
} }
} }
break; break;
case FIELD_STATIC: case FIELD_STATIC:
@ -308,7 +321,7 @@ cJSON * kazoo_event_add_field_to_json(cJSON *dst, switch_event_t *src, kazoo_fie
break; break;
} }
return item; return item;
} }
static switch_status_t kazoo_event_add_fields_to_json(kazoo_logging_ptr logging, cJSON *dst, switch_event_t *src, kazoo_field_ptr field) { static switch_status_t kazoo_event_add_fields_to_json(kazoo_logging_ptr logging, cJSON *dst, switch_event_t *src, kazoo_field_ptr field) {

View File

@ -1097,23 +1097,27 @@ static switch_status_t handle_request_fetch_reply(ei_node_t *ei_node, erlang_pid
if (ei_decode_atom_safe(buf->buff, &buf->index, section_str) if (ei_decode_atom_safe(buf->buff, &buf->index, section_str)
|| !(section = switch_xml_parse_section_string(section_str))) { || !(section = switch_xml_parse_section_string(section_str))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Ignoring a fetch reply without a configuration section\n"); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Ignoring a fetch reply without a configuration section\n");
return erlang_response_badarg(rbuf); return erlang_response_badarg(rbuf);
} }
if (ei_decode_string_or_binary_limited(buf->buff, &buf->index, sizeof(uuid_str), uuid_str) if (ei_decode_string_or_binary_limited(buf->buff, &buf->index, sizeof(uuid_str), uuid_str)
|| zstr_buf(uuid_str)) { || zstr_buf(uuid_str)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Ignoring a fetch reply without request UUID\n"); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Ignoring a fetch reply without request UUID\n");
return erlang_response_badarg(rbuf); return erlang_response_badarg(rbuf);
} }
if (ei_decode_string_or_binary(buf->buff, &buf->index, &xml_str)) { if (ei_decode_string_or_binary(buf->buff, &buf->index, &xml_str)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Ignoring a fetch reply without XML : %s \n", uuid_str); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Ignoring a fetch reply without XML : %s \n", uuid_str);
return erlang_response_badarg(rbuf); return erlang_response_badarg(rbuf);
} }
if (zstr(xml_str)) { if (zstr(xml_str)) {
switch_safe_free(xml_str); switch_safe_free(xml_str);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Ignoring an empty fetch reply : %s\n", uuid_str); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Ignoring an empty fetch reply : %s\n", uuid_str);
return erlang_response_badarg(rbuf); return erlang_response_badarg(rbuf);
} }
@ -1138,13 +1142,19 @@ static switch_status_t handle_request_fetch_reply(ei_node_t *ei_node, erlang_pid
break; break;
default: default:
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Received fetch reply %s for an unknown configuration section: %s : %s\n", uuid_str, section_str, xml_str); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Received fetch reply %s for an unknown configuration section: %s : %s\n", uuid_str, section_str, xml_str);
switch_safe_free(xml_str);
return erlang_response_badarg(rbuf); return erlang_response_badarg(rbuf);
} }
if (result == SWITCH_STATUS_SUCCESS) { if (result == SWITCH_STATUS_SUCCESS) {
switch_safe_free(xml_str);
return erlang_response_ok(rbuf); return erlang_response_ok(rbuf);
} else { } else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Received fetch reply %s is unknown or has expired : %s\n", uuid_str, xml_str); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Received fetch reply %s is unknown or has expired : %s\n", uuid_str, xml_str);
switch_safe_free(xml_str);
return erlang_response_baduuid(rbuf); return erlang_response_baduuid(rbuf);
} }
} }

View File

@ -166,8 +166,10 @@ static switch_status_t my_on_routing(switch_core_session_t *session)
if (channel) { if (channel) {
const char *disable_flag = switch_channel_get_variable(channel, "disable_radius_start"); const char *disable_flag = switch_channel_get_variable(channel, "disable_radius_start");
if (switch_true(disable_flag)) { if (switch_true(disable_flag)) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "[mod_radius_cdr] Not Sending RADIUS Start\n"); switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "[mod_radius_cdr] Not Sending RADIUS Start\n");
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
} }
} }
@ -250,6 +252,7 @@ static switch_status_t my_on_routing(switch_core_session_t *session)
goto end; goto end;
} }
} }
if (profile->caller_id_number) { if (profile->caller_id_number) {
if (rc_avpair_add(rad_config, &send, PW_FS_SRC, (void *) profile->caller_id_number, -1, PW_FS_PEC) == NULL) { if (rc_avpair_add(rad_config, &send, PW_FS_SRC, (void *) profile->caller_id_number, -1, PW_FS_PEC) == NULL) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "failed adding Freeswitch-Src: %s\n", profile->caller_id_number); switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "failed adding Freeswitch-Src: %s\n", profile->caller_id_number);
@ -257,6 +260,7 @@ static switch_status_t my_on_routing(switch_core_session_t *session)
goto end; goto end;
} }
} }
if (profile->caller_id_name) { if (profile->caller_id_name) {
if (rc_avpair_add(rad_config, &send, PW_FS_CLID, (void *) profile->caller_id_name, -1, PW_FS_PEC) == NULL) { if (rc_avpair_add(rad_config, &send, PW_FS_CLID, (void *) profile->caller_id_name, -1, PW_FS_PEC) == NULL) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "failed adding Freeswitch-CLID: %s\n", profile->caller_id_name); switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "failed adding Freeswitch-CLID: %s\n", profile->caller_id_name);
@ -264,6 +268,7 @@ static switch_status_t my_on_routing(switch_core_session_t *session)
goto end; goto end;
} }
} }
if (profile->destination_number) { if (profile->destination_number) {
if (rc_avpair_add(rad_config, &send, PW_FS_DST, (void *) profile->destination_number, -1, PW_FS_PEC) == NULL) { if (rc_avpair_add(rad_config, &send, PW_FS_DST, (void *) profile->destination_number, -1, PW_FS_PEC) == NULL) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "failed adding Freeswitch-Dst: %s\n", profile->destination_number); switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "failed adding Freeswitch-Dst: %s\n", profile->destination_number);
@ -271,6 +276,7 @@ static switch_status_t my_on_routing(switch_core_session_t *session)
goto end; goto end;
} }
} }
if (profile->dialplan) { if (profile->dialplan) {
if (rc_avpair_add(rad_config, &send, PW_FS_DIALPLAN, (void *) profile->dialplan, -1, PW_FS_PEC) == NULL) { if (rc_avpair_add(rad_config, &send, PW_FS_DIALPLAN, (void *) profile->dialplan, -1, PW_FS_PEC) == NULL) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "failed adding Freeswitch-Dialplan: %s\n", profile->dialplan); switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "failed adding Freeswitch-Dialplan: %s\n", profile->dialplan);
@ -278,6 +284,7 @@ static switch_status_t my_on_routing(switch_core_session_t *session)
goto end; goto end;
} }
} }
if (profile->network_addr) { if (profile->network_addr) {
inet_pton(AF_INET, (void *) profile->network_addr, &framed_addr); inet_pton(AF_INET, (void *) profile->network_addr, &framed_addr);
framed_addr = htonl(framed_addr); framed_addr = htonl(framed_addr);
@ -287,6 +294,7 @@ static switch_status_t my_on_routing(switch_core_session_t *session)
goto end; goto end;
} }
} }
if (profile->rdnis) { if (profile->rdnis) {
if (rc_avpair_add(rad_config, &send, PW_FS_RDNIS, (void *) profile->rdnis, -1, PW_FS_PEC) == NULL) { if (rc_avpair_add(rad_config, &send, PW_FS_RDNIS, (void *) profile->rdnis, -1, PW_FS_PEC) == NULL) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "failed adding Freeswitch-RDNIS: %s\n", profile->rdnis); switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "failed adding Freeswitch-RDNIS: %s\n", profile->rdnis);
@ -294,6 +302,7 @@ static switch_status_t my_on_routing(switch_core_session_t *session)
goto end; goto end;
} }
} }
if (profile->context) { if (profile->context) {
if (rc_avpair_add(rad_config, &send, PW_FS_CONTEXT, (void *) profile->context, -1, PW_FS_PEC) == NULL) { if (rc_avpair_add(rad_config, &send, PW_FS_CONTEXT, (void *) profile->context, -1, PW_FS_PEC) == NULL) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "failed adding Freeswitch-Context: %s\n", profile->context); switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "failed adding Freeswitch-Context: %s\n", profile->context);
@ -301,6 +310,7 @@ static switch_status_t my_on_routing(switch_core_session_t *session)
goto end; goto end;
} }
} }
if (profile->ani) { if (profile->ani) {
if (rc_avpair_add(rad_config, &send, PW_FS_ANI, (void *) profile->ani, -1, PW_FS_PEC) == NULL) { if (rc_avpair_add(rad_config, &send, PW_FS_ANI, (void *) profile->ani, -1, PW_FS_PEC) == NULL) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "failed adding Freeswitch-ANI: %s\n", profile->ani); switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "failed adding Freeswitch-ANI: %s\n", profile->ani);
@ -308,6 +318,7 @@ static switch_status_t my_on_routing(switch_core_session_t *session)
goto end; goto end;
} }
} }
if (profile->aniii) { if (profile->aniii) {
if (rc_avpair_add(rad_config, &send, PW_FS_ANIII, (void *) profile->aniii, -1, PW_FS_PEC) == NULL) { if (rc_avpair_add(rad_config, &send, PW_FS_ANIII, (void *) profile->aniii, -1, PW_FS_PEC) == NULL) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "failed adding Freeswitch-ANIII: %s\n", profile->aniii); switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "failed adding Freeswitch-ANIII: %s\n", profile->aniii);
@ -315,6 +326,7 @@ static switch_status_t my_on_routing(switch_core_session_t *session)
goto end; goto end;
} }
} }
if (profile->source) { if (profile->source) {
if (rc_avpair_add(rad_config, &send, PW_FS_SOURCE, (void *) profile->source, -1, PW_FS_PEC) == NULL) { if (rc_avpair_add(rad_config, &send, PW_FS_SOURCE, (void *) profile->source, -1, PW_FS_PEC) == NULL) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "failed adding Freeswitch-Source: %s\n", profile->source); switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "failed adding Freeswitch-Source: %s\n", profile->source);
@ -322,6 +334,7 @@ static switch_status_t my_on_routing(switch_core_session_t *session)
goto end; goto end;
} }
} }
if (callstartdate > 0) { if (callstartdate > 0) {
switch_time_exp_tz(&tm, callstartdate, requested_tm.tm_gmtoff); switch_time_exp_tz(&tm, callstartdate, requested_tm.tm_gmtoff);
switch_snprintf(buffer, sizeof(buffer), "%04u-%02u-%02uT%02u:%02u:%02u.%06u%+03d%02d", switch_snprintf(buffer, sizeof(buffer), "%04u-%02u-%02uT%02u:%02u:%02u.%06u%+03d%02d",
@ -380,25 +393,33 @@ static switch_status_t my_on_routing(switch_core_session_t *session)
} }
if (radius_avpair) { if (radius_avpair) {
char *radius_avpair_data_tmp = NULL;
radius_avpair_data = strdup(radius_avpair + (strncmp(radius_avpair, "ARRAY::", 7) ? 0 : 7)); radius_avpair_data = strdup(radius_avpair + (strncmp(radius_avpair, "ARRAY::", 7) ? 0 : 7));
radius_avpair_data_tmp = radius_avpair_data;
do { do {
delim = strstr(radius_avpair_data, "|:"); delim = strstr(radius_avpair_data_tmp, "|:");
if (delim) { if (delim) {
*delim = '\0'; *delim = '\0';
} }
if (rc_avpair_add(rad_config, &send, PW_FS_AVPAIR, (void *) radius_avpair_data, -1, PW_FS_PEC) == NULL) { if (rc_avpair_add(rad_config, &send, PW_FS_AVPAIR, (void *)radius_avpair_data_tmp, -1, PW_FS_PEC) == NULL) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "failed adding Freeswitch-AVPair: %s\n", radius_avpair_data); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "failed adding Freeswitch-AVPair: %s\n", radius_avpair_data_tmp);
rc_destroy(rad_config); rc_destroy(rad_config);
switch_safe_free(radius_avpair_data);
goto end; goto end;
} }
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "added Freeswitch-AVPair: %s\n", radius_avpair_data);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "added Freeswitch-AVPair: %s\n", radius_avpair_data_tmp);
if (delim) { if (delim) {
radius_avpair_data = delim + 2; radius_avpair_data_tmp = delim + 2;
} }
} while (delim); } while (delim);
switch_safe_free(radius_avpair_data);
} }
} else { } else {
@ -413,11 +434,13 @@ static switch_status_t my_on_routing(switch_core_session_t *session)
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "[mod_radius_cdr] RADIUS Accounting Failed\n"); switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "[mod_radius_cdr] RADIUS Accounting Failed\n");
retval = SWITCH_STATUS_TERM; retval = SWITCH_STATUS_TERM;
} }
rc_avpair_free(send); rc_avpair_free(send);
rc_destroy(rad_config); rc_destroy(rad_config);
end: end:
switch_xml_free(cdr); switch_xml_free(cdr);
switch_thread_rwlock_unlock(globals.rwlock); switch_thread_rwlock_unlock(globals.rwlock);
return (retval); return (retval);
} }

View File

@ -4765,7 +4765,7 @@ static void send_console_command(struct rayo_client *client, const char *to, con
iks *command = NULL; iks *command = NULL;
iksparser *p = iks_dom_new(&command); iksparser *p = iks_dom_new(&command);
if (iks_parse(p, command_str, 0, 1) == IKS_OK && command) { if (p && iks_parse(p, command_str, 0, 1) == IKS_OK && command) {
char *str; char *str;
iks *iq = NULL; iks *iq = NULL;
@ -4784,9 +4784,11 @@ static void send_console_command(struct rayo_client *client, const char *to, con
if (!iks_find_attrib(iq, "type")) { if (!iks_find_attrib(iq, "type")) {
iks_insert_attrib(iq, "type", "set"); iks_insert_attrib(iq, "type", "set");
} }
if (!iks_find_attrib(iq, "id")) { if (!iks_find_attrib(iq, "id")) {
iks_insert_attrib_printf(iq, "id", "console-%i", RAYO_SEQ_NEXT(client)); iks_insert_attrib_printf(iq, "id", "console-%i", RAYO_SEQ_NEXT(client));
} }
iks_insert_attrib(iq, "from", RAYO_JID(client)); iks_insert_attrib(iq, "from", RAYO_JID(client));
/* send command */ /* send command */
@ -4794,10 +4796,13 @@ static void send_console_command(struct rayo_client *client, const char *to, con
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "\nSEND: to %s, %s\n", to, str); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "\nSEND: to %s, %s\n", to, str);
rayo_client_command_recv(client, iq); rayo_client_command_recv(client, iq);
iks_delete(command); iks_delete(command);
iks_parser_delete(p);
} else { } else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "bad request xml\n"); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "bad request xml\n");
if (p) {
iks_parser_delete(p);
}
} }
iks_parser_delete(p);
} }
/** /**

View File

@ -654,6 +654,7 @@ static switch_status_t switch_opusstream_stream_decode(opus_stream_context_t *co
} }
switch_goto_status(SWITCH_STATUS_SUCCESS, end); switch_goto_status(SWITCH_STATUS_SUCCESS, end);
} }
break;
case OP_EREAD: /*An underlying read operation failed. This may signal a truncation attack from an <https:> source.*/ case OP_EREAD: /*An underlying read operation failed. This may signal a truncation attack from an <https:> source.*/
case OP_EFAULT: /* An internal memory allocation failed. */ case OP_EFAULT: /* An internal memory allocation failed. */

View File

@ -189,107 +189,108 @@ SWITCH_STANDARD_APP(java_function)
static switch_status_t load_config(JavaVMOption **javaOptions, int *optionCount, vm_control_t * vmControl) static switch_status_t load_config(JavaVMOption **javaOptions, int *optionCount, vm_control_t * vmControl)
{ {
switch_xml_t cfg, xml; switch_xml_t cfg, xml;
switch_status_t status = SWITCH_STATUS_SUCCESS; switch_status_t status = SWITCH_STATUS_SUCCESS;
char *derr = NULL; char *derr = NULL;
xml = switch_xml_open_cfg("java.conf", &cfg, NULL); xml = switch_xml_open_cfg("java.conf", &cfg, NULL);
if (xml) if (xml) {
{ switch_xml_t javavm;
switch_xml_t javavm; switch_xml_t options;
switch_xml_t options; switch_xml_t startup;
switch_xml_t startup; switch_xml_t shutdown;
switch_xml_t shutdown;
javavm = switch_xml_child(cfg, "javavm"); javavm = switch_xml_child(cfg, "javavm");
if (javavm != NULL) if (javavm != NULL) {
{ const char *path = switch_xml_attr_soft(javavm, "path");
const char *path = switch_xml_attr_soft(javavm, "path");
if (path != NULL) if (path != NULL) {
{
javaVMHandle = switch_dso_open(path, 0, &derr); javaVMHandle = switch_dso_open(path, 0, &derr);
if (derr || !javaVMHandle) { if (derr || !javaVMHandle) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error loading %s\n", path); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error loading %s\n", path);
switch_safe_free(derr);
} }
} } else {
else switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No Java VM path specified in java.conf.xml\n");
{ status = SWITCH_STATUS_FALSE;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No Java VM path specified in java.conf.xml\n"); }
status = SWITCH_STATUS_FALSE; } else {
} switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No Java VM specified in java.conf.xml\n");
} status = SWITCH_STATUS_FALSE;
else goto close;
{ }
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No Java VM specified in java.conf.xml\n");
status = SWITCH_STATUS_FALSE; options = switch_xml_child(cfg, "options");
goto close; if (options != NULL) {
} switch_xml_t option;
int i = 0;
*optionCount = 0;
for (option = switch_xml_child(options, "option"); option; option = option->next) {
const char *value = switch_xml_attr_soft(option, "value");
if (value != NULL) {
++*optionCount;
}
}
*optionCount += 1;
*javaOptions = switch_core_alloc(memoryPool, (switch_size_t)(*optionCount * sizeof(JavaVMOption)));
if (*javaOptions == NULL) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Out of memory!\n");
status = SWITCH_STATUS_FALSE;
goto close;
}
for (option = switch_xml_child(options, "option"); option; option = option->next) {
const char *value = switch_xml_attr_soft(option, "value");
if (value == NULL) {
continue;
}
(*javaOptions)[i].optionString = switch_core_strdup(memoryPool, value);
if ((*javaOptions)[i].optionString == NULL) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Out of memory!\n");
status = SWITCH_STATUS_FALSE;
goto close;
}
++i;
}
options = switch_xml_child(cfg, "options");
if (options != NULL)
{
switch_xml_t option;
int i = 0;
*optionCount = 0;
for (option = switch_xml_child(options, "option"); option; option = option->next)
{
const char *value = switch_xml_attr_soft(option, "value");
if (value != NULL)
++*optionCount;
}
*optionCount += 1;
*javaOptions = switch_core_alloc(memoryPool, (switch_size_t)(*optionCount * sizeof(JavaVMOption)));
if (*javaOptions == NULL)
{
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Out of memory!\n");
status = SWITCH_STATUS_FALSE;
goto close;
}
for (option = switch_xml_child(options, "option"); option; option = option->next)
{
const char *value = switch_xml_attr_soft(option, "value");
if (value == NULL)
continue;
(*javaOptions)[i].optionString = switch_core_strdup(memoryPool, value);
if ((*javaOptions)[i].optionString == NULL)
{
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Out of memory!\n");
status = SWITCH_STATUS_FALSE;
goto close;
}
++i;
}
(*javaOptions)[i].optionString = switch_core_sprintf(memoryPool, "-Djava.library.path=%s", SWITCH_GLOBAL_dirs.mod_dir); (*javaOptions)[i].optionString = switch_core_sprintf(memoryPool, "-Djava.library.path=%s", SWITCH_GLOBAL_dirs.mod_dir);
} }
/* /*
<startup class="net/cog/fs/system/Control" method="startup" arg="start up arg"/> <startup class="net/cog/fs/system/Control" method="startup" arg="start up arg"/>
<shutdown class="net/cog/fs/system/Control" method="shutdown" arg="shutdown arg"/> <shutdown class="net/cog/fs/system/Control" method="shutdown" arg="shutdown arg"/>
*/ */
memset(vmControl, 0, sizeof(struct vm_control)); memset(vmControl, 0, sizeof(struct vm_control));
startup = switch_xml_child(cfg, "startup"); startup = switch_xml_child(cfg, "startup");
if (startup != NULL) { if (startup != NULL) {
vmControl->startup.class = switch_xml_attr_soft(startup, "class"); vmControl->startup.class = switch_xml_attr_soft(startup, "class");
vmControl->startup.method = switch_xml_attr_soft(startup, "method"); vmControl->startup.method = switch_xml_attr_soft(startup, "method");
vmControl->startup.arg = switch_xml_attr_soft(startup, "arg"); vmControl->startup.arg = switch_xml_attr_soft(startup, "arg");
} }
shutdown = switch_xml_child(cfg, "shutdown");
if (shutdown != NULL) {
vmControl->shutdown.class = switch_xml_attr_soft(shutdown, "class");
vmControl->shutdown.method = switch_xml_attr_soft(shutdown, "method");
vmControl->shutdown.arg = switch_xml_attr_soft(shutdown, "arg");
}
close: shutdown = switch_xml_child(cfg, "shutdown");
switch_xml_free(xml); if (shutdown != NULL) {
} vmControl->shutdown.class = switch_xml_attr_soft(shutdown, "class");
else vmControl->shutdown.method = switch_xml_attr_soft(shutdown, "method");
{ vmControl->shutdown.arg = switch_xml_attr_soft(shutdown, "arg");
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error opening java.conf.xml\n"); }
status = SWITCH_STATUS_FALSE;
} close:
return status; switch_xml_free(xml);
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error opening java.conf.xml\n");
status = SWITCH_STATUS_FALSE;
}
return status;
} }
static switch_status_t create_java_vm(JavaVMOption *options, int optionCount, vm_control_t * vmControl) static switch_status_t create_java_vm(JavaVMOption *options, int optionCount, vm_control_t * vmControl)

View File

@ -169,6 +169,7 @@ JS_GLOBAL_FUNCTION_IMPL_STATIC(FetchURLHash)
} else { } else {
/* The var exists, but is wrong type - exit with error */ /* The var exists, but is wrong type - exit with error */
info.GetIsolate()->ThrowException(String::NewFromUtf8(info.GetIsolate(), "Second argument is the name of an existing var of the wrong type")); info.GetIsolate()->ThrowException(String::NewFromUtf8(info.GetIsolate(), "Second argument is the name of an existing var of the wrong type"));
return; return;
} }
} else if (info.Length() > 1 && info[1]->IsArray()) { } else if (info.Length() > 1 && info[1]->IsArray()) {
@ -177,6 +178,7 @@ JS_GLOBAL_FUNCTION_IMPL_STATIC(FetchURLHash)
} else if (info.Length() > 1) { } else if (info.Length() > 1) {
/* The var exists, but is wrong type - exit with error */ /* The var exists, but is wrong type - exit with error */
info.GetIsolate()->ThrowException(String::NewFromUtf8(info.GetIsolate(), "Second argument is of the wrong type")); info.GetIsolate()->ThrowException(String::NewFromUtf8(info.GetIsolate(), "Second argument is of the wrong type"));
return; return;
} else { } else {
/* Second argument doesn't exist, this is also ok. The hash will be returned as the result */ /* Second argument doesn't exist, this is also ok. The hash will be returned as the result */
@ -185,6 +187,11 @@ JS_GLOBAL_FUNCTION_IMPL_STATIC(FetchURLHash)
} }
curl_handle = switch_curl_easy_init(); curl_handle = switch_curl_easy_init();
if (!curl_handle) {
info.GetIsolate()->ThrowException(String::NewFromUtf8(info.GetIsolate(), "Failed to initiate curl easy session."));
return;
}
if (!strncasecmp(js_safe_str(*url), "https", 5)) { if (!strncasecmp(js_safe_str(*url), "https", 5)) {
switch_curl_easy_setopt(curl_handle, CURLOPT_SSL_VERIFYPEER, 0); switch_curl_easy_setopt(curl_handle, CURLOPT_SSL_VERIFYPEER, 0);
@ -224,14 +231,22 @@ JS_GLOBAL_FUNCTION_IMPL_STATIC(FetchURLFile)
const char *url = NULL, *filename = NULL; const char *url = NULL, *filename = NULL;
String::Utf8Value str1(info[0]); String::Utf8Value str1(info[0]);
String::Utf8Value str2(info[1]); String::Utf8Value str2(info[1]);
url = js_safe_str(*str1); url = js_safe_str(*str1);
filename = js_safe_str(*str2); filename = js_safe_str(*str2);
curl_handle = switch_curl_easy_init(); curl_handle = switch_curl_easy_init();
if (!curl_handle) {
info.GetIsolate()->ThrowException(String::NewFromUtf8(info.GetIsolate(), "Failed to initiate curl easy session."));
return;
}
if (!strncasecmp(url, "https", 5)) { if (!strncasecmp(url, "https", 5)) {
switch_curl_easy_setopt(curl_handle, CURLOPT_SSL_VERIFYPEER, 0); switch_curl_easy_setopt(curl_handle, CURLOPT_SSL_VERIFYPEER, 0);
switch_curl_easy_setopt(curl_handle, CURLOPT_SSL_VERIFYHOST, 0); switch_curl_easy_setopt(curl_handle, CURLOPT_SSL_VERIFYHOST, 0);
} }
config_data.isolate = info.GetIsolate(); config_data.isolate = info.GetIsolate();
if ((config_data.fileHandle = open(filename, O_CREAT | O_RDWR | O_TRUNC, S_IRUSR | S_IWUSR)) > -1) { if ((config_data.fileHandle = open(filename, O_CREAT | O_RDWR | O_TRUNC, S_IRUSR | S_IWUSR)) > -1) {
@ -245,13 +260,14 @@ JS_GLOBAL_FUNCTION_IMPL_STATIC(FetchURLFile)
switch_curl_easy_perform(curl_handle); switch_curl_easy_perform(curl_handle);
switch_curl_easy_cleanup(curl_handle);
close(config_data.fileHandle); close(config_data.fileHandle);
info.GetReturnValue().Set(true); info.GetReturnValue().Set(true);
} else { } else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to open file [%s]\n", filename); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to open file [%s]\n", filename);
info.GetReturnValue().Set(false); info.GetReturnValue().Set(false);
} }
switch_curl_easy_cleanup(curl_handle);
} else { } else {
info.GetIsolate()->ThrowException(String::NewFromUtf8(info.GetIsolate(), "Invalid arguments")); info.GetIsolate()->ThrowException(String::NewFromUtf8(info.GetIsolate(), "Invalid arguments"));
} }
@ -270,12 +286,19 @@ JS_GLOBAL_FUNCTION_IMPL_STATIC(FetchURL)
if (info.Length() >= 1) { if (info.Length() >= 1) {
const char *url; const char *url;
String::Utf8Value str(info[0]); String::Utf8Value str(info[0]);
url = js_safe_str(*str); url = js_safe_str(*str);
if (info.Length() > 1) { if (info.Length() > 1) {
buffer_size = info[1]->Int32Value(); buffer_size = info[1]->Int32Value();
} }
curl_handle = switch_curl_easy_init(); curl_handle = switch_curl_easy_init();
if (!curl_handle) {
info.GetIsolate()->ThrowException(String::NewFromUtf8(info.GetIsolate(), "Failed to initiate curl easy session."));
return;
}
if (!strncasecmp(url, "https", 5)) { if (!strncasecmp(url, "https", 5)) {
switch_curl_easy_setopt(curl_handle, CURLOPT_SSL_VERIFYPEER, 0); switch_curl_easy_setopt(curl_handle, CURLOPT_SSL_VERIFYPEER, 0);
switch_curl_easy_setopt(curl_handle, CURLOPT_SSL_VERIFYHOST, 0); switch_curl_easy_setopt(curl_handle, CURLOPT_SSL_VERIFYHOST, 0);
@ -289,6 +312,7 @@ JS_GLOBAL_FUNCTION_IMPL_STATIC(FetchURL)
if (config_data.buffer == NULL) { if (config_data.buffer == NULL) {
info.GetIsolate()->ThrowException(String::NewFromUtf8(info.GetIsolate(), "Failed to allocate data buffer.")); info.GetIsolate()->ThrowException(String::NewFromUtf8(info.GetIsolate(), "Failed to allocate data buffer."));
switch_curl_easy_cleanup(curl_handle); switch_curl_easy_cleanup(curl_handle);
return; return;
} }

View File

@ -147,7 +147,7 @@ static void check_ip(void)
} else if (strcmp(hostname, runtime.hostname)) { } else if (strcmp(hostname, runtime.hostname)) {
if (switch_event_create(&event, SWITCH_EVENT_TRAP) == SWITCH_STATUS_SUCCESS) { if (switch_event_create(&event, SWITCH_EVENT_TRAP) == SWITCH_STATUS_SUCCESS) {
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "condition", "hostname-change"); switch_event_add_header(event, SWITCH_STACK_BOTTOM, "condition", "hostname-change");
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "old-hostname", hostname ? hostname : "nil"); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "old-hostname", hostname);
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "new-hostname", runtime.hostname); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "new-hostname", runtime.hostname);
switch_event_fire(&event); switch_event_fire(&event);
} }

View File

@ -160,8 +160,6 @@ SWITCH_DECLARE(switch_status_t) switch_packetizer_feed_extradata(switch_packetiz
p += 5; p += 5;
left -= 5; left -= 5;
if (left < 0) return SWITCH_STATUS_FALSE;
//sps //sps
n_sps = *p & 0x1f; n_sps = *p & 0x1f;
p += 1; p += 1;

View File

@ -1353,7 +1353,6 @@ SWITCH_DECLARE(void) switch_srtp_err_to_txt(srtp_err_status_t stat, char **msg)
else if (stat == srtp_err_status_read_fail) *msg="couldn't read data"; else if (stat == srtp_err_status_read_fail) *msg="couldn't read data";
else if (stat == srtp_err_status_write_fail) *msg="couldn't write data"; else if (stat == srtp_err_status_write_fail) *msg="couldn't write data";
else if (stat == srtp_err_status_parse_err) *msg="error parsing data"; else if (stat == srtp_err_status_parse_err) *msg="error parsing data";
else if (stat == srtp_err_status_write_fail) *msg="couldn't read data";
else if (stat == srtp_err_status_encode_err) *msg="error encoding data"; else if (stat == srtp_err_status_encode_err) *msg="error encoding data";
else if (stat == srtp_err_status_semaphore_err) *msg="error while using semaphores"; else if (stat == srtp_err_status_semaphore_err) *msg="error while using semaphores";
else if (stat == srtp_err_status_pfkey_err) *msg="error while using pfkey "; else if (stat == srtp_err_status_pfkey_err) *msg="error while using pfkey ";
@ -4947,7 +4946,7 @@ SWITCH_DECLARE(void) switch_rtp_kill_socket(switch_rtp_t *rtp_session)
} }
if (rtp_session->flags[SWITCH_RTP_FLAG_ENABLE_RTCP]) { if (rtp_session->flags[SWITCH_RTP_FLAG_ENABLE_RTCP]) {
if (rtp_session->rtcp_sock_input && rtp_session->rtcp_sock_input != rtp_session->sock_input) { if (rtp_session->sock_input && rtp_session->rtcp_sock_input && rtp_session->rtcp_sock_input != rtp_session->sock_input) {
ping_socket(rtp_session); ping_socket(rtp_session);
switch_socket_shutdown(rtp_session->rtcp_sock_input, SWITCH_SHUTDOWN_READWRITE); switch_socket_shutdown(rtp_session->rtcp_sock_input, SWITCH_SHUTDOWN_READWRITE);
} }