What is it actually about?
Working in a large company, or in a medium-sized company with a small number of branches, more and more often you think about optimizing resources, simplifying administration and standardizing everything and everyone.
We have, for example, several (well, not a few) of the same type of branch offices for 10-100 employees. Telephony can be organized in different ways:
Take a ready-made solution in the provider's cloud
Install your own mini-server and asterisk on each branch
Make a single asterisk in the center
The first 2 options, of course, take place, but they have enough disadvantages. This is not the convenience of maintaining several small instances, it is also a financial issue and some other points.
, , , , . , , . , , 3 , 6 . - 6 ("6 ! !"), 6 .
, - SIP . , -, .
, . , - , -. . ? , - , , - .
18.1 PJSIP .
? , . - . , " ".
(Numbers), . , ?
, (Number)
- ? (Secret)
- , , (domain)
CID -
: , DTMF, -
Flags - -, . , , .
, . ? , , . - , , VIEW. , , . 3 :
Endpoints (ps_endpoints)
(ps_auths)
Aors (ps_aors)
, , "" PJSIP. SQL:
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET NAMES utf8 */;
/*!50503 SET NAMES utf8mb4 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
CREATE ALGORITHM=UNDEFINED SQL SECURITY DEFINER VIEW `ps_aors` AS select concat(`Numbers`.`Number`,if(`Numbers`.`domain` is not null,concat('@',`Numbers`.`domain`),'')) AS `id`,180 AS `default_expiration`,2 AS `max_contacts`,30 AS `minimum_expiration`,'yes' AS `remove_existing`,'' AS `contact` from `Numbers`;
CREATE ALGORITHM=UNDEFINED SQL SECURITY DEFINER VIEW `ps_auths` AS select concat(`Numbers`.`Number`,if(`Numbers`.`domain` is not null,concat('@',`Numbers`.`domain`),'')) AS `id`,'userpass' AS `auth_type`,3600 AS `nonce_lifetime`,`Numbers`.`Secret` AS `password`,`Numbers`.`Number` AS `username`,`Numbers`.`domain` AS `realm` from `Numbers` where `Numbers`.`Secret` <> '';
CREATE ALGORITHM=UNDEFINED SQL SECURITY DEFINER VIEW `ps_endpoints` AS select concat(`Numbers`.`Number`,if(`Numbers`.`domain` is not null,concat('@',`Numbers`.`domain`),'')) AS `id`,concat('transport-',lcase(`Numbers`.`Protocol`)) AS `transport`,concat(`Numbers`.`Number`,if(`Numbers`.`domain` is not null,concat('@',`Numbers`.`domain`),'')) AS `aors`,if(`Numbers`.`Secret` <> '',concat(`Numbers`.`Number`,if(`Numbers`.`domain` is not null,concat('@',`Numbers`.`domain`),'')),NULL) AS `auth`,'SIP' AS `context`,'all' AS `disallow`,concat('ulaw,alaw,opus',if(find_in_set('Video',`Numbers`.`Flags`),',h263,h261,h263p,h264','')) AS `allow`,concat(`Numbers`.`Number`,if(`Numbers`.`domain` is not null,concat('@',`Numbers`.`domain`),'')) AS `outbound_auth`,concat(`Numbers`.`CID`,' <',`Numbers`.`Number`,'>') AS `callerid`,if(`Numbers`.`Protocol` = 'TLS','sdes','no') AS `media_encryption`,`Numbers`.`PickupGroup` AS `named_pickup_group`,2 AS `device_state_busy_at`,concat('vRecord=',if(find_in_set('Record',`Numbers`.`Flags`) > 0,'yes','no'),';','vRussia=',if(find_in_set('Russia',`Numbers`.`Flags`) > 0,'yes','no'),';','vAbroad=',if(find_in_set('Abroad',`Numbers`.`Flags`) > 0,'yes','no'),';','vVoicemail=',if(find_in_set('Voicemail',`Numbers`.`Flags`) > 0,'yes','no'),';','vFilterCID=no') AS `set_var`,`Numbers`.`NumberID` AS `callerid_tag`,'username,auth_username,ip' AS `identify_by` from `Numbers`;
/*!40101 SET SQL_MODE=IFNULL(@OLD_SQL_MODE, '') */;
/*!40014 SET FOREIGN_KEY_CHECKS=IF(@OLD_FOREIGN_KEY_CHECKS IS NULL, 1, @OLD_FOREIGN_KEY_CHECKS) */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
. - - "" "":
, 5 . , . , .
, 3 , , , , , 101, 102, "" 007 ..
, Numbers .
Numbers:
, " " , , .
ps_endpoints
, - Numbers.
ps_auth
ps_aors
, . , Numbers, .
, . - id. 5 , - . 3 @ . , , - .
. , . AOR endpointa , .. @, . , (id) , AOR . . - AOR , . , .
, , .
pjsip.conf
, .
disable multi domain
, no. , . - . , , yes. 2 . .
endpoint identifier order
, , . = ip,username. , , .. IP . , username, endpoint .
, .
res config mysql.conf
, - :
extconfig.conf
, .
ps_contacts , astdb.
Spoiler
sorcery.conf
. , , .
.
, ?
, endpoint :
, . " " . " " .
, . .., 5 :
Dial(PJSIP/19960)
3
Dial(PJSIP/123@test3)
, , .
?
Microsip, :
101 . ?
PS:
- .
- , , . , .
domains:
domain (VARCHAR) | code (VARCHAR)
We fill, for example, like this:
test2 | 01
test3 | 02
Of course, you can take any branch code - even 1 character. We are determined with access to branches. For example, I have access to the "city" in 9, and I will take 8 to the branches. You take what is convenient for you. At least * (asterisk).
Link the domains table with the domains identifier in extconfig.conf . We write a dialplan:
exten => _8XXXXX,1,NoOp(Call from ${CALLERID(all)} to filial ${EXTEN:1:2})
same => n, Set(domain=${REALTIME_FIELD(domains,code,${EXTEN:1:2},domain)})
same => n, GotoIF($[ "${domain}" = "" ]?GotoError) ;
same => n, Dial(PJSIP/${EXTEN:3}@${domain})
same => n, Hangip
In total, we dial 801123 on the phone and get to the test2 branch at 123.
To make it easier to administer, you can add another key constraint:
Numbers .domain - FOREIGN KEY -> domains .domain
This will prevent you from losing domains while editing.