From aa78fde6a92f66b84d626e114d8b54a5fb6ece0c Mon Sep 17 00:00:00 2001
From: ftimme <ft@falkotimme.com>
Date: Wed, 14 Nov 2012 07:19:43 -0500
Subject: [PATCH] - Added function for IPv6 prefixes in multiserver mirror setups to nginx plugin.

---
 server/plugins-available/network_settings_plugin.inc.php |   20 ++++++++++++++++----
 1 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/server/plugins-available/network_settings_plugin.inc.php b/server/plugins-available/network_settings_plugin.inc.php
index 4b06006..8355d9e 100644
--- a/server/plugins-available/network_settings_plugin.inc.php
+++ b/server/plugins-available/network_settings_plugin.inc.php
@@ -79,8 +79,12 @@
 		$app->uses('getconf');
 		$server_config = $app->getconf->get_server_config($conf['server_id'], 'server');
 		
-		// Configure the debian network card settings
-		if($server_config['auto_network_configuration'] == 'y') {
+		//* Configure the debian network card settings.
+		//* Dont configure
+		if($server_config['auto_network_configuration'] == 'y' && 
+		   $data['mirrored'] == false &&
+		   $server_config['ip_address'] != '0.0.0.0' && 
+		   $server_config['gateway'] != '0.0.0.0') {
 			
 			if (is_file('/etc/debian_version')) 
 			{
@@ -97,7 +101,7 @@
 				$network_tpl->setVar('broadcast',$this->broadcast($server_config['ip_address'],$server_config['netmask']));
 				$network_tpl->setVar('network',$this->network($server_config['ip_address'],$server_config['netmask']));
 				
-				$records = $app->db->queryAllRecords("SELECT ip_address FROM server_ip WHERE server_id = ".intval($conf['server_id']) . ' order by ip_address');
+				$records = $app->db->queryAllRecords("SELECT ip_address FROM server_ip WHERE server_id = ".intval($conf['server_id']) . ' ORDER BY server_ip_id ASC');
 				$ip_records = array();
 				$additionl_ip_records = 0;
 				$n = 0;
@@ -129,6 +133,8 @@
 				 * main-server) because the LAST IP in the list is the IP mysql uses
 				 * to determine the host, the user is logging in from.
 				 */
+				/*
+				// Disabled this part as it causes problems on multiserver setups
 				if ($additionl_ip_records != 0)
 				{
 					$swap['ip_address'] = $ip_records[$n-1]['ip_address'];
@@ -149,6 +155,7 @@
 					$network_tpl->setVar('broadcast',$this->broadcast($swap['ip_address'],$swap['netmask']));
 					$network_tpl->setVar('network',$this->network($swap['ip_address'],$swap['netmask']));
 				}
+				*/
 				
 				$network_tpl->setVar('additionl_ip_records',$additionl_ip_records);
 				$network_tpl->setLoop('interfaces',$ip_records);
@@ -235,7 +242,12 @@
 			}
 			
 		} else {
-			$app->log('Network configuration disabled in server settings.',LOGLEVEL_WARN);
+			if($data['mirrored'] == true) {
+				$app->log('Skipping network config request. IP addresses from amster are not configured on the mirror.',LOGLEVEL_DEBUG);
+			} 
+			if($server_config['auto_network_configuration'] == 'n') {
+				$app->log('Network configuration disabled in server settings.',LOGLEVEL_DEBUG);
+			}
 		}
 		
 	}

--
Gitblit v1.9.1