From 76a37ba111fd55e7ca5c4cde8288bead6fc21c8f Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Thu, 30 Apr 2009 19:28:10 +0000 Subject: [PATCH] Bootstrap code for boot-node moved to its class --- .../hub/main/nodes/boot/class_HubBootNode.php | 27 +++++++++++++++++-- .../hub/main/nodes/class_BaseHubNode.php | 27 +++---------------- 2 files changed, 28 insertions(+), 26 deletions(-) diff --git a/application/hub/main/nodes/boot/class_HubBootNode.php b/application/hub/main/nodes/boot/class_HubBootNode.php index b5bd06069..0be26c3d3 100644 --- a/application/hub/main/nodes/boot/class_HubBootNode.php +++ b/application/hub/main/nodes/boot/class_HubBootNode.php @@ -55,12 +55,35 @@ class HubBootNode extends BaseHubNode implements NodeHelper { * should communicate with the bootstrap-nodes at this point. * * @return void - * @todo Implement this method + * @todo add some more special bootstrap things for this boot node */ public function doBootstrapping () { // Call generic (parent) bootstrapping method parent::doGenericBootstrapping(); - $this->partialStub("Please implement this method."); + + // Now check if the IP address matches one of the bootstrap nodes + if ($this->ifAddressMatchesBootstrappingNodes($_SERVER['REMOTE_ADDR'])) { + // Get our port + $ourPort = $this->getConfigInstance()->readConfig('node_listen_port'); + + // Is the port the same? + if (substr($this->bootIpPort, -strlen($ourPort), strlen($ourPort)) == $ourPort) { + // It is the same! + $this->getDebugInstance()->output(__FUNCTION__.'['.__LINE__.']: IP/port matches bootstrapping node ' . $this->bootIpPort . '.'); + + // Now, does the mode match (should be 'boot'!) + if ($this->getRequestInstance()->getRequestElement('mode') == 'boot') { + // Output debug message + $this->getDebugInstance()->output(__FUNCTION__.'['.__LINE__.']: Our node is a valid bootstrapping node.'); + } else { + // Output warning + $this->getDebugInstance()->output(__FUNCTION__.'['.__LINE__.']: WARNING! Mismatching mode ' . $this->getRequestInstance()->getRequestElement('mode') . '!=boot detected.'); + } + } // END - if + } // END - if + + // This might not be all... + $this->partialStub("Please implement more bootsrapping steps."); } } diff --git a/application/hub/main/nodes/class_BaseHubNode.php b/application/hub/main/nodes/class_BaseHubNode.php index fe58930c2..c0dfac164 100644 --- a/application/hub/main/nodes/class_BaseHubNode.php +++ b/application/hub/main/nodes/class_BaseHubNode.php @@ -72,7 +72,7 @@ class BaseHubNode extends BaseFrameworkSystem implements Updateable { * @param $remoteAddr IP address to checkout against our bootstrapping list * @return $isFound Wether the IP is found */ - private function ifAddressMatchesBootstrappingNodes ($remoteAddr) { + protected function ifAddressMatchesBootstrappingNodes ($remoteAddr) { // By default nothing is found $isFound = false; @@ -87,7 +87,7 @@ class BaseHubNode extends BaseFrameworkSystem implements Updateable { $this->bootIpPort = $ipPort; // Output message - $this->getDebugInstance()->output(__FUNCTION__.': IP matches remote address ' . $ipPort . '.'); + $this->getDebugInstance()->output(__FUNCTION__.'['.__LINE__.']: IP matches remote address ' . $ipPort . '.'); // Stop further searching break; @@ -100,7 +100,7 @@ class BaseHubNode extends BaseFrameworkSystem implements Updateable { $this->bootIpPort = $ipPort; // Output message - $this->getDebugInstance()->output(__FUNCTION__.': IP matches listen address ' . $ipPort . '.'); + $this->getDebugInstance()->output(__FUNCTION__.'['.__LINE__.']: IP matches listen address ' . $ipPort . '.'); // Stop further searching break; @@ -140,27 +140,6 @@ class BaseHubNode extends BaseFrameworkSystem implements Updateable { * @return void */ protected function doGenericBootstrapping () { - // Now check if the IP address matches one of the bootstrap nodes - if ($this->ifAddressMatchesBootstrappingNodes($_SERVER['REMOTE_ADDR'])) { - // Get our port - $ourPort = $this->getConfigInstance()->readConfig('node_listen_port'); - - // Is the port the same? - if (substr($this->bootIpPort, -strlen($ourPort), strlen($ourPort)) == $ourPort) { - // It is the same! - $this->getDebugInstance()->output(__FUNCTION__.': IP/port matches bootstrapping node ' . $this->bootIpPort . '.'); - - // Now, does the mode match (should be 'boot'!) - if ($this->getRequestInstance()->getRequestElement('mode') == 'boot') { - // Output debug message - $this->getDebugInstance()->output(__FUNCTION__.': Our node is a valid bootstrapping node.'); - } else { - // Output warning - $this->getDebugInstance()->output(__FUNCTION__.': WARNING! Mismatching mode ' . $this->getRequestInstance()->getRequestElement('mode') . '!=boot detected.'); - } - } // END - if - } // END - if - // Finally output our teaser. This should be the last line! $this->outputConsoleTeaser(); } -- 2.39.5