freeswitch使用mysql代替sqlite以及通过lua管理用户登录(基于mac).md

mac上让freeswitch使用mysql代替sqlite

1.安装unixodbc:

brew install unixodbc
安装到/usr/local/Cellar/unixodbc/2.3.4/下面

2.安装mysql odbc driver

去到mysql官网下载mac版mysql odbc driver
点击打开链接
下载的mysql-connector-odbc-5.3.9-macos10.12-x86-64bit.dmg安装后位于/usr/local/mysql-connector-odbc-5.3.9-macos10.12-x86-64bit/

3.配置ODBC

cd bin/

./myodbc-installer -d -a -n "MySQL ODBC 5.3 Driver" -t "DRIVER=/usr/local/lib/libmyodbc5a.so"
生成或者更新 /Library/ODBC/odbcinst.ini
./myodbc-installer -s -c2 -a -n "freeswitch" -t "DRIVER=MySQL ODBC 5.3 ANSI Driver;SERVER=localhost;DATABASE=freeswitch;UID=myuser;PWD=mypassword;OPTION=67108864" 
生成或者更新 /Library/ODBC/odbc.ini
将上述两步生成的odbc.ini odbcinst.ini拷贝到/usr/local/Celler/unixodbc/2.3.4/etc/下面(覆盖原来的两个文件)

启动mysql:
mysqld_safe --skip-grant-tables
或者mysql.server restart


执行isql -v freeswitch 如果出现下面的显示说明odbc安装成功:


4.准备数据库

以root身份登录mysql: mysql -u root -p
然后创建一个用户lifeng,密码123456: create user lifeng@'%' identified by '123456';
授权用户新创建的用户lifeng有权访问数据库里的各类资源:
grant all privileges on *.* to lifeng@'%' identified by '123456';
flush privileges;


在freeswitch中添加表格userinfo和用户数据进去:
CREATE TABLE userinfo (
`id` int(11) NOT NULL AUTO_INCREMENT,
`username` varchar(10) DEFAULT NULL,
`password` varchar(30) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=19 DEFAULT CHARSET=utf8;
insert into userinfo (username, password) values('test1', '1234');
insert into userinfo (username, password) values('test2', '12345');
insert into ...

5.修改用户注册部分,转接到lua脚本进行注册验证

修改freeswitch/conf/autoload_configs/lua.conf.xml


gen_dir_user_xml.lua内容如下:

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Freeswitch is an open-source telephony platform that allows you to build various communication applications. It supports multiple scripting languages, including Lua. Lua is a lightweight and powerful scripting language that is often used for extending the functionality of Freeswitch. With Lua, you can write custom applications, create dial plans, handle call control logic, and interact with various telephony features provided by Freeswitch. Lua scripts in Freeswitch are typically used for tasks such as call routing, IVR (Interactive Voice Response) systems, call recording, and more. To use Lua with Freeswitch, you need to have the mod_lua module enabled in your Freeswitch installation. Once enabled, you can start writing Lua scripts to control call flows and handle telephony events. Here is a simple Lua script example for Freeswitch that answers an incoming call and plays a welcome message: ```lua -- answer.lua session:answer() session:streamFile("/path/to/welcome-message.wav") ``` In this example, the `session:answer()` function answers the incoming call, and the `session:streamFile()` function plays an audio file to the caller. You can save this script as `answer.lua` and load it in your Freeswitch dial plan configuration to execute it when an incoming call arrives. Note that this is just a basic example, and Lua with Freeswitch offers much more functionality and flexibility. Feel free to explore the official Freeswitch documentation and Lua scripting resources for more advanced use cases and examples.

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值