Project

General

Profile

Download (6.83 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/*
3
    carp_status.php
4
    Copyright (C) 2004 Scott Ullrich
5
    All rights reserved.
6

    
7
    Redistribution and use in source and binary forms, with or without
8
    modification, are permitted provided that the following conditions are met:
9

    
10
    1. Redistributions of source code must retain the above copyright notice,
11
       this list of conditions and the following disclaimer.
12

    
13
    2. Redistributions in binary form must reproduce the above copyright
14
       notice, this list of conditions and the following disclaimer in the
15
       documentation and/or other materials provided with the distribution.
16

    
17
    THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
18
    INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
19
    AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
20
    AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
21
    OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22
    SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23
    INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24
    CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25
    ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26
    POSSIBILITY OF SUCH DAMAGE.
27
*/
28

    
29
##|+PRIV
30
##|*IDENT=page-status-carp
31
##|*NAME=Status: CARP page
32
##|*DESCR=Allow access to the 'Status: CARP' page.
33
##|*MATCH=carp_status.php*
34
##|-PRIV
35

    
36
/*
37
	pfSense_BUILDER_BINARIES:	/sbin/sysctl	
38
	pfSense_MODULE:	carp
39
*/
40

    
41
require_once("guiconfig.inc");
42

    
43
function gentitle_pkg($pgname) {
44
	global $config;
45
	return $config['system']['hostname'] . "." . $config['system']['domain'] . " - " . $pgname;
46
}
47

    
48
unset($interface_arr_cache);
49
unset($carp_interface_count_cache);
50
unset($interface_ip_arr_cache);
51

    
52
$status = get_carp_status();
53
if($_POST['disablecarp'] <> "") {
54
	if($status == true) {
55
		mwexec("/sbin/sysctl net.inet.carp.allow=0");
56
		if(is_array($config['virtualip']['vip'])) {
57
			$viparr = &$config['virtualip']['vip'];
58
                	foreach ($viparr as $vip) {
59
                               	switch ($vip['mode']) {
60
                                       	case "carp":
61
                                       		interface_vip_bring_down($vip);
62
                                       		sleep(1);
63
                                       	break;
64
                                       	case "carpdev-dhcp":
65
                                       		interface_vip_bring_down($vip);
66
                                       		sleep(1);
67
                                       	break;
68
                               	}
69
                	}
70
        	}
71
		$savemsg = sprintf(gettext("%s IPs have been disabled. Please note that disabling does not survive a reboot."), $carp_counter);
72
	} else {
73
		$savemsg = gettext("CARP has been enabled.");
74
		if(is_array($config['virtualip']['vip'])) {
75
                        $viparr = &$config['virtualip']['vip'];
76
                        foreach ($viparr as $vip) {
77
				switch ($vip['mode']) {
78
					case "carp":
79
						interface_carp_configure($vip);
80
						sleep(1);
81
					break;
82
					case "carpdev-dhcp":
83
						interface_carpdev_configure($vip);
84
						sleep(1);
85
					break;
86
					case "ipalias":
87
						if (substr($vip['interface'], 0, 3) == "vip")
88
							interface_ipalias_configure($vip);
89
					break;
90
                                }
91
                        }
92
                }
93
		interfaces_carp_setup();
94
		mwexec("/sbin/sysctl net.inet.carp.allow=1");
95
	}
96
}
97

    
98
$status = get_carp_status();
99

    
100
$pgtitle = array(gettext("Status"),gettext("CARP"));
101
include("head.inc");
102

    
103
?>
104

    
105
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
106
<?php include("fbegin.inc"); ?>
107
<form action="carp_status.php" method="post">
108
<?php if ($savemsg) print_info_box($savemsg); ?>
109

    
110
<div id="mainlevel">
111
	<table width="100%" border="0" cellpadding="0" cellspacing="0">
112
		<tr>
113
			<td>
114
<?php
115
			$carpcount = 0;
116
			if(is_array($config['virtualip']['vip'])) {
117
				foreach($config['virtualip']['vip'] as $carp) {
118
					if ($carp['mode'] == "carp") {
119
						$carpcount++;
120
						break;
121
					}
122
				}
123
			}
124
			if($carpcount > 0) {
125
				if($status == false) {
126
					$carp_enabled = false;
127
					echo "<input type=\"submit\" name=\"disablecarp\" id=\"disablecarp\" value=\"" . gettext("Enable Carp") . "\">";
128
				} else {
129
					$carp_enabled = true;
130
					echo "<input type=\"submit\" name=\"disablecarp\" id=\"disablecarp\" value=\"" . gettext("Disable Carp") . "\">";
131
				}
132
			}
133
?>
134

    
135
			<p>
136
			<table class="tabcont sortable" width="100%" border="0" cellpadding="6" cellspacing="0">
137
				<tr>
138
					<td class="listhdrr"><b><center><?=gettext("CARP Interface"); ?></center></b></td>
139
					<td class="listhdrr"><b><center><?=gettext("Virtual IP"); ?></center></b></td>
140
					<td class="listhdrr"><b><center><?=gettext("Status"); ?></center></b></td>
141
				</tr>
142
<?php
143
				if ($carpcount == 0) {
144
					echo "</td></tr></table></table></div><center><br>" . gettext("Could not locate any defined CARP interfaces.");
145
					echo "</center>";
146

    
147
					include("fend.inc");
148
					echo "</body></html>";
149
					exit;
150
				}
151

    
152
				if(is_array($config['virtualip']['vip'])) {
153
					foreach($config['virtualip']['vip'] as $carp) {
154
						if ($carp['mode'] != "carp")
155
							continue;
156
						$ipaddress = $carp['subnet'];
157
						$password = $carp['password'];
158
						$netmask = $carp['subnet_bits'];
159
						$vhid = $carp['vhid'];
160
						$advskew = $carp['advskew'];
161
						$advbase = $carp['advbase'];
162
						$carp_int = "vip{$vhid}";
163
						$status = get_carp_interface_status($carp_int);
164
						echo "<tr>";
165
						$align = "valign='middle'";
166
						if($carp_enabled == false) {
167
							$icon = "<img {$align} src='/themes/".$g['theme']."/images/icons/icon_block.gif'>";
168
							$status = "DISABLED";
169
						} else {
170
							if($status == "MASTER") {
171
								$icon = "<img {$align} src='/themes/".$g['theme']."/images/icons/icon_pass.gif'>";
172
							} else if($status == "BACKUP") {
173
								$icon = "<img {$align} src='/themes/".$g['theme']."/images/icons/icon_pass_d.gif'>";
174
							} else if($status == "INIT") {
175
								$icon = "<img {$align} src='/themes/".$g['theme']."/images/icons/icon_log.gif'>";
176
							}
177
						}
178
						echo "<td class=\"listlr\"><center>" . $carp_int . "&nbsp;</td>";
179
						echo "<td class=\"listlr\"><center>" . $ipaddress . "&nbsp;</td>";
180
						echo "<td class=\"listlr\"><center>{$icon}&nbsp;&nbsp;" . $status . "&nbsp;</td>";
181
						echo "</tr>";
182
					}
183
				}
184
?>
185
			</table>
186
			</td>
187
		</tr>
188
	</table>
189
</div>
190

    
191
<p/>
192

    
193
<span class="vexpl">
194
<span class="red"><strong><?=gettext("Note"); ?>:</strong></span>
195
<br />
196
<?=gettext("You can configure CARP settings"); ?> <a href="pkg_edit.php?xml=carp_settings.xml&id=0"><?=gettext("here"); ?></a>.
197
</span>
198

    
199
<p/>
200

    
201
<?php
202
	echo "<br>" . gettext("pfSync nodes") . ":<br>";
203
	echo "<pre>";
204
	system("/sbin/pfctl -vvss | /usr/bin/grep creator | /usr/bin/cut -d\" \" -f7 | /usr/bin/sort -u");
205
	echo "</pre>";
206
?>
207

    
208
<?php include("fend.inc"); ?>
209

    
210
</body>
211
</html>
(3-3/239)