From 97c3d51df1bd65dda3b7d73a0e40e393a2630585 Mon Sep 17 00:00:00 2001 From: bitbashing Date: Thu, 15 Sep 2016 10:27:10 -0700 Subject: [PATCH] preform the registration lookup and set the socket in internal_to_external_relay (#100) --- kamailio/default.cfg | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/kamailio/default.cfg b/kamailio/default.cfg index 4545594..a12d352 100644 --- a/kamailio/default.cfg +++ b/kamailio/default.cfg @@ -552,13 +552,6 @@ route[PREPARE_INITIAL_REQUESTS] } } - if ( is_method("INVITE|MESSAGE|NOTIFY") && isflagset(FLAG_INTERNALLY_SOURCED) && $hdr(X-KAZOO-AOR) != $null && registered("location", "$hdr(X-KAZOO-AOR)")) - { - $avp(kazoo_aor) = $hdr(X-KAZOO-AOR); - $avp(kazoo_du) = $xavp(ulrcd=>received); - xlog("L_INFO", "$ci|end|setting aor avp : AOR : $hdr(X-KAZOO-AOR)\n"); - }; - record_route(); } @@ -582,6 +575,19 @@ route[INTERNAL_TO_EXTERNAL_RELAY] } #!endif + if ($hdr(X-KAZOO-AOR) != $null) { + xlog("L_INFO", "$ci|log|using AOR $hdr(X-KAZOO-AOR)\n"); + if (reg_fetch_contacts("location", "$hdr(X-KAZOO-AOR)", "callee")) { + $du = $(ulc(callee=>received)); + $fs = $(ulc(callee=>socket)); + xlog("L_INFO", "$ci|log|routing $hdr(X-KAZOO-AOR) to $du via $fs\n"); + } else { + xlog("L_INFO", "$ci|end|user is not registered\n"); + sl_send_reply("404", "Not registered"); + exit; + } + } + remove_hf_re("^X-.*"); if( $avp(kazoo_aor) != $null)