把分机信息存储到redis,需要验证的时候,从redis读取存储的信息转换成XML格式,让FreeSWITCH完成验证。优点就是redis的读取性能非常快,可以让FreeSWITCH支持大量的分机,并且配置可以实时生效。

配置说明

cti_exten@domain [哈希表]

  1. key 分机名
  2. value
{    "param": {        "allow-empty-password": false,        "password": "123",        "auth-acl": "",        "sip-forbid-register": false    },    "variable": {        "sip-force-contact": "NDLB-connectile-dysfunction-2.0"    },    "attribute": {        "cacheable": "10000",        "number-alias": "myphone"    }}

freeswitch 呼出队列 freeswitch搭建呼叫中心难吗_Time

  • param 参数
  • password 分机密码
  • a1-hash md5(username:realm:passwd),如果担心明文密码不安全,可以使用a1-hash。
  • auth-acl 设置允许注册的IP 。比如 192.168.0.100/255,cidr格式,多个用逗号隔开。
  • allow-empty-password 是否允许空密码
  • sip-forbid-register 是否禁止注册。
  • user-agent-filter 终端的user-agent必须和这个设置匹配才可以注册。这个配置是一个正则表达式。
  • max-registrations-per-extension 最大允许同时注册的终端数量,就是一个账户可以在多少个地方同时注册。
  • variable 变量,可以通过模板自己添加
  • sip-force-contact 使用NDLB-connectile-dysfunction-2.0 ,可以解决NAT问题。
  • sip-force-expires 强制注册间隔,UDP注册方式,如果分机在内网fs在外网,为了维持NAT,要设置为60。
  • attribute 属性
  • cacheable 缓存时间 单位毫秒,如果需要修改配置实时生效,就不能设置缓存,设置true永不过期。
  • number-alias 别名,比如分机号是的字母,你可以配置一个数字的别名。

分机注册状态记录到redis

cti.json

"gui": {    /*分机注册信息推送到redis*/    "registration": {        "hash": "registrations", //记录到hash表        "channel": "", //推送到channel        "list": "" //记录到list    }}

如果分机注册会在哈希表registrations添加一个记录,如果分机注销会删除这个记录。
key:分机号
value:注册信息

{    "Event-Name": "CUSTOM",    "Core-UUID": "7eca4f88-39c1-48c2-bc00-ffe7f11d92f8",    "FreeSWITCH-Hostname": "ai",    "FreeSWITCH-Switchname": "ai",    "FreeSWITCH-IPv4": "192.168.31.57",    "FreeSWITCH-IPv6": "::1",    "Event-Date-Local": "2022-04-07 23:04:50",    "Event-Date-GMT": "Thu, 07 Apr 2022 15:04:50 GMT",    "Event-Date-Timestamp": "1649343890838195",    "Event-Calling-File": "sofia_reg.c",    "Event-Calling-Function": "sofia_reg_handle_register_token",    "Event-Calling-Line-Number": "2079",    "Event-Sequence": "882",    "Event-Subclass": "sofia::register",    "profile-name": "internal",    "from-user": "121",    "from-host": "192.168.31.57",    "presence-hosts": "n/a",    "contact": "\"\" <sip:121@192.168.31.57:55458;ob;fs_nat=yes;fs_path=sip%3A121%40192.168.31.57%3A55458>",    "call-id": "220551059ccc409e9a42606f4e5c52bf",    "rpid": "unknown",    "status": "Registered(AUTO-NAT-2.0)",    "expires": "20",    "to-user": "121",    "to-host": "192.168.31.57",    "network-ip": "192.168.31.57",    "network-port": "55458",    "username": "121",    "realm": "192.168.31.57",    "user-agent": "unknown",    "sip_number_alias": "121",    "sip_auth_username": "121",    "sip_auth_realm": "192.168.31.57",    "number_alias": "121",    "user_name": "121",    "domain_name": "192.168.31.57",    "sip-force-contact": "NDLB-connectile-dysfunction-2.0",    "effective_caller_id_name": "121",    "sip-allow-multiple-registrations": "false",    "sip-force-expires": "20",    "force_ping": "false"}

分机呼叫信息记录到redis

cti.json

"gui": {    /*分机呼叫信息推送到redis*/    "call": {        /*呼叫信息需要记录的变量*/        "fields": [ "Caller-Destination-Number", "Caller-Caller-ID-Number", "Caller-Callee-ID-Number", "Caller-Profile-Created-Time", "Caller-Profile-Created-Time", "Caller-Channel-Answered-Time","Caller-Channel-Hangup-Time", "Answer-State" ],        "hash": "calls",        "channel": "",        "list": ""    }}

如果分机呼出或者呼入,哈希表calls添加一个记录,value就是呼叫信息。如果配置了写入hash表,最后一个挂断的通话信息会缓存。
key:分机号
value:呼叫信息

{    "username": "121",    "current": "47768dc2-9856-4dbd-809e-5b559004881f",    "notify": "answer",    "47768dc2-9856-4dbd-809e-5b559004881f": {        "Caller-Destination-Number": "5555",        "Caller-Caller-ID-Number": "121",        "Caller-Callee-ID-Number": "",        "Caller-Profile-Created-Time": "1649344241663800",        "Caller-Channel-Answered-Time": "1649344243343194"    },    "activity": [        "47768dc2-9856-4dbd-809e-5b559004881f"    ]}

current: 最后状态发生变化的uuid
notify:current指向UUID通道的状态,answer,callin,callout,hangup
activity: 当前所有的通话
uuid: 这个通话的通道变量,fields可以配置要记录的通道变量。
Caller-Profile-Created-Time:通话的发起时间,单位是微妙的时间戳。
Caller-Channel-Answered-Time: 通话的接通时间,单位是微妙的时间戳。
Caller-Channel-Hangup-Time: 通话的挂断时间
Answer-State: 通话状态