Browse code

core: tcp - set default local socket for tls when lookup fails

- GH #2028

Daniel-Constantin Mierla authored on 11/09/2019 10:42:58
Showing 1 changed files
... ...
@@ -1373,18 +1373,31 @@ again:
1373 1373
 	su2ip_addr(&ip, &my_name);
1374 1374
 find_socket:
1375 1375
 #ifdef USE_TLS
1376
-	if (unlikely(type==PROTO_TLS))
1376
+	if (unlikely(type==PROTO_TLS)) {
1377 1377
 		*res_si=find_si(&ip, 0, PROTO_TLS);
1378
-	else
1379
-#endif
1378
+	} else {
1380 1379
 		*res_si=find_si(&ip, 0, PROTO_TCP);
1381
-	
1380
+	}
1381
+#else
1382
+	*res_si=find_si(&ip, 0, PROTO_TCP);
1383
+#endif
1384
+
1382 1385
 	if (unlikely(*res_si==0)){
1383 1386
 		LM_WARN("%s: could not find corresponding"
1384 1387
 				" listening socket for %s, using default...\n",
1385 1388
 					su2a(server, sizeof(*server)), ip_addr2a(&ip));
1389
+#ifdef USE_TLS
1390
+		if (unlikely(type==PROTO_TLS)) {
1391
+			if (server->s.sa_family==AF_INET) *res_si=sendipv4_tls;
1392
+			else *res_si=sendipv6_tls;
1393
+		} else {
1394
+			if (server->s.sa_family==AF_INET) *res_si=sendipv4_tcp;
1395
+			else *res_si=sendipv6_tcp;
1396
+		}
1397
+#else
1386 1398
 		if (server->s.sa_family==AF_INET) *res_si=sendipv4_tcp;
1387 1399
 		else *res_si=sendipv6_tcp;
1400
+#endif
1388 1401
 	}
1389 1402
 	*res_local_addr=*from;
1390 1403
 	return s;