Skip to content

Commit

Permalink
core: tcp - set default local socket for tls when lookup fails
Browse files Browse the repository at this point in the history
- GH #2028

(cherry picked from commit f40df55)
  • Loading branch information
miconda committed Sep 24, 2019
1 parent 7c3cc32 commit 28c4e65
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions src/core/tcp_main.c
Expand Up @@ -1136,18 +1136,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;
Expand Down

0 comments on commit 28c4e65

Please sign in to comment.