jonastelzio created an issue (kamailio/kamailio#4349)

### Description

<!--
Explain what you did, what you expected to happen, and what actually happened.
-->

Kamailio configured with the following listeners:

```
listen=udp:LOCAL_IP:5060 advertise DNS_HOST:5060
listen=tcp:LOCAL_IP:5060 advertise DNS_HOST:5060
listen=tcp:LOCAL_IP:5061 advertise tls:DNS_HOST:5061
```
Notice `tls:` in the advertise part of the last listener. TLS Termination 
happens upstream by, in this case, haproxy.

The following happens:
1. Kamailio receives invite from a phone via TCP, on the TLS advertised 
listener. The phone is communicating via TLS, but it's terminated upstream.
2. Dispatcher is used to select where to forward it
3. Forwards via UDP and the call is connected downstream.
4. The downstream asterisk ends the call by sending a BYE request
5. Kamailio receives this, and generates a BYE request for the phone.

The generated BYE request has an incorrect Via-header:

`Via: SIP/2.0/TCP 
jswiatek.dk.office.tlz:5060;branch=z9hG4bK2e8f.2625efdb2ab26c466f55b8baf1bf807d.0`

This should be `SIP/2.0/TLS`, and the host should be `:5061`

In the provided PCAP, this is message is message number 15.

A similar issue was addressed in this commit: 
https://github.com/kamailio/kamailio/commit/3322bea764036deba6340e435c257244d511a11f

### Troubleshooting

#### SIP Traffic

<!--
If the issue is exposed by processing specific SIP messages, grab them with 
ngrep or save in a pcap file, then add them next, or attach to issue, or 
provide a link to download them (e.g., to a pastebin site).
-->

PCAP of this happening: 
[advertise_tls_bye_fail.zip](https://github.com/user-attachments/files/21597756/advertise_tls_bye_fail.zip)

### Additional Information

  * **Kamailio Version** - output of `kamailio -v`

```
version: kamailio 6.0.2 (x86_64/linux) d4dc5d-dirty
flags: USE_TCP, USE_TLS, USE_SCTP, TLS_HOOKS, USE_RAW_SOCKS, DISABLE_NAGLE, 
USE_MCAST, DNS_IP_HACK, SHM_MMAP, PKG_MALLOC, MEM_JOIN_FREE, 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_BLOCKLIST, HAVE_RESOLV_RES, 
TLS_PTHREAD_MUTEX_SHARED
ADAPTIVE_WAIT_LOOPS 1024, MAX_RECV_BUFFER_SIZE 262144, MAX_SEND_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: d4dc5d -dirty
```

* **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 `lsb_release -a` and `uname -a`)
-->

```
Distributor ID: Debian
Description:    Debian GNU/Linux 12 (bookworm)
Release:        12
Codename:       bookworm

Linux 44298e54e0b8 6.6.87.2-microsoft-standard-WSL2 #1 SMP PREEMPT_DYNAMIC Thu 
Jun  5 18:30:46 UTC 2025 x86_64 GNU/Linux
```


-- 
Reply to this email directly or view it on GitHub:
https://github.com/kamailio/kamailio/issues/4349
You are receiving this because you are subscribed to this thread.

Message ID: <kamailio/kamailio/issues/4...@github.com>
_______________________________________________
Kamailio - Development Mailing List -- sr-dev@lists.kamailio.org
To unsubscribe send an email to sr-dev-le...@lists.kamailio.org
Important: keep the mailing list in the recipients, do not reply only to the 
sender!

Reply via email to