From: Roland Häder Date: Thu, 18 Jan 2018 23:09:51 +0000 (+0100) Subject: Continued: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=cd38e5f0bde06a17615b476904791ee4fa99d178;p=hub.git Continued: - renamed NodeHelper -> Node and bound it to FrameworkInterface as this is no node helper (see Helper interface) but the node instance itself - fixed namespaces in class template files (no real class file, like "class_") - fixed "new" domain (shipsimu.org, without the dash) - fixed bug in bad private key's hash - need to create a dummy array with node data when node is starting first time (no data in db/node_data/ ) - started (unfinished) fixing assertions - updated core framework to latest commit Signed-off-by: Roland Häder --- diff --git a/application/hub/classes/apt-proxy/class_ b/application/hub/classes/apt-proxy/class_ index 4ecf08f34..953aaf76c 100644 --- a/application/hub/classes/apt-proxy/class_ +++ b/application/hub/classes/apt-proxy/class_ @@ -1,6 +1,6 @@ + * @author Roland Haeder * @version 0.0.0 * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org + * @link http://www.shipsimu.org * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -50,7 +50,5 @@ class ??? extends BaseHubSystem implements === { // Return the prepared instance return $!!!Instance; } -} -// [EOF] -?> +} diff --git a/application/hub/classes/class_Base b/application/hub/classes/class_Base index 65ff8cd26..286ec3a63 100644 --- a/application/hub/classes/class_Base +++ b/application/hub/classes/class_Base @@ -1,18 +1,18 @@ + * @author Roland Haeder * @version 0.0.0 * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org + * @link http://www.shipsimu.org * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -27,7 +27,7 @@ use Hub\Generic\BaseHubSystem; * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -class Base??? extends BaseHubSystem { +abstract class Base??? extends BaseHubSystem { /** * Protected constructor * @@ -38,7 +38,5 @@ class Base??? extends BaseHubSystem { // Call parent constructor parent::__construct($className); } -} -// [EOF] -?> +} diff --git a/application/hub/classes/communicator/class_ b/application/hub/classes/communicator/class_ index 4a7c8f4dd..fa62128eb 100644 --- a/application/hub/classes/communicator/class_ +++ b/application/hub/classes/communicator/class_ @@ -2,11 +2,11 @@ /** * A ???->node communicator class * - * @author Roland Haeder + * @author Roland Haeder * @version 0.0.0 * @copyright Copyright (c) 2014 !!! Developer Team * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org + * @link http://www.shipsimu.org * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -44,7 +44,5 @@ class ???NodeCommunicator extends BaseCommunicator implements Communicator { // Return the prepared instance return $communicatorInstance; } -} -// [EOF] -?> +} diff --git a/application/hub/classes/communicator/class_BaseCommunicator.php b/application/hub/classes/communicator/class_BaseCommunicator.php index 242a32c74..82068038c 100644 --- a/application/hub/classes/communicator/class_BaseCommunicator.php +++ b/application/hub/classes/communicator/class_BaseCommunicator.php @@ -12,11 +12,11 @@ use Org\Mxchange\CoreFramework\State\Stateable; /** * A general communicator class * - * @author Roland Haeder + * @author Roland Haeder * @version 0.0.0 * @copyright Copyright (c) 2015 Hub Developer Team * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org + * @link http://www.shipsimu.org * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/application/hub/classes/communicator/crawler/class_CrawlerNodeCommunicator.php b/application/hub/classes/communicator/crawler/class_CrawlerNodeCommunicator.php index ac1cdd8a9..4aa89ea15 100644 --- a/application/hub/classes/communicator/crawler/class_CrawlerNodeCommunicator.php +++ b/application/hub/classes/communicator/crawler/class_CrawlerNodeCommunicator.php @@ -12,11 +12,11 @@ use Org\Mxchange\CoreFramework\Registry\Registerable; /** * A crawler->node communicator class * - * @author Roland Haeder + * @author Roland Haeder * @version 0.0.0 * @copyright Copyright (c) 2014 Crawler Developer Team * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org + * @link http://www.shipsimu.org * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -54,7 +54,5 @@ class CrawlerNodeCommunicator extends BaseCommunicator implements Communicator, // Return the prepared instance return $communicatorInstance; } -} -// [EOF] -?> +} diff --git a/application/hub/classes/communicator/miner/class_MinerNodeCommunicator.php b/application/hub/classes/communicator/miner/class_MinerNodeCommunicator.php index cc6e29caa..200139bfb 100644 --- a/application/hub/classes/communicator/miner/class_MinerNodeCommunicator.php +++ b/application/hub/classes/communicator/miner/class_MinerNodeCommunicator.php @@ -12,11 +12,11 @@ use Org\Mxchange\CoreFramework\Registry\Registerable; /** * A miner->node communicator class * - * @author Roland Haeder + * @author Roland Haeder * @version 0.0.0 * @copyright Copyright (c) 2014 Miner Developer Team * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org + * @link http://www.shipsimu.org * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -54,7 +54,5 @@ class MinerNodeCommunicator extends BaseCommunicator implements Communicator, Re // Return the prepared instance return $communicatorInstance; } -} -// [EOF] -?> +} diff --git a/application/hub/classes/crawler/class_ b/application/hub/classes/crawler/class_ index c4b09bcc4..38069bafd 100644 --- a/application/hub/classes/crawler/class_ +++ b/application/hub/classes/crawler/class_ @@ -1,6 +1,6 @@ setUniqueKey(self::DB_COLUMN_NODE_ID); // Add registration elements to the dataset - $nodeInstance->addElementsToDataSet($dataSetInstance, $requestInstance); + $nodeInstance->addElementsToDataSet($dataSetInstance); // "Insert" this dataset instance completely into the database $this->queryInsertDataSet($dataSetInstance); @@ -135,11 +133,10 @@ class NodeInformationDatabaseWrapper extends BaseHubDatabaseWrapper implements N * This may sound confusing but avoids double code very nicely... * * @param $nodeInstance An instance of a BaseHubNode class - * @param $requestInstance An instance of a Requestable class * @param $searchInstance An instance of a LocalSearchCriteria class * @return void */ - public function registerSessionId (BaseHubNode $nodeInstance, Requestable $requestInstance, LocalSearchCriteria $searchInstance) { + public function registerSessionId (BaseHubNode $nodeInstance, LocalSearchCriteria $searchInstance) { // Get a dataset instance $dataSetInstance = ObjectFactory::createObjectByConfiguredName('dataset_criteria_class', array(self::DB_TABLE_NODE_INFORMATION)); @@ -150,7 +147,7 @@ class NodeInformationDatabaseWrapper extends BaseHubDatabaseWrapper implements N $dataSetInstance->setUniqueKey(self::DB_COLUMN_NODE_ID); // Add registration elements to the dataset - $nodeInstance->addElementsToDataSet($dataSetInstance, $requestInstance); + $nodeInstance->addElementsToDataSet($dataSetInstance); // Update database record $this->queryUpdateDataSet($dataSetInstance); @@ -161,11 +158,10 @@ class NodeInformationDatabaseWrapper extends BaseHubDatabaseWrapper implements N * This may sound confusing but avoids double code very nicely... * * @param $nodeInstance An instance of a BaseHubNode class - * @param $requestInstance An instance of a Requestable class * @param $searchInstance An instance of a LocalSearchCriteria class * @return void */ - public function registerPrivateKey (BaseHubNode $nodeInstance, Requestable $requestInstance, LocalSearchCriteria $searchInstance) { + public function registerPrivateKey (BaseHubNode $nodeInstance, LocalSearchCriteria $searchInstance) { // Get a dataset instance $dataSetInstance = ObjectFactory::createObjectByConfiguredName('dataset_criteria_class', array(self::DB_TABLE_NODE_INFORMATION)); @@ -176,7 +172,7 @@ class NodeInformationDatabaseWrapper extends BaseHubDatabaseWrapper implements N $dataSetInstance->setSearchInstance($searchInstance); // Add registration elements to the dataset - $nodeInstance->addElementsToDataSet($dataSetInstance, $requestInstance); + $nodeInstance->addElementsToDataSet($dataSetInstance); // Update database record $this->queryUpdateDataSet($dataSetInstance); diff --git a/application/hub/classes/decoder/class_ b/application/hub/classes/decoder/class_ index 00d19f96f..607849e30 100644 --- a/application/hub/classes/decoder/class_ +++ b/application/hub/classes/decoder/class_ @@ -1,19 +1,19 @@ + * @author Roland Haeder * @version 0.0.0 * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org + * @link http://www.shipsimu.org * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -51,7 +51,5 @@ class ???Decoder extends BaseDecoder implements Decodeable { // Return the prepared instance return $decoderInstance; } -} -// [EOF] -?> +} diff --git a/application/hub/classes/dht/class_ b/application/hub/classes/dht/class_ index cf2444172..e304b724d 100644 --- a/application/hub/classes/dht/class_ +++ b/application/hub/classes/dht/class_ @@ -1,10 +1,10 @@ resolveUniversalNodeLocatorFromNodeHelper($nodeInstance); + $unlInstance = $resolverInstance->resolveUniversalNodeLocatorFromNode($nodeInstance); + + // Is the instance given? + if (is_null($unlInstance)) { + // Throw NPE here + throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER); + } // END - if // ... and return it return $unlInstance; diff --git a/application/hub/classes/discovery/recipient/class_ b/application/hub/classes/discovery/recipient/class_ index c4d935900..609079c3a 100644 --- a/application/hub/classes/discovery/recipient/class_ +++ b/application/hub/classes/discovery/recipient/class_ @@ -1,9 +1,9 @@ + * @author Roland Haeder * @version 0.0.0 * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org + * @link http://www.shipsimu.org * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/application/hub/classes/factories/decoder/class_DecoderFactory.php b/application/hub/classes/factories/decoder/class_DecoderFactory.php index 01f62500f..8f3fb5827 100644 --- a/application/hub/classes/factories/decoder/class_DecoderFactory.php +++ b/application/hub/classes/factories/decoder/class_DecoderFactory.php @@ -13,11 +13,11 @@ use Org\Mxchange\CoreFramework\Registry\Registry; /** * A factory class for Decodeable objects * - * @author Roland Haeder + * @author Roland Haeder * @version 0.0.0 * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org + * @link http://www.shipsimu.org * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -67,7 +67,5 @@ class DecoderFactory extends ObjectFactory { // Return the instance return $decoderInstance; } -} -// [EOF] -?> +} diff --git a/application/hub/classes/factories/info/class_ConnectionInfoFactory.php b/application/hub/classes/factories/info/class_ConnectionInfoFactory.php index 4e318e2dd..18bcbd197 100644 --- a/application/hub/classes/factories/info/class_ConnectionInfoFactory.php +++ b/application/hub/classes/factories/info/class_ConnectionInfoFactory.php @@ -9,11 +9,11 @@ use Org\Mxchange\CoreFramework\Registry\Registry; /** * A factory class for ShareableInfo * - * @author Roland Haeder + * @author Roland Haeder * @version 0.0.0 * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2017 Hub Developer Team * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org + * @link http://www.shipsimu.org * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/application/hub/classes/factories/locator/class_UniversalNodeLocatorFactory.php b/application/hub/classes/factories/locator/class_UniversalNodeLocatorFactory.php index 01a655fed..fda188fd5 100644 --- a/application/hub/classes/factories/locator/class_UniversalNodeLocatorFactory.php +++ b/application/hub/classes/factories/locator/class_UniversalNodeLocatorFactory.php @@ -9,11 +9,11 @@ use Org\Mxchange\CoreFramework\Registry\Registry; /** * A factory class for LocateableNode * - * @author Roland Haeder + * @author Roland Haeder * @version 0.0.0 * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org + * @link http://www.shipsimu.org * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -47,7 +47,7 @@ class UniversalNodeLocatorFactory extends ObjectFactory { */ public static final function createUnlInstanceFromString ($unl) { // Trace message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('UNL-FACTORY: unl=%s - CALLED!', $unl)); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('UNL-FACTORY: unl=%s - CALLED!', $unl)); // If there is no handler? if (Registry::getRegistry()->instanceExists('unl_' . $unl)) { @@ -64,6 +64,9 @@ class UniversalNodeLocatorFactory extends ObjectFactory { Registry::getRegistry()->addInstance('unl_' . $unl, $unlInstance); } + // Trace message + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('UNL-FACTORY: unlInstance[]=%s - EXIT!', gettype($unlInstance))); + // Return the instance return $unlInstance; } diff --git a/application/hub/classes/factories/node/class_NodeObjectFactory.php b/application/hub/classes/factories/node/class_NodeObjectFactory.php index 383c89c5d..88ce7e927 100644 --- a/application/hub/classes/factories/node/class_NodeObjectFactory.php +++ b/application/hub/classes/factories/node/class_NodeObjectFactory.php @@ -42,11 +42,11 @@ class NodeObjectFactory extends ObjectFactory { } /** - * Returns a singleton (registry-based) NodeHelper instance + * Returns a singleton (registry-based) Node instance * * @param $requestInstance An instance of a class with an Requestable interface * @param $responseInstance An instance of a class with an Responseable interface - * @return $nodeInstance An instance of a NodeHelper class + * @return $nodeInstance An instance of a Node class * @throws FactoryRequiredParameterException If not all parameters are set and no instance 'node' is set. */ public static final function createNodeInstance (Requestable $requestInstance = NULL, Responseable $responseInstance = NULL) { diff --git a/application/hub/classes/factories/resolver/class_ProtocolResolverFactory.php b/application/hub/classes/factories/resolver/class_ProtocolResolverFactory.php index cca555209..d337e6b8d 100644 --- a/application/hub/classes/factories/resolver/class_ProtocolResolverFactory.php +++ b/application/hub/classes/factories/resolver/class_ProtocolResolverFactory.php @@ -10,11 +10,11 @@ use Org\Mxchange\CoreFramework\Registry\Registry; /** * A factory class for ProtocolResolver * - * @author Roland Haeder + * @author Roland Haeder * @version 0.0.0 * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org + * @link http://www.shipsimu.org * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -64,7 +64,5 @@ class ProtocolResolverFactory extends ObjectFactory { // Return the instance return $resolverInstance; } -} -// [EOF] -?> +} diff --git a/application/hub/classes/factories/scanner/class_ScannerObjectFactory.php b/application/hub/classes/factories/scanner/class_ScannerObjectFactory.php index 2112dbe78..bd73087d0 100644 --- a/application/hub/classes/factories/scanner/class_ScannerObjectFactory.php +++ b/application/hub/classes/factories/scanner/class_ScannerObjectFactory.php @@ -10,11 +10,11 @@ use Org\Mxchange\CoreFramework\Task\Taskable; /** * A factory class for scanners * - * @author Roland Haeder + * @author Roland Haeder * @version 0.0.0 * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org + * @link http://www.shipsimu.org * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -74,7 +74,5 @@ class ScannerObjectFactory extends ObjectFactory { // Return the instance return $scannerInstance; } -} -// [EOF] -?> +} diff --git a/application/hub/classes/factories/source/url/class_UrlSourceObjectFactory.php b/application/hub/classes/factories/source/url/class_UrlSourceObjectFactory.php index 77fe09951..ac8a99070 100644 --- a/application/hub/classes/factories/source/url/class_UrlSourceObjectFactory.php +++ b/application/hub/classes/factories/source/url/class_UrlSourceObjectFactory.php @@ -10,11 +10,11 @@ use Org\Mxchange\CoreFramework\Task\Taskable; /** * A factory class for URL sources * - * @author Roland Haeder + * @author Roland Haeder * @version 0.0.0 * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org + * @link http://www.shipsimu.org * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -74,7 +74,5 @@ class UrlSourceObjectFactory extends ObjectFactory { // Return the instance return $sourceInstance; } -} -// [EOF] -?> +} diff --git a/application/hub/classes/factories/states/node/class_NodeStateFactory.php b/application/hub/classes/factories/states/node/class_NodeStateFactory.php index 5f583c28c..c206eaa18 100644 --- a/application/hub/classes/factories/states/node/class_NodeStateFactory.php +++ b/application/hub/classes/factories/states/node/class_NodeStateFactory.php @@ -4,7 +4,7 @@ namespace Org\Shipsimu\Hub\Factory\State\Node; // Import application-specific stuff use Org\Shipsimu\Hub\Factory\Node\NodeObjectFactory; -use Org\Shipsimu\Hub\Helper\Node\NodeHelper; +use Org\Shipsimu\Hub\Node\Node; // Import framework stuff use Org\Mxchange\CoreFramework\Factory\ObjectFactory; @@ -47,10 +47,10 @@ class NodeStateFactory extends ObjectFactory { * given node instance. * * @param $stateName Name of the state - * @param $nodeInstance An instance of a NodeHelper class (optional) + * @param $nodeInstance An instance of a Node class (optional) * @return $stateInstance A Stateable class instance */ - public static final function createNodeStateInstanceByName ($stateName, NodeHelper $nodeInstance = NULL) { + public static final function createNodeStateInstanceByName ($stateName, Node $nodeInstance = NULL) { // Then construct the class' configuraton entry $className = 'node_' . $stateName . '_state_class'; diff --git a/application/hub/classes/feature/hubcoin_reward/class_HubcoinRewardFeature.php b/application/hub/classes/feature/hubcoin_reward/class_HubcoinRewardFeature.php index f24b413a0..aa2eafc9a 100644 --- a/application/hub/classes/feature/hubcoin_reward/class_HubcoinRewardFeature.php +++ b/application/hub/classes/feature/hubcoin_reward/class_HubcoinRewardFeature.php @@ -8,16 +8,16 @@ use Org\Mxchange\CoreFramework\Feature\Feature; use Org\Mxchange\CoreFramework\Feature\FrameworkFeature; // Import other libraries -use DomBlack\Scrypt\Scrypt; +use Com\Github\DomBlack\Scrypt\Scrypt; /** * A HubcoinReward Feature class * - * @author Roland Haeder + * @author Roland Haeder * @version 0.0.0 * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org + * @link http://www.shipsimu.org * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -63,13 +63,13 @@ class HubcoinRewardFeature extends BaseFeature implements Feature { */ public function isFeatureAvailable () { // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('[%s:%d]: CALLED!', __METHOD__, __LINE__)); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('[%s:%d]: CALLED!', __METHOD__, __LINE__)); // Testing this feature is pretty simple: $isAvailable = (($this->getConfigInstance()->getConfigEntry('extension_scrypt_loaded') === TRUE) && (extension_loaded('scrypt')) && (is_callable('scrypt'))); // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('[%s:%d]: isAvailable=%d - EXIT!', __METHOD__, __LINE__, intval($isAvailable))); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('[%s:%d]: isAvailable=%d - EXIT!', __METHOD__, __LINE__, intval($isAvailable))); // Return status return $isAvailable; @@ -87,7 +87,7 @@ class HubcoinRewardFeature extends BaseFeature implements Feature { */ public function featureMethodGenerateHash ($data) { // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('[%s:%d]: data()=%d - CALLED!', __METHOD__, __LINE__, strlen($data))); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('[%s:%d]: data()=%d - CALLED!', __METHOD__, __LINE__, strlen($data))); // Make sure the feature is available assert(FrameworkFeature::isFeatureAvailable('hubcoin_reward')); @@ -96,7 +96,7 @@ class HubcoinRewardFeature extends BaseFeature implements Feature { $hash = Scrypt::hashScrypt($data); // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('[%s:%d]: hash=%s - EXIT!', __METHOD__, __LINE__, $hash)); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('[%s:%d]: hash=%s - EXIT!', __METHOD__, __LINE__, $hash)); // Return generated hash return $hash; @@ -111,7 +111,7 @@ class HubcoinRewardFeature extends BaseFeature implements Feature { */ public function featureMethodCheckHash ($data, $hash) { // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('[%s:%d]: data()=%d,hash=%s - CALLED!', __METHOD__, __LINE__, strlen($data), $hash)); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('[%s:%d]: data()=%d,hash=%s - CALLED!', __METHOD__, __LINE__, strlen($data), $hash)); // Make sure the feature is available assert(FrameworkFeature::isFeatureAvailable('hubcoin_reward')); @@ -120,7 +120,7 @@ class HubcoinRewardFeature extends BaseFeature implements Feature { $isValid = Scrypt::checkScrypt($data, $hash); // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('[%s:%d]: isValid=%d - EXIT!', __METHOD__, __LINE__, intval($isValid))); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('[%s:%d]: isValid=%d - EXIT!', __METHOD__, __LINE__, intval($isValid))); // Return status return $isValid; diff --git a/application/hub/classes/filter/activation/node/class_NodeActivation b/application/hub/classes/filter/activation/node/class_NodeActivation index 39e116660..3e9b35f20 100644 --- a/application/hub/classes/filter/activation/node/class_NodeActivation +++ b/application/hub/classes/filter/activation/node/class_NodeActivation @@ -1,10 +1,10 @@ // Own namespace -namespace Hub\Listener\; +namespace Org\Mxchange\Hub\Listener\; // Import application-specific stuff -use Hub\Helper\Node\NodeHelper; -use Hub\Listener\BaseListener; -use Hub\Listener\Listenable; +use Org\Mxchange\Hub\Listener\BaseListener; +use Org\Mxchange\Hub\Listener\Listenable; +use Org\Mxchange\Hub\Node\Node; // Import framework stuff use Org\Mxchange\CoreFramework\Visitor\Visitable; @@ -181,10 +181,10 @@ class ???Listener extends BaseListener implements Listenable, Visitable { /** * Creates an instance of this class * - * @param $nodeInstance A NodeHelper instance + * @param $nodeInstance An instance of a Node class * @return $listenerInstance An instance a prepared listener class */ - public final static function create???Listener (NodeHelper $nodeInstance) { + public final static function create???Listener (Node $nodeInstance) { // Get new instance $listenerInstance = new ???Listener(); diff --git a/application/hub/classes/helper/class_ b/application/hub/classes/helper/class_ index e015699a7..2e6c4c32c 100644 --- a/application/hub/classes/helper/class_ +++ b/application/hub/classes/helper/class_ @@ -1,11 +1,11 @@ debugOutput('CONNECTION-HELPER: Failed to resolve ' . $packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT] . ':' . $e->getMessage()); - // Is the recipient equal as configured IP + // Is the recipient equal as configured UNL? if (substr($packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT], 0, strlen($helperInstance->getConfigInstance()->getConfigEntry('external_address'))) == $helperInstance->getConfigInstance()->getConfigEntry('external_address')) { // This may connect to shipsimu.org and requests 'ip.php' which will return our external IP address $unlAddress = HubTools::determineExternalAddress(); diff --git a/application/hub/classes/helper/node/announcement/class_NodeAnnouncementHelper.php b/application/hub/classes/helper/node/announcement/class_NodeAnnouncementHelper.php index c8fd61351..2a7e25add 100644 --- a/application/hub/classes/helper/node/announcement/class_NodeAnnouncementHelper.php +++ b/application/hub/classes/helper/node/announcement/class_NodeAnnouncementHelper.php @@ -5,9 +5,9 @@ namespace Org\Shipsimu\Hub\Node\Helper\Announcement; // Import application-specific stuff use Org\Shipsimu\Hub\Factory\Network\NetworkPackageFactory; use Org\Shipsimu\Hub\Helper\Node\BaseNodeHelper; -use Org\Shipsimu\Hub\Helper\Node\NodeHelper; +use Org\Shipsimu\Hub\Helper\Node\HelpableNode; use Org\Shipsimu\Hub\Network\Package\NetworkPackage; -use Org\Shipsimu\Hub\Node\Helper\HelpableNode; +use Org\Shipsimu\Hub\Node\Node; // Import framework stuff use Org\Mxchange\CoreFramework\Factory\Template\XmlTemplateEngineFactory; @@ -68,10 +68,10 @@ class NodeAnnouncementHelper extends BaseNodeHelper implements HelpableNode { /** * Loads the announcement descriptor for parsing * - * @param $nodeInstance An instance of a NodeHelper class + * @param $nodeInstance An instance of a Node class * @return void */ - public function loadDescriptorXml (NodeHelper $nodeInstance) { + public function loadDescriptorXml (Node $nodeInstance) { // Debug message self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('HELPER: Starting with announcement to upper hubs...'); @@ -95,10 +95,10 @@ class NodeAnnouncementHelper extends BaseNodeHelper implements HelpableNode { * the code. After this wents fine, the rendered content got "packaged" * for network delivery. * - * @param $nodeInstance An instance of a NodeHelper class + * @param $nodeInstance An instance of a Node class * @return void */ - public function sendPackage (NodeHelper $nodeInstance) { + public function sendPackage (Node $nodeInstance) { // Sanity check: Is the node in the approx. state? (active) $nodeInstance->getStateInstance()->validateNodeStateIsActiveOrReachable(); diff --git a/application/hub/classes/helper/node/answer/announcement/class_NodeAnnouncementMessageAnswerHelper.php b/application/hub/classes/helper/node/answer/announcement/class_NodeAnnouncementMessageAnswerHelper.php index 79942418a..a8b73bb93 100644 --- a/application/hub/classes/helper/node/answer/announcement/class_NodeAnnouncementMessageAnswerHelper.php +++ b/application/hub/classes/helper/node/answer/announcement/class_NodeAnnouncementMessageAnswerHelper.php @@ -4,8 +4,8 @@ namespace Org\Shipsimu\Hub\Node\Helper\Answer\Announcement; // Import application-specific stuff use Org\Shipsimu\Hub\Factory\Network\NetworkPackageFactory; -use Org\Shipsimu\Hub\Helper\Node\NodeHelper; -use Org\Shipsimu\Hub\Node\Helper\HelpableNode; +use Org\Shipsimu\Hub\Helper\Node\HelpableNode; +use Org\Shipsimu\Hub\Node\Node; // Import framework stuff use Org\Mxchange\CoreFramework\Factory\Template\XmlTemplateEngineFactory; @@ -70,10 +70,10 @@ class NodeAnnouncementMessageAnswerHelper extends BaseHubAnswerHelper implements /** * Loads the descriptor XML file * - * @param $nodeInstance An instance of a NodeHelper class + * @param $nodeInstance An instance of a Node class * @return void */ - public function loadDescriptorXml (NodeHelper $nodeInstance) { + public function loadDescriptorXml (Node $nodeInstance) { // Debug message self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('HELPER: Attempting to answer an announcement...'); @@ -93,10 +93,10 @@ class NodeAnnouncementMessageAnswerHelper extends BaseHubAnswerHelper implements /** * Send out announcement answer package * - * @param $nodeInstance An instance of a NodeHelper class + * @param $nodeInstance An instance of a Node class * @return void */ - public function sendPackage (NodeHelper $nodeInstance) { + public function sendPackage (Node $nodeInstance) { // Sanity check: Is the node in the approx. state? (active/reachable) $nodeInstance->getStateInstance()->validateNodeStateIsActiveOrReachable(); diff --git a/application/hub/classes/helper/node/answer/dht/class_NodeDhtBootstrapMessageAnswerHelper.php b/application/hub/classes/helper/node/answer/dht/class_NodeDhtBootstrapMessageAnswerHelper.php index 6903b0ce2..07185e6b0 100644 --- a/application/hub/classes/helper/node/answer/dht/class_NodeDhtBootstrapMessageAnswerHelper.php +++ b/application/hub/classes/helper/node/answer/dht/class_NodeDhtBootstrapMessageAnswerHelper.php @@ -4,8 +4,8 @@ namespace Org\Shipsimu\Hub\Node\Helper\Answer\Dht\Bootstrap; // Import application-specific stuff use Org\Shipsimu\Hub\Factory\Network\NetworkPackageFactory; -use Org\Shipsimu\Hub\Helper\Node\NodeHelper; -use Org\Shipsimu\Hub\Node\Helper\HelpableNode; +use Org\Shipsimu\Hub\Helper\Node\HelpableNode; +use Org\Shipsimu\Hub\Node\Node; use Org\Shipsimu\Hub\Template\Engine\Xml\Dht\Bootstrap\XmlDhtBootstrapTemplateEngine; // Import framework stuff @@ -71,10 +71,10 @@ class NodeDhtBootstrapMessageAnswerHelper extends BaseHubAnswerHelper implements /** * Loads the descriptor XML file * - * @param $nodeInstance An instance of a NodeHelper class + * @param $nodeInstance An instance of a Node class * @return void */ - public function loadDescriptorXml (NodeHelper $nodeInstance) { + public function loadDescriptorXml (Node $nodeInstance) { // Debug message self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('HELPER: Attempting to answer a DHT bootstrap request...'); @@ -94,10 +94,10 @@ class NodeDhtBootstrapMessageAnswerHelper extends BaseHubAnswerHelper implements /** * Send out announcement answer package * - * @param $nodeInstance An instance of a NodeHelper class + * @param $nodeInstance An instance of a Node class * @return void */ - public function sendPackage (NodeHelper $nodeInstance) { + public function sendPackage (Node $nodeInstance) { // Sanity check: Is the node in the approx. state? (active/reachable) $nodeInstance->getStateInstance()->validateNodeStateIsActiveOrReachable(); diff --git a/application/hub/classes/helper/node/answer/requests/class_NodeRequestNodeListMessageAnswerHelper.php b/application/hub/classes/helper/node/answer/requests/class_NodeRequestNodeListMessageAnswerHelper.php index 623bd4eb0..76215f0b6 100644 --- a/application/hub/classes/helper/node/answer/requests/class_NodeRequestNodeListMessageAnswerHelper.php +++ b/application/hub/classes/helper/node/answer/requests/class_NodeRequestNodeListMessageAnswerHelper.php @@ -4,8 +4,8 @@ namespace Org\Shipsimu\Hub\Node\Helper\Answer\Request\NodeList; // Import application-specific stuff use Org\Shipsimu\Hub\Factory\Network\NetworkPackageFactory; -use Org\Shipsimu\Hub\Helper\Node\NodeHelper; -use Org\Shipsimu\Hub\Node\Helper\HelpableNode; +use Org\Shipsimu\Hub\Helper\Node\HelpableNode; +use Org\Shipsimu\Hub\Node\Node; // Import framework stuff use Org\Mxchange\CoreFramework\Factory\Template\XmlTemplateEngineFactory; @@ -70,10 +70,10 @@ class NodeRequestNodeListMessageAnswerHelper extends BaseHubAnswerHelper impleme /** * Loads the descriptor XML file * - * @param $nodeInstance An instance of a NodeHelper class + * @param $nodeInstance An instance of a Node class * @return void */ - public function loadDescriptorXml (NodeHelper $nodeInstance) { + public function loadDescriptorXml (Node $nodeInstance) { // Debug message self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('HELPER: Attempting to answer a request: node-list...'); @@ -99,10 +99,10 @@ class NodeRequestNodeListMessageAnswerHelper extends BaseHubAnswerHelper impleme /** * Send out request-node-list answer package * - * @param $nodeInstance An instance of a NodeHelper class + * @param $nodeInstance An instance of a Node class * @return void */ - public function sendPackage (NodeHelper $nodeInstance) { + public function sendPackage (Node $nodeInstance) { // Sanity check: Is the node in the approx. state? (active/reachable) $nodeInstance->getStateInstance()->validateNodeStateIsActiveOrReachable(); diff --git a/application/hub/classes/helper/node/class_ b/application/hub/classes/helper/node/class_ index 908c32e61..8ed54ad1c 100644 --- a/application/hub/classes/helper/node/class_ +++ b/application/hub/classes/helper/node/class_ @@ -1,13 +1,13 @@ . */ -class Node???Helper extends BaseNodeHelper implements HelpableNode { +class Node???Helper extends BaseNode implements HelpableNode { /** * Protected constructor * @@ -71,10 +71,10 @@ class Node???Helper extends BaseNodeHelper implements HelpableNode { /** * Do the helped attempt by delivering a package to ourselfs * - * @param $nodeInstance An instance of a NodeHelper class + * @param $nodeInstance An instance of a Node class * @return void */ - public function sendPackage (NodeHelper $nodeInstance) { + public function sendPackage (Node $nodeInstance) { // Sanity check: Is the node in the approx. state? (active) $nodeInstance->getStateInstance()->validateNodeStateIsActive(); diff --git a/application/hub/classes/helper/node/class_BaseNodeHelper.php b/application/hub/classes/helper/node/class_BaseNodeHelper.php index 3706ec807..c04143e73 100644 --- a/application/hub/classes/helper/node/class_BaseNodeHelper.php +++ b/application/hub/classes/helper/node/class_BaseNodeHelper.php @@ -28,7 +28,7 @@ use Org\Shipsimu\Hub\Helper\BaseHubSystemHelper; * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -class BaseNodeHelper extends BaseHubSystemHelper { +abstract class BaseNodeHelper extends BaseHubSystemHelper { /** * Protected constructor * diff --git a/application/hub/classes/helper/node/connection/class_NodeSelfConnectHelper.php b/application/hub/classes/helper/node/connection/class_NodeSelfConnectHelper.php index 2c2cbb73f..b7b3f28bb 100644 --- a/application/hub/classes/helper/node/connection/class_NodeSelfConnectHelper.php +++ b/application/hub/classes/helper/node/connection/class_NodeSelfConnectHelper.php @@ -5,9 +5,9 @@ namespace Org\Shipsimu\Hub\Node\Helper\SelfConnect; // Import application-specific stuff use Org\Shipsimu\Hub\Factory\Network\NetworkPackageFactory; use Org\Shipsimu\Hub\Helper\Node\BaseNodeHelper; -use Org\Shipsimu\Hub\Helper\Node\NodeHelper; +use Org\Shipsimu\Hub\Helper\Node\HelpableNode; use Org\Shipsimu\Hub\Network\Package\NetworkPackage; -use Org\Shipsimu\Hub\Node\Helper\HelpableNode; +use Org\Shipsimu\Hub\Node\Node; use Org\Shipsimu\Hub\Tag\Tagable; // Import framework stuff @@ -69,10 +69,10 @@ class NodeSelfConnectHelper extends BaseNodeHelper implements HelpableNode { /** * Loads the descriptor XML file * - * @param $nodeInstance An instance of a NodeHelper class + * @param $nodeInstance An instance of a Node class * @return void */ - public function loadDescriptorXml (NodeHelper $nodeInstance) { + public function loadDescriptorXml (Node $nodeInstance) { // Debug message self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('HELPER: Attempting self-connect...'); @@ -92,10 +92,10 @@ class NodeSelfConnectHelper extends BaseNodeHelper implements HelpableNode { /** * Do the self-connect attempt by delivering a package to ourselfs * - * @param $nodeInstance An instance of a NodeHelper class + * @param $nodeInstance An instance of a Node class * @return void */ - public function sendPackage (NodeHelper $nodeInstance) { + public function sendPackage (Node $nodeInstance) { // Sanity check: Is the node in the approx. state? (active) $nodeInstance->getStateInstance()->validateNodeStateIsActiveOrAnnouncing(); diff --git a/application/hub/classes/helper/node/requests/class_NodeRequestNodeListHelper.php b/application/hub/classes/helper/node/requests/class_NodeRequestNodeListHelper.php index 0ac6ef599..479a44927 100644 --- a/application/hub/classes/helper/node/requests/class_NodeRequestNodeListHelper.php +++ b/application/hub/classes/helper/node/requests/class_NodeRequestNodeListHelper.php @@ -5,9 +5,9 @@ namespace Org\Shipsimu\Hub\Node\Helper\Request\NodeList; // Import application-specific stuff use Org\Shipsimu\Hub\Factory\Network\NetworkPackageFactory; use Org\Shipsimu\Hub\Helper\Node\BaseNodeHelper; -use Org\Shipsimu\Hub\Helper\Node\NodeHelper; +use Org\Shipsimu\Hub\Helper\Node\HelpableNode; use Org\Shipsimu\Hub\Network\Package\NetworkPackage; -use Org\Shipsimu\Hub\Node\Helper\HelpableNode; +use Org\Shipsimu\Hub\Node\Node; // Import framework stuff use Org\Mxchange\CoreFramework\Factory\Template\XmlTemplateEngineFactory; @@ -68,10 +68,10 @@ class NodeRequestNodeListHelper extends BaseNodeHelper implements HelpableNode { /** * Loads the descriptor XML file * - * @param $nodeInstance An instance of a NodeHelper class + * @param $nodeInstance An instance of a Node class * @return void */ - public function loadDescriptorXml (NodeHelper $nodeInstance) { + public function loadDescriptorXml (Node $nodeInstance) { // Debug message self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('HELPER: Attempting to request: node-list...'); @@ -91,10 +91,10 @@ class NodeRequestNodeListHelper extends BaseNodeHelper implements HelpableNode { /** * Do the helped attempt by delivering a package to ourselfs * - * @param $nodeInstance An instance of a NodeHelper class + * @param $nodeInstance An instance of a Node class * @return void */ - public function sendPackage (NodeHelper $nodeInstance) { + public function sendPackage (Node $nodeInstance) { // Sanity check: Is the node in the approx. state? (active) $nodeInstance->getStateInstance()->validateNodeStateIsAnnouncementCompleted(); diff --git a/application/hub/classes/info/class_ b/application/hub/classes/info/class_ index a7d46d78d..ae12e1b7c 100644 --- a/application/hub/classes/info/class_ +++ b/application/hub/classes/info/class_ @@ -1,10 +1,10 @@ + * @author Roland Haeder * @version 0.0.0 * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2017 Hub Developer Team * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org + * @link http://www.shipsimu.org * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/application/hub/classes/listener/socket/class_SocketFileListener.php b/application/hub/classes/listener/socket/class_SocketFileListener.php index f865ead7e..59c0ca43e 100644 --- a/application/hub/classes/listener/socket/class_SocketFileListener.php +++ b/application/hub/classes/listener/socket/class_SocketFileListener.php @@ -16,11 +16,11 @@ use Org\Mxchange\CoreFramework\Factory\ObjectFactory; /** * A file-based socket listener * - * @author Roland Haeder + * @author Roland Haeder * @version 0.0.0 * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2017 Hub Developer Team * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org + * @link http://www.shipsimu.org * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/application/hub/classes/listener/tcp/class_ b/application/hub/classes/listener/tcp/class_ index 6f2931806..a9bd0c4ad 100644 --- a/application/hub/classes/listener/tcp/class_ +++ b/application/hub/classes/listener/tcp/class_ @@ -133,12 +133,12 @@ socket_close($mainSocket); ?> // Own namespace -namespace Hub\Listener\Tcp\; +namespace Org\Mxchange\Hub\Listener\Tcp\; // Import application-specific stuff -use Hub\Helper\Node\NodeHelper; -use Hub\Listener\BaseListener; -use Hub\Listener\Listenable; +use Org\Mxchange\Hub\Node\Node; +use Org\Mxchange\Hub\Listener\BaseListener; +use Org\Mxchange\Hub\Listener\Listenable; // Import framework stuff use Org\Mxchange\CoreFramework\Visitor\Visitable; @@ -147,11 +147,11 @@ use Org\Mxchange\CoreFramework\Visitor\Visitable; /** * A TCP ??? listener * - * @author Roland Haeder + * @author Roland Haeder * @version 0.0.0 * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org + * @link http://www.shipsimu.org * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -180,10 +180,10 @@ class ???Listener extends BaseListener implements Listenable, Visitable { /** * Creates an instance of this class * - * @param $nodeInstance A NodeHelper instance +a * @param $nodeInstance An instance of a Node class * @return $listenerInstance An instance a prepared listener class */ - public final static function create???Listener (NodeHelper $nodeInstance) { + public final static function create???Listener (Node $nodeInstance) { // Get new instance $listenerInstance = new ???Listener(); @@ -213,7 +213,5 @@ class ???Listener extends BaseListener implements Listenable, Visitable { public function doListen() { $this->partialStub('Need to implement this method.'); } -} -// [EOF] -?> +} diff --git a/application/hub/classes/listener/udp/class_ b/application/hub/classes/listener/udp/class_ index 4764ba5ee..baa5b2334 100644 --- a/application/hub/classes/listener/udp/class_ +++ b/application/hub/classes/listener/udp/class_ @@ -1,22 +1,22 @@ + * @author Roland Haeder * @version 0.0.0 * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org + * @link http://www.shipsimu.org * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -45,10 +45,10 @@ class Udp???Listener extends BaseListener implements Listenable { /** * Creates an instance of this class * - * @param $nodeInstance A NodeHelper instance + * @param $nodeInstance An instance of a Node class * @return $listenerInstance An instance a prepared listener class */ - public final static function createUdp???Listener (NodeHelper $nodeInstance) { + public final static function createUdp???Listener (Node $nodeInstance) { // Get new instance $listenerInstance = new Udp???Listener(); @@ -78,7 +78,5 @@ class Udp???Listener extends BaseListener implements Listenable { public function doListen() { $this->partialStub('Need to implement this method.'); } -} -// [EOF] -?> +} diff --git a/application/hub/classes/miner/class_ b/application/hub/classes/miner/class_ index 48feec9d4..e8b5b36cf 100644 --- a/application/hub/classes/miner/class_ +++ b/application/hub/classes/miner/class_ @@ -1,6 +1,6 @@ + * @author Roland Haeder * @version 0.0.0 * @copyright Copyright (c) 2014 Miner Developer Team * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org + * @link http://www.shipsimu.org * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -86,7 +86,5 @@ class Hub???Miner extends BaseHubMiner implements MinerHelper, Registerable { public function addExtraHubFilters () { // Add some filters here } -} -// [EOF] -?> +} diff --git a/application/hub/classes/nodes/boot/class_HubBootNode.php b/application/hub/classes/nodes/boot/class_HubBootNode.php index d029e5a94..54232ea84 100644 --- a/application/hub/classes/nodes/boot/class_HubBootNode.php +++ b/application/hub/classes/nodes/boot/class_HubBootNode.php @@ -4,7 +4,7 @@ namespace Org\Shipsimu\Hub\Node\Boot; // Import application-specific stuff use Org\Shipsimu\Hub\Node\BaseHubNode; -use Org\Shipsimu\Hub\Helper\Node\NodeHelper; +use Org\Shipsimu\Hub\Node\Node; // Import framework stuff use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap; @@ -35,7 +35,7 @@ use Org\Mxchange\CoreFramework\Registry\Registerable; * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -class HubBootNode extends BaseHubNode implements NodeHelper, Registerable { +class HubBootNode extends BaseHubNode implements Node, Registerable { /** * Protected constructor * @@ -47,10 +47,10 @@ class HubBootNode extends BaseHubNode implements NodeHelper, Registerable { } /** - * Creates an instance of this hub-node class + * Creates an instance of a Node class * * @param $requestInstance An instance of a Requestable class - * @return $nodeInstance An instance of this hub-node class + * @return $nodeInstance An instance of a Node class */ public static final function createHubBootNode () { // Get a new instance diff --git a/application/hub/classes/nodes/class_ b/application/hub/classes/nodes/class_ index 900d4a470..32ebf2c15 100644 --- a/application/hub/classes/nodes/class_ +++ b/application/hub/classes/nodes/class_ @@ -1,10 +1,10 @@ . */ -class Hub???Node extends BaseHubNode implements NodeHelper, Registerable { +class Hub???Node extends BaseHubNode implements Node, Registerable { /** * Protected constructor * @@ -43,9 +43,9 @@ class Hub???Node extends BaseHubNode implements NodeHelper, Registerable { } /** - * Creates an instance of this hub-node class + * Creates an instance of a Node class * - * @return $nodeInstance An instance of this hub-node class + * @return $nodeInstance An instance of a Node class */ public final static function createHub???Node () { // Get a new instance diff --git a/application/hub/classes/nodes/class_BaseHubNode.php b/application/hub/classes/nodes/class_BaseHubNode.php index 7213342cd..22a0af395 100644 --- a/application/hub/classes/nodes/class_BaseHubNode.php +++ b/application/hub/classes/nodes/class_BaseHubNode.php @@ -149,7 +149,7 @@ abstract class BaseHubNode extends BaseHubSystem implements Updateable, AddableC $this->setPrivateKeyHash($this->getCryptoInstance()->hashString($this->getPrivateKey())); // Register the node id with our wrapper - $this->getWrapperInstance()->registerPrivateKey($this, FrameworkBootstrap::getRequestInstance(), $searchInstance); + $this->getWrapperInstance()->registerPrivateKey($this, $searchInstance); // Output message self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BOOTSTRAP: Created new private key with hash: ' . $this->getPrivateKeyHash() . ''); @@ -313,7 +313,7 @@ abstract class BaseHubNode extends BaseHubSystem implements Updateable, AddableC $this->setNodeId($this->getCryptoInstance()->hashString($this->getCryptoInstance()->encryptString($randomString))); // Register the node id with our wrapper - $this->getWrapperInstance()->registerNodeId($this, FrameworkBootstrap::getRequestInstance()); + $this->getWrapperInstance()->registerNodeId($this); // Output message self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BOOTSTRAP: Created new node-id: ' . $this->getNodeId() . ''); @@ -345,7 +345,7 @@ abstract class BaseHubNode extends BaseHubSystem implements Updateable, AddableC $this->setSessionId($this->getCryptoInstance()->hashString($this->getCryptoInstance()->encryptString($randomString))); // Register the node id with our wrapper - $this->getWrapperInstance()->registerSessionId($this, FrameworkBootstrap::getRequestInstance(), $searchInstance); + $this->getWrapperInstance()->registerSessionId($this, $searchInstance); // Output message self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BOOTSTRAP: Created new session-id: ' . $this->getSessionId() . ''); @@ -390,13 +390,12 @@ abstract class BaseHubNode extends BaseHubSystem implements Updateable, AddableC /** * Adds hub data elements to a given dataset instance * - * @param $criteriaInstance An instance of a storeable criteria - * @param $requestInstance An instance of a Requestable class + * @param $criteriaInstance An instance of a StoreableCriteria class * @return void */ - public function addElementsToDataSet (StoreableCriteria $criteriaInstance, Requestable $requestInstance = NULL) { - // Make sure the request instance is set as it is not optional. - assert($requestInstance instanceof Requestable); + public function addElementsToDataSet (StoreableCriteria $criteriaInstance) { + // Get request instance + $requestInstance = FrameworkBootstrap::getRequestInstance(); // Add node number and type $criteriaInstance->addCriteria(NodeInformationDatabaseWrapper::DB_COLUMN_NODE_NR , 1); @@ -854,4 +853,40 @@ abstract class BaseHubNode extends BaseHubSystem implements Updateable, AddableC } // END - foreac } + /** + * Creates a data array for this node suitable for UNL-generation. + * + * @return $nodeData Node's data + */ + public function createNodeDataArray () { + // Get request instance + $requestInstance = FrameworkBootstrap::getRequestInstance(); + + // Create array with all available data + $nodeData = array( + NodeInformationDatabaseWrapper::DB_COLUMN_NODE_NR => NULL, + NodeInformationDatabaseWrapper::DB_COLUMN_NODE_MODE => $requestInstance->getRequestElement('mode'), + NodeInformationDatabaseWrapper::DB_COLUMN_NODE_ID => $this->getNodeId(), + NodeInformationDatabaseWrapper::DB_COLUMN_INTERNAL_UNL => HubTools::determineOwnInternalAddress(), + NodeInformationDatabaseWrapper::DB_COLUMN_EXTERNAL_UNL => HubTools::determineOwnExternalAddress(), + ); + + // Add the session id if acquired + if ($this->getSessionId() != '') { + $nodeData[NodeInformationDatabaseWrapper::DB_COLUMN_SESSION_ID] = $this->getSessionId(); + } // END - if + + // Add the private key if acquired + if ($this->getPrivateKey() != '') { + $nodeData[NodeInformationDatabaseWrapper::DB_COLUMN_PRIVATE_KEY] = base64_encode($this->getPrivateKey()); + $nodeData[NodeInformationDatabaseWrapper::DB_COLUMN_PRIVATE_KEY_HASH] = $this->getPrivateKeyHash(); + } // END - if + + // Debugging: + //* DEBUG-DIE: */ die(sprintf('[%s:%d]: nodeData=%s', __METHOD__, __LINE__, print_r($nodeData, TRUE))); + + // Return it + return $nodeData; + } + } diff --git a/application/hub/classes/nodes/list/class_HubListNode.php b/application/hub/classes/nodes/list/class_HubListNode.php index 42bfee0ed..6ecdcdbfa 100644 --- a/application/hub/classes/nodes/list/class_HubListNode.php +++ b/application/hub/classes/nodes/list/class_HubListNode.php @@ -4,7 +4,7 @@ namespace Org\Shipsimu\Hub\Node\Backup; // Import application-specific stuff use Org\Shipsimu\Hub\Node\BaseHubNode; -use Org\Shipsimu\Hub\Helper\Node\NodeHelper; +use Org\Shipsimu\Hub\Node\Node; // Import framework stuff use Org\Mxchange\CoreFramework\Factory\ObjectFactory; @@ -34,7 +34,7 @@ use Org\Mxchange\CoreFramework\Registry\Registerable; * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -class HubListNode extends BaseHubNode implements NodeHelper, Registerable { +class HubListNode extends BaseHubNode implements Node, Registerable { /** * Protected constructor * @@ -46,10 +46,10 @@ class HubListNode extends BaseHubNode implements NodeHelper, Registerable { } /** - * Creates an instance of this hub-node class + * Creates an instance of a Node class * * @param $requestInstance An instance of a Requestable class - * @return $nodeInstance An instance of this hub-node class + * @return $nodeInstance An instance of a Node class */ public static final function createHubListNode () { // Get a new instance diff --git a/application/hub/classes/nodes/master/class_HubMasterNode.php b/application/hub/classes/nodes/master/class_HubMasterNode.php index fd7fae08c..41039aa2a 100644 --- a/application/hub/classes/nodes/master/class_HubMasterNode.php +++ b/application/hub/classes/nodes/master/class_HubMasterNode.php @@ -4,7 +4,7 @@ namespace Org\Shipsimu\Hub\Node\Master; // Import application-specific stuff use Org\Shipsimu\Hub\Node\BaseHubNode; -use Org\Shipsimu\Hub\Helper\Node\NodeHelper; +use Org\Shipsimu\Hub\Node\Node; // Import framework stuff use Org\Mxchange\CoreFramework\Factory\ObjectFactory; @@ -34,7 +34,7 @@ use Org\Mxchange\CoreFramework\Registry\Registerable; * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -class HubMasterNode extends BaseHubNode implements NodeHelper, Registerable { +class HubMasterNode extends BaseHubNode implements Node, Registerable { /** * Protected constructor * @@ -46,9 +46,9 @@ class HubMasterNode extends BaseHubNode implements NodeHelper, Registerable { } /** - * Creates an instance of this hub-node class + * Creates an instance of a Node class * - * @return $nodeInstance An instance of this hub-node class + * @return $nodeInstance An instance of a Node class */ public static final function createHubMasterNode () { // Get a new instance diff --git a/application/hub/classes/nodes/regular/class_HubRegularNode.php b/application/hub/classes/nodes/regular/class_HubRegularNode.php index 4d97ee4b3..ad0b6eeb6 100644 --- a/application/hub/classes/nodes/regular/class_HubRegularNode.php +++ b/application/hub/classes/nodes/regular/class_HubRegularNode.php @@ -4,7 +4,7 @@ namespace Org\Shipsimu\Hub\Node\Regular; // Import application-specific stuff use Org\Shipsimu\Hub\Node\BaseHubNode; -use Org\Shipsimu\Hub\Helper\Node\NodeHelper; +use Org\Shipsimu\Hub\Node\Node; // Import framework stuff use Org\Mxchange\CoreFramework\Factory\ObjectFactory; @@ -34,7 +34,7 @@ use Org\Mxchange\CoreFramework\Registry\Registerable; * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -class HubRegularNode extends BaseHubNode implements NodeHelper, Registerable { +class HubRegularNode extends BaseHubNode implements Node, Registerable { /** * Protected constructor * @@ -46,10 +46,10 @@ class HubRegularNode extends BaseHubNode implements NodeHelper, Registerable { } /** - * Creates an instance of this hub-node class + * Creates an instance of a Node class * * @param $requestInstance An instance of a Requestable class - * @return $nodeInstance An instance of this hub-node class + * @return $nodeInstance An instance of a Node class */ public static final function createHubRegularNode () { // Get a new instance diff --git a/application/hub/classes/package/class_NetworkPackage.php b/application/hub/classes/package/class_NetworkPackage.php index d231d3f3a..66b8fb22e 100644 --- a/application/hub/classes/package/class_NetworkPackage.php +++ b/application/hub/classes/package/class_NetworkPackage.php @@ -21,6 +21,7 @@ use Org\Shipsimu\Hub\Network\Deliver\Deliverable; use Org\Shipsimu\Hub\Network\Networkable; use Org\Shipsimu\Hub\Network\Package\Fragment\PackageFragmenter; use Org\Shipsimu\Hub\Network\Receive\Receivable; +use Org\Shipsimu\Hub\Node\Generic\InvalidPrivateKeyHashException; use Org\Shipsimu\Hub\Tag\Tagable; use Org\Shipsimu\Hub\Tools\HubTools; @@ -402,12 +403,18 @@ class NetworkPackage extends BaseHubSystem implements Deliverable, Receivable, R * @throws InvalidPrivateKeyHashException If the private key's hash is not valid */ private function determineSenderPrivateKeyHash (array $decodedData) { + // Assert on required fields + assert(!empty($decodedData[self::PACKAGE_CONTENT_SENDER])); + // Get DHT instance $dhtInstance = DhtObjectFactory::createDhtInstance('node'); // Ask DHT for session id $senderData = $dhtInstance->findNodeLocalBySessionId($decodedData[self::PACKAGE_CONTENT_SENDER]); + // Debugging: + //* DEBUG-DIE: */ die(sprintf('[%s:%d]: senderData=%s', __METHOD__, __LINE__, print_r($senderData, TRUE))); + // Is an entry found? if (count($senderData) > 0) { // Make sure the element 'private_key_hash' is there @@ -689,7 +696,7 @@ class NetworkPackage extends BaseHubSystem implements Deliverable, Receivable, R */ private function sendOutgoingRawPackageData (array $packageData) { // Trace message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE: packageData()=%d - CALLED!', count($packageData))); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE: packageData()=%d - CALLED!', count($packageData))); // Init sent bytes $sentBytes = 0; @@ -719,7 +726,7 @@ class NetworkPackage extends BaseHubSystem implements Deliverable, Receivable, R $helperInstance->sendRawPackageData($packageData); // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: EXIT!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: EXIT!'); } /** @@ -733,6 +740,10 @@ class NetworkPackage extends BaseHubSystem implements Deliverable, Receivable, R // Debug message //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: content()=' . strlen($content) . ',senderId=' . $senderId . ' - CALLED!'); + // Assert on variables + assert(!empty($content)); + assert(!empty($senderId)); + // Is the feature enabled? if (!FrameworkFeature::isFeatureAvailable('hubcoin_reward')) { // Feature is not enabled @@ -744,7 +755,7 @@ class NetworkPackage extends BaseHubSystem implements Deliverable, Receivable, R $data = array( self::PACKAGE_CONTENT_SENDER => $senderId, self::PACKAGE_CONTENT_MESSAGE => $content, - self::PACKAGE_CONTENT_PRIVATE_KEY_HASH => '' + self::PACKAGE_CONTENT_PRIVATE_KEY_HASH => $this->getPrivateKeyHash(), ); // Hash content and sender id together, use scrypt @@ -833,6 +844,10 @@ class NetworkPackage extends BaseHubSystem implements Deliverable, Receivable, R // Debug message //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: Enqueueing package for recipientType=' . $helperInstance->getRecipientType() . ' ...'); + // Make sure required data is there + assert(!empty($content)); + assert($this->getSessionId() != ''); + // Now prepare the temporary array and push it on the 'undeclared' stack $this->getStackInstance()->pushNamed(self::STACKER_NAME_UNDECLARED, array( self::PACKAGE_DATA_SENDER_ADDRESS => $this->getSessionId(), @@ -1059,27 +1074,27 @@ class NetworkPackage extends BaseHubSystem implements Deliverable, Receivable, R } // END - if // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE: sentBytes[%s]=%d', gettype($sentBytes), $sentBytes)); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE: sentBytes[%s]=%d', gettype($sentBytes), $sentBytes)); // If there was an error, don't continue here if (($sentBytes === 0) && (strlen($encodedDataArray[self::RAW_INDEX_ENCODED_DATA]) > 0)) { // Nothing sent means all data has been sent - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CONNECTION-HELPER: All sent! (LINE=' . __LINE__ . ')'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CONNECTION-HELPER: All sent! (LINE=' . __LINE__ . ')'); return; } elseif (strlen($encodedDataArray[self::RAW_INDEX_ENCODED_DATA]) == 0) { // Abort here, all sent! - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CONNECTION-HELPER: All sent! (LINE=' . __LINE__ . ')'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CONNECTION-HELPER: All sent! (LINE=' . __LINE__ . ')'); return; } // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CONNECTION-HELPER: Pushing raw data back to stacker, as still some data is pending delivery.'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CONNECTION-HELPER: Pushing raw data back to stacker, as still some data is pending delivery.'); // Push array back in stack $this->getStackInstance()->pushNamed(self::STACKER_NAME_OUTGOING_STREAM, $encodedDataArray); // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: EXIT!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: EXIT!'); } /////////////////////////////////////////////////////////////////////////// @@ -1243,7 +1258,7 @@ class NetworkPackage extends BaseHubSystem implements Deliverable, Receivable, R */ public function handleAssemblerPendingData () { // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: Calling this->getAssemblerInstance()->handlePendingData() ...'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: Calling this->getAssemblerInstance()->handlePendingData() ...'); // Handle it $this->getAssemblerInstance()->handlePendingData(); @@ -1256,7 +1271,7 @@ class NetworkPackage extends BaseHubSystem implements Deliverable, Receivable, R */ public function handleMultipleMessages () { // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: Calling this->getAssemblerInstance()->handleMultipleMessages() ...'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: Calling this->getAssemblerInstance()->handleMultipleMessages() ...'); // Handle it $this->getAssemblerInstance()->handleMultipleMessages(); diff --git a/application/hub/classes/package/fragmenter/class_PackageFragmenter.php b/application/hub/classes/package/fragmenter/class_PackageFragmenter.php index 8cfc6e71e..cef8604d9 100644 --- a/application/hub/classes/package/fragmenter/class_PackageFragmenter.php +++ b/application/hub/classes/package/fragmenter/class_PackageFragmenter.php @@ -8,6 +8,7 @@ use Org\Shipsimu\Hub\Helper\Connection\ConnectionHelper; use Org\Shipsimu\Hub\Network\Package\NetworkPackage; // Import framework stuff +use Org\Mxchange\CoreFramework\Assertion\AssertionException; use Org\Mxchange\CoreFramework\Factory\ObjectFactory; use Org\Mxchange\CoreFramework\Registry\Registerable; diff --git a/application/hub/classes/pools/class_ b/application/hub/classes/pools/class_ index 365c91c4e..926fece4d 100644 --- a/application/hub/classes/pools/class_ +++ b/application/hub/classes/pools/class_ @@ -1,11 +1,11 @@ + * @author Roland Haeder * @version 0.0.0 * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org + * @link http://www.shipsimu.org * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/application/hub/classes/resolver/protocol/class_ b/application/hub/classes/resolver/protocol/class_ index da22550f8..9ed601af7 100644 --- a/application/hub/classes/resolver/protocol/class_ +++ b/application/hub/classes/resolver/protocol/class_ @@ -1,11 +1,11 @@ partialStub('Please implement this method. nodeInstance=' . $nodeInstance->__toString()); } diff --git a/application/hub/classes/resolver/protocol/tcp/class_TcpProtocolResolver.php b/application/hub/classes/resolver/protocol/tcp/class_TcpProtocolResolver.php index 971901b56..7ae311678 100644 --- a/application/hub/classes/resolver/protocol/tcp/class_TcpProtocolResolver.php +++ b/application/hub/classes/resolver/protocol/tcp/class_TcpProtocolResolver.php @@ -5,12 +5,13 @@ namespace Org\Shipsimu\Hub\Resolver\Protocol\Tcp; // Import application-specific stuff use Org\Shipsimu\Hub\Database\Frontend\Node\Information\NodeInformationDatabaseWrapper; use Org\Shipsimu\Hub\Factory\Network\Locator\UniversalNodeLocatorFactory; -use Org\Shipsimu\Hub\Helper\Node\NodeHelper; +use Org\Shipsimu\Hub\Node\Node; use Org\Shipsimu\Hub\Resolver\Protocol\BaseProtocolResolver; use Org\Shipsimu\Hub\Resolver\Protocol\ProtocolResolver; // Import framework stuff use Org\Mxchange\CoreFramework\Console\Tools\ConsoleTools; +use Org\Mxchange\CoreFramework\Criteria\Search\SearchCriteria; use Org\Mxchange\CoreFramework\Factory\ObjectFactory; use Org\Mxchange\CoreFramework\Registry\Registerable; @@ -64,14 +65,13 @@ class TcpProtocolResolver extends BaseProtocolResolver implements ProtocolResolv } /** - * Returns an instance of a LocateableNode class for a given NodeHelper + * Returns an instance of a LocateableNode class for a given Node * instance or null if it was not found. * - * @param $nodeInstance An instance of a NodeHelper class + * @param $nodeInstance An instance of a Node class * @return $unlInstance An instance of a LocateableNode class - * @todo 0% done */ - public function resolveUniversalNodeLocatorFromNodeHelper (NodeHelper $nodeInstance) { + public function resolveUniversalNodeLocatorFromNode (Node $nodeInstance) { // Get search instance (to lookup database result) $searchInstance = $nodeInstance->getSearchInstance(); @@ -83,14 +83,18 @@ class TcpProtocolResolver extends BaseProtocolResolver implements ProtocolResolv // Is the result valid? if ((!$resultInstance->valid()) || (!$resultInstance->next())) { - // Node not found in database, this could mean that your database file is damaged. - return NULL; - } // END - if - - // Get current entry - $current = $resultInstance->current(); + /* + * Node not found in database, this happens on first startup. So + * let's get a prepared array from the node instance. + */ + $current = $nodeInstance->createNodeDataArray(); + } else { + // Get current entry + $current = $resultInstance->current(); + } // This should always be the case, if not your database file might be damaged. + assert(is_array($current)); assert($nodeInstance->getNodeId() == $current[NodeInformationDatabaseWrapper::DB_COLUMN_NODE_ID]); // Get UNL instance and handle over all data @@ -138,7 +142,5 @@ class TcpProtocolResolver extends BaseProtocolResolver implements ProtocolResolv */ return $unl; } -} -// [EOF] -?> +} diff --git a/application/hub/classes/states/communicator/class_Communicator b/application/hub/classes/states/communicator/class_Communicator index b699d28ee..c4d922b7a 100644 --- a/application/hub/classes/states/communicator/class_Communicator +++ b/application/hub/classes/states/communicator/class_Communicator @@ -1,6 +1,6 @@ + * @author Roland Haeder * @version 0.0 * @copyright Copyright (c) 2007 - 2008 Roland Haeder, 2009 - 2015 Hub Developer Team * @license GNU GPL 3.0 or any newer version diff --git a/application/hub/exceptions.php b/application/hub/exceptions.php index 8488577c6..4bebc4421 100644 --- a/application/hub/exceptions.php +++ b/application/hub/exceptions.php @@ -1,5 +1,6 @@ __toString(), @@ -45,7 +48,5 @@ class NodeAlreadyAnnouncedException extends FrameworkException { // Call parent exception constructor parent::__construct($message, $code); } -} -// [EOF] -?> +} diff --git a/application/hub/exceptions/package/class_InvalidPrivateKeyHashException.php b/application/hub/exceptions/package/class_InvalidPrivateKeyHashException.php index f7dcd6ede..4b82c838c 100644 --- a/application/hub/exceptions/package/class_InvalidPrivateKeyHashException.php +++ b/application/hub/exceptions/package/class_InvalidPrivateKeyHashException.php @@ -40,7 +40,7 @@ class InvalidPrivateKeyHashException extends FrameworkException { $message = sprintf('[%s:%d] The package hash is not valid, data=%s, message: %s', $messageArray[0]->__toString(), $this->getLine(), - $messageArray[1], + json_encode($messageArray[1]), $messageArray[2] ); diff --git a/application/hub/interfaces/database/frontend/class_NodeInformationWrapper.php b/application/hub/interfaces/database/frontend/class_NodeInformationWrapper.php index 7c4621a73..5657fde10 100644 --- a/application/hub/interfaces/database/frontend/class_NodeInformationWrapper.php +++ b/application/hub/interfaces/database/frontend/class_NodeInformationWrapper.php @@ -8,7 +8,6 @@ use Org\Shipsimu\Hub\Node\BaseHubNode; // Import framework stuff use Org\Mxchange\CoreFramework\Criteria\Local\LocalSearchCriteria; use Org\Mxchange\CoreFramework\Database\Frontend\DatabaseWrapper; -use Org\Mxchange\CoreFramework\Request\Requestable; /** * An interface for node-information (database) wrapper @@ -38,21 +37,19 @@ interface NodeInformationWrapper extends DatabaseWrapper { * This may sound confusing but avoids double code very nicely... * * @param $nodeInstance A node instance - * @param $requestInstance An instance of a Requestable class * @return void */ - function registerNodeId (BaseHubNode $nodeInstance, Requestable $requestInstance); + function registerNodeId (BaseHubNode $nodeInstance); /** * 'Registers' a new session id along with data provided in the node instance. * This may sound confusing but avoids double code very nicely... * * @param $nodeInstance An instance of a BaseHubNode class - * @param $requestInstance An instance of a Requestable class * @param $searchInstance An instance of a LocalSearchCriteria class * @return void */ - function registerSessionId (BaseHubNode $nodeInstance, Requestable $requestInstance, LocalSearchCriteria $searchInstance); + function registerSessionId (BaseHubNode $nodeInstance, LocalSearchCriteria $searchInstance); /** * 'Registers' a private key along with data provided in the node instance. @@ -63,6 +60,6 @@ interface NodeInformationWrapper extends DatabaseWrapper { * @param $searchInstance An instance of a LocalSearchCriteria class * @return void */ - function registerPrivateKey (BaseHubNode $nodeInstance, Requestable $requestInstance, LocalSearchCriteria $searchInstance); + function registerPrivateKey (BaseHubNode $nodeInstance, LocalSearchCriteria $searchInstance); } diff --git a/application/hub/interfaces/discovery/class_Discoverable b/application/hub/interfaces/discovery/class_Discoverable index 8b3901606..37351e72f 100644 --- a/application/hub/interfaces/discovery/class_Discoverable +++ b/application/hub/interfaces/discovery/class_Discoverable @@ -1,6 +1,6 @@ diff --git a/application/hub/interfaces/discovery/protocol/class_DiscoverableProtocol.php b/application/hub/interfaces/discovery/protocol/class_DiscoverableProtocol.php index 3f1524923..efc60e4dd 100644 --- a/application/hub/interfaces/discovery/protocol/class_DiscoverableProtocol.php +++ b/application/hub/interfaces/discovery/protocol/class_DiscoverableProtocol.php @@ -29,6 +29,3 @@ use Org\Mxchange\CoreFramework\Discovery\Discoverable; */ interface DiscoverableProtocol extends Discoverable { } - -// [EOF] -?> diff --git a/application/hub/interfaces/discovery/recipient/class_DiscoverableRecipient.php b/application/hub/interfaces/discovery/recipient/class_DiscoverableRecipient.php index d6801e699..4e121d0a7 100644 --- a/application/hub/interfaces/discovery/recipient/class_DiscoverableRecipient.php +++ b/application/hub/interfaces/discovery/recipient/class_DiscoverableRecipient.php @@ -48,7 +48,5 @@ interface DiscoverableRecipient extends Discoverable { * @return $isEmpty Whether the recipient list is empty */ function isRecipientListEmpty (); -} -// [EOF] -?> +} diff --git a/application/hub/interfaces/discovery/unl/class_DiscoverableUniversalNodeLocator.php b/application/hub/interfaces/discovery/unl/class_DiscoverableUniversalNodeLocator.php index 444d66f5a..1a1ef14d7 100644 --- a/application/hub/interfaces/discovery/unl/class_DiscoverableUniversalNodeLocator.php +++ b/application/hub/interfaces/discovery/unl/class_DiscoverableUniversalNodeLocator.php @@ -3,7 +3,7 @@ namespace Org\Shipsimu\Hub\Discovery\Locator; // Import application-specific stuff -use Org\Shipsimu\Hub\Helper\Node\NodeHelper; +use Org\Shipsimu\Hub\Node\Node; // Import framework stuff use Org\Mxchange\CoreFramework\Discovery\Discoverable; @@ -32,12 +32,13 @@ use Org\Mxchange\CoreFramework\Discovery\Discoverable; */ interface DiscoverableUniversalNodeLocator extends Discoverable { /** - * "Discovers" an instance of a LocateableNode class for given NodeHelper class + * "Discovers" an instance of a LocateableNode class for given Node class * - * @param $nodeInstance An instance of a NodeHelper class + * @param $nodeInstance An instance of a Node class * @return $unlInstance An instance of a LocateableNode class + * @throws NullPointerException If $unlInstance is NULL */ - function discoverUniversalNodeLocatorByNode (NodeHelper $nodeInstance); + function discoverUniversalNodeLocatorByNode (Node $nodeInstance); /** * "Discovers" the full universal node locator for given configuration entry @@ -51,7 +52,5 @@ interface DiscoverableUniversalNodeLocator extends Discoverable { * @return $unl Universal node locator */ function discoverUniversalNodeLocatorByConfiguredAddress ($configKey); -} -// [EOF] -?> +} diff --git a/application/hub/interfaces/helper/node/class_HelpableNode.php b/application/hub/interfaces/helper/node/class_HelpableNode.php index 0ab41ba76..40c8642e4 100644 --- a/application/hub/interfaces/helper/node/class_HelpableNode.php +++ b/application/hub/interfaces/helper/node/class_HelpableNode.php @@ -1,10 +1,10 @@ - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * @todo We need to find a better name for this interface - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -interface NodeHelper extends Helper, AddableCriteria { - /** - * Method to "bootstrap" the node. This step does also apply provided - * command-line arguments stored in the request instance. You should now - * get it from calling FrameworkBootstrap::getRequestInstance(). - * - * @return void - */ - function doBootstrapping (); - - /** - * Outputs the console teaser. This should only be executed on startup or - * full restarts. This method generates some space around the teaser. - * - * @return void - */ - function outputConsoleTeaser (); - - /** - * Add some node-specific filters - * - * @return void - */ - function addExtraNodeFilters (); - - /** - * Generic method to acquire a hub-id. On first run this generates a new one - * based on many pseudo-random data. On any later run, unless the id - * got not removed from database, it will be restored from the database. - * - * @param $requestInstance A Requestable class - * @param $responseInstance A Responseable class - * @return void - */ - function bootstrapAcquireNodeId (Requestable $requestInstance, Responseable $responseInstance); - - /** - * Activates the hub by doing some final preparation and setting - * $hubIsActive to TRUE. - * - * @param $requestInstance A Requestable class - * @param $responseInstance A Responseable class - * @return void - */ - function activateNode (Requestable $requestInstance, Responseable $responseInstance); - - /** - * Generates a session id which will be sent to the other hubs and peers - * - * @return void - */ - function bootstrapGenerateSessionId (); - - /** - * Generates a private key for en-/decryption - * - * @return void - */ - function bootstrapGeneratePrivateKey (); - - /** - * Initializes the listener pool (class) - * - * @return void - */ - function initializeListenerPool (); - - /** - * Announces this hub to the upper (bootstrap or list) hubs. After this is - * successfully done the given task is unregistered from the handler. - * - * @param $taskInstance The task instance running this announcement - * @return void - * @throws NodeAlreadyAnnouncedException If this hub is already announced - */ - function announceToUpperNodes (Taskable $taskInstance); - - /** - * Does a self-connect attempt on the public IP address. This should make - * it sure, we are reachable from outside world. - * - * @param $taskInstance The task instance running this announcement - * @return void - */ - function doSelfConnection (Taskable $taskInstance); - - /** - * Determines an instance of a LocateableNode class - * - * @return $unlInstance An instance of a LocateableNode class for this node - */ - function determineUniversalNodeLocator (); - - /** - * Updates/refreshes node data (e.g. state). - * - * @return void - */ - function updateNodeData (); - - /** - * Checks whether this node accepts announcements - * - * @return $acceptAnnouncements Whether this node accepts announcements - */ - function isAcceptingAnnouncements (); - - /** - * Checks whether this node has attempted to announce itself - * - * @return $hasAnnounced Whether this node has attempted to announce itself - */ - function ifNodeIsAnnouncing (); - - /** - * Checks whether this node has attempted to announce itself and completed it - * - * @return $hasAnnouncementCompleted Whether this node has attempted to announce itself and completed it - */ - function ifNodeHasAnnouncementCompleted (); - - /** - * Checks wether this node is accepting node-list requests - * - * @return $acceptsRequest Wether this node accepts node-list requests - */ - function isAcceptingNodeListRequests (); - - /** - * Handles message answer by given data array - * - * @param $messageData A valid answer message data array - * @param $packageInstance An instance of a Receivable class - * @return void - */ - function handleAnswerStatusByMessageData (array $messageData, Receivable $packageInstance); - - /** - * "Getter" for an array of all accepted object types - * - * @return $objectList Array of all accepted object types - */ - function getListFromAcceptedObjectTypes (); - - /** - * Adds extra tasks to the given handler for this node - * - * @param $handlerInstance An instance of a HandleableTask class - * @return void - */ - function addExtraTasks (HandleableTask $handlerInstance); - - /** - * Tries to detect own UNL (Universal Node Locator) - * - * @return $unl Node's own universal node locator - */ - function detectOwnUniversalNodeLocator (); -} - -// [EOF] -?> diff --git a/application/hub/interfaces/nodes/class_Node.php b/application/hub/interfaces/nodes/class_Node.php new file mode 100644 index 000000000..6ad367e9e --- /dev/null +++ b/application/hub/interfaces/nodes/class_Node.php @@ -0,0 +1,204 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * @todo We need to find a better name for this interface + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +interface Node extends FrameworkInterface { + /** + * Method to "bootstrap" the node. This step does also apply provided + * command-line arguments stored in the request instance. You should now + * get it from calling FrameworkBootstrap::getRequestInstance(). + * + * @return void + */ + function doBootstrapping (); + + /** + * Outputs the console teaser. This should only be executed on startup or + * full restarts. This method generates some space around the teaser. + * + * @return void + */ + function outputConsoleTeaser (); + + /** + * Add some node-specific filters + * + * @return void + */ + function addExtraNodeFilters (); + + /** + * Generic method to acquire a hub-id. On first run this generates a new one + * based on many pseudo-random data. On any later run, unless the id + * got not removed from database, it will be restored from the database. + * + * @param $requestInstance A Requestable class + * @param $responseInstance A Responseable class + * @return void + */ + function bootstrapAcquireNodeId (Requestable $requestInstance, Responseable $responseInstance); + + /** + * Activates the hub by doing some final preparation and setting + * $hubIsActive to TRUE. + * + * @param $requestInstance A Requestable class + * @param $responseInstance A Responseable class + * @return void + */ + function activateNode (Requestable $requestInstance, Responseable $responseInstance); + + /** + * Generates a session id which will be sent to the other hubs and peers + * + * @return void + */ + function bootstrapGenerateSessionId (); + + /** + * Generates a private key for en-/decryption + * + * @return void + */ + function bootstrapGeneratePrivateKey (); + + /** + * Initializes the listener pool (class) + * + * @return void + */ + function initializeListenerPool (); + + /** + * Announces this hub to the upper (bootstrap or list) hubs. After this is + * successfully done the given task is unregistered from the handler. + * + * @param $taskInstance The task instance running this announcement + * @return void + * @throws NodeAlreadyAnnouncedException If this hub is already announced + */ + function announceToUpperNodes (Taskable $taskInstance); + + /** + * Does a self-connect attempt on the public IP address. This should make + * it sure, we are reachable from outside world. + * + * @param $taskInstance The task instance running this announcement + * @return void + */ + function doSelfConnection (Taskable $taskInstance); + + /** + * Determines an instance of a LocateableNode class + * + * @return $unlInstance An instance of a LocateableNode class for this node + */ + function determineUniversalNodeLocator (); + + /** + * Updates/refreshes node data (e.g. state). + * + * @return void + */ + function updateNodeData (); + + /** + * Checks whether this node accepts announcements + * + * @return $acceptAnnouncements Whether this node accepts announcements + */ + function isAcceptingAnnouncements (); + + /** + * Checks whether this node has attempted to announce itself + * + * @return $hasAnnounced Whether this node has attempted to announce itself + */ + function ifNodeIsAnnouncing (); + + /** + * Checks whether this node has attempted to announce itself and completed it + * + * @return $hasAnnouncementCompleted Whether this node has attempted to announce itself and completed it + */ + function ifNodeHasAnnouncementCompleted (); + + /** + * Checks wether this node is accepting node-list requests + * + * @return $acceptsRequest Wether this node accepts node-list requests + */ + function isAcceptingNodeListRequests (); + + /** + * Handles message answer by given data array + * + * @param $messageData A valid answer message data array + * @param $packageInstance An instance of a Receivable class + * @return void + */ + function handleAnswerStatusByMessageData (array $messageData, Receivable $packageInstance); + + /** + * "Getter" for an array of all accepted object types + * + * @return $objectList Array of all accepted object types + */ + function getListFromAcceptedObjectTypes (); + + /** + * Adds extra tasks to the given handler for this node + * + * @param $handlerInstance An instance of a HandleableTask class + * @return void + */ + function addExtraTasks (HandleableTask $handlerInstance); + + /** + * Tries to detect own UNL (Universal Node Locator) + * + * @return $unl Node's own universal node locator + */ + function detectOwnUniversalNodeLocator (); + + /** + * Creates a data array for this node suitable for UNL-generation. + * + * @return $nodeData Node's data + */ + function createNodeDataArray (); + +} diff --git a/application/hub/interfaces/pool/class_Poolable.php b/application/hub/interfaces/pool/class_Poolable.php index 473185d92..4be12262c 100644 --- a/application/hub/interfaces/pool/class_Poolable.php +++ b/application/hub/interfaces/pool/class_Poolable.php @@ -8,11 +8,11 @@ use Org\Shipsimu\Hub\Generic\HubInterface; /** * A Poolable interface * - * @author Roland Haeder + * @author Roland Haeder * @version 0.0.0 * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2017 Hub Developer Team * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org + * @link http://www.shipsimu.org * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/application/hub/interfaces/pool/listener/class_PoolableListener.php b/application/hub/interfaces/pool/listener/class_PoolableListener.php index 3054182ec..6672a69a1 100644 --- a/application/hub/interfaces/pool/listener/class_PoolableListener.php +++ b/application/hub/interfaces/pool/listener/class_PoolableListener.php @@ -11,11 +11,11 @@ use Org\Shipsimu\Hub\Pool\Poolable; /** * A Poolable interface for listener * - * @author Roland Haeder + * @author Roland Haeder * @version 0.0.0 * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2017 Hub Developer Team * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org + * @link http://www.shipsimu.org * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/application/hub/interfaces/producer/class_ b/application/hub/interfaces/producer/class_ index 6001bb658..19b54ef92 100644 --- a/application/hub/interfaces/producer/class_ +++ b/application/hub/interfaces/producer/class_ @@ -2,11 +2,11 @@ /** * An interface for a ??? producer of the producer/consumer implementation * - * @author Roland Haeder + * @author Roland Haeder * @version 0.0.0 * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org + * @link http://www.shipsimu.org * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -23,6 +23,3 @@ */ interface ???Producer extends Producer { } - -// [EOF] -?> diff --git a/application/hub/interfaces/resolver/class_ProtocolResolver.php b/application/hub/interfaces/resolver/class_ProtocolResolver.php index e2c5fcb03..f81f1914a 100644 --- a/application/hub/interfaces/resolver/class_ProtocolResolver.php +++ b/application/hub/interfaces/resolver/class_ProtocolResolver.php @@ -4,8 +4,7 @@ namespace Org\Shipsimu\Hub\Resolver\Protocol; // Import application-specific stuff use Org\Shipsimu\Hub\Generic\HubInterface; -use Org\Shipsimu\Hub\Helper\Node\NodeHelper; - +use Org\Shipsimu\Hub\Node\Node; /** * An interface for ProtocolResolvers @@ -31,13 +30,13 @@ use Org\Shipsimu\Hub\Helper\Node\NodeHelper; */ interface ProtocolResolver extends HubInterface { /** - * Returns an instance of a LocateableNode class for a given NodeHelper + * Returns an instance of a LocateableNode class for a given Node * instance or null if it was not found. * - * @param $nodeInstance An instance of a NodeHelper class + * @param $nodeInstance An instance of a Node class * @return $unlInstance An instance of a LocateableNode class */ - function resolveUniversalNodeLocatorFromNodeHelper (NodeHelper $nodeInstance); + function resolveUniversalNodeLocatorFromNode (Node $nodeInstance); /** * Returns the UNL as string from given configuration key. diff --git a/application/hub/templates/de/menu/generic_menu_entries.xml b/application/hub/templates/de/menu/generic_menu_entries.xml index 43b4a6dc4..3a6975337 100644 --- a/application/hub/templates/de/menu/generic_menu_entries.xml +++ b/application/hub/templates/de/menu/generic_menu_entries.xml @@ -2,11 +2,11 @@