Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions lib/Config.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,10 @@ exports.settings = {
no_answer_timeout : 60,

// Registration parameters.
register : true,
register_expires : 600,
registrar_server : null,
register : true,
register_expires : 600,
register_from_tag_trail : '',
registrar_server : null,

// Connection options.
sockets : null,
Expand Down Expand Up @@ -282,6 +283,16 @@ const checks = {
}
},

register_from_tag_trail(register_from_tag_trail)
{
if (typeof register_from_tag_trail === 'function')
{
return register_from_tag_trail;
}

return String(register_from_tag_trail);
},

registrar_server(registrar_server)
{
if (!/^sip:/i.test(registrar_server))
Expand Down
23 changes: 19 additions & 4 deletions lib/Registrator.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ module.exports = class Registrator

// Contents of the sip.instance Contact header parameter.
this._sipInstance = `"<urn:uuid:${this._ua.configuration.instance_id}>"`;

this._contact += `;reg-id=${this._reg_id}`;
this._contact += `;+sip.instance=${this._sipInstance}`;
}
Expand Down Expand Up @@ -109,11 +109,26 @@ module.exports = class Registrator
${this._contact};expires=${this._expires}${this._extraContactParams}`);
extraHeaders.push(`Expires: ${this._expires}`);

let fromTag = Utils.newTag();

if (this._ua.configuration.register_from_tag_trail)
{
if (typeof this._ua.configuration.register_from_tag_trail === 'function')
{
fromTag += this._ua.configuration.register_from_tag_trail();
}
else
{
fromTag += this._ua.configuration.register_from_tag_trail;
}
}

const request = new SIPMessage.OutgoingRequest(
JsSIP_C.REGISTER, this._registrar, this._ua, {
'to_uri' : this._to_uri,
'call_id' : this._call_id,
'cseq' : (this._cseq += 1)
'to_uri' : this._to_uri,
'call_id' : this._call_id,
'cseq' : (this._cseq += 1),
'from_tag' : fromTag
}, extraHeaders);

const request_sender = new RequestSender(this._ua, request, {
Expand Down
1 change: 1 addition & 0 deletions lib/UA.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export interface UAConfiguration {
ha1?: string;
register?: boolean;
register_expires?: number;
register_from_tag_trail?: string | function() : string;
registrar_server?: string;
use_preloaded_route?: boolean;
user_agent?: string;
Expand Down