summaryrefslogtreecommitdiffstats
path: root/etc
diff options
context:
space:
mode:
authorBill Marquette <billm@pfsense.org>2008-08-28 21:21:50 +0000
committerBill Marquette <billm@pfsense.org>2008-08-28 21:21:50 +0000
commit0919224fbd27505f35b94f4dd8a8070ceac153aa (patch)
tree748065cc800cd91a30db55a0b657665dc084d9f5 /etc
parent9557628b8ab7dafc01cb28173618d558280f2bb4 (diff)
downloadpfsense-0919224fbd27505f35b94f4dd8a8070ceac153aa.zip
pfsense-0919224fbd27505f35b94f4dd8a8070ceac153aa.tar.gz
Bring in relay options for inbound load balancer
More work pending, this seems to generate proper configs needs much more testing though
Diffstat (limited to 'etc')
-rw-r--r--etc/inc/vslb.inc82
-rw-r--r--etc/inc/xmlparse.inc26
2 files changed, 88 insertions, 20 deletions
diff --git a/etc/inc/vslb.inc b/etc/inc/vslb.inc
index d2488d9..e3a9566 100644
--- a/etc/inc/vslb.inc
+++ b/etc/inc/vslb.inc
@@ -118,13 +118,51 @@ class SendMonitor extends Monitor {
}
}
-
+function echo_lbaction($action) {
+ global $config;
+
+ // Index actions by name
+ $actions_a = array();
+ for ($i=0; isset($config['load_balancer']['lbaction'][$i]); $i++)
+ $actions_a[$config['load_balancer']['lbaction'][$i]['name']] = $config['load_balancer']['lbaction'][$i];
+
+ $ret = "";
+ $ret .= "{$actions_a[$action]['direction']} {$actions_a[$action]['type']} {$actions_a[$action]['action']}";
+ switch($actions_a[$action]['action']) {
+ case 'append': {
+ $ret .= " \"{$actions_a[$action]['options']['value']}\" to \"{$actions_a[$action]['options']['akey']}\"";
+ break;
+ }
+ case 'change': {
+ $ret .= " \"{$actions_a[$action]['options']['akey']}\" to \"{$actions_a[$action]['options']['value']}\"";
+ break;
+ }
+ case 'expect': {
+ $ret .= " \"{$actions_a[$action]['options']['value']}\" from \"{$actions_a[$action]['options']['akey']}\"";
+ break;
+ }
+ case 'filter': {
+ $ret .= " \"{$actions_a[$action]['options']['value']}\" from \"{$actions_a[$action]['options']['akey']}\"";
+ break;
+ }
+ case 'hash': {
+ $ret .= " \"{$actions_a[$action]['options']['akey']}\"";
+ break;
+ }
+ case 'log': {
+ $ret .= " \"{$actions_a[$action]['options']['akey']}\"";
+ break;
+ }
+ }
+ return $ret;
+}
function relayd_configure() {
global $config, $g;
$vs_a = &$config['load_balancer']['virtual_server'];
$pool_a = &$config['load_balancer']['lbpool'];
+ $protocol_a = &$config['load_balancer']['lbprotocol'];
$check_a = array();
@@ -170,16 +208,42 @@ function relayd_configure() {
}
}
}
-
+ if(is_array($protocol_a)) {
+ for ($i = 0; isset($protocol_a[$i]); $i++) {
+ $conf .= "protocol \"{$protocol_a[$i]['name']}\" {\n";
+ if(is_array($protocol_a[$i]['lbaction'])) {
+ for ($a = 0; isset($protocol_a[$i]['lbaction'][$a]); $a++) {
+ $conf .= " " . echo_lbaction($protocol_a[$i]['lbaction'][$a]) . "\n";
+ }
+ }
+ $conf .= "}\n";
+ }
+ }
if(is_array($vs_a)) {
for ($i = 0; isset($vs_a[$i]); $i++) {
- $conf .= "redirect \"{$vs_a[$i]['name']}\" {\n";
- $conf .= " listen on {$vs_a[$i]['ipaddr']} port {$vs_a[$i]['port']}\n";
- $conf .= " forward to <{$vs_a[$i]['pool']}> port {$pools[$vs_a[$i]['pool']]['port']} {$check_a[$pools[$vs_a[$i]['pool']]['monitor']]} timeout 1000\n";
-
- if (isset($vs_a[$i]['sitedown']) && $vs_a[$i]['sitedown'] != "")
- $conf .= " forward to <{$vs_a[$i]['sitedown']}> port {$pools[$vs_a[$i]['pool']]['port']} {$check_a[$pools[$vs_a[$i]['pool']]['monitor']]} timeout 1000\n";
- $conf .= "}\n";
+ switch($vs_a[$i]['mode']) {
+ case 'redirect': {
+ $conf .= "redirect \"{$vs_a[$i]['name']}\" {\n";
+ $conf .= " listen on {$vs_a[$i]['ipaddr']} port {$vs_a[$i]['port']}\n";
+ $conf .= " forward to <{$vs_a[$i]['pool']}> port {$pools[$vs_a[$i]['pool']]['port']} {$check_a[$pools[$vs_a[$i]['pool']]['monitor']]} timeout 1000\n";
+
+ if (isset($vs_a[$i]['sitedown']) && $vs_a[$i]['sitedown'] != "")
+ $conf .= " forward to <{$vs_a[$i]['sitedown']}> port {$pools[$vs_a[$i]['pool']]['port']} {$check_a[$pools[$vs_a[$i]['pool']]['monitor']]} timeout 1000\n";
+ $conf .= "}\n";
+ break;
+ }
+ case 'relay': {
+ $conf .= "relay \"{$vs_a[$i]['name']}\" {\n";
+ $conf .= " listen on {$vs_a[$i]['ipaddr']} port {$vs_a[$i]['port']}\n";
+ $conf .= " protocol \"{$vs_a[$i]['relay_protocol']}\"\n";
+ $conf .= " forward to <{$vs_a[$i]['pool']}> port {$pools[$vs_a[$i]['pool']]['port']} {$check_a[$pools[$vs_a[$i]['pool']]['monitor']]} timeout 1000\n";
+
+ if (isset($vs_a[$i]['sitedown']) && $vs_a[$i]['sitedown'] != "")
+ $conf .= " forward to <{$vs_a[$i]['sitedown']}> port {$pools[$vs_a[$i]['pool']]['port']} {$check_a[$pools[$vs_a[$i]['pool']]['monitor']]} timeout 1000\n";
+ $conf .= "}\n";
+ break;
+ }
+ }
}
}
fwrite($fd, $conf);
diff --git a/etc/inc/xmlparse.inc b/etc/inc/xmlparse.inc
index 1f5b24c..f4a9e12 100644
--- a/etc/inc/xmlparse.inc
+++ b/etc/inc/xmlparse.inc
@@ -32,18 +32,22 @@
/* The following items will be treated as arrays in config.xml */
function listtags() {
+ /* Please keep this list alpha sorted and no longer than 80 characters
+ * I know it's a pain, but it's a pain to find stuff too if it's not
+ */
$ret = explode(" ",
- "element alias aliasurl allowedip cacert config columnitem disk ".
- "dnsserver domainoverrides earlyshellcmd encryption-algorithm-option ".
- "field fieldname hash-algorithm-option hosts group member ca cert ".
- "interface_array item key lbpool menu mobilekey monitor_type ".
- "mount onetoone option ppp package passthrumac phase1 phase2 priv ".
- "proxyarpnet queue pages pipe route row rule schedule service ".
- "servernat servers serversdisabled earlyshellcmd shellcmd staticmap ".
- "subqueue timerange tunnel user authserver vip virtual_server vlan ".
- "winsserver ntpserver wolentry widget depends_on_package ".
- "gateway_item gateway_group dyndns dnsupdate gre gif bridged lagg ".
- "openvpn-server openvpn-client openvpn-csc");
+ "alias aliasurl allowedip authserver bridged ca cacert cert config ".
+ "columnitem depends_on_package disk dnsserver dnsupdate domainoverrides ".
+ "dyndns earlyshellcmd element encryption-algorithm-option field ".
+ "fieldname hash-algorithm-option gateway_item gateway_group gif gre ".
+ "group hosts member interface_array item key lagg lbaction lbpool ".
+ "lbprotocol member menu mobilekey monitor_type mount ntpserver onetoone ".
+ "openvpn-server openvpn-client openvpn-csc" .
+ "option ppp package passthrumac phase1 phase2 priv proxyarpnet queue ".
+ "pages pipe route row rule schedule service servernat servers ".
+ "serversdisabled earlyshellcmd shellcmd staticmap subqueue timerange ".
+ "tunnel user vip virtual_server vlan winsserver wolentry widget "
+ );
return $ret;
}
OpenPOWER on IntegriCloud