Certainly app_lua (or any scripting language plugin, or KEMI, or system call) can do this, but that quickly falls out of scope of “Kamailio doing it” and into having an external program do it.  Most modules that would have functionality that requires “look up criteria based on a value” rely on a database. The specific request (grab a random entry based on criteria) is a combination of easily achieved with an order by some type of DB and not a common enough scenario for someone to have build a dediated module.

 

As far as speed goes, I’m not really sure what you could make that would be faster than pulling a random member out of redis.

 

Kaufman

 

 

From: Ali Taher <ataher@vanrise.com>
Sent: Thursday, August 3, 2023 1:32 AM
To: Kamailio (SER) - Users Mailing List <sr-users@lists.kamailio.org>
Subject: [SR-Users] Re: change A number using a pool of numbers

 

CAUTION: This email originated from outside the organization. Do not click links or open attachments unless you recognize the sender and know the content is safe.

 

Thanks Kaufman,

 

Relying on DB is of course one way to do it, but I thought that there are some modules that could be used and are faster, like app_lua but I’m not sure if it can be used to select a number randomly from a pool saved in a file.

 

Regards,

 

 

From: Kaufman <bkaufman@bcmone.com>
Sent: Wednesday, August 2, 2023 7:36 PM
To: Kamailio (SER) - Users Mailing List <sr-users@lists.kamailio.org>
Subject: [SR-Users] Re: change A number using a pool of numbers

 

There’s functionally two parts to this question:

 

  1. How to change a number
  2. How to select a random number

 

For selection of the number it’s probably easiest to rely on DB lookup. With one column as the original number and another column as the possible replacement numbers, then just select with an order by random to get the replacement number.

 

As far as changing the number, it can depend on specifically what number you’re trying to change.  The RURI can be changed just by setting $rU.  Values in the To: or From: headers should be changed with the functions from the UAC module so that replies can have the original values restored.  For other miscellaneous headers like P-Asserted-Identity, just remove the old header and append a new one.

 

Regards,

Kaufman

 

 

From: Ali Taher <ataher@vanrise.com>
Sent: Wednesday, August 2, 2023 1:20 AM
To: Kamailio (SER) - Users Mailing List <sr-users@lists.kamailio.org>
Subject: [SR-Users] change A number using a pool of numbers

 

CAUTION: This email originated from outside the organization. Do not click links or open attachments unless you recognize the sender and know the content is safe.

 

Hello,

 

I’m looking to change the A number (from number) to a number selected randomly from a pool of existing numbers (hundreds) and then relay the call to a certain gateway.

 

What is the best and more efficient way to do it in kamailio?

 

Thanks in advance