Hi,
I’m developing an application based on the AMI of Asterisk that is able to block an IP when the credentials have been entered incorrectly to access the AMI X times in Y seconds. For this, I do the following:
- I create an ACL in the configuration file (acl.conf) to add the rule that blocks the IP.
- I get a list with all the users of the manager.conf file.
- To each User I assign the ACL that I have created in the first step.
To do the latter I use the action of the AMI “UpdateConfig” like this:
Action: UpdateConfig
Reload:yes
srcfilename:manager.conf
dstfilename:manager.conf
Action-000000: insert
Cat-000000:admin
Line-000000:000000
Var-000000:acl
Value-000000:>ACLDenyPotentiallyDangerousIP
(Which should insert in the first line corresponding to the user “admin” the following line: acl = ACLDenyPotentiallyDangerousIP)
This is done well, the problem is when I do it several times (as many as I have users in the manager.conf).
When the “insert” action is done correctly I should receive a “Success” response, but instead I receive events like these:
Event: ExtensionStatus
Privilege: call,all
SequenceNumber: 6
File: manager.c
Line: 6957
Func: manager_state_cb
Exten: 1000
Context: demo
Hint: SIP/1000
Status: 4
StatusText: Unavailable
Event: ExtensionStatus
Privilege: call,all
SequenceNumber: 7
File: manager.c
Line: 6957
Func: manager_state_cb
Exten: 1001
Context: demo
Hint: SIP/1001
Status: 4
StatusText: Unavailable
…
Event: VarSet
Privilege: dialplan,all
SequenceNumber: 13
File: manager.c
Line: 1817
Func: manager_default_msg_cb
Channel: none
Uniqueid: none
Variable: IAXINFO-AEL
Value: guest
Event: VarSet
Privilege: dialplan,all
SequenceNumber: 14
File: manager.c
Line: 1817
Func: manager_default_msg_cb
Channel: none
Uniqueid: none
Variable: OUTBOUND-TRUNK
Value: “Zap/g2”
…
Event: Reload
Privilege: system,all
SequenceNumber: 19
File: manager.c
Line: 1851
Func: manager_generic_msg_cb
Module: All
Status: 0
In the file sip.conf I only have these extensions defined:
[1001] (public-phone,my-codecs)
type=friend
secret=o3dbMtrRV6U
host=dynamic
context=from-internal
deny=0.0.0.0/0.0.0.0
permit=192.168.0.0/255.255.0.0
[1002]
type=friend
secret=123456
host=dynamic
context=from-internal
permit=0.0.0.0/0.0.0.0
[1003]
type=friend
secret=123456
host=dynamic
context=from-internal
permit=192.168.0.0/255.255.0.0
Any ideas?
Thanks.