On the previous issue (disjoint networks), I eventually settled for binding Asterisk on
localhost:5080, and using rtpproxy to route media to the networks as required. The only
snag is that I had to write a script to rewrite the Kamailio configuration in
order to take current IPs into account.
Now, for the same project. What I want now is to be able to express multiple domains with
an Asterisk backend. That is: given
pbx.company1.com and
pbx.company2.com, two DNS
addresses that point to the same server, I want to have separate accounts
bob(a)pbx.company1.com and bob(a)pbx.company2.com, with separate registration and accounting,
without collisions.
I know about the Kamailio "domain" module, and I have enabled WITH_MULTIDOMAIN
and filled the kamailio.domain table for it to work. Now the authentication is taking
domains into account.
Next, I want to express two non-colliding registrations for Asterisk. What comes to mind
is username rewrite - Kamailio sees bob(a)company1.com, and forwards a REGISTER to Asterisk
using bob_company1_com as the SIP username. I am looking right now at the
WITH_ASTERISK block that uses the uac module:
# Forward REGISTER to Asterisk
route[REGFWD] {
if(!is_method("REGISTER"))
{
return;
}
$var(rip) = $sel(cfg_get.asterisk.bindip);
$uac_req(method)="REGISTER";
$uac_req(ruri)="sip:" + $var(rip) + ":" +
$sel(cfg_get.asterisk.bindport);
$uac_req(furi)="sip:" + $au + "@" + $var(rip) +
":5060";
$uac_req(turi)="sip:" + $au + "@" + $var(rip) +
":5060";
$uac_req(hdrs)="Contact: <sip:" + $au + "@"
+ $sel(cfg_get.kamailio.bindip)
+ ":" + $sel(cfg_get.kamailio.bindport) +
">\r\n";
if($sel(contact.expires) != $null)
$uac_req(hdrs)= $uac_req(hdrs) + "Expires: " +
$sel(contact.expires) + "\r\n";
else
$uac_req(hdrs)= $uac_req(hdrs) + "Expires: " + $hdr(Expires) +
"\r\n";
uac_req_send();
}
#!endif
The above is the non-encoding version. What is the best way to modify it to do a domain
encoding in the username? Or, if a better solution exists, what is it?