Uncommon? Call Forwarding Rule - asterisk

I'm looking to have my FreePBX server forward incoming calls to a phone number that it pulls from a mysql database. The only thing unique about how I need it to forward calls is that there will be multiple numbers located in the database, and I need my PBX to choose one of these numbers purely at random and forward the call there. Is there a native function in FreePBX or Asterisk that allows for pulling a number at random from a database and forwarding the call there? Help is much appreciated

There are no module like that. You can write it or ask someone write it.
You also can use extension with type-> custom and dialline like s#special-dial. After that put in context special-dial into file extensions_custom.conf which will access database.
http://www.voip-info.org/wiki/view/Asterisk+config+extensions.conf
http://www.voip-info.org/wiki/view/Asterisk+func+func_odbc

Related

How to execute code before making a call on Asterisk

I have an asterisk pbx server. I’m new to asterisk, I know there are dial plans extensions groups etc.
My goal is to handle a dial event do some checks then decide whether to let the call go through or not.
I read about ARI AGI AMI and dial plan but I got confused and don’t know how to proceed.
I just want to execute code (call an API for example) when any number is dialed, and drop the call or let it through according to that.
I know if I do more research I can get something working, but honestly I don’t have time. I just need to know where to look.
So I solved it. In case anyone needs this, here's what I did.
I used AsterNET fastAGI and created my service script, which does whatever checks I need and calls HangUp() when needed, else just returns and lets the call go through.
Then I called the fastAGI script in the dial plan and it's working perfectly.

Why is dynamic real time not recommended as per asterisk?

In extconfig.conf they have mentioned that
"However, note that using dynamic realtime extensions is not recommended anymore as a best practice; instead, you should consider writing a static dialplan with proper data abstraction via a tool like func_odbc."
1) Why asterisk is not recommending dynamic realtime extensions?
2) How to do static dialplan with data abstraction using tool liek func_odbc?
My requirement is having have more extensions (in this case mobile number) coming up, how can I dynamically add them to sip.conf and get it registered to the SIP server
There are some issues with dynamic realtime
Most important issue is dialplan.
When/if you use EXACT dialplan like full number match - it work ok. But when you use pattern, it search for pattern in context. To do that it request all records in this context from db EVERY time when you access dialplan. That is really bad, but no easy way fix it. For example you have dialplan of 10 lines for pattern _011. and enother patterns/numbers in same dialplan, overal number of lines 1000. You call 011123456788, it request priority 1 line(db do 1000 rows check), after that priority 2(db do 1000 rows check). So you got 10x1000=10000 db rows for EVERY new call.
If you want dynamic dialplan with hi-load, use db config storage (for dialplan change,reload it for example once every 10 minutes) and check in extension/dialplan for features using func_odbc. That way you have much more control over sql query. Sure that require you understand mysql and able build queries, but no other way for any dynamic pbx with more then 10-20 calls.
sippeers realtime is other thing. It have issues with db update with enabled peer update, or not update peer info if cache enabled. You just have live with that.

Whitelisting Problems?

I have a huge issue that has to do with whitelisting. I have been doing C++ for about 6 months now and I can't seem to figure out how to pinpoint my targets to limit who can open and use my application with a whitelist.
For example, if the user is not on the whitelist the program would tell them by the way it loads. I would like to see this done with ID's if specific ID matches with the whitelist then that person can use my program.
I have tried doing target drawbacks such as getting IP's, but doing this is so vulnerable if the IP is changed. Also, multiple programs could be opened up on different IDs on that IP, which I don't want.
Sorry if this is very confusing I have just been STRUGGLING with this whitelist I have less hair than I did before I started making the whitelist.
Thanks if you can help, tried to explain the best I could! :)
The general strategy is pretty simple.
First, specify what criteria a user should meet to be on the whitelist.
Second, specify how data about users on the whitelist will be stored.
Third, when the program starts, gather information about the user - when the program starts - that can be compared against the criteria on the whitelist.
Fourth, when comparing data about the user with stored whitelist data, start by assuming the user is NOT on the whitelist and only permit access if a match is found. If there are multiple criteria, you need to decide how to combine them to find a match (e.g. restrict a user to a specific IP, allow a user only if using an IP in a range - which will prevent a user starting the program from home, etc etc)
Fifth, take steps to ensure your program can access the stored whitelist data, but users cannot modify it.
There are many ways to target specific users. First, I need some extract information.. How can you identify a single user ? Your program should be a connection toward any server ? In that case, your user should provide an id and a password or it's a anonymous connection ?

"select" in Racket

I want to write an event loop single threaded web server to deal with each request in Racket.
I see there are select method in unix that I can call,
Is there anything similar in Racket API that I can call? or I should write my own select method which is to polling the ready fds?
Thanks in advance!
Apologies if I'm misunderstanding your question, but it sounds like you'll probably want to use tcp-listen on certain ports; success here will create input ports. In order to synchronize on multiple open input ports, check out "synchronizable events"; you can use 'sync' on a whole bunch of open ports simultaneously.
I would be remiss if I failed to add that there's a complete web server included with Racket; I'm assuming that you have your own reasons for wanting to re-implement this.

Determining the set of message destinations at runtime in BizTalk application

I’m a complete newbie at BizTalk and I need to create a BizTalk 2006 application which broadcasts messages in a specific way. I’m not asking for a complete solution, but for advise and guidelines, which capabilities of BizTalk I should use.
There’s a message source, for simplicity, say, a directory where the user adds files to publish them. There are several subscribers, each having a directory to receive published files. The number of subscribers can vary in the course of exploitation of the program. There are also some rules which determine if a particular subscriber needs to receive a particular file, based on the filename. For example, each subscriber has a pattern or mask of filename which files they receives must match. Those rules (for example, patterns) can change in time as well.
I don’t know how to do this. Create a set of send ports at runtime, each for each destination? Is it possible? Use one port changing its binding? Would it work correctly with concurrent sendings? Are there other ways?
EDIT
I realized my question may be to obscure and general to prefer one answer over another to accept. So I just upvoted them.
You could look at using dynamic send ports to achieve this - if your subscribers are truly dynamic. This introduces a bit of complexity since you'll need to use an orchestration to configure the send port's properties based on your rules.
If you can, try and remove the complexity. If you know that you don't need to be truly dynamic when adding subscribers (i.e. a subscriber and it's rules can be configured one time only) and you have a manageable number of subscribers then I would suggest configuring each subscriber using it's own send port and use a filter to create subscriptions based on message context properties. The beauty of this approach is that you don't need to create and deploy an orchestration and this becomes a highly performant and scalable solution.
If the changes to the destination are going to be frequent, you are right in seeking a more dynamic solution. One nice solution is using dynamic send ports and the Business Rules Engine. You create rule set for the messages you are receving. This could be based on a destination property or customer ID in the message. Using these facts, the rules engine can return a bunch of information like file mask, server name, ip address of deleiver server, etc. You can thenuse this information to configure the dynamic send in the orchestration. The real nice thing here is that you can update the rule set in the rules engine without redeploying the whole solution. As a newb, these are some advanced concepts, but not as diificult as you may think.
For a simpler solution, you might want to look at setting the FILE Send adapters properties via it's Propery Schema (ie. File name, Directory, etc.). You could pull these values from a database with a helper class inside an expresison shape. On each message ogig out, use the property shcema to set where the message will be sent and named. This way, you just update the database as things change.
Good Luck!

Resources