Index: channels/chan_sip.c
===================================================================
--- channels/chan_sip.c (revision 53063)
+++ channels/chan_sip.c (working copy)
@@ -7328,12 +7328,16 @@
if (sipmethod == SIP_SUBSCRIBE)
/* For subscribes, match on peer name only */
peer = find_peer(of, NULL, 1);
- else
- /* Look for peer based on the IP address we received data from */
- /* If peer is registered from this IP address or have this as a default
- IP address, this call is from the peer
- */
- peer = find_peer(NULL, &p->recv, 1);
+ else {
+ peer = find_peer(of, NULL, 1);
+ if (!peer) {
+ /* Look for peer based on the IP address we received data from */
+ /* If peer is registered from this IP address or have this as a default
+ IP address, this call is from the peer
+ */
+ peer = find_peer(NULL, &p->recv, 1);
+ }
+ }
if (peer) {
if (debug)