diff options
Diffstat (limited to 'packages')
-rw-r--r-- | packages/carp.xml | 11 | ||||
-rw-r--r-- | packages/carp_rules.php | 66 | ||||
-rw-r--r-- | packages/carp_status.php | 103 |
3 files changed, 180 insertions, 0 deletions
diff --git a/packages/carp.xml b/packages/carp.xml index 73fc4ed3..5e5be0ec 100644 --- a/packages/carp.xml +++ b/packages/carp.xml @@ -8,6 +8,17 @@ <section>Services</section> <configfile>carp.xml</configfile> </menu> + <tabs> + <tab> + <text>CARP Settings</text> + <url>/pkg_edit.php?xml=carp.xml</url> + <active/> + </tab> + <tab> + <text>CARP Status</text> + <url>carp_status.php</url> + </tab> + </tabs> <!-- configpath gets expanded out automatically and config items will be stored in that location --> <configpath>['installedpackages']['carp']['config']</configpath> diff --git a/packages/carp_rules.php b/packages/carp_rules.php new file mode 100644 index 00000000..2c03fb83 --- /dev/null +++ b/packages/carp_rules.php @@ -0,0 +1,66 @@ +<?php +/* + carp_rules.inc + part of pfSense (www.pfSense.com) + Copyright (C) 2004 Scott Ullrich (sullrich@gmail.com) + 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"); +require("xmlparse_pkg.inc"); + +/* + * available anchors: + * anchor natrules + * anchor firewallrules + * anchor loopback + * anchor firewallout + * anchor ftpproxy + * anchor dhcpserverlan + * anchor dhcpserver + * anchor staticrouted + * anchor wanspoof + * anchor wandhcp + * anchor anti-lockout + * anchor pptp + */ + +/* return if there are no carp configured items */ +if(!$config['installedpackages']['carp']['config']) return; + +/* carp records exist, lets process */ +$wan_interface = get_real_wan_interface(); +foreach($config['installedpackages']['carp']['config'] as $carp) { + $ip = $carp['ipaddress']; + $int = find_ip_interface($ip); + $carp_int = find_carp_interface($ip); + if($int <> false && $int <> $wan_interface) { + $ipnet = convert_ip_to_network_format($ip, $carp['netmask']); + $rule = "nat on {$int} inet from {$ipnet} to any -> ({$carp_int}) \n"; + add_rule_to_anchor("natrules", $rule); + } +} + +?>
\ No newline at end of file diff --git a/packages/carp_status.php b/packages/carp_status.php new file mode 100644 index 00000000..65230586 --- /dev/null +++ b/packages/carp_status.php @@ -0,0 +1,103 @@ +#!/usr/local/bin/php +<?php +/* + carp_status.php + Copyright (C) 2004 Scott Ullrich + 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"); +require("xmlparse_pkg.inc"); + +function gentitle_pkg($pgname) { + global $config; + return $config['system']['hostname'] . "." . $config['system']['domain'] . " - " . $pgname; +} + +?> +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> +<html> +<head> +<?php $title = "CARP: Status"; ?> +<title><?=gentitle_pkg($title);?></title> +<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> +<link href="gui.css" rel="stylesheet" type="text/css"> +</head> + +<body link="#0000CC" vlink="#0000CC" alink="#0000CC"> +<?php +include("fbegin.inc"); +?> +<p class="pgtitle"><?=$title?></p> +<form action="firewall_nat_out_load_balancing.php" method="post"> +<?php if ($savemsg) print_info_box($savemsg); ?> + +<table width="100%" border="0" cellpadding="0" cellspacing="0"> +<tr><td> + <ul id="tabnav"> + <li class="tabinact"><a href="/pkg.php?xml=carp.xml">CARP Settings</a></li> + <li class="tabact">CARP Status</li> + </ul> +</td></tr> +<tr><td class="tabcont"> + +<table width="100%" border="0" cellpadding="6" cellspacing="0"> +<tr> + <td class="listhdrr"><b><center>Interface</center></b></td> + <td class="listhdrr"><b><center>Status</center></b></td> + <td class="listhdrr"><b><center>Sync Status</center></b></td> +</tr> +<?php + +foreach($config['installedpackages']['carp']['config'] as $carp) { + $ipaddress = $carp['ipaddress']; + $premption = $carp['premption']; + $password = $carp['password']; + $netmask = $carp['netmask']; + $vhid = $carp['vhid']; + $advskew = $carp['advskew']; + $pfsync = $carp['pfsync']; + $synciface = $carp['synciface']; + $carp_int = find_carp_interface($ipaddress); + $status = get_carp_interface_status($carp_int); + if(isset($carp['balancing'])) $balancing = "true"; else $balancing = "false"; + if(isset($carp['premtpion'])) $premption = "true"; else $premption = "false"; + echo "<tr>"; + echo "<td class=\"listlr\"><center>" . $ipaddress . "</td>"; + echo "<td class=\"listlr\"><center>" . $status . "</td>"; + echo "<td class=\"listlr\"><center>" . $synciface . "</td>"; + echo "</tr>"; +} + +?> + +</table> +</td></tr> +</table> + +</form> +<?php include("fend.inc"); ?> +</body> +</html> + |