Merge branch 'martinl-dev' into devel

This commit is contained in:
Martin Lindberg 2016-10-26 13:51:04 +02:00
commit 101bbabca0
2 changed files with 72 additions and 3 deletions

View file

@ -0,0 +1,25 @@
AUS;19x
BEL;09xx
BRA;05xx
CHL;
CHN;
CZE;9xx
DNK;90xx
ETS;
FIN;0(7[0,5]|[1-3,6]0)
FRA;0[8,9]xx
DEU;0(9xx|137)
HUN;06-[8,9]x
IND;
ITA;8
JPN;0990
NLD;09xx
NZL;0900
USA;1-900
ESP;([8,9]0x|118)
SWE;09xx
CHE;09xx
NOR;82x
TWN;020[3,4,9]
GBR;0[8,9]xx
ARE;[2,6]00

View file

@ -79,6 +79,8 @@ TMPL_BRCM_LINE=$TEMPLATEDIR/brcm_line.TEMPLATE
TMPL_MEETME=$TEMPLATEDIR/meetme.conf.TEMPLATE
SPECRATEDIR=$ASTERISKDIR/special_rate_nr.cfg
run_hook()
{
h="$1_hook"
@ -145,6 +147,7 @@ assemble_and_copy_config()
cp $TMPL_MODULES $WORKDIR/modules.conf
cp $TMPL_EXTENSIONS_MACRO $WORKDIR/extensions_macro.conf
cp $TMPL_MUSICONHOLD $WORKDIR/musiconhold.conf
cp $SPECRATEDIR $WORKDIR/special_rate_nr.cfg
test -e $TMPL_MEETME && cp $TMPL_MEETME $WORKDIR/meetme.conf
@ -1147,7 +1150,7 @@ configure_call_filters()
break
fi
done < "/etc/idc_cc.cfg"
echo "Found IDCs: $idc"
echo "Found CCs: $cc"
@ -1165,6 +1168,43 @@ configure_call_filters()
echo "exten => s,n,MacroExit()" >> $WORKDIR/macros.tmp
echo "exten => s,n(not-foreign),Set(FOREIGN=0)" >> $WORKDIR/macros.tmp
echo "" >> $WORKDIR/macros.tmp
# Get special rate numbers from /etc/asterisk/special_rate_nr.cfg
while read line
do
i=0
for v in $(echo $line | tr ";" "\n")
do
if [ "$i" -eq "0" -a "$v" != "$country" ] ; then
continue 2
fi
if [ "$i" -eq "1" ] ; then
srn=$v
fi
i=$((i+1))
done
if [ -n "$srn" ] ; then
# Special rate numbers found
break
fi
done < "/etc/asterisk/special_rate_nr.cfg"
echo "Found special rate numbers: $srn"
echo "[macro-check-special-rate]" >> $WORKDIR/macros.tmp
echo "exten => s,1,NoOp(${srn})" >> $WORKDIR/macros.tmp
# Create regex patterns
# All x characters are replaced with [0-9] to match a single digit
srn="($(echo $srn | tr -s "" | tr "," "|" | sed 's/x/[0-9]/g'))"
echo "exten => s,n,GotoIf($[\"\${ARG1}\":\"(^$srn[0-9]+)\">0]?special-rate:normal-rate)" >> $WORKDIR/macros.tmp
echo "exten => s,n(special-rate),Set(SPECRATE=1)" >> $WORKDIR/macros.tmp
echo "exten => s,n,MacroExit()" >> $WORKDIR/macros.tmp
echo "exten => s,n(normal-rate),Set(SPECRATE=0)" >> $WORKDIR/macros.tmp
echo "" >> $WORKDIR/macros.tmp
}
#
@ -1194,7 +1234,7 @@ configure_call_filter_helper()
config_get block_special_rate $1 block_special_rate
[ "$#" -ge 2 ] || return 0
direction=$2
if ! [ "x$direction" != "xincoming" -o "x$direction" != "xoutgoing" ] ; then
return
@ -1220,6 +1260,11 @@ configure_call_filter_helper()
echo "exten => s,n,GotoIf($[\${FOREIGN}==1]?block)" >> $WORKDIR/macros.tmp
fi
if [ "x$direction" == "xoutgoing" -a "x$block_special_rate" == "x1" ] ; then
echo "exten => s,n,Macro(check-special-rate,\${DIAL_EXTEN})" >> $WORKDIR/macros.tmp
echo "exten => s,n,GotoIf($[\${SPECRATE}==1]?block)" >> $WORKDIR/macros.tmp
fi
local section cfgtype owner
for section in ${CONFIG_SECTIONS}; do
config_get cfgtype "$section" TYPE
@ -1229,7 +1274,6 @@ configure_call_filter_helper()
local rule_extension rule_enabled
config_get rule_extension $section extension
config_get rule_enabled $section enabled
[ -z "$rule_enabled" -o "$rule_enabled" = "0" ] && continue
# Regular expression for matching calling or called number