Module: kamailio
Branch: master
Commit: 1c58b8e0ed221404a15c1426f40df167654e3860
URL:
https://github.com/kamailio/kamailio/commit/1c58b8e0ed221404a15c1426f40df16…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2020-11-18T07:55:44+01:00
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
---
Modified: src/modules/dispatcher/dispatch.c
---
Diff:
https://github.com/kamailio/kamailio/commit/1c58b8e0ed221404a15c1426f40df16…
Patch:
https://github.com/kamailio/kamailio/commit/1c58b8e0ed221404a15c1426f40df16…
---
diff --git a/src/modules/dispatcher/dispatch.c b/src/modules/dispatcher/dispatch.c
index d33135098a..ad420e83fe 100644
--- a/src/modules/dispatcher/dispatch.c
+++ b/src/modules/dispatcher/dispatch.c
@@ -467,19 +467,19 @@ ds_dest_t *pack_dest(str iuri, int flags, int priority, str *attrs,
int dload)
strncpy(hn, puri.host.s, puri.host.len);
hn[puri.host.len] = '\0';
- /* Do a DNS-Lookup for the Host-Name: */
- he = resolvehost(hn);
- if(he == 0) {
- if(dp->flags & DS_NODNSARES_DST) {
- dp->irmode |= DS_IRMODE_NOIPADDR;
- } else {
+ /* Do a DNS-Lookup for the Host-Name, if not disabled via dst flags */
+ if(dp->flags & DS_NODNSARES_DST) {
+ dp->irmode |= DS_IRMODE_NOIPADDR;
+ } else {
+ he = resolvehost(hn);
+ if(he == 0) {
LM_ERR("could not resolve %.*s (missing no-probing flag?!?)\n",
puri.host.len, puri.host.s);
goto err;
+ } else {
+ /* Store hostent in the dispatcher structure */
+ hostent2ip_addr(&dp->ip_address, he, 0);
}
- } else {
- /* Store hostent in the dispatcher structure */
- hostent2ip_addr(&dp->ip_address, he, 0);
}
/* 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,
pv_value_t val;
int j;
for(j = 0; j < node->nr; j++) {
+ if(node->dlist[j].irmode & DS_IRMODE_NOIPADDR) {
+ /* dst record using hotname with dns not done - no ip to match */
+ continue;
+ }
if(ip_addr_cmp(pipaddr, &node->dlist[j].ip_address)
&& ((mode & DS_MATCH_NOPORT) || node->dlist[j].port == 0
|| tport == node->dlist[j].port)