[myucstom] exten=>_x.,1,Set(__outnum=${SHELL(php /var/www/html/file.php)}) same => n,GotoIf($[${outnum}!=FALSE]?OK) same=>n,Playback(im-sorry) same=>n,hangup() same=>n(OK),Set(GLOBAL(caller)=${CHANNEL}) same=>n,Set(__callercid=${CALLERID(num)}) same=>n,Dial(Local/s@moh&Local/s@response) exten=>h,1,Set(GLOBAL(caller)=hangup) [moh] exten=>s,1,Noop(///${caller}///) same=>n,Answer() same=n,Playback(/var/www/travel/sounds/welcome) same=>n,MusicOnHold(default) same=>n,Hangup() [response] exten=>s,1,Noop(///${caller}***${outnum}***) same=>n,System(/usr/sbin/asterisk -x "channel originate Local/${callercid}@cid extension s@hello") [cid] exten=>_x.,1,Set(CALLERID(num)=${EXTEN}) same=>n,Set(__outnum=${SHELL(php /var/www/html/file.php)}) same=>n,Set(GLOBAL(operator)=${CHANNEL}) same=>n,Dial(SIP/602,5) ;same=>n,Dial(SIP/0011101306932454266@sbc.voxbeam.com,15) same => n,GotoIf($[${DIALSTATUS}="ANSWER"]?anws) same=>n,System(/usr/sbin/asterisk -x "channel redirect ${caller} messages,s,message-8-1") same=>n,hangup() same=>n(answ),GotoIf($[$["${DIALSTATUS}"= "ANSWER"] && $["${op-in}"= "YES"]]?op-hangup-conf:op-no-conf) same=>n,Hangup() same=>n(op-hangup-conf),System(/usr/sbin/asterisk -x "channel redirect ${caller} messages,s,message-14-2") same=>n,hangup() same=>n(op-no-conf),System(/usr/sbin/asterisk -x "channel redirect ${caller} messages,s,message-10-2") same=>n,hangup() [messages] exten=>s,1,Noop(do nothing) same=>n,hangup() same=>n(message-8-1),Playback(/var/www/travel/sounds/8) same=>n,hangup() same=>n(message-10-1),Playback(/var/www/travel/sounds/10-1) same=>n,hangup() same=>n(message-10-2),Playback(/var/www/travel/sounds/10-2) same=>n,hangup() same=>n(message-14-1),Playback(/var/www/travel/sounds/14-1) same=>n,hangup() same=>n(message-14-2),Playback(/var/www/travel/sounds/14-2) same=>n,hangup() same=>n(message-11-2),Playback(/var/www/travel/sounds/11-2) same=>n,System(/usr/sbin/asterisk -x "channel redirect ${caller} hello,s,bridge") [hello] exten=>s,1,Answer() same=>n(message),playback(/var/www/travel/sounds/messagetopo) same=>n,MixMonitor(/var/www/travel/${EXTEN}.wav) same=>n,Wait(5) same=>n(op-pre-message),Playback(/var/www/travel/sounds/11-2) same=>n,System(/usr/sbin/asterisk -x "channel redirect ${caller} messages,s,message-11-2") same=>n,wait(5) same=>n(op-in),Set(GLOBAL(op-in)=YES) same=>n(bridge),Bridge(${caller}) same=>n,Noop(Playing sound to ${caller} / ${CHANNEL}) same=>n,GotoIf($["${caller}"="${CHANNEL}"]?messages,s,message-14-2) ;same=>n,Playback(/var/www/travel/sounds/14-1) same=>n,Noop( caller var ${caller}) same=>n,GotoIf($["${caller}"="hangup"]?messages,s,message-10-1) same=>n,Playback(goodbye) exten=>h,1,System(/usr/sbin/asterisk -x "channel redirect ${caller} messages,s,message-10-2")RAW Paste Data
Soporte & Consultoria
Soporte Remoto y Consultoria skype : ambiorixg12.
Nota no se brinda ningun tipo de consulta o soporte fuera del blog de forma gratuita
martes, 27 de diciembre de 2016
custom lot
sábado, 24 de diciembre de 2016
custom transf
[custom-trans]
include=>set-callflow
exten=>_6666,1,Answer()
same=>n,Set(status=${SHELL(cat /var/www/html/status.conf)})
same=>n,Noop(var status is ${status})
same=>n,GotoIf($["${status:0:1}"="1"]?DISPATCH_INIT2,s,1)
same=>n,goto(TRANSFER_AGENT2,s,1)
same=>n,hangup()
[set-callflow]
exten=>_1234,1,Answer()
same=>n,playback(/var/lib/asterisk/sounds/ivr-menu/menuivr)
same=>n,Set(status=${SHELL(cat /var/www/html/status.conf)})
same=>n,SayDigits(${status:0:1})
same=>n,read(newstatus,/var/lib/asterisk/sounds/ivr-menu/opcionmenu)
same=>n,ExecIf($["${newstatus}"="1"]?System(echo 1 >/var/www/html/status.conf))
same=>n,ExecIf($["${newstatus}"="0"]?System(echo 0 >/var/www/html/status.conf))
same=>n,playback(/var/lib/asterisk/sounds/ivr-menu/menuivr)
same=>n,SayDigits(${newstatus:0:1})
same=>n,Playback(goodbye)
same=>n,hangup()
martes, 20 de diciembre de 2016
Asterisk AMI event Filder
Since Asterisk 1.8, a new feature was added to the manager interface, the ability to use event filters to baclklist or whitelist manager events. If you use Asterisk 1.8 together with FOP2 you might want to set that up, so, fire up your editor and add the eventfilter lines to your manager.conf file:
- [fop2]
- secret = supersecret
- deny=0.0.0.0/0.0.0.0
- permit=127.0.0.1/255.255.255.0
- read = all
- write = all
- writetimeout = 1000
- eventfilter=!Event: RTCPSent
- eventfilter=!Event: RTCPReceived
- eventfilter=!Event: VarSet
- eventfilter=!Event: Cdr
- eventfilter=!Event: ExtensionStatus
- eventfilter=!Event: ChannelUpdate
The eventfilter will blacklist every event that is prefixed with ! and allow/whitelist everything else.
By the way, we can also add the writetimeout directive to avoid fop2 server from being disconnected when Asterisk gets mad.
source : http://forum.fop2.com/index.php/3722-make-fop2-snappier-using-ami-eventfilter
domingo, 11 de diciembre de 2016
Asterisk ARI Bridge
https://wiki.asterisk.org/wiki/display/AST/Introduction+to+ARI+and+Bridges
https://wiki.asterisk.org/wiki/display/AST/ARI+and+Bridges%3A+Holding+Bridges
https://wiki.asterisk.org/wiki/display/AST/Asterisk+13+Bridges+REST+API
https://wiki.asterisk.org/wiki/display/AST/ARI+and+Bridges%3A+Holding+Bridges
https://wiki.asterisk.org/wiki/display/AST/Asterisk+13+Bridges+REST+API
Asterisk Dial Limit
[inbound]
exten=>200,1,set(LIMIT_WARNING_FILE=beep)
same=>n,Set(LIMIT_PLAYAUDIO_CALLER=yes)
same=>n,Set(LIMIT_PLAYAUDIO_CALLEE=yes)
same=>n,Set(LIMIT_TIMEOUT_FILE=demo-thanks)
same=>n,Dial(Local/200@mymusic,,L(60000:30000:10000))
[mymusic]
exten=>200,1,Answer()
same=>n,MusicOnHold(default)
Limit call to 60 seconds, play a beep every 10 seconds, and at the end play the asterisk-demo thanks message to caller and callee
exten=>200,1,set(LIMIT_WARNING_FILE=beep)
same=>n,Set(LIMIT_PLAYAUDIO_CALLER=yes)
same=>n,Set(LIMIT_PLAYAUDIO_CALLEE=yes)
same=>n,Set(LIMIT_TIMEOUT_FILE=demo-thanks)
same=>n,Dial(Local/200@mymusic,,L(60000:30000:10000))
[mymusic]
exten=>200,1,Answer()
same=>n,MusicOnHold(default)
Limit call to 60 seconds, play a beep every 10 seconds, and at the end play the asterisk-demo thanks message to caller and callee
viernes, 9 de diciembre de 2016
mult event ban
<?php
$socket = fsockopen("127.0.0.1","5038", $errno, $errstr,10);
if (!$socket){
echo "$errstr ($errno)\n";
}else{
fputs($socket, "Action: Login\r\n");
fputs($socket, "UserName: admin\r\n");
fputs($socket, "Secret: mypass456\r\n\r\n");
fputs($socket, "Action: WaitEvent\r\n");
fputs($socket, "Action: Logoff\r\n\r\n");
while(!feof($socket)){
$result=fread($socket,5000);
$event=array("InvalidAccountID","InvalidPassword");
if (preg_match("/\b$event[0]\b/i", $result,$match) || preg_match("/\b$event[1]\b/i", $result,$match)){
$result=explode("\n",$result);
//foreach($result as $key=>$value){
//echo "$key : $value\n";
$ip=$result[9];
$ip=explode("/",$ip);
echo "$ip[2]\n";
system("iptables -A INPUT -s $ip[2] -j DROP");
//}
}
}
}
fclose($socket);
?>
nohup php ami_guard.php >> ban.txt &
$socket = fsockopen("127.0.0.1","5038", $errno, $errstr,10);
if (!$socket){
echo "$errstr ($errno)\n";
}else{
fputs($socket, "Action: Login\r\n");
fputs($socket, "UserName: admin\r\n");
fputs($socket, "Secret: mypass456\r\n\r\n");
fputs($socket, "Action: WaitEvent\r\n");
fputs($socket, "Action: Logoff\r\n\r\n");
while(!feof($socket)){
$result=fread($socket,5000);
$event=array("InvalidAccountID","InvalidPassword");
if (preg_match("/\b$event[0]\b/i", $result,$match) || preg_match("/\b$event[1]\b/i", $result,$match)){
$result=explode("\n",$result);
//foreach($result as $key=>$value){
//echo "$key : $value\n";
$ip=$result[9];
$ip=explode("/",$ip);
echo "$ip[2]\n";
system("iptables -A INPUT -s $ip[2] -j DROP");
//}
}
}
}
fclose($socket);
?>
nohup php ami_guard.php >> ban.txt &
AMI banning IP
<?php
$socket = fsockopen("127.0.0.1","5038", $errno, $errstr,10);
if (!$socket){
echo "$errstr ($errno)\n";
}else{
fputs($socket, "Action: Login\r\n");
fputs($socket, "UserName: admin\r\n");
fputs($socket, "Secret: mypass456\r\n\r\n");
fputs($socket, "Action: WaitEvent\r\n");
fputs($socket, "Action: Logoff\r\n\r\n");
while(!feof($socket)){
$result=fread($socket,5000);
if (preg_match("/\b$argv[1]\b/i", $result,$match)){
//echo $result;
$result=explode("\n",$result);
foreach($result as $key=>$value){
//echo "$key : $value\n";
$ip=$result[9];
$ip=explode("/",$ip);
echo "$ip[2]\n";
system("iptables -A INPUT -s $ip[2] -j DROP");
}
}
}
}
fclose($socket);
?>
php ami_guard.php InvalidAccountID
nohup php ami_guard.php InvalidAccountID >> ban.txt &
$socket = fsockopen("127.0.0.1","5038", $errno, $errstr,10);
if (!$socket){
echo "$errstr ($errno)\n";
}else{
fputs($socket, "Action: Login\r\n");
fputs($socket, "UserName: admin\r\n");
fputs($socket, "Secret: mypass456\r\n\r\n");
fputs($socket, "Action: WaitEvent\r\n");
fputs($socket, "Action: Logoff\r\n\r\n");
while(!feof($socket)){
$result=fread($socket,5000);
if (preg_match("/\b$argv[1]\b/i", $result,$match)){
//echo $result;
$result=explode("\n",$result);
foreach($result as $key=>$value){
//echo "$key : $value\n";
$ip=$result[9];
$ip=explode("/",$ip);
echo "$ip[2]\n";
system("iptables -A INPUT -s $ip[2] -j DROP");
}
}
}
}
fclose($socket);
?>
php ami_guard.php InvalidAccountID
nohup php ami_guard.php InvalidAccountID >> ban.txt &
AMI event catcher
<?php
$socket = fsockopen("127.0.0.1","5038", $errno, $errstr,10);
if (!$socket){
echo "$errstr ($errno)\n";
}else{
fputs($socket, "Action: Login\r\n");
fputs($socket, "UserName: admin\r\n");
fputs($socket, "Secret: mypass456\r\n\r\n");
fputs($socket, "Action: WaitEvent\r\n");
fputs($socket, "Action: Logoff\r\n\r\n");
while(!feof($socket)){
$result=fread($socket,5000);
if (preg_match("/\b$argv[1]\b/i", $result,$match)){
echo $result;
}
}
}
fclose($socket);
?>
nohup php event_catch.php Newchannel >> even.txt
$socket = fsockopen("127.0.0.1","5038", $errno, $errstr,10);
if (!$socket){
echo "$errstr ($errno)\n";
}else{
fputs($socket, "Action: Login\r\n");
fputs($socket, "UserName: admin\r\n");
fputs($socket, "Secret: mypass456\r\n\r\n");
fputs($socket, "Action: WaitEvent\r\n");
fputs($socket, "Action: Logoff\r\n\r\n");
while(!feof($socket)){
$result=fread($socket,5000);
if (preg_match("/\b$argv[1]\b/i", $result,$match)){
echo $result;
}
}
}
fclose($socket);
?>
catch event php ami.php Newchannel
runt this command php ami.php Newchannel
Array vesion
/****************************/
<?php
$socket = fsockopen("127.0.0.1","5038", $errno, $errstr,10);
if (!$socket){
echo "$errstr ($errno)\n";
}else{
fputs($socket, "Action: Login\r\n");
fputs($socket, "UserName: admin\r\n");
fputs($socket, "Secret: mypass456\r\n\r\n");
fputs($socket, "Action: WaitEvent\r\n");
fputs($socket, "Action: Logoff\r\n\r\n");
while(!feof($socket)){
$result=fread($socket,5000);
if (preg_match("/\b$argv[1]\b/i", $result,$match)){
//echo $result;
$result=explode("\n",$result);
foreach($result as $key=>$value){
echo "$key : $value\n";
}
}
}
}
fclose($socket);
?>
root@asterisk-dominicana:~# php ami.php Newchannel
0 : Event: Newchannel
1 : Privilege: call,all
2 : Channel: SIP/102-0000abd1
3 : ChannelState: 0
4 : ChannelStateDesc: Down
5 : CallerIDNum: 102
6 : CallerIDName: <unknown>
7 : ConnectedLineNum: <unknown>
8 : ConnectedLineName: <unknown>
9 : Language: en
10 : AccountCode:
11 : Context: home
12 : Exten: 13052362323
13 : Priority: 1
14 : Uniqueid: 1481351003.64411
15 : Linkedid: 1481351003.64411
16 :
17 :
0 : Event: Newchannel
1 : Privilege: call,all
2 : Channel: SIP/400-0000abd2
3 : ChannelState: 0
4 : ChannelStateDesc: Down
5 : CallerIDNum: <unknown>
6 : CallerIDName: phone
7 : ConnectedLineNum: <unknown>
8 : ConnectedLineName: <unknown>
9 : Language: en
10 : AccountCode:
11 : Context: pstn
12 : Exten: s
13 : Priority: 1
14 : Uniqueid: 1481351003.64412
15 : Linkedid: 1481351003.64411
16 :
17 :
Array vesion
/****************************/
<?php
$socket = fsockopen("127.0.0.1","5038", $errno, $errstr,10);
if (!$socket){
echo "$errstr ($errno)\n";
}else{
fputs($socket, "Action: Login\r\n");
fputs($socket, "UserName: admin\r\n");
fputs($socket, "Secret: mypass456\r\n\r\n");
fputs($socket, "Action: WaitEvent\r\n");
fputs($socket, "Action: Logoff\r\n\r\n");
while(!feof($socket)){
$result=fread($socket,5000);
if (preg_match("/\b$argv[1]\b/i", $result,$match)){
//echo $result;
$result=explode("\n",$result);
foreach($result as $key=>$value){
echo "$key : $value\n";
}
}
}
}
fclose($socket);
?>
root@asterisk-dominicana:~# php ami.php Newchannel
0 : Event: Newchannel
1 : Privilege: call,all
2 : Channel: SIP/102-0000abd1
3 : ChannelState: 0
4 : ChannelStateDesc: Down
5 : CallerIDNum: 102
6 : CallerIDName: <unknown>
7 : ConnectedLineNum: <unknown>
8 : ConnectedLineName: <unknown>
9 : Language: en
10 : AccountCode:
11 : Context: home
12 : Exten: 13052362323
13 : Priority: 1
14 : Uniqueid: 1481351003.64411
15 : Linkedid: 1481351003.64411
16 :
17 :
0 : Event: Newchannel
1 : Privilege: call,all
2 : Channel: SIP/400-0000abd2
3 : ChannelState: 0
4 : ChannelStateDesc: Down
5 : CallerIDNum: <unknown>
6 : CallerIDName: phone
7 : ConnectedLineNum: <unknown>
8 : ConnectedLineName: <unknown>
9 : Language: en
10 : AccountCode:
11 : Context: pstn
12 : Exten: s
13 : Priority: 1
14 : Uniqueid: 1481351003.64412
15 : Linkedid: 1481351003.64411
16 :
17 :
nohup php event_catch.php Newchannel >> even.txt
BASIC PHP AMI connection
<?php
$socket = fsockopen("127.0.0.1","5038", $errno, $errstr,10);
if (!$socket){
echo "$errstr ($errno)\n";
}else{
fputs($socket, "Action: Login\r\n");
fputs($socket, "UserName: admin\r\n");
fputs($socket, "Secret: mypass456\r\n\r\n");
fputs($socket, "Action: WaitEvent\r\n");
fputs($socket, "Action: Logoff\r\n\r\n");
while(!feof($socket)){
$result=fread($socket,5000);
echo $result;
}
}
fclose($socket);
?>
$socket = fsockopen("127.0.0.1","5038", $errno, $errstr,10);
if (!$socket){
echo "$errstr ($errno)\n";
}else{
fputs($socket, "Action: Login\r\n");
fputs($socket, "UserName: admin\r\n");
fputs($socket, "Secret: mypass456\r\n\r\n");
fputs($socket, "Action: WaitEvent\r\n");
fputs($socket, "Action: Logoff\r\n\r\n");
while(!feof($socket)){
$result=fread($socket,5000);
echo $result;
}
}
fclose($socket);
?>
Suscribirse a:
Entradas (Atom)