将SIP邀请从SIP中继发送到手机

时间:2019-12-25 22:38:12

标签: sip

我有一个通过https://www.sip.us的免费演示SIP中继。我下载并配置了freeSWITCH,以允许使用SIP中继线对手机进行软件电话呼叫。我能够成功使用SIP中继线使用X-Lite软电话向手机进行出站呼叫。

但是,我的最终目标是成功地从服务器发送SIP邀请到移动电话,其唯一目的是从响应中提取包含IP地址的“ c = IN”头。所以我的问题是,我将如何发送SIP邀请(使用SIP中继)到手机并从c = IN字段提取IP地址?

我是SIP的新手,我甚至不确定我要执行的操作是否可行,但是我尝试了以下代码,最后一个console.log(res1)禁止输入403。我将以下npm模块https://github.com/kirm/sip.js用于代码:


    sipClient.send(invite, function(res) {

    var n_once = res.headers['proxy-authenticate'][0].nonce;


     var ctx = {};
     var authed = digest.signRequest(ctx,invite,res,{user: '5233339346',realm:'gw.sip.us' , password: 'serkrx44492qrb95'});

    console.log(authed.headers['proxy-authorization'][0].uri);
    authed.headers.via.pop();
    authed.headers['proxy-authorization'][0].uri = '"sip:+5233339346@gw.sip.us"';
    authed.headers.cseq.seq++;
    sipClient.destroy();
     sipClient = sip.create({
        port          : sourcePort,
        publicAddress : sourceIp,
        rport         : rport,
        tcp           : tcp,
        udp           : !tcp
    });

    sipClient.send(authed, function(res1) {
    console.log("**************************************************");
    console.log(sip.stringify(authed) + '\n');
    console.log("**************************************************");

    console.log("**************************************************");
    console.log(sip.stringify(res1) + '\n');
    console.log("**************************************************");


    sipClient.destroy();

    });
    });```

The initial request (invite) is as follows:

INVITE sip:+5205101984@174.18.53.9:5060 SIP/2.0
To: sip:+5205101984@174.18.53.9:5060
From: sip:+5233339346@gw.sip.us:6161;tag=568437
Call-ID: 568437
CSeq: 50452 INVITE
Content-Type: application/sdp
Contact: sip:+5233339346@gw.sip.us:6161
Max-Forwards: 70
Content-Length: 0

the response to that is as follows:

SIP/2.0 407 Proxy Authentication Required
Via: SIP/2.0/UDP gw.sip.us:6161;branch=z9hG4bK715271;rport=6161;received=3.136.158.50
From: sip:+5233339346@gw.sip.us:6161;tag=568437
To: sip:+5205101984@174.18.53.9:5060;tag=FD6D5jjUmygpm
Call-ID: 568437
CSeq: 50452 INVITE
User-Agent: FreeSWITCH-mod_sofia/1.10.1~64bit
Accept: application/sdp
Allow: INVITE, ACK, BYE, CANCEL, OPTIONS, MESSAGE, INFO, UPDATE, REGISTER, REFER, NOTIFY, PUBLISH, SUBSCRIBE
Supported: timer, path, replaces
Allow-Events: talk, hold, conference, presence, as-feature-event, dialog, line-seize, call-info, sla, include-session-description, presence.winfo, message-summary, refer
Proxy-Authenticate: Digest realm="gw.sip.us",nonce="1eab4dfc-c06d-4a77-b1c1-7663196ef98a",algorithm=MD5,qop="auth"
Content-Length: 0

then I send the following:

INVITE sip:+5205101984@174.18.53.9:5060 SIP/2.0
To: sip:+5205101984@174.18.53.9:5060
From: sip:+5233339346@gw.sip.us:6161;tag=568437
Call-ID: 568437
CSeq: 50453 INVITE
Content-Type: application/sdp
Contact: sip:+5233339346@gw.sip.us:6161
Max-Forwards: 70
Content-Length: 0
Via: SIP/2.0/UDP gw.sip.us:6161;branch=z9hG4bK212336;rport
Proxy-Authorization: Digest realm="gw.sip.us",username="5233339346",nonce="1eab4dfc-c06d-4a77-b1c1-7663196ef98a",uri="sip:+5233339346@gw.sip.us",nc=00000001,algorithm=md5,cnonce="0918657246a41f5577d7b334f793ca42",qop=auth,response="7c8cd15b73c69c4d1449242c81cc130e"

which then gives a 403 Forbidden response.


0 个答案:

没有答案