drachtio / drachtio-fsmrf

Drachtio freeswitch-based media resource function -- http://davehorton.github.io/drachtio-fsmrf
MIT License
48 stars 26 forks source link

Problems overwriting User-Agent header #46

Closed spointer closed 4 years ago

spointer commented 4 years ago

Hi Dave,

When i call the connectCaller with my own headers, "User-Agent" header is not overwritten.

const {endpoint, dialog} = await mediaserver.connectCaller(req, res, { headers: { 'User-Agent': 'spointer', 'X-version': 'v0.1.0' } });

The actual INVITE 200 OK header is as follows:

SIP/2.0 200 OK Via: SIP/2.0/UDP x.x.x.x:5060;branch=z9hG4bK1d3e92ab45f8661d8-1b38d-0_111501;rport=5060 Via: SIP/2.0/UDP x.x.x.x:5060;branch=z9hG4bK1d3e92ab45f8661d8-1b38d-0 Record-Route: <sip:x.x.x.x;lr> From: sip:1200@x.x.x.x;tag=6b81a7f403ae430c783f9927021fa35c To: sip:1201@172.26.0.2;tag=3DDQ39K2v389j Call-ID: AAkyo3__AdgAABez0-lBRw--c4407075 CSeq: 111501 INVITE Contact: User-Agent: drachtio-fsmrf:98242b28-424f-496c-99e6-d53d09d8e57e Content-Type: application/sdp Content-Length: 228 X-version: v0.1.0 X-esl-outbound: 192.168.10.200:53599

v=0 o=spointer 1602619950 1602619951 IN IP4 172.26.0.4 s=spointer c=IN IP4 172.26.0.4 t=0 0 m=audio 22444 RTP/AVP 0 101 a=rtpmap:0 PCMU/8000 a=rtpmap:101 telephone-event/8000 a=fmtp:101 0-16 a=ptime:20 a=sendrecv

I see createUAS is called inside the connectCaller function and it sets custom headers as you explained in your API reference like this.

srf.invite((req, res) => { let mySdp; // populated somehow with SDP we want to answer in 200 OK srf.createUas(req, res, { localSdp: mySdp, headers: { 'User-Agent': 'drachtio/iechyd-da', 'X-Linked-UUID': '1e2587c' } }, (err, uas) => { if (err) return console.log(Error creating dialog: ${err}); console.log(dialog established, local tag is ${uas.sip.localTag});

  uas.on('destroy', () => console.log('caller hung up'));
});

});

Any suggestions are appreciated.

spointer commented 4 years ago

When i set the header field name to "user-agent"(not User-Agent), i could see my own User-Agent value is appended to the actual User-Agent header of INVITE 200 OK like this.

User-Agent: spointer,drachtio-fsmrf:12242b28-344f-416c-99e6-d53d09d8e57e

davehorton commented 4 years ago

This is not recommended. That user agent header is used (parsed) by the mrf.xml freeswitch dialplan and the information helps identify the call to drachtio-fsmrf in the outbound esl connection