From dd4a91fb24c3e80a8ef950c12c9926bc64db23ee Mon Sep 17 00:00:00 2001 From: Quan HL Date: Thu, 21 Nov 2024 11:00:37 +0700 Subject: [PATCH 1/2] forward all refer to feature server --- lib/call-session.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/lib/call-session.js b/lib/call-session.js index 7613772..130199c 100644 --- a/lib/call-session.js +++ b/lib/call-session.js @@ -783,11 +783,7 @@ class CallSession extends Emitter { try { const response = await dlg.other.request({ method: 'REFER', - headers: { - 'Refer-To': req.get('Refer-To'), - 'Referred-By': req.get('Referred-By'), - 'User-Agent': req.get('User-Agent') - } + headers: req.headers }); res.send(response.status, response.reason); } catch (err) { From da4410e13543ccdf82aba58a5d30e6c81f8fe449 Mon Sep 17 00:00:00 2001 From: Quan HL Date: Mon, 25 Nov 2024 08:38:37 +0700 Subject: [PATCH 2/2] forwawrd extra custom header --- lib/call-session.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/call-session.js b/lib/call-session.js index 130199c..590d291 100644 --- a/lib/call-session.js +++ b/lib/call-session.js @@ -781,9 +781,20 @@ class CallSession extends Emitter { async _onRefer(dlg, req, res) { /* REFER coming in from a sip device, forward to feature server */ try { + const customHeaders = Object.keys(req.headers) + .filter((h) => h.toLowerCase().startsWith('x-')) + .reduce((acc, h) => { + acc[h] = req.get(h); + return acc; + }, {}); const response = await dlg.other.request({ method: 'REFER', - headers: req.headers + headers: { + 'Refer-To': req.get('Refer-To'), + 'Referred-By': req.get('Referred-By'), + 'User-Agent': req.get('User-Agent'), + ...customHeaders + } }); res.send(response.status, response.reason); } catch (err) {