41 lines
1.7 KiB
Markdown
41 lines
1.7 KiB
Markdown
# Local Asterisk CLI API
|
|
|
|
Trusted local programs can submit one Asterisk CLI command per request:
|
|
|
|
```http
|
|
POST http://127.0.0.1:8080/local-asterisk/command
|
|
Content-Type: application/json
|
|
X-Local-Asterisk-Token: <value of pline.local-asterisk-api-token>
|
|
|
|
{"command":"core show version"}
|
|
```
|
|
|
|
Example from a trusted local shell:
|
|
|
|
```bash
|
|
TOKEN="$(sed -n 's/^pline\.local-asterisk-api-token=//p' /opt/cti/application.properties)"
|
|
curl --fail-with-body -sS http://127.0.0.1:8080/local-asterisk/command \
|
|
-H "X-Local-Asterisk-Token: $TOKEN" \
|
|
-H 'Content-Type: application/json' \
|
|
--data '{"command":"core show version"}'
|
|
```
|
|
|
|
On installed systems, the token is generated once and stored as
|
|
`pline.local-asterisk-api-token` in `/opt/cti/application.properties`. It remains
|
|
stable through installer upgrades. Only trusted local processes should be given
|
|
this value; the API accepts Asterisk CLI commands with the same authority as the
|
|
`pline` AMI account.
|
|
|
|
The service accepts requests only from a direct loopback connection. Requests
|
|
with proxy-forwarding headers are rejected, so local programs should connect
|
|
directly to port 8080 rather than through Nginx. Commands are limited to one
|
|
line and 4096 characters. Responses include the command output and whether AMI
|
|
or the local CLI handled the request.
|
|
|
|
CLI commands use a bounded AMI command pool of four connections. If all command
|
|
slots are busy, the request does not wait in an application queue and may use a
|
|
bounded local CLI fallback. At most two local CLI fallback processes run at a
|
|
time; excess requests fail promptly. If an AMI action has been sent but its
|
|
response times out, the service does not retry the command through the CLI,
|
|
because its outcome may be uncertain.
|