From 8c5b659410a252f726eeafcda366015193db0943 Mon Sep 17 00:00:00 2001 From: Tom Schaefer Date: Wed, 29 Sep 2010 04:45:25 -0400 Subject: Version 1.5 added if selection, nano functions, and sp fix --- config/countryblock/countryblock.inc | 4 + config/countryblock/countryblock.tmp | 27 ++++- config/countryblock/countryblock.xml | 10 ++ config/countryblock/countryblock_if.tmp | 194 ++++++++++++++++++++++++++++++++ config/countryblock/firewall_shaper.tmp | 11 ++ 5 files changed, 240 insertions(+), 6 deletions(-) mode change 100644 => 100755 config/countryblock/countryblock.tmp create mode 100644 config/countryblock/countryblock_if.tmp create mode 100755 config/countryblock/firewall_shaper.tmp (limited to 'config/countryblock') diff --git a/config/countryblock/countryblock.inc b/config/countryblock/countryblock.inc index 7cab6c1d..e716f25b 100644 --- a/config/countryblock/countryblock.inc +++ b/config/countryblock/countryblock.inc @@ -59,8 +59,12 @@ function php_install_command_cb() //rename PHP files from .tmp to .php exec("cp /tmp/countryblock.tmp /usr/local/www/packages/countryblock/countryblock.php"); unlink_if_exists("/tmp/countryblock.tmp"); + exec("cp /tmp/countryblock_if.tmp /usr/local/www/packages/countryblock/countryblock_if.php"); + unlink_if_exists("/tmp/countryblock_if.tmp"); exec("cp /tmp/index.tmp /usr/local/www/packages/countryblock/index.php"); unlink_if_exists("/tmp/index.tmp"); + exec("cp /tmp/firewall_shaper.tmp /usr/local/www/packages/countryblock/firewall_shaper.php"); + unlink_if_exists("/tmp/firewall_shaper.tmp"); //Get scripts exec("cp /tmp/countryblock.sh /usr/local/etc/rc.d/countryblock.sh"); unlink_if_exists("/tmp/countryblock.sh"); diff --git a/config/countryblock/countryblock.tmp b/config/countryblock/countryblock.tmp old mode 100644 new mode 100755 index dc0fbbbc..f95c2e7c --- a/config/countryblock/countryblock.tmp +++ b/config/countryblock/countryblock.tmp @@ -68,7 +68,7 @@ if (count($_POST)>0) { } - write_config(); + //write_config(); //services_dnsmasq_configure(); sleep(1); $savemsg_cb = "Country Block settings have been saved/updated. "; @@ -98,7 +98,7 @@ else { ?> "); } } +conf_mount_ro(); ?> @@ -260,7 +261,7 @@ background-color: #F3F3F3; Enable Country Block

-
+ " method="post">

- Check the country that you would like to block completely. Currently + Warning! No Interfaces Selected Click if"; + } + + ?> +

+

Check the country that you would like to block completely. Currently of 246 selected. Manual

+

Manual

Block outbound? Bangladesh"; ob_start(); -$results = exec("cat countries.txt | grep BD"); +$results = exec("cat countries.txt | grep BB"); ob_end_clean(); - if ($results == 'BD') + if ($results == 'BB') echo "

  • Barbados
  • "; else echo "
  • Barbados
  • "; @@ -820,6 +833,7 @@ ob_end_clean(); else echo "
  • Congo - Brazzaville
  • "; + ob_start(); $results = exec("cat countries.txt | grep CD"); ob_end_clean(); @@ -2558,6 +2572,7 @@ ob_end_clean(); echo "
  • Zimbabwe
  • "; ?> + diff --git a/config/countryblock/countryblock.xml b/config/countryblock/countryblock.xml index 68ed8797..4edc4a6e 100644 --- a/config/countryblock/countryblock.xml +++ b/config/countryblock/countryblock.xml @@ -124,6 +124,16 @@ 0755 http://www.pfsense.org/packages/config/countryblock/whitelist.tmp + + /tmp/ + 0755 + http://www.pfsense.org/packages/config/countryblock/countryblock_if.tmp + + + /tmp/ + 0755 + http://www.pfsense.org/packages/config/countryblock/firewall_shaper.tmp + Variable One diff --git a/config/countryblock/countryblock_if.tmp b/config/countryblock/countryblock_if.tmp new file mode 100644 index 00000000..af56756a --- /dev/null +++ b/config/countryblock/countryblock_if.tmp @@ -0,0 +1,194 @@ +. + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, + OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. +*/ + +$pgtitle = "Country Block - Interfaces"; +require("guiconfig.inc"); + +/* + In this file, "port" refers to the physical port name, + while "interface" refers to LAN, WAN, or OPTn. +*/ + +/* get list without VLAN interfaces */ +$portlist = get_interface_list(); + +/* add VLAN interfaces */ +if (is_array($config['vlans']['vlan']) && count($config['vlans']['vlan'])) { + $i = 0; + foreach ($config['vlans']['vlan'] as $vlan) { + $portlist['vlan' . $i] = $vlan; + $portlist['vlan' . $i]['isvlan'] = true; + $i++; + } +} + +if ($_POST) { + + unset($input_errors); + + /* input validation */ + + /* Build a list of the port names so we can see how the interfaces map */ + $portifmap = array(); + foreach ($portlist as $portname => $portinfo) + $portifmap[$portname] = array(); + + /* Go through the list of ports selected by the user, + build a list of port-to-interface mappings in portifmap */ + conf_mount_rw(); + $myFile = "interfaces.txt"; + $fh = fopen($myFile, 'w+'); + + foreach ($_POST as $ifname => $ifport) { + //echo $ifname; + //echo "
    "; + fwrite($fh, $ifname . "\n"); + //if (($ifname == 'lan') || ($ifname == 'wan') || (substr($ifname, 0, 3) == 'opt')) + //$portifmap[$ifport][] = strtoupper($ifname); + } + + conf_mount_ro(); + + + if (!$input_errors) { + /* No errors detected, so update the config */ + foreach ($_POST as $ifname => $ifport) { + + if (($ifname == 'lan') || ($ifname == 'wan') || + (substr($ifname, 0, 3) == 'opt')) { + + + } + } + + $savemsg = get_std_save_message($retval); + + + + } +} + + + + + +$pgtitle = "CountryBlock Interfaces"; +include("head.inc"); + + + +?> + + + +

    + +Here to go back"); ?> +
    + + + + + +
    + +
    +
    + + + + + + + $iface): + if ($iface['descr']) + $ifdescr = $iface['descr']; + else + $ifdescr = strtoupper($ifname); + ?> + + + + + + + + + + + +
    InterfaceSelected 
    + + + + + $portinfo): ?> + + $portname"; + else + echo "$portname"; + } + ?> + + + + +
    +
    +
    +

    +

    +
    + + + + + + + diff --git a/config/countryblock/firewall_shaper.tmp b/config/countryblock/firewall_shaper.tmp new file mode 100755 index 00000000..d01ed55c --- /dev/null +++ b/config/countryblock/firewall_shaper.tmp @@ -0,0 +1,11 @@ + + + + + + + \ No newline at end of file -- cgit v1.2.3