Skip to content

Commit

Permalink
Merge branch 'dev-joseph-hackIpInContact-string'
Browse files Browse the repository at this point in the history
  • Loading branch information
joseph-onsip committed Jul 28, 2015
2 parents 9b6bbff + 67c2772 commit 9097033
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
10 changes: 9 additions & 1 deletion src/UA.js
Original file line number Diff line number Diff line change
Expand Up @@ -1035,7 +1035,12 @@ UA.prototype.loadConfig = function(configuration) {

// Via Host
if (settings.hackIpInContact) {
settings.viaHost = SIP.Utils.getRandomTestNetIP();
if (typeof settings.hackIpInContact === 'boolean') {
settings.viaHost = SIP.Utils.getRandomTestNetIP();
}
else if (typeof settings.hackIpInContact === 'string') {
settings.viaHost = settings.hackIpInContact;
}
}

this.contact = {
Expand Down Expand Up @@ -1299,6 +1304,9 @@ UA.configuration_check = {
if (typeof hackIpInContact === 'boolean') {
return hackIpInContact;
}
else if (typeof hackIpInContact === 'string' && SIP.Grammar.parse(hackIpInContact, 'host') !== -1) {
return hackIpInContact;
}
},

iceCheckingTimeout: function(iceCheckingTimeout) {
Expand Down
9 changes: 7 additions & 2 deletions test/spec/SpecUA.js
Original file line number Diff line number Diff line change
Expand Up @@ -1388,10 +1388,9 @@ describe('UA', function() {
});

describe('.hackIpInContact', function() {
it('fails for all types except boolean', function() {
it('fails for all types except boolean and string', function() {
expect(SIP.UA.configuration_check.optional.hackIpInContact()).toBeUndefined();
expect(SIP.UA.configuration_check.optional.hackIpInContact(7)).toBeUndefined();
expect(SIP.UA.configuration_check.optional.hackIpInContact('string')).toBeUndefined();
expect(SIP.UA.configuration_check.optional.hackIpInContact({even: 'objects'})).toBeUndefined();
expect(SIP.UA.configuration_check.optional.hackIpInContact(['arrays'])).toBeUndefined();
});
Expand All @@ -1400,6 +1399,12 @@ describe('UA', function() {
expect(SIP.UA.configuration_check.optional.hackIpInContact(true)).toBe(true);
expect(SIP.UA.configuration_check.optional.hackIpInContact(false)).toBe(false);
});

it('passes for string parameters that can be parsed as a host', function() {
expect(SIP.UA.configuration_check.optional.hackIpInContact('1string')).toBeUndefined();
expect(SIP.UA.configuration_check.optional.hackIpInContact('string')).toBe('string');
expect(SIP.UA.configuration_check.optional.hackIpInContact('127.0.0.1')).toBe('127.0.0.1');
});
});

describe('.instanceId', function() {
Expand Down

0 comments on commit 9097033

Please sign in to comment.