Originate from a Label within a Macro - macros

How can I originate a call from a label within a macro?
I know this isn't right, but I'm not sure how to work the call viking line into the origination cmd.
The last two lines of the macro comprise what I want to happen in place of "Local/callviking#...".
[macro-Paginator]
exten => s,1,Answer()
exten => s,n,System(asterisk -rx "channel originate Local/callviking#${MACRO_CONTEXT}/n extension ${ARG1}#soundeffects")
exten => s,n,Hangup()
exten => s,n(callviking),Dial(SIP/100,10,D(${ARG2}))
exten => s,n,Hangup()
[soundeffects]
exten => wakeupbell,1(wakeupbell),Answer()
same => n,Playback(custom/bells/daytimebell)
same => n,Hangup()
The macro is called like this:
[from-internal-custom] ;freepbx custom context
exten => 23333,1,Macro(Paginator,angelusbell,1) ;Angelus Bell
Here is an example of a method that works, except that I want to convert it into a macro so from so I can use the same routine with different dtmf tones (arg2) and soundfiles (arg1)
[AngelusBell]
exten => startbell,1,Answer()
exten => startbell,n, NoOp(Ringing-zee dee bell! ${CHANNEL} dialed: ${MACRO_EXTEN})
exten => startbell,n,System(asterisk -rx "channel originate Local/callviking#AngelusBell/n extension ting#soundeffects")
exten => startbell,n,Hangup()
exten => callviking,1,Dial(SIP/100,10,D(5))
exten => callviking,2,Hangup()

Well, this will work although it isn't very elegant. It's not a macro, but at least its all in one place:
[from-internal-custom] ;freepbx custom context
exten => 21005,1,Goto(Paginator,test,1) ;Test Sound via destination 2005 (is a custom-device-extension so as to be included as a Destination)
[Paginator]
exten => officebell,1,Answer()
exten => officebell,n,System(asterisk -rx "channel originate Local/callviking#${CONTEXT}/n extension ting#soundeffects")
exten => officebell,n,Hangup()
exten => startofficebell,1,Answer()
exten => startofficebell,n,System(asterisk -rx "channel originate Local/callviking1#${CONTEXT}/n extension ting#soundeffects")
exten => startofficebell,n,Hangup()
exten => angelusbell,1,Answer()
exten => angelusbell,n,System(asterisk -rx "channel originate Local/callviking1#${CONTEXT}/n extension ting#soundeffects")
exten => angelusbell,n,Hangup()
exten => test,1,Answer()
exten => test,n,System(asterisk -rx "channel originate Local/callviking1#${CONTEXT}/n extension ting#soundeffects")
exten => test,n,Hangup()
exten => callviking1,1,Dial(SIP/100,10,D(1))
exten => callviking1,n,Hangup()
exten => callviking5,1,Dial(SIP/100,10,D(5))
exten => callviking5,n,Hangup()
;------------------------------------------------------
[soundeffects]
exten => wakeupbell,1(wakeupbell),Answer()
same => n,Playback(custom/bells/daytimebell)
same => n,Hangup()

Related

Check for secure connection via proxy using LWP::UserAgent and HTTP::Request

Years ago I write some Perl code using LWP::UserAgent and HTTP::Request.
That code runs fine, and one part of it is checking for a secured connection by inspecting the response header for Client-SSL-Cipher, Client-SSL-Cert-Subject, and Client-SSL-Cert-Issuer (besides a https: URL).
However when the program uses a proxy (via $user_agent->env_proxy()) the response does not include those Client-SSL headers.
(The via headers indicate that the proxy (squid/2.7.STABLE5) is used.)
The proxy environment lists the https_proxy using a http://some_host:3128/ URL.
How can I get those SSL-details while using a proxy? The versions being used are those for SLES12 SP4, so neither very old nor very recent (perl 5.18.2).
(Partial) Example Header without Proxy
'_headers' => HTTP::Headers=HASH(0x55bfc8d76470)
'::std_case' => HASH(0x55bfc90a0980)
'client-date' => 'Client-Date'
'client-peer' => 'Client-Peer'
'client-response-num' => 'Client-Response-Num'
'client-ssl-cert-issuer' => 'Client-SSL-Cert-Issuer'
'client-ssl-cert-subject' => 'Client-SSL-Cert-Subject'
'client-ssl-cipher' => 'Client-SSL-Cipher'
'client-ssl-socket-class' => 'Client-SSL-Socket-Class'
'strict-transport-security' => 'Strict-Transport-Security'
'x-content-type-options' => 'X-Content-Type-Options'
'x-frame-options' => 'X-Frame-Options'
'accept-ranges' => 'bytes'
'client-date' => 'Tue, 24 Mar 2020 10:45:23 GMT'
'client-peer' => '134.76.12.6:443'
'client-response-num' => 1
'client-ssl-cert-issuer' => '/C=DE/O=Verein zur Foerderung eines Deutschen Forschungsnetzes e. V./OU=DFN-PKI/CN=DFN-Verein Global Issuing CA'
'client-ssl-cert-subject' => '/C=DE/ST=NIEDERSACHSEN/L=GOETTINGEN/O=Gesellschaft fuer wissenschaftliche Datenverarbeitung/CN=ftp6.gwdg.de'
'client-ssl-cipher' => 'ECDHE-RSA-AES256-GCM-SHA384'
'client-ssl-socket-class' => 'IO::Socket::SSL'
'connection' => 'close'

Can't send email with laravel 5.1 + gmail

I'm having troubles sending e-mails via a Laravel 5.1 application using gmail.
Here is my config file :
<?php
return [
'driver' => 'sendmail',
'host' => 'smtp.gmail.com',
'port' => 578,
'from' => array('address' => 'adresse#gmail.com', 'name' => 'Something'),
'encryption' => 'tls',
'username' => 'someaddress#gmail.com',
'password' => '****',
'sendmail' => '/usr/sbin/sendmail -bs',
'pretend' => false,
];
Allowing less secure apps to access your account is turned on.
What config shall I use ?
You must to allow less secure apps here and Enable Unlock Captcha here
Also, Set .env as follows
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=something#gmail.com
MAIL_PASSWORD=*********
MAIL_ENCRYPTION=tls
And Set config/mail.php as follows
'driver' => env('MAIL_DRIVER', 'smtp'),
'host' => env('MAIL_HOST', 'smtp.gmail.com'),
'port' => env('MAIL_PORT', 587),
'from' => [
'address' => 'something#gmail.com',
'name' => env('MAIL_FROM_NAME', 'Admin'),
],
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
'username' => env('MAIL_USERNAME','something#gmail.com'),
'password' => env('MAIL_PASSWORD','*********'),
'sendmail' => '/usr/sbin/sendmail -bs',
Hope it's Help!

Perl get value of nested hash

I have spent couple hours trying to get the value of 'Auth-Token' out of REST api response header, I just don't understand the meaning of bless({ key=> value })
is this a hashref inside an array? How can I loop through it.
$VAR1 = bless( {
'access-control-allow-credentials' => 'true',
'connection' => 'keep-alive',
'x-powered-by' => 'restheart.org',
'client-response-num' => 1,
'access-control-allow-origin' => '*',
'date' => 'Thu, 05 May 2016 22:54:44 GMT',
'client-peer' => '172.18.18.122:8080',
'content-length' => '469',
'access-control-expose-headers' => 'Location, ETag, Auth-Token, Auth-Token-Valid-Until, Auth-Token-Location, X-Powered-By',
'::std_case' => {
'access-control-allow-credentials' => 'Access-Control-Allow-Credentials',
'x-powered-by' => 'X-Powered-By',
'client-response-num' => 'Client-Response-Num',
'access-control-allow-origin' => 'Access-Control-Allow-Origin',
'client-peer' => 'Client-Peer',
'access-control-expose-headers' => 'Access-Control-Expose-Headers',
'client-date' => 'Client-Date',
'auth-token-valid-until' => 'Auth-Token-Valid-Until',
'auth-token-location' => 'Auth-Token-Location',
'auth-token' => 'Auth-Token'
},
'client-date' => 'Thu, 05 May 2016 22:55:00 GMT',
'content-type' => 'application/hal+json',
'auth-token-valid-until' => '2016-05-05T23:09:44.471Z',
'auth-token-location' => '/_authtokens/test',
'auth-token' => 'fbbb0215-cedd-4a10-9f89-93fdf1e84fdc'
}, 'HTTP::Headers' );
That's a hash that's been blessed into an HTTP::Headers object. You can access what you need by using its API:
my $token = $VAR1->header('auth-token');
I wouldn't recommend accessing it via the hash directly (breaking encapsulation), in case the internals of HTTP::Headers ever changes.
Its common in perl5 to use a hash for objects. In this case, you have a 'HTTP::Headers' object in $VAR1. Under the hood, the object is a blessed HashRef, so what your are seeing are the ordinary "guts" of a hash. To the left of the "fat commas" are the keys and to the right are the values.
So, your question boils down to - given a hashref in a variable, how do I get the value for key 'x'? Now, here is how you do that - but DONT do it.
print $VAR1->{ auth-token };
The reason why I say "dont do it" is that you're breaking a fundamental principle of OO programming called encapsulation. The details of the object are not supposed to be any of your business. Instead use the methods provided by the class (ie, provided by the module HTTP::Headers)
Reading the HTTP::Heders doco, you can get the header for 'auth token' like so;
print $VAR1->header( 'auth-token' )
This is what you need to do.

Asterisk outgoing call fails with 'Busy Here' error

I have Asterisk 11.7.0 configured on CentOS 6.4 x64 with following sip.conf configuration:
[general]
register =>myuser:pass#voipproviderip
registertimeout=20
context=incoming
allowoverlap=no
bindport=5060
bindaddr=192.168.0.3
srvlookup=no
subscribecontext=from-sip
[VoIPProvider]
canreinvite=yes
username=myuser
fromuser=myuser
secret=mypass
context=incoming
type=friend
;fromdomain=voipproviderip
host=voipproviderip
dtmfmode=rfc2833
disallow=all
allow=alaw
allow=ulaw
nat=yes
insecure=very
; ext 100
[100]
type=friend
host=dynamic
secret=MyPass123
context=default
mailbox=100#default
callgroup=1
pickupgroup=1
dtmfmode=rfc2833
canreinvite=no
; ext 101
[101]
type=friend
host=dynamic
secret=MyPass123
context=default
mailbox=101#default
callgroup=1
pickupgroup=1
dtmfmode=rfc2833
canreinvite=no
; ext 102
[102]
type=friend
host=dynamic
secret=MyPass123
context=default
mailbox=102#default
callgroup=1
pickupgroup=1
dtmfmode=rfc2833
canreinvite=no
; ext 103
[103]
type=friend
host=dynamic
secret=MyPass123
context=default
mailbox=103#default
callgroup=1
pickupgroup=1
dtmfmode=rfc2833
canreinvite=no
; ext 104
[104]
type=friend
host=dynamic
secret=MyPass123
context=default
mailbox=104#default
callgroup=1
pickupgroup=1
dtmfmode=rfc2833
canreinvite=no
; ext 105
[105]
type=friend
host=dynamic
secret=MyPass123
context=default
mailbox=105#default
callgroup=1
pickupgroup=1
dtmfmode=rfc2833
canreinvite=no
; ext 106
[106]
type=friend
host=dynamic
secret=MyPass123
context=default
mailbox=106#default
callgroup=1
pickupgroup=1
dtmfmode=rfc2833
canreinvite=no
; ext 100
[107]
type=friend
host=dynamic
secret=MyPass123
context=default
mailbox=107#default
callgroup=1
pickupgroup=1
dtmfmode=rfc2833
canreinvite=no
; ext 108
[108]
type=friend
host=dynamic
secret=MyPass123
context=default
mailbox=108#default
callgroup=1
pickupgroup=1
dtmfmode=rfc2833
canreinvite=no
and following extensions.conf:
[default]
include => internal
include => incoming
include => outgoing
[incoming]
; Ring on extension 100, 200 and the mobile phone.
exten => s,1,Answer()
exten => s,n,Dial(SIP/101&SIP/103,30,r,t,)
; Pass unanswered call to a mobile phone
exten => s,n,Dial(SIP/101&SIP/103/&SIP/100,30,r)
same => n,GotoIf($["${DIALSTATUS}" = "BUSY"]?busy:unavail)
same => n(unavail),VoiceMail(100#default,u)
same => n,Hangup()
same => n(busy),VoiceMail(100#default,b)
same => n,Hangup()
[outgoing]
; Outbound calls can be routed based on the number of digits dialled (or the value of the first few digits)
;exten=> _XXXXXXXXXXXX.,1,Dial(SIP/VoIPProvider/${EXTEN})
;exten=> _XXXXXXXXXXXX.,2,Hangup
exten => _XXXXXXXXXXXX,1,Dial(SIP/VoIPProvider/${EXTEN})
exten => _XXXXXXXXX,1,Dial(SIP/VoIPProvider/${EXTEN})
exten => _XXXXXXXXX,1,Dial(SIP/VoIPProvider/${EXTEN})
exten => _XXXXXXX,1,Dial(SIP/VoIPProvider/${EXTEN})
[internal]
; Calls between employees (between extensions)
exten => _XXX,1,Dial(SIP/${EXTEN},60)
include => outgoing
; Calls to ext 100
exten => 100,1,Dial(SIP/100,20)
exten => 100,n,VoiceMail(100,u)
exten => 100,n,Hangup
; Calls to ext 101
exten => 101,1,Dial(SIP/101,20)
exten => 101,n,VoiceMail(101,u)
exten => 101,n,Hangup
; Calls to ext 102
exten => 102,1,Dial(SIP/102,20)
exten => 102,n,VoiceMail(102,u)
exten => 102,n,Hangup
; Calls to ext 103
exten => 103,1,Dial(SIP/103,20)
exten => 103,n,VoiceMail(103,u)
exten => 103,n,Hangup
; Calls to ext 104
exten => 104,1,Dial(SIP/104,20)
exten => 104,n,VoiceMail(104,u)
exten => 104,n,Hangup
; Calls to ext 105
exten => 105,1,Dial(SIP/105,20)
exten => 105,n,VoiceMail(105,u)
exten => 105,n,Hangup
; Calls to ext 106
exten => 106,1,Dial(SIP/106,20)
exten => 106,n,VoiceMail(106,u)
exten => 106,n,Hangup
; Calls to ext 107
exten => 107,1,Dial(SIP/107,20)
exten => 107,n,VoiceMail(107,u)
exten => 107,n,Hangup
; Calls to ext 108
exten => 108,1,Dial(SIP/108,20)
exten => 108,n,VoiceMail(108,u)
exten => 108,n,Hangup
Whenever I dial a number from CLI>console dial mynumber, I see the folowing output:
-- Executing [mynumber#default:1] Dial("Console/dsp", "SIP/VoIPProvider/mynumber") in new stack
== Using SIP RTP CoS mark 5
-- Called SIP/VoIPProvider/mynumber
-- Got SIP response 486 "Busy Here" back from voipproviderip:5060
-- SIP/VoIPProvider-00000000 is busy
== Everyone is busy/congested at this time (1:1/0/0)
-- Auto fallthrough, channel 'Console/dsp' status is 'BUSY'
I have tried all the possible ways to dial a number, (including / excluding country code, etc.) but it always replays with 486 "Busy Here" could it be that I have to pay the bill of my voip service?
I would try Dial(SIP/mynumber#VoIPProvider);
Also, what do see when you do sip show peers ???

Asterisk - To reduce extension repitition in extensions.conf in a context

I have a very basic extensions.conf with the following context:
[LocalPhones]
exten => 1001,1,noop(Dialing ${PEX_ONE})
same => n,Macro(DialStartMonitor,${PEX_ONE})
same => n,Dial(SIP/${PEX_ONE},30,mTt)
same => n,Playback(vm-nobodyavail) ; Play "no one's available"
same => n,Hangup()
exten => 1002,1,noop(Dialing ${PEX_TWO})
same => n,Macro(DialStartMonitor,${PEX_TWO})
same => n,Dial(SIP/${PEX_TWO},30,mTt)
same => n,Playback(vm-nobodyavail) ; Play "no one's available"
same => n,Hangup()
exten => 1003,1,noop(Dialing ${PEX_THREE})
same => n,Macro(DialStartMonitor,${PEX_THREE})
same => n,Dial(SIP/${PEX_THREE},30,mTt)
same => n,Playback(vm-nobodyavail) ; Play "no one's available"
same => n,Hangup()
exten => 1004,1,Dial(Dialing ${PEX_FOUR})
same => n,Macro(DialStartMonitor,${PEX_FOUR})
same => n,Dial(SIP/${PEX_FOUR},10,m)
same => n,Playback(vm-nobodyavail) ; Play "no one's available"
same => n,Hangup()
exten => 1005,1,Dial(Dialing ${PEX_FIVE})
same => n,Macro(DialStartMonitor,${PEX_FIVE})
same => n,Dial(SIP/${PEX_FIVE},10,m)
same => n,Playback(vm-nobodyavail) ; Play "no one's available"
same => n,Hangup()
Is there a way I can combine all these into a single block (instead of 5 blocks like it is now) so that the extensions can dial each other (the extensions are from 1001 to 1010)?
Correct value-placement dialplan for asterisk is like this
exten => 1000,1,Set(trunk=${PEX_ONE})
exten => 1002,1,Set(trunk=${PEX_TWO})
exten => 1003,1,Set(trunk=${PEX_THREE})
exten => 1004,1,Set(trunk=${PEX_PHONE})
exten => 1005,1,Set(trunk=${PEX_FIVE})
; this will be executed after any of above
; note,it start from 2 prio(1 is from set above)
exten => _100[1-5],2,Noop(Dialing ${trunk})
same => n,Macro(DialStartMonitor,${trunk})
same => n,Dial(SIP/${trunk},10,m)
same => n,Playback(vm-nobodyavail) ; Play "no one's available"
same => n,Hangup()
Note, your dialplan is still bad, becuase it play vm-nobodyavail even if user busy or communication was ok, but hanguped called user.
For correct dialplan like that you need analyze DIALSTATUS variable, check extensions.conf.sample for dialplan like that or read dialplan of freepbx.org software.
I think it will be something like bellow:
exten => _100[12345],1,Set(DIALTO=${PEX_ONE})
same => n,GotoIf($["${EXTEN:-1}" = "1"]?process)
same => n,Set(DIALTO=${PEX_TWO})
same => n,GotoIf($["${EXTEN:-1}" = "2"]?process)
same => n,Set(DIALTO=${PEX_THREE})
same => n,GotoIf($["${EXTEN:-1}" = "3"]?process)
same => n,Set(DIALTO=${PEX_FOUR})
same => n,GotoIf($["${EXTEN:-1}" = "4"]?process)
same => n,Set(DIALTO=${PEX_FIVE})
same => n(process),Macro(DialStartMonitor,${DIALTO})
same => n,Dial(SIP/${DIALTO},30,mTt)
same => n,Playback(vm-nobodyavail) ; Play "no one's available"
same => n,Hangup()