Compare commits

..

5 Commits

Author SHA1 Message Date
Sam Machin
8eaefd77b2 Merge branch 'main' into feat/declineverbheader 2026-03-27 17:12:07 +00:00
Dave Horton
df30496dac fix uncaught exception referencing this.ep in freeswitch hangup scenario (#1532) 2026-03-27 08:31:32 -04:00
Sam Machin
e7aa0968b4 Update sip_decline.js 2026-02-20 17:01:55 +00:00
Sam Machin
1c724c00ee lint 2026-02-20 17:00:38 +00:00
Sam Machin
18c38ce970 add x-ver to sip-decline 2026-02-20 16:58:19 +00:00
4 changed files with 7 additions and 30 deletions

View File

@@ -28,7 +28,6 @@ module.exports = function(srf, logger) {
registrar,
lookupClientByAccountAndUsername
} = srf.locals.dbHelpers;
const {addKey} = srf.locals.dbHelpers;
const {
writeAlerts,
AlertType
@@ -143,14 +142,6 @@ module.exports = function(srf, logger) {
rootSpan
};
/* write a short-lived Redis key mapping the original Call-ID (X-CID) to the traceId,
so sbc-inbound can look it up for CDRs even when a CANCEL is sent to sbc-inbound */
const externalCallId = req.get('X-CID');
if (externalCallId) {
addKey(`callid:${externalCallId}`, traceId, 300)
.catch((err) => logger.error(err, 'createRootSpan: error writing traceId to Redis'));
}
/**
* end the span on final failure or cancel from caller;
* otherwise it will be closed when sip dialog is destroyed

View File

@@ -1488,12 +1488,7 @@ class CallSession extends Emitter {
else if (opts.call_status === CallStatus.NoAnswer) {
if (this.direction === CallDirection.Inbound) {
if (this.res && !this.res.finalResponseSent) {
const traceId = this.req?.locals?.traceId;
this.res.send(503, {
headers: {
...(traceId && {'X-Trace-ID': traceId})
}
});
this.res.send(503);
this._callReleased();
}
}
@@ -2481,7 +2476,7 @@ Duration=${duration} `
this.logger.info(`allocated endpoint ${ep.uuid}`);
this.ep.on('destroy', () => {
this.logger.debug(`endpoint was destroyed!! ${this.ep.uuid}`);
this.logger.debug(`endpoint was destroyed!! ${this.ep?.uuid}`);
});
if (this.direction === CallDirection.Inbound || this.application?.transferredCall) {
@@ -2526,12 +2521,10 @@ Duration=${duration} `
// Send SIP error response immediately for inbound calls
if (this.res && !this.res.finalResponseSent) {
this.logger.info(`Sending ${err.status} response to SBC due to SipError`);
const traceId = this.req?.locals?.traceId;
this.res.send(err.status, {
headers: {
'X-Reason': `endpoint allocation failure: ${err.reason || 'Endpoint Allocation Failed'}`,
...(sipReasonHeader && {'Reason': sipReasonHeader}),
...(traceId && {'X-Trace-ID': traceId})
...(sipReasonHeader && {'Reason': sipReasonHeader})
}
});
this._notifyCallStatusChange({

View File

@@ -51,14 +51,12 @@ class InboundCallSession extends CallSession {
_onTasksDone() {
if (!this.res.finalResponseSent) {
const traceId = this.req.locals.traceId;
if (this._mediaServerFailure) {
this.rootSpan.setAttributes({'call.termination': 'media server failure'});
this.logger.info('InboundCallSession:_onTasksDone generating 480 due to media server failure');
this.res.send(480, {
headers: {
'X-Reason': 'crankback: media server failure',
...(traceId && {'X-Trace-ID': traceId})
'X-Reason': 'crankback: media server failure'
}
});
}
@@ -71,19 +69,14 @@ class InboundCallSession extends CallSession {
this.res.send(status, {
headers: {
'X-Reason': `endpoint allocation failure: ${reason}`,
...(sipReasonHeader && {'Reason': sipReasonHeader}),
...(traceId && {'X-Trace-ID': traceId})
...(sipReasonHeader && {'Reason': sipReasonHeader})
}
});
}
else {
this.rootSpan.setAttributes({'call.termination': 'tasks completed without answering call'});
this.logger.info('InboundCallSession:_onTasksDone auto-generating non-success response to invite');
this.res.send(603, {
headers: {
...(traceId && {'X-Trace-ID': traceId})
}
});
this.res.send(603);
}
}
this.req.removeAllListeners('cancel');

View File

@@ -17,7 +17,7 @@ class TaskSipDecline extends Task {
async exec(cs, {res}) {
super.exec(cs);
res.send(this.data.status, this.data.reason, {
headers: this.headers
headers: {'X-Reason': 'SIP Decline Verb', ...this.headers}
}, (err) => {
if (!err) {
// Call was successfully declined