aboutsummaryrefslogtreecommitdiffstats
path: root/config/Fit123
diff options
context:
space:
mode:
Diffstat (limited to 'config/Fit123')
-rw-r--r--config/Fit123/bin/afc/reset_states.sh7
-rw-r--r--config/Fit123/bin/cpaddon/filter.inc3332
-rwxr-xr-xconfig/Fit123/bin/cpaddon/services_captiveportal.abc608
-rwxr-xr-xconfig/Fit123/bin/date/index.abc264
-rwxr-xr-xconfig/Fit123/bin/dnssrv/system.abc347
-rw-r--r--config/Fit123/bin/ltsp/services.inc1320
-rwxr-xr-xconfig/Fit123/bin/ltsp/services_dhcp.abc696
-rw-r--r--config/Fit123/cass.xml59
-rw-r--r--config/Fit123/ddns.xml72
-rw-r--r--config/Fit123/fit123.inc428
-rw-r--r--config/Fit123/fit123.xml84
11 files changed, 0 insertions, 7217 deletions
diff --git a/config/Fit123/bin/afc/reset_states.sh b/config/Fit123/bin/afc/reset_states.sh
deleted file mode 100644
index 4a7eb7e7..00000000
--- a/config/Fit123/bin/afc/reset_states.sh
+++ /dev/null
@@ -1,7 +0,0 @@
-#!/bin/sh
-echo "Runnig the After Filter Change reset_states script" | logger
-sleep 60
-/sbin/pfctl -F state
-sleep 40
-/sbin/pfctl -F state
-echo "States has been reset" | logger
diff --git a/config/Fit123/bin/cpaddon/filter.inc b/config/Fit123/bin/cpaddon/filter.inc
deleted file mode 100644
index e9ca153a..00000000
--- a/config/Fit123/bin/cpaddon/filter.inc
+++ /dev/null
@@ -1,3332 +0,0 @@
-<?php
-/* $Id$ */
-/*
- filter.inc
- Copyright (C) 2004-2006 Scott Ullrich
- Copyright (C) 2005 Bill Marquette
- Copyright (C) 2006 Peter Allgeyer
- All rights reserved.
-
- originally part of m0n0wall (http://m0n0.ch/wall)
- Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
- 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.
-
-*/
-
-/* include all configuration functions */
-require_once("functions.inc");
-require_once("pkg-utils.inc");
-require_once("notices.inc");
-
-if(!function_exists("filter_configure"))
- require_once("filter.inc");
-
-if($config['system']['shapertype'] <> "m0n0")
- require_once ("shaper.inc");
-
-/* holds the items that will be executed *AFTER* the filter is fully loaded */
-$after_filter_configure_run = array();
-
-function filter_pflog_start() {
- global $config, $g;
-
- if(isset($config['system']['developerspew'])) {
- $mt = microtime();
- echo "filter_pflog_start() being called $mt\n";
- }
-
- mute_kernel_msgs();
-
- $pid = `ps awwwux | grep -v "grep" | grep "tcpdump -s 256 -v -l -n -e -ttt -i pflog0" | awk '{ print $2 }'`;
- if(!$pid)
- mwexec_bg("/usr/sbin/tcpdump -s 256 -v -l -n -e -ttt -i pflog0 | logger -t pf -p local0.info");
-
- unmute_kernel_msgs();
-
-}
-
-/* reload filter async */
-function filter_configure() {
- if(isset($config['system']['developerspew'])) {
- $mt = microtime();
- echo "filter_configure() being called $mt\n";
- }
- global $g;
-
- touch($g['tmp_path'] . "/filter_dirty");
-}
-
-/* reload filter sync */
-function filter_configure_sync() {
- global $config, $g, $after_filter_configure_run;
- filter_pflog_start();
- update_filter_reload_status("Initializing");
- /* invalidate interface cache */
- get_interface_arr(true);
- if(isset($config['system']['developerspew'])) {
- $mt = microtime();
- echo "filter_configure_sync() being called $mt\n";
- }
-
- /* load ipfw / dummynet early on if required */
- if($config['system']['dummynetshaper']) {
- $status = intval(`kldstat | grep ipfw | wc -l | awk '{ print $1 }'`);
- if($status == "0") {
- mwexec("/sbin/kldload ipfw");
- mwexec("/sbin/kldload dummynet");
- }
- } else {
- /* check to see if any rules reference a schedule
- * and if so load ipfw for later usage.
- */
- foreach($config['filter']['rule'] as $rule) {
- if($rule['sched'])
- $time_based_rules = true;
- }
- if($time_based_rules == true) {
- $status = intval(`kldstat | grep ipfw | wc -l | awk '{ print $1 }'`);
- if($status == "0") {
- mute_kernel_msgs();
- mwexec("/sbin/kldload ipfw");
- unmute_kernel_msgs();
- }
- if ($config['system']['maximumstates'] <> "" && is_numeric($config['system']['maximumstates'])) {
- /* Set ipfw states to user defined maximum states in Advanced menu. */
- mwexec("sysctl net.inet.ip.fw.dyn_max={$config['system']['maximumstates']}");
- } else {
- /* Set to default 10,000 */
- mwexec("sysctl net.inet.ip.fw.dyn_max=10000");
- }
- exec("/sbin/ipfw delete set 9");
- exec("/sbin/ipfw delete 2");
- exec("/sbin/ipfw delete 3");
- }
- }
-
- $lan_if = $config['interfaces']['lan']['if'];
- $wan_if = get_real_wan_interface();
-
- /* generate aliases */
- if($g['booting'] == true) echo ".";
- update_filter_reload_status("Creating aliases");
- $aliases = filter_generate_aliases();
- /* generate nat rules */
- if($g['booting'] == true) echo ".";
- update_filter_reload_status("Generating NAT rules");
- $natrules = filter_nat_rules_generate();
- /* generate pfctl rules */
- if($g['booting'] == true) echo ".";
- update_filter_reload_status("Generating filter rules");
- $pfrules = filter_rules_generate();
-
- if (isset($config['shaper']['enable']) and $config['system']['shapertype'] <> "m0n0") {
- /* generate altq interface setup parms */
- if($g['booting'] == true) echo ".";
- update_filter_reload_status("Generating ALTQ interfaces");
- $altq_ints = filter_setup_altq_interfaces();
- /* generate altq queues */
- if($g['booting'] == true) echo ".";
- update_filter_reload_status("Generating ALTQ queues");
- $altq_queues = filter_generate_altq_queues($altq_ints);
- /* generate altq rules */
- if($g['booting'] == true) echo ".";
- /* Setup a default rule that tags ALL packets as unshaped
- * we'll match only unshaped packets in the shaper code later
- * this allows the shaper to be first match
- */
- $pf_altq_rules = "block in all tag unshaped label \"SHAPER: first match rule\"\n";
- update_filter_reload_status("Generating ALTQ rules");
- $pf_altq_rules .= filter_generate_pf_altq_rules();
- }
-
- update_filter_reload_status("Loading filter rules");
-
- /* enable pf if we need to, otherwise disable */
- if (!isset ($config['system']['disablefilter'])) {
- mwexec("/sbin/pfctl -e", true);
- } else {
- mwexec("/sbin/pfctl -d");
- unlink_if_exists("{$g['tmp_path']}/filter_loading");
- update_filter_reload_status("Filter is disabled. Not loading rules.");
- return;
- }
-
- // Copy rules.debug to rules.debug.old
- if(file_exists("{$g['tmp_path']}/rules.debug"))
- exec("cp {$g['tmp_path']}/rules.debug {$g['tmp_path']}/rules.debug.old");
-
- $fd = fopen("{$g['tmp_path']}/rules.debug", "w");
- $rules = $aliases . " \n";
-
- update_filter_reload_status("Setting up logging information");
-
- $rules .= setup_logging_interfaces();
-
- if ($config['system']['optimization'] <> "") {
- $rules .= "set optimization {$config['system']['optimization']}\n";
- if ($config['system']['optimization'] == "conservative") {
- $rules .= "set timeout { udp.first 300, udp.single 150, udp.multiple 900 }\n";
- }
- } else {
- $rules .= "set optimization normal\n";
- }
-
- if ($config['system']['maximumstates'] <> "" && is_numeric($config['system']['maximumstates'])) {
- /* User defined maximum states in Advanced menu. */
- $rules .= "set limit states {$config['system']['maximumstates']}\n";
- }
- $rules .= "\n";
-
- update_filter_reload_status("Setting up SCRUB information");
- /* get our wan interface? */
- $wanif = get_real_wan_interface();
-
- /* disable scrub option */
- if(!isset($config['system']['disablescrub'])) {
- /* set up MSS clamping */
- if ($config['interfaces']['wan']['mtu'] <> "" and is_numeric($config['interfaces']['wan']['mtu']))
- $mssclamp = "max-mss " . (intval($config['interfaces']['wan']['mtu'] - 40));
- else
- if ($config['interfaces']['wan']['ipaddr'] == "pppoe")
- $mssclamp = "max-mss 1452";
- else
- $mssclamp = "";
-
- /* configure no-df for linux nfs and others */
- if ($config['system']['scrubnodf'])
- $scrubnodf = "no-df random-id";
- else
- $scrubnodf = "random-id";
- $rules .= "scrub all {$scrubnodf} {$mssclamp} fragment reassemble\n"; // reassemble all directions
- } else if ($config['interfaces']['wan']['mtu'] <> "" and is_numeric($config['interfaces']['wan']['mtu'])) {
- $rules .= "scrub {$mssclamp}\n"; // reassemble all directions
- }
-
- if($config['system']['shapertype'] <> "m0n0") {
- $rules.= "{$altq_ints}\n";
- $rules.= "{$altq_queues}\n";
- }
- $rules.= "{$natrules}\n";
- if($config['system']['shapertype'] <> "m0n0")
- $rules.= "{$pf_altq_rules}\n";
- $rules.= "{$pfrules}\n";
- fwrite($fd, $rules);
- fclose($fd);
-
- $rules = "1"; // force to be diff from oldrules
- $oldrules = "2"; // force to be diff from rules
-
- if(file_exists("{$g['tmp_path']}/rules.debug"))
- $rules = file_get_contents("{$g['tmp_path']}/rules.debug");
- if(file_exists("{$g['tmp_path']}/rules.debug.old"))
- $oldrules = file_get_contents("{$g['tmp_path']}/rules.debug.old");
-
- if(isset($config['system']['developerspew'])) {
- $mt = microtime();
- echo "pfctl being called at $mt\n";
- }
- $rules_loading = mwexec("/sbin/pfctl -o basic -f {$g['tmp_path']}/rules.debug");
- if(isset($config['system']['developerspew'])) {
- $mt = microtime();
- echo "pfctl done at $mt\n";
- }
-
- /* check for a error while loading the rules file. if an error has occured
- then output the contents of the error to the caller */
- if($rules_loading <> 0) {
- $rules_error = exec_command("/sbin/pfctl -f {$g['tmp_path']}/rules.debug");
- $line_error = split("\:", $rules_error);
- $line_number = $line_error[1];
- $rules_file = `/bin/cat {$g['tmp_path']}/rules.debug`;
- $line_split = split("\n", $rules_file);
- if(is_array($line_split))
- $line_error = "The line in question reads [{$line_number}]: {$line_split[$line_number-1]}";
- if($line_error and $line_number) {
- file_notice("filter_load", "There were error(s) loading the rules: {$rules_error} {$line_error}", "Filter Reload", "");
- log_error("There were error(s) loading the rules: {$rules_error} - {$line_error}");
- update_filter_reload_status("There were error(s) loading the rules: {$rules_error} - {$line_error}");
- return;
- }
- }
-
- unlink_if_exists("/usr/local/pkg/pf/carp_sync_client.php");
-
- /* run items scheduled for after filter configure run */
- $fda = fopen("/tmp/commands.txt", "w");
- foreach($after_filter_configure_run as $afcr)
- fwrite($fda, $afcr . "\n");
- fclose($fda);
- if(file_exists("/tmp/commands.txt")) {
- mwexec("sh /tmp/commands.txt &");
- unlink("/tmp/commands.txt");
- }
-
- update_filter_reload_status("Running plugins");
-
- if(is_dir("/usr/local/pkg/pf/")) {
- /* process packager manager custom rules */
- update_filter_reload_status("Running plugins (pf)");
- run_plugins("/usr/local/pkg/pf/");
- update_filter_reload_status("Plugins completed.");
- }
-
- system_start_ftp_helpers();
-
- if($config['system']['shapertype'] == "m0n0") {
- require_once ("/etc/inc/m0n0/shaper.inc");
- shaper_configure();
- }
-
- /* if time based rules are enabled then swap in the set */
- if($time_based_rules == true) {
- tdr_install_cron(true);
- tdr_install_set();
- } else {
- tdr_install_cron(false);
- }
-
- /*
- we need a way to let a user run a shell cmd after each
- filter_configure() call. run this xml command after
- each change.
- */
- if($config['system']['afterfilterchangeshellcmd'] <> "")
- mwexec($config['system']['afterfilterchangeshellcmd']);
-
- /* sync carp entries to other firewalls */
- update_filter_reload_status("Syncing CARP data");
- carp_sync_client();
-
- system_routing_configure();
-
- update_filter_reload_status("Done");
-
- return 0;
-}
-
-function filter_generate_aliases() {
- global $config, $g;
- if(isset($config['system']['developerspew'])) {
- $mt = microtime();
- echo "filter_generate_aliases() being called $mt\n";
- }
- $aliases = "";
-
- $i = 0;
-
- $lanip = find_interface_ip($config['interfaces']['lan']['if']);
- $wanip = find_interface_ip(get_real_wan_interface());
-
- $aliases .= "# System Aliases \n";
- $aliases .= "loopback = \"{ lo0 }\"\n";
- $aliases .= "lan = \"{ {$config['interfaces']['lan']['if']}{$lan_aliases} }\"\n";
-
- if($config['interfaces']['wan']['ipaddr'] == "pppoe" or $config['interfaces']['wan']['ipaddr'] == "pptp") {
- $aliases .= "ng0 = \"{ " . $config['interfaces']['wan']['if'] . " " . get_real_wan_interface() . " }\" \n";
- $aliases .= "wan = \"{ " . $config['interfaces']['wan']['if'] . " ng0 }\"\n";
- } else {
- $aliases .= "wan = \"{ " . get_real_wan_interface() . " }\"\n";
- }
-
- $aliases .= "enc0 = \"{ enc0 }\"\n";
-
- /* used to count netgraph interfaces */
- $counter = 0;
-
- /* ng ordering is VERY important here. do not alter order */
- if($config['pptpd']['mode'] == "server") {
- /* build pptp alias */
- $tmp = "pptp = \"{ ";
- $starting_pptp = 1;
- if($config['interfaces']['wan']['ipaddr'] == "pppoe")
- $starting_pptp = 1;
- for($x=$starting_pptp; $x<$g["n_pptp_units"]+$starting_pptp; $x++)
- $tmp .= "ng{$x} ";
- $counter = $x;
- $tmp .= "}\" \n";
- if($counter > 0)
- $aliases .= $tmp;
- }
- if($config['pppoe']['mode'] == "server") {
- /* build pppoe alias */
- $tmp = "pppoe = \"{ ";
- $starting_pppoe = 1;
- if($config['interfaces']['wan']['ipaddr'] == "pppoe")
- $starting_pppoe = 1;
- for($x=0; $x<$g["n_pppoe_units"]+$starting_pppoe; $x++) {
- $tmp .= "ng{$counter} ";
- $counter++;
- }
- $tmp .= "}\" \n";
- if($x > 0)
- $aliases .= $tmp;
- }
-
- $ifdescrs = array();
- for ($j = 1; isset($config['interfaces']['opt' . $j]); $j++) {
- $ifdescrs['opt' . $j] = "opt" . $j;
- }
- $bridgetracker = 0;
- foreach ($ifdescrs as $ifdescr => $ifname) {
- /* do not process tun interfaces */
- /* do process tun interfaces for openvpn compatibility */
- /* if(stristr(filter_opt_interface_to_real($ifname), "tun") == true) continue; */
- $aliases .= convert_friendly_interface_to_friendly_descr($ifname) . " = \"{ " . filter_opt_interface_to_real($ifname);
-// if(link_int_to_bridge_interface($ifname))
-// $aliases .= " " . link_int_to_bridge_interface($ifname);
- $optip = find_interface_ip($config['interfaces'][$ifname]['if']);
- if($optip) {
- $opt_carp_ints = link_ip_to_carp_interface($optip);
- if($opt_carp_ints)
- $aliases .= $opt_carp_ints;
- }
- $aliases .= " }\"\n";
- }
- $aliases .= "# User Aliases \n";
- /* Setup pf groups */
- if (isset($config['aliases']['alias'])) {
- foreach ($config['aliases']['alias'] as $alias) {
- $extraalias = "";
- $ip = find_interface_ip($alias['address']);
- $extraalias = " " . link_ip_to_carp_interface($ip);
- $aliases .= "{$alias['name']} = \"{ {$alias['address']}{$extralias} }\"\n";
- }
- }
-
- return $aliases;
-}
-
-function get_vpns_list() {
- global $config;
- /* build list of vpns */
- $vpns = "";
- $isfirst = true;
- /* ipsec */
- if ($config['ipsec']['tunnel']) {
- foreach ($config['ipsec']['tunnel'] as $tunnel) {
- if ($isfirst == false)
- $vpns .= " ";
- $vpns .= $tunnel['remote-subnet'];
- $isfirst = false;
- }
- }
- /* openvpn */
- foreach (array('client', 'server') as $type) {
- $conf =& $config['installedpackages']["openvpn$type"]['config'];
- if (!is_array($conf)) continue;
- foreach ($conf as $tunnel) {
- if ($isfirst == false)
- $vpns .= " ";
- $vpns .= $tunnel['remote_network'];
- $isfirst = false;
- }
- }
- /* pppoe */
- if ($config['pppoe']['remoteip']) {
- if ($isfirst == false)
- $vpns .= " ";
- $vpns .= $config['pppoe']['remoteip'] ."/". $config['pppoe']['pppoe_subnet'];
- $isfirst = false;
- }
- $vpns .= " ";
- return $vpns;
-}
-
-function generate_optcfg_array(& $optcfg) {
- global $config;
- if(isset($config['system']['developerspew'])) {
- $mt = microtime();
- echo "generate_optcfg_array() being called $mt\n";
- }
-
- for ($i = 1; isset($config['interfaces']['opt' . $i]); $i++) {
- $oc = $config['interfaces']['opt' . $i];
-
- if (isset($oc['enable']) && $oc['if']) {
- $oic = array();
- $oic['if'] = $oc['if'];
-
- if ($oc['bridge']) {
- if (!strstr($oc['bridge'], "opt") ||
- isset($config['interfaces'][$oc['bridge']]['enable'])) {
- if (is_ipaddr($config['interfaces'][$oc['bridge']]['ipaddr'])) {
- $oic['ip'] = $config['interfaces'][$oc['bridge']]['ipaddr'];
- $oic['sn'] = $config['interfaces'][$oc['bridge']]['subnet'];
- $oic['sa'] = gen_subnet($oic['ip'], $oic['sn']);
- }
- }
- $oic['bridge'] = 1;
- } else {
- $oic['ip'] = $oc['ipaddr'];
- $oic['sn'] = $oc['subnet'];
- $oic['sa'] = gen_subnet($oic['ip'], $oic['sn']);
- $oic['descr'] = $oc['descr'];
- }
-
- $optcfg['opt' . $i] = $oic;
- }
- }
-}
-
-function filter_flush_nat_table() {
- global $config, $g;
- if(isset($config['system']['developerspew'])) {
- $mt = microtime();
- echo "filter_flush_nat_table() being called $mt\n";
- }
- return mwexec("/sbin/pfctl -F nat");
-}
-
-function filter_flush_state_table() {
- global $config, $g;
-
- return mwexec("/sbin/pfctl -F state");
-}
-
-/* Generate a 'nat on' or 'no nat on' rule for given interface */
-function filter_nat_rules_generate_if($if, $src = "any", $srcport = "", $dst = "any", $dstport = "", $natip = "", $natport = "", $nonat = false, $staticnatport = false) {
- global $config;
-
- /* XXX: billm - any idea if this code is needed? */
- if($src == "/32" || $src{0} == "/")
- return;
-
- /* Use interface name if IP isn't specified */
- if ($natip != "")
- $tgt = "{$natip}/32";
- else
- $tgt = "($if)";
-
- /* Add the hard set source port (useful for ISAKMP) */
- if ($natport != "")
- $tgt .= " port {$natport}";
-
- /* sometimes this gets called with "" instead of a value */
- if ($src == "")
- $src = "any";
-
- /* Match on this source port */
- if ($srcport != "")
- $src .= " port {$srcport}";
-
- /* sometimes this gets called with "" instead of a value */
- if ($dst == "")
- $dst = "any";
-
- /* Match on this dest port */
- if ($dstport != "")
- $dst .= " port {$dstport}";
-
- /* Allow for negating NAT entries */
- if ($nonat) {
- $nat = "no nat";
- $target = "";
- } else {
- $nat = "nat";
- $target = "-> {$tgt}";
- }
-
- /* outgoing static-port option, hamachi, Grandstream, VOIP, etc */
- if($staticnatport)
- $staticnatport_txt = " static-port";
- else
- if(!$natport)
- $staticnatport_txt = " port 1024:65535"; // set source port range
- else
- $staticnatport_txt = "";
-
- $if_friendly = convert_real_interface_to_friendly_descr($if);
-
- /* Put all the pieces together */
- if($if_friendly)
- $natrule = "{$nat} on \${$if_friendly} from {$src} to {$dst} {$target}{$staticnatport_txt}\n";
-
- return $natrule;
-}
-
-function is_one_to_one_or_server_nat_rule($iptocheck) {
- global $config, $target;
- if(isset($config['system']['developerspew'])) {
- $mt = microtime();
- echo "is_one_to_one_or_server_nat_rule() being called $mt\n";
- }
-
- if($config['nat']['onetoone'] <> "")
- foreach($config['nat']['onetoone'] as $onetoone) {
- if(ip_in_subnet($iptocheck,$onetoone['internal']."/".$onetoone['subnet']) == true)
- return true;
- if($onetoone['internal'] == $target)
- return true;
- }
-
- if($config['nat']['servernat'] <> "")
- foreach($config['nat']['servernat'] as $onetoone) {
- $int = explode("/", $onetoone['ipaddr']);
- if(ip_in_subnet($iptocheck,$onetoone['ipaddr']."/".$onetoone['subnet']) == true)
- return true;
- if($onetoone['ipaddr'] == $target)
- return true;
- }
-
- if($config['nat']['rule'] <> "")
- foreach($config['nat']['rule'] as $onetoone) {
- $int = explode("/", $onetoone['target']);
- if(ip_in_subnet($iptocheck,$onetoone['target']."/".$onetoone['subnet']) == true)
- return true;
- if($onetoone['target'] == $target)
- return true;
- }
-
- return FALSE;
-}
-
-function filter_nat_rules_generate() {
- global $config, $g, $after_filter_configure_run;
-
- $wancfg = $config['interfaces']['wan'];
- $lancfg = $config['interfaces']['lan'];
-
- $pptpdcfg = $config['pptpd'];
- $pppoecfg = $config['pppoe'];
- $wanif = get_real_wan_interface();
-
- $lanif = $config['interfaces']['lan']['if'];
- $lanip = $config['interfaces']['lan']['ipaddr'];
-
- $lansa = gen_subnet($lancfg['ipaddr'], $lancfg['subnet']);
-
- $natrules .= "nat-anchor \"pftpx/*\"\n";
-
- $natrules .= "nat-anchor \"natearly/*\"\n";
- $natrules .= "nat-anchor \"natrules/*\"\n";
-
- $natrules .= "# FTP proxy\n";
- $natrules .= "rdr-anchor \"pftpx/*\"\n";
-
- update_filter_reload_status("Creating 1:1 rules...");
-
- /* any 1:1 mappings? */
- if (is_array($config['nat']['onetoone'])) {
- foreach ($config['nat']['onetoone'] as $natent) {
- if (!is_numeric($natent['subnet']))
- $sn = 32;
- else
- $sn = $natent['subnet'];
-
- if (!$natent['interface'] || ($natent['interface'] == "wan"))
- $natif = $wanif;
- else
- $natif = $config['interfaces'][$natent['interface']]['if'];
-
- if($natif)
- $natrules .= "binat on $natif from {$natent['internal']}/{$sn} to any -> {$natent['external']}/{$sn}\n";
- }
- }
-
- $natrules .= "\n# Outbound NAT rules\n";
-
- /* outbound rules - advanced or standard */
- if (isset($config['nat']['advancedoutbound']['enable'])) {
- /* advanced outbound rules */
- if (is_array($config['nat']['advancedoutbound']['rule'])) {
- foreach ($config['nat']['advancedoutbound']['rule'] as $obent) {
-
- update_filter_reload_status("Creating advanced outbound rule {$obent['descr']}");
-
- $src = $obent['source']['network'];
- if (isset($obent['destination']['not']) && !isset($obent['destination']['any']))
- $dst = "!" . $obent['destination']['address'];
- else
- $dst = $obent['destination']['address'];
-
-
- if (!$obent['interface'] || ($obent['interface'] == "wan"))
- $natif = $wanif;
- else
- $natif = $config['interfaces'][$obent['interface']]['if'];
-
- $natrules .= filter_nat_rules_generate_if($natif,
- $src,
- $obent['sourceport'],
- $dst,
- $obent['dstport'],
- $obent['target'],
- $obent['natport'],
- isset($obent['nonat']),
- isset($obent['staticnatport'])
- );
- }
- }
- } else {
- /* standard outbound rules (one for each interface) */
- update_filter_reload_status("Creating outbound NAT rules");
-
- $natrules .= filter_nat_rules_generate_if($wanif,
- "{$lansa}/{$lancfg['subnet']}", 500, "", 500, null, 500, false);
- $natrules .= filter_nat_rules_generate_if($wanif,
- "{$lansa}/{$lancfg['subnet']}", 5060, "", 5060, null, 5060, false);
- $natrules .= filter_nat_rules_generate_if($wanif,
- "{$lansa}/{$lancfg['subnet']}");
-
- $optints = array();
- generate_optcfg_array($optints);
-
- /* generate lan nat mappings for opts with a gateway opts */
- foreach($optints as $oc) {
- $opt_interface = $oc['if'];
- if (interface_has_gateway("$opt_interface")) {
- $natrules .= filter_nat_rules_generate_if($opt_interface,
- "{$lansa}/{$lancfg['subnet']}", 500, "", 500, null, 500, false);
- $natrules .= filter_nat_rules_generate_if($opt_interface,
- "{$lansa}/{$lancfg['subnet']}", 5060, "", 5060, null, 5060, false);
- $natrules .= filter_nat_rules_generate_if($opt_interface,
- "{$lansa}/{$lancfg['subnet']}");
- }
- }
-
- /* optional interfaces */
- for ($i = 1; isset($config['interfaces']['opt' . $i]); $i++) {
- update_filter_reload_status("Creating outbound rules (opt{$i})");
- $optcfg = $config['interfaces']['opt' . $i];
-
- if ((isset ($optcfg['enable'])) && (!$optcfg['bridge']) && (!interface_has_gateway("opt{$i}"))) {
- $optsa = gen_subnet($optcfg['ipaddr'], $optcfg['subnet']);
-
- /* create outbound nat entries for primary wan */
- $natrules .= filter_nat_rules_generate_if($wanif,
- "{$optsa}/{$optcfg['subnet']}", 500, "", 500, null, 500, false);
- $natrules .= filter_nat_rules_generate_if($wanif,
- "{$optsa}/{$optcfg['subnet']}", 5060, "", 5060, null, 5060, false);
- $natrules .= filter_nat_rules_generate_if($wanif,
- "{$optsa}/{$optcfg['subnet']}", null, "", null, null, null, isset($optcfg['nonat']));
-
- /* create outbound nat entries for all opt wans */
- foreach($optints as $oc) {
- $opt_interface = $oc['if'];
- if (interface_has_gateway("$opt_interface")) {
- $natrules .= filter_nat_rules_generate_if($opt_interface,
- "{$optsa}/{$optcfg['subnet']}", 500, "", 500, null, 500, false);
- $natrules .= filter_nat_rules_generate_if($opt_interface,
- "{$optsa}/{$optcfg['subnet']}", 5060, "", 5060, null, 5060, false);
- $natrules .= filter_nat_rules_generate_if($opt_interface,
- "{$optsa}/{$optcfg['subnet']}", null, "", null, null, null, isset($optcfg['nonat']));
- }
- }
- }
- }
-
- /* PPTP subnet */
- if ($pptpdcfg['mode'] == "server") {
- $pptp_subnet = $g['pptp_subnet'];
- if($config['pptp']['pptp_subnet'] <> "")
- $pptp_subnet = $config['pptp']['pptp_subnet'];
- $natrules .= filter_nat_rules_generate_if($wanif,
- "{$pptpdcfg['remoteip']}/{$pptp_subnet}", 500, "", 500, null, 500, false);
- $natrules .= filter_nat_rules_generate_if($wanif,
- "{$pptpdcfg['remoteip']}/{$pptp_subnet}", 5060, "", 5060, null, 5060, false);
- $natrules .= filter_nat_rules_generate_if($wanif,
- "{$pptpdcfg['remoteip']}/{$pptp_subnet}");
-
- /* generate nat mappings for opts with a gateway opts */
- foreach($optints as $oc) {
- $opt_interface = $oc['if'];
- if ((is_private_ip($pptpdcfg['remoteip'])) && (interface_has_gateway($opt_interface))) {
- $natrules .= filter_nat_rules_generate_if($opt_interface,
- "{$pptpdcfg['remoteip']}/{$pptp_subnet}", 500, "", 500, null, 500, false);
- $natrules .= filter_nat_rules_generate_if($opt_interface,
- "{$pptpdcfg['remoteip']}/{$pptp_subnet}", 5060, "", 5060, null, 5060, false);
- $natrules .= filter_nat_rules_generate_if($opt_interface,
- "{$pptpdcfg['remoteip']}/{$pptp_subnet}");
- }
- }
- }
-
- /* PPPoE subnet */
- if ($pppoecfg['mode'] == "server") {
- $pppoe_subnet = $g['pppoe_subnet'];
- if($config['pppoe']['pppoe_subnet'] <> "")
- $pppoe_subnet = $config['pppoe']['pppoe_subnet'];
- $natrules .= filter_nat_rules_generate_if($wanif,
- "{$pppoecfg['remoteip']}/{$pppoe_subnet}", 500, "", 500, null, 500, false);
- $natrules .= filter_nat_rules_generate_if($wanif,
- "{$pppoecfg['remoteip']}/{$pppoe_subnet}", 5060, "", 5060, null, 5060, false);
- $natrules .= filter_nat_rules_generate_if($wanif,
- "{$pppoecfg['remoteip']}/{$pppoe_subnet}");
-
- /* generate nat mappings for opts with a gateway opts */
- foreach($optints as $oc) {
- $opt_interface = $oc['if'];
- if ((is_private_ip($pppoecfg['remoteip'])) && (interface_has_gateway($opt_interface))) {
- $natrules .= filter_nat_rules_generate_if($opt_interface,
- "{$pppoecfg['remoteip']}/{$pppoe_subnet}", 500, "", 500, null, 500, false);
- $natrules .= filter_nat_rules_generate_if($opt_interface,
- "{$pppoecfg['remoteip']}/{$pppoe_subnet}", 5060, "", 5060, null, 5060, false);
- $natrules .= filter_nat_rules_generate_if($opt_interface,
- "{$pppoecfg['remoteip']}/{$pppoe_subnet}");
- }
- }
- }
-
- /* static routes */
- if (is_array($config['staticroutes']['route'])) {
- foreach ($config['staticroutes']['route'] as $route) {
- $netip = explode("/", $route['network']);
- if ((! interface_has_gateway($route['interface'])) && (is_private_ip($netip[0]))) {
- $natrules .= filter_nat_rules_generate_if($wanif,
- "{$route['network']}", 500, "", 500, null, 500, false);
- $natrules .= filter_nat_rules_generate_if($wanif,
- "{$route['network']}", 5060, "", 5060, null, 5060, false);
- $natrules .= filter_nat_rules_generate_if($wanif,
- "{$route['network']}", "", null);
- }
- /* generate nat mapping for static routes on opts */
- foreach($optints as $oc) {
- $opt_interface = $oc['if'];
- if ((! interface_has_gateway($route['interface'])) && (is_private_ip($netip[0])) && (interface_has_gateway($opt_interface))) {
- $natrules .= filter_nat_rules_generate_if($opt_interface,
- "{$route['network']}", 500, "", 500, null, 500, false);
- $natrules .= filter_nat_rules_generate_if($opt_interface,
- "{$route['network']}", 5060, "", 5060, null, 5060, false);
- $natrules .= filter_nat_rules_generate_if($opt_interface,
- "{$route['network']}", "", null);
- }
- }
-
- }
- }
-
- }
-
- $natrules .= "\n#SSH Lockout Table\n";
- $natrules .= "table <sshlockout> persist\n\n";
-
- /* is SPAMD insalled? */
- if (is_package_installed("spamd") == 1) {
- $natrules .= "\n# spam table \n";
-
- $natrules .= "table <whitelist> persist\n";
- $natrules .= "table <blacklist> persist\n";
- $natrules .= "table <spamd> persist\n";
- if(file_exists("/var/db/whitelist.txt"))
- $natrules .= "table <spamd-white> persist file \"/var/db/whitelist.txt\"\n";
- $natrules .= "rdr pass on {$wanif} proto tcp from <blacklist> to port smtp -> 127.0.0.1 port spamd\n";
- $natrules .= "rdr pass on {$wanif} proto tcp from <spamd> to port smtp -> 127.0.0.1 port spamd\n";
- $natrules .= "rdr pass on {$wanif} proto tcp from !<spamd-white> to port smtp -> 127.0.0.1 port spamd\n";
- if($config['installedpackages']['spamdsettings']['config'])
- foreach($config['installedpackages']['spamdsettings']['config'] as $ss)
- $nextmta = $ss['nextmta'];
- if($nextmta <> "") {
- $natrules .= "rdr pass on {$wanif} proto tcp from <spamd-white> to port smtp -> {$nextmta} port smtp\n";
- }
- }
-
- /* load balancer anchor */
- $natrules .= "\n# Load balancing anchor - slbd updates\n";
- $natrules .= "rdr-anchor \"slb\"\n";
-
- update_filter_reload_status("Setting up FTP helper");
-
- $natrules .= "\n# FTP Proxy/helper\n";
- /* build an array of interfaces to work with */
- $iflist = array("lan" => "LAN");
- for ($i = 1; isset($config['interfaces']['opt' . $i]); $i++)
- $iflist['opt' . $i] = "opt{$i}";
- $interface_counter = 0;
- $vpns_list = get_vpns_list();
- /* prevent 1:1 ips from pftpx, they will be handled by ftp-sesame */
- if($config['nat']['onetoone'])
- foreach ($config['nat']['onetoone'] as $vipent)
- $onetoone_list .= "{$vipent['internal']} ";
- if($onetoone_list)
- $natrules .= "table <onetoonelist> { $onetoone_list }\n";
- if($vpns_list)
- $natrules .= "table <vpns> { $vpns_list }\n";
- /* loop through all interfaces and handle pftpx redirections */
- foreach ($iflist as $ifent => $ifname) {
- $ifname_lower = convert_friendly_interface_to_friendly_descr(strtolower($ifname));
- $realif = convert_friendly_interface_to_real_interface_name(strtolower($ifname));
- $int_ip = find_interface_ip($realif);
- if(isset($config['interfaces'][strtolower($ifname)]['disableftpproxy'])) {
- if($g['debug'])
- log_error("Filter: FTP proxy disabled for interface {$ifname} - ignoring.");
- $interface_counter++;
- continue;
- }
- if(stristr($ifname, "opt")) {
- if(!isset($config['interfaces'][$ifname]['enable'])) {
- continue;
- }
- }
- /* are we in routed mode? no source nat rules and not a outside interface? */
- /* If we have advanced outbound nat we skip the FTP proxy, we use ftpsesame */
- if((isset($config['nat']['advancedoutbound']['enable'])) && (! interface_has_gateway($ifname))) {
- $sourcenat = 0;
- /* we are using advanced outbound nat, are we in routing mode? */
- $realif = convert_friendly_interface_to_real_interface_name($ifname);
- /* if the interface address lies within a outbound NAT source network we should skip */
- if(! empty($config['nat']['advancedoutbound']['rule'])) {
- foreach($config['nat']['advancedoutbound']['rule'] as $natnetwork) {
- if(ip_in_subnet($int_ip, $natnetwork['source']['network'])) {
- /* if the interface address is matched in the AON Rule we need the ftp proxy */
- $sourcenat++;
- }
- }
- }
- if($sourcenat == 0) {
- if($g['debug'])
- log_error("Filter: No AON rule matched for interface {$ifname} - not using the FTP proxy");
- $interface_counter++;
- continue;
- } else {
- if($g['debug'])
- log_error("Filter: AON Rule matched for interface {$ifname} - using FTP proxy");
- }
- }
- $tmp_port = 8021 + $interface_counter;
- $tmp_interface = convert_friendly_interface_to_real_interface_name($ifname);
- $ifname_lower = strtolower(convert_friendly_interface_to_friendly_descr($ifname));
- $vpns = get_vpns_list();
- /* if the user has defined, include the alias so that we do not redirect ftp
- connections across the tunnels to pftpx */
- $int_ip = find_interface_ip($tmp_interface);
- /* if interface lacks an ip, dont setup a rdr for ftp. they are most likely on a bridged interface */
- if($int_ip and $vpns_list)
- if($ifname_lower) {
- $natrules .= "no rdr on $tmp_interface proto tcp from any to <vpns> port 21\n";
- if($onetoone_list)
- $natrules .= "no rdr on $tmp_interface proto tcp from <onetoonelist> to any port 21\n";
- }
- if($ifname_lower)
- $natrules .= "rdr on $tmp_interface proto tcp from any to any port 21 -> 127.0.0.1 port {$tmp_port}\n";
- $interface_counter++;
- }
- $natrules .= "\n";
-
- /* DIAG: add ipv6 NAT, if requested */
- if (isset($config['diag']['ipv6nat']['enable']) and $config['diag']['ipv6nat']['ipaddr'] <> "") {
- /* XXX: FIX ME! IPV6 */
- $natrules .= "rdr on \$wan proto ipv6 from any to any -> {$config['diag']['ipv6nat']['ipaddr']}\n";
- }
-
- if(file_exists("/var/etc/inetd.conf"))
- mwexec("rm /var/etc/inetd.conf");
- touch("/var/etc/inetd.conf");
-
- if (isset($config['nat']['rule'])) {
- $natrules .= "# NAT Inbound Redirects\n";
-
- if(!isset($config['system']['disablenatreflection'])) {
- $inetd_fd = fopen("/var/etc/inetd.conf","w");
- /* start redirects on port 19000 of localhost */
- $starting_localhost_port = 19000;
- }
-
- foreach ($config['nat']['rule'] as $rule) {
-
- update_filter_reload_status("Creating NAT rule {$rule['descr']}");
-
- /* if item is an alias, expand */
- $extport = "";
- unset($extport);
- if(alias_expand($rule['external-port']))
- $extport[0] = alias_expand_value($rule['external-port']);
- else
- $extport = explode("-", $rule['external-port']);
-
- /* if item is an alias, expand */
- if(alias_expand($rule['local-port']))
- $localport = "";
- else
- $localport = " port {$rule['local-port']}";
-
- $target = alias_expand_host($rule['target']);
-
- if (!$target) {
- $natrules .= "# Unresolvable alias {$rule['target']}\n";
- continue; /* unresolvable alias */
- }
-
- # use tables for aliases in rdr
- if (!is_ipaddr($target)) {
- $natrules .= "table <{$rule['target']}> { $target }\n";
- $target = "<{$rule['target']}>";
- }
-
- if ($rule['external-address'])
- if($rule['external-address'] <> "any")
- $extaddr = $rule['external-address'] . "/32";
- else
- $extaddr = $rule['external-address'];
- else
- $extaddr = get_current_wan_address($rule['interface']);
-
- if (!$rule['interface'] || ($rule['interface'] == "wan"))
- $natif = $wanif;
- else if($rule['interface'] == "\$pptp")
- $natif = "pptp";
- else if($rule['interface'] == "\$pppoe")
- $natif = "pppoe";
- else
- $natif = $config['interfaces'][$rule['interface']]['if'];
-
- $lanif = $lancfg['if'];
-
- /*
- * Expand aliases
- * XXX: may want to integrate this into pf macros
- */
- if(alias_expand($target))
- $target = alias_expand($target);
- if(alias_expand($extaddr))
- $extaddr = alias_expand($extaddr);
-
- /*
- * If FTP Proxy Helper is enabled and the
- * operator has requested a port forward to
- * a ftp server then launch a helper
- */
- $dontinstallrdr = false;
- if($target <> "") {
- $external_address = $rule['external-address'];
- if($extport[0] == "21" and !isset($config['interfaces'][strtolower($rule['interface'])]['disableftpproxy'])) {
- $helpers = exec("/bin/ps awux | grep \"{$target} -b {$external_address}\" | grep -v grep");
- if(!$helpers) {
- if($external_address == "")
- $external_address = find_interface_ip(get_real_wan_interface());
- /* install a pftpx helper, do not set a rule. also use the delay filter configure run
- * routines because if this is the first bootup the filter is not completely configured
- * and thus pf is not fully running. otherwise we end up with: pftpx: pf is disabled
- */
- if(isset($config['shaper']['enable'])) {
- if(isset($config['ezshaper']['step5']['p2pcatchall'])) {
- $shaper_queue = "-q qP2PUp ";
- } else {
- $upq = "q" . convert_friendly_interface_to_friendly_descr($config['ezshaper']['step2']['outside_int']);
- $shaper_queue = "-q {$upq}def ";
- }
- } else {
- $shaper_queue = "";
- }
- $after_filter_configure_run[] = "/usr/local/sbin/pftpx {$shaper_queue}-f {$target} -b {$external_address} -c 21 -g 21";
- }
- $dontinstallrdr = true;
- }
- }
-
- if($extaddr == "")
- $dontinstallrdr = true;
-
- $rdr_on = convert_real_interface_to_friendly_descr($rule['interface']);
-
- if($dontinstallrdr == false) {
- /* is rule a port range? */
- if ((!$extport[1]) || ($extport[0] == $extport[1])) {
-
- switch ($rule['protocol']) {
- case "tcp/udp":
- if($natif) {
- if($rule['external-port'] <> $rule['local-port'])
- $natrules .= "{$nordr}rdr on $natif proto { tcp udp } from any to {$extaddr} port { {$extport[0]} } -> {$target}{$localport}";
- else
- $natrules .= "{$nordr}rdr on $natif proto { tcp udp } from any to {$extaddr} port { {$extport[0]} } -> {$target}";
- }
- break;
- case "udp":
- case "tcp":
- if($extport[0])
- if($natif) {
- if($rule['external-port'] <> $rule['local-port'])
- $natrules .= "rdr on $natif proto {$rule['protocol']} from any to {$extaddr} port { {$extport[0]} } -> {$target}{$localport}";
- else
- $natrules .= "rdr on $natif proto {$rule['protocol']} from any to {$extaddr} port { {$extport[0]} } -> {$target}";
- }
- else
- if($natif)
- $natrules .= "rdr on $natif proto {$rule['protocol']} from any to {$extaddr} -> {$target}{$localport}";
- break;
- default:
- $natrules .= "rdr on $natif proto {$rule['protocol']} from any to {$extaddr} -> {$target}";
- break;
- }
- } else {
- switch ($rule['protocol']) {
- case "tcp/udp":
- if($natif)
- $natrules .= "{$nordr}rdr on $natif proto { tcp udp } from any to {$extaddr} port {$extport[0]}:{$extport[1]} -> {$target}{$localport}:*";
- break;
- case "udp":
- case "tcp":
- if($natif)
- $natrules .= "{$nordr}rdr on $natif proto {$rule['protocol']} from any to {$extaddr} port {$extport[0]}:{$extport[1]} -> {$target}{$localport}:*";
- break;
- default:
- if($natif)
- $natrules .= "{$nordr}rdr on $natif proto {$rule['protocol']} from any to {$extaddr} -> {$target}";
- }
- }
- }
-
- /* does this rule redirect back to a internal host?
- * if so, add some extra goo to help this work.
- */
- $rule_friendly_if = convert_friendly_interface_to_real_interface_name($rule['interface']);
- $rule_interface_ip = find_interface_ip($rule_friendly_if);
- $rule_interface_subnet = $config['interfaces'][$rule['interface']]['subnet'];
- $rule_subnet = gen_subnet($rule_interface_ip, $rule_interface_subnet);
- if($rule['external-address'] == "any" and $rule['interface'] == "lan") {
- $natrules .= "\n";
- if($rule_friendly_if)
- $natrules .= "no nat on {$rule_friendly_if} proto tcp from {$rule_friendly_if} to {$rule_subnet}/{$rule_interface_subnet}\n";
- if($rule_friendly_if)
- $natrules .= "nat on {$rule_friendly_if} proto tcp from {$rule_subnet}/{$rule_interface_subnet} to {$target} port {$extport[0]} -> {$rule_friendly_if}\n";
- }
-
- if(!isset($config['system']['disablenatreflection'])) {
-
- update_filter_reload_status("Setting up reflection");
-
- $natrules .= "\n# Reflection redirects\n";
- foreach ($iflist as $ifent => $ifname) {
-
- /* do not process interfaces with gateways*/
- if($config['interfaces'][$ifname]['gateway'] <> "")
- continue;
-
- /* do not process interfaces that will end up with gateways */
- if($config['interfaces'][$ifname]['ipaddr'] == "dhcp" or
- $config['interfaces'][$ifname]['ipaddr'] == "bigpond" or
- $config['interfaces'][$ifname]['ipaddr'] == "pppoe" or
- $config['interfaces'][$ifname]['ipaddr'] == "pptp")
- continue;
-
- $ifname_real = convert_friendly_interface_to_real_interface_name($ifname);
-
- if($extport[1])
- $range_end = ($extport[1]);
- else
- $range_end = ($extport[0]);
-
- $range_end++;
-
- if($rule['local-port'])
- $lrange_start = $rule['local-port'];
-
- if($range_end - $extport[0] > 500) {
- $range_end = $extport[0]+1;
- log_error("Not installing nat reflection rules for a port range > 500");
- } else {
- /* only install reflection rules for < 19991 items */
- if($starting_localhost_port < 19991) {
- $loc_pt = $lrange_start;
- for($x=$extport[0]; $x<$range_end; $x++) {
-
- $xxx = $x;
-
- /* do not install reflection rules for FTP. This simply
- * opens up pandoras box.
- */
- if($xxx == "21")
- continue;
-
- update_filter_reload_status("Creating reflection rule for {$rule['descr']}...");
-
- $ifname_real = convert_friendly_interface_to_friendly_descr(strtolower($ifname));
-
- if($config['system']['reflectiontimeout'])
- $reflectiontimeout = $config['system']['reflectiontimeout'];
- else
- $reflectiontimeout = "2000";
-
- switch($rule['protocol']) {
-
- case "tcp/udp":
- $protocol = "{ tcp udp }";
- $toadd_array = array();
- if(is_alias($loc_pt)) {
- $loc_pt_translated = alias_expand_value($loc_pt);
- if(stristr($loc_pt_translated, " ")) {
- /* XXX: we should deal with multiple ports */
- $loc_pt_translated_split = split(" ", $loc_pt_translated);
- foreach($loc_pt_translated_split as $lpts)
- $toadd_array[] = $lpts;
- } else {
- $toadd_array[] = $loc_pt_translated;
- }
- } else {
- $loc_pt_translated = $loc_pt;
- $toadd_array[] = $loc_pt_translated;
- }
- foreach($toadd_array as $tda){
- fwrite($inetd_fd, "{$starting_localhost_port}\tstream\ttcp/udp\tnowait/0\tnobody\t/usr/bin/nc nc -w {$reflectiontimeout} {$target} {$tda}\n");
- if($ifname_real)
- $natrules .= "rdr on \${$ifname_real} proto tcp from any to {$extaddr} port { {$xxx} } -> 127.0.0.1 port {$starting_localhost_port}\n";
- $starting_localhost_port++;
- fwrite($inetd_fd, "{$starting_localhost_port}\tstream\ttcp/udp\tnowait/0\tnobody\t/usr/bin/nc nc -u -w {$reflectiontimeout} {$target} {$tda}\n");
- if($ifname_real)
- $natrules .= "rdr on \${$ifname_real} proto udp from any to {$extaddr} port { {$xxx} } -> 127.0.0.1 port {$starting_localhost_port}\n";
- $xxx++;
- $starting_localhost_port++;
- }
- break;
- case "tcp":
- case "udp":
- $protocol = $rule['protocol'];
- $toadd_array = array();
- if(is_alias($loc_pt)) {
- $loc_pt_translated = alias_expand_value($loc_pt);
- if(stristr($loc_pt_translated, " ")) {
- /* XXX: we should deal with multiple ports */
- $loc_pt_translated_split = split(" ", $loc_pt_translated);
- foreach($loc_pt_translated_split as $lpts)
- $toadd_array[] = $lpts;
- } else {
- $toadd_array[] = $loc_pt_translated;
- }
- } else {
- $loc_pt_translated = $loc_pt;
- $toadd_array[] = $loc_pt_translated;
- }
- foreach($toadd_array as $tda){
- if($protocol == "udp")
- $dash_u = "-u ";
- else
- $dash_u = "";
- if($config['system']['reflectiontimeout'])
- $reflectiontimeout = $config['system']['reflectiontimeout'];
- else
- $reflectiontimeout = "2000";
- fwrite($inetd_fd, "{$starting_localhost_port}\tstream\t{$protocol}\tnowait/0\tnobody\t/usr/bin/nc nc {$dash_u}-w {$reflectiontimeout} {$target} {$tda}\n");
- if($ifname_real)
- $natrules .= "rdr on \${$ifname_real} proto {$protocol} from any to {$extaddr} port { {$xxx} } -> 127.0.0.1 port {$starting_localhost_port}\n";
- $xxx++;
- $starting_localhost_port++;
- }
- break;
- default:
- break;
- }
- $loc_pt++;
- if($starting_localhost_port > 19990) {
- log_error("Not installing nat reflection rules. Maximum 1,000 reached.");
- $x = $range_end+1;
- }
- }
- }
- }
-
- }
-
- }
-
- $natrules .= "\n";
- }
-
- if(!isset($config['system']['disablenatreflection'])) {
- fclose($inetd_fd);
- $helpers = trim(exec("/bin/ps ax | /usr/bin/grep inetd | /usr/bin/grep -v grep | /usr/bin/grep 127"));
- if(!$helpers)
- mwexec("/usr/sbin/inetd -wW -R 0 -a 127.0.0.1 /var/etc/inetd.conf");
- else
- mwexec("/usr/bin/killall -HUP inetd", true);
-
- }
- }
-
- if ($pptpdcfg['mode'] && $pptpdcfg['mode'] != "off") {
-
- if ($pptpdcfg['mode'] == "server")
- $pptpdtarget = "127.0.0.1";
- else if ($pptpdcfg['mode'] == "redir")
- $pptpdtarget = $pptpdcfg['redir'];
-
- if ($pptpdcfg['mode'] == "redir") {
-
- $natrules .= <<<EOD
-
-# PPTP
-rdr on \$wan proto gre from any to any -> $pptpdtarget
-rdr on \$wan proto tcp from any to any port 1723 -> $pptpdtarget
-
-EOD;
- }
- }
-
- if (is_package_installed('squid') && file_exists('/usr/local/pkg/squid.inc')) {
- require_once('squid.inc');
- $natrules .= squid_generate_rules('nat');
- }
-
- if (is_package_installed('clamav') && file_exists('/usr/local/pkg/clamav.inc')) {
- require_once('clamav.inc');
- $natrules .= clamav_generate_rules('nat');
- }
-
- if (is_package_installed('frickin') && file_exists('/usr/local/pkg/frickin.inc')) {
- require_once ('frickin.inc');
- $natrules .= frickin_generate_rules('nat');
- }
-
- if (is_package_installed('siproxd') && file_exists('/usr/local/pkg/sipproxd.inc')) {
- require_once('sipproxd.inc');
- $natrules .= siproxd_generate_rules('nat');
- }
-
- $natrules .= process_carp_nat_rules();
-
- $natrules .= "# IMSpector rdr anchor\n";
- $natrules .= "rdr-anchor \"imspector\"\n";
-
- $natrules .= "# UPnPd rdr anchor\n";
- $natrules .= "rdr-anchor \"miniupnpd\"\n";
-
- return $natrules;
-}
-
-function run_command_return_string($cmd) {
- global $config;
- if(isset($config['system']['developerspew'])) {
- $mt = microtime();
- echo "generate_user_filter_rule() being called $mt\n";
- }
-
- $fd = popen($cmd, "r");
- while(!feof($fd)) {
- $tmp .= fread($fd,49);
- }
- fclose($fd);
- return $tmp;
-}
-
-function generate_user_filter_rule_arr($rule, $ngcounter) {
- global $config;
- update_filter_reload_status("Creating filter rules {$rule['descr']} ...");
- if(isset($config['system']['developerspew'])) {
- $mt = microtime();
- echo "generate_user_filter_rule() being called $mt\n";
- }
- $ret = array();
- $line = generate_user_filter_rule($rule, $ngcounter);
- $ret['rule'] = $line;
- $ret['interface'] = $rule['interface'];
- if ($line[0] != '#') {
- if($rule['descr'] != "" and $line != "")
- $ret['descr'] = "label \"USER_RULE: " . str_replace('"', '', $rule['descr']) . "\"";
- else
- $ret['descr'] = "label \"USER_RULE\"";
- }
- $ret['ackq'] = get_ack_queue($rule['interface']);
-
- return $ret;
-}
-
-function generate_user_filter_rule($rule, $ngcounter) {
- global $config, $g;
- global $table_cache;
- global $schedule_enabled;
-
- if($config['schedules']) {
- foreach($config['schedules']['schedule'] as $sched) {
- $schedule_enabled = true;
- break;
- }
- }
-
- if(isset($config['system']['developerspew'])) {
- $mt = microtime();
- echo "generate_user_filter_rule() being called $mt\n";
- }
-
- /* Setup cache array if not already existing */
- if (!isset($table_cache)) {
- if ($g['debug'])
- echo "Creating table cache\n";
- $table_cache = array();
- }
-
- update_filter_reload_status("Creating filter rules {$rule['descr']} ...");
-
- $wancfg = $config['interfaces']['wan'];
- $lancfg = $config['interfaces']['lan'];
- $pptpdcfg = $config['pptpd'];
- $pppoecfg = $config['pppoe'];
-
- $lanif = $lancfg['if'];
- $wanif = get_real_wan_interface();
-
- $lanip = $lancfg['ipaddr'];
- $lansa = gen_subnet($lancfg['ipaddr'], $lancfg['subnet']);
- $lansn = $lancfg['subnet'];
-
- $int = "";
-
- $optcfg = array();
- generate_optcfg_array($optcfg);
-
- $curwanip = get_current_wan_address();
-
- /* don't include disabled rules */
- if (isset($rule['disabled'])) {
- return "# rule " . $rule['descr'] . " disabled ";
- }
-
- $pptpdcfg = $config['pptpd'];
- $pppoecfg = $config['pppoe'];
-
- if ($pptpdcfg['mode'] == "server") {
- $pptpip = $pptpdcfg['localip'];
- $pptpsa = $pptpdcfg['remoteip'];
- $pptpsn = $g['pptp_subnet'];
- if($config['pptp']['pptp_subnet'] <> "")
- $pptpsn = $config['pptp']['pptp_subnet'];
- }
-
- if ($pppoecfg['mode'] == "server") {
- $pppoeip = $pppoecfg['localip'];
- $pppoesa = $pppoecfg['remoteip'];
- $pppoesn = $g['pppoe_subnet'];
- if($config['pppoe']['pppoe_subnet'] <> "")
- $pppoesn = $config['pppoe']['pppoe_subnet'];
- }
-
- /* does the rule deal with a PPTP interface? */
- if ($rule['interface'] == "pptp") {
- if ($pptpdcfg['mode'] != "server")
- return "";
- $nif = $g['n_pptp_units'];
- if($config['pptp']['n_pptp_units'] <> "")
- $nif = $config['pptp']['n_pptp_units'];
- $ispptp = true;
- } else if($rule['interface'] == "pppoe") {
- if ($pppoecfg['mode'] != "server") {
- return " # Error creating pppoe rule";
- }
- $nif = $g['n_pppoe_units'];
- if($config['pppoe']['n_pppoe_units'] <> "")
- $nif = $config['pppoe']['n_pppoe_units'];
- $ispppoe = true;
- } else if(!isset($rule['interface'])) {
- return '# Interface empty for rule: '.$rule['descr'];
- } else {
-
- /* Check to see if the interface is opt and in our opt list */
- if (strstr($rule['interface'], "opt")) {
- if (!array_key_exists($rule['interface'], $optcfg)) {
- $item = "";
- foreach($optcfg as $oc) $item .= $oc['if'];
- return "# {$real_int} {$item} {$rule['interface']} array key does not exist for " . $rule['descr'];
- }
- }
-
- $nif = 1;
- $ispptp = false;
- $ispppoe = false;
- }
-
- if ($pptpdcfg['mode'] != "server") {
- if (($rule['source']['network'] == "pptp") ||
- ($rule['destination']['network'] == "pptp")) {
- return "# source network or destination network == pptp on " . $rule['descr'];
- }
- }
-
- if ($rule['source']['network'] && strstr($rule['source']['network'], "opt")) {
- if (!array_key_exists($rule['source']['network'], $optcfg)) {
- $optmatch = "";
- if(preg_match("/opt([0-999])/", $rule['source']['network'], $optmatch)) {
- $real_opt_int = convert_friendly_interface_to_real_interface_name("opt" . $optmatch[1]);
- $opt_ip = find_interface_ip($real_opt_int);
- if(!$opt_ip)
- return "# unresolvable optarray $real_opt_int - $optmatch[0] - $opt_ip";
- } else {
- return "# {$rule['source']['network']} !array_key_exists source network " . $rule['descr'];
- }
- }
- }
- if ($rule['destination']['network'] && strstr($rule['destination']['network'], "opt")) {
- if (!array_key_exists($rule['destination']['network'], $optcfg)) {
- if(preg_match("/opt([0-999])/", $rule['destination']['network'], $optmatch)) {
- $real_opt_int = convert_friendly_interface_to_real_interface_name("opt" . $optmatch[1]);
- $opt_ip = find_interface_ip($real_opt_int);
- if(!$opt_ip)
- return "# unresolvable oparray $real_opt_int - $optmatch[0] - $opt_ip";
- } else {
- return "# {$item} {$rule['destination']['network']} !array_key_exists dest network " . $rule['descr'];
- }
- }
- }
-
- /* check for unresolvable aliases */
- if ($rule['source']['address'] && !alias_expand($rule['source']['address'])) {
- file_notice("Filter_Reload", "# unresolvable source aliases {$rule['descr']}");
- return "# unresolvable source aliases {$rule['descr']}";
- }
- if ($rule['destination']['address'] && !alias_expand($rule['destination']['address'])) {
- file_notice("Filter_Reload", "# unresolvable dest aliases {$rule['descr']}");
- return "# unresolvable dest aliases {$rule['descr']}";
- }
-
- $ifdescrs = array();
- for ($i = 1; isset($config['interfaces']['opt' . $i]); $i++)
- $ifdescrs[] = "opt" . $i;
-
- update_filter_reload_status("Setting up pass/block rules");
-
- for ($iif = 0; $iif < $nif; $iif++) {
-
- $type = $rule['type'];
-
-
- if ($type != "pass" && $type != "block" && $type != "reject") {
- /* default (for older rules) is pass */
- $type = "pass";
- }
-
- if ($type == "reject") {
- /* special reject packet */
- $aline['type'] = "block return";
- } else {
- $aline['type'] = $type;
- }
-
- /* ensure the direction is in */
- $aline['direction'] = " in ";
-
- if (isset($rule['log']))
- $aline['log'] = "log ";
-
- $aline['quick'] = "quick ";
-
- if ($ispptp) {
- $aline['interface'] = "on \$pptp ";
- } else if ($ispppoe) {
- $aline['interface'] = "on \$pppoe ";
- } else {
- // translate wan, man, lan, opt to real interface.
- $interface = $rule['interface'];
- $temp = filter_get_opt_interface_descr($interface);
- if($temp <> "") $interface = $temp;
- if(isset($rule['destination']['address'])) {
- $canadd = 0; // XXX: billm - eh? this is a nice little noop
- /* because pf will not allow a interface for proxyARP
- type traffic lets check if its in use and if so leave
- off the interface */
- if(is_one_to_one_or_server_nat_rule($rule['destination']['address']))
- $canadd = 0;
- }
- if($canadd == 0)
- $aline['interface'] = "on \$" . convert_real_interface_to_friendly_descr($rule['interface']) . " ";
- }
-
-
- /* set the gateway interface */
- $ri = filter_translate_type_to_real_interface($rule['interface']);
-
- update_filter_reload_status("Setting up pass/block rules {$rule['descr']}");
-
- /*
- * check to see if /tmp/{${ri}_router exists. This file
- * is created by dhclient for 2nd wan interfaces, etc.
- * else get gateway from the interface config
- */
- if(file_exists("{$g['tmp_path']}/{$ri}_router")) {
- $rg = file_get_contents("{$g['tmp_path']}/{$ri}_router");
- $rg = rtrim($rg);
- } elseif ($config['interfaces'][$rule['interface']]['gateway'] <> "") {
- $rg = $config['interfaces'][$rule['interface']]['gateway'];
- }
-
- /* do not process reply-to for gateway'd rules */
- if(($rule['gateway'] == "") and ($ri != "") and ($rg != "")) {
- $aline['reply'] = "reply-to (" . $ri . " " . $rg . ") ";
- }
-
- /* if user has selected a custom gateway, lets work with it */
- if($rule['gateway'] <> "") {
- $foundlb = 0;
- $routeto = " route-to { ";
- if(is_array($config['load_balancer']['lbpool'])) {
- foreach($config['load_balancer']['lbpool'] as $lb) {
- update_filter_reload_status("Creating load balancing item...");
- if($lb['name'] == $rule['gateway']) {
- $gateway = $rule['gateway'];
- /*
- * is $gateway a interface name?
- * if so, lets find out the gateway address
- * from /tmp/router_bleh.router
- */
- if(in_array($gateway, $ifdescrs)==true) {
- if(is_file("{$g['tmp_path']}/{$gateway}_router")) {
- $return_gateway = file_get_contents("{$g['tmp_path']}/{$gateway}_router");
- } else {
- log_error("Could not find {$g['tmp_path']}/{$gateway}_router. Needed for dhcp gateway information");
- continue;
- }
- }
- /* if /tmp/$lbname.pool exists then read in our gateway hints from slbd */
- if(file_exists("{$g['tmp_path']}/{$lb['name']}.pool")) {
- $lbs_tmp = split("\n", file_get_contents("{$g['tmp_path']}/{$lb['name']}.pool"));
- $lbs = array();
- /* process the entire file to prevent empty lines */
- foreach($lbs_tmp as $lb_tmp) {
- if(is_ipaddr($lb_tmp)) {
- $lbs[] = $lb_tmp;
- }
- }
- $lbs_count = count($lbs);
- if($g['debug'])
- log_error("We found $lbs_count valid entries in status file {$g['tmp_path']}/{$lb['name']}.pool");
-
- if(count($lbs) == 0) {
- if($g['debug'])
- log_error("There are no servers found in the status file, using XML config settings!");
- foreach ($lb['servers'] as $lbsvr) {
- $lbsvr_split = split("\|", $lbsvr);
- $lbs[] = $lbsvr_split[1];
- }
- }
- } else {
- if($g['debug'])
- log_error("There is no server status file, using XML config settings!");
- $lbs = array();
- foreach ($lb['servers'] as $lbsvr) {
- $lbsvr_split = split("\|", $lbsvr);
- $lbs[] = $lbsvr_split[1];
- }
- }
- /* If we want failover we only return the first (top) server from the list
- * and work our way down from there. This way we order the failover order.
- */
- if($lb['behaviour'] == "failover") {
- $firstsrv = $lbs[0];
- $lbs = array("$firstsrv");
- }
-
- /* create server/gateway gateway/monitor array */
- $l = 0;
- $lbconfig = array();
- foreach ($lb['servers'] as $lbsvr) {
- $lbsvr_split=split("\|", $lbsvr);
- $lbconfig['gateway'][$l] = $lbsvr_split[0];
- $lbconfig['monitor'][$l] = $lbsvr_split[1];
- $l++;
- }
- $lbconfig_count = count($lbconfig['gateway']);
-
- $l = 0;
- while($l < $lbconfig_count) {
- /* iterate through $lbs and setup items accordingly */
- foreach($lbs as $server) {
- if ($server == "")
- continue;
- unset($gateway, $int);
- if ($lbconfig['monitor'][$l] == $server) {
- /* determine interface gateway */
- if(is_ipaddr($lbconfig['gateway'][$l])) {
- $int = guess_interface_from_ip($lbconfig['gateway'][$l]);
- $gateway = $lbconfig['gateway'][$l];
- log_error("SLBD pool {$lb['name']} is old style. Please recreate.");
- } else if(interface_has_gateway($lbconfig['gateway'][$l])) {
- $int = convert_friendly_interface_to_real_interface_name($lbconfig['gateway'][$l]);
- $gateway = get_interface_gateway($lbconfig['gateway'][$l]);
- }
- if(($int <> "") && ($gateway <> "")) {
- if($g['debug'])
- log_error("Setting up route with {$lbconfig['gateway'][$l]} om $int for monitor {$lbconfig['monitor'][$l]} on gateway $gateway");
- if($foundlb == 1)
- $routeto .= ", ";
- $routeto .= "( {$int} {$gateway} ) ";
- $foundlb = 1;
- }
- /* we have a match, go forth and try the next LB item so we don't setup multiples incorrectly */
- $l++;
- continue;
- }
- }
- $l++;
- }
- /* If we want failover just use route-to else round-robin */
- if($lb['behaviour'] == "failover") {
- $routeto .= "} ";
- } else {
- $routeto .= "} round-robin ";
- if(isset($config['system']['lb_use_sticky']))
- $routeto .= " sticky-address ";
- }
- }
- }
- /* Add the load balanced gateways */
- if ($foundlb == 1)
- $aline['route'] = $routeto;
- }
- /* we're not using load balancing, just setup gateway */
- if($foundlb == 0) {
- $gateway = $rule['gateway'];
- /*
- * is $gateway a interface name?
- * if so, lets find out the gateway address
- * from /tmp/router_bleh.router
- */
- if(in_array($gateway, $ifdescrs)==true) {
- $int=filter_opt_interface_to_real($gateway);
- if(is_file("{$g['tmp_path']}/{$int}_router")) {
- $gatewayip = file_get_contents("{$g['tmp_path']}/{$int}_router");
- $gatewayip = rtrim($gatewayip);
- if (is_ipaddr($gatewayip)) {
- if($int)
- $aline['route'] = " route-to ( {$int} {$gatewayip} ) ";
- log_error("An error occurred while trying to determine the real interface name for the gateway $gateway");
- }
- } else {
- log_error("Could not find {$g['tmp_path']}/{$int}_router. Needed for dhcp gateway information");
- continue;
- }
- } else {
- /* user picked a real gateway ip */
- if(is_ipaddr($rule['gateway'])) {
- $gatewayip = $rule['gateway'];
- $int = guess_interface_from_ip($gatewayip);
- $aline['route'] = " route-to ( " . guess_interface_from_ip($rule['gateway']) . " {$rule['gateway']} ) ";
- }
- }
- }
- }
-
- if (isset($rule['protocol'])) {
- if($rule['protocol'] == "tcp/udp")
- $aline['prot'] = "proto { tcp udp } ";
- elseif($rule['protocol'] == "icmp")
- $aline['prot'] = "inet proto icmp ";
- else
- $aline['prot'] = "proto {$rule['protocol']} ";
- } else {
- if($rule['source']['port'] <> "" || $rule['destination']['port'] <> "") {
- $aline['prot'] = "proto tcp ";
- }
- }
-
- update_filter_reload_status("Creating rule {$rule['descr']}");
-
- /* source address */
- if (isset($rule['source']['any'])) {
- $src = "any";
- } else if ($rule['source']['network']) {
-
- if (strstr($rule['source']['network'], "opt")) {
- $src = $optcfg[$rule['source']['network']]['sa'] . "/" .
- $optcfg[$rule['source']['network']]['sn'];
- if (isset($rule['source']['not'])) $src = " !{$src}";
- /* check for opt$NUMip here */
- $matches = "";
- if (preg_match("/opt([0-9999])ip/", $rule['source']['network'], $matches)) {
- $optnum = $matches[1];
- $real_int = convert_friendly_interface_to_real_interface_name("opt{$optnum}");
- $src = find_interface_ip($real_int);
- }
- } else {
- switch ($rule['source']['network']) {
- case 'wanip':
- $src = $curwanip;
- break;
- case 'lanip':
- $src = $lanip;
- break;
- case 'lan':
- $src = "{$lansa}/{$lansn}";
- break;
- case 'pptp':
- $src = "{$pptpsa}/{$pptpsn}";
- break;
- case 'pppoe':
- $src = "{$pppoesa}/{$pppoesn}";
- break;
- }
- if (isset($rule['source']['not'])) $src = "!{$src}";
- }
- } else if ($rule['source']['address']) {
- $expsrc = alias_expand($rule['source']['address']);
-
- if (isset($rule['source']['not']))
- $not = "!";
- else
- $not = "";
-
- if (stristr($expsrc, "$")) {
- if($not) {
- $src = "{";
- foreach(preg_split("/[\s]+/", alias_expand_value($rule['source']['address'])) as $item) {
- if($item != "") {
- $src .= " {$not}{$item}";
- }
- }
- /* added support for tables */
- $src .= " 0/0 }";
- $src_table = "<not" . $rule['source']['address'] . ">";
- }
- else {
- $src = "{ {$not} " . alias_expand_value($rule['source']['address']) . " } ";
- $src_table = "<" . $rule['source']['address'] . ">";
- }
-
- /* support for tables */
- $src_table_line = "table $src_table {$src}\n";
- $src = $src_table;
- }
- else
- $src = "{ {$not} {$expsrc} }";
- }
-
- if (!$src || ($src == "/")) {
- return "# at the break!";
- }
-
- $aline['src'] = "from $src ";
-
- if (in_array($rule['protocol'], array("tcp","udp","tcp/udp"))) {
-
- if ($rule['source']['port']) {
- $srcport = explode("-", $rule['source']['port']);
- if(alias_expand($srcport[0]))
- $srcporta = alias_expand($srcport[0]);
- else
- $srcporta = $srcport[0];
- if ((!$srcport[1]) || ($srcport[0] == $srcport[1])) {
- if(alias_expand($srcport[0]))
- $aline['srcport'] = "port {$srcporta} ";
- else
- $aline['srcport'] = "port = {$srcporta} ";
- } else if (($srcport[0] == 1) && ($srcport[1] == 65535)) {
- /* no need for a port statement here */
- } else if ($srcport[1] == 65535) {
- $aline['srcport'] = "port >= {$srcport[0]} ";
- } else if ($srcport[0] == 1) {
- $aline['srcport']= "port <= {$srcport[1]} ";
- } else {
- $srcport[0]--;
- $srcport[1]++;
- $aline['srcport'] = "port {$srcport[0]} >< {$srcport[1]} ";
- }
- }
- /* OS signatures */
- if (($rule['protocol'] == "tcp") && ($rule['os'] <> ""))
- $aline['os'] = "os {$rule['os']} ";
-
- }
-
- /* destination address */
- if (isset($rule['destination']['any'])) {
- $dst = "any";
- } else if ($rule['destination']['network']) {
-
- if (strstr($rule['destination']['network'], "opt")) {
- $dst = $optcfg[$rule['destination']['network']]['sa'] . "/" .
- $optcfg[$rule['destination']['network']]['sn'];
- /* check for opt$NUMip here */
- $matches = "";
- if (preg_match("/opt([0-9999])ip/", $rule['destination']['network'], $matches)) {
- $optnum = $matches[1];
- $real_int = convert_friendly_interface_to_real_interface_name("opt{$optnum}");
- $dst = find_interface_ip($real_int);
- }
- if (isset($rule['destination']['not'])) $dst = " !{$dst}";
- } else {
- switch ($rule['destination']['network']) {
- case 'wanip':
- $dst = $curwanip;
- break;
- case 'lanip':
- $dst = $lanip;
- break;
- case 'lan':
- $dst = "{$lansa}/{$lansn}";
- break;
- case 'pptp':
- $dst = "{$pptpsa}/{$pptpsn}";
- break;
- case 'pppoe':
- $dst = "{$ppoesa}/{$pppoesn}";
- break;
- }
- if (isset($rule['destination']['not'])) $dst = " !{$dst}";
- }
- } else if ($rule['destination']['address']) {
- $expdst = alias_expand($rule['destination']['address']);
-
- if (isset($rule['destination']['not']))
- $not = "!";
- else
- $not = "";
-
- if (stristr($expdst, "$")) {
- if($not) {
- $dst = "{";
- foreach(preg_split("/[\s]+/", alias_expand_value($rule['destination']['address'])) as $item) {
- if($item != "") {
- $dst .= " {$not}{$item}";
- }
- }
- /* added support for tables */
- $dst .= " 0/0 }";
- $dst_table = "<not" . $rule['destination']['address'] . ">";
- }
- else {
- $dst = "{ {$not} " . alias_expand_value($rule['destination']['address']) . " } ";
- $dst_table = "<" . $rule['destination']['address'] . ">";
- }
-
- /* support for tables */
- $dst_table_line = "table $dst_table {$dst}\n";
- $dst = $dst_table;
- }
- else
- $dst = "{ {$not} {$expdst} }";
- }
-
- if (!$dst || ($dst == "/")) {
- return "# returning at dst $dst == \"/\"";
- }
-
- $aline['dst'] = "to $dst ";
-
- if (in_array($rule['protocol'], array("tcp","udp","tcp/udp"))) {
-
- if ($rule['destination']['port']) {
- $dstport = explode("-", $rule['destination']['port']);
- if(alias_expand($dstport[0]))
- $dstporta = alias_expand($dstport[0]);
- else
- $dstporta = $dstport[0];
- if ((!$dstport[1]) || ($dstport[0] == $dstport[1])) {
- if(alias_expand($dstport[0]))
- $aline['dstport'] = "port {$dstporta} ";
- else
- $aline['dstport'] = "port = {$dstporta} ";
- } else if (($dstport[0] == 1) && ($dstport[1] == 65535)) {
- /* no need for a port statement here */
- } else if ($dstport[1] == 65535) {
- $aline['dstport'] = "port >= {$dstport[0]} ";
- } else if ($dstport[0] == 1) {
- $aline['dstport'] = "port <= {$dstport[1]} ";
- } else {
- $dstport[0]--;
- $dstport[1]++;
- $aline['dstport'] = "port {$dstport[0]} >< {$dstport[1]} ";
- }
- }
- }
-
- if (($rule['protocol'] == "icmp") && $rule['icmptype']) {
- $aline['icmp-type'] = "icmp-type {$rule['icmptype']} ";
- }
-
- if ($type == "pass") {
-
- if( isset($rule['source-track']) or isset($rule['max-src-nodes']) or isset($rule['max-src-states']) )
- if($rule['protocol'] == "tcp")
- $aline['flags'] = "flags S/SA ";
- /*
- # keep state
- works with TCP, UDP, and ICMP.
- # modulate state
- works only with TCP. pfSense will generate strong Initial Sequence Numbers (ISNs)
- for packets matching this rule.
- # synproxy state
- proxies incoming TCP connections to help protect servers from spoofed TCP SYN floods.
- This option includes the functionality of keep state and modulate state combined.
- # none
- do not use state mechanisms to keep track. this is only useful if your doing advanced
- queueing in certain situations. please check the faq.
- */
- $noadvoptions = false;
- if(isset($rule['statetype']) && $rule['statetype'] <> "") {
- switch($rule['statetype']) {
- case "none":
- $noadvoptions = true;
- $aline['flags'] = "no state ";
- break;
- case "modulate state":
- case "synproxy state":
- if($rule['protocol'] == "tcp")
- $aline['flags'] = "{$rule['statetype']} ";
- break;
- default:
- $aline['flags'] = "{$rule['statetype']} ";
- }
- } else {
- $aline['flags'] = "keep state ";
- }
- if($noadvoptions == false)
- if( isset($rule['source-track']) and $rule['source-track'] <> "" or
- isset($rule['max-src-nodes']) and $rule['max-src-nodes'] <> "" or
- isset($rule['max-src-conn-rate']) and $rule['max-src-conn-rate'] <> "" or
- isset($rule['max-src-conn-rates']) and $rule['max-src-conn-rates'] <> "" or
- isset($rule['max-src-states']) and $rule['max-src-states'] <> "" or
- isset($rule['statetimeout']) and $rule['statetimeout'] <> "") {
- $aline['flags'] .= "( ";
- if(isset($rule['source-track']) and $rule['source-track'] <> "")
- $aline['flags'] .= "source-track rule ";
- if(isset($rule['max-src-nodes']) and $rule['max-src-nodes'] <> "")
- $aline['flags'] .= "max-src-nodes " . $rule['max-src-nodes'] . " ";
- if(isset($rule['max-src-states']) and $rule['max-src-states'] <> "")
- $aline['flags'] .= "max-src-states " . $rule['max-src-states'] . " ";
- if(isset($rule['statetimeout']) and $rule['statetimeout'] <> "")
- $aline['flags'] .= "tcp.established " . $rule['statetimeout'] . " ";
- if(isset($rule['max-src-conn-rate']) and $rule['max-src-conn-rate'] <> ""
- and isset($rule['max-src-conn-rates']) and $rule['max-src-conn-rates'] <> "") {
- $aline['flags'] .= "max-src-conn-rate " . $rule['max-src-conn-rate'] . " ";
- $aline['flags'] .= "/" . $rule['max-src-conn-rates'] . ", overload <virusprot> flush global ";
- }
- $aline['flags'] .= " ) ";
- }
- }
- if ($type == "reject" && $rule['protocol'] == "tcp") {
- /* special reject packet */
- $aline['flags'] .= "flags S/SA ";
- }
- }
-
- /* cache entries */
- if (isset($src_table))
- if (isset($table_cache[$src_table])) {
- if ($g['debug'])
- echo "{$src_table} found in cache\n";
- } else {
- if ($g['debug'])
- echo "{$src_table} NOT found in cache...adding\n";
- $table_cache[$src_table] = $src_table_line;
- }
- if (isset($dst_table))
- if (isset($table_cache[$dst_table])) {
- if ($g['debug'])
- echo "{$dst_table} found in cache\n";
- } else {
- if ($g['debug'])
- echo "{$dst_table} NOT found in cache...adding\n";
- $table_cache[$dst_table] = $dst_table_line;
- }
-
- /* exception(s) to a user rules can go here. */
- /* rules with a gateway or pool should create another rule for routing to local networks or vpns */
- /* we only trigger this for a rule with the destination of any and without a gateway */
- if (($aline['route'] <> "") && ($aline['type'] == "pass") && ($dst == "any") && (! interface_has_gateway($aline['interface']))) {
- /* negate VPN/PPTP/PPPoE networks for load balancer rules */
- $vpns = " to <vpns> ";
- $line .= $aline['type'] . $aline['direction'] . $aline['log'] . $aline['quick'] . $aline['interface'] . $aline['prot'] .
- $aline['src'] . $aline['srcport'] . $aline['os'] . $vpns . $aline['dstport'].
- $aline['icmp-type'] . $aline['flags'] .
- " label \"NEGATE_ROUTE: Negate policy route for local network(s)\"\n";
- }
-
- /* piece together the actual user rule */
- $line .= $aline['type'] . $aline['direction'] . $aline['log'] . $aline['quick'] . $aline['interface'] . $aline['reply'] .
- $aline['route'] . $aline['prot'] . $aline['src'] . $aline['srcport'] . $aline['os'] . $aline['dst'] .
- $aline['dstport'] . $aline['icmp-type'] . $aline['flags'];
-
- /* is a time based rule schedule attached? */
- if($rule['sched']) {
- if($config['schedules']) {
- foreach($config['schedules']['schedule'] as $sched) {
- if($sched['name'] == $rule['sched'])
- $schedule_xml_block = $sched;
- $schedule_enabled = true;
- }
- }
- if($schedule_xml_block)
- $status = get_time_based_rule_status($schedule_xml_block);
- if($status) {
- if($g['debug'])
- log_error("[TDR DEBUG] status true -- rule type '$type'");
- if($type == "block") {
- // active deny rules should deny
- $ipfw_rule = tdr_create_ipfw_rule($rule, "deny");
- tdr_install_rule($ipfw_rule);
- } else {
- // active allow rules should allow
- $ipfw_rule = tdr_create_ipfw_rule($rule, "allow");
- tdr_install_rule($ipfw_rule);
- }
- return "$line";
- } else {
- /* rule is turned off, if type == pass, deny traffic until
- * active else allow traffic until active
- */
- if($type == "pass") {
- // inactive pass rules should deny
- $ipfw_rule = tdr_create_ipfw_rule($rule, "deny");
- tdr_install_rule($ipfw_rule);
- } else {
- // inactive block rules should skipto
- $ipfw_rule = tdr_create_ipfw_rule($rule, "skipto");
- tdr_install_rule($ipfw_rule);
- }
- return "# $line";
- }
- } else {
- if($schedule_enabled) {
- // no schedule allow rules should simply allow
- $ipfw_rule = tdr_create_ipfw_rule($rule, "allow");
- tdr_install_rule($ipfw_rule);
- }
- return $line;
- }
-}
-
-function filter_rules_generate() {
- global $config, $g, $table_cache;
-
- update_filter_reload_status("Creating default rules");
-
- if(isset($config['system']['developerspew'])) {
- $mt = microtime();
- echo "filter_rules_generate() being called $mt\n";
- }
-
- $wancfg = $config['interfaces']['wan'];
- $lancfg = $config['interfaces']['lan'];
- $pptpdcfg = $config['pptpd'];
- $pppoecfg = $config['pppoe'];
-
- $lanif = $lancfg['if'];
- $wanif = get_real_wan_interface();
-
- $lanip = $lancfg['ipaddr'];
- $lansa = gen_subnet($lancfg['ipaddr'], $lancfg['subnet']);
- $lansn = $lancfg['subnet'];
-
- $wanip = find_interface_ip(get_real_wan_interface());
-
- if($lansa)
- $lansa_sn_combo = "{$lansa}/{$lansn}";
- else
- $lansa_sn_combo = "192.168.1.1/32";
-
- /* optional interfaces */
- $optcfg = array();
- generate_optcfg_array($optcfg);
-
- if (is_package_installed('squid') && file_exists('/usr/local/pkg/squid.inc')) {
- require_once('squid.inc');
- $ipfrules .= squid_generate_rules('filter');
- }
-
- if (is_package_installed('clamav') && file_exists('/usr/local/pkg/clamav.inc')) {
- require_once('clamav.inc');
- $ipfrules .= clamav_generate_rules('filter');
- }
-
- if (is_package_installed('clamav') && file_exists('/usr/local/pkg/clamav.inc')) {
- require_once('clamav.inc');
- $ipfrules .= clamav_generate_rules('filter');
- }
-
- if (is_package_installed('frickin') && file_exists('/usr/local/pkg/frickin.inc')) {
- require_once ('frickin.inc');
- $ipfrules .= frickin_generate_rules('filter');
- }
-
- if (is_package_installed('siproxd') && file_exists('/usr/local/pkg/sipproxd.inc')) {
- require_once('sipproxd.inc');
- $ipfrules .= siproxd_generate_rules('filter');
- }
-
- /* if captive portal is enabled, ensure that access to this port
- * is allowed on a locked down interface
- */
- if (isset($config['captiveportal']['enable'])) {
- $cp_interface = $config['captiveportal']['interface'];
- $cp_interface_real = convert_friendly_interface_to_real_interface_name($cp_interface);
- $cp_interface_ip = find_interface_ip($cp_interface_real);
- if (isset($config['captiveportal']['peruserbw']))
- mwexec("kldload dummynet");
- if($cp_interface_ip and $cp_interface_real)
- $ipfrules .= "pass in quick on {$cp_interface_real} proto tcp from any to {$cp_interface_ip} port { 8000 8001 } keep state\n";
- }
-
- /* ftp-sesame */
- $ipfrules .= "anchor \"ftpsesame/*\" \n";
-
- # BEGIN OF firewall rules
- $ipfrules .= "anchor \"firewallrules\"\n";
-
- if ($pptpdcfg['mode'] == "server") {
- $pptpip = $pptpdcfg['localip'];
- $pptpsa = $pptpdcfg['remoteip'];
- $pptpsn = $g['pptp_subnet'];
- if($config['pptp']['pptp_subnet'] <> "")
- $pptpsn = $config['pptp']['pptp_subnet'];
- }
-
- if ($pppoecfg['mode'] == "server") {
- $pppoeip = $pppoecfg['localip'];
- $pppoesa = $pppoecfg['remoteip'];
- $pppoesn = $g['pppoe_subnet'];
- if($config['pppoe']['pppoe_subnet'] <> "")
- $pppoesn = $config['pppoe']['pppoe_subnet'];
- }
-
- /* default block logging? */
- if (!isset($config['syslog']['nologdefaultblock']))
- $log = "log";
- else
- $log = "";
-
- $ipfrules .= <<<EOD
-
-# We use the mighty pf, we cannot be fooled.
-block quick proto { tcp, udp } from any port = 0 to any
-block quick proto { tcp, udp } from any to any port = 0
-
-# snort2c
-table <snort2c> persist
-block quick from <snort2c> to any label "Block snort2c hosts"
-block quick from any to <snort2c> label "Block snort2c hosts"
-
-EOD;
-
- if(!isset($config['system']['ipv6allow'])) {
- $ipfrules .= "# Block all IPv6\n";
- $ipfrules .= "block in quick inet6 all\n";
- $ipfrules .= "block out quick inet6 all\n";
- }
-
- $ipfrules .= <<<EOD
-# loopback
-anchor "loopback"
-pass in quick on \$loopback all label "pass loopback"
-pass out quick on \$loopback all label "pass loopback"
-
-# package manager early specific hook
-anchor "packageearly"
-
-
-# carp
-anchor "carp"
-
-EOD;
-
-if($wanip)
- $ipfrules .= <<<EOD
-
-# permit wan interface to ping out (ping_hosts.sh)
-pass quick proto icmp from {$wanip} to any keep state
-
-EOD;
-
- $ipfrules .= <<<EOD
-
-# NAT Reflection rules
-
-EOD;
-
- if (isset($config['nat']['rule'])) {
- $natrules .= "# NAT Inbound Redirects\n";
-
- if(!isset($config['system']['disablenatreflection'])) {
- //$fd = fopen("/var/etc/inetd.conf","w");
- /* start redirects on port 19000 of localhost */
- $starting_localhost_port = 18999;
- }
-
- foreach ($config['nat']['rule'] as $rule) {
-
- update_filter_reload_status("Creating NAT rule {$rule['descr']}");
-
- /* if item is an alias, expand */
- if(alias_expand($rule['external-port']))
- $extport[0] = alias_expand_value($rule['external-port']);
- else
- $extport = explode("-", $rule['external-port']);
-
- /* if item is an alias, expand */
- if(alias_expand($rule['local-port']))
- $localport = "";
- else
- $localport = " port {$rule['local-port']}";
-
- $target = alias_expand_host($rule['target']);
-
- if (!$target)
- continue; /* unresolvable alias */
-
- if ($rule['external-address'])
- if($rule['external-address'] <> "any")
- $extaddr = $rule['external-address'] . "/32";
- else
- $extaddr = $rule['external-address'];
- else
- $extaddr = get_current_wan_address($rule['interface']);
-
- if (!$rule['interface'] || ($rule['interface'] == "wan"))
- $natif = $wanif;
- else if($rule['interface'] == "\$pptp")
- $natif = "pptp";
- else if($rule['interface'] == "\$pppoe")
- $natif = "pppoe";
- else
- $natif = $config['interfaces'][$rule['interface']]['if'];
-
- $lanif = $lancfg['if'];
-
- /*
- * Expand aliases
- * XXX: may want to integrate this into pf macros
- */
- if(alias_expand($target))
- $target = alias_expand($target);
- if(alias_expand($extaddr))
- $extaddr = alias_expand($extaddr);
-
- if(!isset($config['system']['disablenatreflection'])) {
-
- /* if list */
- $iflist = array("lan" => "LAN");
- for ($i = 1; isset($config['interfaces']['opt' . $i]); $i++)
- $iflist['opt' . $i] = "opt{$i}";
-
- foreach ($iflist as $ifent => $ifname) {
-
- /* do not process interfaces with gateways*/
- if($config['interfaces'][$ifname]['gateway'] <> "")
- continue;
-
- /* do not process interfaces that will end up with gateways */
- if($config['interfaces'][$ifname]['ipaddr'] == "dhcp" or
- $config['interfaces'][$ifname]['ipaddr'] == "bigpond" or
- $config['interfaces'][$ifname]['ipaddr'] == "pppoe" or
- $config['interfaces'][$ifname]['ipaddr'] == "pptp")
-
- continue;
-
- $ifname_real = convert_friendly_interface_to_real_interface_name($ifname);
-
- if($extport[1])
- $range_end = ($extport[1]);
- else
- $range_end = ($extport[0]);
-
- $range_end++;
-
- if($rule['local-port'])
- $lrange_start = $rule['local-port'];
-
- if($range_end - $extport[0] > 500) {
- $range_end = $extport[0]+1;
- log_error("Not installing nat reflection rules for a port range > 500");
- } else {
- /* only install reflection rules for < 19991 items */
- if($starting_localhost_port < 19991) {
- $loc_pt = $lrange_start;
- for($x=$extport[0]; $x<$range_end; $x++) {
-
- $starting_localhost_port++;
- $ifname_real = convert_friendly_interface_to_friendly_descr(strtolower($ifname));
-
- switch($rule['protocol']) {
- case "tcp/udp":
- $protocol = "{ tcp udp }";
- $ipfrules .= "pass in quick on \${$ifname_real} inet proto tcp from any to \$loopback port {$starting_localhost_port} keep state label \"NAT REFLECT: Allow traffic to localhost\"\n";
- $starting_localhost_port++;
- $ipfrules .= "pass in quick on \${$ifname_real} inet proto udp from any to \$loopback port {$starting_localhost_port} keep state label \"NAT REFLECT: Allow traffic to localhost\"\n";
- break;
- case "tcp":
- case "udp":
- $protocol = $rule['protocol'];
- $ipfrules .= "pass in quick on \${$ifname_real} inet proto {$rule['protocol']} from any to \$loopback port {$starting_localhost_port} keep state label \"NAT REFLECT: Allow traffic to localhost\"\n";
- break;
- default:
- break;
- }
- $loc_pt++;
- if($starting_localhost_port > 19990) {
- log_error("Not installing nat reflection rules. Maximum 1,000 reached.");
- $x = $range_end+1;
- }
- }
- }
- }
- }
-
- }
- }
- }
-
- $ipfrules .= <<<EOD
-
-# allow access to DHCP server on LAN
-anchor "dhcpserverlan"
-pass in quick on \$lan proto udp from any port = 68 to 255.255.255.255 port = 67 label "allow access to DHCP server on LAN"
-pass in quick on \$lan proto udp from any port = 68 to $lanip port = 67 label "allow access to DHCP server on LAN"
-pass out quick on \$lan proto udp from $lanip port = 67 to any port = 68 label "allow access to DHCP server on LAN"
-
-EOD;
-
- /* allow access to DHCP server on optional interfaces */
- foreach ($optcfg as $on => $oc) {
- if ($config[interfaces][$on][ipaddr] == "dhcp" ) {
- $friendly_on = filter_get_opt_interface_descr($on);
- $ipfrules .= <<<EOD
-
-# Not installing DHCP server firewall rules for $friendly_on which is configured for DHCP.
-
-EOD;
- } elseif (isset($config['dhcpd'][$on]['enable']) && (!$oc['bridge']) ||
- ($oc['bridge'] && isset($config['dhcpd'][$oc['bridge']]['enable']))) {
-
- $friendly_on = filter_get_opt_interface_descr($on);
-
- $ipfrules .= <<<EOD
-
-# allow access to DHCP server on {$on}
-anchor "dhcpserver{$friendly_on}"
-pass in quick on \${$friendly_on} proto udp from any port = 68 to 255.255.255.255 port = 67 label "allow access to DHCP server"
-pass in quick on \${$friendly_on} proto udp from any port = 68 to {$oc['ip']} port = 67 label "allow access to DHCP server"
-pass out quick on \${$friendly_on} proto udp from {$oc['ip']} port = 67 to any port = 68 label "allow access to DHCP server"
-
-EOD;
- }
- }
-
- /* pass traffic between statically routed subnets and the subnet on the
- interface in question to avoid problems with complicated routing
- topologies */
- $sa = "";
- if (isset($config['filter']['bypassstaticroutes']) && is_array($config['staticroutes']['route']) && count($config['staticroutes']['route'])) {
- $ipfrules .= <<<EOD
-anchor "staticroutes"
-
-EOD;
- foreach ($config['staticroutes']['route'] as $route) {
- unset($sa);
- $friendly_int = convert_friendly_interface_to_friendly_descr($route['interface']);
- if ($route['interface'] == "lan") {
- $sa = $lansa;
- $sn = $lansn;
- $if = $lanif;
- $friendly_int = "lan";
- } else if (strstr($route['interface'], "opt")) {
- $oc = $optcfg[$route['interface']];
- if ($oc['ip']) {
- $sa = $oc['sa'];
- $sn = $oc['sn'];
- $if = $oc['if'];
- }
- }
-
- if ($sa) {
- $ipfrules .= <<<EOD
-pass in quick on \${$friendly_int} from {$sa}/{$sn} to {$route['network']} no state label "pass traffic between statically routed subnets"
-pass in quick on \${$friendly_int} from {$route['network']} to {$sa}/{$sn} no state label "pass traffic between statically routed subnets"
-pass out quick on \${$friendly_int} from {$sa}/{$sn} to {$route['network']} no state label "pass traffic between statically routed subnets"
-pass out quick on \${$friendly_int} from {$route['network']} to {$sa}/{$sn} no state label "pass traffic between statically routed subnets"
-
-EOD;
- }
- }
- }
-
- /* install wan spoof check rule if lan address exists */
- if($lansa) {
- if(!isset($config['interfaces']['wan']['spoofmac'])) {
- $ipfrules .= <<<EOD
-
-# WAN spoof check
-anchor "wanspoof"
-block in $log quick on \$wan from $lansa/$lansn to any label "WAN spoof check"
-
-EOD;
-
- }
- }
-
- foreach ($optcfg as $oc) {
- if (!$oc['bridge'])
- if($oc['sa'] <> "")
- if(isset($oc['enable']))
- $ipfrules .= "block in $log quick on \$wan from {$oc['sa']}/{$oc['sn']} to any label \"interface spoof check\"\n";
- }
-
- /* allow PPTP traffic if PPTP client is enabled on WAN */
- if ($wancfg['ipaddr'] == "pptp") {
- $ipfrules .= <<<EOD
-
-# allow PPTP client
-anchor "pptpclient"
-pass in quick on \$wan proto gre from any to any modulate state label "allow PPTP client"
-pass in quick on \$wan proto gre from any to any modulate state label "allow PPTP client"
-pass in quick on \$wan proto tcp from any port = 1723 to any flags S/SA modulate state label "allow PPTP client"
-pass in quick on \$wan proto tcp from any to any port = 1723 flags S/SA modulate state label "allow PPTP client"
-
-EOD;
- }
-
- if ($wancfg['ipaddr'] == "dhcp") {
-
- $ipfrules .= <<<EOD
-
-# allow our DHCP client out to the WAN
-anchor "wandhcp"
-pass out quick on \$wan proto udp from any port = 68 to any port = 67 label "allow dhcp client out wan"
-
-EOD;
- }
-
-if($config['interfaces']['lan']['bridge'] <> "wan" and $config['interfaces']['wan']['bridge'] <> "lan")
- $ipfrules .= "block in $log quick on \$wan proto udp from any port = 67 to {$lansa_sn_combo} port = 68 label \"block dhcp client out wan\"\n";
-
- $ipfrules .= <<<EOD
-
-# LAN/OPT spoof check (needs to be after DHCP because of broadcast addresses)
-
-EOD;
-
- /* LAN spoof check */
- $lanbridge = false;
- foreach($config['interfaces'] as $int)
- if($int['bridge'] == "lan")
- $lanbridge = true;
- if(!$lanbridge)
- $ipfrules .= filter_rules_spoofcheck_generate('lan', $lanif, $lansa, $lansn, $log);
- $wanbridge = false;
- foreach($config['interfaces'] as $int)
- if($int['bridge'] == "wan")
- $lanbridge = true;
- if($config['interfaces']['lan']['bridge'] == "wan")
- $wanbridge = true;
-
- /* OPT spoof check */
- foreach ($optcfg as $on => $oc) {
- $isbridged = false;
- foreach ($optcfg as $on2 => $oc2) {
- if ($oc2['bridge'] && $oc2['bridge'] == $on) {
- $isbridged = true;
- break;
- }
- }
- if ($oc['ip'] && !(($oc['bridge'] || $isbridged) && isset($config['bridge']['filteringbridge'])))
- $ipfrules .= filter_rules_spoofcheck_generate($on, $oc['if'], $oc['sa'], $oc['sn'], $log);
- }
-
- $ipfrules .= "\nanchor \"spoofing\"\n";
-
- /* block private networks on WAN? */
- if (isset($config['interfaces']['wan']['blockpriv'])) {
- if($wanbridge == false) {
- $ipfrules .= <<<EOD
-
-# block anything from private networks on WAN interface
-anchor "spoofing"
-antispoof for \$wan
-block in $log quick on \$wan from 10.0.0.0/8 to any label "block private networks from wan block 10/8"
-block in $log quick on \$wan from 127.0.0.0/8 to any label "block private networks from wan block 127/8"
-block in $log quick on \$wan from 172.16.0.0/12 to any label "block private networks from wan block 172.16/12"
-block in $log quick on \$wan from 192.168.0.0/16 to any label "block private networks from wan block 192.168/16"
-
-EOD;
-
- }
- }
-
- /*
- * Support for allow limiting of TCP connections by establishment rate
- * Useful for protecting against sudden outburts, etc.
- */
- $ipfrules .= <<<EODF
-# Support for allow limiting of TCP connections by establishment rate
-anchor "limitingesr"
-table <virusprot>
-block in quick from <virusprot> to any label "virusprot overload table"
-
-EODF;
-
- /* block bogon networks on WAN */
- /* http://www.cymru.com/Documents/bogon-bn-nonagg.txt */
- /* file is automatically in cron every 3000 minutes */
- if (isset($config['interfaces']['wan']['blockbogons'])) {
- $ipfrules .= <<<EOD
-
-# block bogon networks
-# http://www.cymru.com/Documents/bogon-bn-nonagg.txt
-anchor "wanbogons"
-table <bogons> persist file "/etc/bogons"
-block in $log quick on \$wan from <bogons> to any label "block bogon networks from wan"
-
-EOD;
- }
-
-if (!isset($config['shaper']['enable']) && !is_array($config['shaper']['queue']) and $config['system']['shapertype'] <> "m0n0") {
-
- $ipfrules .= <<<EOD
-
-# let out anything from the firewall host itself and decrypted IPsec traffic
-pass out quick on \$lan proto icmp keep state label "let out anything from firewall host itself"
-pass out quick on \$wan proto icmp keep state label "let out anything from firewall host itself"
-
-# tcp.closed 5 is a workaround for load balancing, squid and a few other issues.
-# ticket (FEN-857512) in centipede tracker.
-pass out quick on $wanif all keep state ( tcp.closed 5 ) label "let out anything from firewall host itself"
-
-EOD;
-
-}
-
- $ipfrules .= create_firewall_outgoing_rules_to_itself();
-
- /* group heads for optional interfaces */
- foreach ($optcfg as $on => $oc) {
-
- $friendly_on = convert_friendly_interface_to_friendly_descr($on);
-
- if($oc['descr'])
- $friendly_on = $oc['descr'];
-
- $ipfrules .= <<<EOD
-
-
-# let out anything from the firewall host itself and decrypted IPsec traffic
-pass out quick on {$oc['if']} proto icmp keep state ( tcp.closed 5 ) label "let out anything from firewall host itself"
-pass out quick on \${$friendly_on} all keep state ( tcp.closed 5 ) label "let out anything from firewall host itself"
-
-EOD;
-
- }
-
- if($config['interfaces']['wan']['ipaddr'] == "pppoe")
- $ipfrules .= <<<EOD
-# permit wan interface to ping out (ping_hosts.sh)
-pass out quick on ng0 proto icmp keep state ( tcp.closed 5 ) label "let out anything from firewall host itself"
-
-EOD;
-
- if (!isset($config['system']['webgui']['noantilockout'])) {
-
- if($lansa and $lansn) {
-
- $ipfrules .= <<<EOD
-
-# make sure the user cannot lock himself out of the webGUI or SSH
-anchor "anti-lockout"
-pass in quick on $lanif from any to $lanip keep state label "anti-lockout web rule"
-
-EOD;
- }
- }
-
- /* PPTPd enabled? */
- if ($pptpdcfg['mode'] && ($pptpdcfg['mode'] != "off")) {
-
- if ($pptpdcfg['mode'] == "server")
- $pptpdtarget = get_current_wan_address();
- else
- $pptpdtarget = $pptpdcfg['redir'];
-
- if($pptpdtarget) {
- if(!isset($config['system']['disablevpnrules'])) {
- $ipfrules .= <<<EOD
-
-# PPTPd rules
-anchor "pptp"
-pass in quick on \$wan proto gre from any to $pptpdtarget keep state label "allow gre pptpd"
-pass in quick on \$wan proto tcp from any to $pptpdtarget port = 1723 modulate state label "allow pptpd {$pptpdtarget}"
-
-EOD;
- }
-
- } else {
- /* this shouldnt ever happen but instead of breaking the clients ruleset
- * log an error.
- */
- log_error("ERROR! PPTP enabled but could not resolve the \$pptpdtarget");
- }
- }
-
- /* BigPond client enabled? */
- if ($wancfg['ipaddr'] == "bigpond") {
-
- $ipfrules .= <<<EOD
-
-# BigPond heartbeat rules
-anchor "bigpond"
-pass in quick proto udp from any to any port = 5050 keep state label "BigPond heartbeat"
-
-# package manager late specific hook
-anchor "packagelate"
-
-
-
-EOD;
- }
-
- $ipfrules .= "\n# SSH lockout\n";
- $ipfrules .= "block in log quick proto tcp from <sshlockout> to any port 22 label \"sshlockout\"\n\n";
-
- $ipfrules .= "anchor \"ftpproxy\"\n";
- $ipfrules .= "anchor \"pftpx/*\"\n";
-
- $ipfrules .= process_carp_rules();
-
- if (isset($config['filter']['rule'])) {
- /* Pre-cache all our rules so we only have to generate them once */
- $rule_arr = array();
- foreach ($config['filter']['rule'] as $rule) {
- update_filter_reload_status("Pre-caching {$rule['descr']}...");
- $line = "";
- if (!isset($rule['disabled'])) {
- if ($rule['interface'] == "pptp") {
- /* we have a pptp rule but its turned off, ignore */
- if(!$config['pptpd']['mode'] == "server")
- continue;
- $n_pptp_units = $g['n_pptp_units'];
- if($config['pptp']['n_pptp_units'] <> "")
- $nif = $config['pptp']['n_pptp_units'];
- /*
- * now that PPTP server are user rules, detect
- * that user is setting the pptp server rule
- * and setup for all netgraph interfaces
- */
- $rule_arr[] = generate_user_filter_rule_arr($rule, 0);
- } else if($rule['interface'] == "pppoe") {
- if(!$config['pppoe']['mode'] == "server")
- continue;
- $n_pppoe_units = $g['n_pppoe_units'];
- if($config['pppoe']['n_pppoe_units'] <> "")
- $nif = $config['pppoe']['n_pppoe_units'];
- /*
- * now that pppoe server are user rules, detect
- * that user is setting the pppoe server rule
- * and setup for all netgraph interfaces
- */
- $rule_arr[] = generate_user_filter_rule_arr($rule, 0);
- } else {
- $rule_arr[] = generate_user_filter_rule_arr($rule, 0);
- }
- }
- }
-
- $ipfrules .= "\n# User-defined aliases follow\n";
- /* tables for aliases */
- foreach($table_cache as $table) {
- $ipfrules .= $table;
- }
-
- /* Shaper rules */
- if (isset($config['shaper']['enable']) && is_array($config['shaper']['queue']) && isset($config['filter']['rule']) and $config['system']['shapertype'] <> "m0n0") {
-
- $ipfrules .= "\n# Anchors for rules that might be matched by queues\n";
-
- /* This is ugly, but we generate one anchor per queue */
- foreach ($config['shaper']['queue'] as $queue) {
- update_filter_reload_status("Creating filter anchor for {$queue['name']} ...");
- /* Add anchor to rules */
- $ipfrules .= "anchor {$queue['name']} tagged {$queue['name']}\n";
- $ipfrules .= "load anchor {$queue['name']} from \"{$g['tmp_path']}/{$queue['name']}.rules\"\n";
- /* Create rules for anchors */
- $fd = fopen("{$g['tmp_path']}/{$queue['name']}.rules", "w");
- /* aliases don't recurse to anchors */
- $line = filter_generate_aliases();
- fwrite($fd, $line);
- foreach($rule_arr as $rule) {
- if($rule['ackq'] != "")
- $line = "{$rule['rule']} queue ({$queue['name']}, {$rule['ackq']}) {$rule['descr']}\n";
- else
- $line = "{$rule['rule']} queue {$queue['name']} {$rule['descr']}\n";
- fwrite($fd, $line);
- }
- fclose($fd);
- }
- }
-
- $ipfrules .= "\n# User-defined rules follow\n";
- /* Generate user rule lines */
- foreach($rule_arr as $rule) {
- $line = "";
- if (!isset($rule['disabled'])) {
- $line = $rule['rule'];
- if($line <> "") {
- /* Add default queue if we're using the shaper */
- if (isset($config['shaper']['enable']) && is_array($config['shaper']['queue']) and $config['system']['shapertype'] <> "m0n0") {
- $defq = find_default_queue($rule['interface']);
- $ackq = $rule['ackq'];
- if (($defq != "") and ($ackq != ""))
- $line .= " queue ({$defq}, {$ackq}) ";
- }
- /* label */
- $line .= " {$rule['descr']}";
- }
- }
- $line .= "\n";
- $ipfrules .= $line;
- }
- }
-
- update_filter_reload_status("Creating carp rules...");
-
- $ipfrules .= "\n# VPN Rules\n";
- $lan_ip = $config['interfaces']['lan']['ipaddr'];
- $lan_subnet = $config['interfaces']['lan']['subnet'];
- $wanif = get_real_wan_interface();
- $wan_ip = find_interface_ip($wanif);
- if($wan_ip) {
- $internal_subnet = gen_subnet($lan_ip, $lan_subnet) . "/" . $config['interfaces']['lan']['subnet'];
- /* Is IP Compression enabled? */
- if(isset($config['ipsec']['ipcomp']))
- exec("/sbin/sysctl net.inet.ipcomp.ipcomp_enable=1");
- else
- exec("/sbin/sysctl net.inet.ipcomp.ipcomp_enable=0");
-
- /* build an interface collection */
- $ifdescrs = array ("wan");
- for ($j = 1; isset ($config['interfaces']['opt' . $j]); $j++) {
- if(isset($config['interfaces']['opt' . $j]['enable']))
- $ifdescrs['opt' . $j] = filter_get_opt_interface_descr("opt" . $j);
- }
-
- if(is_array($config['ipsec']['tunnel']) && isset($config['ipsec']['enable'])) {
- foreach ($config['ipsec']['tunnel'] as $tunnel) {
- if(isset($tunnel['disabled']))
- continue;
- update_filter_reload_status("Creating IPSEC tunnel items {$tunnel['descr']}...");
- /* if tunnel is disabled, lets skip to next item */
- $ipsec_ips = array(get_current_wan_address($tunnel['interface']));
- /* is this a dynamic dns hostname? */
- if(!is_ipaddr($tunnel['remote-gateway'])) {
- $remote_gateway = resolve_retry($tunnel['remote-gateway']);
- } else {
- $remote_gateway = $tunnel['remote-gateway'];
- }
- /* do not add items with blank remote_gateway */
- if(!is_ipaddr($remote_gateway)) {
- $ipfrules .= "# ERROR! Remote gateway not found on {$tunnel['remote-gateway']}\n";
- continue;
- }
- $local_subnet = return_vpn_subnet($tunnel['local-subnet']);
- foreach($ifdescrs as $iface) {
- foreach($ipsec_ips as $interface_ip) {
- if($iface == "wan")
- $interface_ip = find_interface_ip(get_real_wan_interface());
- else
- $interface_ip = find_interface_ip(convert_friendly_interface_to_real_interface_name($iface));
- if(!$interface_ip)
- continue;
- if(!$remote_gateway)
- continue;
- if(isset($config['system']['disablevpnrules']))
- continue;
-
- $shorttunneldescr = substr($tunnel['descr'], 0, 26);
- $ipfrules .= "pass out quick on \${$iface} proto udp from any to {$remote_gateway} port = 500 keep state label \"IPSEC: {$shorttunneldescr} - outbound isakmp\"\n";
- $ipfrules .= "pass in quick on \${$iface} proto udp from {$remote_gateway} to any port = 500 keep state label \"IPSEC: {$shorttunneldescr} - inbound isakmp\"\n";
- if ($tunnel['p2']['protocol'] == 'esp') {
- $ipfrules .= "pass out quick on \${$iface} proto esp from any to {$remote_gateway} keep state label \"IPSEC: {$shorttunneldescr} - outbound esp proto\"\n";
- $ipfrules .= "pass in quick on \${$iface} proto esp from {$remote_gateway} to any keep state label \"IPSEC: {$shorttunneldescr} - inbound esp proto\"\n";
- }
- if ($tunnel['p2']['protocol'] == 'ah') {
- $ipfrules .= "pass out quick on \${$iface} proto ah from any to {$remote_gateway} keep state label \"IPSEC: {$shorttunneldescr} - outbound ah proto\"\n";
- $ipfrules .= "pass in quick on \${$iface} proto ah from {$remote_gateway} to any keep state label \"IPSEC: {$shorttunneldescr} - inbound ah proto\"\n";
- }
- }
- }
- }
- }
-
- /* is mobile ipsec enabled? if so lets allow some pretty
- * loose rules to allow mobile clients to phone in.
- */
- $ipseccfg = $config['ipsec'];
- if (isset($ipseccfg['mobileclients']['enable'])) {
- if(!isset($config['system']['disablevpnrules'])) {
- foreach($ifdescrs as $iface) {
- $ipfrules .= "pass in quick on \${$iface} proto udp from any to any port = 500 keep state label \"IPSEC: Mobile - inbound isakmp\"\n";
- $ipfrules .= "pass in quick on \${$iface} proto esp from any to any keep state label \"IPSEC: Mobile - inbound esp proto\"\n";
- $ipfrules .= "pass in quick on \${$iface} proto ah from any to any keep state label \"IPSEC: Mobile - inbound ah proto\"\n";
- }
- }
- }
- }
- $ipfrules .= <<<EOD
-
-pass in quick on $lanif inet proto tcp from any to \$loopback port 8021 keep state label "FTP PROXY: Allow traffic to localhost"
-pass in quick on $lanif inet proto tcp from any to \$loopback port 21 keep state label "FTP PROXY: Allow traffic to localhost"
-pass in quick on $wanif inet proto tcp from port 20 to ($wanif) port > 49000 flags S/SA keep state label "FTP PROXY: PASV mode data connection"
-
-EOD;
-
- if(!isset($config['system']['disableftpproxy'])) {
-
- $ipfrules .= "# enable ftp-proxy\n";
-
- $optcfg = array();
- generate_optcfg_array($optcfg);
- $ftp_counter = "8022";
- foreach($optcfg as $oc) {
- if(!isset($oc['gateway']) && $oc['if'] <> "") {
- $ipfrules .= "pass in quick on " . $oc['if'] . " inet proto tcp from any to \$loopback port {$ftp_counter} keep state label \"FTP PROXY: Allow traffic to localhost\"\n";
- $ipfrules .= "pass in quick on " . $oc['if'] . " inet proto tcp from any to \$loopback port 21 keep state label \"FTP PROXY: Allow traffic to localhost\"\n";
- }
- $ftp_counter++;
- }
-
- if(isset($config['system']['rfc959workaround'])) {
- $ipfrules .= <<<EODEOD
-
-# Fix sites that violate RFC 959 which specifies that the data connection
-# be sourced from the command port - 1 (typically port 20)
-# This workaround doesn't expose us to any extra risk as we'll still only allow
-# connections to the firewall on a port that ftp-proxy is listening on
-pass in quick on $wanif inet proto tcp from any to ($wanif) port > 49000 flags S/SA keep state label "FTP PROXY: RFC959 violation workaround"
-
-EODEOD;
-
- $optcfg = array();
- generate_optcfg_array($optcfg);
- foreach($optcfg as $oc) {
- if($oc['gateway'] <> "")
- $ipfrules .= "pass in quick on {$oc['if']} inet proto tcp from any to ({$oc['if']}) port > 49000 flags S/SA keep state label \"FTP PROXY: RFC959 violation workaround\" \n";
- }
- }
- }
-
- $ipfrules .= <<<EOD
-
-# IMSpector
-anchor "imspector"
-
-# uPnPd
-anchor "miniupnpd"
-
-#---------------------------------------------------------------------------
-# default deny rules
-#---------------------------------------------------------------------------
-block in $log quick all label "Default deny rule"
-block out $log quick all label "Default deny rule"
-
-EOD;
-
- return $ipfrules;
-}
-
-function filter_rules_spoofcheck_generate($ifname, $if, $sa, $sn, $log) {
-
- global $g, $config;
-
- if(isset($config['system']['developerspew'])) {
- $mt = microtime();
- echo "filter_rules_spoofcheck_generate() being called $mt\n";
- }
-
- $ipfrules = "antispoof for {$if}\n";
-
- return $ipfrules;
-
-}
-
-function setup_logging_interfaces() {
- global $config;
- if(isset($config['system']['developerspew'])) {
- $mt = microtime();
- echo "setup_logging_interfaces() being called $mt\n";
- }
- $rules = "";
- $i = 0;
- $ifdescrs = array('wan', 'lan');
- for ($j = 1; isset($config['interfaces']['opt' . $j]); $j++) {
- $ifdescrs['opt' . $j] = "opt" . $j;
- }
- foreach ($ifdescrs as $ifdescr => $ifname) {
- /* do not work with tun interfaces */
- if(stristr(filter_translate_type_to_real_interface($ifname), "tun") == true) continue;
- $int = filter_translate_type_to_real_interface($ifname);
- $rules .= "set loginterface {$int}\n";
- }
- return $rules;
-}
-
-function create_firewall_outgoing_rules_to_itself() {
- global $config, $g;
-
- if(isset($config['system']['developerspew'])) {
- $mt = microtime();
- echo "create_firewall_outgoing_rules_to_itself() being called $mt\n";
- }
-
- $i = 0;
- $rule .= "# pass traffic from firewall -> out\n";
- $rule .= "anchor \"firewallout\"\n";
- $ifdescrs = array('wan', 'lan');
- for ($j = 1; isset($config['interfaces']['opt' . $j]); $j++)
- $ifdescrs['opt' . $j] = "opt" . $j;
-
- /* go through primary and optional interfaces */
- foreach ($ifdescrs as $ifdescr => $ifname) {
- $return_gateway = $config['interfaces'][$ifname]['gateway'];
- $ints = array();
- $int = filter_translate_type_to_real_interface($ifname);
- /* if the interface is pppoe, set the ng0 interface */
- update_filter_reload_status("Creating IPSEC tunnel items {$tunnel['descr']}...");
- $ip = find_interface_ip($int);
- if ($config['interfaces'][$ifname]['ipaddr'] == "pppoe")
- $int = " { " . filter_translate_type_to_real_interface($ifname) . " ng0 } ";
- if (isset($config['shaper']['enable']) && is_array($config['shaper']['queue']) and $config['system']['shapertype'] <> "m0n0") {
- $ackq = get_ack_queue($ifname);
- $defq = find_default_queue($ifname);
- /* Handle all tagged packets */
- foreach ($config['shaper']['queue'] as $queue) {
- if(!filter_is_queue_being_used_on_interface($queue['name'], $ifname, 'out'))
- continue;
- if ($ackq == "" || $defq == "") {
- /* Shaper must not be enabled on this interface */
- $q = "";
- } else {
- $q = "queue ({$queue['name']}, {$ackq})";
- }
- $rule .="pass out quick on {$int} all keep state tagged {$queue['name']} {$q} label \"let out anything from firewall host itself\"\n";
- }
- /* Handle untagged packets */
- if ($ackq == "" || $defq == "") {
- /* Shaper must not be enabled on this interface */
- $q = "";
- } else {
- $q = "queue ({$defq}, {$ackq})";
- }
- $rule .="pass out quick on {$int} all keep state {$q} label \"let out anything from firewall host itself\"\n";
- } else {
- /* first add a rule for the real interface, then for ng0 */
- $rule .="pass out quick on {$int} all keep state label \"let out anything from firewall host itself\"\n";
- }
- }
-/*
- update_filter_reload_status("Setting up bridging items");
- // is bridging turned on?
- for($x=0; $x<10; $x++) {
- if(does_interface_exist("bridge{$x}") == true)
- $rule .="pass out quick on bridge{$x} all keep state label \"let out anything from firewall host itself\"\n";
- }
-*/
- update_filter_reload_status("Setting up pptp items");
- if($config['pptpd']['mode'] == "server")
- $rule .="pass out quick on \$pptp all keep state label \"let out anything from firewall host itself pptp\"\n";
-
- update_filter_reload_status("Setting up pppoe items");
- if($config['pppoe']['mode'] == "server")
- $rule .="pass out quick on \$pppoe all keep state label \"let out anything from firewall host itself pppoe\"\n";
-
- update_filter_reload_status("Setting up gif tunnels");
- /* setup outgoing gif tunnels */
- $number_of_gifs = find_last_gif_device();
- $number_of_gifs++;
- for($x=0; $x<$number_of_gifs; $x++) {
- if(does_interface_exist("gif{$x}") == true)
- $rule .="pass out quick on gif{$x} all keep state label \"let out anything from firewall host itself ipsec gif\"\n";
- }
-
- update_filter_reload_status("Setting up tun interfaces (openvpn)");
- /* openvpn tun interfaces. check for 100. */
- for($x=0; $x<100; $x++) {
- if(does_interface_exist("tun{$x}") == true) {
- $rule .="pass out quick on tun{$x} all keep state label \"let out anything from firewall host itself openvpn\"\n";
- $friendlytunif = convert_real_interface_to_friendly_interface_name("tun{$x}");
- /* If the interface has a gateway we do not add a pass in rule. */
- /* Some people use a TUN tunnel with public IP as a Multiwan interface */
- if(interface_has_gateway("tun{$x}")) {
- $rule .= "# Not adding default pass in rule for interface $friendlytunif - tun{$x} with a gateway!\n";
- } elseif (!isset($config['system']['disablevpnrules'])) {
- $rule .="pass in quick on tun{$x} all keep state label \"let out anything from firewall host itself openvpn\"\n";
- }
- }
- }
- for($x=0; $x<100; $x++) {
- if(does_interface_exist("tap{$x}") == true) {
- $rule .="pass out quick on tap{$x} all keep state label \"let out anything from firewall host itself openvpn\"\n";
- $friendlytapif = convert_real_interface_to_friendly_interface_name("tap{$x}");
- /* If the interface has a gateway we do not add a pass in rule. */
- /* Some people use a TAP tunnel with public IP as a Multiwan interface */
- if(interface_has_gateway("tap{$x}")) {
- $rule .= "# Not adding default pass in rule for interface $friendlytapif - tap{$x} with a gateway!\n";
- } elseif (!isset($config['system']['disablevpnrules'])) {
- $rule .="pass in quick on tap{$x} all keep state label \"let out anything from firewall host itself openvpn\"\n";
- }
- }
- }
-
- /* permit internal ipsec outbound traffic */
- $rule .="pass out quick on \$enc0 keep state label \"IPSEC internal host to host\"";
-
- return $rule;
-}
-
-function process_carp_nat_rules() {
- global $g, $config;
-
- update_filter_reload_status("Creating CARP NAT rules");
-
- $wan_interface = get_real_wan_interface();
-
- if(isset($config['system']['developerspew'])) {
- $mt = microtime();
- echo "process_carp_nat_rules() being called $mt\n";
- }
- $lines = "";
- if($config['installedpackages']['carp']['config'] != "")
- foreach($config['installedpackages']['carp']['config'] as $carp) {
- $ip = $carp['ipaddress'];
- if($ip <> "any") {
- $ipnet = "any";
- } else {
- $int = find_ip_interface($ip);
- $carp_int = find_carp_interface($ip);
- }
- if($int != false and $int != $wan_interface) {
- $ipnet = convert_ip_to_network_format($ip, $carp['netmask']);
- if($int)
- $lines .= "nat on {$int} inet from {$ipnet} to any -> ({$carp_int}) \n";
- }
- }
- return $lines;
-}
-
-function process_carp_rules() {
- global $g, $config;
- if(isset($config['system']['developerspew'])) {
- $mt = microtime();
- echo "process_carp_rules() being called $mt\n";
- }
- $lines = "";
- /* return if there are no carp configured items */
- if($config['installedpackages']['carpsettings']['config'] <> "" or
- $config['virtualip']['vip'] <> "") {
- $lines .= "pass quick proto carp\n";
- $lines .= "pass quick proto pfsync";
- }
- return $lines;
-}
-
-function remove_special_characters($string) {
- $match_array = "";
- preg_match_all("/[a-zA-Z0-9\_\-]+/",$string,$match_array);
- $string = "";
- foreach($match_array[0] as $ma) {
- if($string <> "")
- $string .= " ";
- $string .= $ma;
- }
- return $string;
-}
-
-function carp_sync_xml($url, $password, $sections, $port = 80, $method = 'pfsense.restore_config_section') {
- global $config, $g;
-
- if($g['booting'])
- return;
-
- update_filter_reload_status("Syncing CARP data to {$url}");
-
- /* make a copy of config */
- $config_copy = $config;
-
- /* strip out nosync items */
- for ($x = 0; $x < count($config_copy['nat']['advancedoutbound']['rule']); $x++) {
- if (isset ($config_copy['nat']['advancedoutbound']['rule'][$x]['nosync']))
- unset ($config_copy['nat']['advancedoutbound']['rule'][$x]);
- $config_copy['nat']['advancedoutbound']['rule'][$x]['descr'] = remove_special_characters($config_copy['nat']['advancedoutbound']['rule'][$x]['descr']);
- }
- for ($x = 0; $x < count($config_copy['nat']['rule']); $x++) {
- if (isset ($config_copy['nat']['rule'][$x]['nosync']))
- unset ($config_copy['nat']['rule'][$x]);
- $config_copy['nat']['rule'][$x]['descr'] = remove_special_characters($config_copy['nat']['rule'][$x]['descr']);
- }
- for ($x = 0; $x < count($config_copy['filter']['rule']); $x++) {
- if (isset ($config_copy['filter']['rule'][$x]['nosync']))
- unset ($config_copy['filter']['rule'][$x]);
- $config_copy['filter']['rule'][$x]['descr'] = remove_special_characters($config_copy['filter']['rule'][$x]['descr']);
- }
- for ($x = 0; $x < count($config_copy['aliases']['alias']); $x++) {
- if (isset ($config_copy['aliases']['alias'][$x]['nosync']))
- unset ($config_copy['aliases']['alias'][$x]);
- $config_copy['aliases']['alias'][$x]['descr'] = remove_special_characters($config_copy['aliases']['alias'][$x]['descr']);
- }
- for ($x = 0; $x < count($config_copy['dnsmasq']['hosts']); $x++) {
- if (isset ($config_copy['dnsmasq']['hosts'][$x]['nosync']))
- unset ($config_copy['dnsmasq']['hosts'][$x]);
- $config_copy['dnsmasq']['hosts'][$x]['descr'] = remove_special_characters($config_copy['dnsmasq']['hosts'][$x]['descr']);
- }
- for ($x = 0; $x < count($config_copy['virtualip']['vip']); $x++) {
- if (isset ($config_copy['virtualip']['vip'][$x]['nosync']) or $config_copy['virtualip']['vip'][$x]['mode'] == "proxyarp")
- unset ($config_copy['virtualip']['vip'][$x]);
- $config_copy['virtualip']['vip'][$x]['descr'] = remove_special_characters($config_copy['virtualip']['vip'][$x]['descr']);
- }
- for ($x = 0; $x < count($config_copy['ipsec']['tunnel']); $x++) {
- if (isset ($config_copy['ipsec']['tunnel'][$x]['nosync']))
- unset ($config_copy['ipsec']['tunnel'][$x]);
- $config_copy['ipsec']['tunnel'][$x]['descr'] = remove_special_characters($config_copy['ipsec']['tunnel'][$x]['descr']);
- }
-
- foreach($sections as $section) {
- /* we can't use array_intersect_key()
- due to the vip 'special case' */
- if($section != 'virtualip') {
- $xml[$section] = $config_copy[$section];
- } else {
- $xml[$section] = backup_vip_config_section();
- }
- }
-
- $params = array(
- XML_RPC_encode($password),
- XML_RPC_encode($xml)
- );
-
- $numberofruns = 0;
- while($numberofruns < 2) {
- log_error("Beginning XMLRPC sync to {$url}:{$port}.");
- $msg = new XML_RPC_Message($method, $params);
- $cli = new XML_RPC_Client('/xmlrpc.php', $url, $port);
- $username = $config['system']['username'];
- $cli->setCredentials($username, $password);
- if($numberofruns == 1)
- $cli->setDebug(1);
- /* send our XMLRPC message and timeout after 240 seconds */
- $resp = $cli->send($msg, "240");
- if(!$resp) {
- $error = "A communications error occured while attempting XMLRPC sync with username {$username} {$url}:{$port}.";
- log_error($error);
- file_notice("sync_settings", $error, "Settings Sync", "");
- } elseif($resp->faultCode()) {
- $error = "An error code was received while attempting XMLRPC sync with username {$username} {$url}:{$port} - Code " . $resp->faultCode() . ": " . $resp->faultString();
- log_error($error);
- file_notice("sync_settings", $error, "Settings Sync", "");
- } else {
- log_error("XMLRPC sync successfully completed with {$url}:{$port}.");
- $numberofruns = 3;
- }
- $numberofruns++;
- }
-}
-
-function carp_sync_client() {
-
- global $config, $g;
-
- update_filter_reload_status("Building CARP sync information");
-
- if($g['booting'])
- return;
-
- if(is_array($config['installedpackages']['carpsettings']['config'])) {
- foreach($config['installedpackages']['carpsettings']['config'] as $carp) {
- if($carp['synchronizetoip'] != "" ) {
- /*
- * XXX: The way we're finding the port right now is really suboptimal -
- * we can't assume that the other machine is setup identically.
- */
- if($config['system']['webgui']['protocol'] != "") {
- $synchronizetoip = $config['system']['webgui']['protocol'];
- $synchronizetoip .= "://";
- }
- $port = $config['system']['webgui']['port'];
- /* if port is empty lets rely on the protocol selection */
- if($port == "") {
- if($config['system']['webgui']['protocol'] == "http") {
- $port = "80";
- } else {
- $port = "443";
- }
- }
- $synchronizetoip .= $carp['synchronizetoip'];
- if($carp['synchronizerules'] != "" and is_array($config['filter'])) {
- $sections[] = 'filter';
- }
- if($carp['synchronizenat'] != "" and is_array($config['nat'])) {
- $sections[] = 'nat';
- }
- if($carp['synchronizealiases'] != "" and is_array($config['aliases'])) {
- $sections[] = 'aliases';
- }
- if($carp['synchronizedhcpd'] != "" and is_array($config['dhcpd'])) {
- $sections[] = 'dhcpd';
- }
- if($carp['synchronizewol'] != "" and is_array($config['wol'])) {
- $sections[] = 'wol';
- }
- if($carp['synchronizetrafficshaper'] != "" and is_array($config['shaper'])) {
- $sections[] = 'shaper';
- }
- if($carp['synchronizestaticroutes'] != "" and is_array($config['staticroutes'])) {
- $sections[] = 'staticroutes';
- }
- if($carp['synchronizevirtualip'] != "" and is_array($config['virtualip'])) {
- $sections[] = 'virtualip';
- }
- if($carp['synchronizelb'] != "" and is_array($config['load_balancer'])) {
- $sections[] = 'load_balancer';
- }
- if($carp['synchronizeipsec'] != "" and is_array($config['ipsec'])) {
- $sections[] = 'ipsec';
- }
- if($carp['synchronizednsforwarder'] != "" and is_array($config['dnsmasq'])) {
- $sections[] = 'dnsmasq';
- }
- if($carp['synchronizeschedules'] != "" and is_array($config['schedules'])) {
- $sections[] = 'schedules';
- }
- if(count($sections) > 0) {
- update_filter_reload_status("Signaling CARP reload signal...");
- carp_sync_xml($synchronizetoip, $carp['password'], $sections, $port);
- $cli = new XML_RPC_Client('/xmlrpc.php', $synchronizetoip, $port);
- $msg = new XML_RPC_Message('pfsense.filter_configure', array(new XML_RPC_Value($carp['password'], 'string')));
- $username = $config['system']['username'];
- $cli->setCredentials($username, $carp['password']);
- $cli->send($msg, "900");
- /* signal a carp reload */
- $msg = new XML_RPC_Message('pfsense.interfaces_carp_configure');
- $cli->send($msg, "900");
- }
- }
- }
- }
-
-}
-
-function return_vpn_subnet($adr) {
- global $config;
- if(isset($config['system']['developerspew'])) {
- $mt = microtime();
- echo "return_vpn_subnet() being called $mt\n";
- }
-
- if ($adr['address']) {
- list($padr, $pmask) = explode("/", $adr['address']);
- if (is_null($pmask))
- return "{$padr}/32";
- return "{$padr}/{$pmask}";
- }
-
- /* XXX: do not return wan, lan, etc */
- if(strstr($adr['network'], "wan") or strstr($adr['network'], "lan") or strstr($adr['network'], "opt"))
- return convert_ip_to_network_format($config['interfaces'][$adr['network']]['ipaddr'],
- $config['interfaces'][$adr['network']]['subnet']);
-
- /* fallback - error */
- return " # error - {$adr['network']} ";
-
-}
-
-?>
diff --git a/config/Fit123/bin/cpaddon/services_captiveportal.abc b/config/Fit123/bin/cpaddon/services_captiveportal.abc
deleted file mode 100755
index bafb27a7..00000000
--- a/config/Fit123/bin/cpaddon/services_captiveportal.abc
+++ /dev/null
@@ -1,608 +0,0 @@
-<?php
-/*
- services_captiveportal.php
- part of m0n0wall (http://m0n0.ch/wall)
-
- Copyright (C) 2003-2006 Manuel Kasper <mk@neon1.net>.
- 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 = "Services:Captive portal";
-require("guiconfig.inc");
-
-if (!is_array($config['captiveportal'])) {
- $config['captiveportal'] = array();
- $config['captiveportal']['page'] = array();
- $config['captiveportal']['timeout'] = 60;
-}
-
-if ($_GET['act'] == "viewhtml") {
- echo base64_decode($config['captiveportal']['page']['htmltext']);
- exit;
-} else if ($_GET['act'] == "viewerrhtml") {
- echo base64_decode($config['captiveportal']['page']['errtext']);
- exit;
-}
-
-$pconfig['cinterface'] = $config['captiveportal']['interface'];
-$pconfig['maxproc'] = $config['captiveportal']['maxproc'];
-$pconfig['maxprocperip'] = $config['captiveportal']['maxprocperip'];
-$pconfig['timeout'] = $config['captiveportal']['timeout'];
-$pconfig['idletimeout'] = $config['captiveportal']['idletimeout'];
-$pconfig['enable'] = isset($config['captiveportal']['enable']);
-$pconfig['auth_method'] = $config['captiveportal']['auth_method'];
-$pconfig['radacct_enable'] = isset($config['captiveportal']['radacct_enable']);
-$pconfig['radmac_enable'] = isset($config['captiveportal']['radmac_enable']);
-$pconfig['radmac_secret'] = $config['captiveportal']['radmac_secret'];
-$pconfig['reauthenticate'] = isset($config['captiveportal']['reauthenticate']);
-$pconfig['reauthenticateacct'] = $config['captiveportal']['reauthenticateacct'];
-$pconfig['httpslogin_enable'] = isset($config['captiveportal']['httpslogin']);
-$pconfig['httpsname'] = strtolower($config['captiveportal']['httpsname']);
-$pconfig['cert'] = base64_decode($config['captiveportal']['certificate']);
-$pconfig['key'] = base64_decode($config['captiveportal']['private-key']);
-$pconfig['logoutwin_enable'] = isset($config['captiveportal']['logoutwin_enable']);
-$pconfig['peruserbw'] = isset($config['captiveportal']['peruserbw']);
-$pconfig['bwdefaultdn'] = $config['captiveportal']['bwdefaultdn'];
-$pconfig['bwdefaultup'] = $config['captiveportal']['bwdefaultup'];
-$pconfig['nomacfilter'] = isset($config['captiveportal']['nomacfilter']);
-$pconfig['noconcurrentlogins'] = isset($config['captiveportal']['noconcurrentlogins']);
-$pconfig['redirurl'] = $config['captiveportal']['redirurl'];
-$pconfig['radiusip'] = $config['captiveportal']['radiusip'];
-$pconfig['radiusip2'] = $config['captiveportal']['radiusip2'];
-$pconfig['radiusport'] = $config['captiveportal']['radiusport'];
-$pconfig['radiusport2'] = $config['captiveportal']['radiusport2'];
-$pconfig['radiusacctport'] = $config['captiveportal']['radiusacctport'];
-$pconfig['radiuskey'] = $config['captiveportal']['radiuskey'];
-$pconfig['radiuskey2'] = $config['captiveportal']['radiuskey2'];
-$pconfig['radiusvendor'] = $config['captiveportal']['radiusvendor'];
-
-//$pconfig['radiussession_timeout'] = isset($config['captiveportal']['radiussession_timeout']);
-
-if ($_POST) {
-
- unset($input_errors);
- $pconfig = $_POST;
-
- /* input validation */
- if ($_POST['enable']) {
- $reqdfields = explode(" ", "cinterface");
- $reqdfieldsn = explode(",", "Interface");
-
- do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
-
- /* make sure no interfaces are bridged */
- for ($i = 1; isset($config['interfaces']['opt' . $i]); $i++) {
- $coptif = $config['interfaces']['opt' . $i];
- if (isset($coptif['enable']) && $coptif['bridge'] == $pconfig['cinterface']) {
- $input_errors[] = "The captive portal cannot be used when one or more interfaces are bridged.";
- break;
- }
- }
-
- if ($_POST['httpslogin_enable']) {
- if (!$_POST['cert'] || !$_POST['key']) {
- $input_errors[] = "Certificate and key must be specified for HTTPS login.";
- } else {
- if (!strstr($_POST['cert'], "BEGIN CERTIFICATE") || !strstr($_POST['cert'], "END CERTIFICATE"))
- $input_errors[] = "This certificate does not appear to be valid.";
- if (!strstr($_POST['key'], "BEGIN RSA PRIVATE KEY") || !strstr($_POST['key'], "END RSA PRIVATE KEY"))
- $input_errors[] = "This key does not appear to be valid.";
- }
-
- if (!$_POST['httpsname'] || !is_domain($_POST['httpsname'])) {
- $input_errors[] = "The HTTPS server name must be specified for HTTPS login.";
- }
- }
- }
-
- if ($_POST['timeout'] && (!is_numeric($_POST['timeout']) || ($_POST['timeout'] < 1))) {
- $input_errors[] = "The timeout must be at least 1 minute.";
- }
- if ($_POST['idletimeout'] && (!is_numeric($_POST['idletimeout']) || ($_POST['idletimeout'] < 1))) {
- $input_errors[] = "The idle timeout must be at least 1 minute.";
- }
- if (($_POST['radiusip'] && !is_ipaddr($_POST['radiusip']))) {
- $input_errors[] = "A valid IP address must be specified. [".$_POST['radiusip']."]";
- }
- if (($_POST['radiusip2'] && !is_ipaddr($_POST['radiusip2']))) {
- $input_errors[] = "A valid IP address must be specified. [".$_POST['radiusip2']."]";
- }
- if (($_POST['radiusport'] && !is_port($_POST['radiusport']))) {
- $input_errors[] = "A valid port number must be specified. [".$_POST['radiusport']."]";
- }
- if (($_POST['radiusport2'] && !is_port($_POST['radiusport2']))) {
- $input_errors[] = "A valid port number must be specified. [".$_POST['radiusport2']."]";
- }
- if (($_POST['radiusacctport'] && !is_port($_POST['radiusacctport']))) {
- $input_errors[] = "A valid port number must be specified. [".$_POST['radiusacctport']."]";
- }
- if ($_POST['maxproc'] && (!is_numeric($_POST['maxproc']) || ($_POST['maxproc'] < 4) || ($_POST['maxproc'] > 100))) {
- $input_errors[] = "The total maximum number of concurrent connections must be between 4 and 100.";
- }
- $mymaxproc = $_POST['maxproc'] ? $_POST['maxproc'] : 16;
- if ($_POST['maxprocperip'] && (!is_numeric($_POST['maxprocperip']) || ($_POST['maxprocperip'] > $mymaxproc))) {
- $input_errors[] = "The maximum number of concurrent connections per client IP address may not be larger than the global maximum.";
- }
-
- if (!$input_errors) {
- $config['captiveportal']['interface'] = $_POST['cinterface'];
- $config['captiveportal']['maxproc'] = $_POST['maxproc'];
- $config['captiveportal']['maxprocperip'] = $_POST['maxprocperip'] ? $_POST['maxprocperip'] : false;
- $config['captiveportal']['timeout'] = $_POST['timeout'];
- $config['captiveportal']['idletimeout'] = $_POST['idletimeout'];
- $config['captiveportal']['enable'] = $_POST['enable'] ? true : false;
- $config['captiveportal']['auth_method'] = $_POST['auth_method'];
- $config['captiveportal']['radacct_enable'] = $_POST['radacct_enable'] ? true : false;
- $config['captiveportal']['reauthenticate'] = $_POST['reauthenticate'] ? true : false;
- $config['captiveportal']['radmac_enable'] = $_POST['radmac_enable'] ? true : false;
- $config['captiveportal']['radmac_secret'] = $_POST['radmac_secret'] ? $_POST['radmac_secret'] : false;
- $config['captiveportal']['reauthenticateacct'] = $_POST['reauthenticateacct'];
- $config['captiveportal']['httpslogin'] = $_POST['httpslogin_enable'] ? true : false;
- $config['captiveportal']['httpsname'] = $_POST['httpsname'];
- $config['captiveportal']['peruserbw'] = $_POST['peruserbw'] ? true : false;
- $config['captiveportal']['bwdefaultdn'] = $_POST['bwdefaultdn'];
- $config['captiveportal']['bwdefaultup'] = $_POST['bwdefaultup'];
- $config['captiveportal']['certificate'] = base64_encode($_POST['cert']);
- $config['captiveportal']['private-key'] = base64_encode($_POST['key']);
- $config['captiveportal']['logoutwin_enable'] = $_POST['logoutwin_enable'] ? true : false;
- $config['captiveportal']['nomacfilter'] = $_POST['nomacfilter'] ? true : false;
- $config['captiveportal']['noconcurrentlogins'] = $_POST['noconcurrentlogins'] ? true : false;
- $config['captiveportal']['redirurl'] = $_POST['redirurl'];
- $config['captiveportal']['radiusip'] = $_POST['radiusip'];
- $config['captiveportal']['radiusip2'] = $_POST['radiusip2'];
- $config['captiveportal']['radiusport'] = $_POST['radiusport'];
- $config['captiveportal']['radiusport2'] = $_POST['radiusport2'];
- $config['captiveportal']['radiusacctport'] = $_POST['radiusacctport'];
- $config['captiveportal']['radiuskey'] = $_POST['radiuskey'];
- $config['captiveportal']['radiuskey2'] = $_POST['radiuskey2'];
- $config['captiveportal']['radiusvendor'] = $_POST['radiusvendor'] ? $_POST['radiusvendor'] : false;
- //$config['captiveportal']['radiussession_timeout'] = $_POST['radiussession_timeout'] ? true : false;
-
- /* file upload? */
- if (is_uploaded_file($_FILES['htmlfile']['tmp_name']))
- $config['captiveportal']['page']['htmltext'] = base64_encode(file_get_contents($_FILES['htmlfile']['tmp_name']));
- if (is_uploaded_file($_FILES['errfile']['tmp_name']))
- $config['captiveportal']['page']['errtext'] = base64_encode(file_get_contents($_FILES['errfile']['tmp_name']));
-
- write_config();
-
- $retval = 0;
-
- config_lock();
- $retval = captiveportal_configure();
- config_unlock();
-
- $savemsg = get_std_save_message($retval);
- }
-}
-include("head.inc");
-?>
-<?php include("fbegin.inc"); ?>
-<script language="JavaScript">
-<!--
-function enable_change(enable_change) {
- var endis, radius_endis;
- endis = !(document.iform.enable.checked || enable_change);
- radius_endis = !((!endis && document.iform.auth_method[2].checked) || enable_change);
-
- document.iform.cinterface.disabled = endis;
- //document.iform.maxproc.disabled = endis;
- document.iform.maxprocperip.disabled = endis;
- document.iform.idletimeout.disabled = endis;
- document.iform.timeout.disabled = endis;
- document.iform.redirurl.disabled = endis;
- document.iform.radiusip.disabled = radius_endis;
- document.iform.radiusip2.disabled = radius_endis;
- document.iform.radiusport.disabled = radius_endis;
- document.iform.radiusport2.disabled = radius_endis;
- document.iform.radiuskey.disabled = radius_endis;
- document.iform.radiuskey2.disabled = radius_endis;
- document.iform.radacct_enable.disabled = radius_endis;
- document.iform.peruserbw.disabled = endis;
- document.iform.bwdefaultdn.disabled = endis;
- document.iform.bwdefaultup.disabled = endis;
- document.iform.reauthenticate.disabled = radius_endis;
- document.iform.auth_method[0].disabled = endis;
- document.iform.auth_method[1].disabled = endis;
- document.iform.auth_method[2].disabled = endis;
- document.iform.radmac_enable.disabled = radius_endis;
- document.iform.httpslogin_enable.disabled = endis;
- document.iform.httpsname.disabled = endis;
- document.iform.cert.disabled = endis;
- document.iform.key.disabled = endis;
- document.iform.logoutwin_enable.disabled = endis;
- document.iform.nomacfilter.disabled = endis;
- document.iform.noconcurrentlogins.disabled = endis;
- document.iform.radiusvendor.disabled = radius_endis;
- //document.iform.radiussession_timeout.disabled = radius_endis;
- document.iform.htmlfile.disabled = endis;
- document.iform.errfile.disabled = endis;
-
- document.iform.radiusacctport.disabled = (radius_endis || !document.iform.radacct_enable.checked) && !enable_change;
-
- document.iform.radmac_secret.disabled = (radius_endis || !document.iform.radmac_enable.checked) && !enable_change;
-
- var reauthenticate_dis = (radius_endis || !document.iform.reauthenticate.checked) && !enable_change;
- document.iform.reauthenticateacct[0].disabled = reauthenticate_dis;
- document.iform.reauthenticateacct[1].disabled = reauthenticate_dis;
- document.iform.reauthenticateacct[2].disabled = reauthenticate_dis;
-}
-//-->
-</script>
-<p class="pgtitle"><?=$pgtitle?></p>
-<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
-<?php if ($input_errors) print_input_errors($input_errors); ?>
-<?php if ($savemsg) print_info_box($savemsg); ?>
-<form action="services_captiveportal.php" method="post" enctype="multipart/form-data" name="iform" id="iform">
-<table width="100%" border="0" cellpadding="0" cellspacing="0">
- <tr><td class="tabnavtbl">
-<?php
- $tab_array = array();
- $tab_array[] = array("Captive portal", true, "services_captiveportal.php");
- $tab_array[] = array("Pass-through MAC", false, "services_captiveportal_mac.php");
- $tab_array[] = array("Allowed IP addresses", false, "services_captiveportal_ip.php");
- $tab_array[] = array("Users", false, "services_captiveportal_users.php");
- $tab_array[] = array("File Manager", false, "services_captiveportal_filemanager.php");
- display_top_tabs($tab_array);
-?> </td></tr>
- <tr>
- <td class="tabcont">
- <table width="100%" border="0" cellpadding="6" cellspacing="0">
- <tr>
- <td width="22%" valign="top" class="vtable">&nbsp;</td>
- <td width="78%" class="vtable">
- <input name="enable" type="checkbox" value="yes" <?php if ($pconfig['enable']) echo "checked"; ?> onClick="enable_change(false)">
- <strong>Enable captive portal </strong></td>
- </tr>
- <tr>
- <td width="22%" valign="top" class="vncellreq">Interface</td>
- <td width="78%" class="vtable">
- <select name="cinterface" class="formfld" id="cinterface">
- <?php $interfaces = array('lan' => 'LAN');
- for ($i = 1; isset($config['interfaces']['opt' . $i]); $i++) {
- if (isset($config['interfaces']['opt' . $i]['enable']))
- $interfaces['opt' . $i] = $config['interfaces']['opt' . $i]['descr'];
- }
- foreach ($interfaces as $iface => $ifacename): ?>
- <option value="<?=$iface;?>" <?php if ($iface == $pconfig['cinterface']) echo "selected"; ?>>
- <?=htmlspecialchars($ifacename);?>
- </option>
- <?php endforeach; ?>
- </select> <br>
- <span class="vexpl">Choose which interface to run the captive portal on.</span></td>
- </tr>
- <tr>
- <td valign="top" class="vncell">Maximum concurrent connections</td>
- <td class="vtable">
- <table cellpadding="0" cellspacing="0">
- <tr>
- <td><input name="maxprocperip" type="text" class="formfld" id="maxprocperip" size="5" value="<?=htmlspecialchars($pconfig['maxprocperip']);?>"> per client IP address (0 = no limit)</td>
- </tr>
- </table>
-This setting limits the number of concurrent connections to the captive portal HTTP(S) server. This does not set how many users can be logged in
-to the captive portal, but rather how many users can load the portal page or authenticate at the same time!
-Default is 4 connections per client IP address, with a total maximum of 16 connections.</td>
- </tr>
- <tr>
- <td valign="top" class="vncell">Idle timeout</td>
- <td class="vtable">
- <input name="idletimeout" type="text" class="formfld" id="idletimeout" size="6" value="<?=htmlspecialchars($pconfig['idletimeout']);?>">
-minutes<br>
-Clients will be disconnected after this amount of inactivity. They may log in again immediately, though. Leave this field blank for no idle timeout.</td>
- </tr>
- <tr>
- <td width="22%" valign="top" class="vncell">Hard timeout</td>
- <td width="78%" class="vtable">
- <input name="timeout" type="text" class="formfld" id="timeout" size="6" value="<?=htmlspecialchars($pconfig['timeout']);?>">
- minutes<br>
- Clients will be disconnected after this amount of time, regardless of activity. They may log in again immediately, though. Leave this field blank for no hard timeout (not recommended unless an idle timeout is set).</td>
- </tr>
- <tr>
- <td width="22%" valign="top" class="vncell">Logout popup window</td>
- <td width="78%" class="vtable">
- <input name="logoutwin_enable" type="checkbox" class="formfld" id="logoutwin_enable" value="yes" <?php if($pconfig['logoutwin_enable']) echo "checked"; ?>>
- <strong>Enable logout popup window</strong><br>
- If enabled, a popup window will appear when clients are allowed through the captive portal. This allows clients to explicitly disconnect themselves before the idle or hard timeout occurs.</td>
- </tr>
- <tr>
- <td valign="top" class="vncell">Redirection URL</td>
- <td class="vtable">
- <input name="redirurl" type="text" class="formfld" id="redirurl" size="60" value="<?=htmlspecialchars($pconfig['redirurl']);?>">
- <br>
-If you provide a URL here, clients will be redirected to that URL instead of the one they initially tried
-to access after they've authenticated.</td>
- </tr>
- <tr>
- <td valign="top" class="vncell">Concurrent user logins</td>
- <td class="vtable">
- <input name="noconcurrentlogins" type="checkbox" class="formfld" id="noconcurrentlogins" value="yes" <?php if ($pconfig['noconcurrentlogins']) echo "checked"; ?>>
- <strong>Disable concurrent logins</strong><br>
- If this option is set, only the most recent login per username will be active. Subsequent logins will cause machines previously logged in with the same username to be disconnected.</td>
- </tr>
- <tr>
- <td valign="top" class="vncell">MAC filtering </td>
- <td class="vtable">
- <input name="nomacfilter" type="checkbox" class="formfld" id="nomacfilter" value="yes" <?php if ($pconfig['nomacfilter']) echo "checked"; ?>>
- <strong>Disable MAC filtering</strong><br>
- If this option is set, no attempts will be made to ensure that the MAC address of clients stays the same while they're logged in.
- This is required when the MAC address of the client cannot be determined (usually because there are routers between <?=$g['product_name']; ?> and the clients).
- If this is enabled, RADIUS MAC authentication cannot be used.</td>
- </tr>
- <tr>
- <td valign="top" class="vncell">Per-user bandwidth restriction</td>
- <td class="vtable">
- <input name="peruserbw" type="checkbox" class="formfld" id="peruserbw" value="yes" <?php if ($pconfig['peruserbw']) echo "checked"; ?>>
- <strong>Enable per-user bandwidth restriction</strong><br><br>
- <table cellpadding="0" cellspacing="0">
- <tr>
- <td>Default download</td>
- <td><input type="text" class="formfld" name="bwdefaultdn" id="bwdefaultdn" size="10" value="<?=htmlspecialchars($pconfig['bwdefaultdn']);?>"> Kbit/s</td>
- </tr>
- <tr>
- <td>Default upload</td>
- <td><input type="text" class="formfld" name="bwdefaultup" id="bwdefaultup" size="10" value="<?=htmlspecialchars($pconfig['bwdefaultup']);?>"> Kbit/s</td>
- </tr></table>
- <br>
- If this option is set, the captive portal will restrict each user who logs in to the specified default bandwidth. RADIUS can override the default settings. Leave empty or set to 0 for no limit.</td>
- </tr>
- <tr>
- <td width="22%" valign="top" class="vncell">Authentication</td>
- <td width="78%" class="vtable">
- <table cellpadding="0" cellspacing="0">
- <tr>
- <td colspan="2"><input name="auth_method" type="radio" id="auth_method" value="none" onClick="enable_change(false)" <?php if($pconfig['auth_method']!="local" && $pconfig['auth_method']!="radius") echo "checked"; ?>>
- No authentication</td>
- </tr>
- <tr>
- <td colspan="2"><input name="auth_method" type="radio" id="auth_method" value="local" onClick="enable_change(false)" <?php if($pconfig['auth_method']=="local") echo "checked"; ?>>
- Local <a href="services_captiveportal_users.php">user manager</a></td>
- </tr>
- <tr>
- <td colspan="2"><input name="auth_method" type="radio" id="auth_method" value="radius" onClick="enable_change(false)" <?php if($pconfig['auth_method']=="radius") echo "checked"; ?>>
- RADIUS authentication</td>
- </tr><tr>
- <td>&nbsp;</td>
- <td>&nbsp;</td>
- </tr>
- </table>
- <table width="100%" border="0" cellpadding="6" cellspacing="0">
- <tr>
- <td colspan="2" valign="top" class="optsect_t2">Primary RADIUS server</td>
- </tr>
- <tr>
- <td class="vncell" valign="top">IP address</td>
- <td class="vtable"><input name="radiusip" type="text" class="formfld" id="radiusip" size="20" value="<?=htmlspecialchars($pconfig['radiusip']);?>"><br>
- Enter the IP address of the RADIUS server which users of the captive portal have to authenticate against.</td>
- </tr>
- <tr>
- <td class="vncell" valign="top">Port</td>
- <td class="vtable"><input name="radiusport" type="text" class="formfld" id="radiusport" size="5" value="<?=htmlspecialchars($pconfig['radiusport']);?>"><br>
- Leave this field blank to use the default port (1812).</td>
- </tr>
- <tr>
- <td class="vncell" valign="top">Shared secret&nbsp;&nbsp;</td>
- <td class="vtable"><input name="radiuskey" type="text" class="formfld" id="radiuskey" size="16" value="<?=htmlspecialchars($pconfig['radiuskey']);?>"><br>
- Leave this field blank to not use a RADIUS shared secret (not recommended).</td>
- </tr>
- <tr>
- <td colspan="2" class="list" height="12"></td>
- </tr>
- <tr>
- <td colspan="2" valign="top" class="optsect_t2">Secondary RADIUS server</td>
- </tr>
- <tr>
- <td class="vncell" valign="top">IP address</td>
- <td class="vtable"><input name="radiusip2" type="text" class="formfld" id="radiusip2" size="20" value="<?=htmlspecialchars($pconfig['radiusip2']);?>"><br>
- If you have a second RADIUS server, you can activate it by entering its IP address here.</td>
- </tr>
- <tr>
- <td class="vncell" valign="top">Port</td>
- <td class="vtable"><input name="radiusport2" type="text" class="formfld" id="radiusport2" size="5" value="<?=htmlspecialchars($pconfig['radiusport2']);?>"></td>
- </tr>
- <tr>
- <td class="vncell" valign="top">Shared secret&nbsp;&nbsp;</td>
- <td class="vtable"><input name="radiuskey2" type="text" class="formfld" id="radiuskey2" size="16" value="<?=htmlspecialchars($pconfig['radiuskey2']);?>"></td>
- </tr>
- <tr>
- <td colspan="2" class="list" height="12"></td>
- </tr>
- <tr>
- <td colspan="2" valign="top" class="optsect_t2">Accounting</td>
- </tr>
- <tr>
- <td class="vncell">&nbsp;</td>
- <td class="vtable"><input name="radacct_enable" type="checkbox" id="radacct_enable" value="yes" onClick="enable_change(false)" <?php if($pconfig['radacct_enable']) echo "checked"; ?>>
- <strong>send RADIUS accounting packets</strong><br>
- If this is enabled, RADIUS accounting packets will be sent to the primary RADIUS server.</td>
- </tr>
- <tr>
- <td class="vncell" valign="top">Accounting port</td>
- <td class="vtable"><input name="radiusacctport" type="text" class="formfld" id="radiusacctport" size="5" value="<?=htmlspecialchars($pconfig['radiusacctport']);?>"><br>
- Leave blank to use the default port (1813).</td>
- </tr>
- <tr>
- <td colspan="2" class="list" height="12"></td>
- </tr>
- <tr>
- <td colspan="2" valign="top" class="optsect_t2">Reauthentication</td>
- </tr>
- <tr>
- <td class="vncell">&nbsp;</td>
- <td class="vtable"><input name="reauthenticate" type="checkbox" id="reauthenticate" value="yes" onClick="enable_change(false)" <?php if($pconfig['reauthenticate']) echo "checked"; ?>>
- <strong>Reauthenticate connected users every minute</strong><br>
- If reauthentication is enabled, Access-Requests will be sent to the RADIUS server for each user that is
- logged in every minute. If an Access-Reject is received for a user, that user is disconnected from the captive portal immediately.</td>
- </tr>
- <tr>
- <td class="vncell" valign="top">Accounting updates</td>
- <td class="vtable">
- <input name="reauthenticateacct" type="radio" value="" <?php if(!$pconfig['reauthenticateacct']) echo "checked"; ?>> no accounting updates<br>
- <input name="reauthenticateacct" type="radio" value="stopstart" <?php if($pconfig['reauthenticateacct'] == "stopstart") echo "checked"; ?>> stop/start accounting<br>
- <input name="reauthenticateacct" type="radio" value="interimupdate" <?php if($pconfig['reauthenticateacct'] == "interimupdate") echo "checked"; ?>> interim update
- </td>
- </tr>
- <tr>
- <td colspan="2" class="list" height="12"></td>
- </tr>
- <tr>
- <td colspan="2" valign="top" class="optsect_t2">RADIUS MAC authentication</td>
- </tr>
- <tr>
- <td class="vncell">&nbsp;</td>
- <td class="vtable">
- <input name="radmac_enable" type="checkbox" id="radmac_enable" value="yes" onClick="enable_change(false)" <?php if ($pconfig['radmac_enable']) echo "checked"; ?>><strong>Enable RADIUS MAC authentication</strong><br>
- If this option is enabled, the captive portal will try to authenticate users by sending their MAC address as the username and the password
- entered below to the RADIUS server.</td>
- </tr>
- <tr>
- <td class="vncell">Shared secret</td>
- <td class="vtable"><input name="radmac_secret" type="text" class="formfld" id="radmac_secret" size="16" value="<?=htmlspecialchars($pconfig['radmac_secret']);?>"></td>
- </tr>
- <tr>
- <td colspan="2" class="list" height="12"></td>
- </tr>
- <tr>
- <td colspan="2" valign="top" class="optsect_t2">RADIUS options</td>
- </tr>
-
- <!--
- <tr>
- <td class="vncell" valign="top">Session-Timeout</td>
- <td class="vtable"><input name="radiussession_timeout" type="checkbox" id="radiussession_timeout" value="yes" <?php if ($pconfig['radiussession_timeout']) echo "checked"; ?>><strong>Use RADIUS Session-Timeout attributes</strong><br>
- When this is enabled, clients will be disconnected after the amount of time retrieved from the RADIUS Session-Timeout attribute.</td>
- </tr>
- -->
-
- <tr>
- <td class="vncell" valign="top">Type</td>
- <td class="vtable"><select name="radiusvendor" id="radiusvendor">
- <option>default</option>
- <?php
- $radiusvendors = array("cisco");
- foreach ($radiusvendors as $radiusvendor){
- if ($pconfig['radiusvendor'] == $radiusvendor)
- echo "<option selected value=\"$radiusvendor\">$radiusvendor</option>\n";
- else
- echo "<option value=\"$radiusvendor\">$radiusvendor</option>\n";
- }
- ?></select><br>
- If RADIUS type is set to Cisco, in Access-Requests the value of Calling-Station-Id will be set to the client's IP address and
- the Called-Station-Id to the client's MAC address. Default behaviour is Calling-Station-Id = client's MAC address and Called-Station-Id = <?=$g['product_name'];?>'s WAN IP address.</td>
- </tr>
- </table>
- </tr>
- <tr>
- <td valign="top" class="vncell">HTTPS login</td>
- <td class="vtable">
- <input name="httpslogin_enable" type="checkbox" class="formfld" id="httpslogin_enable" value="yes" <?php if($pconfig['httpslogin_enable']) echo "checked"; ?>>
- <strong>Enable HTTPS login</strong><br>
- If enabled, the username and password will be transmitted over an HTTPS connection to protect against eavesdroppers. A server name, certificate and matching private key must also be specified below.</td>
- </tr>
- <tr>
- <td valign="top" class="vncell">HTTPS server name </td>
- <td class="vtable">
- <input name="httpsname" type="text" class="formfld" id="httpsname" size="30" value="<?=htmlspecialchars($pconfig['httpsname']);?>"><br>
- This name will be used in the form action for the HTTPS POST and should match the Common Name (CN) in your certificate (otherwise, the client browser will most likely display a security warning). Make sure captive portal clients can resolve this name in DNS and verify on the client that the IP resolves to the correct interface IP on <?=$g['product_name'];?>.. </td>
- </tr>
- <tr>
- <td valign="top" class="vncell">HTTPS certificate</td>
- <td class="vtable">
- <textarea name="cert" cols="65" rows="7" id="cert" class="formpre"><?=htmlspecialchars($pconfig['cert']);?></textarea>
- <br>
- Paste a signed certificate in X.509 PEM format here.</td>
- </tr>
- <tr>
- <td valign="top" class="vncell">HTTPS private key</td>
- <td class="vtable">
- <textarea name="key" cols="65" rows="7" id="key" class="formpre"><?=htmlspecialchars($pconfig['key']);?></textarea>
- <br>
- Paste an RSA private key in PEM format here.</td>
- </tr>
- <tr>
- <td width="22%" valign="top" class="vncellreq">Portal page contents</td>
- <td width="78%" class="vtable">
- <?=$mandfldhtml;?><input type="file" name="htmlfile" class="formfld" id="htmlfile"><br>
- <?php
- list($host) = explode(":", $_SERVER['HTTP_HOST']);
- if(isset($config['captiveportal']['httpslogin'])) {
- $href = "https://$host:8001";
- } else {
- $href = "http://$host:8000";
- }
- ?>
- <?php if ($config['captiveportal']['page']['htmltext']): ?>
- <a href="<?=$href?>" target="_new">View current page</a>
- <br>
- <br>
- <?php endif; ?>
- Upload an HTML file for the portal page here (leave blank to keep the current one). Make sure to include a form (POST to &quot;$PORTAL_ACTION$&quot;)
-with a submit button (name=&quot;accept&quot;) and a hidden field with name=&quot;redirurl&quot; and value=&quot;$PORTAL_REDIRURL$&quot;.
-Include the &quot;auth_user&quot; and &quot;auth_pass&quot; input fields if authentication is enabled, otherwise it will always fail.
-Example code for the form:<br>
- <br>
- <tt>&lt;form method=&quot;post&quot; action=&quot;$PORTAL_ACTION$&quot;&gt;<br>
- &nbsp;&nbsp;&nbsp;&lt;input name=&quot;auth_user&quot; type=&quot;text&quot;&gt;<br>
- &nbsp;&nbsp;&nbsp;&lt;input name=&quot;auth_pass&quot; type=&quot;password&quot;&gt;<br>
- &nbsp;&nbsp;&nbsp;&lt;input name=&quot;redirurl&quot; type=&quot;hidden&quot; value=&quot;$PORTAL_REDIRURL$&quot;&gt;<br>
-&nbsp;&nbsp;&nbsp;&lt;input name=&quot;accept&quot; type=&quot;submit&quot; value=&quot;Continue&quot;&gt;<br>
- &lt;/form&gt;</tt></td>
- </tr>
- <tr>
- <td width="22%" valign="top" class="vncell">Authentication<br>
- error page<br>
- contents</td>
- <td class="vtable">
- <input name="errfile" type="file" class="formfld" id="errfile"><br>
- <?php if ($config['captiveportal']['page']['errtext']): ?>
- <a href="?act=viewerrhtml" target="_blank">View current page</a>
- <br>
- <br>
- <?php endif; ?>
-The contents of the HTML file that you upload here are displayed when an authentication error occurs.
-You may include &quot;$PORTAL_MESSAGE$&quot;, which will be replaced by the error or reply messages from the RADIUS server, if any.</td>
- </tr>
- <tr>
- <td width="22%" valign="top">&nbsp;</td>
- <td width="78%">
- <input name="Submit" type="submit" class="formbtn" value="Save" onClick="enable_change(true)">
- </td>
- </tr>
- <tr>
- <td width="22%" valign="top">&nbsp;</td>
- <td width="78%"><span class="vexpl"><span class="red"><strong>Note:<br>
- </strong></span>Changing any settings on this page will disconnect all clients! Don't forget to enable the DHCP server on your captive portal interface! Make sure that the default/maximum DHCP lease time is higher than the timeout entered on this page. Also, the DNS forwarder needs to be enabled for DNS lookups by unauthenticated clients to work. </span></td>
- </tr>
- </table>
- </td>
- </tr>
- </table>
-</form>
-<script language="JavaScript">
-<!--
-enable_change(false);
-//-->
-</script>
-<?php include("fend.inc"); ?>
-</body>
-</html>
diff --git a/config/Fit123/bin/date/index.abc b/config/Fit123/bin/date/index.abc
deleted file mode 100755
index f63b7001..00000000
--- a/config/Fit123/bin/date/index.abc
+++ /dev/null
@@ -1,264 +0,0 @@
-<?php
-/* $Id$ */
-/*
- index.php
- Copyright (C) 2004, 2005 Scott Ullrich
- All rights reserved.
-
- Originally part of m0n0wall (http://m0n0.ch/wall)
- Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
- 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.
-*/
-
- ## Load Essential Includes
- require_once('guiconfig.inc');
- require_once('notices.inc');
-
-
- ## Load Functions Files
- require_once('includes/functions.inc.php');
-
-
- ## Load AJAX, Initiate Class ###############################################
- require_once('includes/sajax.class.php');
-
- ## Initiate Class and Set location of ajax file containing
- ## the information that we need for this page. Also set functions
- ## that SAJAX will be using.
- $oSajax = new sajax();
- $oSajax->sajax_remote_uri = 'sajax/index.sajax.php';
- $oSajax->sajax_request_type = 'POST';
- $oSajax->sajax_export("get_stats");
- $oSajax->sajax_handle_client_request();
- ############################################################################
-
-
- ## Check to see if we have a swap space,
- ## if true, display, if false, hide it ...
- if(file_exists("/usr/sbin/swapinfo")) {
- $swapinfo = `/usr/sbin/swapinfo`;
- if(stristr($swapinfo,'%') == true) $showswap=true;
- }
-
-
- ## User recently restored his config.
- ## If packages are installed lets resync
- if(file_exists('/conf/needs_package_sync')) {
- if($config['installedpackages'] <> '') {
- conf_mount_rw();
- unlink('/conf/needs_package_sync');
- header('Location: pkg_mgr_install.php?mode=reinstallall');
- exit;
- }
- }
-
-
- ## If it is the first time webGUI has been
- ## accessed since initial install show this stuff.
- if(file_exists('/conf/trigger_initial_wizard')) {
-
- echo <<<EOF
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html>
-<head>
- <title>{$g['product_name']}.local - {$g['product_name']} first time setup</title>
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
- <link rel="stylesheet" type="text/css" href="/niftycssprintCode.css" media="print" />
- <script type="text/javascript">var theme = "nervecenter"</script>
- <script type="text/javascript" src="/themes/nervecenter/loader.js"></script>
-
-EOF;
- echo "<body link=\"#0000CC\" vlink=\"#0000CC\" alink=\"#0000CC\">\n";
-
- if(file_exists("/usr/local/www/themes/{$g['theme']}/wizard.css"))
- echo "<link rel=\"stylesheet\" href=\"/themes/{$g['theme']}/wizard.css\" media=\"all\" />\n";
- else
- echo "<link rel=\"stylesheet\" href=\"/themes/{$g['theme']}/all.css\" media=\"all\" />";
-
- echo "<form>\n";
- echo "<center>\n";
- echo "<img src=\"/themes/{$g['theme']}/images/logo.gif\" border=\"0\"><p>\n";
- echo "<div \" style=\"width:700px;background-color:#ffffff\" id=\"nifty\">\n";
- echo "Welcome to {$g['product_name']}!<p>\n";
- echo "One moment while we start the initial setup wizard.<p>\n";
- echo "Embedded platform users: Please be patient, the wizard takes a little longer to run than the normal GUI.<p>\n";
- echo "To bypass the wizard, click on the {$g['product_name']} logo on the initial page.\n";
- echo "</div>\n";
- echo "<meta http-equiv=\"refresh\" content=\"1;url=wizard.php?xml=setup_wizard.xml\">\n";
- echo "<script type=\"text/javascript\">\n";
- echo "NiftyCheck();\n";
- echo "Rounded(\"div#nifty\",\"all\",\"#AAA\",\"#FFFFFF\",\"smooth\");\n";
- echo "</script>\n";
- exit;
- }
-
-
- ## Find out whether there's hardware encryption or not
- unset($hwcrypto);
- $fd = @fopen("{$g['varlog_path']}/dmesg.boot", "r");
- if ($fd) {
- while (!feof($fd)) {
- $dmesgl = fgets($fd);
- if (preg_match("/^hifn.: (.*?),/", $dmesgl, $matches)) {
- $hwcrypto = $matches[1];
- break;
- }
- }
- fclose($fd);
- }
-
-
- ## Set Page Title and Include Header
- $pgtitle = "{$g['product_name']} webGUI";
- include("head.inc");
-
-?>
-
-<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
-<script language="javascript">
-var ajaxStarted = false;
-</script>
-<?php
-include("fbegin.inc");
- if(!file_exists("/usr/local/www/themes/{$g['theme']}/no_big_logo"))
- echo "<center><img src=\"./themes/".$g['theme']."/images/logobig.jpg\"></center><br>";
-?>
-<?
-exec("/bin/date", $dateOutput, $dateStatus);
-$currentDate = $dateOutput[0];
-?>
-<p class="pgtitle">System Overview</p>
-
-<div id="niftyOutter">
-<form action="index.php" method="post">
-<table bgcolor="#990000" width="100%" border="0" cellspacing="0" cellpadding="0">
- <tbody>
- <tr>
- <td colspan="2" class="listtopic">System information</td>
- </tr>
- <tr>
- <td width="25%" class="vncellt">Name</td>
- <td width="75%" class="listr"><?php echo $config['system']['hostname'] . "." . $config['system']['domain']; ?></td>
- </tr>
- <tr>
- <td width="25%" valign="top" class="vncellt">Version</td>
- <td width="75%" class="listr">
- <strong><?php readfile("/etc/version"); ?></strong>
- <br />
- built on <?php readfile("/etc/version.buildtime"); ?>
- </td>
- </tr>
- <?php if(!$g['hideplatform']): ?>
- <tr>
- <td width="25%" class="vncellt">Platform / Current Date</td>
- <td width="75%" class="listr"><?=htmlspecialchars($g['platform']);?> / <?=$currentDate;?></td>
- </tr>
- <?php endif; ?>
- <?php if ($hwcrypto): ?>
- <tr>
- <td width="25%" class="vncellt">Hardware crypto</td>
- <td width="75%" class="listr"><?=htmlspecialchars($hwcrypto);?></td>
- </tr>
- <?php endif; ?>
- <tr>
- <td width="25%" class="vncellt">Uptime</td>
- <td width="75%" class="listr"><input style="border: 0px solid white;" size="30" name="uptime" id="uptime" value="<?= htmlspecialchars(get_uptime()); ?>" /></td>
- </tr>
- <?php if ($config['lastchange']): ?>
- <tr>
- <td width="25%" class="vncellt">Last config change</td>
- <td width="75%" class="listr"><?= htmlspecialchars(date("D M j G:i:s T Y", $config['revision']['time']));?></td>
- </tr>
- <?php endif; ?>
- <tr>
- <td width="25%" class="vncellt">State table size</td>
- <td width="75%" class="listr">
- <input style="border: 0px solid white;" size="30" name="pfstate" id="pfstate" value="<?= htmlspecialchars(get_pfstate()); ?>" />
- <br />
- <a href="diag_dump_states.php">Show states</a>
- </td>
- </tr>
- <tr>
- <td width="25%" class="vncellt">MBUF Usage</td>
- <td width="75%" class="listr">
- <?php
- $mbufs_inuse=`netstat -mb | grep "mbufs in use" | awk '{ print $1 }' | cut -d"/" -f1`;
- $mbufs_total=`netstat -mb | grep "mbufs in use" | awk '{ print $1 }' | cut -d"/" -f3`;
- ?>
- <?=$mbufs_inuse?>/<?=$mbufs_total?>
- </td>
- </tr>
- <tr>
- <td width="25%" class="vncellt">CPU usage</td>
- <td width="75%" class="listr">
- <?php $cpuUsage = "0"; ?>
- <img src="./themes/<?= $g['theme']; ?>/images/misc/bar_left.gif" height="15" width="4" border="0" align="middle" alt="left bar" /><img src="./themes/<?= $g['theme']; ?>/images/misc/bar_blue.gif" height="15" name="cpuwidtha" id="cpuwidtha" width="<?= $cpuUsage; ?>" border="0" align="middle" alt="red bar" /><img src="./themes/<?= $g['theme']; ?>/images/misc/bar_gray.gif" height="15" name="cpuwidthb" id="cpuwidthb" width="<?= (100 - $cpuUsage); ?>" border="0" align="middle" alt="gray bar" /><img src="./themes/<?= $g['theme']; ?>/images/misc/bar_right.gif" height="15" width="5" border="0" align="middle" alt="right bar" />
- &nbsp;
- <input style="border: 0px solid white;" size="30" name="cpumeter" id="cpumeter" value="(Updating in 5 seconds)" />
- </td>
- </tr>
- <tr>
- <td width="25%" class="vncellt">Memory usage</td>
- <td width="75%" class="listr">
- <?php $memUsage = mem_usage(); ?>
- <img src="./themes/<?= $g['theme']; ?>/images/misc/bar_left.gif" height="15" width="4" border="0" align="middle" alt="left bar" /><img src="./themes/<?= $g['theme']; ?>/images/misc/bar_blue.gif" height="15" name="memwidtha" id="memwidtha" width="<?= $memUsage; ?>" border="0" align="middle" alt="red bar" /><img src="./themes/<?= $g['theme']; ?>/images/misc/bar_gray.gif" height="15" name="memwidthb" id="memwidthb" width="<?= (100 - $memUsage); ?>" border="0" align="middle" alt="gray bar" /><img src="./themes/<?= $g['theme']; ?>/images/misc/bar_right.gif" height="15" width="5" border="0" align="middle" alt="right bar" />
- &nbsp;
- <input style="border: 0px solid white;" size="30" name="memusagemeter" id="memusagemeter" value="<?= $memUsage.'%'; ?>" />
- </td>
- </tr>
- <?php if($showswap == true): ?>
- <tr>
- <td width="25%" class="vncellt">SWAP usage</td>
- <td width="75%" class="listr">
- <?php $swapUsage = swap_usage(); ?>
- <img src="./themes/<?= $g['theme']; ?>/images/misc/bar_left.gif" height="15" width="4" border="0" align="middle" alt="left bar" /><img src="./themes/<?= $g['theme']; ?>/images/misc/bar_blue.gif" height="15" width="<?= $swapUsage; ?>" border="0" align="middle" alt="red bar" /><img src="./themes/<?= $g['theme']; ?>/images/misc/bar_gray.gif" height="15" width="<?= (100 - $swapUsage); ?>" border="0" align="middle" alt="gray bar" /><img src="./themes/<?= $g['theme']; ?>/images/misc/bar_right.gif" height="15" width="5" border="0" align="middle" alt="right bar" />
- &nbsp;
- <input style="border: 0px solid white;" size="30" name="swapusagemeter" id="swapusagemeter" value="<?= $swapUsage.'%'; ?>" />
- </td>
- </tr>
- <?php endif; ?>
- <tr>
- <td width="25%" class="vncellt">Disk usage</td>
- <td width="75%" class="listr">
- <?php $diskusage = disk_usage(); ?>
- <img src="./themes/<?= $g["theme"]; ?>/images/misc/bar_left.gif" height="15" width="4" border="0" align="middle" alt="left bar" /><img src="./themes/<?= $g["theme"]; ?>/images/misc/bar_blue.gif" height="15" width="<?= $diskusage; ?>" border="0" align="middle" alt="red bar" /><img src="./themes/<?= $g["theme"]; ?>/images/misc/bar_gray.gif" height="15" width="<?= (100 - $diskusage); ?>" border="0" align="middle" alt="gray bar" /><img src="./themes/<?= $g["theme"]; ?>/images/misc/bar_right.gif" height="15" width="5" border="0" align="middle" alt="right bar" />
- &nbsp;
- <input style="border: 0px solid white;" size="30" name="diskusagemeter" id="diskusagemeter" value="<?= $diskusage.'%'; ?>" />
- </td>
- </tr>
- </tbody>
-</table>
-</form>
-</div>
-
-<?php include("fend.inc"); ?>
-
-<script type="text/javascript">
- NiftyCheck();
- Rounded("div#nifty","top","#FFF","#EEEEEE","smooth");
-</script>
-
-</body>
-</html>
diff --git a/config/Fit123/bin/dnssrv/system.abc b/config/Fit123/bin/dnssrv/system.abc
deleted file mode 100755
index 898505b9..00000000
--- a/config/Fit123/bin/dnssrv/system.abc
+++ /dev/null
@@ -1,347 +0,0 @@
-<?php
-/* $Id$ */
-/*
- system.php
- part of m0n0wall (http://m0n0.ch/wall)
-
- Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
- 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.
-*/
-
-require("guiconfig.inc");
-
-$pconfig['hostname'] = $config['system']['hostname'];
-$pconfig['domain'] = $config['system']['domain'];
-list($pconfig['dns1'],$pconfig['dns2'],$pconfig['dns3'],$pconfig['dns4']) = $config['system']['dnsserver'];
-
-$pconfig['dnsallowoverride'] = isset($config['system']['dnsallowoverride']);
-$pconfig['username'] = $config['system']['username'];
-if (!$pconfig['username'])
- $pconfig['username'] = "admin";
-$pconfig['webguiproto'] = $config['system']['webgui']['protocol'];
-if (!$pconfig['webguiproto'])
- $pconfig['webguiproto'] = "http";
-$pconfig['webguiport'] = $config['system']['webgui']['port'];
-$pconfig['timezone'] = $config['system']['timezone'];
-$pconfig['timeupdateinterval'] = $config['system']['time-update-interval'];
-$pconfig['timeservers'] = $config['system']['timeservers'];
-$pconfig['theme'] = $config['system']['theme'];
-
-if (!isset($pconfig['timeupdateinterval']))
- $pconfig['timeupdateinterval'] = 300;
-if (!$pconfig['timezone'])
- $pconfig['timezone'] = "Etc/UTC";
-if (!$pconfig['timeservers'])
- $pconfig['timeservers'] = "pool.ntp.org";
-
-$changedesc = "System: ";
-$changecount = 0;
-
-function is_timezone($elt) {
- return !preg_match("/\/$/", $elt);
-}
-
-if($pconfig['timezone'] <> $_POST['timezone']) {
- /* restart firewall log dumper helper */
- require_once("functions.inc");
- $pid = `ps awwwux | grep -v "grep" | grep "tcpdump -v -l -n -e -ttt -i pflog0" | awk '{ print $2 }'`;
- if($pid) {
- mwexec("kill $pid");
- usleep(1000);
- }
- filter_pflog_start();
-}
-
-exec('/usr/bin/tar -tzf /usr/share/zoneinfo.tgz', $timezonelist);
-$timezonelist = array_filter($timezonelist, 'is_timezone');
-sort($timezonelist);
-
-if ($_POST) {
-
- $changecount++;
-
- unset($input_errors);
- $pconfig = $_POST;
-
- /* input validation */
- $reqdfields = split(" ", "hostname domain username");
- $reqdfieldsn = split(",", "Hostname,Domain,Username");
-
- do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
-
- if ($_POST['hostname'] && !is_hostname($_POST['hostname'])) {
- $input_errors[] = "The hostname may only contain the characters a-z, 0-9 and '-'.";
- }
- if ($_POST['domain'] && !is_domain($_POST['domain'])) {
- $input_errors[] = "The domain may only contain the characters a-z, 0-9, '-' and '.'.";
- }
- if (($_POST['dns1'] && !is_ipaddr($_POST['dns1'])) || ($_POST['dns2'] && !is_ipaddr($_POST['dns2'])) || ($_POST['dns3'] && !is_ipaddr($_POST['dns3'])) || ($_POST['dns4'] && !is_ipaddr($_POST['dns4']))) {
- $input_errors[] = "A valid IP address must be specified for the primary/secondary DNS server.";
- }
- if ($_POST['username'] && !preg_match("/^[a-zA-Z0-9]*$/", $_POST['username'])) {
- $input_errors[] = "The username may only contain the characters a-z, A-Z and 0-9.";
- }
- if ($_POST['webguiport'] && (!is_numericint($_POST['webguiport']) ||
- ($_POST['webguiport'] < 1) || ($_POST['webguiport'] > 65535))) {
- $input_errors[] = "A valid TCP/IP port must be specified for the webGUI port.";
- }
- if (($_POST['password']) && ($_POST['password'] != $_POST['password2'])) {
- $input_errors[] = "The passwords do not match.";
- }
-
- $t = (int)$_POST['timeupdateinterval'];
- if (($t < 0) || (($t > 0) && ($t < 6)) || ($t > 1440)) {
- $input_errors[] = "The time update interval must be either 0 (disabled) or between 6 and 1440.";
- }
- foreach (explode(' ', $_POST['timeservers']) as $ts) {
- if (!is_domain($ts)) {
- $input_errors[] = "A NTP Time Server name may only contain the characters a-z, 0-9, '-' and '.'.";
- }
- }
-
- if (!$input_errors) {
- update_if_changed("hostname", $config['system']['hostname'], strtolower($_POST['hostname']));
- update_if_changed("domain", $config['system']['domain'], strtolower($_POST['domain']));
- update_if_changed("username", $config['system']['username'], $_POST['username']);
-
- if (update_if_changed("webgui protocol", $config['system']['webgui']['protocol'], $_POST['webguiproto']))
- $restart_webgui = true;
- if (update_if_changed("webgui port", $config['system']['webgui']['port'], $_POST['webguiport']))
- $restart_webgui = true;
-
- update_if_changed("timezone", $config['system']['timezone'], $_POST['timezone']);
- update_if_changed("NTP servers", $config['system']['timeservers'], strtolower($_POST['timeservers']));
- update_if_changed("NTP update interval", $config['system']['time-update-interval'], $_POST['timeupdateinterval']);
-
- /* pfSense themes */
- update_if_changed("System Theme", $config['theme'], $_POST['theme']);
-
- /* XXX - billm: these still need updating after figuring out how to check if they actually changed */
- unset($config['system']['dnsserver']);
- if ($_POST['dns1'])
- $config['system']['dnsserver'][] = $_POST['dns1'];
- if ($_POST['dns2'])
- $config['system']['dnsserver'][] = $_POST['dns2'];
- if ($_POST['dns3'])
- $config['system']['dnsserver'][] = $_POST['dns3'];
- if ($_POST['dns4'])
- $config['system']['dnsserver'][] = $_POST['dns4'];
-
- $olddnsallowoverride = $config['system']['dnsallowoverride'];
-
- unset($config['system']['dnsallowoverride']);
- $config['system']['dnsallowoverride'] = $_POST['dnsallowoverride'] ? true : false;
- if ($_POST['password']) {
- $config['system']['password'] = crypt($_POST['password']);
- update_changedesc("password changed via webConfigurator");
- sync_webgui_passwords();
- }
-
- if ($changecount > 0)
- write_config($changedesc);
-
- if ($restart_webgui) {
- global $_SERVER;
- list($host) = explode(":", $_SERVER['HTTP_HOST']);
- if ($config['system']['webgui']['port']) {
- $url="{$config['system']['webgui']['protocol']}://{$host}:{$config['system']['webgui']['port']}/system.php";
- } else {
- $url = "{$config['system']['webgui']['protocol']}://{$host}/system.php";
- }
- }
-
- $retval = 0;
- config_lock();
- $retval = system_hostname_configure();
- $retval |= system_hosts_generate();
- $retval |= system_resolvconf_generate();
- $retval |= system_password_configure();
- $retval |= services_dnsmasq_configure();
- $retval |= system_timezone_configure();
- $retval |= system_ntp_configure();
-
- if ($olddnsallowoverride != $config['system']['dnsallowoverride'])
- $retval |= interfaces_wan_configure();
-
- config_unlock();
-
- // Reload filter -- plugins might need to run
- filter_configure();
-
- $savemsg = get_std_save_message($retval);
- if ($restart_webgui)
- $savemsg .= "<br />One moment...redirecting to {$url} in 10 seconds.";
- }
-}
-
-$pgtitle = "System: General Setup";
-include("head.inc");
-
-?>
-
-<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
-<?php include("fbegin.inc"); ?>
-<p class="pgtitle"><?=$pgtitle?></p>
-<?php if ($input_errors) print_input_errors($input_errors); ?>
-<?php if ($savemsg) print_info_box($savemsg); ?>
-<form action="system.php" method="post">
- <table width="100%" border="0" cellpadding="6" cellspacing="0">
- <tr>
- <td width="22%" valign="top" class="vncellreq">Hostname</td>
- <td width="78%" class="vtable"> <input name="hostname" type="text" class="formfld" id="hostname" size="40" value="<?=htmlspecialchars($pconfig['hostname']);?>">
- <br> <span class="vexpl">name of the firewall host, without
- domain part<br>
- e.g. <em>firewall</em></span></td>
- </tr>
- <tr>
- <td width="22%" valign="top" class="vncellreq">Domain</td>
- <td width="78%" class="vtable"> <input name="domain" type="text" class="formfld" id="domain" size="40" value="<?=htmlspecialchars($pconfig['domain']);?>">
- <br> <span class="vexpl">e.g. <em>mycorp.com</em> </span></td>
- </tr>
- <tr>
- <td width="22%" valign="top" class="vncell">DNS servers</td>
- <td width="78%" class="vtable"> <p>
- <input name="dns1" type="text" class="formfld" id="dns1" size="20" value="<?=htmlspecialchars($pconfig['dns1']);?>">
- <br>
- <input name="dns2" type="text" class="formfld" id="dns22" size="20" value="<?=htmlspecialchars($pconfig['dns2']);?>">
- <br>
- <input name="dns3" type="text" class="formfld" id="dns3" size="20" value="<?=htmlspecialchars($pconfig['dns3']);?>">
- <br>
- <input name="dns4" type="text" class="formfld" id="dns4" size="20" value="<?=htmlspecialchars($pconfig['dns4']);?>">
- <br>
- <span class="vexpl">IP addresses; these are also used for
- the DHCP service, DNS forwarder and for PPTP VPN clients<br>
- <br>
- <input name="dnsallowoverride" type="checkbox" id="dnsallowoverride" value="yes" <?php if ($pconfig['dnsallowoverride']) echo "checked"; ?>>
- <strong>Allow DNS server list to be overridden by DHCP/PPP
- on WAN</strong><br>
- If this option is set, <?=$g['product_name']?> will use DNS servers assigned
- by a DHCP/PPP server on WAN for its own purposes (including
- the DNS forwarder). They will not be assigned to DHCP and
- PPTP VPN clients, though.</span></p></td>
- </tr>
- <tr>
- <td valign="top" class="vncell">Username</td>
- <td class="vtable"> <input name="username" type="text" class="formfld" id="username" size="20" value="<?=$pconfig['username'];?>">
- <br>
- <span class="vexpl">If you want
- to change the username for accessing the webGUI, enter it
- here.</span></td>
- </tr>
- <tr>
- <td width="22%" valign="top" class="vncell">Password</td>
- <td width="78%" class="vtable"> <input name="password" type="password" class="formfld" id="password" size="20">
- <br> <input name="password2" type="password" class="formfld" id="password2" size="20">
- &nbsp;(confirmation) <br> <span class="vexpl">If you want
- to change the password for accessing the webGUI, enter it
- here twice.</span></td>
- </tr>
- <tr>
- <td width="22%" valign="top" class="vncell">webGUI protocol</td>
- <td width="78%" class="vtable"> <input name="webguiproto" type="radio" value="http" <?php if ($pconfig['webguiproto'] == "http") echo "checked"; ?>>
- HTTP &nbsp;&nbsp;&nbsp; <input type="radio" name="webguiproto" value="https" <?php if ($pconfig['webguiproto'] == "https") echo "checked"; ?>>
- HTTPS</td>
- </tr>
- <tr>
- <td valign="top" class="vncell">webGUI port</td>
- <td class="vtable"> <input name="webguiport" type="text" class="formfld" id="webguiport" "size="5" value="<?=htmlspecialchars($config['system']['webgui']['port']);?>">
- <br>
- <span class="vexpl">Enter a custom port number for the webGUI
- above if you want to override the default (80 for HTTP, 443
- for HTTPS). Changes will take effect immediately after save.</span></td>
- </tr>
- <tr>
- <td width="22%" valign="top" class="vncell">Time zone</td>
- <td width="78%" class="vtable"> <select name="timezone" id="timezone">
- <?php foreach ($timezonelist as $value): ?>
- <option value="<?=htmlspecialchars($value);?>" <?php if ($value == $pconfig['timezone']) echo "selected"; ?>>
- <?=htmlspecialchars($value);?>
- </option>
- <?php endforeach; ?>
- </select> <br> <span class="vexpl">Select the location closest
- to you</span></td>
- </tr>
- <!--
- <tr>
- <td width="22%" valign="top" class="vncell">Time update interval</td>
- <td width="78%" class="vtable"> <input name="timeupdateinterval" type="text" class="formfld" id="timeupdateinterval" size="4" value="<?=htmlspecialchars($pconfig['timeupdateinterval']);?>">
- <br> <span class="vexpl">Minutes between network time sync.;
- 300 recommended, or 0 to disable </span></td>
- </tr>
- -->
- <tr>
- <td width="22%" valign="top" class="vncell">NTP time server</td>
- <td width="78%" class="vtable"> <input name="timeservers" type="text" class="formfld" id="timeservers" size="40" value="<?=htmlspecialchars($pconfig['timeservers']);?>">
- <br> <span class="vexpl">Use a space to separate multiple
- hosts (only one required). Remember to set up at least one
- DNS server if you enter a host name here!</span></td>
- </tr>
- <tr>
- <td colspan="2" class="list" height="12">&nbsp;</td>
- </tr>
- <tr>
- <td colspan="2" valign="top" class="listtopic">Theme</td>
- </tr>
- <tr>
- <td width="22%" valign="top" class="vncell">&nbsp;</td>
- <td width="78%" class="vtable">
- <select name="theme">
-<?php
- $files = return_dir_as_array("/usr/local/www/themes/");
- foreach($files as $f) {
- if ( (substr($f, 0, 1) == "_") && !isset($config['system']['developer']) ) continue;
- if($f == "CVS") continue;
- $selected = "";
- if($f == $config['theme'])
- $selected = " SELECTED";
- if($config['theme'] == "" and $f == "pfsense")
- $selceted = " SELECTED";
- echo "\t\t\t\t\t"."<option{$selected}>{$f}</option>\n";
- }
-?>
- </select>
- <strong>This will change the look and feel of <?=$g['product_name']?></strong>
- </td>
- </tr>
- <tr>
- <td width="22%" valign="top">&nbsp;</td>
- <td width="78%"> <input name="Submit" type="submit" class="formbtn" value="Save">
- </td>
- </tr>
- </table>
-</form>
-<?php include("fend.inc"); ?>
-<?php
- // restart webgui if proto or port changed
- if ($restart_webgui) {
- echo "<meta http-equiv=\"refresh\" content=\"10;url={$url}\">";
- }
-?>
-</body>
-</html>
-<?php
-if ($restart_webgui) {
- touch("/tmp/restart_webgui");
-}
-?>
diff --git a/config/Fit123/bin/ltsp/services.inc b/config/Fit123/bin/ltsp/services.inc
deleted file mode 100644
index f999868a..00000000
--- a/config/Fit123/bin/ltsp/services.inc
+++ /dev/null
@@ -1,1320 +0,0 @@
-<?php
-/* $Id$ */
-/*
- services.inc
- part of m0n0wall (http://m0n0.ch/wall)
-
- Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
- 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.
-*/
-
-/* include all configuration functions */
-require_once("functions.inc");
-
-function load_balancer_use_sticky() {
- global $config, $g;
- if (isset ($config['system']['lb_use_sticky']))
- touch("/var/etc/use_pf_pool__stickyaddr");
- else
- unlink_if_exists("/var/etc/use_pf_pool__stickyaddr");
-}
-
-function services_dhcpd_configure() {
- global $config, $g;
- if(isset($config['system']['developerspew'])) {
- $mt = microtime();
- echo "services_dhcpd_configure($if) being called $mt\n";
- }
-
- /* if OLSRD is enabled, allow WAN to house DHCP. */
- if($config['installedpackages']['olsrd'])
- foreach($config['installedpackages']['olsrd']['config'] as $olsrd)
- if($olsrd['enable'])
- $is_olsr_enabled = true;
-
- /* configure DHCPD chroot */
- $fd = fopen("/tmp/dhcpd.sh","w");
- $status = `mount | grep "{$g['dhcpd_chroot_path']}/dev"`;
- fwrite($fd, "mkdir -p {$g['dhcpd_chroot_path']}\n");
- fwrite($fd, "mkdir -p {$g['dhcpd_chroot_path']}/dev\n");
- fwrite($fd, "mkdir -p {$g['dhcpd_chroot_path']}/etc\n");
- fwrite($fd, "mkdir -p {$g['dhcpd_chroot_path']}/usr/local/sbin\n");
- fwrite($fd, "mkdir -p {$g['dhcpd_chroot_path']}/var/db\n");
- fwrite($fd, "mkdir -p {$g['dhcpd_chroot_path']}/var/run\n");
- fwrite($fd, "mkdir -p {$g['dhcpd_chroot_path']}/usr\n");
- fwrite($fd, "mkdir -p {$g['dhcpd_chroot_path']}/lib\n");
- fwrite($fd, "mkdir -p {$g['dhcpd_chroot_path']}/run\n");
- fwrite($fd, "chown -R dhcpd:_dhcp {$g['dhcpd_chroot_path']}/*\n");
- fwrite($fd, "cp /lib/libc.so.* {$g['dhcpd_chroot_path']}/lib/\n");
- fwrite($fd, "cp /usr/local/sbin/dhcpd {$g['dhcpd_chroot_path']}/usr/local/sbin/\n");
- fwrite($fd, "chmod a+rx {$g['dhcpd_chroot_path']}/usr/local/sbin/dhcpd\n");
- if(!trim($status))
- fwrite($fd, "mount -t devfs devfs {$g['dhcpd_chroot_path']}/dev\n");
- fclose($fd);
- mwexec("/bin/sh /tmp/dhcpd.sh");
-
- /* kill any running dhcpd */
- if(is_process_running("dhcpd"))
- mwexec("killall dhcpd", true);
-
- $syscfg = $config['system'];
- $dhcpdcfg = $config['dhcpd'];
-
- /* DHCP enabled on any interfaces? */
- $dhcpdenable = false;
- if(is_array($dhcpdcfg))
- foreach ($dhcpdcfg as $dhcpif => $dhcpifconf) {
- if (isset($dhcpifconf['enable']) &&
- (($dhcpif == "lan") ||
- (isset($config['interfaces'][$dhcpif]['enable']) &&
- $config['interfaces'][$dhcpif]['if'] && (!$config['interfaces'][$dhcpif]['bridge']))))
- $dhcpdenable = true;
- if (isset($dhcpifconf['enable']) &&
- (($dhcpif == "wan") || (isset($config['interfaces'][$dhcpif]['enable']) &&
- $config['interfaces'][$dhcpif]['if'] && (!$config['interfaces'][$dhcpif]['bridge']))))
- $dhcpdenable = true;
- }
-
- if (!$dhcpdenable)
- return 0;
-
- if ($g['booting'])
- echo "Starting DHCP service...";
- else
- sleep(1);
-
- /* write dhcpd.conf */
- $fd = fopen("{$g['dhcpd_chroot_path']}/etc/dhcpd.conf", "w");
- if (!$fd) {
- printf("Error: cannot open dhcpd.conf in services_dhcpd_configure().\n");
- return 1;
- }
-
-
-
- $dhcpdconf = <<<EOD
-option domain-name "{$syscfg['domain']}";
-default-lease-time 7200;
-max-lease-time 86400;
-authoritative;
-log-facility local7;
-ddns-update-style none;
-one-lease-per-client true;
-deny duplicates;
-
-EOD;
-
- $dhcpdifs = array();
-
- /* loop through and deterimine if we need to setup
- * failover peer "bleh" entries
- */
- $dhcpnum = 0;
- foreach ($dhcpdcfg as $dhcpif => $dhcpifconf) {
- if($dhcpifconf['failover_peerip'] <> "") {
- /*
- * yep, failover peer is defined.
- * does it match up to a defined vip?
- */
- $skew = 110;
- $a_vip = &$config['virtualip']['vip'];
- if(is_array($a_vip)) {
- foreach ($a_vip as $vipent) {
- $int = guess_interface_from_ip($dhcpifconf['failover_peerip']);
- $intip = find_interface_ip($int);
- $real_dhcpif = convert_friendly_interface_to_real_interface_name($dhcpif);
- if($int == $real_dhcpif) {
- /* this is the interface! */
- if($vipent['advskew'] < "20")
- $skew = 0;
- }
- }
- } else {
- log_error("Warning! DHCP Failover setup and no CARP virtual IP's defined!");
- }
- if($skew > 10) {
- $type = "secondary";
- $dhcpdconf_pri = "mclt 600;\n";
- $my_port = "520";
- $peer_port = "519";
- } else {
- $my_port = "519";
- $peer_port = "520";
- $type = "primary";
- $dhcpdconf_pri = "split 128;\n";
- $dhcpdconf_pri .= " mclt 600;\n";
- }
- $dhcpdconf .= <<<EOPP
-failover peer "dhcp{$dhcpnum}" {
- {$type};
- address {$intip};
- port {$my_port};
- peer address {$dhcpifconf['failover_peerip']};
- peer port {$peer_port};
- max-response-delay 10;
- max-unacked-updates 10;
- {$dhcpdconf_pri}
- load balance max seconds 3;
-}
-
-EOPP;
- $dhcpnum++;
- }
- }
-
- $dhcpnum = 0;
-
- foreach ($dhcpdcfg as $dhcpif => $dhcpifconf) {
-
- $ifcfg = $config['interfaces'][$dhcpif];
-
- if (!isset($dhcpifconf['enable']) ||
- ($ifcfg['ipaddr'] == "dhcp") ||
- (($dhcpif != "lan") &&
- (!isset($ifcfg['enable']) || !$ifcfg['if'] || $ifcfg['bridge'])))
- continue;
-
- if($dhcpif == "lan" && $ifcfg['bridge'])
- log_error("NOTE: DHCP Server on LAN is enabled.");
-
- $subnet = gen_subnet($ifcfg['ipaddr'], $ifcfg['subnet']);
- $subnetmask = gen_subnet_mask($ifcfg['subnet']);
-
- if($is_olsr_enabled == true)
- if($dhcpifconf['netmask'])
- $subnetmask = gen_subnet_mask($dhcpifconf['netmask']);
-
- $dnscfg = "";
-
- if ($dhcpifconf['domain']) {
- $dnscfg .= " option domain-name \"{$dhcpifconf['domain']}\";\n";
- }
- if (isset($dhcpifconf['ddnsupdate'])) {
- if($dhcpifconf['ddnsdomain'] <> "") {
- $dnscfg .= " ddns-domainname \"{$dhcpifconf['ddnsdomain']}\";\n";
- }
- $dnscfg .= " ddns-update-style interim;\n";
- }
-
-
- if (is_array($dhcpifconf['dnsserver']) && ($dhcpifconf['dnsserver'][0])) {
- $dnscfg .= " option domain-name-servers " . join(",", $dhcpifconf['dnsserver']) . ";";
- } else if (isset($config['dnsmasq']['enable'])) {
- $dnscfg .= " option domain-name-servers " . $ifcfg['ipaddr'] . ";";
- } else if (is_array($syscfg['dnsserver']) && ($syscfg['dnsserver'][0])) {
- $dnscfg .= " option domain-name-servers " . join(",", $syscfg['dnsserver']) . ";";
- }
-
- $dhcpdconf .= "subnet $subnet netmask $subnetmask {\n";
- $dhcpdconf .= " pool {\n";
-
- /* is failover dns setup? */
- if (is_array($dhcpifconf['dnsserver']) && $dhcpifconf['dnsserver'][0] <> "") {
- $dhcpdconf .= " option domain-name-servers {$dhcpifconf['dnsserver'][0]}";
- if($dhcpifconf['dnsserver'][1] <> "")
- $dhcpdconf .= ",{$dhcpifconf['dnsserver'][1]}";
- $dhcpdconf .= ";\n";
- }
-
- if($dhcpifconf['failover_peerip'] <> "")
- $dhcpdconf .= " deny dynamic bootp clients;\n";
-
- if (isset($dhcpifconf['denyunknown']))
- $dhcpdconf .= " deny unknown clients;\n";
-
- if ($dhcpifconf['gateway'])
- $routers = $dhcpifconf['gateway'];
- else
- $routers = $ifcfg['ipaddr'];
-
- if($dhcpifconf['failover_peerip'] <> "") {
- $dhcpdconf .= " failover peer \"dhcp{$dhcpnum}\";\n";
- $dhcpnum++;
- }
-
- $dhcpdconf .= <<<EOD
- range {$dhcpifconf['range']['from']} {$dhcpifconf['range']['to']};
- }
- option routers {$routers};
-$dnscfg
-
-EOD;
-
- if ($dhcpifconf['defaultleasetime'])
- $dhcpdconf .= " default-lease-time {$dhcpifconf['defaultleasetime']};\n";
- if ($dhcpifconf['maxleasetime'])
- $dhcpdconf .= " max-lease-time {$dhcpifconf['maxleasetime']};\n";
-
- if (is_array($dhcpifconf['winsserver']) && $dhcpifconf['winsserver'][0]) {
- $dhcpdconf .= " option netbios-name-servers " . join(",", $dhcpifconf['winsserver']) . ";\n";
- $dhcpdconf .= " option netbios-node-type 8;\n";
- }
-
- if (is_array($dhcpifconf['ntpserver']) && $dhcpifconf['ntpserver'][0])
- $dhcpdconf .= " option ntp-servers " . join(",", $dhcpifconf['ntpserver']) . ";\n";
-
- if(isset($dhcpifconf['netboot'])) {
- if (($dhcpifconf['next-server'] <> "") && ($dhcpifconf['filename'] <> "")) {
- $dhcpdconf .= " next-server {$dhcpifconf['next-server']};\n";
- $dhcpdconf .= " filename \"{$dhcpifconf['filename']}\";\n";
- }
- if ($dhcpifconf['rootpath'] <> "") {
- $dhcpdconf .= " option root-path \"{$dhcpifconf['rootpath']}\";\n";
- }
- }
- $dhcpdconf .= <<<EOD
-}
-
-EOD;
-
- /* add static mappings */
- if (is_array($dhcpifconf['staticmap'])) {
-
- $i = 0;
- foreach ($dhcpifconf['staticmap'] as $sm) {
- $dhcpdconf .= <<<EOD
-host s_{$dhcpif}_{$i} {
- hardware ethernet {$sm['mac']};
-
-EOD;
- if ($sm['ipaddr'])
- $dhcpdconf .= " fixed-address {$sm['ipaddr']};\n";
-
- $dhcpdconf .= "}\n";
- $i++;
- }
- }
-
- $dhcpdifs[] = $ifcfg['if'];
- }
-
- fwrite($fd, $dhcpdconf);
- fclose($fd);
-
- /* create an empty leases database */
- touch("{$g['dhcpd_chroot_path']}/var/db/dhcpd.leases");
-
- /* fire up dhcpd in a chroot */
- mwexec("/usr/local/sbin/dhcpd -user dhcpd -group _dhcp -chroot {$g['dhcpd_chroot_path']} -cf {$g['dhcpd_chroot_path']}/etc/dhcpd.conf " .
- join(" ", $dhcpdifs));
-
- if ($g['booting']) {
- print "done.\n";
- }
-
- return 0;
-}
-
-function interfaces_staticarp_configure($if) {
- global $config, $g;
- if(isset($config['system']['developerspew'])) {
- $mt = microtime();
- echo "interfaces_staticarp_configure($if) being called $mt\n";
- }
-
- $ifcfg = $config['interfaces'][$if];
-
- /* Enable staticarp, if enabled */
- if(isset($config['dhcpd'][$if]['staticarp'])) {
- mwexec("/sbin/ifconfig " . escapeshellarg($ifcfg['if']) . " staticarp " );
- mwexec("/usr/sbin/arp -ad > /dev/null 2>&1 ");
- if (is_array($config['dhcpd'][$if]['staticmap'])) {
-
- foreach ($config['dhcpd'][$if]['staticmap'] as $arpent) {
- mwexec("/usr/sbin/arp -s " . escapeshellarg($arpent['ipaddr']) . " " . escapeshellarg($arpent['mac']));
- log_error("/usr/sbin/arp -s " . escapeshellarg($arpent['ipaddr']) . " " . escapeshellarg($arpent['mac']));
- }
-
- }
- } else {
- mwexec("/sbin/ifconfig " . escapeshellarg($ifcfg['if']) . " -staticarp " );
- mwexec("/usr/sbin/arp -da > /dev/null 2>&1 ");
- }
-
- return 0;
-}
-
-function services_dhcrelay_configure() {
- global $config, $g;
- if(isset($config['system']['developerspew'])) {
- $mt = microtime();
- echo "services_dhcrelay_configure() being called $mt\n";
- }
-
- /* kill any running dhcrelay */
- killbypid("{$g['varrun_path']}/dhcrelay.pid");
-
- $dhcrelaycfg = $config['dhcrelay'];
-
- /* DHCPRelay enabled on any interfaces? */
- $dhcrelayenable = false;
- if(is_array($dhcrelaycfg)) {
- foreach ($dhcrelaycfg as $dhcrelayif => $dhcrelayifconf) {
- if (isset($dhcrelayifconf['enable']) &&
- (($dhcrelayif == "lan") ||
- (isset($config['interfaces'][$dhcrelayif]['enable']) &&
- $config['interfaces'][$dhcrelayif]['if'] && (!$config['interfaces'][$dhcrelayif]['bridge']))))
- $dhcrelayenable = true;
- }
- }
-
- if (!$dhcrelayenable)
- return 0;
-
- if ($g['booting'])
- echo "Starting DHCP relay service...";
- else
- sleep(1);
-
- $dhcrelayifs = array();
- foreach ($dhcrelaycfg as $dhcrelayif => $dhcrelayifconf) {
-
- $ifcfg = $config['interfaces'][$dhcrelayif];
-
- if (!isset($dhcrelayifconf['enable']) ||
- (($dhcrelayif != "lan") &&
- (!isset($ifcfg['enable']) || !$ifcfg['if'] || $ifcfg['bridge'])))
- continue;
-
- $dhcrelayifs[] = $ifcfg['if'];
- }
-
- /* In order for the relay to work, it needs to be active on the
- interface in which the destination server sits */
- foreach ($config['interfaces'] as $ifname) {
- $subnet = $ifname['ipaddr'] . "/" . $ifname['subnet'];
- if (ip_in_subnet($dhcrelaycfg['server'],$subnet))
- $destif = $ifname['if'];
- }
-
- if (!isset($destif))
- $destif = $config['interfaces']['wan']['if'];
-
- $dhcrelayifs[] = $destif;
- $dhcrelayifs = array_unique($dhcrelayifs);
-
- /* fire up dhcrelay */
- $cmd = "/usr/local/sbin/dhcrelay -i " . join(" -i ", $dhcrelayifs);
-
- if (isset($dhcrelaycfg['agentoption']))
- $cmd .= " -a -m replace";
-
- $cmd .= " {$dhcrelaycfg['server']}";
- mwexec($cmd);
-
- if (!$g['booting']) {
- /* set the reload filter dity flag */
- touch("{$g['tmp_path']}/filter_dirty");
- }
-
- return 0;
-}
-
-function services_dyndns_reset() {
- global $config, $g;
- if(isset($config['system']['developerspew'])) {
- $mt = microtime();
- echo "services_dyndns_reset() being called $mt\n";
- }
-
- if (file_exists("{$g['vardb_path']}/ez-ipupdate.cache")) {
- conf_mount_rw();
- unlink("{$g['vardb_path']}/ez-ipupdate.cache");
- conf_mount_ro();
- }
-
- if (file_exists("{$g['conf_path']}/ez-ipupdate.cache")) {
- conf_mount_rw();
- unlink("{$g['conf_path']}/ez-ipupdate.cache");
- conf_mount_ro();
- }
-
- if (file_exists("{$g['conf_path']}/dyndns.cache")) {
- conf_mount_rw();
- unlink("{$g['conf_path']}/dyndns.cache");
- conf_mount_ro();
- }
-
- return 0;
-}
-
-function services_dyndns_configure() {
- global $config, $g;
- if(isset($config['system']['developerspew'])) {
- $mt = microtime();
- echo "services_dyndns_configure() being called $mt\n";
- }
-
- $dyndnscfg = $config['dyndns'];
- $wancfg = $config['interfaces']['wan'];
-
- if (isset($dyndnscfg['enable'])) {
-
- if ($g['booting']) {
- echo "Starting DynDNS client...";
- if(isset($config['system']['use_old_dyndns'])) {
- echo " [Using ez-ipupdate] ";
- services_dyndns_configure_old();
- return;
- }
- } else {
- sleep(1);
- if(isset($config['system']['use_old_dyndns'])) {
- services_dyndns_configure_old();
- return;
- }
- }
-
- /* load up the dyndns.class */
- require_once("dyndns.class");
-
- log_error("DynDns: Running updatedns()");
-
- /* determine WAN interface name */
- $wanif = get_real_wan_interface();
- /* get ip */
- $ip = find_interface_ip($wanif);
-
- $dns = new updatedns($dnsService = $config['dyndns']['type'],
- $dnsHost = $config['dyndns']['host'],
- $dnsUser = $config['dyndns']['username'],
- $dnsPass = $config['dyndns']['password'],
- $dnsWilcard = $config['dyndns']['wildcard'],
- $dnsMX = $config['dyndns']['mx']);
-
- if ($g['booting'])
- echo "done.\n";
- }
-
- return 0;
-}
-
-function services_dyndns_configure_old() {
- global $config, $g;
- if(isset($config['system']['developerspew'])) {
- $mt = microtime();
- echo "services_dyndns_configure_old() being called $mt\n";
- }
-
- /* kill any running ez-ipupdate */
- /* ez-ipupdate needs SIGQUIT instead of SIGTERM */
- sigkillbypid("{$g['varrun_path']}/ez-ipupdate.pid", "QUIT");
-
- $dyndnscfg = $config['dyndns'];
- $wancfg = $config['interfaces']['wan'];
-
- if (isset($dyndnscfg['enable'])) {
-
- if ($g['booting'])
- echo "Starting DynDNS client...";
- else
- sleep(1);
-
- /* determine WAN interface name */
- $wanif = get_real_wan_interface();
-
- /* write ez-ipupdate.conf */
- $fd = fopen("{$g['varetc_path']}/ez-ipupdate.conf", "w");
- if (!$fd) {
- printf("Error: cannot open ez-ipupdate.conf in services_dyndns_configure().\n");
- return 1;
- }
-
- $ezipupdateconf = <<<EOD
-service-type={$dyndnscfg['type']}
-user={$dyndnscfg['username']}:{$dyndnscfg['password']}
-host={$dyndnscfg['host']}
-interface={$wanif}
-max-interval=2073600
-pid-file={$g['varrun_path']}/ez-ipupdate.pid
-cache-file={$g['vardb_path']}/ez-ipupdate.cache
-execute=/etc/rc.dyndns.storecache
-daemon
-
-EOD;
-
- /* enable server[:port]? */
- if ($dyndnscfg['server']) {
- if ($dyndnscfg['port'])
- $ezipupdateconf .= "server={$dyndnscfg['server']}:{$dyndnscfg['port']}\n";
- else
- $ezipupdateconf .= "server={$dyndnscfg['server']}\n";
- }
-
- /* enable MX? */
- if ($dyndnscfg['mx']) {
- $ezipupdateconf .= "mx={$dyndnscfg['mx']}\n";
- }
-
- /* enable wildcards? */
- if (isset($dyndnscfg['wildcard'])) {
- $ezipupdateconf .= "wildcard\n";
- }
-
- fwrite($fd, $ezipupdateconf);
- fclose($fd);
-
- /* if we're booting, copy the cache file from /conf */
- if ($g['booting']) {
- if (file_exists("{$g['conf_path']}/ez-ipupdate.cache")) {
- copy("{$g['conf_path']}/ez-ipupdate.cache", "{$g['vardb_path']}/ez-ipupdate.cache");
- }
- }
-
- /* run ez-ipupdate */
- mwexec("/usr/local/bin/ez-ipupdate -c {$g['varetc_path']}/ez-ipupdate.conf");
-
- if ($g['booting'])
- echo "done\n";
- }
-
- return 0;
-}
-
-function services_dnsmasq_configure() {
- global $config, $g;
- $return = 0;
-
- if(isset($config['system']['developerspew'])) {
- $mt = microtime();
- echo "services_dnsmasq_configure() being called $mt\n";
- }
-
- /* kill any running dnsmasq */
- sigkillbypid("{$g['varrun_path']}/dnsmasq.pid", "TERM");
-
- if (isset($config['dnsmasq']['enable'])) {
-
- if ($g['booting'])
- echo "Starting DNS forwarder...";
- else
- sleep(1);
-
- /* generate hosts file */
- if(system_hosts_generate()!=0)
- $return = 1;
-
- $args = "";
-
- if (isset($config['dnsmasq']['regdhcp'])) {
-
- $args .= " -l {$g['dhcpd_chroot_path']}/var/db/dhcpd.leases" .
- " -s {$config['system']['domain']}";
- }
-
- if (isset($config['dnsmasq']['domainoverrides']) && is_array($config['dnsmasq']['domainoverrides'])) {
- foreach($config['dnsmasq']['domainoverrides'] as $override) {
- $args .= ' --server=/' . $override['domain'] . '/' . $override['ip'];
- }
- }
-
- /* suppose that dnsmasq handles our domain and don't send
- requests for our local domain to upstream servers */
- //if (!empty($config['system']['domain'])) {
- // $args .= sprintf(' --local=/%s/', $config['system']['domain']);
- //}
-
- /* run dnsmasq */
- mwexec("/usr/local/sbin/dnsmasq --all-servers {$args}");
-
- if ($g['booting'])
- echo "done.\n";
- }
-
- if (!$g['booting']) {
- if(services_dhcpd_configure()!=0)
- $return = 1;
- }
-
- return $return;
-}
-
-function services_snmpd_configure() {
- global $config, $g;
- if(isset($config['system']['developerspew'])) {
- $mt = microtime();
- echo "services_snmpd_configure() being called $mt\n";
- }
-
- /* kill any running snmpd */
- sigkillbypid("{$g['varrun_path']}/snmpd.pid", "TERM");
- if(is_process_running("bsnmpd"))
- mwexec("/usr/bin/killall bsnmpd", true);
-
- if (isset($config['snmpd']['enable'])) {
-
- if ($g['booting'])
- echo "Starting SNMP daemon... ";
-
- /* generate snmpd.conf */
- $fd = fopen("{$g['varetc_path']}/snmpd.conf", "w");
- if (!$fd) {
- printf("Error: cannot open snmpd.conf in services_snmpd_configure().\n");
- return 1;
- }
-
-
- $snmpdconf = <<<EOD
-location := "{$config['snmpd']['syslocation']}"
-contact := "{$config['snmpd']['syscontact']}"
-read := "{$config['snmpd']['rocommunity']}"
-
-EOD;
-
-/* No docs on what write strings do there for disable for now.
- if(isset($config['snmpd']['rwenable']) && preg_match('/^\S+$/', $config['snmpd']['rwcommunity'])){
- $snmpdconf .= <<<EOD
-# write string
-write := "{$config['snmpd']['rwcommunity']}"
-
-EOD;
- }
-*/
-
-
- if(isset($config['snmpd']['trapenable']) && preg_match('/^\S+$/', $config['snmpd']['trapserver'])){
- $snmpdconf .= <<<EOD
-# SNMP Trap support.
-traphost := {$config['snmpd']['trapserver']}
-trapport := {$config['snmpd']['trapserverport']}
-trap := "{$config['snmpd']['trapstring']}"
-
-
-EOD;
- }
-
-
- $snmpdconf .= <<<EOD
-system := 1 # pfSense
-%snmpd
-begemotSnmpdDebugDumpPdus = 2
-begemotSnmpdDebugSyslogPri = 7
-begemotSnmpdCommunityString.0.1 = $(read)
-
-EOD;
-
-/* No docs on what write strings do there for disable for now.
- if(isset($config['snmpd']['rwcommunity']) && preg_match('/^\S+$/', $config['snmpd']['rwcommunity'])){
- $snmpdconf .= <<<EOD
-begemotSnmpdCommunityString.0.2 = $(write)
-
-EOD;
- }
-*/
-
-
- if(isset($config['snmpd']['trapenable']) && preg_match('/^\S+$/', $config['snmpd']['trapserver'])){
- $snmpdconf .= <<<EOD
-begemotTrapSinkStatus.[$(traphost)].$(trapport) = 4
-begemotTrapSinkVersion.[$(traphost)].$(trapport) = 2
-begemotTrapSinkComm.[$(traphost)].$(trapport) = $(trap)
-
-EOD;
- }
-
-
- $snmpdconf .= <<<EOD
-begemotSnmpdCommunityDisable = 1
-
-EOD;
-
- if(isset($config['snmpd']['bindlan'])) {
- $bind_to_ip = $config['interfaces']['lan']['ipaddr'];
- } else {
- $bind_to_ip = "0.0.0.0";
- }
-
- if(is_port( $config['snmpd']['pollport'] )) {
- $snmpdconf .= <<<EOD
-begemotSnmpdPortStatus.{$bind_to_ip}.{$config['snmpd']['pollport']} = 1
-
-EOD;
-
- }
-
- $snmpdconf .= <<<EOD
-begemotSnmpdLocalPortStatus."/var/run/snmpd.sock" = 1
-begemotSnmpdLocalPortType."/var/run/snmpd.sock" = 4
-
-# These are bsnmp macros not php vars.
-sysContact = $(contact)
-sysLocation = $(location)
-sysObjectId = 1.3.6.1.4.1.12325.1.1.2.1.$(system)
-
-snmpEnableAuthenTraps = 2
-
-EOD;
-
- if (is_array( $config['snmpd']['modules'] )) {
- if(isset($config['snmpd']['modules']['mibii'])) {
- $snmpdconf .= <<<EOD
-begemotSnmpdModulePath."mibII" = "/usr/lib/snmp_mibII.so"
-
-EOD;
- }
-
- if(isset($config['snmpd']['modules']['netgraph'])) {
- $snmpdconf .= <<<EOD
-begemotSnmpdModulePath."netgraph" = "/usr/lib/snmp_netgraph.so"
-%netgraph
-begemotNgControlNodeName = "snmpd"
-
-EOD;
- }
-
- if(isset($config['snmpd']['modules']['pf'])) {
- $snmpdconf .= <<<EOD
-begemotSnmpdModulePath."pf" = "/usr/lib/snmp_pf.so"
-
-EOD;
- }
-
- if(isset($config['snmpd']['modules']['hostres'])) {
- $snmpdconf .= <<<EOD
-begemotSnmpdModulePath."hostres" = "/usr/lib/snmp_hostres.so"
-
-EOD;
- }
- if(isset($config['snmpd']['modules']['bridge'])) {
- $snmpdconf .= <<<EOD
-begemotSnmpdModulePath."bridge" = "/usr/lib/snmp_bridge.so"
-# config must end with blank line
-
-
-EOD;
- }
- }
-
- fwrite($fd, $snmpdconf);
- fclose($fd);
-
- if (isset($config['snmpd']['bindlan'])) {
- $bindlan = "";
- }
-
- /* run bsnmpd */
- mwexec("/usr/sbin/bsnmpd -c {$g['varetc_path']}/snmpd.conf" .
- "{$bindlan} -p {$g['varrun_path']}/snmpd.pid");
-
- if ($g['booting'])
- echo "done.\n";
- }
-
- return 0;
-}
-
-function services_proxyarp_configure() {
- global $config, $g;
- if(isset($config['system']['developerspew'])) {
- $mt = microtime();
- echo "services_proxyarp_configure() being called $mt\n";
- }
-
- /* kill any running choparp */
- killbyname("choparp");
-
- if (isset($config['virtualip']) && is_array($config['virtualip']['vip'])) {
- $paa = array();
-
- /* group by interface */
- foreach ($config['virtualip']['vip'] as $vipent) {
- if ($vipent['mode'] === "proxyarp") {
- if ($vipent['interface'])
- $if = $vipent['interface'];
- else
- $if = "wan";
-
- if (!is_array($paa[$if]))
- $paa[$if] = array();
-
- $paa[$if][] = $vipent;
- }
- }
-
- if (count($paa))
- foreach ($paa as $paif => $paents) {
- if ($paif == "wan" && !(is_ipaddr($config['interfaces']['wan']['ipaddr']) ||
- ($config['interfaces']['wan']['ipaddr'] == "dhcp") ||
- ($config['interfaces']['wan']['ipaddr'] == "bigpond")))
- continue;
-
- $args = $config['interfaces'][$paif]['if'] . " auto";
-
- foreach ($paents as $paent) {
-
- if (isset($paent['subnet']))
- $args .= " " . escapeshellarg("{$paent['subnet']}/{$paent['subnet_bits']}");
- else if (isset($paent['range']))
- $args .= " " . escapeshellarg($paent['range']['from'] . "-" .
- $paent['range']['to']);
- }
-
- mwexec_bg("/usr/local/sbin/choparp " . $args);
- }
- }
-}
-
-function services_dnsupdate_process() {
- global $config, $g;
- if(isset($config['system']['developerspew'])) {
- $mt = microtime();
- echo "services_dnsupdate_process() being called $mt\n";
- }
-
- /* Dynamic DNS updating active? */
- if (isset($config['dnsupdate']['enable'])) {
-
- $wanip = get_current_wan_address();
- if ($wanip) {
-
- $keyname = $config['dnsupdate']['keyname'];
- /* trailing dot */
- if (substr($keyname, -1) != ".")
- $keyname .= ".";
-
- $hostname = $config['dnsupdate']['host'];
- /* trailing dot */
- if (substr($hostname, -1) != ".")
- $hostname .= ".";
-
- /* write private key file
- this is dumb - public and private keys are the same for HMAC-MD5,
- but nsupdate insists on having both */
- $fd = fopen("{$g['varetc_path']}/K{$keyname}+157+00000.private", "w");
- $privkey .= <<<EOD
-Private-key-format: v1.2
-Algorithm: 157 (HMAC)
-Key: {$config['dnsupdate']['keydata']}
-
-EOD;
- fwrite($fd, $privkey);
- fclose($fd);
-
- /* write public key file */
- if ($config['dnsupdate']['keytype'] == "zone") {
- $flags = 257;
- $proto = 3;
- } else if ($config['dnsupdate']['keytype'] == "host") {
- $flags = 513;
- $proto = 3;
- } else if ($config['dnsupdate']['keytype'] == "user") {
- $flags = 0;
- $proto = 2;
- }
-
- $fd = fopen("{$g['varetc_path']}/K{$keyname}+157+00000.key", "w");
- fwrite($fd, "{$keyname} IN KEY {$flags} {$proto} 157 {$config['dnsupdate']['keydata']}\n");
- fclose($fd);
-
- /* generate update instructions */
- $upinst = "";
- if ($config['dnsupdate']['server'])
- $upinst .= "server {$config['dnsupdate']['server']}\n";
- $upinst .= "update delete {$config['dnsupdate']['host']} A\n";
- $upinst .= "update add {$config['dnsupdate']['host']} {$config['dnsupdate']['ttl']} A {$wanip}\n";
- $upinst .= "\n"; /* mind that trailing newline! */
-
- $fd = fopen("{$g['varetc_path']}/nsupdatecmds", "w");
- fwrite($fd, $upinst);
- fclose($fd);
-
- /* invoke nsupdate */
- $cmd = "/usr/bin/nsupdate -k {$g['varetc_path']}/K{$keyname}+157+00000.key";
- if (isset($config['dnsupdate']['usetcp']))
- $cmd .= " -v";
- $cmd .= " {$g['varetc_path']}/nsupdatecmds";
-
- mwexec_bg($cmd);
- }
- }
-
- return 0;
-}
-
-function setup_wireless_olsr() {
- global $config, $g;
- if(!$config['installedpackages']['olsrd'] || !$config['installedpackages'])
- return;
- if(isset($config['system']['developerspew'])) {
- $mt = microtime();
- echo "setup_wireless_olsr($interface) being called $mt\n";
- }
- conf_mount_rw();
- foreach($config['installedpackages']['olsrd']['config'] as $olsrd) {
- $olsr_enable = $olsrd['enable'];
- if($olsr_enable <> "on")
- return;
- $fd = fopen("{$g['varetc_path']}/olsr.conf", "w");
-
- if($olsrd['announcedynamicroute'] or $olsrd['enableannounce'] == "on") {
- $enableannounce .= "\nHna4\n";
- $enableannounce .= "{\n";
- if($olsrd['announcedynamicroute'])
- $enableannounce .= "\t{$olsrd['announcedynamicroute']}\n";
- if($olsrd['enableannounce'] == "on")
- $enableannounce .= "0.0.0.0 0.0.0.0";
- $enableannounce .= "\n}\n";
- } else {
- $enableannounce = "";
- }
-
- $olsr .= <<<EODA
-#
-# olsr.org OLSR daemon config file
-#
-# Lines starting with a # are discarded
-#
-# This file was generated by setup_wireless_olsr() in services.inc
-#
-
-# This file is an example of a typical
-# configuration for a mostly static
-# network(regarding mobility) using
-# the LQ extention
-
-# Debug level(0-9)
-# If set to 0 the daemon runs in the background
-
-DebugLevel 2
-
-# IP version to use (4 or 6)
-
-IpVersion 4
-
-# Clear the screen each time the internal state changes
-
-ClearScreen yes
-
-{$enableannounce}
-
-# Should olsrd keep on running even if there are
-# no interfaces available? This is a good idea
-# for a PCMCIA/USB hotswap environment.
-# "yes" OR "no"
-
-AllowNoInt yes
-
-# TOS(type of service) value for
-# the IP header of control traffic.
-# If not set it will default to 16
-
-#TosValue 16
-
-# The fixed willingness to use(0-7)
-# If not set willingness will be calculated
-# dynamically based on battery/power status
-# if such information is available
-
-#Willingness 4
-
-# Allow processes like the GUI front-end
-# to connect to the daemon.
-
-IpcConnect
-{
- # Determines how many simultaneously
- # IPC connections that will be allowed
- # Setting this to 0 disables IPC
-
- MaxConnections 0
-
- # By default only 127.0.0.1 is allowed
- # to connect. Here allowed hosts can
- # be added
-
- Host 127.0.0.1
- #Host 10.0.0.5
-
- # You can also specify entire net-ranges
- # that are allowed to connect. Multiple
- # entries are allowed
-
- #Net 192.168.1.0 255.255.255.0
-}
-
-# Wether to use hysteresis or not
-# Hysteresis adds more robustness to the
-# link sensing but delays neighbor registration.
-# Used by default. 'yes' or 'no'
-
-UseHysteresis no
-
-# Hysteresis parameters
-# Do not alter these unless you know
-# what you are doing!
-# Set to auto by default. Allowed
-# values are floating point values
-# in the interval 0,1
-# THR_LOW must always be lower than
-# THR_HIGH.
-
-#HystScaling 0.50
-#HystThrHigh 0.80
-#HystThrLow 0.30
-
-
-# Link quality level
-# 0 = do not use link quality
-# 1 = use link quality for MPR selection
-# 2 = use link quality for MPR selection and routing
-# Defaults to 0
-
-LinkQualityLevel {$olsrd['enablelqe']}
-
-# Link quality window size
-# Defaults to 10
-
-LinkQualityWinSize 10
-
-# Polling rate in seconds(float).
-# Default value 0.05 sec
-
-Pollrate 0.05
-
-
-# TC redundancy
-# Specifies how much neighbor info should
-# be sent in TC messages
-# Possible values are:
-# 0 - only send MPR selectors
-# 1 - send MPR selectors and MPRs
-# 2 - send all neighbors
-#
-# defaults to 0
-
-TcRedundancy 2
-
-#
-# MPR coverage
-# Specifies how many MPRs a node should
-# try select to reach every 2 hop neighbor
-#
-# Can be set to any integer >0
-#
-# defaults to 1
-
-MprCoverage 3
-
-# Example plugin entry with parameters:
-
-EODA;
-
-if($olsrd['enablehttpinfo'] == "on") {
- $olsr .= <<<EODB
-
-LoadPlugin "/usr/local/lib/olsrd_httpinfo.so.0.1"
-{
- PlParam "port" "{$olsrd['port']}"
- PlParam "Net" "{$olsrd['allowedhttpinfohost']} {$olsrd['allowedhttpinfosubnet']}"
-}
-
-EODB;
-
-}
-
-if($olsrd['enabledsecure'] == "on") {
- $olsr .= <<<EODC
-
-LoadPlugin "/usr/local/lib/olsrd_secure.so.0.5"
-{
- PlParam "Keyfile" "/usr/local/etc/olsrkey.txt"
-}
-
-EODC;
-
-}
-
-if($olsrd['enabledyngw'] == "on") {
-
- /* unset default route, olsr auto negotiates */
- mwexec("/sbin/route delete default");
-
- $olsr .= <<<EODE
-
-LoadPlugin "/usr/local/lib/olsrd_dyn_gw.so.0.4"
-{
- # how often to look for a inet gw, in seconds
- # defaults to 5 secs, if commented out
- PlParam "Interval" "{$olsrd['polling']}"
-
- # if one or more IPv4 addresses are given, do a ping on these in
- # descending order to validate that there is not only an entry in
- # routing table, but also a real internet connection. If any of
- # these addresses could be pinged successfully, the test was
- # succesful, i.e. if the ping on the 1st address was successful,the
- # 2nd won't be pinged
- PlParam "Ping" "{$olsrd['ping']}"
- #PlParam "HNA" "192.168.81.0 255.255.255.0"
-}
-
-EODE;
-
-}
-
-foreach($config['installedpackages']['olsrd']['config'] as $conf) {
- $interfaces = explode(',', $conf['iface_array']);
- foreach($interfaces as $interface) {
- $realinterface = convert_friendly_interface_to_real_interface_name($interface);
-$olsr .= <<<EODAD
-Interface "{$realinterface}"
-{
-
- # Hello interval in seconds(float)
- HelloInterval 2.0
-
- # HELLO validity time
- HelloValidityTime 20.0
-
- # TC interval in seconds(float)
- TcInterval 5.0
-
- # TC validity time
- TcValidityTime 30.0
-
- # MID interval in seconds(float)
- MidInterval 5.0
-
- # MID validity time
- MidValidityTime 30.0
-
- # HNA interval in seconds(float)
- HnaInterval 5.0
-
- # HNA validity time
- HnaValidityTime 30.0
-
- # When multiple links exist between hosts
- # the weight of interface is used to determine
- # the link to use. Normally the weight is
- # automatically calculated by olsrd based
- # on the characteristics of the interface,
- # but here you can specify a fixed value.
- # Olsrd will choose links with the lowest value.
-
- # Weight 0
-
-
-}
-
-EODAD;
-
- }
- break;
-}
- fwrite($fd, $olsr);
- fclose($fd);
- }
-
- if(is_process_running("olsrd"))
- mwexec("/usr/bin/killall olsrd", true);
-
- sleep(2);
-
- mwexec_bg("/usr/local/sbin/olsrd -f {$g['varetc_path']}/olsr.conf");
-
- conf_mount_ro();
-}
-
-/* configure cron service */
-function configure_cron() {
- global $g, $config;
- conf_mount_rw();
- /* preserve existing crontab entries */
- $crontab_contents = file_get_contents("/etc/crontab");
- $crontab_contents_a = split("\n", $crontab_contents);
-
- for ($i = 0; $i < count($crontab_contents_a); $i++) {
- $item =& $crontab_contents_a[$i];
- if (strpos($item, "# pfSense specific crontab entries") !== false) {
- array_splice($crontab_contents_a, $i - 1);
- break;
- }
- }
- $crontab_contents = implode("\n", $crontab_contents_a) . "\n";
-
-
- if (is_array($config['cron']['item'])) {
- $crontab_contents .= "#\n";
- $crontab_contents .= "# pfSense specific crontab entries\n";
- $crontab_contents .= "# Created: " . date("F j, Y, g:i a") . "\n";
- $crontab_contents .= "#\n";
-
- foreach ($config['cron']['item'] as $item) {
- $crontab_contents .= "\n{$item['minute']}\t";
- $crontab_contents .= "{$item['hour']}\t";
- $crontab_contents .= "{$item['mday']}\t";
- $crontab_contents .= "{$item['month']}\t";
- $crontab_contents .= "{$item['wday']}\t";
- $crontab_contents .= "{$item['who']}\t";
- $crontab_contents .= "{$item['command']}";
- }
-
- $crontab_contents .= "\n#\n";
- $crontab_contents .= "# If possible do not add items to this file manually.\n";
- $crontab_contents .= "# If you do so, this file must be terminated with a blank line (e.g. new line)\n";
- $crontab_contents .= "#\n\n";
- }
-
- /* please maintain the newline at the end of file */
- file_put_contents("/etc/crontab", $crontab_contents);
-
- if (!$g['booting'])
- conf_mount_ro();
-}
-
-function upnp_action ($action) {
- switch($action) {
- case "start":
- if(file_exists('/var/etc/miniupnpd.conf'))
- mwexec_bg('/usr/local/sbin/miniupnpd -f /var/etc/miniupnpd.conf');
- break;
- case "stop":
- while((int)exec("pgrep miniupnpd | wc -l") > 0)
- mwexec('killall miniupnpd 2>/dev/null', true);
- mwexec('/sbin/pfctl -aminiupnpd -Fr 2>&1 >/dev/null');
- mwexec('/sbin/pfctl -aminiupnpd -Fn 2>&1 >/dev/null');
- break;
- case "restart":
- upnp_action('stop');
- upnp_action('start');
- break;
- }
-}
-
-function upnp_start() {
- global $config, $g;
- if($config['installedpackages']['miniupnpd']['config'][0]['enable']) {
- if($g['booting']) {
- echo "Starting UPnP service...";
- include('/usr/local/pkg/miniupnpd.inc');
- sync_package_miniupnpd();
- echo "done.\n";
- }
- else {
- upnp_action('start');
- }
- }
-}
-
-?>
diff --git a/config/Fit123/bin/ltsp/services_dhcp.abc b/config/Fit123/bin/ltsp/services_dhcp.abc
deleted file mode 100755
index 7a203491..00000000
--- a/config/Fit123/bin/ltsp/services_dhcp.abc
+++ /dev/null
@@ -1,696 +0,0 @@
-<?php
-/* $Id$ */
-/*
- services_dhcp.php
- part of m0n0wall (http://m0n0.ch/wall)
-
- Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
- 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.
-*/
-
-require("guiconfig.inc");
-
-/* Fix failover DHCP problem
- * http://article.gmane.org/gmane.comp.security.firewalls.pfsense.support/18749
- */
-ini_set("memory_limit","64M");
-
-/* This function will remove entries from dhcpd.leases that would otherwise
- * overlap with static DHCP reservations. If we don't clean these out,
- * then DHCP will print a warning in the logs about a duplicate lease
- */
-function dhcp_clean_leases() {
- global $g, $config;
- $leasesfile = "{$g['dhcpd_chroot_path']}/var/db/dhcpd.leases";
- if (!file_exists($leasesfile))
- return;
- /* Build list of static MACs */
- $staticmacs = array();
- foreach($config['interfaces'] as $ifname => $ifarr)
- if (is_array($config['dhcpd'][$ifname]['staticmap']))
- foreach($config['dhcpd'][$ifname]['staticmap'] as $static)
- $staticmacs[] = $static['mac'];
- /* Read existing leases */
- $leases_contents = explode("\n", file_get_contents($leasesfile));
- $newleases_contents = array();
- $i=0;
- while ($i < count($leases_contents)) {
- /* Find a lease definition */
- if (substr($leases_contents[$i], 0, 6) == "lease ") {
- $templease = array();
- $thismac = "";
- /* Read to the end of the lease declaration */
- do {
- if (substr($leases_contents[$i], 0, 20) == " hardware ethernet ")
- $thismac = substr($leases_contents[$i], 20, 17);
- $templease[] = $leases_contents[$i];
- $i++;
- } while ($leases_contents[$i-1] != "}");
- /* Check for a matching MAC address and if not present, keep it. */
- if (! in_array($thismac, $staticmacs))
- $newleases_contents = array_merge($newleases_contents, $templease);
- } else {
- /* It's a line we want to keep, copy it over. */
- $newleases_contents[] = $leases_contents[$i];
- $i++;
- }
- }
- /* Write out the new leases file */
- $fd = fopen($leasesfile, 'w');
- fwrite($fd, implode("\n", $newleases_contents));
- fclose($fd);
-}
-
-$if = $_GET['if'];
-if ($_POST['if'])
- $if = $_POST['if'];
-
-/* if OLSRD is enabled, allow WAN to house DHCP. */
-if($config['installedpackages']['olsrd']) {
- foreach($config['installedpackages']['olsrd']['config'] as $olsrd) {
- if($olsrd['enable']) {
- $iflist = array("lan" => "LAN", "wan" => "WAN");
- $is_olsr_enabled = true;
- break;
- }
- }
-}
-
-if(!$iflist)
- $iflist = array("lan" => "LAN");
-
-for ($i = 1; isset($config['interfaces']['opt' . $i]); $i++) {
- $oc = $config['interfaces']['opt' . $i];
-
- if (isset($oc['enable']) && $oc['if'] && (!$oc['bridge'])) {
- $iflist['opt' . $i] = $oc['descr'];
- }
-}
-
-if (!$if || !isset($iflist[$if]))
- $if = "lan";
-
-$pconfig['range_from'] = $config['dhcpd'][$if]['range']['from'];
-$pconfig['range_to'] = $config['dhcpd'][$if]['range']['to'];
-$pconfig['deftime'] = $config['dhcpd'][$if]['defaultleasetime'];
-$pconfig['maxtime'] = $config['dhcpd'][$if]['maxleasetime'];
-$pconfig['gateway'] = $config['dhcpd'][$if]['gateway'];
-list($pconfig['wins1'],$pconfig['wins2']) = $config['dhcpd'][$if]['winsserver'];
-list($pconfig['dns1'],$pconfig['dns2']) = $config['dhcpd'][$if]['dnsserver'];
-$pconfig['enable'] = isset($config['dhcpd'][$if]['enable']);
-$pconfig['denyunknown'] = isset($config['dhcpd'][$if]['denyunknown']);
-$pconfig['staticarp'] = isset($config['dhcpd'][$if]['staticarp']);
-$pconfig['ddnsdomain'] = $config['dhcpd'][$if]['ddnsdomain'];
-$pconfig['ddnsupdate'] = isset($config['dhcpd'][$if]['ddnsupdate']);
-list($pconfig['ntp1'],$pconfig['ntp2']) = $config['dhcpd'][$if]['ntpserver'];
-$pconfig['netboot'] = isset($config['dhcpd'][$if]['netboot']);
-$pconfig['nextserver'] = $config['dhcpd'][$if]['next-server'];
-$pconfig['filename'] = $config['dhcpd'][$if]['filename'];
-$pconfig['rootpath'] = $config['dhcpd'][$if]['rootpath'];
-$pconfig['failover_peerip'] = $config['dhcpd'][$if]['failover_peerip'];
-$pconfig['netmask'] = $config['dhcpd'][$if]['netmask'];
-
-$ifcfg = $config['interfaces'][$if];
-
-/* set the enabled flag which will tell us if DHCP relay is enabled
- * on any interface. We will use this to disable DHCP server since
- * the two are not compatible with each other.
- */
-
-$dhcrelay_enabled = false;
-$dhcrelaycfg = $config['dhcrelay'];
-
-if(is_array($dhcrelaycfg)) {
- foreach ($dhcrelaycfg as $dhcrelayif => $dhcrelayifconf) {
- if (isset($dhcrelayifconf['enable']) &&
- (($dhcrelayif == "lan") ||
- (isset($config['interfaces'][$dhcrelayif]['enable']) &&
- $config['interfaces'][$dhcrelayif]['if'] && (!$config['interfaces'][$dhcrelayif]['bridge']))))
- $dhcrelay_enabled = true;
- }
-}
-
-
-if (!is_array($config['dhcpd'][$if]['staticmap'])) {
- $config['dhcpd'][$if]['staticmap'] = array();
-}
-staticmaps_sort($if);
-$a_maps = &$config['dhcpd'][$if]['staticmap'];
-
-function is_inrange($test, $start, $end) {
- if ( (ip2long($test) < ip2long($end)) && (ip2long($test) > ip2long($start)) )
- return true;
- else
- return false;
-}
-
-if ($_POST) {
-
- unset($input_errors);
-
- $pconfig = $_POST;
-
- /* input validation */
- if ($_POST['enable']) {
- $reqdfields = explode(" ", "range_from range_to");
- $reqdfieldsn = explode(",", "Range begin,Range end");
-
- do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
-
- foreach($a_maps as $mapent) {
- if(is_inrange($mapent['ipaddr'], $_POST['range_from'], $_POST['range_to'])) {
- $input_errors[] = "{$mapent['ipaddr']} is inside the range you specified.";
- }
-
- }
-
- if (($_POST['range_from'] && !is_ipaddr($_POST['range_from']))) {
- $input_errors[] = "A valid range must be specified.";
- }
- if (($_POST['range_to'] && !is_ipaddr($_POST['range_to']))) {
- $input_errors[] = "A valid range must be specified.";
- }
- if (($_POST['gateway'] && !is_ipaddr($_POST['gateway']))) {
- $input_errors[] = "A valid IP address must be specified for the gateway.";
- }
- if (($_POST['wins1'] && !is_ipaddr($_POST['wins1'])) || ($_POST['wins2'] && !is_ipaddr($_POST['wins2']))) {
- $input_errors[] = "A valid IP address must be specified for the primary/secondary WINS servers.";
- }
- if (($_POST['dns1'] && !is_ipaddr($_POST['dns1'])) || ($_POST['dns2'] && !is_ipaddr($_POST['dns2']))) {
- $input_errors[] = "A valid IP address must be specified for the primary/secondary DNS servers.";
- }
- if ($_POST['deftime'] && (!is_numeric($_POST['deftime']) || ($_POST['deftime'] < 60))) {
- $input_errors[] = "The default lease time must be at least 60 seconds.";
- }
- if ($_POST['maxtime'] && (!is_numeric($_POST['maxtime']) || ($_POST['maxtime'] < 60) || ($_POST['maxtime'] <= $_POST['deftime']))) {
- $input_errors[] = "The maximum lease time must be at least 60 seconds and higher than the default lease time.";
- }
- if (($_POST['ddnsdomain'] && !is_domain($_POST['ddnsdomain']))) {
- $input_errors[] = "A valid domain name must be specified for the dynamic DNS registration.";
- }
- if (($_POST['ntp1'] && !is_ipaddr($_POST['ntp1'])) || ($_POST['ntp2'] && !is_ipaddr($_POST['ntp2']))) {
- $input_errors[] = "A valid IP address must be specified for the primary/secondary NTP servers.";
- }
- if (($_POST['nextserver'] && !is_ipaddr($_POST['nextserver']))) {
- $input_errors[] = "A valid IP address must be specified for the network boot server.";
- }
-
-
- if (!$input_errors) {
- /* make sure the range lies within the current subnet */
- $subnet_start = (ip2long($ifcfg['ipaddr']) & gen_subnet_mask_long($ifcfg['subnet']));
- $subnet_end = (ip2long($ifcfg['ipaddr']) | (~gen_subnet_mask_long($ifcfg['subnet'])));
-
- if ((ip2long($_POST['range_from']) < $subnet_start) || (ip2long($_POST['range_from']) > $subnet_end) ||
- (ip2long($_POST['range_to']) < $subnet_start) || (ip2long($_POST['range_to']) > $subnet_end)) {
- $input_errors[] = "The specified range lies outside of the current subnet.";
- }
-
- if (ip2long($_POST['range_from']) > ip2long($_POST['range_to']))
- $input_errors[] = "The range is invalid (first element higher than second element).";
-
- /* make sure that the DHCP Relay isn't enabled on this interface */
- if (isset($config['dhcrelay'][$if]['enable']))
- $input_errors[] = "You must disable the DHCP relay on the {$iflist[$if]} interface before enabling the DHCP server.";
- }
- }
-
- if (!$input_errors) {
- $config['dhcpd'][$if]['range']['from'] = $_POST['range_from'];
- $config['dhcpd'][$if]['range']['to'] = $_POST['range_to'];
- $config['dhcpd'][$if]['defaultleasetime'] = $_POST['deftime'];
- $config['dhcpd'][$if]['maxleasetime'] = $_POST['maxtime'];
- $config['dhcpd'][$if]['netmask'] = $_POST['netmask'];
- $previous = $config['dhcpd'][$if]['failover_peerip'];
- if($previous <> $_POST['failover_peerip']) {
- mwexec("rm -rf /var/dhcpd/var/db/*");
- }
- $config['dhcpd'][$if]['failover_peerip'] = $_POST['failover_peerip'];
-
- unset($config['dhcpd'][$if]['winsserver']);
- if ($_POST['wins1'])
- $config['dhcpd'][$if]['winsserver'][] = $_POST['wins1'];
- if ($_POST['wins2'])
- $config['dhcpd'][$if]['winsserver'][] = $_POST['wins2'];
-
- unset($config['dhcpd'][$if]['dnsserver']);
- if ($_POST['dns1'])
- $config['dhcpd'][$if]['dnsserver'][] = $_POST['dns1'];
- if ($_POST['dns2'])
- $config['dhcpd'][$if]['dnsserver'][] = $_POST['dns2'];
-
- $config['dhcpd'][$if]['gateway'] = $_POST['gateway'];
- $config['dhcpd'][$if]['denyunknown'] = ($_POST['denyunknown']) ? true : false;
- $config['dhcpd'][$if]['enable'] = ($_POST['enable']) ? true : false;
- $config['dhcpd'][$if]['staticarp'] = ($_POST['staticarp']) ? true : false;
- $config['dhcpd'][$if]['ddnsdomain'] = $_POST['ddnsdomain'];
- $config['dhcpd'][$if]['ddnsupdate'] = ($_POST['ddnsupdate']) ? true : false;
-
- unset($config['dhcpd'][$if]['ntpserver']);
- if ($_POST['ntp1'])
- $config['dhcpd'][$if]['ntpserver'][] = $_POST['ntp1'];
- if ($_POST['ntp2'])
- $config['dhcpd'][$if]['ntpserver'][] = $_POST['ntp2'];
-
- $config['dhcpd'][$if]['netboot'] = ($_POST['netboot']) ? true : false;
- $config['dhcpd'][$if]['next-server'] = $_POST['nextserver'];
- $config['dhcpd'][$if]['filename'] = $_POST['filename'];
- $config['dhcpd'][$if]['rootpath'] = $_POST['rootpath'];
-
- write_config();
-
- /* static arp configuration */
- interfaces_staticarp_configure($if);
-
- $retval = 0;
- $retvaldhcp = 0;
- $retvaldns = 0;
- config_lock();
- /* Stop DHCP so we can cleanup leases */
- killbyname("dhcpd");
- dhcp_clean_leases();
- /* dnsmasq_configure calls dhcpd_configure */
- /* no need to restart dhcpd twice */
- if (isset($config['dnsmasq']['regdhcpstatic'])) {
- $retvaldns = services_dnsmasq_configure();
- if ($retvaldns == 0) {
- if (file_exists($d_hostsdirty_path))
- unlink($d_hostsdirty_path);
- if (file_exists($d_staticmapsdirty_path))
- unlink($d_staticmapsdirty_path);
- }
- } else {
- $retvaldhcp = services_dhcpd_configure();
- if ($retvaldhcp == 0) {
- if (file_exists($d_staticmapsdirty_path))
- unlink($d_staticmapsdirty_path);
- }
- }
- config_unlock();
- if($retvaldhcp == 1 || $retvaldns == 1)
- $retval = 1;
- $savemsg = get_std_save_message($retval);
- }
-}
-
-if ($_GET['act'] == "del") {
- if ($a_maps[$_GET['id']]) {
- unset($a_maps[$_GET['id']]);
- write_config();
- if(isset($config['dhcpd'][$if]['enable'])) {
- touch($d_staticmapsdirty_path);
- if (isset($config['dnsmasq']['regdhcpstatic']))
- touch($d_hostsdirty_path);
- }
- header("Location: services_dhcp.php?if={$if}");
- exit;
- }
-}
-
-$pgtitle = "Services: DHCP server";
-include("head.inc");
-
-?>
-
-<script type="text/javascript" language="JavaScript">
-
-function enable_change(enable_over) {
- var endis;
- endis = !(document.iform.enable.checked || enable_over);
- document.iform.range_from.disabled = endis;
- document.iform.range_to.disabled = endis;
- document.iform.wins1.disabled = endis;
- document.iform.wins2.disabled = endis;
- document.iform.dns1.disabled = endis;
- document.iform.dns2.disabled = endis;
- document.iform.deftime.disabled = endis;
- document.iform.maxtime.disabled = endis;
- document.iform.gateway.disabled = endis;
- document.iform.failover_peerip.disabled = endis;
- document.iform.staticarp.disabled = endis;
- document.iform.ddnsdomain.disabled = endis;
- document.iform.ddnsupdate.disabled = endis;
- document.iform.ntp1.disabled = endis;
- document.iform.ntp2.disabled = endis;
- document.iform.netboot.disabled = endis;
- document.iform.nextserver.disabled = endis;
- document.iform.filename.disabled = endis;
- document.iform.rootpath.disabled = endis;
- document.iform.denyunknown.disabled = endis;
-}
-
-function show_ddns_config() {
- document.getElementById("showddnsbox").innerHTML='';
- aodiv = document.getElementById('showddns');
- aodiv.style.display = "block";
-}
-
-function show_ntp_config() {
- document.getElementById("showntpbox").innerHTML='';
- aodiv = document.getElementById('showntp');
- aodiv.style.display = "block";
-}
-
-function show_netboot_config() {
- document.getElementById("shownetbootbox").innerHTML='';
- aodiv = document.getElementById('shownetboot');
- aodiv.style.display = "block";
-}
-
-</script>
-
-<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
-<?php include("fbegin.inc"); ?>
-<p class="pgtitle"><?=$pgtitle?></p>
-<form action="services_dhcp.php" method="post" name="iform" id="iform">
-<?php if ($input_errors) print_input_errors($input_errors); ?>
-<?php if ($savemsg) print_info_box($savemsg); ?>
-<?php
- if ($dhcrelay_enabled) {
- echo "DHCP Relay is currently enabled. Cannot enable the DHCP Server service while the DHCP Relay is enabled on any interface.";
- include("fend.inc");
- echo "</body>";
- echo "</html>";
- exit;
- }
-?>
-<?php if (file_exists($d_staticmapsdirty_path)): ?><p>
-<?php print_info_box_np("The static mapping configuration has been changed.<br>You must apply the changes in order for them to take effect.");?><br>
-<?php endif; ?>
-<table width="100%" border="0" cellpadding="0" cellspacing="0">
- <tr><td>
- <?php
- /* active tabs */
- $tab_array = array();
- $tabscounter = 0;
- $i = 0;
- foreach ($iflist as $ifent => $ifname) {
- if ($ifent == $if)
- $active = true;
- else
- $active = false;
- $tab_array[] = array($ifname, $active, "services_dhcp.php?if={$ifent}");
- }
- display_top_tabs($tab_array);
- ?>
- </td></tr>
- <tr>
- <td>
- <div id="mainarea">
- <table class="tabcont" width="100%" border="0" cellpadding="6" cellspacing="0">
- <tr>
- <td width="22%" valign="top" class="vtable">&nbsp;</td>
- <td width="78%" class="vtable">
- <input name="enable" type="checkbox" value="yes" <?php if ($pconfig['enable']) echo "checked"; ?> onClick="enable_change(false)">
- <strong>Enable DHCP server on
- <?=htmlspecialchars($iflist[$if]);?>
- interface</strong></td>
- </tr>
- <tr>
- <td width="22%" valign="top" class="vtable">&nbsp;</td>
- <td width="78%" class="vtable">
- <input name="denyunknown" id="denyunknown" type="checkbox" value="yes" <?php if ($pconfig['denyunknown']) echo "checked"; ?>>
- <strong>Deny unknown clients</strong><br>
- If this is checked, only the clients defined below will get DHCP leases from this server. </td>
- </tr>
- <tr>
- <td width="22%" valign="top" class="vncellreq">Subnet</td>
- <td width="78%" class="vtable">
- <?=gen_subnet($ifcfg['ipaddr'], $ifcfg['subnet']);?>
- </td>
- </tr>
- <tr>
- <td width="22%" valign="top" class="vncellreq">Subnet
- mask</td>
- <td width="78%" class="vtable">
- <?=gen_subnet_mask($ifcfg['subnet']);?>
- </td>
- </tr>
- <tr>
- <td width="22%" valign="top" class="vncellreq">Available
- range</td>
- <td width="78%" class="vtable">
- <?=long2ip(ip2long($ifcfg['ipaddr']) & gen_subnet_mask_long($ifcfg['subnet']));?>
- -
- <?=long2ip(ip2long($ifcfg['ipaddr']) | (~gen_subnet_mask_long($ifcfg['subnet']))); ?>
- </td>
- </tr>
- <?php if($is_olsr_enabled): ?>
- <tr>
- <td width="22%" valign="top" class="vncellreq">Subnet Mask</td>
- <td width="78%" class="vtable">
- <select name="netmask" class="formfld" id="netmask">
- <?php
- for ($i = 32; $i > 0; $i--) {
- if($i <> 31) {
- echo "<option value=\"{$i}\" ";
- if ($i == $pconfig['netmask']) echo "selected";
- echo ">" . $i . "</option>";
- }
- }
- ?>
- </select>
- </td>
- </tr>
- <?php endif; ?>
- <tr>
- <td width="22%" valign="top" class="vncellreq">Range</td>
- <td width="78%" class="vtable">
- <input name="range_from" type="text" class="formfld" id="range_from" size="20" value="<?=htmlspecialchars($pconfig['range_from']);?>">
- &nbsp;to&nbsp; <input name="range_to" type="text" class="formfld" id="range_to" size="20" value="<?=htmlspecialchars($pconfig['range_to']);?>">
- </td>
- </tr>
- <tr>
- <td width="22%" valign="top" class="vncell">WINS servers</td>
- <td width="78%" class="vtable">
- <input name="wins1" type="text" class="formfld" id="wins1" size="20" value="<?=htmlspecialchars($pconfig['wins1']);?>"><br>
- <input name="wins2" type="text" class="formfld" id="wins2" size="20" value="<?=htmlspecialchars($pconfig['wins2']);?>">
- </td>
- </tr>
- <tr>
- <td width="22%" valign="top" class="vncell">DNS servers</td>
- <td width="78%" class="vtable">
- <input name="dns1" type="text" class="formfld" id="dns1" size="20" value="<?=htmlspecialchars($pconfig['dns1']);?>"><br>
- <input name="dns2" type="text" class="formfld" id="dns2" size="20" value="<?=htmlspecialchars($pconfig['dns2']);?>"><br>
- NOTE: leave blank to use the system default DNS servers - this interface's IP if DNS forwarder is enabled, otherwise the servers configured on the General page.
- </td>
- </tr>
- <tr>
- <td width="22%" valign="top" class="vncell">Gateway</td>
- <td width="78%" class="vtable">
- <input name="gateway" type="text" class="formfld" id="gateway" size="20" value="<?=htmlspecialchars($pconfig['gateway']);?>"><br>
- The default is to use the IP on this interface of the firewall as the gateway. Specify an alternate gateway here if this is not the correct gateway for your network.
- </td>
- </tr>
- <tr>
- <td width="22%" valign="top" class="vncell">Default lease
- time</td>
- <td width="78%" class="vtable">
- <input name="deftime" type="text" class="formfld" id="deftime" size="10" value="<?=htmlspecialchars($pconfig['deftime']);?>">
- seconds<br>
- This is used for clients that do not ask for a specific
- expiration time.<br>
- The default is 7200 seconds.
- </td>
- </tr>
- <tr>
- <td width="22%" valign="top" class="vncell">Maximum lease
- time</td>
- <td width="78%" class="vtable">
- <input name="maxtime" type="text" class="formfld" id="maxtime" size="10" value="<?=htmlspecialchars($pconfig['maxtime']);?>">
- seconds<br>
- This is the maximum lease time for clients that ask
- for a specific expiration time.<br>
- The default is 86400 seconds.
- </td>
- </tr>
- <tr>
- <td width="22%" valign="top" class="vncell">Failover peer IP:</td>
- <td width="78%" class="vtable">
- <input name="failover_peerip" type="text" class="formfld" id="failover_peerip" size="20" value="<?=htmlspecialchars($pconfig['failover_peerip']);?>"><br>
- Leave blank to disable. Enter the REAL address of the other machine. Machines must be using CARP.
- </td>
- </tr>
- <tr>
- <td width="22%" valign="top" class="vncell">Static ARP</td>
- <td width="78%" class="vtable">
- <table>
- <tr>
- <td>
- <input valign="middle" type="checkbox" value="yes" name="staticarp" id="staticarp" <?php if($pconfig['staticarp']) echo " checked"; ?>>&nbsp;
- </td>
- <td>
- <b>Enable Static ARP entries</b>
- </td>
- </tr>
- <tr>
- <td>
- &nbsp;
- </td>
- <td>
- <span class="red"><strong>Note:</strong></span> Only the machines listed below will be able to communicate with the firewall on this NIC.
- </td>
- </tr>
- </table>
- </td>
- </tr>
- <tr>
- <td width="22%" valign="top" class="vncell">Dynamic DNS</td>
- <td width="78%" class="vtable">
- <div id="showddnsbox">
- <input type="button" onClick="show_ddns_config()" value="Advanced"></input> - Show Dynamic DNS</a>
- </div>
- <div id="showddns" style="display:none">
- <input valign="middle" type="checkbox" value="yes" name="ddnsupdate" id="ddnsupdate" <?php if($pconfig['ddnsupdate']) echo " checked"; ?>>&nbsp;
- <b>Enable registration of DHCP client names in DNS.</b><br />
- <p>
- <input name="ddnsdomain" type="text" class="formfld" id="ddnsdomain" size="20" value="<?=htmlspecialchars($pconfig['ddnsdomain']);?>"><br />
- Note: Leave blank to disable dynamic DNS registration.<br />
- Enter the dynamic DNS domain which will be used to register client names in the DNS server.
- </div>
- </td>
- </tr>
- <tr>
- <td width="22%" valign="top" class="vncell">NTP servers</td>
- <td width="78%" class="vtable">
- <div id="showntpbox">
- <input type="button" onClick="show_ntp_config()" value="Advanced"></input> - Show NTP configuration</a>
- </div>
- <div id="showntp" style="display:none">
- <input name="ntp1" type="text" class="formfld" id="ntp1" size="20" value="<?=htmlspecialchars($pconfig['ntp1']);?>"><br>
- <input name="ntp2" type="text" class="formfld" id="ntp2" size="20" value="<?=htmlspecialchars($pconfig['ntp2']);?>">
- </div>
- </td>
- </tr>
- <tr>
- <td width="22%" valign="top" class="vncell">Enable Network booting</td>
- <td width="78%" class="vtable">
- <div id="shownetbootbox">
- <input type="button" onClick="show_netboot_config()" value="Advanced"></input> - Show Network booting</a>
- </div>
- <div id="shownetboot" style="display:none">
- <input valign="middle" type="checkbox" value="yes" name="netboot" id="netboot" <?php if($pconfig['netboot']) echo " checked"; ?>>&nbsp;
- <b>Enables network booting.</b>
- <p>
- <input name="nextserver" type="text" class="formfld" id="nextserver" size="20" value="<?=htmlspecialchars($pconfig['nextserver']);?>"><br>
- Enter the IP address from the network boot server.
- <p>
- <input name="filename" type="text" class="formfld" id="filename" size="20" value="<?=htmlspecialchars($pconfig['filename']);?>"><br>
- Enter the filename used for network booting.<br />
- Note: You need both a filename and a boot server configured for this to work!<br />
- <p>
- <input name="rootpath" type="text" class="formfld" id="rootpath" size="20" value="<?=htmlspecialchars($pconfig['rootpath']);?>"><br>
- Enter option root-path.
- </div>
- </td>
- </tr>
- <tr>
- <td width="22%" valign="top">&nbsp;</td>
- <td width="78%">
- <input name="if" type="hidden" value="<?=$if;?>">
- <input name="Submit" type="submit" class="formbtn" value="Save" onclick="enable_change(true)">
- </td>
- </tr>
- <tr>
- <td width="22%" valign="top">&nbsp;</td>
- <td width="78%"> <p><span class="vexpl"><span class="red"><strong>Note:<br>
- </strong></span>The DNS servers entered in <a href="system.php">System:
- General setup</a> (or the <a href="services_dnsmasq.php">DNS
- forwarder</a>, if enabled) </span><span class="vexpl">will
- be assigned to clients by the DHCP server.<br>
- <br>
- The DHCP lease table can be viewed on the <a href="diag_dhcp_leases.php">Status:
- DHCP leases</a> page.<br>
- </span></p>
- </td>
- </tr>
- </table>
- <table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0">
- <tr>
- <td width="25%" class="listhdrr">MAC address</td>
- <td width="15%" class="listhdrr">IP address</td>
- <td width="20%" class="listhdrr">Hostname</td>
- <td width="30%" class="listhdr">Description</td>
- <td width="10%" class="list">
- <table border="0" cellspacing="0" cellpadding="1">
- <tr>
- <td valign="middle" width="17"></td>
- <td valign="middle"><a href="services_dhcp_edit.php?if=<?=$if;?>"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0"></a></td>
- </tr>
- </table>
- </td>
- </tr>
- <?php if(is_array($a_maps)): ?>
- <?php $i = 0; foreach ($a_maps as $mapent): ?>
- <?php if($mapent['mac'] <> "" or $mapent['ipaddr'] <> ""): ?>
- <tr>
- <td class="listlr" ondblclick="document.location='services_dhcp_edit.php?if=<?=$if;?>&id=<?=$i;?>';">
- <?=htmlspecialchars($mapent['mac']);?>
- </td>
- <td class="listr" ondblclick="document.location='services_dhcp_edit.php?if=<?=$if;?>&id=<?=$i;?>';">
- <?=htmlspecialchars($mapent['ipaddr']);?>&nbsp;
- </td>
- <td class="listr" ondblclick="document.location='services_dhcp_edit.php?if=<?=$if;?>&id=<?=$i;?>';">
- <?=htmlspecialchars($mapent['hostname']);?>&nbsp;
- </td>
- <td class="listbg" ondblclick="document.location='services_dhcp_edit.php?if=<?=$if;?>&id=<?=$i;?>';">
- <font color="#FFFFFF"><?=htmlspecialchars($mapent['descr']);?>&nbsp;</font>
- </td>
- <td valign="middle" nowrap class="list">
- <table border="0" cellspacing="0" cellpadding="1">
- <tr>
- <td valign="middle"><a href="services_dhcp_edit.php?if=<?=$if;?>&id=<?=$i;?>"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" width="17" height="17" border="0"></a></td>
- <td valign="middle"><a href="services_dhcp.php?if=<?=$if;?>&act=del&id=<?=$i;?>" onclick="return confirm('Do you really want to delete this mapping?')"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0"></a></td>
- </tr>
- </table>
- </td>
- </tr>
- <?php endif; ?>
- <?php $i++; endforeach; ?>
- <?php endif; ?>
- <tr>
- <td class="list" colspan="4"></td>
- <td class="list">
- <table border="0" cellspacing="0" cellpadding="1">
- <tr>
- <td valign="middle" width="17"></td>
- <td valign="middle"><a href="services_dhcp_edit.php?if=<?=$if;?>"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0"></a></td>
- </tr>
- </table>
- </td>
- </tr>
- </table>
- </div>
- </td>
- </tr>
-</table>
-</form>
-<script language="JavaScript">
-<!--
-enable_change(false);
-//-->
-</script>
-<?php include("fend.inc"); ?>
-</body>
-</html>
diff --git a/config/Fit123/cass.xml b/config/Fit123/cass.xml
deleted file mode 100644
index 7539d63b..00000000
--- a/config/Fit123/cass.xml
+++ /dev/null
@@ -1,59 +0,0 @@
-<?xml version="1.0" encoding="utf-8" ?>
-<!DOCTYPE packagegui SYSTEM "../schema/packages.dtd">
-<?xml-stylesheet type="text/xsl" href="./xsl/package.xsl"?>
-<packagegui>
- <copyright></copyright>
- <description>Describe your package here</description>
- <requirements>Describe your package requirements here</requirements>
- <faq>Currently there are no FAQ items provided.</faq>
- <name>cass</name>
- <title>CASS</title>
- <include_file>/usr/local/pkg/fit123.inc</include_file>
- <tabs>
- <tab>
- <text>Fit123</text>
- <url>/pkg_edit.php?xml=fit123.xml&amp;id=0</url>
- </tab>
- <tab>
- <text>DDNS</text>
- <url>/pkg_edit.php?xml=ddns.xml&amp;id=0</url>
- </tab>
- <tab>
- <text>CASS</text>
- <url>/pkg_edit.php?xml=cass.xml&amp;id=0</url>
- <active/>
- </tab>
- </tabs>
- <fields>
- <field>
- <fielddescr>Clear a single state</fielddescr>
- <fieldname>cass2</fieldname>
- <description>
- When your dynamic ip on wan changes, the states of your voip phone needs to be cleared. </description>
- <type>checkbox</type>
- </field>
- <field>
- <fielddescr>Your phone ip address</fielddescr>
- <fieldname>ypia</fieldname>
- <description>
- </description>
- <type>input</type>
- <size>15</size>
- </field>
- <field>
- <fielddescr>IP address of your VOIP </fielddescr>
- <fieldname>iaoyv</fieldname>
- <description>
- </description>
- <type>input</type>
- <size>15</size>
- </field>
- </fields>
- <custom_add_php_command></custom_add_php_command>
- <custom_php_command_before_form>cass_config();</custom_php_command_before_form>
- <custom_php_after_form_command></custom_php_after_form_command>
- <custom_php_validation_command></custom_php_validation_command>
- <custom_php_resync_config_command></custom_php_resync_config_command>
- <custom_php_install_command>Fit123_install_config();</custom_php_install_command>
- <custom_php_deinstall_command>Fit123_install_deinstall();</custom_php_deinstall_command>
-</packagegui>
diff --git a/config/Fit123/ddns.xml b/config/Fit123/ddns.xml
deleted file mode 100644
index cbc6348b..00000000
--- a/config/Fit123/ddns.xml
+++ /dev/null
@@ -1,72 +0,0 @@
-<?xml version="1.0" encoding="utf-8" ?>
-<!DOCTYPE packagegui SYSTEM "../schema/packages.dtd">
-<?xml-stylesheet type="text/xsl" href="./xsl/package.xsl"?>
-<packagegui>
- <copyright></copyright>
- <description>Describe your package here</description>
- <requirements>Describe your package requirements here</requirements>
- <faq>Currently there are no FAQ items provided.</faq>
- <name>ddns</name>
- <title>DDNS</title>
- <include_file>/usr/local/pkg/fit123.inc</include_file>
- <tabs>
- <tab>
- <text>Fit123</text>
- <url>/pkg_edit.php?xml=fit123.xml&amp;id=0</url>
- </tab>
- <tab>
- <text>DDNS</text>
- <url>/pkg_edit.php?xml=ddns.xml&amp;id=0</url>
- <active/>
- </tab>
- <tab>
- <text>CASS</text>
- <url>/pkg_edit.php?xml=cass.xml&amp;id=0</url>
- </tab>
- </tabs>
- <fields>
- <field>
- <fielddescr>Dynamic DNS</fielddescr>
- <fieldname>enable</fieldname>
- <description>
- A more customize way to update dynamic dns and mainly for IP's that doesn't change very often.&lt;br&gt;
- Will check for ip change every 5 min via local shell script and will only contact provider on change.&lt;br&gt;
- </description>
- <type>checkbox</type>
- </field>
- <field>
- <fielddescr>Enter string that should be phrased</fielddescr>
- <fieldname>line1</fieldname>
- <description>
- String for OpenDNS should look like:&lt;br&gt;
- https://username:password@updates.opendns.com/nic/update?hostname=
- </description>
- <type>textarea</type>
- <cols>80</cols>
- <rows>1</rows>
- </field>
- <field>
- <fielddescr>Enter 2th string that should be phrased</fielddescr>
- <fieldname>line2</fieldname>
- <description>Leave empty if not used</description>
- <type>textarea</type>
- <cols>80</cols>
- <rows>1</rows>
- </field>
- <field>
- <fielddescr>Enter 3th string that should be phrased</fielddescr>
- <fieldname>line3</fieldname>
- <description>Leave empty if not used</description>
- <type>textarea</type>
- <cols>80</cols>
- <rows>1</rows>
- </field>
- </fields>
- <custom_add_php_command></custom_add_php_command>
- <custom_php_command_before_form>ddns_config();</custom_php_command_before_form>
- <custom_php_after_form_command></custom_php_after_form_command>
- <custom_php_validation_command></custom_php_validation_command>
- <custom_php_resync_config_command></custom_php_resync_config_command>
- <custom_php_install_command>Fit123_install_config();</custom_php_install_command>
- <custom_php_deinstall_command>Fit123_install_deinstall();</custom_php_deinstall_command>
-</packagegui>
diff --git a/config/Fit123/fit123.inc b/config/Fit123/fit123.inc
deleted file mode 100644
index b1338df2..00000000
--- a/config/Fit123/fit123.inc
+++ /dev/null
@@ -1,428 +0,0 @@
-<?php
-
-function Fit123_install_deinstall() {
- conf_mount_rw();
- config_lock();
- exec("cd ..");
- exec("rm -d -R /usr/local/pkg/Fit123");
- conf_mount_ro();
- config_unlock();
-}
-
-function Fit123_install_config() {
- conf_mount_rw();
- config_lock();
- exec("cd ..");
-//Adding new themes
-// exec("tar -zxovf /usr/local/pkg/code-red.tar.gz");
-// exec("mv code-red /usr/local/www/themes/code-red");
-//Creating backup directory
- exec("mkdir /usr/local/pkg/Fit123");
- exec("mkdir /usr/local/pkg/Fit123/backup");
-//Copy orignal files to backup dir
- //Date
- exec("cp /usr/local/www/index.php /usr/local/pkg/Fit123/backup/");
- //Captive Portal Add-On
-// exec("cp /etc/inc/filter.inc /usr/local/pkg/Fit123/backup/");
-// exec("cp /usr/local/www/services_captiveportal.php /usr/local/pkg/Fit123/backup/");
- //LTSP network boot Option
- exec("cp /etc/inc/services.inc /usr/local/pkg/Fit123/backup/");
- exec("cp /usr/local/www/services_dhcp.php /usr/local/pkg/Fit123/backup/");
- //DNS Server adds option for a 3th and 4th DNS Server
- exec("cp /usr/local/www/system.php /usr/local/pkg/Fit123/backup/");
-//Greate directories and downloading files to them
- //Date
- exec("mkdir /usr/local/pkg/Fit123/date");
- exec("fetch -o /usr/local/pkg/Fit123/date/index.php https://packages.pfsense.org/packages/config/Fit123/bin/date/index.abc");
- //Captive Portal Add-On
- exec("mkdir /usr/local/pkg/Fit123/cpaddon");
- exec("fetch -o /usr/local/pkg/Fit123/cpaddon/filter.inc https://packages.pfsense.org/packages/config/Fit123/bin/cpaddon/filter.inc");
- exec("fetch -o /usr/local/pkg/Fit123/cpaddon/services_captiveportal.php https://packages.pfsense.org/packages/config/Fit123/bin/cpaddon/services_captiveportal.abc");
- //LTSP 3th network boot Option
- exec("mkdir /usr/local/pkg/Fit123/LTSP");
- exec("fetch -o /usr/local/pkg/Fit123/LTSP/ https://packages.pfsense.org/packages/config/Fit123/bin/ltsp/services.inc");
- exec("fetch -o /usr/local/pkg/Fit123/LTSP/services_dhcp.php https://packages.pfsense.org/packages/config/Fit123/bin/ltsp/services_dhcp.abc");
- //AFC Reset's states after filter change
- exec("mkdir /usr/local/pkg/Fit123/afc");
- exec("fetch -o /usr/local/pkg/Fit123/afc/reset_states.sh https://packages.pfsense.org/packages/config/Fit123/bin/afc/reset_states.sh");
- exec("chmod 744 /usr/local/pkg/Fit123/afc/reset_states.sh");
- //DDNS
- exec("mkdir /usr/local/pkg/Fit123/ddns");
- //DNS Server adds option for a 3th and 4th DNS Server
- exec("mkdir /usr/local/pkg/Fit123/dnssrv");
- exec("fetch -o /usr/local/pkg/Fit123/dnssrv/system.php https://packages.pfsense.org/packages/config/Fit123/bin/dnssrv/system.abc");
- conf_mount_ro();
- config_unlock();
-}
-
-function Fit123_config() {
-global $config;
-
- $adddate = $config['installedpackages']['fit123']['config'][0]['adddate'];
- if($adddate)
- exec("cp /usr/local/pkg/Fit123/date/index.php /usr/local/www/index.php");
- else
- exec("cp /usr/local/pkg/Fit123/backup/index.php /usr/local/www/index.php");
-
- $cpaddon = $config['installedpackages']['fit123']['config'][0]['cpaddon'];
- if($cpaddon){
- exec("cp /usr/local/pkg/Fit123/cpaddon/filter.inc /etc/inc/filter.inc");
- exec("cp /usr/local/pkg/Fit123/cpaddon/services_captiveportal.php /usr/local/www/services_captiveportal.php");
- }
- else
- {
- exec("cp /usr/local/pkg/Fit123/backup/filter.inc /etc/inc/filter.inc");
- exec("cp /usr/local/pkg/Fit123/backup/services_captiveportal.php /usr/local/www/services_captiveportal.php");
- }
-
- $ltsp = $config['installedpackages']['fit123']['config'][0]['ltsp'];
- if($ltsp){
- exec("cp /usr/local/pkg/Fit123/LTSP/services.inc /etc/inc/services.inc");
- exec("cp /usr/local/pkg/Fit123/LTSP/services_dhcp.php /usr/local/www/services_dhcp.php");
- }
- else
- {
- exec("cp /usr/local/pkg/Fit123/backup/services.inc /etc/inc/services.inc");
- exec("cp /usr/local/pkg/Fit123/backup/services_dhcp.php /usr/local/www/services_dhcp.php");
- }
-
- $afc = $config['installedpackages']['fit123']['config'][0]['afc'];
- if($afc)
- $config['system']['afterfilterchangeshellcmd'] = "/usr/local/pkg/Fit123/afc/reset_states.sh";
- else
- $config['system']['afterfilterchangeshellcmd'] = "";
-
- $dnssrv = $config['installedpackages']['fit123']['config'][0]['dnssrv'];
- if($dnssrv)
- exec("cp /usr/local/pkg/Fit123/dnssrv/system.php /usr/local/www/system.php");
- else
- exec("cp /usr/local/pkg/Fit123/backup/system.php /usr/local/www/system.php");
-}
-
-function cass_config(){
-global $config;
-// Is CASS enable or not
- $hoba2 = $config['installedpackages']['cass']['config'][0]['cass2'];
- if($hoba2){
- // Is CASS.sh already added as a conjob
- $task_key = '/usr/local/pkg/Fit123/CASS.sh';
- $x_name='';
- $x=0;
- foreach($config['cron']['item'] as $item) {
- if($item['command']==$task_key) {
- $x_name = $x;
- }
- $x++;
- }
- unset($x);
- if(!$x_name > 0)
- {
- // Add cron job CASS.sh to config.xml
- $cron_item = array();
- $cron_item['minute'] = "*/1";
- $cron_item['hour'] = "*";
- $cron_item['mday'] = "*";
- $cron_item['month'] = "*";
- $cron_item['wday'] = "*";
- $cron_item['who'] = "root";
- $cron_item['command'] = "/usr/local/pkg/Fit123/CASS.sh";
- $config['cron']['item'][] = $cron_item;
- write_config();
- configure_cron();
- }
- }
- else
- {
- // Remove CASS.sh cron entry from config.xml
- $task_key = '/usr/local/pkg/Fit123/CASS.sh';
- $x_name='';
- $x=0;
- foreach($config['cron']['item'] as $item) {
- if($item['command']==$task_key) {
- $x_name = $x;
- }
- $x++;
- }
- unset($x);
- if($x_name > 0)
- {
- unset($config['cron']['item'][$x_name]);
- write_config();
- }
- configure_cron();
-}
-
-// Create local shell script to watch for wan ip change
- $local_voip = $config['installedpackages']['cass']['config'][0]['ypia'];
- $voip_p = $config['installedpackages']['cass']['config'][0]['iaoyv'];
-
- //Open CASS.sh for writing
- $hfd = fopen("/usr/local/pkg/Fit123/CASS.sh","w");
- if(!$hfd) {
- log_error("could not open /usr/local/pkg/Fit123/CASS.sh for writing");
- exit;
- }
- // The start of the config file
- fwrite($hfd, '#!/bin/sh');
- fwrite($hfd, "\n");
- fwrite($hfd, 'lip="');
- fwrite($hfd, $local_voip);
- fwrite($hfd, '"');
- fwrite($hfd, "\n");
- fwrite($hfd, 'rip="');
- fwrite($hfd, $voip_p);
- fwrite($hfd, '"');
- fwrite($hfd, "\n");
- fwrite($hfd, 'dns_file="/usr/local/pkg/Fit123/CASS.ip"');
- fwrite($hfd, "\n");
- fwrite($hfd, 'EXIT_SUCCESS=0');
- fwrite($hfd, "\n");
- fwrite($hfd, 'EXIT_FAILURE=1');
- fwrite($hfd, "\n");
- fwrite($hfd, 'if [ `id -u` -ne 0 ]');
- fwrite($hfd, "\n");
- fwrite($hfd, 'then');
- fwrite($hfd, "\n");
- fwrite($hfd, ' echo "Only root may run this program."');
- fwrite($hfd, "\n");
- fwrite($hfd, ' exit $EXIT_FAILURE');
- fwrite($hfd, "\n");
- fwrite($hfd, 'fi');
- fwrite($hfd, "\n");
- fwrite($hfd, 'get_ip(){');
- fwrite($hfd, "\n");
- fwrite($hfd, ' if [ -f $dns_file ]');
- fwrite($hfd, "\n");
- fwrite($hfd, ' then');
- fwrite($hfd, "\n");
- fwrite($hfd, ' registered_ip=`cat ${dns_file}`');
- fwrite($hfd, "\n");
- fwrite($hfd, ' else');
- fwrite($hfd, "\n");
- fwrite($hfd, ' registered_ip=""');
- fwrite($hfd, "\n");
- fwrite($hfd, ' fi');
- fwrite($hfd, "\n");
- fwrite($hfd, ' current_ip=`fetch -qo- http://jackson.io/ip/`');
- fwrite($hfd, "\n");
- fwrite($hfd, '}');
- fwrite($hfd, "\n");
- fwrite($hfd, 'update_hosts(){');
- fwrite($hfd, "\n");
- fwrite($hfd, ' if [ "$registered_ip" != "$current_ip" ]');
- fwrite($hfd, "\n");
- fwrite($hfd, ' then');
- fwrite($hfd, "\n");
- fwrite($hfd, ' /sbin/pfctl -k $lip -k $rip');
- fwrite($hfd, "\n");
- fwrite($hfd, ' echo $current_ip > $dns_file');
- fwrite($hfd, "\n");
- fwrite($hfd, ' echo "WAN ip address changed, clearing states entries.." | logger');
- fwrite($hfd, "\n");
- fwrite($hfd, ' fi');
- fwrite($hfd, "\n");
- fwrite($hfd, '}');
- fwrite($hfd, "\n");
- fwrite($hfd, 'get_ip');
- fwrite($hfd, "\n");
- fwrite($hfd, 'update_hosts');
- fwrite($hfd, "\n");
- fwrite($hfd, 'exit $EXIT_SUCCESS');
- fwrite($hfd, "\n");
- fclose($hfd);
-
- exec("chmod 744 /usr/local/pkg/Fit123/CASS.sh");
-}
-
-function ddns_config(){
-global $config;
-
-// Is DDNS enable or not
- $hoba = $config['installedpackages']['ddns']['config'][0]['enable'];
- if($hoba){
- // Is DDNS.sh already added as a conjob
- $task_key = '/usr/local/pkg/Fit123/ddns/DDNS.sh';
- $x_name='';
- $x=0;
- foreach($config['cron']['item'] as $item) {
- if($item['command']==$task_key) {
- $x_name = $x;
- }
- $x++;
- }
- unset($x);
- if(!$x_name > 0)
- {
- // Add cron job DDNS.sh to config.xml
- $cron_item = array();
- $cron_item['minute'] = "*/5";
- $cron_item['hour'] = "*";
- $cron_item['mday'] = "*";
- $cron_item['month'] = "*";
- $cron_item['wday'] = "*";
- $cron_item['who'] = "root";
- $cron_item['command'] = "/usr/local/pkg/Fit123/ddns/DDNS.sh";
- $config['cron']['item'][] = $cron_item;
- write_config();
- configure_cron();
- }
- }
- else
- {
- // Remove DDNS.sh cron entry from config.xml
- $task_key = '/usr/local/pkg/Fit123/ddns/DDNS.sh';
- $x_name='';
- $x=0;
- foreach($config['cron']['item'] as $item) {
- if($item['command']==$task_key) {
- $x_name = $x;
- }
- $x++;
- }
- unset($x);
- if($x_name > 0)
- {
- unset($config['cron']['item'][$x_name]);
- write_config();
- }
- configure_cron();
- }
-
-// Created DDNS updater file ddns.php
-
- //Get user entry from config.xml
- $line1text = $config['installedpackages']['ddns']['config'][0]['line1'];
- $line2text = $config['installedpackages']['ddns']['config'][0]['line2'];
- $line3text = $config['installedpackages']['ddns']['config'][0]['line3'];
-
- // Open ddns.php for writing
- $hf = fopen("/usr/local/pkg/Fit123/ddns/ddns.php","w");
- if(!$hf) {
- log_error("could not open /usr/local/pkg/Fit123/ddns/ddns.php for writing");
- exit;
- }
-
- // The start of the config file
- fwrite($hf, '<?php');
- fwrite($hf, "\n");
- fwrite($hf, '$ch = curl_init();');
- fwrite($hf, "\n");
- fwrite($hf, 'curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);');
- fwrite($hf, "\n");
- // add to config file
- if ($line1text != ""){
- fwrite($hf, 'curl_setopt($ch, CURLOPT_URL, "');
- fwrite($hf, $line1text);
- fwrite($hf, '");');
- fwrite($hf, "\n");
- fwrite($hf, '$result = curl_exec($ch);');
- fwrite($hf, "\n");
- }
- if ($line2text != ""){
- fwrite($hf, 'curl_setopt($ch, CURLOPT_URL, "');
- fwrite($hf, $line2text);
- fwrite($hf, '");');
- fwrite($hf, "\n");
- fwrite($hf, '$result = curl_exec($ch);');
- fwrite($hf, "\n");
- }
- if ($line3text != ""){
- fwrite($hf, 'curl_setopt($ch, CURLOPT_URL, "');
- fwrite($hf, $line3text);
- fwrite($hf, '");');
- fwrite($hf, "\n");
- fwrite($hf, '$result = curl_exec($ch);');
- fwrite($hf, "\n");
- }
- // The end of the config file
- fwrite($hf, 'curl_close ($ch);');
- fwrite($hf, "\n");
- fwrite($hf, '?>');
- fwrite($hf, "\n");
- fclose($hf);
-
-// Create local shell script to watch for wan ip change
-
- // Get WAN nic name from config.xml
- $wannic = $config['interfaces']['wan']['if'];
-
- //Open DDNS.sh for writing
- $hfd = fopen("/usr/local/pkg/Fit123/ddns/DDNS.sh","w");
- if(!$hfd) {
- log_error("could not open /usr/local/pkg/Fit123/ddns/DDNS.sh for writing");
- exit;
- }
- // The start of the config file
- fwrite($hfd, '#!/bin/sh');
- fwrite($hfd, "\n");
- fwrite($hfd, 'ext_if="');
- fwrite($hfd, $wannic);
- fwrite($hfd, '"');
- fwrite($hfd, "\n");
- fwrite($hfd, 'dns_file="/usr/local/pkg/Fit123/ddns/DDNS.ip"');
- fwrite($hfd, "\n");
- fwrite($hfd, 'update_file="/usr/local/bin/php /usr/local/pkg/Fit123/ddns/ddns.php"');
- fwrite($hfd, "\n");
- fwrite($hfd, 'EXIT_SUCCESS=0');
- fwrite($hfd, "\n");
- fwrite($hfd, 'EXIT_FAILURE=1');
- fwrite($hfd, "\n");
- fwrite($hfd, 'if [ `id -u` -ne 0 ]');
- fwrite($hfd, "\n");
- fwrite($hfd, 'then');
- fwrite($hfd, "\n");
- fwrite($hfd, ' echo "Only root may run this program."');
- fwrite($hfd, "\n");
- fwrite($hfd, ' exit $EXIT_FAILURE');
- fwrite($hfd, "\n");
- fwrite($hfd, 'fi');
- fwrite($hfd, "\n");
- fwrite($hfd, 'get_ip(){');
- fwrite($hfd, "\n");
- fwrite($hfd, ' if [ -f $dns_file ]');
- fwrite($hfd, "\n");
- fwrite($hfd, ' then');
- fwrite($hfd, "\n");
- fwrite($hfd, ' registered_ip=`cat ${dns_file}`');
- fwrite($hfd, "\n");
- fwrite($hfd, ' else');
- fwrite($hfd, "\n");
- fwrite($hfd, ' registered_ip=""');
- fwrite($hfd, "\n");
- fwrite($hfd, ' fi');
- fwrite($hfd, "\n");
- fwrite($hfd, ' current_ip=`ifconfig ${ext_if} | awk ');
- fwrite($hfd, "'");
- fwrite($hfd, '/inet / { print $2 }');
- fwrite($hfd, "'");
- fwrite($hfd, '`');
- fwrite($hfd, "\n");
- fwrite($hfd, '}');
- fwrite($hfd, "\n");
- fwrite($hfd, 'update_hosts(){');
- fwrite($hfd, "\n");
- fwrite($hfd, ' if [ "$registered_ip" != "$current_ip" ]');
- fwrite($hfd, "\n");
- fwrite($hfd, ' then');
- fwrite($hfd, "\n");
- fwrite($hfd, ' $update_file');
- fwrite($hfd, "\n");
- fwrite($hfd, ' echo $current_ip > $dns_file');
- fwrite($hfd, "\n");
- fwrite($hfd, ' echo "Your DDNS records have been updated" | logger');
- fwrite($hfd, "\n");
- fwrite($hfd, ' fi');
- fwrite($hfd, "\n");
- fwrite($hfd, '}');
- fwrite($hfd, "\n");
- fwrite($hfd, 'get_ip');
- fwrite($hfd, "\n");
- fwrite($hfd, 'update_hosts');
- fwrite($hfd, "\n");
- fwrite($hfd, 'exit $EXIT_SUCCESS');
- fwrite($hfd, "\n");
- fclose($hfd);
-
- exec("chmod 744 /usr/local/pkg/Fit123/ddns/DDNS.sh");
-}
-?>
diff --git a/config/Fit123/fit123.xml b/config/Fit123/fit123.xml
deleted file mode 100644
index 0ff202f9..00000000
--- a/config/Fit123/fit123.xml
+++ /dev/null
@@ -1,84 +0,0 @@
-<?xml version="1.0" encoding="utf-8" ?>
-<!DOCTYPE packagegui SYSTEM "../schema/packages.dtd">
-<?xml-stylesheet type="text/xsl" href="./xsl/package.xsl"?>
-<packagegui>
- <copyright></copyright>
- <description>Describe your package here</description>
- <requirements>Describe your package requirements here</requirements>
- <faq>Currently there are no FAQ items provided.</faq>
- <name>Fit123</name>
- <version>0.0.0.1</version>
- <title>Fit123</title>
- <include_file>/usr/local/pkg/fit123.inc</include_file>
- <menu>
- <name>Fit123</name>
- <tooltiptext></tooltiptext>
- <section>Status</section>
- <url>/pkg_edit.php?xml=fit123.xml&amp;id=0</url>
- </menu>
- <tabs>
- <tab>
- <text>Fit123</text>
- <url>/pkg_edit.php?xml=fit123.xml&amp;id=0</url>
- <active/>
- </tab>
- <tab>
- <text>DDNS</text>
- <url>/pkg_edit.php?xml=ddns.xml&amp;id=0</url>
- </tab>
- <tab>
- <text>CASS</text>
- <url>/pkg_edit.php?xml=cass.xml&amp;id=0</url>
- </tab>
- </tabs>
- <additional_files_needed>
- <prefix>/usr/local/pkg/</prefix>
- <chmod>0644</chmod>
- <item>https://packages.pfsense.org/packages/config/Fit123/fit123.inc</item>
- </additional_files_needed>
- <additional_files_needed>
- <prefix>/usr/local/pkg/</prefix>
- <chmod>0644</chmod>
- <item>https://packages.pfsense.org/packages/config/Fit123/ddns.xml</item>
- </additional_files_needed>
- <additional_files_needed>
- <prefix>/usr/local/pkg/</prefix>
- <chmod>0644</chmod>
- <item>https://packages.pfsense.org/packages/config/Fit123/cass.xml</item>
- </additional_files_needed>
- <fields>
- <field>
- <fielddescr>Date</fielddescr>
- <fieldname>adddate</fieldname>
- <description>Adds current date to front page</description>
- <type>checkbox</type>
- </field>
- <field>
- <fielddescr>LTSP</fielddescr>
- <fieldname>ltsp</fieldname>
- <description>Adds 3th network boot option</description>
- <type>checkbox</type>
- </field>
- <field>
- <fielddescr>After Filter Change</fielddescr>
- <fieldname>afc</fieldname>
- <description>
- When using voip behind a multiwan failover setup, states needs to be cleared.&lt;br&gt;
- (Press save twice to activate and deactivate)
- </description>
- <type>checkbox</type>
- </field>
- <field>
- <fielddescr>DNS Servers</fielddescr>
- <fieldname>dnssrv</fieldname>
- <description>Adds option for a 3th and 4th DNS Server</description>
- <type>checkbox</type>
- </field>
- </fields>
- <custom_php_command_before_form>Fit123_config();</custom_php_command_before_form>
- <custom_php_after_form_command></custom_php_after_form_command>
- <custom_php_validation_command></custom_php_validation_command>
- <custom_php_resync_config_command></custom_php_resync_config_command>
- <custom_php_install_command>Fit123_install_config();</custom_php_install_command>
- <custom_php_deinstall_command>Fit123_install_deinstall();</custom_php_deinstall_command>
-</packagegui>