text
stringlengths
0
152
If you are going to expose your AMI outside the machine it is run‐
ning on, you will want to configure TLS connectivity.
The manager.conf configuration file also contains the configuration of AMI user
accounts. You create an account by adding a section with the username inside square
brackets. Within each [username] section there are options that can be set that will
account. The ~/src/asterisk-15<TAB>/configs/samples/
apply only
manager.conf.sample file also contains detailed explanations of each of these parame‐
ters. Our user named [hello], has the simplest configuration, which is to allow all
read and write actions. You should normally create AMI users that are restricted to
only the actions necessary to their functioning.
that
to
Within the [username] section, the read and write options set which manager
actions and manager events a particular user has access to. At this writing there are 20
of them: all, system, call, log, verbose, agent, user, config, command, dtmf, report
ing, cdr, dialplan, originate, agi, cc, aoc, test, security, and message. You will
find the manager.conf.sample file contains a reference for each of these that is relevant
to your release (and, if any are added that have not been listed here, they will be in the
sample file).
Take special notice of the system, command, and originate permis‐
sions. These permissions grant significant power to any applica‐
tions that are authorized to use them. Only grant these permissions
to applications that you have full control over (and ideally are run‐
ning on the same box).
http.conf
As we’ve seen, the Asterisk Manager Interface can be accessed over HTTP as well as
TCP. To make that work, a very simple HTTP server is embedded in Asterisk. All of
the options relevant to the AMI go in the [general] section of /etc/asterisk/http.conf.
304
|
Chapter 17: Asterisk Manager Interface and Call Files
Enabling access to the AMI over HTTP requires both /etc/asterisk/
manager.conf and /etc/asterisk/http.conf. The AMI must be enabled
in manager.conf with the enabled option set to yes, and the man‐
ager.conf option webenabled must be set to yes to allow access over
HTTP. Finally, the enabled option in http.conf must be set to yes to
turn on the HTTP server itself.
The available options will be found in your ~/src/asterisk-15<TAB>/configs/samples/
http.conf.sample file.
Protocol Overview
There are two main types of messages on the Asterisk Manager Interface: manager
events and manager actions.
Manager events are one-way messages sent from Asterisk to AMI clients to report
something that has occurred on the system (Figure 17-1).
Figure 17-1. Manager events
Manager actions are requests from a client to Asterisk to perform some action and
return the result (Figure 17-2). For example, the AMI action Originate requests that
Asterisk create a new call, and naturally the client application will need responses
from Asterisk to indicate the progress of that activity.
Protocol Overview
|
305
Figure 17-2. Manager actions
Other manager actions are requests for data. For example, there is a manager action
to get a list of all active channels on the system: the details about each channel are
delivered as a manager event. When the list of results is complete, a final message will
be sent to indicate that the end has been reached. See Figure 17-3 for a graphical rep‐
resentation of a client sending this type of manager action and receiving a list of
responses.
Figure 17-3. Manager actions that return a list of data
Message Encoding
All AMI messages, including manager events, manager actions, and manager action
responses, are encoded the same way. The messages are text-based, with lines termi‐
nated by a carriage return and a line-feed character. A message is terminated by a
blank line:
306
|
Chapter 17: Asterisk Manager Interface and Call Files
Header1: This is the first header<CR><LF>
Header2: This is the second header<CR><LF>
Header3: This is the last header of this message<CR><LF>
<CR><LF>