Skip to content
Permalink
Browse files

Added 'registrar_server' UA configuration parameter. See the doc at h…

  • Loading branch information
ibc committed Mar 1, 2013
1 parent e1dd5d8 commit c79037e70aac2d69127a2b62b18f0a5d11365e8e
Showing with 45 additions and 11 deletions.
  1. +1 −1 src/Registrator.js
  2. +34 −5 src/UA.js
  3. +3 −1 test/helpers.js
  4. +7 −4 test/test-UA-no-WebRTC.js
@@ -18,14 +18,14 @@ Registrator = function(ua, transport) {
this.ua = ua;
this.transport = transport;

this.registrar = ua.configuration.registrar_server;
this.expires = ua.configuration.register_expires;
this.min_expires = ua.configuration.register_min_expires;

// Call-ID and CSeq values RFC3261 10.2
this.call_id = JsSIP.Utils.createRandomToken(22);
this.cseq = 80;

this.registrar = 'sip:'+ ua.configuration.hostport_params;
// this.to_uri
this.to_uri = ua.configuration.uri;

@@ -640,7 +640,7 @@ UA.prototype.recoverTransport = function(ua) {
*/
UA.prototype.loadConfig = function(configuration) {
// Settings and default values
var parameter, value, checked_value, hostport_params,
var parameter, value, checked_value, hostport_params, registrar_server,
settings = {
/* Host address
* Value to be set in Via sent_by and host part of Contact FQDN
@@ -654,6 +654,7 @@ UA.prototype.loadConfig = function(configuration) {
register_expires: 600,
register_min_expires: 120,
register: true,
registrar_server: null,

// Transport related parameters
ws_server_max_reconnection: 3,
@@ -746,6 +747,13 @@ UA.prototype.loadConfig = function(configuration) {
settings.authorization_user = settings.uri.user;
}

/* If no 'registrar_server' is set use the 'uri' value without user portion. */
if (!settings.registrar_server) {
registrar_server = settings.uri.clone();
registrar_server.user = null;
settings.registrar_server = registrar_server;
}

// User no_answer_timeout
settings.no_answer_timeout = settings.no_answer_timeout * 1000;

@@ -785,10 +793,13 @@ UA.prototype.loadConfig = function(configuration) {
// Fill the value of the configuration_skeleton
console.log(LOG_PREFIX + 'configuration parameters after validation:');
for(parameter in settings) {
if (parameter !== 'uri') {
console.log('· ' + parameter + ': ' + window.JSON.stringify(settings[parameter]));
} else {
console.log('· ' + parameter + ': ' + settings[parameter]);
switch(parameter) {
case 'uri':
case 'registrar_server':
console.log('· ' + parameter + ': ' + settings[parameter]);
break;
default:
console.log('· ' + parameter + ': ' + window.JSON.stringify(settings[parameter]));
}
UA.configuration_skeleton[parameter].value = settings[parameter];
}
@@ -834,6 +845,7 @@ UA.configuration_skeleton = (function() {
"no_answer_timeout", // 30 seconds.
"password",
"register_expires", // 600 seconds.
"registrar_server",
"stun_servers",
"trace_sip",
"turn_servers",
@@ -1029,6 +1041,23 @@ UA.configuration_check = {
}
},

registrar_server: function(registrar_server) {
var parsed;

if (!/^sip:/i.test(registrar_server)) {
registrar_server = JsSIP.C.SIP + ':' + registrar_server;
}
parsed = JsSIP.URI.parse(registrar_server);

if(!parsed) {
return;
} else if(parsed.user) {
return;
} else {
return parsed;
}
},

stun_servers: function(stun_servers) {
var idx, stun_server;

@@ -21,6 +21,7 @@ TestJsSIP.Helpers = {
hack_via_tcp: false,
hack_ip_in_contact: false,
uri: 'sip:fakeUA@jssip.net',
registrar_server: 'sip:registrar.jssip.net:6060;transport=tcp',
ws_servers: [{'ws_uri':'ws://localhost:12345','sip_uri':'<sip:localhost:12345;transport=ws;lr>','weight':0,'status':0,'scheme':'WS'}],
display_name: 'Fake UA ð→€ł !!!',
authorization_user: 'fakeUA'
@@ -31,7 +32,8 @@ TestJsSIP.Helpers = {
ws_servers: 'ws://localhost:12345',
display_name: 'Fake UA ð→€ł !!!',
register: false,
use_preloaded_route: true
use_preloaded_route: true,
registrar_server: 'registrar.jssip.NET:6060;TRansport=TCP'
},

createFakeUA: function() {
@@ -21,10 +21,13 @@ test('UA no WS connection', function() {
strictEqual(ua.contact.toString({anonymous: true, outbound: true}), '<sip:anonymous@anonymous.invalid;transport=ws;ob>');

for (parameter in TestJsSIP.Helpers.DEFAULT_JSSIP_CONFIGURATION_AFTER_START) {
if (parameter !== 'uri') {
deepEqual(ua.configuration[parameter], TestJsSIP.Helpers.DEFAULT_JSSIP_CONFIGURATION_AFTER_START[parameter], 'testing parameter ' + parameter);
} else {
deepEqual(ua.configuration[parameter].toString(), TestJsSIP.Helpers.DEFAULT_JSSIP_CONFIGURATION_AFTER_START[parameter], 'testing parameter ' + parameter);
switch(parameter) {
case 'uri':
case 'registrar_server':
deepEqual(ua.configuration[parameter].toString(), TestJsSIP.Helpers.DEFAULT_JSSIP_CONFIGURATION_AFTER_START[parameter], 'testing parameter ' + parameter);
break;
default:
deepEqual(ua.configuration[parameter], TestJsSIP.Helpers.DEFAULT_JSSIP_CONFIGURATION_AFTER_START[parameter], 'testing parameter ' + parameter);
}
}

1 comment on commit c79037e

@jmillan

This comment has been minimized.

Copy link
Member

jmillan commented on c79037e Mar 1, 2013

🍰 for you

Please sign in to comment.
You can’t perform that action at this time.