Index: channels/chan_iax2.c =================================================================== RCS file: /usr/cvsroot/asterisk/channels/chan_iax2.c,v retrieving revision 1.349 diff -u -r1.349 chan_iax2.c --- channels/chan_iax2.c 15 Sep 2005 02:25:06 -0000 1.349 +++ channels/chan_iax2.c 23 Sep 2005 16:10:12 -0000 @@ -5149,23 +5149,9 @@ /* Normal password authentication */ res = authenticate(p->challenge, override, okey, authmethods, &ied, sin, &p->ecx, &p->dcx); } else { - ast_mutex_lock(&peerl.lock); - peer = peerl.peers; - while(peer) { - if ((ast_strlen_zero(p->peer) || !strcmp(p->peer, peer->name)) - /* No peer specified at our end, or this is the peer */ - && (ast_strlen_zero(peer->username) || (!strcmp(peer->username, p->username))) - /* No username specified in peer rule, or this is the right username */ - && (!peer->addr.sin_addr.s_addr || ((sin->sin_addr.s_addr & peer->mask.s_addr) == (peer->addr.sin_addr.s_addr & peer->mask.s_addr))) - /* No specified host, or this is our host */ - ) { - res = authenticate(p->challenge, peer->secret, peer->outkey, authmethods, &ied, sin, &p->ecx, &p->dcx); - if (!res) - break; - } - peer = peer->next; - } - ast_mutex_unlock(&peerl.lock); + peer = find_peer(p->peer, 1); + if (peer) + res = authenticate(p->challenge, peer->secret, peer->outkey, authmethods, &ied, sin, &p->ecx, &p->dcx); } if (ies->encmethods) ast_set_flag(p, IAX_ENCRYPTED | IAX_KEYPOPULATED);