core: tcp - set default local socket for tls when lookup fails
authorDaniel-Constantin Mierla <miconda@gmail.com>
Wed, 11 Sep 2019 10:42:58 +0000 (12:42 +0200)
committerDaniel-Constantin Mierla <miconda@gmail.com>
Wed, 11 Sep 2019 10:42:58 +0000 (12:42 +0200)
- GH #2028

src/core/tcp_main.c

index 668103e..e86fc87 100644 (file)
@@ -1373,18 +1373,31 @@ again:
        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;