Hello,
I am redirecting the agents/reps to their asterisk server based on the hostname which they connect, and, i wonder if it's possible to read from db instead of the file cause it's getting big ;)
# Dispatch requests route[DISPATCH] { switch ($fd){ case "oro.streamlinepbx.nl": if (!ds_select_dst("1", "4")) { send_reply(503, "Service Unavailable $fd"); exit; } break; case "oro3.streamlinepbx.nl": if (!ds_select_dst("2", "4")) { send_reply(503, "Service Unavailable $fd"); exit; } break; ............ default: log("unknow destination?"); send_reply(503, "No service defined"); xlog("--- SCRIPT: going to <$ru> via <$du> ...Exiting"); exit; }
xlog("--- SCRIPT: going to <$ru> via <$du> (attrs: $xavp(_dsdst_=>attrs))\n"); t_on_failure("RTF_DISPATCH"); route(RELAY); exit; }
Thanks,
I would say "sqlops" would be helpful for your case. You can fetch any variable from db with proper query.
Regards EU.
Get Outlook for Androidhttps://aka.ms/ghei36 ________________________________ From: sr-users sr-users-bounces@lists.kamailio.org on behalf of Mihai Cezar mihai@mokalife.ro Sent: Sunday, December 27, 2020 3:18:49 PM To: Kamailio (SER) - Users Mailing List sr-users@lists.kamailio.org Subject: [SR-Users] Read $fd from mysql?
Hello,
I am redirecting the agents/reps to their asterisk server based on the hostname which they connect, and, i wonder if it's possible to read from db instead of the file cause it's getting big ;)
# Dispatch requests route[DISPATCH] { switch ($fd){ case "oro.streamlinepbx.nlhttp://oro.streamlinepbx.nl": if (!ds_select_dst("1", "4")) { send_reply(503, "Service Unavailable $fd"); exit; } break; case "oro3.streamlinepbx.nlhttp://oro3.streamlinepbx.nl": if (!ds_select_dst("2", "4")) { send_reply(503, "Service Unavailable $fd"); exit; } break; ............ default: log("unknow destination?"); send_reply(503, "No service defined"); xlog("--- SCRIPT: going to <$ru> via <$du> ...Exiting"); exit; }
xlog("--- SCRIPT: going to <$ru> via <$du> (attrs: $xavp(_dsdst_=>attrs))\n"); t_on_failure("RTF_DISPATCH"); route(RELAY); exit; }
Thanks,
Hi,
Have you tried using sqlops?
Something like...
... modparam("sqlops","sqlcon","ca=>dbdriver://username:password@dbhost/dbname") ... sql_query("ca", "select dst_grp from lookup_table where from_domain=$(fd{s.escape.common})”, "ra"); if($dbr(ra=>rows)>0) { ds_select_dst("$dbr(ra=>[0,0])", "4"); } sql_result_free("ra"); ......
Alternatively, you could set up some naptr/srv records for all the from domains and simply relay to those, using dns instead of dispatcher, if you’re not already using them.
Blessings, — Daniel Donoghue
On 27 Dec 2020, at 13:18, Mihai Cezar mihai@mokalife.ro wrote:
Hello,
I am redirecting the agents/reps to their asterisk server based on the hostname which they connect, and, i wonder if it's possible to read from db instead of the file cause it's getting big ;)
# Dispatch requests route[DISPATCH] { switch ($fd){ case "oro.streamlinepbx.nl http://oro.streamlinepbx.nl/": if (!ds_select_dst("1", "4")) { send_reply(503, "Service Unavailable $fd"); exit; } break; case "oro3.streamlinepbx.nl http://oro3.streamlinepbx.nl/": if (!ds_select_dst("2", "4")) { send_reply(503, "Service Unavailable $fd"); exit; } break; ............ default: log("unknow destination?"); send_reply(503, "No service defined"); xlog("--- SCRIPT: going to <$ru> via <$du> ...Exiting"); exit; }
xlog("--- SCRIPT: going to <$ru> via <$du> (attrs: $xavp(_dsdst_=>attrs))\n"); t_on_failure("RTF_DISPATCH"); route(RELAY); exit;
}
Thanks,
Kamailio (SER) - Users Mailing List sr-users@lists.kamailio.org https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
Thanks Daniel, it looks like sqlops was what I needed! Don't know how DNS SRV records can help, as the host from($fd) points to private IP's
On Sun, Dec 27, 2020 at 2:34 PM Daniel Donoghue < daniel.donoghue@freespee.com> wrote:
Hi,
Have you tried using sqlops?
Something like...
... modparam("sqlops","sqlcon","ca=>dbdriver://username:password@dbhost/dbname") ... sql_query("ca", "select dst_grp from lookup_table where from_domain=$(fd{s.escape.common})”, "ra"); if($dbr(ra=>rows)>0) { ds_select_dst("$dbr(ra=>[0,0])", "4"); } sql_result_free("ra"); ......
Alternatively, you could set up some naptr/srv records for all the from domains and simply relay to those, using dns instead of dispatcher, if you’re not already using them.
Blessings, — Daniel Donoghue
On 27 Dec 2020, at 13:18, Mihai Cezar mihai@mokalife.ro wrote:
Hello,
I am redirecting the agents/reps to their asterisk server based on the hostname which they connect, and, i wonder if it's possible to read from db instead of the file cause it's getting big ;)
# Dispatch requests route[DISPATCH] { switch ($fd){ case "oro.streamlinepbx.nl": if (!ds_select_dst("1", "4")) { send_reply(503, "Service Unavailable $fd"); exit; } break; case "oro3.streamlinepbx.nl": if (!ds_select_dst("2", "4")) { send_reply(503, "Service Unavailable $fd"); exit; } break; ............ default: log("unknow destination?"); send_reply(503, "No service defined"); xlog("--- SCRIPT: going to <$ru> via <$du> ...Exiting"); exit; }
xlog("--- SCRIPT: going to <$ru> via <$du> (attrs:
$xavp(_dsdst_=>attrs))\n"); t_on_failure("RTF_DISPATCH"); route(RELAY); exit; }
Thanks,
Kamailio (SER) - Users Mailing List sr-users@lists.kamailio.org https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
Kamailio (SER) - Users Mailing List sr-users@lists.kamailio.org https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users