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

  1. [myucstom]
  2. exten=>_x.,1,Set(__outnum=${SHELL(php /var/www/html/file.php)})
  3. same => n,GotoIf($[${outnum}!=FALSE]?OK)
  4. same=>n,Playback(im-sorry)
  5. same=>n,hangup()
  6. same=>n(OK),Set(GLOBAL(caller)=${CHANNEL})
  7. same=>n,Set(__callercid=${CALLERID(num)})
  8. same=>n,Dial(Local/s@moh&Local/s@response)
  9. exten=>h,1,Set(GLOBAL(caller)=hangup)
  10.  
  11. [moh]
  12. exten=>s,1,Noop(///${caller}///)
  13. same=>n,Answer()
  14. same=n,Playback(/var/www/travel/sounds/welcome)
  15. same=>n,MusicOnHold(default)
  16. same=>n,Hangup()
  17.  
  18. [response]
  19.  exten=>s,1,Noop(///${caller}***${outnum}***)
  20. same=>n,System(/usr/sbin/asterisk -x "channel originate Local/${callercid}@cid extension s@hello")
  21.  
  22.  
  23. [cid]
  24. exten=>_x.,1,Set(CALLERID(num)=${EXTEN})
  25. same=>n,Set(__outnum=${SHELL(php /var/www/html/file.php)})
  26. same=>n,Set(GLOBAL(operator)=${CHANNEL})
  27. same=>n,Dial(SIP/602,5)
  28. ;same=>n,Dial(SIP/0011101306932454266@sbc.voxbeam.com,15)
  29. same => n,GotoIf($[${DIALSTATUS}="ANSWER"]?anws)
  30. same=>n,System(/usr/sbin/asterisk -x "channel redirect ${caller} messages,s,message-8-1")
  31. same=>n,hangup()
  32. same=>n(answ),GotoIf($[$["${DIALSTATUS}"= "ANSWER"] && $["${op-in}"= "YES"]]?op-hangup-conf:op-no-conf)
  33. same=>n,Hangup()
  34. same=>n(op-hangup-conf),System(/usr/sbin/asterisk -x "channel redirect ${caller} messages,s,message-14-2")
  35. same=>n,hangup()
  36. same=>n(op-no-conf),System(/usr/sbin/asterisk -x "channel redirect ${caller} messages,s,message-10-2")
  37. same=>n,hangup()
  38.  
  39. [messages]
  40. exten=>s,1,Noop(do nothing)
  41. same=>n,hangup()
  42.  
  43. same=>n(message-8-1),Playback(/var/www/travel/sounds/8)
  44. same=>n,hangup()
  45. same=>n(message-10-1),Playback(/var/www/travel/sounds/10-1)
  46. same=>n,hangup()
  47.  
  48. same=>n(message-10-2),Playback(/var/www/travel/sounds/10-2)
  49. same=>n,hangup()
  50.  
  51. same=>n(message-14-1),Playback(/var/www/travel/sounds/14-1)
  52. same=>n,hangup()
  53.  
  54. same=>n(message-14-2),Playback(/var/www/travel/sounds/14-2)
  55. same=>n,hangup()
  56.  
  57. same=>n(message-11-2),Playback(/var/www/travel/sounds/11-2)
  58. same=>n,System(/usr/sbin/asterisk -x "channel redirect ${caller} hello,s,bridge")
  59.  
  60. [hello]
  61. exten=>s,1,Answer()
  62. same=>n(message),playback(/var/www/travel/sounds/messagetopo)
  63. same=>n,MixMonitor(/var/www/travel/${EXTEN}.wav)
  64. same=>n,Wait(5)
  65. same=>n(op-pre-message),Playback(/var/www/travel/sounds/11-2)
  66. same=>n,System(/usr/sbin/asterisk -x "channel redirect ${caller} messages,s,message-11-2")
  67. same=>n,wait(5)
  68. same=>n(op-in),Set(GLOBAL(op-in)=YES)
  69. same=>n(bridge),Bridge(${caller})
  70. same=>n,Noop(Playing sound to  ${caller} / ${CHANNEL})
  71. same=>n,GotoIf($["${caller}"="${CHANNEL}"]?messages,s,message-14-2)
  72. ;same=>n,Playback(/var/www/travel/sounds/14-1)
  73. same=>n,Noop( caller var ${caller})
  74. same=>n,GotoIf($["${caller}"="hangup"]?messages,s,message-10-1)
  75. same=>n,Playback(goodbye)
  76. exten=>h,1,System(/usr/sbin/asterisk -x "channel redirect ${caller} messages,s,message-10-2")
RAW Paste Data

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:
  1. [fop2]
  2. secret = supersecret
  3. deny=0.0.0.0/0.0.0.0
  4. permit=127.0.0.1/255.255.255.0
  5. read = all
  6. write = all
  7. writetimeout = 1000
  8. eventfilter=!Event: RTCPSent
  9. eventfilter=!Event: RTCPReceived
  10. eventfilter=!Event: VarSet
  11. eventfilter=!Event: Cdr
  12. eventfilter=!Event: ExtensionStatus
  13. 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

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

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 &

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 &


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);


?>

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 :

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);


?>