Skip to content

Commit

Permalink
hack_ip_in_contact now generates a IP in the range of Test-Net as sta…
Browse files Browse the repository at this point in the history
…ted in RFC 5735 (192.0.2.0/24).
  • Loading branch information
ibc committed Feb 4, 2013
1 parent 42b3749 commit f306d3c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/UA.js
Expand Up @@ -719,7 +719,7 @@ JsSIP.UA.prototype.loadConfig = function(configuration) {

// Via Host
if (settings.hack_ip_in_contact) {
settings.via_host = JsSIP.Utils.getRandomIP();
settings.via_host = JsSIP.Utils.getRandomTestNetIP();
}

// Transports
Expand Down
12 changes: 8 additions & 4 deletions src/Utils.js
Expand Up @@ -137,11 +137,15 @@ JsSIP.Utils= {
return JsSIP.C.causes.SIP_FAILURE_CODE;
},

getRandomIP: function() {
function get_octet() {
return (Math.random() * 255 | 0) + 1;
/**
* Generate a random Test-Net IP (http://tools.ietf.org/html/rfc5735)
* @private
*/
getRandomTestNetIP: function() {
function getOctet(from,to) {
return window.Math.floor(window.Math.random()*(to-from+1)+from);
}
return get_octet()+'.'+get_octet()+'.'+get_octet()+'.'+get_octet();
return '192.0.2.' + getOctet(1, 254);
},

checkUAStatus: function(ua) {
Expand Down

0 comments on commit f306d3c

Please sign in to comment.