### Description
We have some JS code looping over all P-Asserted-Identity headers removing some of the entries:
```
let headerIndex = 0;
const telUriMatcher = new RegExp("tel:");
let paiValue = ksr.pv
.gete("$(hdr(P-Asserted-Identity)[" + headerIndex + "])")
.toString();
while (paiValue.length > 0) {
ksr.info(
`${ksr.pv.getw("$ci")}: Found P-A-I header with content <${ksr.pv.getw(
"$(hdr(P-Asserted-Identity)[" + headerIndex + "])"
)}> at index ${headerIndex}\n`
);
if (telUriMatcher.test(paiValue)) {
ksr.info(
`${ksr.pv.getw("$ci")}: Removed P-A-I header ${ksr.pv.getw(
"$(hdr(P-Asserted-Identity)[" + headerIndex + "])"
)}\n`
);
ksr.textopsx.remove_hf_value(
"P-Asserted-Identity[" + headerIndex + "]"
);
}
headerIndex++;
paiValue = ksr.pv
.gete("$(hdr(P-Asserted-Identity)[" + headerIndex + "])")
.toString();
}
```
In our tests, we wanted to remove the second header, but the first one got removed instead. The pseudovars docs say, the index of a header is 0-based. In textopsx docs it doesn't explicitly say, it's 1-based, but the first example shows it actually is.
### Possible Solutions
Right now, we replaced the line
```
ksr.textopsx.remove_hf_value("P-Asserted-Identity[" + headerIndex + "]");
```
with this one:
```
ksr.textopsx.remove_hf_value("P-Asserted-Identity[" + (headerIndex + 1) + "]");
```
This solves the problem, but it is not what we would expect. Both header access methods should use the same index base.
### Additional Information
* **Kamailio Version** - output of `kamailio -v`
```
version: kamailio 5.3.5 (x86_64/linux)
flags: USE_TCP, USE_TLS, USE_SCTP, TLS_HOOKS, USE_RAW_SOCKS, DISABLE_NAGLE, USE_MCAST, DNS_IP_HACK, SHM_MMAP, PKG_MALLOC, Q_MALLOC, F_MALLOC, TLSF_MALLOC, DBG_SR_MEMORY, USE_FUTEX, FAST_LOCK-ADAPTIVE_WAIT, USE_DNS_CACHE, USE_DNS_FAILOVER, USE_NAPTR, USE_DST_BLACKLIST, HAVE_RESOLV_RES, TLS_PTHREAD_MUTEX_SHARED
ADAPTIVE_WAIT_LOOPS 1024, MAX_RECV_BUFFER_SIZE 262144, MAX_URI_SIZE 1024, BUF_SIZE 65535, DEFAULT PKG_SIZE 8MB
poll method support: poll, epoll_lt, epoll_et, sigio_rt, select.
id: unknown
compiled with gcc 8.3.0
```
* **Operating System**:
<!--
Details about the operating system, the type: Linux (e.g.,: Debian 8.4, Ubuntu 16.04, CentOS 7.1, ...), MacOS, xBSD, Solaris, ...;
Kernel details (output of `uname -a`)
-->
```
Linux hostname 4.19.0-9-amd64 #1 SMP Debian 4.19.118-2+deb10u1 (2020-06-07) x86_64 GNU/Linux
```
--
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/kamailio/kamailio/issues/2387
Module: kamailio
Branch: master
Commit: ac60e5d0a9f847fe77458d733d6ca67c9352978d
URL: https://github.com/kamailio/kamailio/commit/ac60e5d0a9f847fe77458d733d6ca67…
Author: Kamailio Dev <kamailio.dev(a)kamailio.org>
Committer: Kamailio Dev <kamailio.dev(a)kamailio.org>
Date: 2021-03-31T16:16:15+02:00
modules: readme files regenerated - textopsx ... [skip ci]
---
Modified: src/modules/textopsx/README
---
Diff: https://github.com/kamailio/kamailio/commit/ac60e5d0a9f847fe77458d733d6ca67…
Patch: https://github.com/kamailio/kamailio/commit/ac60e5d0a9f847fe77458d733d6ca67…
---
diff --git a/src/modules/textopsx/README b/src/modules/textopsx/README
index 772461ae54..dbb27653a0 100644
--- a/src/modules/textopsx/README
+++ b/src/modules/textopsx/README
@@ -246,7 +246,7 @@ if(fnmatch("$rU", "123*"))
Meaning of the parameters is as follows:
* hf - Header field to be appended. Format: HFNAME [ [IDX] ]. If
index is not specified new header is inserted at the end of
- message.
+ message. The index 1 correxponds to the first header.
* hvalue - Value to be added, config var formatting supported.
Example 1.7. append_hf_value usage
@@ -267,7 +267,7 @@ ot exists add new header
Meaning of the parameters is as follows:
* hf - Header field to be appended. Format: HFNAME [ [IDX] ]. If
index is not specified new header is inserted at the top of
- message.
+ message. The index 1 correxponds to the first header.
* hvalue - Value to be added, config var formatting supported.
Example 1.8. insert_hf_value usage
@@ -285,7 +285,7 @@ insert_hf_value("foo[1]", "gogo") # try add to the first header
Meaning of the parameters is as follows:
* hf_par - Header field/param to be removed. Format: HFNAME [ [IDX] ]
[. PARAM ] If asterisk is specified as index then all values are
- affected.
+ affected. The index 1 correxponds to the first header.
Example 1.9. remove_hf_value usage
...
@@ -305,7 +305,7 @@ remove_hf_value("foo[*].bar") # for each foo delete bar parameters
Meaning of the parameters is as follows:
* hf_par - Header/param to be removed. Format: HFNAME [ [IDX] ] [.
PARAM ] If asterisk is specified as index then all values are
- affected.
+ affected. The index 1 correxponds to the first header.
Example 1.10. remove_hf_value2 usage
...
@@ -324,7 +324,7 @@ remove_hf_value2("foo[*].bar") # for each foo delete bar parameters
Meaning of the parameters is as follows:
* hf_para - Header field value / param to be appended. Format: HFNAME
[ [IDX] ] [. PARAM] If asterisk is specified as index then all
- values are affected.
+ values are affected. The index 1 correxponds to the first header.
* hvalue - Value to be assigned, config var formatting supported. If
value is empty then no equal sign appears in param.
@@ -348,7 +348,7 @@ assign_hf_value("foo[*].bar", "") # set empty value (ex. lr)
Meaning of the parameters is as follows:
* hf_para - Header field value / param to be appended. Format: HFNAME
[ [IDX] ] [. PARAM] If asterisk is specified as index then all
- values are affected.
+ values are affected. The index 1 correxponds to the first header.
* hvalue - Value to be assigned, config var formatting supported. If
value is empty then no equal sign appears in param.
Module: kamailio
Branch: master
Commit: 6379f1280ba41e87ddb34fa1705ffe4231dcac9c
URL: https://github.com/kamailio/kamailio/commit/6379f1280ba41e87ddb34fa1705ffe4…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2021-03-31T16:06:31+02:00
textopsx: docs - notes about 1-based indexing for hf value functions
- GH #2387
---
Modified: src/modules/textopsx/doc/functions.xml
---
Diff: https://github.com/kamailio/kamailio/commit/6379f1280ba41e87ddb34fa1705ffe4…
Patch: https://github.com/kamailio/kamailio/commit/6379f1280ba41e87ddb34fa1705ffe4…
---
diff --git a/src/modules/textopsx/doc/functions.xml b/src/modules/textopsx/doc/functions.xml
index 0ef8dab411..0980e4060b 100644
--- a/src/modules/textopsx/doc/functions.xml
+++ b/src/modules/textopsx/doc/functions.xml
@@ -205,7 +205,8 @@ if(fnmatch("$rU", "123*"))
<itemizedlist>
<listitem>
<para><emphasis>hf</emphasis> - Header field to be appended. Format: HFNAME [ [IDX] ].
- If index is not specified new header is inserted at the end of message.
+ If index is not specified new header is inserted at the end of message. The index 1
+ correxponds to the first header.
</para>
</listitem>
<listitem>
@@ -238,7 +239,8 @@ append_hf_value("foo[-1]", "$var(Bar)") # try add value to the last header, if n
<itemizedlist>
<listitem>
<para><emphasis>hf</emphasis> - Header field to be appended. Format: HFNAME [ [IDX] ].
- If index is not specified new header is inserted at the top of message.
+ If index is not specified new header is inserted at the top of message. The index 1
+ correxponds to the first header.
</para>
</listitem>
<listitem>
@@ -269,7 +271,8 @@ insert_hf_value("foo[1]", "gogo") # try add to the first header
<itemizedlist>
<listitem>
<para><emphasis>hf_par</emphasis> - Header field/param to be removed. Format: HFNAME [ [IDX] ] [. PARAM ]
- If asterisk is specified as index then all values are affected.
+ If asterisk is specified as index then all values are affected. The index 1
+ correxponds to the first header.
</para>
</listitem>
</itemizedlist>
@@ -299,7 +302,8 @@ remove_hf_value("foo[*].bar") # for each foo delete bar parameters
<itemizedlist>
<listitem>
<para><emphasis>hf_par</emphasis> - Header/param to be removed. Format: HFNAME [ [IDX] ] [. PARAM ]
- If asterisk is specified as index then all values are affected.
+ If asterisk is specified as index then all values are affected. The index 1
+ correxponds to the first header.
</para>
</listitem>
</itemizedlist>
@@ -329,7 +333,8 @@ remove_hf_value2("foo[*].bar") # for each foo delete bar parameters
<listitem>
<para><emphasis>hf_para</emphasis> - Header field value / param to be appended.
Format: HFNAME [ [IDX] ] [. PARAM]
- If asterisk is specified as index then all values are affected.
+ If asterisk is specified as index then all values are affected. The index 1
+ correxponds to the first header.
</para>
</listitem>
<listitem>
@@ -365,7 +370,8 @@ assign_hf_value("foo[*].bar", "") # set empty value (ex. lr)
<itemizedlist>
<listitem>
<para><emphasis>hf_para</emphasis> - Header field value / param to be appended. Format: HFNAME [ [IDX] ] [. PARAM]
- If asterisk is specified as index then all values are affected.
+ If asterisk is specified as index then all values are affected. The index 1
+ correxponds to the first header.
</para>
</listitem>
<listitem>
Is it possible to specify a specific server name/server id for dispatcher to use to send pings with (and in outgoing requests)
It seems I can't (or haven't noticed in the docs) an event route I could use to set the xavp, as tm:local-request happens to late to use there. As an aside why isn't there a "last chance before send" event route?
This is probably a feature request more than a bug, as the ideal solution from my point of view would be an additional dispatcher attrs value to be able to set it per destination in the underlying dispatcher data
Judging by the output from tls module dbg the tls xavps are checked, before the ping is sent..
I've had a cursery glance at dispatch.c and it seems easy enough to add an extra attr parameter but I'm ata loss as to how I would preset the server name/id xavp... (I'm no c dev, but can Google quick enough to follow along mostly, and happy to fiddle away if anyone can be kind enough to give me some pointers in the right direction)
--
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/kamailio/kamailio/issues/2591
### Description
I'm using dispatcher module like:
```
loadmodule "dispatcher.so"
modparam("dispatcher", "list_file", "/etc/kamailio/dispatcher.list")
modparam("dispatcher", "ds_probing_mode", 1)
modparam("dispatcher", "ds_ping_interval", 60)
```
With records like:
```
1 sip:sip.host.com;transport=tls 0 1 socket=tls:111.222.233.10:5061;ping_from=sip:my-domain-01.com
2 sip:sip.host.com;transport=tls 0 1 socket=tls:111.222.233.20:5061;ping_from=sip:my-domain-02.com
```
In event_route[tm:local-request] I'm modifying 'Contact' and would like to specify what client TLS profile to use via server name or server id.
```
event_route[tm:local-request] {
if(is_method("OPTIONS")) {
append_hf("Contact: <sip:some-host.com;transport=tls>\r\n");
$xavp(tls=>server_name)=$fd;
$xavp(tls[0]=>server_id)=$fd;
}
}
```
Setting 'tls' xavp doesn't make any difference and default client TLS profile is being used.
It happens because in src/modules/tm/uac.c there is a code:
```
t_run_local_req()
...
tm_xdata_swap(new_cell, &backup_xd, 0);
...
/* restore original environment */
tm_xdata_swap(new_cell, &backup_xd, 1);
```
which resets any xavp changes done in event_route[tm:local-request].
Expected behaviour: ability to use xavp in tm:local-request route. That would allow to choose TLS client profile for dispatcher initiated requests.
### Possible Solutions
As a hack, in tm_xdata_swap() for mode=1, don't restore xavp list if it was NULL.
```
if (x->xavps_list != NULL && *x->xavps_list==NULL) {
// .... don't restore empty list...
} else {
xavp_set_list(x->xavps_list);
}
```
This change allows to select required TLS profile for dispatcher requests.
### Additional Information
* **Kamailio Version** - output of `kamailio -v`
```
version: kamailio 5.3.5 (x86_64/linux) ff2f8c-dirty
flags: USE_TCP, USE_TLS, USE_SCTP, TLS_HOOKS, USE_RAW_SOCKS, DISABLE_NAGLE, USE_MCAST, DNS_IP_HACK, SHM_MMAP, PKG_MALLOC, Q_MALLOC, F_MALLOC, TLSF_MALLOC, DBG_SR_MEMORY, USE_FUTEX, FAST_LOCK-ADAPTIVE_WAIT, USE_DNS_CACHE, USE_DNS_FAILOVER, USE_NAPTR, USE_DST_BLACKLIST, HAVE_RESOLV_RES, TLS_PTHREAD_MUTEX_SHARED
ADAPTIVE_WAIT_LOOPS 1024, MAX_RECV_BUFFER_SIZE 262144, MAX_URI_SIZE 1024, BUF_SIZE 65535, DEFAULT PKG_SIZE 8MB
poll method support: poll, epoll_lt, epoll_et, sigio_rt, select.
id: ff2f8c -dirty
compiled on 10:19:05 Jul 28 2020 with gcc 7.5.0
```
* **Operating System**:
```
Linux xx 4.15.0-111-generic #112-Ubuntu SMP Thu Jul 9 20:32:34 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
```
--
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/kamailio/kamailio/issues/2413
Module: kamailio
Branch: master
Commit: 4edb9b27aa5cf8e39cb87c78557391445952b21c
URL: https://github.com/kamailio/kamailio/commit/4edb9b27aa5cf8e39cb87c785573914…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2021-03-31T15:51:04+02:00
tls: docs for tls_set_connect_server_id(srvid)
---
Modified: src/modules/tls/doc/functions.xml
---
Diff: https://github.com/kamailio/kamailio/commit/4edb9b27aa5cf8e39cb87c785573914…
Patch: https://github.com/kamailio/kamailio/commit/4edb9b27aa5cf8e39cb87c785573914…
---
diff --git a/src/modules/tls/doc/functions.xml b/src/modules/tls/doc/functions.xml
index 2a371de8f1..2a5d4f4f2d 100644
--- a/src/modules/tls/doc/functions.xml
+++ b/src/modules/tls/doc/functions.xml
@@ -27,11 +27,37 @@
<example>
<title><function>is_peer_verified</function> usage</title>
<programlisting>
+...
if (proto==TLS && !is_peer_verified()) {
sl_send_reply("400", "No certificate or verification failed");
exit;
}
- </programlisting>
+...
+</programlisting>
+ </example>
+ </section>
+ <section id="tls.f.tls_set_connect_server_id">
+ <title><function>tls_set_connect_server_id(srvid)</function></title>
+ <para>
+ Set the server id of the tls profile to be used by next client
+ connect, being reset after use. It is an alternative to the use
+ of xavp to specify server id of a client profile for the cases
+ when xavps are no longer available (e.g., after
+ event_route[tm:local-request]).
+ </para>
+ <para>
+ If the parameter is an empty string, then the value is reset.
+ </para>
+ <para>
+ It can be used only in ANY_ROUTE.
+ </para>
+ <example>
+ <title><function>tls_set_connect_server_id</function> usage</title>
+ <programlisting>
+...
+ tls_set_connect_server_id("clientone");
+...
+</programlisting>
</example>
</section>
</section>
<!--
Kamailio Project uses GitHub Issues only for bugs in the code or feature requests. Please use this template only for bug reports.
If you have questions about using Kamailio or related to its configuration file, ask on sr-users mailing list:
* http://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
If you have questions about developing extensions to Kamailio or its existing C code, ask on sr-dev mailing list:
* http://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev
Please try to fill this template as much as possible for any issue. It helps the developers to troubleshoot the issue.
If there is no content to be filled in a section, the entire section can be removed.
You can delete the comments from the template sections when filling.
You can delete next line and everything above before submitting (it is a comment).
-->
### Description
topos_redis sets TTL on dialogs including presence SUBSCRIPTIONs. Once the TTL expires on those SUBSCRIBEs the topos module fails to route the in-dialog NOTIFYs & subsequent SUBSCRIBEs. That causes presence to break.
<!--
Explain what you did, what you expected to happen, and what actually happened.
-->
### Troubleshooting
```
loadmodule "topos_redis.so"
modparam("topos_redis", "serverid", "srv1")
loadmodule "topos.so"
modparam("topos", "storage", "redis")
```
#### Reproduction
load up topos and topos_redis module, set expiration in topos_redis to 600 (just to reproduce this) create a dialog, either INVITE or SUBSCRIBE anything is fine. Once the TTL is expired the in-dialog routing of packets fail in route[WITHINDLG] with 404 Not here.
The route[WITHINGDLG] is just the standard one for us(can be pasted when needed)
I can set the TTL to few days, but doing that brought the problem back for SUBSCRIBEs since the desk phone stay alive for weeks at a stretch.
<!--
If the issue can be reproduced, describe how it can be done.
-->
### Possible Solutions
I could only think about renewing/refreshing the TTL for dialogs whenever they're loaded, so I modified the topos and topos_redis module for this and tested it. so far it works well and SUBSCRIBEs/NOTIFYs have been getting routed perfectly fine over the course of a week+
<!--
If you found a solution or workaround for the issue, describe it. Ideally, provide a pull request with a fix.
-->
### Additional Information
* **Kamailio Version** - output of `kamailio -v`
```
version: kamailio 5.4.3 (x86_64/linux) a96451-dirty
flags: USE_TCP, USE_TLS, USE_SCTP, TLS_HOOKS, USE_RAW_SOCKS, DISABLE_NAGLE, USE_MCAST, DNS_IP_HACK, SHM_MMAP, PKG_MALLOC, Q_MALLOC, F_MALLOC, TLSF_MALLOC, DBG_SR_MEMORY, USE_FUTEX, FAST_LOCK-ADAPTIVE_WAIT, USE_DNS_CACHE, USE_DNS_FAILOVER, USE_NAPTR, USE_DST_BLACKLIST, HAVE_RESOLV_RES, TLS_PTHREAD_MUTEX_SHARED
ADAPTIVE_WAIT_LOOPS 1024, MAX_RECV_BUFFER_SIZE 262144, MAX_URI_SIZE 1024, BUF_SIZE 65535, DEFAULT PKG_SIZE 8MB
poll method support: poll, epoll_lt, epoll_et, sigio_rt, select.
id: a96451 -dirty
compiled on 23:44:16 Feb 20 2021 with gcc 8.3.0
```
* **Operating System**:
<!--
Details about the operating system, the type: Linux (e.g.,: Debian 8.4, Ubuntu 16.04, CentOS 7.1, ...), MacOS, xBSD, Solaris, ...;
Kernel details (output of `uname -a`)
-->
```
Debian GNU/Linux 10 (buster)
Linux sbc-va-2 4.19.0-13-cloud-amd64 #1 SMP Debian 4.19.160-2 (2020-11-28) x86_64 GNU/Linux
```
* **Suggested Fix/Patch**:
https://github.com/kamailio/kamailio/compare/master...goharahmed:master
--
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/kamailio/kamailio/issues/2652