dns lookup of peername rather than peer's host in transmit_register()
authorDavid Vossel <dvossel@digium.com>
Mon, 13 Jul 2009 23:26:51 +0000 (23:26 +0000)
committerDavid Vossel <dvossel@digium.com>
Mon, 13 Jul 2009 23:26:51 +0000 (23:26 +0000)
(closes issue #15052)
Reported by: fsantulli
Patches:
      chan_sip_bug_15052_[20090626204511].patch uploaded by fsantulli (license 818)
Tested by: fsantulli

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@206280 65c4cc65-6c06-0410-ace0-fbb531ad65f3

channels/chan_sip.c

index 715d7c9..bbdbaf8 100644 (file)
@@ -11532,6 +11532,7 @@ static int transmit_register(struct sip_registry *r, int sipmethod, const char *
        char tmp[80];
        char addr[80];
        struct sip_pvt *p;
+       struct sip_peer *peer;
        int res;
        char *fromdomain;
        char *domainport = NULL;
@@ -11546,8 +11547,12 @@ static int transmit_register(struct sip_registry *r, int sipmethod, const char *
 
        if (r->dnsmgr == NULL) {
                char transport[MAXHOSTNAMELEN];
+               peer = find_peer(r->hostname, NULL, TRUE, FINDPEERS, FALSE);
                snprintf(transport, sizeof(transport), "_sip._%s", get_transport(r->transport)); /* have to use static get_transport function */
-               ast_dnsmgr_lookup(r->hostname, &r->us, &r->dnsmgr, sip_cfg.srvlookup ? transport : NULL);
+               ast_dnsmgr_lookup(peer ? peer->tohost : r->hostname, &r->us, &r->dnsmgr, sip_cfg.srvlookup ? transport : NULL);
+               if (peer) {
+                       unref_peer(peer, "removing peer ref for dnsmgr_lookup");
+               }
        }
 
        if (r->call) {  /* We have a registration */