From 8dc0377748bdfb45d9cdf180ead3f4f5c63e670c Mon Sep 17 00:00:00 2001 From: marcelloc Date: Fri, 28 Oct 2011 17:24:44 -0200 Subject: pfBlocker - version 0.1.2 with widget and more fixes --- config/pf-blocker/pfBlocker.widget.php | 81 ++++++++++++++++++++++++++++++++++ config/pf-blocker/pfblocker.inc | 22 ++++----- config/pf-blocker/pfblocker.xml | 7 ++- 3 files changed, 99 insertions(+), 11 deletions(-) create mode 100644 config/pf-blocker/pfBlocker.widget.php (limited to 'config/pf-blocker') diff --git a/config/pf-blocker/pfBlocker.widget.php b/config/pf-blocker/pfBlocker.widget.php new file mode 100644 index 00000000..ec1d08a2 --- /dev/null +++ b/config/pf-blocker/pfBlocker.widget.php @@ -0,0 +1,81 @@ +"; + +$in=""; +$out=""; +$white=""; +$rules=$config['filter']['rule']; +#echo "
";
+foreach($rules as $rule){
+	if ($rule['destination']['address'] == 'pfBlockerOutbound' && $out == ""){
+		#print_r($rule);
+		$out="";
+	}
+		
+	if ($rule['source']['address']== 'pfBlockerInbound' && $in == "")
+		$in="";
+		
+	if ($rule['source']['address']== 'pfBlockerWL' && $white == "")
+		$white="";
+		
+	if ($rule['destination']['address']== 'pfBlockerWL' && $white == "")
+		$white="";
+}
+
+$in=($in != ""?$in:"");
+$out=($out != ""?$out:"");
+$white=($white != ""?$white:"");
+
+echo "    pfBlockerInbound".$in."";
+echo "    pfBlockerOutbound".$out."";
+echo "    pfBlockerWL".$white."";
+
+echo"  ";
+echo"  ";
+if (file_exists("/usr/local/pkg/pfb_in.txt")) {
+         $resultsIP = preg_match_all("/\//",file_get_contents("/usr/local/pkg/pfb_in.txt"),$matches);
+         echo "    ". count($matches[0])." Networks";
+}
+if (file_exists("/usr/local/pkg/pfb_out.txt")) {
+         $resultsIP = preg_match_all("/\//",file_get_contents("/usr/local/pkg/pfb_out.txt"),$matches);
+         echo "    " . count($matches[0])." Networks";
+}
+if (file_exists("/usr/local/pkg/pfb_w.txt")) {
+         $resultsIP = preg_match_all("/\//",file_get_contents("/usr/local/pkg/pfb_w.txt"),$matches);
+         echo "    " . count($matches[0])." Networks";}
+
+echo"  ";
+echo"";
+?>
\ No newline at end of file
diff --git a/config/pf-blocker/pfblocker.inc b/config/pf-blocker/pfblocker.inc
index f37676ef..578ed75d 100755
--- a/config/pf-blocker/pfblocker.inc
+++ b/config/pf-blocker/pfblocker.inc
@@ -173,9 +173,8 @@ function sync_package_pfblocker() {
 	file_put_contents('/usr/local/pkg/pfb_w.txt',$whitelist, LOCK_EX);
 
 	
-	#edit or assign alias "pfblocker" and "pfblockerWL" 
+	#edit or assign alias "pfblockerInbound", "pfblockerOutbound" and "pfblockerWL" 
 	$aliases=$config['aliases']['alias'];
-	#print "
";
 	$new_aliases=array();
 	$pfBlockerInbound='/var/db/aliastables/pfBlockerInbound.txt';
 	if ($ips_in != "" && $config['installedpackages']['pfblocker']['config'][0]['enable_cb'] == "on"){
@@ -242,11 +241,12 @@ function sync_package_pfblocker() {
 			$new_aliases[]=	$cbalias;
 	}
 	$config['aliases']['alias']=$new_aliases;
-	# check contryblock filter options
-	$rules=$config['filter']['rule'];
+	
+	# check pfBlocker filter options
 	$ifaces = $pfblocker_config['inbound_interface'];
-    foreach (explode(",", $ifaces) as $i => $iface) {
-    	if ($whitelist != ""){
+	if ($ifaces != "")
+      foreach (explode(",", $ifaces) as $i => $iface) {
+    	if ($whitelist != "" && $iface != ""){
 			${$iface}[0]=array("id" => "",
 					"type"=>"pass",
 					"tag"=>	"",
@@ -266,7 +266,7 @@ function sync_package_pfblocker() {
 			if ($pfblocker_config['enable_log'])
 				${$iface}[0]["log"]="";
     	}
-		if ($ips_in != ""){
+		if ($ips_in != "" && $iface != ""){
 			$action=($pfblocker_config['inbound_deny_action']!= ""?$pfblocker_config['inbound_deny_action']:"block");
 			${$iface}[1]=array(	"id" => "",
 							"type"=>$action,
@@ -289,8 +289,9 @@ function sync_package_pfblocker() {
 		}
 	}
 	$ifaces = $pfblocker_config['outbound_interface'];
-    foreach (explode(",", $ifaces) as $i => $iface) {
-    	if ($whitelist != ""){
+	if ($ifaces != "")
+      foreach (explode(",", $ifaces) as $i => $iface) {
+    	if ($whitelist != "" && $iface != ""){
 			${$iface}[2]=array(	"id" => "",
 							"type"=>"pass",
 							"tag"=>	"",
@@ -309,7 +310,7 @@ function sync_package_pfblocker() {
 		if ($pfblocker_config['enable_log'])
 				${$iface}[2]["log"]="";			
     	}
-		if ($ips_out != ""){
+		if ($ips_out != "" && $iface != ""){
 			$action=($pfblocker_config['outbound_deny_action']!= ""?$pfblocker_config['outbound_deny_action']:"block");
 			${$iface}[3]= array("id" => "",
 							"type"=>$action,
@@ -333,6 +334,7 @@ function sync_package_pfblocker() {
 
 	}
 	$last_iface="";
+	$rules=$config['filter']['rule'];
 	foreach ($rules as $rule){
 		if ($rule['interface'] <> $last_iface){
 			$last_iface = $rule['interface'];
diff --git a/config/pf-blocker/pfblocker.xml b/config/pf-blocker/pfblocker.xml
index 99202f5b..c8a1facf 100755
--- a/config/pf-blocker/pfblocker.xml
+++ b/config/pf-blocker/pfblocker.xml
@@ -62,6 +62,11 @@
 		/usr/local/www/
 		0755
 	
+	
+		http://www.pfsense.org/packages/config/pf-blocker/pfBlocker.widget.php
+		/usr/local/www/widgets/widgets/
+		0755
+	
 	
 		http://www.pfsense.org/packages/config/pf-blocker/pfblocker_topspammers.xml
 		/usr/local/pkg/
@@ -279,7 +284,7 @@
 				Url
 				url
 				input
-				65
+				55
 			
 			
 		
-- 
cgit v1.2.3