Skip to content

Commit

Permalink
Choose correct port for responding to UDP.
Browse files Browse the repository at this point in the history
Chooses the correct port to respond to on the remote host per RFC's 3261
and 3581.

Resolves kirm#134.
  • Loading branch information
jeremy-j-ackso committed Nov 9, 2018
1 parent d6a5852 commit 556907d
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion sip.js
Original file line number Diff line number Diff line change
Expand Up @@ -769,7 +769,13 @@ function makeUdpTransport(options, callback) {
msg.headers.via[0].params.rport = rinfo.port;
}

callback(msg, {protocol: 'UDP', address: rinfo.address, port: rinfo.port, local: {address: address, port: port}});
var targetPort = 5060;
if(msg.headers.via[0].params.hasOwnProperty('sent-by'))
targetPort = msg.headers.via[0].params.hasOwnProperty('sent-by');
if(msg.headers.via[0].params.hasOwnProperty('rport'))
targetPort = msg.headers.via[0].params.rport;

callback(msg, {protocol: 'UDP', address: rinfo.address, port: targetPort, local: {address: address, port: port}});
}
}

Expand Down

0 comments on commit 556907d

Please sign in to comment.