This commit is contained in:
Hoan Luu Huu
2023-05-24 19:29:12 +07:00
committed by GitHub
parent f3ec847474
commit d09dca47b9
2 changed files with 16 additions and 11 deletions

View File

@@ -74,12 +74,12 @@ router.get('/:call_id', async(req, res) => {
}
});
router.get('/:call_id/pcap', async(req, res) => {
router.get('/:call_id/:method/pcap', async(req, res) => {
const {logger} = req.app.locals;
try {
const token = await getHomerApiKey(logger);
if (!token) return res.sendStatus(400, {msg: 'getHomerApiKey: Failed to get Homer API token; check server config'});
const stream = await getHomerPcap(logger, token, [req.params.call_id]);
const stream = await getHomerPcap(logger, token, [req.params.call_id], req.params.method);
if (!stream) {
logger.info(`getHomerApiKey: unable to get sip traces from Homer for ${req.params.call_id}`);
return res.sendStatus(404);

View File

@@ -64,7 +64,7 @@ const getHomerSipTrace = async(logger, apiKey, callId) => {
}
};
const getHomerPcap = async(logger, apiKey, callIds) => {
const getHomerPcap = async(logger, apiKey, callIds, method) => {
if (!process.env.HOMER_BASE_URL || !process.env.HOMER_USERNAME || !process.env.HOMER_PASSWORD) {
logger.debug('getHomerPcap: Homer integration not installed');
}
@@ -73,18 +73,23 @@ const getHomerPcap = async(logger, apiKey, callIds) => {
const stream = await postPcap('/api/v3/export/call/messages/pcap', {
param: {
transaction: {
call: true,
registration: true,
call: method === 'invite',
registration: method === 'register',
rest: false
},
orlogic: true,
search: {
'1_call': {
callid: callIds
},
'1_registration': {
callid: callIds
}
...(method === 'invite' && {
'1_call': {
callid: callIds
}
})
,
...(method === 'register' && {
'1_registration': {
callid: callIds
}
})
},
},
timestamp: {