麒麟(linux)搭建coturn

发布时间 2023-08-24 11:57:08作者: ziff123

一、概述

coturn 是开源的服务器应用,完整实现了 STUN 和 TURN 协议。借助 coturn,我们可以快捷方便的搭建一个 STUN/TURN 服务。

二、安装步骤

1、安装coturn依赖库

sudo apt-get install libssl-dev
sudo apt-get install libevent-dev
sudo apt-get install libpq-dev

2、安装coturn

sudo apt install coturn

 

3、复制DTLS、TLS支持的证书文件:

cp /usr/share/doc/coturn/examples/etc/turn_server_cert.pem /etc/turn_server_cert.pem
cp /usr/share/doc/coturn/examples/etc/turn_server_pkey.pem /etc/turn_server_pkey.pem

4、编辑/etc/turnserver.conf文件:

vim turnserver.conf

将以下信息复制进去(IP\用户名密码修改自己的)

listening-port=3478
tls-listening-port=5349
listening-ip=内网ip地址
relay-ip=内网ip地址
external-ip=外网ip地址
server-name=外网ip地址
realm=外网地址
lt-cred-mech
user=用户名:密码
userdb=/var/lib/turn/turndb
cert=/etc/turn_server_cert.pem
pkey=/etc/turn_server_pkey.pem
no-stdout-log
log-file=/var/tmp/turnserver.log
pidfile="/var/run/turnserver.pid"

 

5、编辑/etc/default/coturn文件:

vim /etc/default/coturn

将以下信息复制进去保存

TURNSERVER_ENABLED=1

 

6、重启coturn

service coturn restart

7、测试验证

第一种方式:

 turnadmin -a -u test -r 外网地址(域名) -p test
 turnutils_uclient 外网地址(域名) -u test -w test

第二种方式:

打开:https://webrtc.github.io/samples/src/content/peerconnection/trickle-ice/

 

 

参考:http://senlt.cn/article/873982555.html

https://www.cnblogs.com/tony-yang-flutter/p/16981566.html