// Import SPL stuff
use \InvalidArgumentException;
+use \OutOfBoundsException;
use \UnexpectedValueException;
/**
// Stop further searching
break;
- } elseif ($unl == FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('node_listen_addr')) {
+ } elseif ($unl == FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('node_listen_address')) {
/*
* IP matches listen address. At this point we really don't care
* if we can really listen on that address
*
* @return void
* @throws UnexpectedValueException If private_key_hash is "invalid"
+ * @throws OutOfBoundsException If an array element is not found
*/
public function bootstrapGeneratePrivateKey () {
// Find node by id
$current = $resultInstance->current();
// Is the element set?
- if (is_null($current[NodeInformationDatabaseFrontend::DB_COLUMN_PRIVATE_KEY])) {
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-HUB-NODE: current(%s)=%d', NodeInformationDatabaseFrontend::DB_COLUMN_PRIVATE_KEY, array_key_exists(NodeInformationDatabaseFrontend::DB_COLUMN_PRIVATE_KEY, $current)));
+ //* DEBUG-DIE: */ ApplicationEntryPoint::exitApplication(sprintf('[%s:%d]: current[%s]=%s', __METHOD__, __LINE__, gettype($current), print_r($current, TRUE)));
+ if (!array_key_exists(NodeInformationDatabaseFrontend::DB_COLUMN_PRIVATE_KEY, $current)) {
+ // This should not happend
+ throw new OutOfBoundsException(sprintf('Array current[] does not contain element %s', NodeInformationDatabaseFrontend::DB_COLUMN_PRIVATE_KEY));
+ } elseif (empty($current[NodeInformationDatabaseFrontend::DB_COLUMN_PRIVATE_KEY])) {
/*
* Auto-generate the private key for e.g. out-dated database
* "tables". This allows a smooth update for the underlaying
* database table.
*/
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-HUB-NODE: Calling this->generatePrivateKeyAndHash(%s) ...', $this->getSearchInstance()->__toString()));
$this->generatePrivateKeyAndHash($this->getSearchInstance());
} else {
// Get the node id from result and set it
$criteriaInstance->addCriteria(NodeInformationDatabaseFrontend::DB_COLUMN_SESSION_ID, $this->getSessionId());
}
- // Add the private key if acquired
+ // Is the private key there?
if (!empty($this->getPrivateKey())) {
+ // Add the private key
$criteriaInstance->addCriteria(NodeInformationDatabaseFrontend::DB_COLUMN_PRIVATE_KEY , base64_encode($this->getPrivateKey()));
$criteriaInstance->addCriteria(NodeInformationDatabaseFrontend::DB_COLUMN_PRIVATE_KEY_HASH, $this->getNodePrivateKeyHash());
+ } else {
+ // Add empty fields
+ $criteriaInstance->addCriteria(NodeInformationDatabaseFrontend::DB_COLUMN_PRIVATE_KEY , NULL);
+ $criteriaInstance->addCriteria(NodeInformationDatabaseFrontend::DB_COLUMN_PRIVATE_KEY_HASH, NULL);
}
// Add own external and internal addresses as UNLs
$listenerInstance = ObjectFactory::createObjectByConfiguredName('tcp_listener_class');
// Setup address and port
- $listenerInstance->setListenAddressByConfiguration('node_listen_addr');
+ $listenerInstance->setListenAddressByConfiguration('node_listen_address');
/*
* All nodes can now use the same configuration entry because it can be
$listenerInstance = ObjectFactory::createObjectByConfiguredName('udp_listener_class');
// Setup address and port
- $listenerInstance->setListenAddressByConfiguration('node_listen_addr');
+ $listenerInstance->setListenAddressByConfiguration('node_listen_address');
/*
* All nodes can now use the same configuration entry because it can be