Project

General

Profile

Download (5.36 KB) Statistics
| Branch: | Tag: | Revision:
1 94ac0ffc Bill Marquette
<?php
2 577c9191 Bill Marquette
/* $Id$ */
3 94ac0ffc Bill Marquette
/*
4
	load_balancer_pool.php
5 c7281770 Chris Buechler
	part of pfSense (https://www.pfsense.org/)
6 94ac0ffc Bill Marquette
7 ce77a9c4 Phil Davis
	Copyright (C) 2013-2015 Electric Sheep Fencing, LP
8 50d86c13 Bill Marquette
	Copyright (C) 2005-2008 Bill Marquette <bill.marquette@gmail.com>.
9 94ac0ffc Bill Marquette
	All rights reserved.
10
11
	Redistribution and use in source and binary forms, with or without
12
	modification, are permitted provided that the following conditions are met:
13
14
	1. Redistributions of source code must retain the above copyright notice,
15
	   this list of conditions and the following disclaimer.
16
17
	2. Redistributions in binary form must reproduce the above copyright
18
	   notice, this list of conditions and the following disclaimer in the
19
	   documentation and/or other materials provided with the distribution.
20
21
	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
22
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
23
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
25
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30
	POSSIBILITY OF SUCH DAMAGE.
31
*/
32 7ac5a4cb Scott Ullrich
/*
33
	pfSense_MODULE:	routing
34
*/
35 94ac0ffc Bill Marquette
36 6b07c15a Matthew Grooms
##|+PRIV
37
##|*IDENT=page-loadbalancer-pool
38
##|*NAME=Load Balancer: Pool page
39
##|*DESCR=Allow access to the 'Load Balancer: Pool' page.
40
##|*MATCH=load_balancer_pool.php*
41
##|-PRIV
42
43 3327ac10 Ermal
require_once("guiconfig.inc");
44 7a927e67 Scott Ullrich
require_once("functions.inc");
45
require_once("filter.inc");
46
require_once("shaper.inc");
47 94ac0ffc Bill Marquette
48 a9c6f68a Bill Marquette
if (!is_array($config['load_balancer']['lbpool'])) {
49
	$config['load_balancer']['lbpool'] = array();
50 94ac0ffc Bill Marquette
}
51 a9c6f68a Bill Marquette
$a_pool = &$config['load_balancer']['lbpool'];
52 94ac0ffc Bill Marquette
53 50d86c13 Bill Marquette
54 94ac0ffc Bill Marquette
if ($_POST) {
55
	$pconfig = $_POST;
56
57
	if ($_POST['apply']) {
58
		$retval = 0;
59 920b3bb0 Scott Ullrich
		$retval |= filter_configure();
60 17623ab5 Bill Marquette
		$retval |= relayd_configure();
61 920b3bb0 Scott Ullrich
62 94ac0ffc Bill Marquette
		$savemsg = get_std_save_message($retval);
63 a368a026 Ermal Lu?i
		clear_subsystem_dirty('loadbalancer');
64 94ac0ffc Bill Marquette
	}
65
}
66
67
if ($_GET['act'] == "del") {
68 3b15c32c jim-p
	if (array_key_exists($_GET['id'], $a_pool)) {
69 94ac0ffc Bill Marquette
		/* make sure no virtual servers reference this entry */
70
		if (is_array($config['load_balancer']['virtual_server'])) {
71
			foreach ($config['load_balancer']['virtual_server'] as $vs) {
72 6e9b046e jim-p
				if ($vs['poolname'] == $a_pool[$_GET['id']]['name']) {
73 019db2a3 Carlos Eduardo Ramos
					$input_errors[] = gettext("This entry cannot be deleted because it is still referenced by at least one virtual server.");
74 94ac0ffc Bill Marquette
					break;
75
				}
76
			}
77
		}
78
79
		if (!$input_errors) {
80
			unset($a_pool[$_GET['id']]);
81
			write_config();
82 a368a026 Ermal Lu?i
			mark_subsystem_dirty('loadbalancer');
83 94ac0ffc Bill Marquette
			header("Location: load_balancer_pool.php");
84
			exit;
85
		}
86
	}
87
}
88
89 50d86c13 Bill Marquette
/* Index monitor_type array for easy hyperlinking */
90
$mondex = array();
91
for ($i = 0; isset($config['load_balancer']['monitor_type'][$i]); $i++) {
92
	$mondex[$config['load_balancer']['monitor_type'][$i]['name']] = $i;
93
}
94
for ($i = 0; isset($config['load_balancer']['lbpool'][$i]); $i++) {
95
	$a_pool[$i]['monitor'] = "<a href=\"/load_balancer_monitor_edit.php?id={$mondex[$a_pool[$i]['monitor']]}\">{$a_pool[$i]['monitor']}</a>";
96
}
97
98 019db2a3 Carlos Eduardo Ramos
$pgtitle = array(gettext("Services"), gettext("Load Balancer"),gettext("Pool"));
99 b32dd0a6 jim-p
$shortcut_section = "relayd";
100 e234921a jim-p
101 94ac0ffc Bill Marquette
include("head.inc");
102
103
?>
104
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
105
<?php include("fbegin.inc"); ?>
106
<form action="load_balancer_pool.php" method="post">
107
<?php if ($input_errors) print_input_errors($input_errors); ?>
108
<?php if ($savemsg) print_info_box($savemsg); ?>
109 0e7aea24 Colin Fleming
<?php if (is_subsystem_dirty('loadbalancer')): ?><br/>
110 8cd558b6 ayvis
<?php print_info_box_np(sprintf(gettext("The load balancer configuration has been changed%sYou must apply the changes in order for them to take effect."), "<br />"));?><br />
111 94ac0ffc Bill Marquette
<?php endif; ?>
112 0e7aea24 Colin Fleming
<table width="100%" border="0" cellpadding="0" cellspacing="0" summary="load balancer pools">
113 94ac0ffc Bill Marquette
  <tr><td class="tabnavtbl">
114
  <?php
115
        /* active tabs */
116
        $tab_array = array();
117 019db2a3 Carlos Eduardo Ramos
        $tab_array[] = array(gettext("Pools"), true, "load_balancer_pool.php");
118
        $tab_array[] = array(gettext("Virtual Servers"), false, "load_balancer_virtual_server.php");
119 3e2165b6 jim-p
        $tab_array[] = array(gettext("Monitors"), false, "load_balancer_monitor.php");
120 259f606e Pierre POMES
        $tab_array[] = array(gettext("Settings"), false, "load_balancer_setting.php");
121 94ac0ffc Bill Marquette
        display_top_tabs($tab_array);
122
  ?>
123
  </td></tr>
124
  <tr>
125
    <td>
126
	<div id="mainarea">
127 0e7aea24 Colin Fleming
<?php
128 50d86c13 Bill Marquette
			$t = new MainTable();
129
			$t->edit_uri('load_balancer_pool_edit.php');
130
			$t->my_uri('load_balancer_pool.php');
131 d5bcf950 Carlos Eduardo Ramos
			$t->add_column(gettext('Name'),'name',10);
132 e0c27075 jim-p
			$t->add_column(gettext('Mode'),'mode',10);
133 d5bcf950 Carlos Eduardo Ramos
			$t->add_column(gettext('Servers'),'servers',15);
134
			$t->add_column(gettext('Port'),'port',10);
135 e0c27075 jim-p
			$t->add_column(gettext('Monitor'),'monitor',10);
136 e988813d jim-p
			$t->add_column(gettext('Description'),'descr',25);
137 50d86c13 Bill Marquette
			$t->add_button('edit');
138
			$t->add_button('dup');
139
			$t->add_button('del');
140
			$t->add_content_array($a_pool);
141
			$t->display();
142
?>
143
144
	</div>
145
    </td>
146
  </tr>
147 d89fdda0 jim-p
  <tr><td>
148 8cd558b6 ayvis
	<br /><span class="red"><strong><?=gettext("Hint:");?></strong></span><br />
149 d89fdda0 jim-p
	<?= sprintf(gettext("The Load Balancer in %s 2.0 is for server load balancing, not Multi-WAN. For load balancing or failover for multiple WANs, use "), $g['product_name']);?>
150
	<a href="/system_gateway_groups.php"><?= gettext("Gateway Groups"); ?></a>
151
  </td></tr>
152 50d86c13 Bill Marquette
</table>
153
</form>
154 94ac0ffc Bill Marquette
<?php include("fend.inc"); ?>
155
</body>
156
</html>