Copyright (C) 2008 Remco Hoef 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. */ $shortcut_section = "haproxy"; require_once("guiconfig.inc"); require_once("haproxy.inc"); require_once("certs.inc"); require_once("haproxy_utils.inc"); require_once("pkg_haproxy_tabs.inc"); $changedesc = "Services: HAProxy: Frontends"; if (!is_array($config['installedpackages']['haproxy']['ha_backends']['item'])) { $config['installedpackages']['haproxy']['ha_backends']['item'] = array(); } $a_frontend = &$config['installedpackages']['haproxy']['ha_backends']['item']; if($_GET['action'] == "toggle") { $id = $_GET['id']; echo "$id|"; if (isset($a_frontend[get_frontend_id($id)])) { $frontent = &$a_frontend[get_frontend_id($id)]; if ($frontent['status'] != "disabled"){ $frontent['status'] = 'disabled'; echo "0|"; }else{ $frontent['status'] = 'active'; echo "1|"; } $changedesc .= " set frontend '$id' status to: {$frontent['status']}"; touch($d_haproxyconfdirty_path); write_config($changedesc); } echo "ok|"; exit; } if ($_POST) { $pconfig = $_POST; if ($_POST['apply']) { $result = haproxy_check_and_run($savemsg, true); if ($result) unlink_if_exists($d_haproxyconfdirty_path); } } else { $result = haproxy_check_config($retval); if ($result) $savemsg = gettext($result); } $id = $_GET['id']; $id = get_frontend_id($id); if ($_GET['act'] == "del") { if (isset($a_frontend[$id])) { if (!$input_errors) { unset($a_frontend[$id]); write_config(); touch($d_haproxyconfdirty_path); } header("Location: haproxy_listeners.php"); exit; } } function haproxy_userlist_backend_servers($backendname) { //used for hint title text when hovering mouse over a backend name global $a_servermodes; $backend_servers = ""; $backend = get_backend($backendname); if ($backend && is_array($backend['ha_servers']) && is_array($backend['ha_servers']['item'])){ $servers = $backend['ha_servers']['item']; $backend_servers = sprintf(gettext("Servers in \"%s\" pool:"), $backendname); if (is_array($servers)){ foreach($servers as $server){ $srvstatus = $server['status']; $status = $a_servermodes[$srvstatus]['sign']; if (isset($server['forwardto']) && $server['forwardto'] != "") $backend_servers .= "\n{$status}[{$server['forwardto']}]"; else $backend_servers .= "\n{$status}{$server['address']}:{$server['port']}"; } } } return $backend_servers; } $pgtitle = "Services: HAProxy: Frontends"; include("head.inc"); haproxy_css(); ?>
"; print_info_box_np("The haproxy configuration has been changed.
You must apply the changes in order for them to take effect."); echo "
"; ?>
$b['secondary'] ? 1 : -1; if ($a['name'] != $b['name']) return $a['name'] > $b['name'] ? 1 : -1; return 0; } $a_frontend_grouped = array(); foreach($a_frontend as &$frontend2) { $mainfrontend = get_primaryfrontend($frontend2); $mainname = $mainfrontend['name']; $ipport = get_frontend_ipport($frontend2, true); $frontend2['ipport'] = $ipport; $frontend2['type'] = $mainfrontend['type']; $a_frontend_grouped[$mainname][] = $frontend2; } ksort($a_frontend_grouped); $img_cert = "/themes/{$g['theme']}/images/icons/icon_frmfld_cert.png"; $img_adv = "/themes/{$g['theme']}/images/icons/icon_advanced.gif"; $img_acl = "/themes/{$g['theme']}/images/icons/icon_ts_rule.gif"; $textgray = ""; $first = true; $last_frontend_shared = false; foreach ($a_frontend_grouped as $a_frontend) { usort($a_frontend, 'sort_sharedfrontends'); if ((count($a_frontend) > 1 || $last_frontend_shared) && !$first) { ?> 1; foreach ($a_frontend as $frontend) { $frontendname = $frontend['name']; $textgray = $frontend['status'] != 'active' ? " gray" : ""; ?>
On Primary Advanced Name Description Address Type Backend
 
" alt="icon" /> " ondblclick="document.location='haproxy_listeners_edit.php?id=';"> "; if (get_frontend_uses_ssl($frontend)) { $cert = lookup_cert($frontend['ssloffloadcert']); $descr = htmlspecialchars($cert['descr']); if (is_array($frontend['ha_certificates']) && is_array($frontend['ha_certificates']['item'])) { $certs = $frontend['ha_certificates']['item']; if (count($certs) > 0){ foreach($certs as $certitem){ $cert = lookup_cert($certitem['ssl_certificate']); $descr .= "\n".htmlspecialchars($cert['descr']); } } } echo 'SSL offloading'; } $isadvset = ""; if ($frontend['advanced_bind']) $isadvset .= "Advanced bind: ".htmlspecialchars($frontend['advanced_bind'])."\r\n"; if ($frontend['advanced']) $isadvset .= "Advanced pass thru setting used\r\n"; if ($isadvset) echo ""; ?> "; print "
"; print "{$addr['addr']}:{$addr['port']}"; if ($addr['ssl'] == 'yes') { echo 'SSL'; } print "
"; echo "{$backend}"; if (!empty($actionitem['acl'])) { echo " if({$actionitem['acl']})"; } echo "
"; } } } $hint = haproxy_userlist_backend_servers($frontend['backend_serverpool']); $backend = $frontend['backend_serverpool']; if (!empty($backend)) { echo "
"; echo "{$backend} (default)"; echo "
"; } ?>
" width="17" height="17" border="0" /> " width="17" height="17" border="0" /> " width="17" height="17" border="0" />
" width="17" height="17" border="0" />