* @todo add some more special bootstrap things for this boot node
*/
public function doBootstrapping () {
- // @TODO Unfinished
- die(__METHOD__ . ':' . print_r($this, TRUE));
-
// Now check if the IP address matches one of the bootstrap nodes
- if ($this->ifAddressMatchesBootstrapNodes($this->getConfigInstance()->detectServerAddress())) {
+ if ($this->ifAddressMatchesBootstrapNodes($this->detectOwnUniversalNodeLocator())) {
// Get our port from configuration
$ourPort = $this->getConfigInstance()->getConfigEntry('node_listen_port');
}
} else {
// IP does match, but no port
- self::createDebugInstance(__CLASS__)->debugOutput('BOOTSTRAP: WARNING: Our IP ' . $this->getConfigInstance()->detectServerAddress() . ' does match a known bootstrap-node but not the port ' . $ourPort . '/' . $bootPort . '.');
+ self::createDebugInstance(__CLASS__)->debugOutput('BOOTSTRAP: WARNING: Our IP ' . $this->detectOwnUniversalNodeLocator() . ' does match a known bootstrap-node but not the port ' . $ourPort . '/' . $bootPort . '.');
}
} else {
// Node does not match any know bootstrap-node
- self::createDebugInstance(__CLASS__)->debugOutput('BOOTSTRAP: WARNING: Our IP ' . $this->getConfigInstance()->detectServerAddress() . ' does not match any known bootstrap-nodes.');
+ self::createDebugInstance(__CLASS__)->debugOutput('BOOTSTRAP: WARNING: Our IP ' . $this->detectOwnUniversalNodeLocator() . ' does not match any known bootstrap-nodes.');
}
// Enable acceptance of announcements
/**
* Universal node locator of bootstrap node
*/
- private $bootUnlInstance = '';
+ private $bootUnl = '';
/**
* Whether this node is anncounced (keep on FALSE!)
NodeStateFactory::createNodeStateInstanceByName('init', $this);
}
- /**
- * Generates a random string from various data inluding UUID if PECL
- * extension uuid is installed.
- *
- * @param $length Length of the random part
- * @return $randomString Random string
- * @todo Make this code more generic and move it to CryptoHelper or
- */
- protected function generateRamdomString ($length) {
- // Get an RNG instance
- $rngInstance = ObjectFactory::createObjectByConfiguredName('rng_class');
-
- // Generate a pseudo-random string
- $randomString = $rngInstance->randomString($length) . ':' . $this->getBootUniversalNodeLocator() . ':' . $this->getRequestInstance()->getRequestElement('mode');
-
- // Add UUID for even more entropy for the hasher
- $randomString .= $this->getCryptoInstance()->createUuid();
-
- // Return it
- return $randomString;
- }
-
/**
* Generates a private key and hashes it (for speeding up things)
*
self::createDebugInstance(__CLASS__)->debugOutput('BOOTSTRAP: Created new private key with hash: ' . $this->getPrivateKeyHash() . '');
}
+ /**
+ * Generates a random string from various data inluding UUID if PECL
+ * extension uuid is installed.
+ *
+ * @param $length Length of the random part
+ * @return $randomString Random string
+ * @todo Make this code more generic and move it to CryptoHelper or
+ */
+ protected function generateRamdomString ($length) {
+ // Get an RNG instance
+ $rngInstance = ObjectFactory::createObjectByConfiguredName('rng_class');
+
+ // Generate a pseudo-random string
+ $randomString = $rngInstance->randomString($length) . ':' . $this->getBootUniversalNodeLocator() . ':' . $this->getRequestInstance()->getRequestElement('mode');
+
+ // Add UUID for even more entropy for the hasher
+ $randomString .= $this->getCryptoInstance()->createUuid();
+
+ // Return it
+ return $randomString;
+ }
+
/**
* Getter for boot IP/port combination
*
- * @return $bootUnlInstance The IP/port combination of the boot node
+ * @return $bootUnl The IP/port combination of the boot node
*/
protected final function getBootUniversalNodeLocator () {
- return $this->bootUnlInstance;
+ return $this->bootUnl;
}
/**
$isFound = FALSE;
// Run through all configured IPs
- foreach (explode(BaseHubSystem::BOOTSTRAP_NODES_SEPARATOR, $this->getConfigInstance()->getConfigEntry('hub_bootstrap_nodes')) as $unlArray) {
+ foreach (explode(BaseHubSystem::BOOTSTRAP_NODES_SEPARATOR, $this->getConfigInstance()->getConfigEntry('hub_bootstrap_nodes')) as $unl) {
// @TODO Unfinished
- die(__METHOD__ . ':' . print_r($unlArray, TRUE));
+ die(__METHOD__ . ':' . print_r($this, TRUE));
+ die(__METHOD__ . ': unl=' . $unl . ',remoteAddr=' . $remoteAddr);
// Does it match?
- if ($unlArray[0] == $remoteAddr) {
+ if ($unl == $remoteAddr) {
// Found it!
$isFound = TRUE;
- // Remember the UNL array
- $this->bootUnlInstance = $unlArray;
+ // Remember the UNL
+ $this->bootUnl = $unl;
// Output message
- self::createDebugInstance(__CLASS__)->debugOutput('BOOTSTRAP: ' . __FUNCTION__ . '[' . __METHOD__ . ':' . __LINE__ . ']: IP matches remote address ' . $unlArray->__toString() . '.');
+ self::createDebugInstance(__CLASS__)->debugOutput('BOOTSTRAP: ' . __FUNCTION__ . '[' . __METHOD__ . ':' . __LINE__ . ']: IP matches remote address ' . $unl->__toString() . '.');
// Stop further searching
break;
- } elseif ($unlArray[0] == $this->getConfigInstance()->getConfigEntry('node_listen_addr')) {
+ } elseif ($unl == $this->getConfigInstance()->getConfigEntry('node_listen_addr')) {
/*
* IP matches listen address. At this point we really don't care
* if we can really listen on that address
$isFound = TRUE;
// Remember the port number
- $this->bootUnlInstance = $unlArray;
+ $this->bootUnl = $unl;
// Output message
- self::createDebugInstance(__CLASS__)->debugOutput('BOOTSTRAP: ' . __FUNCTION__ . '[' . __METHOD__ . ':' . __LINE__ . ']: IP matches listen address ' . $unlArray->__toString() . '.');
+ self::createDebugInstance(__CLASS__)->debugOutput('BOOTSTRAP: ' . __FUNCTION__ . '[' . __METHOD__ . ':' . __LINE__ . ']: IP matches listen address ' . $unl->__toString() . '.');
// Stop further searching
break;
return $isFound;
}
+ /**
+ * Tries to detect own UNL (Universal Node Locator)
+ *
+ * @return $unl Node's own universal node locator
+ */
+ public function detectOwnUniversalNodeLocator () {
+ // Get the UNL array back
+ $unlArray = $this->getUniversalNodeLocatorArray();
+
+ // @TODO
+ die(__METHOD__ . ':unlArray=' . print_r($unlArray, TRUE));
+ }
+
/**
* Outputs the console teaser. This should only be executed on startup or
* full restarts. This method generates some space around the teaser.