项目作者: kettenbach-it

项目描述 :
Fast-AGI service built with Python to use the Tellows Blacklist API Service within Asterisk
高级语言: Python
项目地址: git://github.com/kettenbach-it/asterisk-fastagi-tellows.git
创建时间: 2021-05-04T14:52:17Z
项目社区:https://github.com/kettenbach-it/asterisk-fastagi-tellows

开源协议:GNU Affero General Public License v3.0

下载


Asterisk FastAGI Integration of Tellows Blacklist API

Fast-AGI service built with Python to use the
Tellows Blacklist API Service
within Asterisk.

It requires an API-Key which can be obtained in the Tellows Shop.

Installation

This service was developed with the aim of running in docker.
It will also work without docker, but docker is the recommended way.

Using docker

The latest docker-image can be found on DockerHub.

Use docker-compose.example.yml to run your container.

Running in docker, the configuration of the service is done in envrionment variables
as shown below:

  1. version: "3.7"
  2. services:
  3. asterisk-fastagi-tellows:
  4. image: vkettenbach/asterisk-fastagi-tellows:latest
  5. container_name: asterisk-fastagi-tellows
  6. restart: unless-stopped
  7. network_mode: host
  8. environment:
  9. APIKEYMD5: "<your api key as md5 hash>"
  10. HOST: "0.0.0.0" # Listen on all interfaces
  11. PORT: 4573 # Listen on asterisk agi port
  12. TIMEOUT: 2 # Timeout
  13. REDIS_HOST: localhost # Redis host to lookup whitelist at
  14. REDIS_PORT: 6379 # Redis port to lookup whitelist at

Not using docker

If not all of the four environment variables are supplied, the service will
fall back to read the file “config.yaml” - see config.example.yaml.

So if you want to checkout the code from git an run it using python
you need to create a virtual env to run the code. The service was
developed sing Python 3.9. It will probaly work down to 3.7. It won’t
work with Python 2.

Here is an example of how this is done - somewhat:

  1. git pull https://github.com/kettenbach-it/asterisk-fastagi-tellows
  2. python3 -m venv venv
  3. source venv/bin/activate
  4. pip install -r requirements.txt
  5. cp config.example.yaml config.yaml
  6. # now edit config.yaml accoring to your needs
  7. python3 tellows.agi.py

Usage in Asterisk

Here’s an example how you can use this FastAGI service in Asterisk
(in a Macro) assuming you deployed it to the same host Asterisk is running
at. You can deploy it to any other docker host having internet access
reachable by your asterisk host - just adjust the hostname accordingly.
Calls will be checked using the Tellows service and calls with score > 6
will be sent to the “blacklistedtellows” priority and then handled by “Zapateller”

  1. ; Tellows check via FastAGI
  2. exten => s,n,AGI(agi://localhost/)
  3. exten => s,n,GotoIf($[ ${TELLOWS_SCORE} > 6 ]?blacklistedtellows)
  4. ....
  5. ; Blacklist Tellows
  6. exten => s,n(blacklistedtellows),Set(CHANNEL(accountcode)=blacklisted-tellows)
  7. exten => s,n(blacklistedtellows),Zapateller(answer)
  8. exten => s,n(blacklistedtellows),Congestion()

References

Source Code

Can be found on GitHub

Docker Container Image

Can be found on DockerHub.

Tellows API Documentation

https://www.tellows.de/apidoc (Username: tellowskey, Password:

License

GNU AGPL v3

Fore more, see LICENSE