freeswitch号码黑名单
阅读原文时间:2023年07月08日阅读:2

概述

freeswitch是一款简单好用的的VOIP开源软交换平台。

在客户的呼叫过程中,会遇到一些异常的号码,包括高投诉风险号码、敏感号码、特殊号码等。

在客户呼叫流程中,需要针对这些异常号码做呼叫限制,最简单直接的方式就是设置号码黑名单。

环境

centos:CentOS  release 7.0 (Final)或以上版本

freeswitch:v1.10.7

GCC:4.8.5

黑名单模块

fs自带的黑名单模块mod_blacklist,模块默认不编译安装,需要进入“src/mod/applications/mod_blacklist”目录,手动编译安装。

该模块设计的目标是作为工具模块,可以在dialplan或脚本中直接返回true或false。

模块对应的配置文件是“autoload_configs/blacklist.conf.xml”。

拨号计划示例

添加号码进黑名单

检查黑名单

删除黑名单

API接口

freeswitch@localhost.localdomain> blacklist help

blacklist check

blacklist add

blacklist del

blacklist save

blacklist reload

blacklist help

+OK

测试

修改“autoload_configs/modules.conf.xml”

修改“autoload_configs/blacklist.conf.xml”

创建文件“conf/blacklists/blocked.list”,并保证fs有写权限。

测试API

freeswitch@localhost.localdomain> blacklist check blocked 12345

false

freeswitch@localhost.localdomain> blacklist add blocked 12345

+OK

2022-12-09 14:37:54.549789 [INFO] mod_blacklist.c:228 Added [12345] to list [blocked]

freeswitch@localhost.localdomain>

freeswitch@localhost.localdomain> blacklist check blocked 12345

true

freeswitch@localhost.localdomain> blacklist save blocked

2022-12-09 14:38:27.989788 [INFO] mod_blacklist.c:280 Saving blocked to ../conf-test//blacklists/blocked.list

2022-12-09 14:38:27.989788 [DEBUG] mod_blacklist.c:288 adding 12345 to the dump file

修改“dialplan/test.xml”

发起测试呼叫,10010->12345

2022-12-09 14:58:55.049767 [INFO] mod_dialplan_xml.c:637 Processing 10011 <10011>->12345 in context public

Dialplan: sofia/external/10011@10.55.55.138 parsing [public->test_blacklist] continue=true

Dialplan: sofia/external/10011@10.55.55.138 Regex (PASS) [test_blacklist] ${blacklist(check blocked ${destination_number})}(true) =~ /^true$/ break=on-true

Dialplan: sofia/external/10011@10.55.55.138 Action hangup(CALL_REJECTED)

EXECUTE sofia/external/10011@10.55.55.138 hangup(CALL_REJECTED)

2022-12-09 14:58:55.049767 [DEBUG] mod_sofia.c:440 Channel sofia/external/10011@10.55.55.138 hanging up, cause: CALL_REJECTED

2022-12-09 14:58:55.049767 [DEBUG] mod_sofia.c:579 Responding to INVITE with: 603

2022-12-09 14:58:55.049767 [DEBUG] switch_core_state_machine.c:60 sofia/external/10011@10.55.55.138 Standard HANGUP, cause: CALL_REJECTED

总结

voip呼叫系统中,黑名单的需求很普遍,fs自带的mod_blacklist基本可以满足大部分场景的需求。

空空如常

求真得真

手机扫一扫

移动阅读更方便

阿里云服务器
腾讯云服务器
七牛云服务器

你可能感兴趣的文章