<p></p>
<p><a class="user-mention" data-hovercard-type="user" data-hovercard-url="/users/miconda/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/miconda">@miconda</a> , Yes i am adding and removing on the fly. I am adding(using ka_add_destination) to KA list on successful registration and removing(using ka_del_destination) when registration expires.</p>
<pre><code>
#####################KEEPALIVE#######################################
modparam("keepalive", "ping_interval", 20)
modparam("keepalive", "delete_counter", 5)
modparam("keepalive", "ping_from", "sip:keepalive@fromsbc")

request_route {

##ON RECIEVING OPTIONS FROM KA MODULE ON 9090 PORT, Set $du using handle_ruri_alias , replace tp with transport and relay it to edge proxy from which we recieved register packet
                if ($Rp == "9090" && is_method("OPTIONS")){
                        if (t_newtran()) {
                                if (handle_ruri_alias()){
                                        $avp(request_uri)= $ru ;
                                        $avp(pb-ip)=$(avp(request_uri){param.value,pb-ip});
                                        if (is_ipv6($avp(pb-ip))) {
                                                if (subst_uri('/^sip:(.*)@(.*);pb-ip=(.*);pb-pt=(.*);tp=(.*)$/sip:\1@[\3]:\4;pb-ip=\3;pb-pt=\4;transport=\5/i')){
                                                          xlog("L_INFO","(KA OPTIONS) : ($avp(uuid)) : Destination URI <$du> created from alias.");
                                                         t_relay();
                                              }

                                        } else {
                                                if (subst_uri('/^sip:(.*)@(.*);pb-ip=(.*);pb-pt=(.*);tp=(.*)$/sip:\1@\3:\4;pb-ip=\3;pb-pt=\4;transport=\5/i')){
                                                          xlog("L_INFO","(KA OPTIONS) : ($avp(uuid)) : Destination URI <$du> created from alias.");
                                                         t_relay();
                                                }

                                        }

                                }

                                exit;
                        }

$du=sip:APPLICATION_SERVER_IP:5060; ##IP of application server ( Freeswitch) to which kamailio will relay register packet add_contact_alias();
t_on_reply("reply_register")
if (!t_relay()) {
                sl_reply_error();
        }
exit;

onreply_route[reply_register ]{
 if ((status=~"200") && $rm=="REGISTER" && $(avp(c_ct){param.value,expires}) != 0)
        {
## On receiving fresh registration (i.e with expires !=0) , Kamailio will register a contact address for that registration in KA module ping registry.
        $avp(ka_contact) = 'sip:'+$fU+'@LOCAL_IP:9090;alias='+$(avp(c_ct){param.value,alias})+';pb-ip='+$(avp(c_ct){param.value,pb-ip})+';pb-pt='+$(avp(c_ct){param.value,pb-pt})+';tp='+$(avp(c_ct){param.value,transport}{s.rm,>});
        ka_add_destination("$avp(ka_contact)","config");


if ((status=~"200") && $rm=="REGISTER" && $(avp(c_ct){param.value,expires}) == 0)
 {

        $avp(ka_contact) = 'sip:'+$fU+'@LOCAL_IP:9090;alias='+$(avp(c_ct){param.value,alias})+';pb-ip='+$(avp(c_ct){param.value,pb-ip})+';pb-pt='+$(avp(c_ct){param.value,pb-pt})+';tp='+$(avp(c_ct){param.value,transport}{s.rm,>});
        ka_del_destination("$avp(ka_contact)","config");
}

}
</code></pre>
<p><a class="user-mention" data-hovercard-type="user" data-hovercard-url="/users/NGSegovia/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/NGSegovia">@NGSegovia</a> , I am adding destinations from CFG file.</p>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />You are receiving this because you are subscribed to this thread.<br />Reply to this email directly, <a href="https://github.com/kamailio/kamailio/issues/2448#issuecomment-683752918">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/ABO7UZJBXLP7JFKB34FTX2TSDOK2DANCNFSM4QE75I5Q">unsubscribe</a>.<img src="https://github.com/notifications/beacon/ABO7UZI5GOVCDP5QB2X34J3SDOK2DA5CNFSM4QE75I52YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOFDAT3VQ.gif" height="1" width="1" alt="" /></p>
<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/kamailio/kamailio/issues/2448#issuecomment-683752918",
"url": "https://github.com/kamailio/kamailio/issues/2448#issuecomment-683752918",
"name": "View Issue"
},
"description": "View this Issue on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>