Okay... I've been hacking about with a way to handle pre-paid dialout stuff with Asterisk-b2bua and sheer, ugly hacking. I'll explain.
Asterisk-b2bua basically is code that sets the session timer of an asterisk dial session based on a value it pulls out of the radius DB. Now... the trick is, of course, that something has to SET that value for the call, and then you're accessing the radius server without a password to do authentication. Passwordless radius(only authentication -- no authorisation), grabbing its data from a DB, is a bit like grabbing data directly from the DB... but... well... with something in the way.
So... something has to set the session timer based on the price of the call divided into the amount of money a person might have in his account.
As opposed to writing a script to JUST set a session timer (and creating an additional DB store/lookup), I've hacked the b2bua.pl script to skip the radius authentication and hit the DB direct for authentication in a billing DB. From that billing DB, it then grabs the amount of money left in a person's account... then goes through the rate file (which I've converted to a sorted jagged array for optimisation) to determine which prefix is a best match for that call, and grabs the amount per minute that the call costs. It does a quick divide to determine how many minutes that would allow for a call, converts it to seconds, and then sets the session timer based on the seconds available for a call, using the surrounding code of the b2bua.pl script.
At the end of the script, it calculates the time on the call either before the timer expired or after and updates the amount in that person's account accordingly.
SO... that's the logic behind the overall hack. Since I'm barely awake and have been staring at this code for something like 100+ hours now (including time editing the rate file for optimisation), I can barely see what I'm typing, much less see any gaping logical errors I may have made.
Does anyone see any HUGE, insurmountable problems with my idea? Any small, perhaps surmountable problems? Any possible issues I need to watch out for (other than not allowing more than one outgoing PSTN call per account at a time)?
If you do, I'd love to hear them. Thanks.
N.