Skip to content

Commit

Permalink
refactor presence role (#136)
Browse files Browse the repository at this point in the history
* refactor presence role

* Update presence-role.cfg

* Update presence_notify_sync-role.cfg

* Update presence-role.cfg

* Update registrar-role.cfg

* Update presence_notify_sync-role.cfg

* typo

* remove trans

* Update presence-role.cfg

* Update presence-role.cfg

* Update presence_notify_sync-role.cfg

* Update presence-role.cfg

* Update presence-role.cfg

* Update presence-role.cfg

* update presence

* update local

* update bindings

* Update presence-role.cfg

* bring back comments on defaults

* remove PRESENCE_NAT role from definitions

* outbound should be loaded before stun

* Update presence-role.cfg

* add a threshold for 408 and other errors

* handle summary & detail queries

* Update accounting-role.cfg

* Update default.cfg

* fix call-id in logging

* Update fast-pickup-role.cfg
  • Loading branch information
lazedo authored and k-anderson committed Feb 9, 2017
1 parent cda462b commit 10e5707
Show file tree
Hide file tree
Showing 9 changed files with 306 additions and 94 deletions.
6 changes: 3 additions & 3 deletions kamailio/accounting-role.cfg
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
####### Flags #######
flags
FLAG_ACC: 7,
FLAG_ACCMISSED: 8,
FLAG_ACCFAILED: 9;
FLAG_ACC: 8,
FLAG_ACCMISSED: 9,
FLAG_ACCFAILED: 10;

######## Accounting module ########
loadmodule "acc.so"
Expand Down
45 changes: 22 additions & 23 deletions kamailio/default.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -63,17 +63,21 @@ tcp_wq_blk_size = 2100
tcp_wq_max = 10485760

####### UDP Parameters #########
udp4_raw = -1
udp4_raw = 0
#udp4_raw_mtu = 800
# # pmtu_discovery = no
#udp_mtu = 800
# #udp_mtu_try_proto = TCP

####### DNS Parameters #########
dns = no
rev_dns = no
dns_try_ipv6 = no
use_dns_cache = on
dns_cache_del_nonexp = no
dns_cache_del_nonexp = yes
dns_cache_flags = 1
dns_cache_gc_interval = 120
dns_cache_init = 1
dns_cache_init = 0
dns_cache_mem = 1000
dns_cache_negative_ttl = 60
dns_try_naptr = no
Expand All @@ -86,12 +90,12 @@ disable_sctp = yes
####### Modules Section ########
mpath="/usr/lib64/kamailio/modules/:/usr/lib/x86_64-linux-gnu/kamailio/modules/"

######## Kamailio stun module ########
loadmodule "stun.so"

######## Kamailio outbound module ########
loadmodule "outbound.so"

######## Kamailio stun module ########
loadmodule "stun.so"

######## Kamailio path module ########
loadmodule "path.so"

Expand Down Expand Up @@ -167,6 +171,8 @@ loadmodule "uac_redirect.so"
loadmodule "db_text.so"
modparam("db_text", "db_mode", 1)
modparam("db_text", "emptystring", 1)
modparam("db_text", "default_connection", "KAZOO_DB_URL")


####### Kazoo Integration module ##########
loadmodule "kazoo.so"
Expand Down Expand Up @@ -795,7 +801,6 @@ onsend_route {

event_route[kazoo:mod-init]
{
#!ifdef PRESENCE_ROLE

### use this simple form of binding a listener
### kazoo_subscribe("dialoginfo", "direct", "BLF-QUEUE-MY_HOSTNAME", "BLF-MY_HOSTNAME");
Expand All @@ -814,7 +819,15 @@ event_route[kazoo:mod-init]
###
###

$var(payload) = '{ "exchange" : "dialoginfo" , "type" : "direct", "queue" : "BLF-QUEUE-MY_HOSTNAME", "routing" : "BLF-MY_HOSTNAME", "auto_delete" : 0, "durable" : 1, "no_ack" : 0, "wait_for_consumer_ack" : 1 }';
#!ifdef PRESENCE_ROLE

$var(payload) = "{ 'exchange' : 'presence' , 'queue' : 'presence-dialog-MY_HOSTNAME', 'exclusive' : 0 ,'type' : 'topic', 'routing' : 'dialog.*.*', 'federate' : 1 }";
kazoo_subscribe("$var(payload)");

$var(payload) = "{ 'exchange' : 'presence' , 'queue' : 'presence-presence-MY_HOSTNAME', 'exclusive' : 0 ,'type' : 'topic', 'routing' : 'update.*.*', 'federate' : 1 }";
kazoo_subscribe("$var(payload)");

$var(payload) = "{ 'exchange' : 'presence' , 'queue' : 'presence-mwi-MY_HOSTNAME', 'exclusive' : 0 ,'type' : 'topic', 'routing' : 'mwi_updates.*', 'federate' : 1 }";
kazoo_subscribe("$var(payload)");

#!endif
Expand All @@ -841,16 +854,9 @@ event_route[kazoo:mod-init]

#!endif

#!ifdef PRESENCE_SYNC_ROLE

$var(payload) = "{ 'exchange' : 'presence' , 'type' : 'topic', 'queue' : 'PRESENCE-QUEUE-MY_HOSTNAME', 'routing' : 'sync', 'auto_delete' : 1, 'durable' : 0, 'no_ack' : 1, 'wait_for_consumer_ack' : 0 }";
kazoo_subscribe("$var(payload)");

#!endif

#!ifdef PRESENCE_QUERY_ROLE

$var(payload) = "{ 'exchange' : 'omnipresence' , 'type' : 'topic', 'routing' : 'presence.search_req.*', 'federate' : 1 }";
$var(payload) = "{ 'exchange' : 'presence' , 'type' : 'topic', 'queue' : 'presence-search-MY_HOSTNAME', 'exclusive' : 0, 'routing' : 'presence.search_req.*', 'federate' : 1 }";
kazoo_subscribe("$var(payload)");

#!endif
Expand All @@ -869,13 +875,6 @@ event_route[kazoo:mod-init]

#!endif

#!ifdef PRESENCE_BROADCAST_ROLE

$var(payload) = "{ 'exchange' : 'omnipresence' , 'queue' : 'PRESENCE-BROADCAST-MY_HOSTNAME', 'exclusive' : 0 ,'type' : 'topic', 'routing' : 'presence.update' }";
kazoo_subscribe("$var(payload)");

#!endif

}

event_route[kazoo:consumer-event]
Expand Down
6 changes: 5 additions & 1 deletion kamailio/defs.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,12 @@

####### defs ########

#!ifndef KAZOO_DATA_DIR
#!substdef "!KAZOO_DATA_DIR!/etc/kazoo/kamailio/dbtext!g"
#!endif

#!ifndef KAZOO_DB_URL
#!substdef "!KAZOO_DB_URL!text:///etc/kazoo/kamailio/dbtext!g"
#!substdef "!KAZOO_DB_URL!text://KAZOO_DATA_DIR!g"
#!endif

#!ifndef MAX_WHILE_LOOPS
Expand Down
11 changes: 8 additions & 3 deletions kamailio/fast-pickup-role.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,22 @@ route[FAST_PICKUP_ATTEMPT]
}

if($var(replaced_call_id) != "none") {
xlog("L_INFO", "$ci|log|replaces call-id $var(replaced_call_id)\n");
xlog("L_INFO", "$ci|log|request has replaces call-id $var(replaced_call_id)\n");
$var(amqp_payload_request) = '{"Event-Category" : "call_event" , "Event-Name" : "channel_status_req", "Call-ID" : "' + $var(replaced_call_id) + '", "Active-Only" : true }';
$var(amqp_routing_key) = "call.status_req." + $(var(replaced_call_id){kz.encode});
sl_send_reply("100", "Attempting K query");
sl_send_reply("100", "locating your call");
xlog("L_INFO", "$ci|log|querying cluster for the location of call-id $var(replaced_call_id)\n");
if(kazoo_query("callevt", $var(amqp_routing_key), $var(amqp_payload_request))) {
$du = $(kzR{kz.json,Switch-URL});
if($du != $null) {
xlog("L_INFO", "$ci|log|call-id $var(replaced_call_id) found redirecting call to $du, courtesy of kazoo\n");
xlog("L_INFO", "$ci|log|call-id $var(replaced_call_id) found redirecting call to $du\n");
route(EXTERNAL_TO_INTERNAL_RELAY);
exit();
} else {
remove_hf_re("^Replaces");
}
} else {
remove_hf_re("^Replaces");
}
}

Expand Down
1 change: 0 additions & 1 deletion kamailio/local.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ debug = L_INFO
# # #!trydef REGISTRAR_SYNC_ROLE
# # #!trydef PRESENCE_SYNC_ROLE
# # #!trydef PRESENCE_NOTIFY_SYNC_ROLE
# # #!trydef PRESENCE_BROADCAST_ROLE

################################################################################
## SERVER INFORMATION
Expand Down
Loading

0 comments on commit 10e5707

Please sign in to comment.