mirror of
https://github.com/jambonz/sbc-outbound.git
synced 2025-12-19 04:27:45 +00:00
return 482 loop detected if call to a sip uri would loop back to us (#173)
* return 482 loop detected if call to a sip uri would loop back to us * this pr fixes #172 * typo * wip * wip
This commit is contained in:
@@ -260,9 +260,22 @@ module.exports = (srf, logger, redisClient) => {
|
||||
else if ('sip' === desiredRouting) {
|
||||
// call that needs to be forwarded to a sip endpoint
|
||||
logger.info(`forwarding call to sip endpoint ${req.uri}`);
|
||||
|
||||
// check if the domain is one of ours
|
||||
if (process.env.JAMBONES_LOCAL_SIP_DOMAINS) {
|
||||
const allowedDomains = process.env.JAMBONES_LOCAL_SIP_DOMAINS.split(',');
|
||||
const domain = uri.host;
|
||||
const isLoop = allowedDomains.some((allowed) =>
|
||||
domain === allowed.trim() || domain.endsWith(`.${allowed.trim()}`)
|
||||
);
|
||||
if (isLoop) {
|
||||
logger.info({ host: domain }, `returning 482 Loop Detected for attempt to send to: ${req.uri}`);
|
||||
res.send(482, 'Loop Detected');
|
||||
return req.srf.endSession(req);
|
||||
}
|
||||
}
|
||||
req.locals.target = 'forward';
|
||||
}
|
||||
else if ('phone' === desiredRouting) {
|
||||
} else if ('phone' === desiredRouting) {
|
||||
debug('sending call to LCR');
|
||||
req.locals.target = 'lcr';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user