Skip to content
Permalink
Browse files

Use a random user in the UA's contact.

- Compare the received Contact headers in response to a REGISTER against such random user
  • Loading branch information
jmillan committed Feb 14, 2013
1 parent 35e1e40 commit a7b69b80ce844403ef8551c7dec78f25a5caedd1
Showing with 8 additions and 6 deletions.
  1. +1 −1 src/Registrator.js
  2. +2 −2 src/Session.js
  3. +5 −3 src/UA.js
@@ -94,7 +94,7 @@ JsSIP.Registrator.prototype = {

while(contacts--) {
contact = response.parseHeader('contact', contacts);
if(contact.uri.toString() === this.ua.contact.uri) {
if(contact.uri.user === this.ua.contact.uri.user) {
expires = contact.getParam('expires');
break;
} else {
@@ -787,11 +787,11 @@ JsSIP.Session.prototype.newSession = function(originator, request, target) {
session.direction = (originator === 'local') ? 'outgoing' : 'incoming';

if (originator === 'remote') {
session.local_identity = request.s('to').uri.toAor();
session.local_identity = session.ua.configuration.from_uri;
session.remote_identity = request.s('from').uri.toAor();
} else if (originator === 'local'){
session.local_identity = session.ua.configuration.from_uri;
session.remote_identity = target;
session.remote_identity = target.toAor();
}

session.ua.emit(event_name, session.ua, {
@@ -356,7 +356,7 @@ JsSIP.UA.prototype.receiveRequest = function(request) {
method = request.method;

// Check that Ruri points to us
if(request.ruri.user !== this.configuration.user) {
if(request.ruri.user !== this.configuration.user && request.ruri.user !== this.contact.uri.user) {
console.log(JsSIP.C.LOG_UA +'Request-URI does not point to us');
request.reply_sl(404);
return;
@@ -595,7 +595,7 @@ JsSIP.UA.prototype.recoverTransport = function(ua) {
*/
JsSIP.UA.prototype.loadConfig = function(configuration) {
// Settings and default values
var parameter, value, checked_value, contact,
var parameter, value, checked_value, contact, contact_uri,
settings = {
/* Host address
* Value to be set in Via sent_by and host part of Contact FQDN
@@ -707,9 +707,11 @@ JsSIP.UA.prototype.loadConfig = function(configuration) {
settings.via_host = JsSIP.Utils.getRandomTestNetIP();
}

contact_uri = new JsSIP.URI(null, JsSIP.Utils.createRandomToken(8), settings.via_host, null, {transport: 'ws'});

contact = {
uri: {
value: 'sip:' + settings.user + '@' + settings.via_host + ';transport=ws',
value: contact_uri,
writable: false,
configurable: false
}

4 comments on commit a7b69b8

@saghul

This comment has been minimized.

Copy link
Contributor

saghul replied Feb 14, 2013

Is this token numeric or alphanumeric? In Blink we had to switch to numbers only due to interoperability problems with weird devices...

@ibc

This comment has been minimized.

Copy link
Member

ibc replied Feb 14, 2013

I don't understand. Typically the Contact username is the same as the account URI user (alice, bob) so alphanumeric. How can that be a problem?

@saghul

This comment has been minimized.

Copy link
Contributor

saghul replied Feb 14, 2013

Stupid manufacturers expecting 100@192.168.1.1, I guess.

@jmillan

This comment has been minimized.

Copy link
Member Author

jmillan replied Feb 14, 2013

Uauu...,

well lets maintain alphanumeric usernames. There is always time for changing the call to JsSIP.Utils.createRandomToken passing 10 as base instead of 32.

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