Skip to content

Commit

Permalink
ruxc: added modparams to set libruxc logtype and debug
Browse files Browse the repository at this point in the history
  • Loading branch information
miconda committed Aug 20, 2021
1 parent 31377b1 commit ec3f963
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 0 deletions.
39 changes: 39 additions & 0 deletions src/modules/ruxc/doc/ruxc_admin.xml
Expand Up @@ -140,6 +140,45 @@ modparam("ruxc", "http_reuse", 1)
...
modparam("ruxc", "http_retry", 2)
...
</programlisting>
</example>
</section>
<section id="ruxc.p.http_logtype">
<title><varname>http_logtype</varname> (int)</title>
<para>
Set the log type for libruxc http functions: 0 - stdout; 1 - syslog.
</para>
<para>
<emphasis>
Default value is 0.
</emphasis>
</para>
<example>
<title>Set <varname>http_logtype</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("ruxc", "http_logtype", 1)
...
</programlisting>
</example>
</section>
<section id="ruxc.p.http_debug">
<title><varname>http_debug</varname> (int)</title>
<para>
Set the debug mode for libruxc http functions: 0 - no debug; 1 - errors;
2 - debug.
</para>
<para>
<emphasis>
Default value is 0.
</emphasis>
</para>
<example>
<title>Set <varname>http_debug</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("ruxc", "http_debug", 1)
...
</programlisting>
</example>
</section>
Expand Down
15 changes: 15 additions & 0 deletions src/modules/ruxc/ruxc_mod.c
Expand Up @@ -42,6 +42,8 @@ static int _ruxc_http_timeout = 5000;
static int _ruxc_http_tlsmode = 0;
static int _ruxc_http_reuse = 0;
static int _ruxc_http_retry = 0;
static int _ruxc_http_logtype = 0;
static int _ruxc_http_debug = 0;

static int mod_init(void);
static int child_init(int);
Expand Down Expand Up @@ -77,6 +79,8 @@ static param_export_t params[]={
{"http_tlsmode", PARAM_INT, &_ruxc_http_tlsmode},
{"http_reuse", PARAM_INT, &_ruxc_http_reuse},
{"http_retry", PARAM_INT, &_ruxc_http_retry},
{"http_logtype", PARAM_INT, &_ruxc_http_logtype},
{"http_debug", PARAM_INT, &_ruxc_http_debug},

{0, 0, 0}
};
Expand All @@ -101,6 +105,13 @@ struct module_exports exports = {
*/
static int mod_init(void)
{
if(_ruxc_http_logtype==1 && log_stderr==1) {
LM_INFO("setting http logtype to 0\n");
_ruxc_http_logtype = 0;
} else if(_ruxc_http_logtype==0 && log_stderr==0) {
LM_INFO("setting http logtype to 1\n");
_ruxc_http_logtype = 1;
}
return 0;
}

Expand Down Expand Up @@ -138,6 +149,8 @@ static int ki_ruxc_http_get_helper(sip_msg_t *_msg, str *url, str *hdrs,
v_http_request.tlsmode = _ruxc_http_tlsmode;
v_http_request.reuse = _ruxc_http_reuse;
v_http_request.retry = _ruxc_http_retry;
v_http_request.logtype = _ruxc_http_logtype;
v_http_request.debug = _ruxc_http_debug;

v_http_request.url = url->s;
v_http_request.url_len = url->len;
Expand Down Expand Up @@ -237,6 +250,8 @@ static int ki_ruxc_http_post_helper(sip_msg_t *_msg, str *url, str *body, str *h
v_http_request.tlsmode = _ruxc_http_tlsmode;
v_http_request.reuse = _ruxc_http_reuse;
v_http_request.retry = _ruxc_http_retry;
v_http_request.logtype = _ruxc_http_logtype;
v_http_request.debug = _ruxc_http_debug;

v_http_request.url = url->s;
v_http_request.url_len = url->len;
Expand Down

0 comments on commit ec3f963

Please sign in to comment.