linux 安装turnserver

部署WebRTC 或 SIP p2p 方案时经常会遇到p2p 无法穿透的环境,


这时就是TunServer 的用武之地了。


这里我们使用turnserver-0.7.3 




下载confuse依赖库


http://savannah.spinellicreations.com//confuse/confuse-2.7.zip
tar zxvf confuse-2.7.tar.gz


cd confuse*


./configure


make && make install




下载
yum install bzip2
yum install libconfuse-devel


libssl-dev 就是安装 yum install openssl-devel
wget http://downloads.sourceforge.NET/project/turnserver/turnserver-0.7.3.tar.bz2
tar jxvf turnserver-0.7.3.tar.bz2


cd turnserver*


./configure --prefix


make && make install




编辑配置文件


将extra 中的配置文件模版拷贝到/etc目录下,假设您的ip 是 1.2.3.4


1,配置文件


cp extra/turnserver.conf.template  /etc/turnserver.conf
vi /etc/tunserver.conf


修改
 listen_address = { "1.2.3.4" }


修改 ## Daemon mode.
daemon = true # 修改为后台服务方式


修改带宽限制


## Allocation bandwidth limitation (in KBytes/s).
## 0 value means bandwidth quota disabled.
bandwidth_per_allocation = 1024




## Restricted user bandwidth (in KBytes/s).
## 0 value means bandwidth limitation disabled.
restricted_bandwidth = 0






## Account file (if account_method = file). 指定认证文件路径
account_file = "/etc/turnusers.txt" 
2,认证用户文件


cp extra/turnusers.txt.template /etc/turnusers.txt
vi /etc/turnusers.txt


添加一行或多行认证信息格式为    用户名:密码:domain:authorized
例如下面的行:
700:700pass:domain.org:authorized




启动 TurnServer, 运行命令
turnserver  -c /etc/turnserver.conf  


添加完成后,就可以在webrtc 里面使用stun 和tun server 了。
var configuration = {
  'iceServers': [{
    { 'url' : 'stun:1.2.3.4'} ,
    { 'url' : ‘turn:700@1.2.3.4',credential : '700pass'}
  }]
};


realm = "domain.org":
var configuration = {  'iceServers': [{    { “url” : “stun:1.2.3.4”} ,


{ “url” : "turn:turnserver@1.2.3.4",credential : "123456" }


  }]};?



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值