Browse code

dispatcher: test no-dns flag to skip ip matching for hostnames

- no dns done at startup if the flag is set in the destination record

Daniel-Constantin Mierla authored on 18/11/2020 06:55:44
Showing 1 changed files
... ...
@@ -467,19 +467,19 @@ ds_dest_t *pack_dest(str iuri, int flags, int priority, str *attrs, int dload)
467 467
 	strncpy(hn, puri.host.s, puri.host.len);
468 468
 	hn[puri.host.len] = '\0';
469 469
 
470
-	/* Do a DNS-Lookup for the Host-Name: */
471
-	he = resolvehost(hn);
472
-	if(he == 0) {
473
-		if(dp->flags & DS_NODNSARES_DST) {
474
-			dp->irmode |= DS_IRMODE_NOIPADDR;
475
-		} else {
470
+	/* Do a DNS-Lookup for the Host-Name, if not disabled via dst flags */
471
+	if(dp->flags & DS_NODNSARES_DST) {
472
+		dp->irmode |= DS_IRMODE_NOIPADDR;
473
+	} else {
474
+		he = resolvehost(hn);
475
+		if(he == 0) {
476 476
 			LM_ERR("could not resolve %.*s (missing no-probing flag?!?)\n",
477 477
 					puri.host.len, puri.host.s);
478 478
 			goto err;
479
+		} else {
480
+			/* Store hostent in the dispatcher structure */
481
+			hostent2ip_addr(&dp->ip_address, he, 0);
479 482
 		}
480
-	} else {
481
-		/* Store hostent in the dispatcher structure */
482
-		hostent2ip_addr(&dp->ip_address, he, 0);
483 483
 	}
484 484
 
485 485
 	/* Copy the port out of the URI */
... ...
@@ -3189,6 +3189,10 @@ int ds_is_addr_from_set(sip_msg_t *_m, struct ip_addr *pipaddr,
3189 3189
 	pv_value_t val;
3190 3190
 	int j;
3191 3191
 	for(j = 0; j < node->nr; j++) {
3192
+		if(node->dlist[j].irmode & DS_IRMODE_NOIPADDR) {
3193
+			/* dst record using hotname with dns not done - no ip to match */
3194
+			continue;
3195
+		}
3192 3196
 		if(ip_addr_cmp(pipaddr, &node->dlist[j].ip_address)
3193 3197
 				&& ((mode & DS_MATCH_NOPORT) || node->dlist[j].port == 0
3194 3198
 						   || tport == node->dlist[j].port)