Browse code

kamailio.cfg: catch OPTIONS keepalive requests in route[REQINIT]

Daniel-Constantin Mierla authored on 21/02/2014 19:09:33
Showing 1 changed files
... ...
@@ -543,16 +543,13 @@ route[REQINIT] {
543 543
 	# flood dection from same IP and traffic ban for a while
544 544
 	# be sure you exclude checking trusted peers, such as pstn gateways
545 545
 	# - local host excluded (e.g., loop to self)
546
-	if(src_ip!=myself)
547
-	{
548
-		if($sht(ipban=>$si)!=$null)
549
-		{
546
+	if(src_ip!=myself) {
547
+		if($sht(ipban=>$si)!=$null) {
550 548
 			# ip is already blocked
551 549
 			xdbg("request from blocked IP - $rm from $fu (IP:$si:$sp)\n");
552 550
 			exit;
553 551
 		}
554
-		if (!pike_check_req())
555
-		{
552
+		if (!pike_check_req()) {
556 553
 			xlog("L_ALERT","ALERT: pike blocking $rm from $fu (IP:$si:$sp)\n");
557 554
 			$sht(ipban=>$si) = 1;
558 555
 			exit;
... ...
@@ -565,8 +562,12 @@ route[REQINIT] {
565 562
 		exit;
566 563
 	}
567 564
 
568
-	if(!sanity_check("1511", "7"))
569
-	{
565
+	if(is_method("OPTIONS") && uri==myself && $rU==$null) {
566
+		sl_send_reply("200","Keepalive");
567
+		exit;
568
+	}
569
+
570
+	if(!sanity_check("1511", "7")) {
570 571
 		xlog("Malformed SIP message from $si:$sp\n");
571 572
 		exit;
572 573
 	}