Module: kamailio Branch: master Commit: aa794581ecf105b5313d2f5b8bcfe516ab337936 URL: https://github.com/kamailio/kamailio/commit/aa794581ecf105b5313d2f5b8bcfe516...
Author: Daniel-Constantin Mierla miconda@gmail.com Committer: Daniel-Constantin Mierla miconda@gmail.com Date: 2024-09-05T09:01:52+02:00
core: try to lookup connection for WSS when TCPCONN_MATCH_STRICT is set
- URIs have always transport ws, but most likely the connection is wss - GH #3969
---
Modified: src/core/forward.h
---
Diff: https://github.com/kamailio/kamailio/commit/aa794581ecf105b5313d2f5b8bcfe516... Patch: https://github.com/kamailio/kamailio/commit/aa794581ecf105b5313d2f5b8bcfe516...
---
diff --git a/src/core/forward.h b/src/core/forward.h index 31086c6512b..8d96e4df5cb 100644 --- a/src/core/forward.h +++ b/src/core/forward.h @@ -137,6 +137,7 @@ static inline int msg_send_buffer( union sockaddr_union local_addr; struct tcp_connection *con = NULL; struct ws_event_info wsev; + int dproto; int ret; #endif
@@ -192,9 +193,21 @@ static inline int msg_send_buffer( if(likely(port)) { su2ip_addr(&ip, &dst->to); if(tcp_connection_match == TCPCONN_MATCH_STRICT) { + /* lookup first for WSS, because transport=ws is in URI, + * but WS is less likely */ + if(dst->proto == PROTO_WSS || dst->proto == PROTO_WS) { + dproto = PROTO_WSS; + } else { + dproto = dst->proto; + } con = tcpconn_lookup(dst->id, &ip, port, from, (dst->send_sock) ? dst->send_sock->port_no : 0, 0, - dst->proto); + dproto); + if(con == NULL && dst->proto == PROTO_WS) { + con = tcpconn_lookup(dst->id, &ip, port, from, + (dst->send_sock) ? dst->send_sock->port_no : 0, 0, + PROTO_WS); + } } else { con = tcpconn_get(dst->id, &ip, port, from, 0); }