diff --git a/channels/chan_sip.c b/channels/chan_sip.c index a29ca9c55b5f39ad1bbaa079a8c009d5af9ccb3e..1889fe4cc5f39ac3142899a5a3d3ee22bff8fd20 100644 --- a/channels/chan_sip.c +++ b/channels/chan_sip.c @@ -13383,7 +13383,14 @@ static int transmit_register(struct sip_registry *r, int sipmethod, const char * peer = sip_find_peer(r->hostname, NULL, TRUE, FINDPEERS, FALSE, 0); snprintf(transport, sizeof(transport), "_%s._%s",get_srv_service(r->transport), get_srv_protocol(r->transport)); /* have to use static sip_get_transport function */ r->us.ss.ss_family = get_address_family_filter(&bindaddr); /* Filter address family */ - ast_dnsmgr_lookup(peer ? peer->tohost : r->hostname, &r->us, &r->dnsmgr, sip_cfg.srvlookup ? transport : NULL); + + /* No point in doing a DNS lookup of the register hostname if we're just going to + * end up using an outbound proxy. obproxy_get is safe to call with either of r->call + * or peer NULL. Since we're only concerned with its existence, we're not going to + * bother getting a ref to the proxy*/ + if (!obproxy_get(r->call, peer)) { + ast_dnsmgr_lookup(peer ? peer->tohost : r->hostname, &r->us, &r->dnsmgr, sip_cfg.srvlookup ? transport : NULL); + } if (peer) { peer = sip_unref_peer(peer, "removing peer ref for dnsmgr_lookup"); }