便宜

88一年的腾讯VPC云..1M小水管, 不买白不买…

prepare

10.31 updated

docker-ce

miniconda 
    pip install docker-compose
    pip install mycli
laradock
    docker-compose build mariadb

ejabberd

ejabberd using mariadb

接下来尝试切换ejabberd的数据库到mariadb.. https://docs.ejabberd.im/admin/databases/mysql/

root登录mycli, 给ejabberd用户权限

grant all on *.* to 'ejabberd'@'%' identified by 'xxx';
flush privileges;

导入sql文件:

mycli -u ejabberd -D ejabberd
//https://raw.githubusercontent.com/processone/ejabberd/master/sql/mysql.new.sql
source mysql.new.sql

ejabberd.yml添加:

auth_method: sql
new_sql_schema: true
sql_type: mysql
sql_server: "localhost"
sql_database: "ejabberd"
sql_username: "ejabberd"
sql_password: "xxx"

然后添加点admin和普通测试用户:

./ejabberdctl register admin 49.233.92.47 admin
for i in {1..10}
do
./ejabberdctl register test$i 49.233.92.47 test$i
done

client端converse.js: https://conversejs.org/fullscreen.html

如何与现有账户系统集成

ejabberd auth external

看到了auth_methodexternal的方式:

https://www.ejabberd.im/extauth/

大概就是ejabberd会外发认证协议,脚本去实现协议:

https://www.ejabberd.im/files/doc/dev.html#htoc9

	try:
		if ejab_request[0] == "auth":
			op_result = auth(ejab_request[1], ejab_request[2], ejab_request[3])
		elif ejab_request[0] == "isuser":
			op_result = isuser(ejab_request[1], ejab_request[2])
		elif ejab_request[0] == "setpass":
			op_result = setpass(ejab_request[1], ejab_request[2], ejab_request[3])
		elif ejab_request[0] == "tryregister":
			op_result = tryregister(ejab_request[1], ejab_request[2], ejab_request[3])
		elif ejab_request[0] == "removeuser":
			op_result = removeuser(ejab_request[1], ejab_request[2])
		elif ejab_request[0] == "removeuser3":
			op_result = removeuser3(ejab_request[1], ejab_request[2], ejab_request[3])
	except Exception:
		logging.exception("Exception occured")

迁移

laravel php artisan:

php artisan ff-im-migrate

2.如何远程调用register

ejabberd 配置权限,只有指定的ip才有权限

api

3.新用户注册,即到im注册新账号

登录和im通信app仍然走xmpp