-
-
Notifications
You must be signed in to change notification settings - Fork 103
/
18.sh
executable file
·36 lines (25 loc) · 1.08 KB
/
18.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/usr/bin/env bash
. include/common
unitname="DoS and SIP Security - Doesn't Block Known Carrier IP(s)"
# settings
source_ip="127.0.0.11"
username="smoketest"
host="localhost"
# Add Carrier IP to address table
mysql kamailio -e "insert into address values (null,8,'$source_ip',32,0,'name:Smoke Test Carrier,gwgroup:0');"
# Reload the address table
kamcmd permissions.addressReload >/dev/null
# Send a bunch of of requests to the server
sipsak -F -d -k $source_ip -e 500 -s sip:$username@$host >/dev/null
sleep 1
# Check the ipban htable to see if the ipaddress is being blocked after sending a
# bunch of SIP requests
# Using '!' to negate the return code. I want return code of 1 to negate to a 0 if the source_ip is not found in the ipban table
! kamcmd htable.dump ipban | grep -q "$source_ip"
ret=$?
# Clean up, remove the entry
kamcmd htable.delete ipban $source_ip
# TODO: Add a test to validate that the Server user agent is no longer sento
# Remove IP from Carrier table
mysql kamailio -e "DELETE FROM address WHERE tag LIKE '%name:Smoke Test Carrier%';"
process_result "$unitname" $ret