[mod_json_cdr] add timeout param.

This commit is contained in:
Hailin Zhou 2022-01-27 21:28:09 +08:00 committed by GitHub
parent 6113db7bd7
commit d249fb8017
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 1 deletions

View File

@ -23,6 +23,8 @@
<!-- HTTP(S) logging --> <!-- HTTP(S) logging -->
<!-- URL where to POST JSON CDRs. Leave empty for no URL logging. Up to 20 URLs may be specified. --> <!-- URL where to POST JSON CDRs. Leave empty for no URL logging. Up to 20 URLs may be specified. -->
<param name="url" value=""/> <param name="url" value=""/>
<!-- optional timeout : second -->
<param name="timeout" value="5"/>
<!-- Authentication scheme for the above URL. May be one of basic|digest|NTLM|GSS-NEGOTIATE|any--> <!-- Authentication scheme for the above URL. May be one of basic|digest|NTLM|GSS-NEGOTIATE|any-->
<param name="auth-scheme" value="basic"/> <param name="auth-scheme" value="basic"/>
<!-- Credentials in the form username:password if auth-scheme is used. Leave empty for no authentication. --> <!-- Credentials in the form username:password if auth-scheme is used. Leave empty for no authentication. -->

View File

@ -70,6 +70,7 @@ static struct {
int disable100continue; int disable100continue;
int rotate; int rotate;
long auth_scheme; long auth_scheme;
int timeout;
switch_memory_pool_t *pool; switch_memory_pool_t *pool;
switch_event_node_t *node; switch_event_node_t *node;
int encode_values; int encode_values;
@ -361,8 +362,10 @@ static void process_cdr(cdr_data_t *data)
switch_curl_easy_setopt(curl_handle, CURLOPT_CAINFO, globals.ssl_cacert_file); switch_curl_easy_setopt(curl_handle, CURLOPT_CAINFO, globals.ssl_cacert_file);
} }
// tcp timeout
switch_curl_easy_setopt(curl_handle, CURLOPT_TIMEOUT, globals.timeout);
/* these were used for testing, optionally they may be enabled if someone desires /* these were used for testing, optionally they may be enabled if someone desires
switch_curl_easy_setopt(curl_handle, CURLOPT_TIMEOUT, 120); // tcp timeout
switch_curl_easy_setopt(curl_handle, CURLOPT_FOLLOWLOCATION, 1); // 302 recursion level switch_curl_easy_setopt(curl_handle, CURLOPT_FOLLOWLOCATION, 1); // 302 recursion level
*/ */
@ -607,6 +610,14 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_json_cdr_load)
globals.log_http_and_disk = switch_true(val); globals.log_http_and_disk = switch_true(val);
} else if (!strcasecmp(var, "log-errors-to-disk")) { } else if (!strcasecmp(var, "log-errors-to-disk")) {
globals.log_errors_to_disk = !switch_false(val); globals.log_errors_to_disk = !switch_false(val);
} else if (!strcasecmp(var, "timeout")) {
int tmp = atoi(val);
if (tmp >= 0) {
globals.timeout = tmp;
} else {
globals.timeout = 0;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't set a negative timeout!\n");
}
} else if (!strcasecmp(var, "delay") && !zstr(val)) { } else if (!strcasecmp(var, "delay") && !zstr(val)) {
globals.delay = (uint32_t) atoi(val); globals.delay = (uint32_t) atoi(val);
} else if (!strcasecmp(var, "log-b-leg")) { } else if (!strcasecmp(var, "log-b-leg")) {