Skip to content

Commit

Permalink
Use a random user in the UA's contact.
Browse files Browse the repository at this point in the history
- 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 a7b69b8
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/Registrator.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions src/Session.js
Original file line number Diff line number Diff line change
Expand Up @@ -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, {
Expand Down
8 changes: 5 additions & 3 deletions src/UA.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
}
Expand Down

4 comments on commit a7b69b8

@saghul
Copy link
Contributor

@saghul saghul commented on a7b69b8 Feb 14, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@ibc
Copy link
Member

@ibc ibc commented on a7b69b8 Feb 14, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Contributor

@saghul saghul commented on a7b69b8 Feb 14, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stupid manufacturers expecting 100@192.168.1.1, I guess.

@jmillan
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.