Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to send REGISTER request without expires #794

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion lib/Config.js
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ const checks = {
{
const value = Number(register_expires);

if (value > 0)
if (value >= 0)
{
return value;
}
Expand Down
9 changes: 5 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 @@ -104,10 +104,11 @@ module.exports = class Registrator
}

const extraHeaders = this._extraHeaders.slice();
let contactValue = `${this._contact}${this._extraContactParams}`;

extraHeaders.push(`Contact: \
${this._contact};expires=${this._expires}${this._extraContactParams}`);
extraHeaders.push(`Expires: ${this._expires}`);
if (this._expires) contactValue = `${this._contact};expires=${this._expires}${this._extraContactParams}`;
extraHeaders.push(`Contact: ${contactValue}`);
if (this._expires) extraHeaders.push(`Expires: ${this._expires}`);
Comment on lines +109 to +111
Copy link
Member

Choose a reason for hiding this comment

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

For readability:

Suggested change
if (this._expires) contactValue = `${this._contact};expires=${this._expires}${this._extraContactParams}`;
extraHeaders.push(`Contact: ${contactValue}`);
if (this._expires) extraHeaders.push(`Expires: ${this._expires}`);
let contactValue;
if (this._expires)
{
contactValue = `${this._contact};expires=${this._expires}${this._extraContactParams}`;
extraHeaders.push(`Expires: ${this._expires}`);
}
else
{
contactValue = `${this._contact}${this._extraContactParams}`;
}
extraHeaders.push(`Contact: ${contactValue}`);


const request = new SIPMessage.OutgoingRequest(
JsSIP_C.REGISTER, this._registrar, this._ua, {
Expand Down