diff --git a/README.md b/README.md index f309a54..1a28975 100644 --- a/README.md +++ b/README.md @@ -39,6 +39,14 @@ You can sign up for a free SentryPeer account at https://sentrypeer.com ![SentryPeer Module Menu](https://raw.githubusercontent.com/SentryPeer/SentryPeer-FreePBX-Module/main/assets/img/Screenshot%20from%202023-02-23%2021-38-23.png) ![SentryPeer Module Main Screen](https://raw.githubusercontent.com/SentryPeer/SentryPeer-FreePBX-Module/main/assets/img/Screenshot%20from%202023-02-23%2021-38-44.png) +### To Do + +Add options to the SentryPeer module configuration page to allow the user to select the following actions when a number is found to be malicious: + +1. [ ] Hangup +2. [ ] Play a message (from Recordings) +3. [ ] Send email + ### Trademark [**SENTRYPEER** is a registered trademark](https://trademarks.ipo.gov.uk/ipo-tmcase/page/Results/1/UK00003700947) of Gavin Henry diff --git a/Sentrypeer.class.php b/Sentrypeer.class.php index eb3645c..6c4d6dc 100644 --- a/Sentrypeer.class.php +++ b/Sentrypeer.class.php @@ -88,9 +88,16 @@ public function doDialplanHook(&$ext, $engine, $priority) } if ($dial_macro_exists) { // splice - https://wiki.freepbx.org/pages/viewpage.action?pageId=98701336 - $ext->splice($context, $exten, "gocall", new \ext_noop('Checking ${DIAL_NUMBER} with SentryPeer'), "", 1); - $ext->splice($context, $exten, "gocall", new \ext_agi('sentrypeer.php, ${DIAL_NUMBER}'), "", 2); + $ext->splice($context, $exten, '', new \ext_set('ORIGINAL_NUM_FOR_SENTRYPEER', '${ARG2}'), "", 1); + $ext->splice($context, $exten, "gocall", new \ext_noop('Checking ${ORIGINAL_NUM_FOR_SENTRYPEER} with SentryPeer'), "", 1); + $ext->splice($context, $exten, "gocall", new \ext_agi('sentrypeer.php, ${ORIGINAL_NUM_FOR_SENTRYPEER}'), "", 2); $ext->splice($context, $exten, "gocall", new \ext_noop('SentryPeer Finished'), "", 3); + + // Add our own custom context so others can hook into it via extensions_custom.conf + $ext->addInclude('macro-dialout-trunk', 'sentrypeer-context', 'For the SentryPeer service - https://sentypeer.com'); // Add the context to from-internal + $mcontext = 'sentrypeer-context'; + $ext->add($mcontext, $exten, '', new \ext_noop('Number found on in the SentryPeer database. Hanging up the call.')); + $ext->add($mcontext, $exten, '', new \ext_goto('1', 'h', 'macro-dialout-trunk')); } } diff --git a/agi-bin/sentrypeer.php b/agi-bin/sentrypeer.php index 18ddc1d..1765725 100755 --- a/agi-bin/sentrypeer.php +++ b/agi-bin/sentrypeer.php @@ -30,7 +30,6 @@ if ($res_code == 404) { $agi->verbose("SentryPeer API call res code is 404. Number not seen before. Allowing the call."); - exit(0); } elseif ($res_code == 401) { $agi->verbose("SentryPeer API call res code is 401. Getting a new Bearer token."); @@ -40,19 +39,18 @@ if ($res_code == 404) { $agi->verbose("SentryPeer has not seen this number before. Allowing the call."); - exit(0); } else { - $agi->verbose("SentryPeer has seen this number before. Halting call."); - exit(1); + $agi->verbose("SentryPeer has seen this number before. Hanging up the call."); + $agi->goto_dest('sentrypeer-context', 's', 1); } } else { $agi->verbose("SentryPeer Bearer token is still empty. Aborting."); - exit(1); } } else { $agi->verbose("SentryPeer has seen this number before. Halting call."); - exit(1); + $agi->goto_dest('sentrypeer-context', 's', 1); } +exit(0); function checkPhoneNumber($sentrypeer, $agi, $phone_number_to_check) { @@ -65,7 +63,7 @@ function checkPhoneNumber($sentrypeer, $agi, $phone_number_to_check) $agi->verbose("SentryPeer Bearer token is now set."); } else { $agi->verbose("SentryPeer Bearer token is still empty. Aborting."); - exit(1); + exit(0); } }