标签归档:turnserver

Centos6 安装 stun/turn服务

1,关于stun和turn

STUN(Simple Traversal of UDP over NATs,NAT 的UDP简单穿越)是一种网络协议,它允许位于NAT(或多重NAT)后的客户端找出自己的公网地址,查出自己位于哪种类型的NAT之后以及NAT为某一 个本地端口所绑定的Internet端端口。这些信息被用来在两个同时处于NAT 路由器之后的主机之间建立UDP通信。该协议由RFC 3489定义。目前RFC 3489协议已被RFC 5389协议所取代,新的协议中,将STUN定义为一个协助穿越NAT的工具,并不独立提供穿越的解决方案。它还有升级版本RFC 7350,目前正在完善中。 

http://baike.baidu.com/view/884586.htm

TURN的全称为Traversal Using Relay NAT,即通过Relay方式穿越NAT,TURN应用模型通过分配TURNServer的地址和端口作为客户端对外的接受地址和端口,即私网用户发出的报文都要经过TURNServer进行Relay转发。 

http://baike.baidu.com/subview/351571/10359693.htm

2,安装

参考: 

http://www.hankcs.com/program/network/compile-rfc5766-turn-server-to-build-turn-server.html

代码下载: 

https://github.com/coturn/rfc5766-turn-server/releases 

下载最新的tar.gz包。rfc5766-turn-server-3.2.5.9.tar.gz

安装依赖环境

##ssl 需要yum安装 yum install openssl openssl-libs libevent libevent-devel
  • 1
  • 2

如果还是报错,就手动安装libevent。

centos Libevent2 development libraries are not installed properly in required location
  • 1

下载:http://libevent.org/ 官网,下载 

https://sourceforge.net/projects/levent/files/libevent/libevent-2.0/libevent-2.0.22-stable.tar.gz 

然后解压缩编译安装即可

编译turn-server

tar -zxvf rfc5766-turn-server-3.2.5.9.tar.gz
cd rfc5766-turn-server-3.2.5.9 ./configure 
make
make install
  • 1
  • 2
  • 3
  • 4
  • 5

configure成功:

more is /usr/bin/more
install is /usr/bin/install
pkill is /usr/bin/pkill
Use TMP dir /var/tmp
Compiler: cc Do not use -lsocket Do not use -lwldap32 Do not use -lwldap64 Do not use -lintl
Sockets code is fine: no sin_len field present
Ignore IP_RECVERR
Crypto SSL lib found.
SSL lib found.
Libevent2 development found.
Libevent2 runtime found.
Libevent2 openssl found.
Libevent2 pthreads found.

POSTGRESQL DEVELOPMENT LIBRARY (libpq.a) AND/OR HEADER (libpq-fe.h)
        ARE NOT INSTALLED PROPERLY ON THIS SYSTEM.
        THAT'S OK BUT THE TURN SERVER IS BUILDING WITHOUT POSTGRESQL DATABASE SUPPORT. MYSQL DEVELOPMENT LIBRARY (libmysqlclient) AND/OR HEADER (mysql.h)
        ARE NOT INSTALLED PROPERLY ON THIS SYSTEM.
        THAT'S OK BUT THE TURN SERVER IS BUILDING WITHOUT MYSQL DATABASE SUPPORT. HIREDIS DEVELOPMENT LIBRARY (libhiredis.*) AND/OR HEADERS (hiredis/*.h)
        ARE NOT INSTALLED PROPERLY ON THIS SYSTEM.
        THAT'S OK BUT THE TURN SERVER IS BUILDING WITHOUT REDIS SUPPORT. PREFIX=/usr/local OSLIBS= -L/usr/local/lib/ -L/usr/local/lib/ -L/usr/local/lib64/ -L/usr/local/lib64/ -lrt -pthread -lcrypto -lssl -levent_core -levent_openssl -levent_pthreads  -Wl,-rpath,/usr/local/lib/ -Wl,-rpath,/usr/local/lib/ -Wl,-rpath,/usr/local/lib64/ -Wl,-rpath,/usr/local/lib64/ -Wl,-rpath,/usr/lib64/mysql -Wl,-rpath,/usr/local/lib DBLIBS= OSCFLAGS=-g  -Wall -Wno-deprecated-declarations -Wextra -Wformat-security -Wnested-externs -Wstrict-prototypes  -Wmissing-prototypes -Wpointer-arith -Wcast-qual -I/usr/local/include -I/usr/local/include/ -I/usr/local/include  -DTURN_HAS_DAEMON    -DINSTALL_PREFIX=/usr/local DBCFLAGS=
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33

只是说没有数据库支持的库,暂时不需要。

安装之后说明:

1) If you system supports automatic start-up system daemon services, 
the, to enable the turnserver as an automatically started system 
service, you have to:

        a) Create and edit /etc/turnserver.conf or /usr/local/etc/turnserver.conf . 
        Use /usr/local/etc/turnserver.conf.default as an example.

        b) For user accounts settings, if using the turnserver with authentication: create and edit /etc/turnuserdb.conf 
        file, or set up PostgreSQL or MySQL or Redis database for user accounts.
        Use /usr/local/etc/turnuserdb.conf.default as example for flat file DB, or use /usr/local/share/turnserver/schema.sql as SQL database schema, or use /usr/local/share/turnserver/schema.userdb.redis as Redis database schema description and/or /usr/local/share/turnserver/schema.stats.redis as Redis status & statistics database schema description.

        c) add whatever is necessary to enable start-up daemon for the /usr/local/bin/turnserver. 2) If you do not want the turnserver to be a system service, then you can start/stop it "manually", using the "turnserver" executable with appropriate options (see the documentation). 3) To create database schema, use schema in file /usr/local/share/turnserver/schema.sql. 4) For additional information, run:

   $ man turnserver
   $ man turnadmin
   $ man turnutils
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30

在根目录创建一个user.db文件 

使用turnserver启动:

turnserver --userdb /root/turnuser.db 里面是webrtc用户名密码: webrtc:secret
  • 1
  • 2
  • 3

3,页面调用

https://github.com/EricssonResearch/openwebrtc-examples/tree/master/web 

安装node参考之前文章: 

http://blog.csdn.net/freewebsys/article/details/46649667#t1

修改main.js

// must use 'url' here since Firefox doesn't understand 'urls' var configuration = { "iceServers": [
  { "url": "stun:mmt-stun.verkstad.net" },
  { "url": "turn:mmt-turn.verkstad.net", "username": "webrtc", "credential": "secret" }
  ]
};
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13

将stun服务器和turn服务器替换。

4,总结

stun和trun是webrtc打通的关键服务器,但是资源有限没有在公网测试。

turnserver.conf文件详解

谷歌推荐的开源穿透服务器,包含trun和stun服务,主页:https://code.google.com/p/rfc5766-turn-server/
(个人觉得可以利用这个来进一步搭建VPN,有兴趣的可以试试)

由于国内通讯都被监控,所以WebRTC是不能直接P2P的,都需要中继服务作为转发的,所以在国内使用WebRTC是需要搭建中继服务。

安装:
版本:turnserver-3.2.3.95.tar.gz  系统环境:centos

下载必要库

yum install -y make auomake gcc cc gcc-c++ wget
yum install -y openssl-devel libevent libevent-devel mysql-devel mysql-server
wget https://github.com/downloads/libevent/libevent/libevent-2.0.21-stable.tar.gz
tar xvfz libevent-2.0.21-stable.tar.gz
cd libevent-2.0.21-stable && ./configure
make && make install && cd ..


下载turnserver-3.2.3.95.tar.gz并安装

wget http://turnserver.open-sys.org/downloads/v3.2.3.95/turnserver-3.2.3.95.tar.gz
tar -xvzf turnserver-3.2.3.95.tar.gz
cd turnserver-3.2.3.95
./configure
make && make install




安装后,配置turnserver.conf和turnuserdb.conf
启动

turnserver -L <public_ip_address> -c turnserver.conf -o -a -b turnuserdb.conf -f -r <system_domain_name>




可以通过以下指令获取帮助

turnserver -h




turnserver.conf配置:

# RFC5766-TURN-SERVER configuration file
# RFC5766-TURN-SERVER配置文件
#
# Boolean values note: where boolean value is supposed to be used,
# you can use ‘0’, ‘off’, ‘no’, ‘false’, ‘f’ as ‘false,
# and you can use ‘1’, ‘on’, ‘yes’, ‘true’, ‘t’ as ‘true’
# If the value is missed, then it means ‘true’.
#
# 布尔值注意: 布尔值应该被使用,
# 您可以使用’0′, ‘off’, ‘no’, ‘false’, ‘f’ 相当于 ‘false,
# 还有你可以用’1′, ‘on’, ‘yes’, ‘true’, ‘t’ 相当于 ‘true’
# 如果没有值,相当于’true’.
#

# Listener interface device (optional, Linux only).
# NOT RECOMMENDED.
#
# 侦听器接口设备(仅可选,Linux)。
# 不推荐。
#
#listening-device=eth0

# TURN listener port for UDP and TCP (Default: 3478).
# Note: actually, TLS & DTLS sessions can connect to the
# “plain” TCP & UDP port(s), too – if allowed by configuration.
#
# TURN为UDP和TCP的侦听器端口(默认: 3478)。
# 注:实际上,TLS和DTLS会话可以连接到”清晰的”TCP和UDP端口,——如果允许配置。
#
#listening-port=3478
listening-port=3478

# TURN listener port for TLS (Default: 5349).
# Note: actually, “plain” TCP & UDP sessions can connect to the TLS & DTLS
# port(s), too – if allowed by configuration. The TURN server
# “automatically” recognizes the type of traffic. Actually, two listening
# endpoints (the “plain” one and the “tls” one) are equivalent in terms of
# functionality; but we keep both endpoints to satisfy the RFC 5766 specs.
# For secure TCP connections, we currently support SSL version 3 and
# TLS version 1.0, 1.1 and 1.2. SSL2 “encapculation mode” is also supported.
# For secure UDP connections, we support DTLS version 1.
#
# TURN为TLS的侦听器端口(默认: 5349)。
# 注意:事实上,”清晰的”TCP和UDP会话可以连接到TLS和DTLS端口,如果允许配置。
# TURN服务器”自动”识别传输类型。实际上,两个监听终端点(“清晰的”端和”TLS”端)是
# 对等的功能;但我们保持两个端点来满足RFC 5766规范。
# 对于安全的TCP连接,我们目前支持SSL的3个版本,是TLS 1.0版本,1.1版本和1.2版本。
# SSL2还支持”encapculation模式”。对于安全的UDP连接,我们支持DTLS版本1。
#
#tls-listening-port=5349
tls-listening-port=5349

# Alternative listening port for UDP and TCP listeners;
# default (or zero) value means “listening port plus one”.
# This is needed for RFC 5780 support
# (STUN extension specs, NAT behavior discovery). The TURN Server
# supports RFC 5780 only if it is started with more than one
# listening IP address of the same family (IPv4 or IPv6).
# RFC 5780 is supported only by UDP protocol, other protocols
# are listening to that endpoint only for “symmetry”.
#
# 选择UDP和TCP监听器监听端口;
# 默认(或者0)是表示监听的端口加1.
# 这是必须的,为了RFC 5780的支持(STUN的扩展规范, NAT后端的发现)。
# TURN服务器支持RFC 5780只有启动与多个监听同一族的IP地址(IPv4或IPv6).
# RFC 5780只有UDP协议,支持其他协议是监听”对称”型端口的。
#
#alt-listening-port=0
                                   
# Alternative listening port for TLS and DTLS protocols.
# Default (or zero) value means “TLS listening port plus one”.
#
# 选择监听端口TLS和DTLS协议。
# 默认(或者0)是表示TLS监听的端口加1.
#
#alt-tls-listening-port=0
    
# Listener IP address of relay server. Multiple listeners can be specified.
# If no IP(s) specified in the config file or in the command line options,
# then all IPv4 and IPv6 system IPs will be used for listening.
#
# 侦听器中继服务器的IP地址。可以指定多个侦听器。
# 如果没有在配置文件或者命令选项中指定监听的IP,
# 那么所有的IPv4和IPv6所有的IP将被监听
#
#listening-ip=172.17.19.101
#listening-ip=10.207.21.238
#listening-ip=2607:f0d0:1002:51::4
listening-ip=<IP>

# Auxiliary STUN/TURN server listening endpoint.
# Aux servers have almost full TURN and STUN functionality.
# The (minor) limitations are:
# 1) Auxiliary servers do not have alternative ports and
# they do not support STUN RFC 5780 functionality (CHANGE REQUEST).
# 2) Auxiliary servers also are never returning ALTERNATIVE-SERVER reply.
# Valid formats are 1.2.3.4:5555 for IPv4 and [1:2::3:4]:5555 for IPv6.
# There may be multiple aux-server options, each will be used for listening
# to client requests.
#
# 辅助STUN/TURN服务器监听端口。
# 辅助服务器几乎有齐TURN和STUN功能
# (一些)局限性:
# 1) 辅助服务器没有替代的端口并且他们不支持STUN RFC 5780功能(变更请求)。
# 2) 辅助服务器也不会返回ALTERNATIVE-SERVER回复。
# 有效格式,IPv4的1.2.3.4:5555 和IPv6的[1:2::3:4]:5555。
# 可能会有多个aux-server选项,每个将用于监听客户端请求。
#
#aux-server=172.17.19.110:33478
#aux-server=[2607:f0d0:1002:51::4]:33478

# (recommended for older Linuxes only)
# Automatically balance UDP traffic over auxiliary servers (if configured).
# The load balancing is using the ALTERNATE-SERVER mechanism.
# The TURN client must support 300 ALTERNATE-SERVER response for this
# functionality.
#
# (仅推荐老的Linuxes)
# 在辅助服务器自动均衡UDP流量(如果配置)。
# 使用ALTERNATE-SERVER的负载均衡机制。
# TURN客户端必须支持300个ALTERNATE-SERVER响应。
#
#udp-self-balance

# Relay interface device for relay sockets (optional, Linux only).
# NOT RECOMMENDED.
#
# 终极接口设备为中继套接字(可选, 仅Linux).
# 不推荐。
#
#relay-device=eth1

# Relay address (the local IP address that will be used to relay the
# packets to the peer).
# Multiple relay addresses may be used.
# The same IP(s) can be used as both listening IP(s) and relay IP(s).
# If no relay IP(s) specified, then the turnserver will apply the default
# policy: it will decide itself which relay addresses to be used, and it
# will always be using the client socket IP address as the relay IP address
# of the TURN session (if the requested relay address family is the same
# as the family of the client socket).
#
# 中继地址(本地IP地址将用于传递数据包的给每个端)
# 可以使用多个中继地址。
# 相同的IP可以用作监听IP和继电器IP。
# 如果没有指定中继IP,那么turnserver将应用默认策略:它将自行决定使用那个中继
# 地址,并且它总是会使用客户端套接字的IP地址作为中继的IP地址在TURN会话中(如果
# 请求的中继地址族解决同族的客户端套接字)。
#
#relay-ip=172.17.19.105
#relay-ip=2607:f0d0:1002:51::5
relay-ip=<IP>

# For Amazon EC2 users:#
# TURN Server public/private address mapping, if the server is behind NAT.
# In that situation, if a -X is used in form “-X <ip>” then that ip will be reported
# as relay IP address of all allocations. This scenario works only in a simple case
# when one single relay address is be used, and no RFC5780 functionality is required.
# That single relay address must be mapped by NAT to the ‘external’ IP.
# The “external-ip” value, if not empty, is returned in XOR-RELAYED-ADDRESS field.
# For that ‘external’ IP, NAT must forward ports directly (relayed port 12345
# must be always mapped to the same ‘external’ port 12345).
# In more complex case when more than one IP address is involved,
# that option must be used several times, each entry must
# have form “-X <public-ip/private-ip>”, to map all involved addresses.
# RFC5780 NAT discovery STUN functionality will work correctly,
# if the addresses are mapped properly, even when the TURN server itself
# is behind A NAT.
# By default, this value is empty, and no address mapping is used.
#
# Amazon EC2用户:
# TURN服务器公开/私有的地址映射,假如服务器是在NAT后端。
# 在这种情况下,如果一个表单中”-X <ip>”使用一个-X,然后该ip将被作为中继ip地址来使用。
# 这种情况只适用于一个简单的例子,当一个中继的地址是被使用,和没有RFC5780功能是必需的。
# 单个中继地址必须通过NAT映射到外部的IP。
# 外部的IP值,假如不为空,通过XOR-RELAYED-ADDRESS字段返回。
# 外部的IP,NAT必须直接转发端口(转发端口12345,必须总是映射到相同的外部端口12345)。
# 在更复杂的情况下,当涉及到多个IP地址,这个选项必须使用几次,每个条目必须形
# 成”-X <public-ip/private-ip>”,将所有涉及到的地址。
# RFC5780 NAT发现STUN功能正常工作,如果正确的地址映射,即使TURN服务器本身是
# 在一个NAT后。
# 默认,该值为空,并且没有使用地址映射。
#
#external-ip=60.70.80.91
#
#OR:
#
#external-ip=60.70.80.91/172.17.19.101
#external-ip=60.70.80.92/172.17.19.102
external-ip=<IP>

# Number of relay threads to handle the established connections
# (in addition to authentication thread and the listener thread).
# If set to 0 then application runs relay process in a single thread,
# in the same thread with the listener process (the authentication thread will
# still be a separate thread).
# In the older systems (Linux kernel before 3.9),
# the number of UDP threads is always one thread per network listening endpoint –
# including the auxiliary endpoints – unless 0 (zero) or 1 (one) value is set.
#
# 数量的中继线程处理建立连接(除了验证线程和侦听器线程)。
# 如果设置为0,那么应用程序中继进程在一个线程中运行,在同一
# 个线程中监听处理(身份验证线程仍然是一个单独的线程)。
# 在旧系统(3.9 Linux内核之前),数量的UDP线程总是一个线程监听一个网络端点,包括辅助端点——除非设置0或1值。
#
#relay-threads=0
relay-threads=10

# Lower and upper bounds of the UDP relay endpoints:
# (default values are 49152 and 65535)
#
# UDP中继端点的上下边界:
# (默认是49152至65535)
#
#min-port=49152
#max-port=65535
    
# Uncomment to run TURN server in ‘normal’ ‘moderate’ verbose mode.
# By default the verbose mode is off.
#
# 取消TURN服务器运行’normal’ ‘moderate’详细模式。
# 默认情况下,详细模式是关闭的。
#
#verbose
    
# Uncomment to run TURN server in ‘extra’ verbose mode.
# This mode is very annoying and produces lots of output.
# Not recommended under any normal circumstances.
#
# 取消TURN服务器运行’extra’详细模式。
# 这种模式是非常恼人的,产生大量的输出。
# 在任何正常情况下不建议。
#
#Verbose

# Uncomment to use fingerprints in the TURN messages.
# By default the fingerprints are off.
#
# 取消在TURN消息中使用指纹。
# 默认情况下,指纹是关闭的。
#
#fingerprint

# Uncomment to use long-term credential mechanism.
# By default no credentials mechanism is used (any user allowed).
# This option can be used with either flat file user database or
# PostgreSQL DB or MySQL DB or Redis DB for user keys storage.
#
# 取消使用长期证书机制。
# 默认情况下不使用凭证机制(允许任何用户)。
# 这个选项可能使用用户数据文件或PostgreSQL或MySQL或Redis来存储用户密钥。
#
#lt-cred-mech
lt-cred-mech

# Uncomment to use short-term credential mechanism.
# By default no credentials mechanism is used (any user allowed).
# For short-term credential mechanism you have to use PostgreSQL or
# MySQL or Redis database for user password storage.
#
# 取消使用短期证书机制。
# 默认情况下不使用凭证机制(允许任何用户)。
# 短期证书机制必须使用PostgreSQL或MySQL或Redis数据库来存储用户密码。
#
#st-cred-mech

# This option is opposite to lt-cred-mech or st-cred-mech.
# (TURN Server with no-auth option allows anonymous access).
# If neither option is defined, and no users are defined,
# then no-auth is default. If at least one user is defined,
# in this file or in command line or in usersdb file, then
# lt-cred-mech is default.
#
# 这个选项是lt-cred-mech或st-cred-mech相反。
# (TURN服务器no-auth选项允许匿名访问)。
# 如果没有选项定义,没有用户定义,那么no-auth默认。
# 如果至少定义有一个用户,在这个文件中或在命令行或usersdb文件,
# 那么lt-cred-mech默认。
#
#no-auth

# TURN REST API flag.
# Flag that sets a special authorization option that is based upon authentication secret.
# This feature can be used with the long-term authentication mechanism, only.
# This feature purpose is to support “TURN Server REST API”, see
# “TURN REST API” link in the project’s page
http://code.google.com/p/rfc5766-turn-server/.
# This option is used with timestamp:
# usercombo -> “timestamp:userid”
# turn user -> usercombo
# turn password -> base64(hmac(secret key, usercombo))
# This allows TURN credentials to be accounted for a specific user id.
# If you don’t have a suitable id, the timestamp alone can be used.
# This option is just turning on secret-based authentication.
# The actual value of the secret is defined either by option static-auth-secret,
# or can be found in the turn_secret table in the database (see below).
#
# TURN REST API标志。
# 标志是设置一个特殊的授权选项,是基于身份验证的私密。
# 这个功能可以用于长期验证机制。
# 这个功能的目的是支持”TURN Server REST API”,看到”TURN Server REST API”项目的页面的链接
http://code.google.com/p/rfc5766-turn-server/。
# 这个选项是使用时间戳:
# usercombo -> “timestamp:userid”
# turn user -> usercombo
# turn password -> base64(hmac(secret key, usercombo))
# 这允许TURN凭证占用一个特定的用户id。
# 如果你没有一个合适的id,可以使用单独的时间戳。
# 这个选项只是打开基于私密的身份验证。
# 实际值定义的私密就是通过选择static-auth-secret,或可以在数据库中找到turn_secret表(见下文)。
#
#use-auth-secret

# ‘Static’ authentication secret value (a string) for TURN REST API only.
# If not set, then the turn server
# will try to use the ‘dynamic’ value in turn_secret table
# in user database (if present). The database-stored  value can be changed on-the-fly
# by a separate program, so this is why that other mode is ‘dynamic’.
#
# TURN REST API的’Static’身份验证的私密值(字符串)
# 如果没有设置,那么turn服务器将尝试使用’dynamic’值在用户数据库的turn_secret表(如果存在)。
# 数据库存储的值可以随时改变,通过单独的程序,所以这就是’dynamic’模式。
#
#static-auth-secret     

# ‘Static’ user accounts for long term credentials mechanism, only.
# This option cannot be used with TURN REST API or with short-term credentials
# mechanism.
# ‘Static’ user accounts are NOT dynamically checked by the turnserver process,
# so that they can NOT be changed while the turnserver is running.
#
# ‘Static’用户长期占凭证机制。
# 这个选项不能用于TURN REST API或短期凭证机制。
# ‘Static’用户帐户不是turnserver程序动态检查,所以他们不能改变在turnserver运行时。
#
#user=username1:key1
#user=username2:key2
# OR:
#user=username1:password1
#user=username2:password2
#
# Keys must be generated by turnadmin utility. The key value depends
# on user name, realm, and password:
#
# 钥匙必须由turnadmin实用程序生成。键值取决于用户名称、领域和密码:
#
# Example:
# 例子,使用以下命令:
#
# $ turnadmin -k -u ninefingers -r north.gov -p youhavetoberealistic
#
# Output: 0xbc807ee29df3c9ffa736523fb2c4e8ee
# 输出是: 0xbc807ee29df3c9ffa736523fb2c4e8ee
#
# (‘0x’ in the beginning of the key is what differentiates the key from
# password. If it has 0x then it is a key, otherwise it is a password).
# (‘0x’开始的关键是区分从密码的关键。如果它有0x,那么它是一个关键,否则这是一个密码)。
#
# The corresponding user account entry in the config file will be:
# 相应的配置文件中的用户帐户条目将:
#
#user=ninefingers:0xbc807ee29df3c9ffa736523fb2c4e8ee
# Or, equivalently, with open clear password (less secure):
#或者是这样,明文密码(不安全的):
#user=ninefingers:youhavetoberealistic
#
user=<yourname:yourpsw>

# ‘Dynamic’ user accounts database file name.
# Only users for long-term mechanism can be stored in a flat file,
# short-term mechanism will not work with option, the short-term
# mechanism required PostgreSQL or MySQL or Redis database.
# ‘Dynamic’ long-term user accounts are dynamically checked by the turnserver process,
# so that they can be changed while the turnserver is running.
# Default file name is turnuserdb.conf.
#
# ‘Dynamic’用户帐户数据库文件名。
# 只有用户长期机制可以存储在一个文件,短期机制不会处理选项,短期机制需要PostgreSQL或MySQL或
# Redis数据库。
# ‘Dynamic’的长期用户帐户在turnserver程序中动态检查的,这样他们可以改变的在turnserver运行时。
# 默认文件名是turnuserdb.conf.
#
#userdb=/usr/local/etc/turnuserdb.conf
userdb=/etc/turnuserdb.conf

# PostgreSQL database connection string in the case that we are using PostgreSQL
# as the user database.
# This database can be used for long-term and short-term credential mechanisms
# and it can store the secret value for secret-based timed authentication in TURN RESP API.
# See http://www.postgresql.org/docs/8.4/static/libpq-connect.html for 8.x PostgreSQL
# versions connection string format, see
http://www.postgresql.org/docs/9.2/static/libpq-connect.html#LIBPQ-CONNSTRING
# for 9.x and newer connection string formats.
#
# PostgreSQL数据库连接字符串,使用PostgreSQL作为用户数据库。
# 该数据库可用于长期和短期证书机制,它可以存储的私密值,为基于私密身份验证的在TURN RESP API中。
# 8.x PostgreSQL版本请参见http://www.postgresql.org/docs/8.4/static/libpq-connect.html的连接字符串
# 格式,9.x和更新的请参阅http://www.postgresql.org/docs/9.2/static/libpq-connect.html LIBPQ-CONNSTRING
# 的连接字符串格式。
#
#psql-userdb=”host=<host> dbname=<database-name>
user=<database-user> password=<database-user-password>
connect_timeout=30″

# MySQL database connection string in the case that we are using MySQL
# as the user database.
# This database can be used for long-term and short-term credential mechanisms
# and it can store the secret value for secret-based timed authentication in TURN RESP API.
# Use string format as below (space separated parameters, all optional):
#
# MySQL数据库连接字符串,使用MySQL作为用户数据库。
# 该数据库可用于长期和短期证书机制,它可以存储的私密值,为基于私密身份验证的在TURN RESP API中。
# 使用字符串格式如下(空间分离参数,所有可选):
#
#mysql-userdb=”host=<host> dbname=<database-name>
user=<database-user> password=<database-user-password>
port=<port> connect_timeout=<seconds>”

# Redis database connection string in the case that we are using Redis
# as the user database.
# This database can be used for long-term and short-term credential mechanisms
# and it can store the secret value for secret-based timed authentication in TURN RESP API.
# Use string format as below (space separated parameters, all optional):
#
# Redis数据库连接字符串,使用Redis作为用户数据库。
# 该数据库可用于长期和短期证书机制,它可以存储的私密值,为基于私密身份验证的在TURN RESP API中。
# 使用字符串格式如下(空间分离参数,所有可选):
#
#redis-userdb=”ip=<ip-address> dbname=<database-number>
password=<database-user-password> port=<port>
connect_timeout=<seconds>”

# Redis status and statistics database connection string, if used (default – empty, no Redis stats DB used).
# This database keeps allocations status information, and it can be also used for publishing
# and delivering traffic and allocation event notifications.
# The connection string has the same parameters as redis-userdb connection string.
# Use string format as below (space separated parameters, all optional):
#
# Redis状态和统计数据库连接字符串,如果使用(默认空,没有Redis统计数据库使用)。
# 这个数据库保持分配状态信息,它也可以用于发布和交付传输和分配事件通知。
# 连接字符串有相同的参数作为redis-userdb连接字符串。
# 使用字符串格式如下(空间分离参数,所有可选):
#
#redis-statsdb=”ip=<ip-address> dbname=<database-number>
password=<database-user-password> port=<port>
connect_timeout=<seconds>”

# Realm for long-term credentials mechanism and for TURN REST API.
#
# TURN REST API的长期凭证机制范围。
#
#realm=mycompany.org

# Per-user allocation quota.
# default value is 0 (no quota, unlimited number of sessions per user).
#
# 每个用户分配配额。
# 默认值为0(没有配额,每个用户无限数量的会话)。
#
#user-quota=0

# Total allocation quota.
# default value is 0 (no quota).
#
# 总分配配额。
# 默认值为0(无配额)。
#
#total-quota=0

# Max bytes-per-second bandwidth a TURN session is allowed to handle
# (input and output network streams are treated separately). Anything above
# that limit will be dropped or temporary suppressed (within
# the available buffer limits).
#
# TURN会话允许最大的传输占用带宽(输入和输出网络流分别处理)。
# 高于限制将被删除或暂时抑制(在可用的缓冲区范围内)。
#
#max-bps=0
max-bps=1024

# Uncomment if no UDP client listener is desired.
# By default UDP client listener is always started.
#
# 如果没有UDP客户端监听器需要取消。
# 默认情况下UDP客户端监听器总是启动。
#
#no-udp

# Uncomment if no TCP client listener is desired.
# By default TCP client listener is always started.
#
# 如果没有TCPP客户端监听器需要取消。
# 默认情况下TCPP客户端监听器总是启动。
#
#no-tcp

# Uncomment if no TLS client listener is desired.
# By default TLS client listener is always started.
#
# 如果没有TLS客户端监听器需要取消。
# 默认情况下TLS客户端监听器总是启动。
#
#no-tls

# Uncomment if no DTLS client listener is desired.
# By default DTLS client listener is always started.
#
# 如果没有DTLS客户端监听器需要取消。
# 默认情况下DTLS客户端监听器总是启动。
#
#no-dtls

# Uncomment if no UDP relay endpoints are allowed.
# By default UDP relay endpoints are enabled (like in RFC 5766).
#
# 如果不允许UDP中继端点需要取消。
# 默认情况下启用UDP继电器端点(如在RFC 5766)。
#
#no-udp-relay

# Uncomment if no TCP relay endpoints are allowed.
# By default TCP relay endpoints are enabled (like in RFC 6062).
#
# 如果不允许TCP中继端点需要取消。
# 默认情况下启用TCP继电器端点(如在RFC 5766)。
#
#no-tcp-relay

# Uncomment if extra security is desired,
# with nonce value having limited lifetime (600 secs).
# By default, the nonce value is unique for a session,
# but it has unlimited lifetime. With this option,
# the nonce lifetime is limited to 600 seconds, after that
# the client will get 438 error and will have to re-authenticate itself.
#
# 取消如果需要额外的安全,现时已有有限的生命周期(600秒)。
# 默认情况下,一个会话的唯一临界值,但它一般拥有无限的生命周期。这个选项,临界值
# 仅限于600秒,之后,客户端将得到438错误,将不得不重新认证。
#
#stale-nonce

# Certificate file.
# Use an absolute path or path relative to the
# configuration file.
#
# 证书文件。
# 使用绝对路径或路径相对于配置文件。
#
#cert=/usr/local/etc/turn_server_cert.pem

# Private key file.
# Use an absolute path or path relative to the
# configuration file.
# Use PEM file format.
#
# 私钥文件。
# 使用绝对路径或路径相对于配置文件。使用PEM文件格式。
#
#pkey=/usr/local/etc/turn_server_pkey.pem

# Private key file password, if it is in encoded format.
# This option has no default value.
#
# 私有密钥文件密码,如果是在编码格式。
# 这个选项没有默认值。
#
#pkey-pwd=…

# Allowed OpenSSL cipher list for TLS/DTLS connections.
# Default value is “DEFAULT”.
#
# 允许OpenSSL的密码列表为TLS/DTLS连接。
# 默认值是”DEFAULT”
#
#cipher-list=”DEFAULT”

# CA file in OpenSSL format.
# Forces TURN server to verify the client SSL certificates.
# By default it is not set: there is no default value and the client
# certificate is not checked.
#
# 在OpenSSL格式的CA文件。
# 强制TURN服务器验证客户端SSL证书。
# 默认情况下它没有设置:没有默认值,不检查的客户端证书。
#
# Example:
#CA-file=/etc/ssh/id_rsa.cert

# Curve name for EC ciphers, if supported by OpenSSL library (TLS and DTLS).
# The default value is prime256v1.
#
# 曲线名称的EC密码,如果由OpenSSL库支持(TLS和DTLS)。
# 默认值是prime256v1。
#
#ec-curve-name=prime256v1

# Use 566 bits predefined DH TLS key. Default size of the key is 1066.
#
# 使用566位预定义DH TLS键。默认键大小是1066
#
#dh566

# Use 2066 bits predefined DH TLS key. Default size of the key is 1066.
#
# 使用2066位预定义DH TLS键。默认键大小是1066
#
#dh2066

# Use custom DH TLS key, stored in PEM format in the file.
# Flags –dh566 and –dh2066 are ignored when the DH key is taken from a file.
#
# 使用惯例的DH TLS键,使用PEM格式存储在文件里
# 当DH键从文件里加载,将忽略标志–dh566和–dh2066
#
#dh-file=<DH-PEM-file-name>

# Flag to prevent stdout log messages.
# By default, all log messages are going to both stdout and to
# the configured log file. With this option everything will be
# going to the configured log only (unless the log file itself is stdout).
#
# 标志防止输出日志信息
# 默认情况下,所有日志消息将输出到配置的日志文件。采用这一选项都将只配置日志
# (除非日志文件本身是输出的)。
#
#no-stdout-log

# Option to set the log file name.
# By default, the turnserver tries to open a log file in
# /var/log, /var/tmp, /tmp and current directories directories
# (which open operation succeeds first that file will be used).
# With this option you can set the definite log file name.
# The special names are “stdout” and “-” – they will force everything
# to the stdout. Also, the “syslog” name will force everything to
# the system log (syslog).
# In the runtime, the logfile can be reset with the SIGHUP signal
# to the turnserver process.
#
# 设置日志文件
# 默认情况下,turnserver尝试一个日志文件在/var/log,/var/tmp,/tmp和
# 当前目录(那个文件先打开成功,文件将被使用)。
# 采用这一选项可以设置明确的日志文件名。
# 特殊的名字是”stdout”和”-“——他们将强制所有的输出。同时,”syslog”名称将强制所有的系统日志(syslog)。
# 在运行时,日志文件可以重置通过SIGHUP信号在turnserver程序中。
#
#log-file=/var/tmp/turn.log

# Option to redirect all log output into system log (syslog).
#
# 选择重定向所有日志输出到系统日志(syslog)。
#
#syslog

# This flag means that no log file rollover will be used, and the log file
# name will be constructed as-is, without PID and date appendage.
#
# 这个标志意味着没有日志文件将使用翻转,并按原样将创建日志文件名称,没有PID和日期的附加。
#
#simple-log

# Option to set the “redirection” mode. The value of this option
# will be the address of the alternate server for UDP & TCP service in form of
# <ip>[:<port>]. The server will send this value in the attribute
# ALTERNATE-SERVER, with error 300, on ALLOCATE request, to the client.
# Client will receive only values with the same address family
# as the client network endpoint address family.
# See RFC 5389 and RFC 5766 for ALTERNATE-SERVER functionality description.
# The client must use the obtained value for subsequent TURN communications.
# If more than one –alternate-server options are provided, then the functionality
# can be more accurately described as “load-balancing” than a mere “redirection”.
# If the port number is omitted, then the default port
# number 3478 for the UDP/TCP protocols will be used.
# Colon ( characters in IPv6 addresses may conflict with the syntax of
# the option. To alleviate this conflict, literal IPv6 addresses are enclosed
# in square brackets in such resource identifiers, for example:
# [2001:db8:85a3:8d3:1319:8a2e:370:7348]:3478 .
# Multiple alternate servers can be set. They will be used in the
# round-robin manner. All servers in the pool are considered of equal weight and
# the load will be distributed equally. For example, if we have 4 alternate servers,
# then each server will receive 25% of ALLOCATE requests. A alternate TURN server
# address can be used more than one time with the alternate-server option, so this
# can emulate “weighting” of the servers.
#
# 选项设置”redirection”模式。这个选项的值将备用服务器的地址UDP和TCP服务形式的<ip>[:<port>]。
# 服务器将发送这个值属性ALTERNATE-SERVER,错误300,在ALLOCATE请求,客户端。
# 客户端将只接收和自己相同的地址族的客户端的值。查看RFC 5389和RFC 5766为ALTERNATE-SERVER的功能描述。
# 客户端必须使用获得的值为随后的TURN通信。如果不止一个——alternate-server选项提供,那么功能可以更准确
# 地描述为”load-balancing”,而不仅仅是一个”redirection”。如果端口号省略,那么为UDP/TCP协议,使用默认端
# 口号是3478。冒号(在IPv6地址字符可能与选项的语法冲突。缓解这种冲突,文字IPv6地址包含在方括号在这种
# 资源标识符,例如[2001:db8:85a3:8d3:1319:8a2e:370:7348]:3478 。
# 可以设置多个备用服务器。他们将用于循环的方式。所有服务器池中被认为是平等的重量和载荷将平均分配的原则。
# 例如,如果我们有4个备用服务器,每个服务器将获得25%的分配请求。备用TURN服务器地址可以使用超过一次
# alternate-server选项,所以这可以效仿的”weighting”服务器。
#
# Examples:
#alternate-server=1.2.3.4:5678
#alternate-server=11.22.33.44:56789
#alternate-server=5.6.7.8
#alternate-server=[2001:db8:85a3:8d3:1319:8a2e:370:7348]:3478
              
# Option to set alternative server for TLS & DTLS services in form of
# <ip>:<port>. If the port number is omitted, then the default port
# number 5349 for the TLS/DTLS protocols will be used. See the previous
# option for the functionality description.
#
# 选项设置替代服务器TLS和DTLS服务形式的<ip>:<port>。
# 如果省略的端口号,那么默认端口号5349将使用TLS/DTLS协议。看到前面选择的功能描述。
#
# Examples:
#tls-alternate-server=1.2.3.4:5678
#tls-alternate-server=11.22.33.44:56789
#tls-alternate-server=[2001:db8:85a3:8d3:1319:8a2e:370:7348]:3478

# Option to suppress TURN functionality, only STUN requests will be processed.
# Run as STUN server only, all TURN requests will be ignored.
# By default, this option is NOT set.
#
# 选择抑制TURN功能,只有STUN的请求将被处理。
# 作为STUN服务器,所有TURN请求将被忽略。
# 默认情况下,没有设置这个选项。
#
#stun-only

# Option to suppress STUN functionality, only TURN requests will be processed.
# Run as TURN server only, all STUN requests will be ignored.
# By default, this option is NOT set.
#
# 选择抑制STUN功能,只有TURN的请求将被处理。
# 作为TURN服务器,所有STUN请求将被忽略。
# 默认情况下,没有设置这个选项。
#
#no-stun

# This is the timestamp/username separator symbol (character) in TURN REST API.
# The default value is ‘:’.
#
# 这是时间戳/用户名分离器符号(字符)在TURN REST API。
# 默认是使用’:’
#
# rest-api-separator=:    

# Flag that can be used to disallow peers on the loopback addresses (127.x.x.x and ::1).
# This is an extra security measure.
#
# 标记用于不接受的端在环回地址(127.x.x.x 和 ::1)。
# 这是一个额外的安全措施。
#
#no-loopback-peers

# Flag that can be used to disallow peers on well-known broadcast addresses (224.0.0.0 and above, and FFXX:*).
# This is an extra security measure.
#
# 标记用于不接受的端在广播地址(224.0.0.0和以上的,和FFXX:*)。
# 这是一个额外的安全措施。
#
#no-multicast-peers

# Option to set the max time, in seconds, allowed for full allocation establishment.
# Default is 60 seconds.
#
# 选项设置的最大时间,以秒为单位,允许完整的分配。
# 默认60秒
#
#max-allocate-timeout=60

# Option to allow or ban specific ip addresses or ranges of ip addresses.
# If an ip address is specified as both allowed and denied, then the ip address is
# considered to be allowed. This is useful when you wish to ban a range of ip
# addresses, except for a few specific ips within that range.
# This can be used when you do not want users of the turn server to be able to access
# machines reachable by the turn server, but would otherwise be unreachable from the
# internet (e.g. when the turn server is sitting behind a NAT)
#
# 选择允许或禁止特定的ip地址或ip地址范围。
# 如果指定一个ip地址允许和拒绝,那么ip地址被认为是允许的。这是有用的,当你希望禁止一个范
# 围的ip地址,除了一些特定的ip范围内。
# 这可以使用当你不希望turn服务器的用户能够访问机器通过turn服务器,但可能是另一方面从互联
# 网上不能到达(例如,当turn服务器是在一个NAT后)
#
# Examples:
# denied-peer-ip=83.166.64.0-83.166.95.255
# allowed-peer-ip=83.166.68.45

# File name to store the pid of the process.
# Default is /var/run/turnserver.pid (if superuser account is used) or
# /var/tmp/turnserver.pid .
#
# 存储进程pid的文件名。
# 默认是/var/run/turnserver.pid(超级用户使用)或者是/var/tmp/turnserver.pid
#
#pidfile=”/var/run/turnserver.pid”
pidfile=”/var/tmp/turnserver.pid”

# Require authentication of the STUN Binding request.
# By default, the clients are allowed anonymous access to the STUN Binding functionality.
#
# 需要STUN绑定请求的身份验证。
# 默认情况下,客户允许匿名访问STUN绑定功能。
#
#secure-stun

# Require SHA256 digest function to be used for the message integrity.
# By default, the server uses SHA1 (as per TURN standard specs).
# With this option, the server
# always requires the stronger SHA256 function. The client application
# must support SHA256 hash function if this option is used. If the server obtains
# a message from the client with a weaker (SHA1) hash function then the
# server returns error code 426.
#
# 需要SHA256采摘功能用于消息的完整性。
# 默认情况下,服务器使用SHA1(按标准规格)。
# 采用这一选项,服务器总是需要更强的SHA256功能。客户端应用程序必须支持SHA256散列函数
# 如果使用这个选项。如果服务器获得消息从客户端较弱(SHA1)散列函数那么服务器返回错误代码426。
#
#sha256

# Mobility with ICE (MICE) specs support.
#
# 移动的ICE(MICE)的规范支持。
#
#mobility

# User name to run the process. After the initialization, the turnserver process
# will make an attempt to change the current user ID to that user.
#
# 用户名运行程序。初始化后,turnserver程序将试图改变当前用户的用户ID。
#
#proc-user=<user-name>

# Group name to run the process. After the initialization, the turnserver process
# will make an attempt to change the current group ID to that group.
#
# 组名运行程序。初始化后,turnserver程序将试图改变当前组的组ID。
#
#proc-group=<group-name>

# Turn OFF the CLI support.
# By default it is always ON.
# See also options cli-ip and cli-port.
#
# 关掉CLI的支持。
# 默认情况下它总是ON。
# 参阅选项cli-ip和cli-port。
#
#no-cli

#Local system IP address to be used for CLI server endpoint. Default value
# is 127.0.0.1.
#
# 本地系统的IP地址将用于CLI服务器端点。默认值是127.0.0.1。
#
#cli-ip=127.0.0.1

# CLI server port. Default is 5766.
#
# CLI服务器端口。默认是5766。
#
#cli-port=5766

# CLI access password. Default is empty (no password).
#
# CLI访问密码。默认是空的(没有密码)。
#
#cli-password=logen

# Server relay. NON-STANDARD AND DANGEROUS OPTION.
# Only for those applications when we want to run
# server applications on the relay endpoints.
# This option eliminates the IP permissions check on
# the packets incoming to the relay endpoints.
#
# 中继服务器。NON-STANDARD和DANGEROUS的选择。
# 只对这些应用程序时,我们想在中继服务器上运行服务器应用程序端点。
# 这个选项可以消除IP权限检查传递的数据包传入的端点。
#
#server-relay

# Maximum number of output sessions in ps CLI command.
# This value can be changed on-the-fly in CLI. The default value is 256.
#
# 最大数量的输出会议在ps CLI命令。
# 这个值可以动态改变在CLI。默认值是256。
#
#cli-max-output-sessions

# Set network engine type for the process (for internal purposes).
#
# 设置网络引擎类型(用于内部目的)的过程。
#
#ne=[1|2|3]

# Do not allow an SSL/TLS version of protocol
#
# 不允许一个SSL/TLS版本的协议
#
#no-sslv2
#no-sslv3
#no-tlsv1
#no-tlsv1_1
#no-tlsv1_2




turnuserdb.conf

#This file can be used as user accounts storage for long-term credentials mechanism.
#这个文件可以用作长期用户帐户存储凭证机制。
#
#username1:key1
#username2:key2
# OR:
#username1:password1
#username2:password2
#
# Keys must be generated by turnadmin utility. The key value depends
# on user name, realm, and password:
# 钥匙必须由turnadmin实用程序生成。键值取决于用户名称、领域和密码:
#
# Example:
# 例子,使用以下命令:
# $ turnadmin -k -u ninefingers -r north.gov -p youhavetoberealistic
# Output: 0xbc807ee29df3c9ffa736523fb2c4e8ee
# 输出是: 0xbc807ee29df3c9ffa736523fb2c4e8ee
#
# (‘0x’ in the beginning of the key is what differentiates the key from
# password. If it has 0x then it is a key, otherwise it is a password).
# (‘0x’开始的关键是区分从密码的关键。如果它有0x,那么它是一个关键,否则这是一个密码)。
#
# The corresponding user account entry in the userdb file will be:
# 相应的用户帐号在userdb文件中是:
#
#ninefingers:0xbc807ee29df3c9ffa736523fb2c4e8ee
# Or, equivalently (less secure):
#或者是这样(不安全的):
#ninefingers:youhavetoberealistic
#
yourname:yourpsw


转自:www.webrtcbbs.com

webrtc与stunserver、turnserver建立连接花费时间十秒左右

  很奇怪,使用之前基于webrtc的p2p模块时出了了大问题,问题如标题左右,记得之前使用另外版本的webrtc做开发的时候,本地在CreateOffer后能够能够很快和turnserver连接,估计最左就两三秒,然而现在却是十秒左右了!

   由于换了一个webrtc的版本(此版本是支持winxp系统的),所以第一感觉似乎是webrtc版本的问题,实际上不是,因为就算是换回之前的版本,client和turnserver的连接时间几乎花费了与当前版本webrtc 差不多的时间。

 
 之前也说了,就是之前有点时间,client与turnserver的连接是正常的,于是在google到了一个解决方案,即是trickle
ice技术,据说使用该方法能够大大缩短client与opposite
client的连接时间,这个解决方案似乎和当前所遇到的问题擦着一点边,但是似乎可以值得尝试,因为这或多或少会提升client连接到对面的体验!然而client和turnserver的连接速度是似乎没多大作用,放弃此方案。

   
实际上只要网络状态好,按道理来讲本地client和turnserver的connect
时间应该很短才对,实际上也是如此!后来调试发现在client连接turnserver的过程中在stunrequest.cc中都有调用OnTimeout函数,而且说明本地client和turnserver的连接很不理想,通过查看源码获知在timeout的过程中,本地客户端总共尝试了MAX_SENDS次重发送(发送给turnserver、stunserver),在源码中MAX_SENDS被宏定义为9,超过9次之后才正式通知外部(OnTimeout),
OnTimeout函数最终会触发webrtc底层,告知client本地的icecandidate的收集已经完成,接着出发了外部的OnIceGatheringChange函数,该函数的icecandidate收集状态state将会为kIceGatheringComplete,此时本地的client才会知道本地的icecandidate信息收集已经完结,那么怎么根据当前peerconnection是否成功和stunserver、turnserver连接呢?如果已经收集到的icecandidate中不但包含了本地的ip信息,还包括了stunserver、turnserver的ip信息,那么就可以决断本地client已经成功和turnserver连接,如果只是包含了本地的ip地址信息(icecandidate信息的type字段为host、local),那么就可以决断本地client连接turnserver服务器失败。

 
 而我遇到的情况是,从client开始连接到收集icecandidate信息成功花费了太长的时间(10左右),不过最后还是能够成功连接上turnserver,之前也说了花费了那么长时间全是浪费在timeout上了,那么问题来了?为什么我本地的网络情况良好(可下载、可开网页),怎么在就是在探测turnserver的时候那么艰难呢?断点查看timeout时对应的ip地址,明白了,这个ip地址是我电脑中之前安装的virtulBox中一个虚拟机的ip地址,这个我真是没想到!查看源码,知道webrtc在探测turnserver的时候是要遍历当前平台下的所有的网络适配器的,不管是系统自带的无限网络、还是以太有线网,还是其他应用软件虚拟出来的适配器,webrtc探测时都会遍历,之所以出现时间是花在timeout上,也只是说明对应的网络适配器在和turnserver尝试连接的时候,网路状况不好!鉴于此,于是在控制面板中将virtualBox中虚拟出来的适配器禁用,重新打开本地的client,发现几乎是秒连了!