1. Ядро биллинга должно содержать в себе всю бизнес-логику, и строить его надо на DB с поддержкой необходимых для этого возможностей, таких как views, stored procedures, triggers. Предлагаю взять PostgreSQL. Комментарии плиз.
2. Мы должны взять за основу таблицы, в которых астериск хранит свои конфиги, и вокруг них все выстроить. Давайте обсудим что брать, res_config или real time?
В res_config конфиг файлы тупо перенесены в базу.
create table ast_config (
id bigint primary key not null auto_increment,
cat_metric int not null default 0,
var_metric int not null default 0,
commented int not null default 0,
filename varchar(128) not null,
category varchar(128) not null default 'default',
var_name varchar(128) not null,
var_val varchar(128) not null
);
Вот пример того что там есть:
.............
22737 | 0 | 12 | 0 | iax.conf | general | jittershrinkrate | 1
22738 | 0 | 13 | 0 | iax.conf | general | runkfreq | 20
22739 | 0 | 14 | 0 | iax.conf | general | authdebug | yes
22740 | 0 | 15 | 0 | iax.conf | general | tos | lowdelay
22787 | 3 | 0 | 0 | sip.conf | 10001 | type | friend
22788 | 3 | 1 | 0 | sip.conf | 10001 | host | dynamic
22789 | 3 | 2 | 0 | sip.conf | 10001 | secret | superman
22790 | 3 | 3 | 0 | sip.conf | 10001 | nat | yes
22793 | 7 | 0 | 0 | voicemail.conf |
22794 | 0 | 0 | 0 | sip.conf | general | context | default
22795 | 0 | 1 | 1 | sip.conf | general | astappcomment | recordhistory=yes
...........
В Real time интереснее, там все по полям.
mysql> describe iax_buddies;
+-------------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-------------+--------------+------+-----+---------+----------------+
| id | int(11) | | PRI | NULL | auto_increment |
| name | varchar(30) | | UNI | | |
| username | varchar(30) | YES | | NULL | |
| type | varchar(6) | | | | |
| secret | varchar(50) | YES | | NULL | |
| md5secret | varchar(32) | YES | | NULL | |
| dbsecret | varchar(100) | YES | | NULL | |
| notransfer | varchar(10) | YES | | NULL | |
| inkeys | varchar(100) | YES | | NULL | |
| auth | varchar(100) | YES | | NULL | |
| accountcode | varchar(100) | YES | | NULL | |
| amaflags | varchar(100) | YES | | NULL | |
| callerid | varchar(100) | YES | | NULL | |
| context | varchar(100) | YES | | NULL | |
| defaultip | varchar(15) | YES | | NULL | |
| host | varchar(31) | | | dynamic | |
| language | varchar(5) | YES | | NULL | |
| mailbox | varchar(50) | YES | | NULL | |
| permit | varchar(95) | YES | | NULL | |
| deny | varchar(95) | YES | | NULL | |
| qualify | varchar(4) | YES | | NULL | |
| disallow | varchar(100) | YES | | NULL | |
| allow | varchar(100) | YES | | NULL | |
| ipaddr | varchar(15) | YES | | NULL | |
| port | int(11) | YES | | 0 | |
| regseconds | int(11) | YES | | 0 | |
| comment | text | | | | |
| tech_prefix | varchar(20) | | | | |
+-------------+--------------+------+-----+---------+----------------+
28 rows in set (0.00 sec)
+----+-------------+----------+------+--------+-----------+----------+------------+--------+------+-------------+----------+----------+---------+-----------+---------+----------+---------+--------+------+---------+----------+-------+---------+------+------------+-------------------+-------------+
| id | name | username | type | secret | md5secret | dbsecret | notransfer | inkeys | auth | accountcode | amaflags | callerid | context | defaultip | host | language | mailbox | permit | deny | qualify | disallow | allow | ipaddr | port | regseconds | comment | tech_prefix |
+----+-------------+----------+------+--------+-----------+----------+------------+--------+------+-------------+----------+----------+---------+-----------+---------+----------+---------+--------+------+---------+----------+-------+---------+------+------------+-------------------+-------------+
| 2 | iaxprovider | username | IAX2 | secret | | | | | | | | | | | 3.3.3.3 | | | | | | | | 3.3.3.3 | 4569 | 0 | test iax provider | |
+----+-------------+----------+------+--------+-----------+----------+------------+--------+------+-------------+----------+----------+---------+-----------+---------+----------+---------+--------+------+---------+----------+-------+---------+------+------------+-------------------+-------------+
1 row in set (0.02 sec)
Данные по диалплану совсем другие:
mysql> describe extensions_table;
+----------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+----------+--------------+------+-----+---------+----------------+
| id | int(11) | | MUL | NULL | auto_increment |
| context | varchar(20) | | | | |
| exten | varchar(20) | | | | |
| priority | tinyint(4) | | | 0 | |
| app | varchar(20) | | | | |
| appdata | varchar(128) | | | | |
+----------+--------------+------+-----+---------+----------------+
6 rows in set (0.00 sec)