Module: kamailio
Branch: master
Commit: f40df55af2f50789ca4a8b89a213f7323b1932f2
URL:
https://github.com/kamailio/kamailio/commit/f40df55af2f50789ca4a8b89a213f73…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2019-09-11T12:42:58+02:00
core: tcp - set default local socket for tls when lookup fails
- GH #2028
---
Modified: src/core/tcp_main.c
---
Diff:
https://github.com/kamailio/kamailio/commit/f40df55af2f50789ca4a8b89a213f73…
Patch:
https://github.com/kamailio/kamailio/commit/f40df55af2f50789ca4a8b89a213f73…
---
diff --git a/src/core/tcp_main.c b/src/core/tcp_main.c
index 668103e676..e86fc872a8 100644
--- a/src/core/tcp_main.c
+++ b/src/core/tcp_main.c
@@ -1373,18 +1373,31 @@ inline static int tcp_do_connect( union sockaddr_union* server,
su2ip_addr(&ip, &my_name);
find_socket:
#ifdef USE_TLS
- if (unlikely(type==PROTO_TLS))
+ if (unlikely(type==PROTO_TLS)) {
*res_si=find_si(&ip, 0, PROTO_TLS);
- else
-#endif
+ } else {
*res_si=find_si(&ip, 0, PROTO_TCP);
-
+ }
+#else
+ *res_si=find_si(&ip, 0, PROTO_TCP);
+#endif
+
if (unlikely(*res_si==0)){
LM_WARN("%s: could not find corresponding"
" listening socket for %s, using default...\n",
su2a(server, sizeof(*server)), ip_addr2a(&ip));
+#ifdef USE_TLS
+ if (unlikely(type==PROTO_TLS)) {
+ if (server->s.sa_family==AF_INET) *res_si=sendipv4_tls;
+ else *res_si=sendipv6_tls;
+ } else {
+ if (server->s.sa_family==AF_INET) *res_si=sendipv4_tcp;
+ else *res_si=sendipv6_tcp;
+ }
+#else
if (server->s.sa_family==AF_INET) *res_si=sendipv4_tcp;
else *res_si=sendipv6_tcp;
+#endif
}
*res_local_addr=*from;
return s;