為Odoo配置您的VoIP Asterisk服務器?

安裝Asterisk服務器?

依賴項?

在安裝Asterisk之前,您需要安裝以下依賴項:

  • wget

  • gcc

  • g++

  • ncurses-devel

  • libxml2-devel

  • sqlite-devel

  • libsrtp-devel

  • libuuid-devel

  • openssl-devel

  • 包配置

為了安裝libsrtp,請按照以下說明操作:

cd /usr/local/src/
wget http://srtp.sourceforge.net/srtp-1.4.2.tgz
tar zxvf srtp-1.4.2.tgz
cd /usr/local/src/srtp
./configure CFLAGS=-fPIC --prefix=/usr/local/lib
make && make install

您還需要安裝PJSIP,可以在此處下載源代碼 here。一旦源代碼目錄被提?。?/p>

  • 切換到 pjproject 源代碼目錄:

# cd pjproject
  • run:

# ./configure --prefix=/usr --enable-shared --disable-sound --disable-resample --disable-video --disable-opencore-amr CFLAGS='-O2 -DNDEBUG'
  • 構建并安裝pjproject:

# make dep
# make
# make install
  • 更新共享庫鏈接:

# ldconfig
  • 驗證是否已安裝pjproject:

# ldconfig -p | grep pj
  • 結果應該是:

libpjsua.so (libc6,x86-64) => /usr/lib/libpjsua.so
libpjsip.so (libc6,x86-64) => /usr/lib/libpjsip.so
libpjsip-ua.so (libc6,x86-64) => /usr/lib/libpjsip-ua.so
libpjsip-simple.so (libc6,x86-64) => /usr/lib/libpjsip-simple.so
libpjnath.so (libc6,x86-64) => /usr/lib/libpjnath.so
libpjmedia.so (libc6,x86-64) => /usr/lib/libpjmedia.so
libpjmedia-videodev.so (libc6,x86-64) => /usr/lib/libpjmedia-videodev.so
libpjmedia-codec.so (libc6,x86-64) => /usr/lib/libpjmedia-codec.so
libpjmedia-audiodev.so (libc6,x86-64) => /usr/lib/libpjmedia-audiodev.so
libpjlib-util.so (libc6,x86-64) => /usr/lib/libpjlib-util.so
libpj.so (libc6,x86-64) => /usr/lib/libpj.so

星號?

tar zxvf asterisk*
  • 輸入 Asterisk 目錄:

cd ./asterisk*
  • 運行Asterisk配置腳本:

./configure --with-pjproject --with-ssl --with-srtp
  • 運行Asterisk菜單選擇工具:

make menuselect
  • 在menuselect中,進入資源選項并確保啟用res_srtp。如果res_srtp旁邊有3個x,則srtp庫存在問題,您必須重新安裝它。保存配置(按x鍵)。您還應該在res_pjsip行前面看到星號。

  • 編譯并安裝Asterisk:

make && make install
  • 如果您需要示例配置文件,可以運行“make samples”安裝示例配置文件。如果您需要安裝Asterisk啟動腳本,可以運行“make config”。

DTLS證書?

  • 接下來需要設置DTLS證書。

mkdir /etc/asterisk/keys
  • 輸入Asterisk腳本目錄:

cd /asterisk*/contrib/scripts
  • 創建 DTLS 證書(將 pbx.mycompany.com 替換為您的 IP 地址或 DNS 名稱,將 My Super Company 替換為您的公司名稱):

./ast_tls_cert -C pbx.mycompany.com -O "My Super Company" -d /etc/asterisk/keys

配置Asterisk服務器?

對于WebRTC,許多必要的設置必須在對等端設置中。全局設置不能很好地流入對等端設置。默認情況下,Asterisk配置文件位于/etc/asterisk/。首先編輯http.conf文件,并確保以下行未被注釋:

;http.conf
[general]
enabled=yes
bindaddr=127.0.0.1 ; Replace this with your IP address
bindport=8088 ; Replace this with the port you want to listen on

接下來,編輯sip.conf文件。WebRTC對等體需要啟用加密、avpf和icesupport。在大多數情況下,應禁用directmedia。此外,在WebRTC客戶端下,傳輸需要列為“ws”以允許websocket連接。所有這些配置行都應該在對等體本身下設置;全局設置這些配置行可能無法正常工作:

;sip.conf
[general]
realm=127.0.0.1 ; Replace this with your IP address
udpbindaddr=127.0.0.1 ; Replace this with your IP address
transport=udp

[1060] ; This will be WebRTC client
type=friend
username=1060 ; The Auth user for SIP.js
host=dynamic ; Allows any host to register
secret=password ; The SIP Password for SIP.js
encryption=yes ; Tell Asterisk to use encryption for this peer
avpf=yes ; Tell Asterisk to use AVPF for this peer
icesupport=yes ; Tell Asterisk to use ICE for this peer
context=default ; Tell Asterisk which context to use when this peer is dialing
directmedia=no ; Asterisk will relay media for this peer
transport=udp,ws ; Asterisk will allow this peer to register on UDP or WebSockets
force_avp=yes ; Force Asterisk to use avp. Introduced in Asterisk 11.11
dtlsenable=yes ; Tell Asterisk to enable DTLS for this peer
dtlsverify=no ; Tell Asterisk to not verify your DTLS certs
dtlscertfile=/etc/asterisk/keys/asterisk.pem ; Tell Asterisk where your DTLS cert file is
dtlsprivatekey=/etc/asterisk/keys/asterisk.pem ; Tell Asterisk where your DTLS private key is
dtlssetup=actpass ; Tell Asterisk to use actpass SDP parameter when setting up DTLS

在 sip.conf 和 rtp.conf 文件中,您還需要添加或取消注釋以下行:

icesupport = true
stunaddr = stun.l.google.com:19302

最后,設置 extensions.conf:

;extensions.conf
[default]
exten => 1060,1,Dial(SIP/1060) ; Dialing 1060 will call the SIP client registered to 1060

配置Odoo VOIP?

在Odoo中,配置應該在用戶的個人偏好中完成。

../../../_images/voip_config01.png
  • SIP登錄/瀏覽器的分機號是您之前在sip.conf文件中配置的號碼(在我們的示例中為:1060)。

  • SIP密碼是您在sip.conf文件中選擇的密碼。

  • 您辦公室電話的分機號不是必填字段,但如果您想將來自Odoo的電話轉移到在sip.conf文件中配置的外部電話,則需要使用它。

配置還應在“集成”部分下的“常規設置”中完成。

../../../_images/onsip02.png
  • PBX服務器IP應該與您在http.conf文件中定義的IP相同。

  • WebSocket 應該是:ws://localhost:XXXX/ws,其中 “localhost” 需要與之前定義的 IP 相同,”XXXX” 需要是 http.conf 文件中定義的端口。