-
-
Save hgaibor/82433116540f15ab345b2914500abb0d to your computer and use it in GitHub Desktop.
Feature code + Class of Service implementation to allow certain users to spy/whisper/barge on a specified extension. Based on Lgaetz original targeted spy, but allowing user permissions to be set with COS module on FPBX
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; Feature code + Class of Service implementation to allow certain users to spy/whisper/barge on | |
; a specified extension. | |
; | |
; Latest version: | |
; https://gist.github.com/hgaibor/82433116540f15ab345b2914500abb0d | |
; | |
; Forked original version: | |
; https://gist.github.com/lgaetz/78c4e114952e79596c1ed4123559d3d3 | |
; | |
; Usage and install instructions: | |
; 1. On FreePBX/PBXact GUI, Create a Custom Destination that points to the [custom-spy-with-cos] context0. | |
; Fill the interface fields with the values after the --> : | |
; 1.1 Target --> custom-spy-with-cos,s,1 | |
; 1.2 Description --> Put a brief description | |
; 1.3 Notes --> Put your detailed comments here | |
; 1.4 Return --> no | |
; | |
; 2. Create a Misc Application that will point to created custom destination above. | |
; This destination will have the feature code you choose and will allow you to set the permissions over the | |
; Class of Service module. | |
; 2.1 Enable --> Yes | |
; 2.2 Description --> Spy with permissions feature code | |
; 2.3 Feature Code --> *557 | |
; 2.4 Destination --> SELECT Custom Destination created above | |
; | |
; 3. Create Class of Service rules to DENY all users to use this code and allow the ones you need. | |
; Since you used the Misc Application module to assign the feature code, it will appear under the | |
; Class of Service --> [Feature codes] tab | |
; | |
; 4. Put Custom Dialplan at (GUI can be used using Config edit module): | |
; /etc/asterisk/extensions_custom.conf | |
; Dial feature code assigned under Misc Application to start in spy mode. While spying on | |
; active channel use the following dtmf input to toggle modes: | |
; dtmf 4 - spy mode | |
; 5 - whisper mode | |
; 6 - barge mode | |
; | |
; This is default behavior mentioned in https://wiki.asterisk.org/wiki/display/AST/Application_ChanSpy | |
; | |
; License: GNU GPL2 | |
; | |
; Version History | |
; 2021-03-08 First public commit by hgaibor | |
[custom-spy-with-cos] | |
exten => s,1,Noop(Entering user defined context custom-spy-with-cos in extensions_custom.conf) | |
exten => s,n,Read(spyee,please-enter-the&extension&number&followed_pound) | |
exten => s,n,GoTo(targeted-chanspy,${spyee},1) | |
[targeted-chanspy] | |
exten => _.,1,Noop(Entering user defined context targeted-chanspy in extensions_custom.conf) | |
exten => _.,n,Set(TIMEOUT(absolute)=3600) ; prevent hung channel by setting 1 hour timeout recommended if using infinite loop | |
exten => _.,n,Answer | |
exten => _.,n(once-upon-a-time),Wait(1) | |
exten => _.,n,set(spy_target=) ; initialize target var | |
; get list of dialable devices for extension | |
exten => _.,n,Set(DEVS=${DB(AMPUSER/${EXTEN}/device)}) ; & delimited list of devices | |
exten => _.,n,Set(DEVS=${STRREPLACE(DEVS,&,\,)}) ; comma delimited list of devices | |
; step thru each device and look for an active channel | |
exten => _.,n,While($["${SET(DEV=${POP(DEVS)})}" != ""]) | |
exten => _.,n,noop(dev: ${DEV}) | |
; using a regex of SIP/${EXTEN}- will match both SIP and PJSIP channels, and the trailing - character should | |
; help to ensure there is only a single match. If multiple channels are returned the chanspy application will fail | |
exten => _.,n,set(spy_target=${CHANNELS(SIP/${DEV}-)}) | |
exten => _.,n,ExecIf($["${spy_target}"!=""]?ExitWhile) ; if an active channel is found exit the loop | |
exten => _.,n,EndWhile() | |
exten => _.,n,ExecIF($["${spy_target}"!=""]?ChanSpy(${spy_target},dnqE)) ; q option suppresses channel announce on barge | |
exten => _.,n,Hangup() ;comment this line with a semicolon to do infinite loop | |
exten => _.,n,GoTo(once-upon-a-time) | |
exten => _.,n,Hangup() | |
exten => h,1,Hangup() | |
exten => s,1,Hangup() | |
exten => T,1,Hangup() ; timeout destination |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Great stuff, thanks Hugo!