1.搭建turn服务器目的
部署WebRTC 或 SIP p2p 方案时经常会遇到p2p 无法穿透的环境,
这时就是TunServer 的用武之地了。
这里我们使用turnserver-0.7.3
2.下载confuse依赖库
1 | wget http://savannah.nongnu.org/download/confuse/confuse-2.7.tar.gz |
3.下载turnserver
1 | wget http://downloads.sourceforge.net/project/turnserver/turnserver-0.7.3.tar.bz2 |
4.编辑配置文件
将extra 中的配置文件模版拷贝到/etc目录下,假设您的ip 是 1.2.3.4
1,配置文件
1 | cp extra/turnserver.conf.template /etc/turnserver.conf |
修改
listen_address = { “1.2.3.4” }
修改 ## Daemon mode. daemon = true # 修改为后台服务方式
修改带宽限制
1 | ##Allocation bandwidth limitation (in KBytes/s). ## 0 value means bandwidth quota disabled. bandwidth_per_allocation = 1024 |
2,认证用户文件
1 | cp extra/turnusers.txt.template /etc/turnusers.txt |
添加一行或多行认证信息格式为 用户名:密码:domain:authorized 例如下面的行: 700:700pass:domain.org:authorized
添加完成后,就可以在webrtc 里面使用stun 和tunserver 了。
1 | 'iceServers': [{ { 'url' : 'stun:1.2.3.4'} , { 'url' : ‘turn:700@1.2.3.4',credential : '700pass'} }] }; |