日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

搭建turn服务器

發布時間:2024/8/1 编程问答 32 豆豆
生活随笔 收集整理的這篇文章主要介紹了 搭建turn服务器 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

編譯環境搭建

Vagrant

Windows用戶要想在Windows下編譯rfc5766-turn-server的話,需安裝虛擬機,我推薦程序員專用的虛擬機——Vagrant,Linux用戶請忽略。其配置文件如下:

Vagrantfile

1 2 3 4 5 6 7 8 9 10 11 12 13 14 #?-*-?mode:?ruby?-*- #?vi:?set?ft=ruby?: ?? VAGRANTFILE_API_VERSION?=?"2" ?? Vagrant.configure(VAGRANTFILE_API_VERSION)?do?|config| ??config.vm.box?=?"hashicorp/precise64" ??config.vm.box_url?=?"virtualbox.box" ???? ??config.vm.provider?"virtualbox"?do?|vb| ????vb.memory?=?2048 ????vb.cpus?=?2 ??end end

使用命令行啟動它:

1 2 vagrant?up vagrant?ssh

安裝編譯工具鏈

1 sudo?apt-get?install?build-essential

確認安裝成功:

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 vagrant@precise64:~$?gcc?-v Using?built-in?specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.6/lto-wrapper Target:?x86_64-linux-gnu Configured?with:?../src/configure?-v?--with-pkgversion='Ubuntu/Linaro?4.6.3-1ubu ntu5'?--with-bugurl=file:///usr/share/doc/gcc-4.6/README.Bugs?--enable-languages =c,c++,fortran,objc,obj-c++?--prefix=/usr?--program-suffix=-4.6?--enable-shared --enable-linker-build-id?--with-system-zlib?--libexecdir=/usr/lib?--without-incl uded-gettext?--enable-threads=posix?--with-gxx-include-dir=/usr/include/c++/4.6 --libdir=/usr/lib?--enable-nls?--with-sysroot=/?--enable-clocale=gnu?--enable-li bstdcxx-debug?--enable-libstdcxx-time=yes?--enable-gnu-unique-object?--enable-pl ugin?--enable-objc-gc?--disable-werror?--with-arch-32=i686?--with-tune=generic?- -enable-checking=release?--build=x86_64-linux-gnu?--host=x86_64-linux-gnu?--targ et=x86_64-linux-gnu Thread?model:?posix gcc?version?4.6.3?(Ubuntu/Linaro?4.6.3-1ubuntu5) vagrant@precise64:~$?make?-v GNU?Make?3.81 Copyright?(C)?2006??Free?Software?Foundation,?Inc. This?is?free?software;?see?the?source?for?copying?conditions. There?is?NO?warranty;?not?even?for?MERCHANTABILITY?or?FITNESS?FOR?A PARTICULAR?PURPOSE. ?? This?program?built?for?x86_64-pc-linux-gnu vagrant@precise64:~$

安裝依賴項

1 2 3 4 5 6 sudo?apt-get?install?libssl-dev sudo?apt-get?install?libevent-dev sudo?apt-get?install?libpq-dev sudo?apt-get?install?mysql-client sudo?apt-get?install?libmysqlclient-dev sudo?apt-get?install?libhiredis-dev

其中SQL相關的依賴項可能會失敗,不過這也沒什么大不了的,SQL庫是為了支持更多用戶而準備的,如果你不是生產環境的話,忽略也行。

檢出代碼

Vagrantfile的同一目錄檢出https://code.google.com/p/rfc5766-turn-server/source/checkout?到任意目錄,我檢出到了stun,下文腳本請注意自行對號入座。

cd進去

1 2 3 4 5 6 7 8 9 10 11 vagrant@precise64:~$?cd?/vagrant vagrant@precise64:/vagrant$?ls down.cmd??stun??up.cmd??Vagrantfile vagrant@precise64:/vagrant$?cd?stun vagrant@precise64:/vagrant/stun$?ls AUTHORS????examples??LICENSE.OpenSSL??NOTE???????????????rpm bin????????include???Makefile?????????postinstall.txt????src build??????INSTALL???Makefile.in??????README.turnadmin???STATUS ChangeLog??lib???????make-man.sh??????README.turnserver??TODO configure??LICENSE???man??????????????README.turnutils???turndb vagrant@precise64:/vagrant/stun$

開始編譯

生成makefile文件,編譯,安裝

1 2 3 ./configure make sudo?make?install

測試

試試看是否編譯成功,先看看turnserver支持哪些功能

1 turnserver?-h?>?help.txt
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 0:?log?file?opened:?/var/tmp/turn_1313_2014-11-04.log 0:? RFC?3489/5389/5766/5780/6062/6156?STUN/TURN?Server Version?Citrix-3.2.4.6?'Marshal?West' 0:? Max?number?of?open?files/sockets?allowed?for?this?process:?4096 0:? Due?to?the?open?files/sockets?limitation, max?supported?number?of?TURN?Sessions?possible?is:?2000?(approximately) 0:? ?? ====?Show?him?the?instruments,?Practical?Frost:?==== ?? 0:?TLS?supported 0:?DTLS?supported 0:?Redis?supported 0:?PostgreSQL?is?not?supported 0:?MySQL?is?not?supported 0:?OpenSSL?compile-time?version?0x1000100f:?fresh?enough 0:?Default?Net?Engine?version:?2?(UDP?thread?per?network?endpoint) ?? ===================================================== ?? ?? Usage:?turnserver?[options] Options: ?-d,?--listening-device?? <device-name>???? Listener?interface?device?(NOT?RECOMMENDED.?Optional,?Linux?only). ?-p,?--listening-port???? <port>??????? TURN?listener?port?(Default:?3478). ????????????????????????Note:?actually,?TLS?&?DTLS?sessions?can?connect?to?the?"plain"?TCP?&?UDP?port(s),?too, ????????????????????????if?allowed?by?configuration. ????????????????????????省略……

支持協議

測試各基礎協議是否支持

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 ?$?cd?examples ?vagrant@precise64:/vagrant/stun/examples$?./scripts/rfc5769.sh RFC?5769?message?fingerprint?test(0)?result:?success RFC?5769?simple?request?short-term?credentials?and?integrity?test?result:?succes s RFC?5769?NEGATIVE?fingerprint?test(0)?result:?success RFC?5769?message?structure,?long-term?credentials?and?integrity?test?result:?suc cess RFC?5769?message?encoding?test?result:?success RFC?5769?NEGATIVE?long-term?credentials?test?result:?success RFC?5769?message?fingerprint?test(1)?result:?success RFC?5769?IPv4?response?short-term?credentials?and?integrity?test?result:?success ?? RFC?5769?NEGATIVE?fingerprint?test(1)?result:?success RFC?5769?IPv4?encoding?result:?success RFC?5769?message?fingerprint?test(2)?result:?success RFC?5769?IPv6?response?short-term?credentials?and?integrity?test?result:?success ?? RFC?5769?NEGATIVE?fingerprint?test(2)?result:?success RFC?5769?IPv6?encoding?result:?success vagrant@precise64:/vagrant/stun/examples$

TURN測試

先安裝screen

1 sudo?apt-get?install?screen

這樣我們就能在一個終端里運行多個窗口了,使用快捷鍵Ctrl+a+c新建一個窗口,通過執行命令

1 ./scripts/basic/relay.sh

把TURN服務器運行起來:

然后執行命令:

1 ./scripts/basic/udp_c2c_client.sh

把客戶端跑起來,可以看到它在通過中轉服務器自己給自己發數據:

通過Ctrl+a+n來切回服務器的窗口,觀察到它的確在收發數據:

至此,說明一切完全正常。

Reference

http://www.cnblogs.com/Haijunzhu/p/3833350.html

http://www.cnblogs.com/mchina/archive/2013/01/30/2880680.html

https://code.google.com/p/rfc5766-turn-server/


總結

以上是生活随笔為你收集整理的搭建turn服务器的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。