The file [th-test.c.txt](https://github.com/kamailio/kamailio/files/10608862/th-test.c.txt) contains the exact copy of the th_mask_encode() and th_mask_decode() functions from src/modules/topoh/th_mask.c . (except LM_ERR is removed and pkg_malloc/pkg_free are replaced with malloc/free).
When I run Kamilio under topoh and the websocket client calls, at some moment `sip:test-gnome-calls@bapha.be;gr=urn:uuid:f2f5a3cf-a0fb-0047-be50-740fb9bdc562;alias=87.118.146.153~60472~2>;+sip.instance="urn:uuid:f2f5a3cf-a0fb-0047-be50-740fb9bdc562";+org.linphone.specs="conference/1.0,ephemeral/1.1,groupchat/1.1,groupchat/1.2,lime"` is passed to th_mask_encode(). The output it `sip:127.3.4.84;line=sr-if7s1mg7i36PNf0AbdwPpfzlbqWEpLzsSGItpLwyN39ZMY4t1mCTSd6DNo4LWdIOpfpPp5FLpUQscX63Kd47W5EPWO6sNL90pLgoW5p-1fzlSdzO25n3KoIk1vHkWXptc5wOeopsWXi-eo9*`. This is put in a Contact: header. When that last string is passed to th_mask_decode(), e.g. because BYE or ACK have it as R-URI, the output is `sip:test-gnome-calls@bapha.be;gr=urn:uuid:f2f5a3cf-a0fb-0047-be50-740fb9bdc562;alias=87.118.1`. From the initial input the final output misses at least `46.153`.
The attached file contains under `b2` another input, which is passed ot th_mask_decode. This is the actual input Kamailio gets at runtime and passes to th_mask_decode. The result is not a string — callu.b.p...b.;.r...n:s..d..2lQ — where the dots represent unprintable bytes.
The error report is that th_mask_encode() produces output, which th_mask_decode() does not convert to its origin.
N.B.: The above problem happens, when a websocket client calls TCP-client with topoh-module. When a TLS-client calls TCP-client (no websockets involved), topoh does not make problems — BYE is delivered properly.
See also: * https://lists.kamailio.org/mailman3/hyperkitty/list/sr-users@lists.kamailio.... * https://lists.kamailio.org/mailman3/hyperkitty/list/sr-users@lists.kamailio....
This might also be related: * https://lists.kamailio.org/mailman3/hyperkitty/list/sr-users@lists.kamailio....