From: Roland Häder Date: Wed, 2 Dec 2020 04:56:14 +0000 (+0100) Subject: Continued: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=8292bd24d49115580996920c6c79baf70e859b25;p=hub.git Continued: - removed PackageData->$rawXml instance and used $packageContent instead - used ApplicationEntryPoint::exitApplication() instead of die() - updated core framework Signed-off-by: Roland Häder --- diff --git a/application/hub/classes/dht/node/class_NodeDhtFacade.php b/application/hub/classes/dht/node/class_NodeDhtFacade.php index 3b19a24ce..2d43958cf 100644 --- a/application/hub/classes/dht/node/class_NodeDhtFacade.php +++ b/application/hub/classes/dht/node/class_NodeDhtFacade.php @@ -12,6 +12,7 @@ use Org\Shipsimu\Hub\Network\Package\DeliverablePackage; // Import framework stuff use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap; +use Org\Mxchange\CoreFramework\EntryPoint\ApplicationEntryPoint; use Org\Mxchange\CoreFramework\Factory\Database\Frontend\DatabaseFrontendFactory; use Org\Mxchange\CoreFramework\Factory\ObjectFactory; use Org\Mxchange\CoreFramework\Handler\DataSet\HandleableDataSet; @@ -199,7 +200,7 @@ class NodeDhtFacade extends BaseDht implements DistributableNode, Registerable { } // Return node data - //* DEBUG-DIE: */ die(sprintf('[%s:%d]: nodeData=%s', __METHOD__, __LINE__, print_r($nodeData, TRUE))); + //* DEBUG-DIE: */ ApplicationEntryPoint::exitApplication(sprintf('[%s:%d]: nodeData=%s', __METHOD__, __LINE__, print_r($nodeData, TRUE))); /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NODE-DHT-FACADE: nodeData()=%d - EXIT!', count($nodeData))); return $nodeData; } @@ -213,14 +214,14 @@ class NodeDhtFacade extends BaseDht implements DistributableNode, Registerable { public function findNodeByUniversalNodeLocator (LocateableNode $locatorInstance) { // Default is empty data array /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NODE-DHT-FACADE: locatorInstance=%s - CALLED!', $locatorInstance->__toString())); - //* DEBUG-DIE: */ die(sprintf('[%s:%d]: locatorInstance=%s', __METHOD__, __LINE__, print_r($locatorInstance, TRUE))); + //* DEBUG-DIE: */ ApplicationEntryPoint::exitApplication(sprintf('[%s:%d]: locatorInstance=%s', __METHOD__, __LINE__, print_r($locatorInstance, TRUE))); $nodeData = []; // Query database $resultInstance = $this->getFrontendInstance()->findNodeLocalByLocatorInstance($locatorInstance); // Make sure the result instance is valid - //* DEBUG-DIE: */ die(sprintf('[%s:%d]: resultInstance=%s', __METHOD__, __LINE__, print_r($resultInstance, TRUE))); + //* DEBUG-DIE: */ ApplicationEntryPoint::exitApplication(sprintf('[%s:%d]: resultInstance=%s', __METHOD__, __LINE__, print_r($resultInstance, TRUE))); assert($resultInstance instanceof SearchableResult); // Is the next entry valid? @@ -233,7 +234,7 @@ class NodeDhtFacade extends BaseDht implements DistributableNode, Registerable { } // Return node data - //* DEBUG-DIE: */ die(sprintf('[%s:%d]: nodeData=%s', __METHOD__, __LINE__, print_r($nodeData, TRUE))); + //* DEBUG-DIE: */ ApplicationEntryPoint::exitApplication(sprintf('[%s:%d]: nodeData=%s', __METHOD__, __LINE__, print_r($nodeData, TRUE))); /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NODE-DHT-FACADE: nodeData()=%d - EXIT!', count($nodeData))); return $nodeData; } diff --git a/application/hub/classes/discovery/recipient/package/class_PackageRecipientDiscovery.php b/application/hub/classes/discovery/recipient/package/class_PackageRecipientDiscovery.php index 6ae12306a..3e993829d 100644 --- a/application/hub/classes/discovery/recipient/package/class_PackageRecipientDiscovery.php +++ b/application/hub/classes/discovery/recipient/package/class_PackageRecipientDiscovery.php @@ -11,6 +11,7 @@ use Org\Shipsimu\Hub\Node\Data\InvalidSessionIdException; use Org\Shipsimu\Hub\Tools\HubTools; // Import framework stuff +use Org\Mxchange\CoreFramework\EntryPoint\ApplicationEntryPoint; use Org\Mxchange\CoreFramework\Factory\ObjectFactory; use Org\Mxchange\CoreFramework\Generic\FrameworkException; use Org\Mxchange\CoreFramework\Registry\Registerable; @@ -124,7 +125,7 @@ class PackageRecipientDiscovery extends BaseRecipientDiscovery implements Discov } // Get a protocol handler back from decoded data - //* DEBUG-DIE: */ die(sprintf('[%s:%d]: packageInstance=%s', __METHOD__, __LINE__, print_r($packageInstance, TRUE))); + //* DEBUG-DIE: */ ApplicationEntryPoint::exitApplication(sprintf('[%s:%d]: packageInstance=%s', __METHOD__, __LINE__, print_r($packageInstance, TRUE))); $handlerInstance = ProtocolHandlerFactory::createProtocolHandlerFromPackageInstance($packageInstance); // Is the 'recipient' field same as this peer's IP? diff --git a/application/hub/classes/factories/socket/class_SocketFactory.php b/application/hub/classes/factories/socket/class_SocketFactory.php index cbe224401..f72c639db 100644 --- a/application/hub/classes/factories/socket/class_SocketFactory.php +++ b/application/hub/classes/factories/socket/class_SocketFactory.php @@ -12,6 +12,7 @@ use Org\Shipsimu\Hub\Pool\Poolable; // Import framework stuff use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap; +use Org\Mxchange\CoreFramework\EntryPoint\ApplicationEntryPoint; use Org\Mxchange\CoreFramework\Factory\ObjectFactory; use Org\Mxchange\CoreFramework\Registry\GenericRegistry; use Org\Mxchange\CoreFramework\Socket\InvalidSocketException; @@ -65,7 +66,7 @@ class SocketFactory extends ObjectFactory { public static function createSocketFromPackageInstance (DeliverablePackage $packageInstance, HandleableProtocol $protocolInstance) { // Init instance /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('SOCKET-FACTORY: packageInstance=%s,protocolInstance=%s - CALLED!', $packageInstance->__toString(), $protocolInstance->__toString())); - //* DEBUG-DIE: */ die(sprintf('[%s:%d]: packageInstance=%s', __METHOD__, __LINE__, print_r($packageInstance, TRUE))); + //* DEBUG-DIE: */ ApplicationEntryPoint::exitApplication(sprintf('[%s:%d]: packageInstance=%s', __METHOD__, __LINE__, print_r($packageInstance, TRUE))); $socketInstance = NULL; // Construct registry key diff --git a/application/hub/classes/handler/chunks/class_ChunkHandler.php b/application/hub/classes/handler/chunks/class_ChunkHandler.php index 0468445c7..a23f91294 100644 --- a/application/hub/classes/handler/chunks/class_ChunkHandler.php +++ b/application/hub/classes/handler/chunks/class_ChunkHandler.php @@ -9,6 +9,7 @@ use Org\Shipsimu\Hub\Network\Package\Delivery\Fragment\PackageFragmenter; // Import framework stuff use Org\Mxchange\CoreFramework\Assertion\AssertionException; +use Org\Mxchange\CoreFramework\EntryPoint\ApplicationEntryPoint; use Org\Mxchange\CoreFramework\Factory\ObjectFactory; use Org\Mxchange\CoreFramework\Registry\Registerable; use Org\Mxchange\CoreFramework\Utils\String\StringUtils; @@ -296,7 +297,7 @@ class ChunkHandler extends BaseHubHandler implements HandleableChunks, Registera private function preparePackageAssmble () { // Make sure both arrays have same count (this however should always be TRUE) /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CHUNK-HANDLER: CALLED!'); - //* DEBUG-DIE: */ die(sprintf('[%s:%d]: finalPackageChunks=%s', __METHOD__, __LINE__, print_r($this->finalPackageChunks['content'], TRUE))); + //* DEBUG-DIE: */ ApplicationEntryPoint::exitApplication(sprintf('[%s:%d]: finalPackageChunks=%s', __METHOD__, __LINE__, print_r($this->finalPackageChunks['content'], TRUE))); assert(count($this->finalPackageChunks['hashes']) == count($this->finalPackageChunks['content'])); /* diff --git a/application/hub/classes/handler/package/class_NetworkPackageHandler.php b/application/hub/classes/handler/package/class_NetworkPackageHandler.php index 8e6115393..cc8ed5ccc 100644 --- a/application/hub/classes/handler/package/class_NetworkPackageHandler.php +++ b/application/hub/classes/handler/package/class_NetworkPackageHandler.php @@ -32,6 +32,7 @@ use Org\Shipsimu\Hub\Tools\HubTools; // Import framework stuff use Org\Mxchange\CoreFramework\Compressor\Compressor; +use Org\Mxchange\CoreFramework\EntryPoint\ApplicationEntryPoint; use Org\Mxchange\CoreFramework\Factory\ObjectFactory; use Org\Mxchange\CoreFramework\Factory\Registry\Socket\SocketRegistryFactory; use Org\Mxchange\CoreFramework\Feature\FrameworkFeature; @@ -125,17 +126,18 @@ class NetworkPackageHandler extends BaseHubHandler implements Deliverable, Recei * Array indexes for raw package array */ const INDEX_PACKAGE_SENDER_ADDRESS = 0; - const INDEX_PACKAGE_SENDER_PORT = 1; - const INDEX_PACKAGE_RECIPIENT = 2; - const INDEX_PACKAGE_CONTENT = 3; - const INDEX_PACKAGE_STATUS = 4; - const INDEX_PACKAGE_HASH = 5; - const INDEX_PACKAGE_PRIVATE_KEY_HASH = 6; + const INDEX_PACKAGE_SENDER_ID = 1; + const INDEX_PACKAGE_SENDER_PORT = 2; + const INDEX_PACKAGE_RECIPIENT = 3; + const INDEX_PACKAGE_CONTENT = 4; + const INDEX_PACKAGE_STATUS = 5; + const INDEX_PACKAGE_HASH = 6; + const INDEX_PACKAGE_PRIVATE_KEY_HASH = 7; /** * Size of the decoded data array */ - const DECODED_DATA_ARRAY_SIZE = 7; + const DECODED_DATA_ARRAY_SIZE = 8; /** * Named array elements for decoded package content @@ -259,12 +261,12 @@ class NetworkPackageHandler extends BaseHubHandler implements Deliverable, Recei /** * Stacker name for new messages */ - const STACKER_NAME_NEW_MESSAGE = 'package_new_message'; + const STACKER_NAME_NEW_MESSAGE = 'message_new'; /** * Stacker name for processed messages */ - const STACKER_NAME_PROCESSED_MESSAGE = 'package_processed_message'; + const STACKER_NAME_PROCESSED_MESSAGE = 'message_processed'; /************************************************************************** * Stacker for raw data handling * @@ -452,6 +454,7 @@ class NetworkPackageHandler extends BaseHubHandler implements Deliverable, Recei self::STACKER_NAME_DECODED_HANDLED, self::STACKER_NAME_DECODED_CHUNKED, self::STACKER_NAME_PACKAGE_DECOMPRESSED_XML, + self::STACKER_NAME_NEW_MESSAGE, self::STACKER_NAME_PROCESSED_MESSAGE, self::STACKER_NAME_OUTGOING_STREAM ), $forceReInit); @@ -474,7 +477,7 @@ class NetworkPackageHandler extends BaseHubHandler implements Deliverable, Recei // Is an entry found? /* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-HANDLER: senderData()=%d', count($senderData))); - //* DEBUG-DIE: */ die(sprintf('[%s:%d]: senderData=%s', __METHOD__, __LINE__, print_r($senderData, TRUE))); + //* DEBUG-DIE: */ ApplicationEntryPoint::exitApplication(sprintf('[%s:%d]: senderData=%s', __METHOD__, __LINE__, print_r($senderData, TRUE))); if (count($senderData) > 0 || !empty($senderData[NodeDistributedHashTableDatabaseFrontend::DB_COLUMN_PRIVATE_KEY_HASH])) { // Return it /* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-HANDLER: Returning senderData[%s]=%s', NodeDistributedHashTableDatabaseFrontend::DB_COLUMN_PRIVATE_KEY_HASH, $senderData[NodeDistributedHashTableDatabaseFrontend::DB_COLUMN_PRIVATE_KEY_HASH])); @@ -576,7 +579,7 @@ class NetworkPackageHandler extends BaseHubHandler implements Deliverable, Recei public function getHashFromPackageSessionId (DeliverablePackage $packageInstance) { // Is session id set? /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-HANDLER: packageInstance=%s - CALLED!', $packageInstance->__toString())); - /* DEBUG-DIE: */ die(sprintf('[%s:%d]: packageInstance=%s', __METHOD__, __LINE__, print_r($packageInstance, TRUE))); + /* DEBUG-DIE: */ ApplicationEntryPoint::exitApplication(sprintf('[%s:%d]: packageInstance=%s', __METHOD__, __LINE__, print_r($packageInstance, TRUE))); if (empty($packageInstance->getSessionId())) { // Throw exception throw new InvalidArgumentException('packageInstance has no sessionId set.'); @@ -585,7 +588,7 @@ class NetworkPackageHandler extends BaseHubHandler implements Deliverable, Recei // Create the hash // @TODO md5() is very weak, but it needs to be fast $hash = md5(sprintf(self::CONTENT_CHECKSUM_MASK, - $packageInstance->getRawXml(), + $packageInstance->getPackageContent(), $packageInstance->getSessionId(), $packageInstance->getCompressorExtension() )); @@ -800,31 +803,38 @@ class NetworkPackageHandler extends BaseHubHandler implements Deliverable, Recei } /** - * Checks whether the hash of given package data is 'valid', here that + * Checks whether the hash of given package's raw XML is 'valid', here that * means it is the same or not. * * @param $packageInstance An instance of a DeliverablePackage class * @return $isHashValid Whether the hash is valid */ - private function isPackageHashValid (DeliverablePackage $packageInstance) { + private function isPackageContentHashValid (DeliverablePackage $packageInstance) { // Is the feature enabled? /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-HANDLER: packageInstance=%s - CALLED!', $packageInstance->__toString())); if (!FrameworkFeature::isFeatureAvailable('hubcoin_reward')) { // Feature is not enabled, so hashes are always valid - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: Feature "hubcoin_reward" not available, not checking hash. Returning TRUE ...'); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: Feature "hubcoin_reward" not available, not checking hash. Returning TRUE ...'); return TRUE; + } elseif (empty($packageInstance->getSenderId())) { + // Empty sender id + ApplicationEntryPoint::exitApplication(sprintf('[%s:%d]: packageInstance->senderId is empty', __METHOD__, __LINE__)); + } elseif (empty($packageInstance->getPackageContent())) { + // Empty sender id + ApplicationEntryPoint::exitApplication(sprintf('[%s:%d]: packageInstance->PackageContent is empty', __METHOD__, __LINE__)); } // Check validity /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-HANDLER: packageInstance->senderId=%s,packageInstance->packageContent=%s,packageInstance->contentHash=%s', $packageInstance->getSenderId(), $packageInstance->getPackageContent(), $packageInstance->getContentHash())); - $isHashValid = FrameworkFeature::callFeature('hubcoin_reward', 'checkHash', array( + //* DEBUG-DIE: */ ApplicationEntryPoint::exitApplication(sprintf('[%s:%d]: packageInstance=%s', __METHOD__, __LINE__, print_r($packageInstance, TRUE))); + $isHashValid = FrameworkFeature::callFeature('hubcoin_reward', 'checkHash', [ sprintf('%s:%s:%s', $packageInstance->getSenderId(), $packageInstance->getPackageContent(), $this->determineSenderPrivateKeyHash($packageInstance) ), $packageInstance->getContentHash(), - )); + ]); // Return it /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-HANDLER: isHashValid=%s - EXIT!', intval($isHashValid))); @@ -1433,7 +1443,7 @@ class NetworkPackageHandler extends BaseHubHandler implements Deliverable, Recei // Assert on count (should be always 6) /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-HANDLER: decodedArray()=%d', count($decodedArray))); - //* DEBUG-DIE: */ die(sprintf('[%s:%d]: decodedArray=%s', __METHOD__, __LINE__, print_r($decodedArray, TRUE))); + //* DEBUG-DIE: */ ApplicationEntryPoint::exitApplication(sprintf('[%s:%d]: decodedArray=%s', __METHOD__, __LINE__, print_r($decodedArray, TRUE))); if (count($decodedArray) != self::DECODED_DATA_ARRAY_SIZE) { // Count of array elements not expected throw new InvalidArgumentException(sprintf('decodedArray()=%d does not match expected size %d. rawPackageContent=%s', @@ -1448,6 +1458,7 @@ class NetworkPackageHandler extends BaseHubHandler implements Deliverable, Recei // Set all data $packageInstance->setSenderAddress($decodedArray[self::INDEX_PACKAGE_SENDER_ADDRESS]); + $packageInstance->setSenderId($decodedArray[self::INDEX_PACKAGE_SENDER_ID]); $packageInstance->setSenderPort($decodedArray[self::INDEX_PACKAGE_SENDER_PORT]); $packageInstance->setRecipientId($decodedArray[self::INDEX_PACKAGE_RECIPIENT]); $packageInstance->setRecipientType(self::RECIPIENT_TYPE_DIRECT); @@ -1501,14 +1512,14 @@ class NetworkPackageHandler extends BaseHubHandler implements Deliverable, Recei // Copy data to package instance $packageInstance->setCompressorExtension($decodedContent[self::INDEX_COMPRESSOR_EXTENSION]); // Raw XML, being BASE64-decoded, still compressed - $packageInstance->setRawXml(base64_decode($decodedContent[self::INDEX_PACKAGE_DATA])); + $packageInstance->setPackageContent(base64_decode($decodedContent[self::INDEX_PACKAGE_DATA])); // Tags as an indexed array for "tagging" the message $packageInstance->setContentTags(explode(self::PACKAGE_TAGS_SEPARATOR, $decodedContent[self::INDEX_TAGS])); // Checksum of the _decoded_ data $packageInstance->setContentChecksum($decodedContent[self::INDEX_CHECKSUM]); // Decompress raw XML stream - $packageInstance->setRawXml($this->getCompressorInstance()->decompressStream($packageInstance->getRawXml())); + $packageInstance->setPackageContent($this->getCompressorInstance()->decompressStream($packageInstance->getPackageContent())); // And push it on the next stack $this->getStackInstance()->pushNamed(self::STACKER_NAME_PACKAGE_DECOMPRESSED_XML, $packageInstance); @@ -1525,7 +1536,7 @@ class NetworkPackageHandler extends BaseHubHandler implements Deliverable, Recei public function isNewMessageArrived () { // Determine if the stack is not empty //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: CALLED!'); - $hasArrived = (!$this->getStackInstance()->isStackEmpty(self::STACKER_NAME_PACKAGE_DECOMPRESSED_XML)); + $hasArrived = (!$this->getStackInstance()->isStackEmpty(self::STACKER_NAME_NEW_MESSAGE)); // Return it //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-HANDLER: hasArrived=%d - EXIT!', intval($hasArrived))); @@ -1568,7 +1579,7 @@ class NetworkPackageHandler extends BaseHubHandler implements Deliverable, Recei $messageInstance = $this->getStackInstance()->popNamed(self::STACKER_NAME_NEW_MESSAGE); // Generate the hash of comparing it - /* DEBUG-DIE: */ die(sprintf('[%s:%d]: messageInstance=%s', __METHOD__, __LINE__, print_r($messageInstance, TRUE))); + /* DEBUG-DIE: */ ApplicationEntryPoint::exitApplication(sprintf('[%s:%d]: messageInstance=%s', __METHOD__, __LINE__, print_r($messageInstance, TRUE))); /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-HANDLER: messageInstance=%s,senderId=%s,senderPrivateKeyHash=%s', $messageInstance->__toString(), $messageInstance->getSenderId(), $messageInstance->getSenderPrivateKeyHash())); if (empty($messageInstance->getSenderId())) { // Invalid $messageInstance @@ -1576,9 +1587,9 @@ class NetworkPackageHandler extends BaseHubHandler implements Deliverable, Recei } elseif (empty($messageInstance->getSenderPrivateKeyHash())) { // This needs fixing throw new InvalidPrivateKeyHashException(array($this, $senderData, 'empty hash in decodedData'), BaseHubSystem::EXCEPTION_INVALID_PRIVATE_KEY_HASH); - } elseif (!$this->isPackageHashValid($messageInstance)) { + } elseif (!$this->isMessageContentHashValid($messageInstance)) { // Is not valid, so throw an exception here - exit(__METHOD__ . ':INVALID HASH! UNDER CONSTRUCTION!' . PHP_EOL); + ApplicationEntryPoint::exitApplication(__METHOD__ . ':INVALID HASH! UNDER CONSTRUCTION!' . PHP_EOL); } // Now get a filter chain back from factory with given tags array @@ -1621,7 +1632,7 @@ class NetworkPackageHandler extends BaseHubHandler implements Deliverable, Recei $packageInstance = $this->getStackInstance()->popNamed(self::STACKER_NAME_PACKAGE_DECOMPRESSED_XML); // Generate the hash of comparing it - /* DEBUG-DIE: */ die(sprintf('[%s:%d]: packageInstance=%s', __METHOD__, __LINE__, print_r($packageInstance, TRUE))); + //* DEBUG-DIE: */ ApplicationEntryPoint::exitApplication(sprintf('[%s:%d]: packageInstance=%s', __METHOD__, __LINE__, print_r($packageInstance, TRUE))); /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-HANDLER: packageInstance=%s,senderId=%s,senderPrivateKeyHash=%s', $packageInstance->__toString(), $packageInstance->getSenderId(), $packageInstance->getSenderPrivateKeyHash())); if (empty($packageInstance->getSenderId())) { // Invalid $packageInstance @@ -1629,13 +1640,13 @@ class NetworkPackageHandler extends BaseHubHandler implements Deliverable, Recei } elseif (empty($packageInstance->getSenderPrivateKeyHash())) { // This needs fixing throw new InvalidPrivateKeyHashException(array($this, $senderData, 'empty hash in decodedData'), BaseHubSystem::EXCEPTION_INVALID_PRIVATE_KEY_HASH); - } elseif (!$this->isPackageHashValid($packageInstance)) { + } elseif (!$this->isPackageContentHashValid($packageInstance)) { // Is not valid, so throw an exception here - exit(__METHOD__ . ':INVALID HASH! UNDER CONSTRUCTION!' . PHP_EOL); + ApplicationEntryPoint::exitApplication(__METHOD__ . ':INVALID HASH! UNDER CONSTRUCTION!' . PHP_EOL); } // Parse package's XML into a message instance - /* DEBUG-DIE: */ die(sprintf('[%s:%d]: packageInstance=%s', __METHOD__, __LINE__, print_r($packageInstance, TRUE))); + /* DEBUG-DIE: */ ApplicationEntryPoint::exitApplication(sprintf('[%s:%d]: packageInstance=%s', __METHOD__, __LINE__, print_r($packageInstance, TRUE))); // Trace message /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: EXIT!'); diff --git a/application/hub/classes/info/connection/class_ConnectionInfo.php b/application/hub/classes/info/connection/class_ConnectionInfo.php index aaa0e308b..0c0f1845d 100644 --- a/application/hub/classes/info/connection/class_ConnectionInfo.php +++ b/application/hub/classes/info/connection/class_ConnectionInfo.php @@ -12,6 +12,7 @@ use Org\Shipsimu\Hub\Locator\Node\LocateableNode; use Org\Shipsimu\Hub\Traits\Container\Socket\StorableSocketTrait; // Import framework stuff +use Org\Mxchange\CoreFramework\EntryPoint\ApplicationEntryPoint; use Org\Mxchange\CoreFramework\Registry\Registerable; use Org\Mxchange\CoreFramework\Socket\InvalidSocketException; @@ -239,7 +240,7 @@ class ConnectionInfo extends BaseInfo implements ShareableInfo, Registerable { // Set socket here /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('CONNECTION-INFO: Setting socketInstance=%s ...', $socketInstance->__toString())); - //* DEBUG-DIE: */ die(sprintf('[%s:%d]: socketInstance=%s', __METHOD__, __LINE__, print_r($socketInstance, TRUE))); + //* DEBUG-DIE: */ ApplicationEntryPoint::exitApplication(sprintf('[%s:%d]: socketInstance=%s', __METHOD__, __LINE__, print_r($socketInstance, TRUE))); $this->setSocketInstance($socketInstance); // Trace message diff --git a/application/hub/classes/nodes/class_BaseHubNode.php b/application/hub/classes/nodes/class_BaseHubNode.php index 765b46814..fe2cfc915 100644 --- a/application/hub/classes/nodes/class_BaseHubNode.php +++ b/application/hub/classes/nodes/class_BaseHubNode.php @@ -23,6 +23,7 @@ use Org\Mxchange\CoreFramework\Criteria\Add\AddableCriteria; use Org\Mxchange\CoreFramework\Criteria\Local\LocalSearchCriteria; use Org\Mxchange\CoreFramework\Criteria\Storing\StoreableCriteria; use Org\Mxchange\CoreFramework\Database\Updateable; +use Org\Mxchange\CoreFramework\EntryPoint\ApplicationEntryPoint; use Org\Mxchange\CoreFramework\Factory\Database\Frontend\DatabaseFrontendFactory; use Org\Mxchange\CoreFramework\Factory\ObjectFactory; use Org\Mxchange\CoreFramework\Generic\NullPointerException; @@ -1036,7 +1037,7 @@ abstract class BaseHubNode extends BaseHubSystem implements Updateable, AddableC } // END - if // Debugging: - //* DEBUG-DIE: */ die(sprintf('[%s:%d]: nodeData=%s', __METHOD__, __LINE__, print_r($nodeData, TRUE))); + //* DEBUG-DIE: */ ApplicationEntryPoint::exitApplication(sprintf('[%s:%d]: nodeData=%s', __METHOD__, __LINE__, print_r($nodeData, TRUE))); // Return it return $nodeData; diff --git a/application/hub/classes/package/deliverable/class_PackageData.php b/application/hub/classes/package/deliverable/class_PackageData.php index b43f5955f..36bdb7620 100644 --- a/application/hub/classes/package/deliverable/class_PackageData.php +++ b/application/hub/classes/package/deliverable/class_PackageData.php @@ -6,6 +6,7 @@ namespace Org\Shipsimu\Hub\Network\Package; use Org\Shipsimu\Hub\Generic\BaseHubSystem; // Import framework stuff +use Org\Mxchange\CoreFramework\EntryPoint\ApplicationEntryPoint; use Org\Mxchange\CoreFramework\Registry\Registerable; // Import SPL stuff @@ -41,11 +42,6 @@ class PackageData extends BaseHubSystem implements DeliverablePackage, Registera */ private $contentHash; - /** - * Content message - */ - private $rawXml; - /** * Content checksum */ @@ -329,25 +325,6 @@ class PackageData extends BaseHubSystem implements DeliverablePackage, Registera $this->contentTags = $contentTags; } - /** - * Getter for content message - * - * @return $rawXml Content message - */ - public final function getRawXml () { - return $this->rawXml; - } - - /** - * Setter for content message - * - * @param $rawXml Content message - * @return void - */ - public final function setRawXml (string $rawXml) { - $this->rawXml = $rawXml; - } - /** * Getter for content checksum * @@ -463,7 +440,7 @@ class PackageData extends BaseHubSystem implements DeliverablePackage, Registera //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('PACKAGE-DATA: properties()=%d', count($properties))); foreach ($properties as $propertyInstance) { // Is the declaring class this one? - //* DEBUG-DIE: */ die(sprintf('[%s:%d] propertyInstance=%s', __METHOD__, __LINE__, print_r($propertyInstance))); + //* DEBUG-DIE: */ ApplicationEntryPoint::exitApplication(sprintf('[%s:%d] propertyInstance=%s', __METHOD__, __LINE__, print_r($propertyInstance))); //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('PACKAGE-DATA: propertyInstance->declaringClass->name=%s', $propertyInstance->getDeclaringClass()->getName())); if ($propertyInstance->getDeclaringClass()->getName() !== $this->__toString()) { // No, then skip this one diff --git a/application/hub/classes/package/fragmenter/class_PackageFragmenter.php b/application/hub/classes/package/fragmenter/class_PackageFragmenter.php index acdf7946b..c8870b9cf 100644 --- a/application/hub/classes/package/fragmenter/class_PackageFragmenter.php +++ b/application/hub/classes/package/fragmenter/class_PackageFragmenter.php @@ -11,6 +11,7 @@ use Org\Shipsimu\Hub\Network\Package\DeliverablePackage; // Import framework stuff use Org\Mxchange\CoreFramework\Assertion\AssertionException; use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap; +use Org\Mxchange\CoreFramework\EntryPoint\ApplicationEntryPoint; use Org\Mxchange\CoreFramework\Factory\ObjectFactory; use Org\Mxchange\CoreFramework\Registry\Registerable; use Org\Mxchange\CoreFramework\Traits\Crypto\CryptoTrait; @@ -508,10 +509,12 @@ class PackageFragmenter extends BaseHubSystem implements Fragmentable, Registera if (!$this->isPackageProcessed($packageInstance)) { // First put it the right way together again, implode on getAllAsArray() won't work! /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-FRAGMENTER: Package is not processed., getting all raw data ...'); - //* DEBUG-DIE: */ die(sprintf('[%s:%d]: packageInstance->allAsArray=%s', __METHOD__, __LINE__, print_r($packageInstance->getAllAsArray(), TRUE))); - $rawData = sprintf('%s%s%d%s%s%s%s%s%s%s%s%s%s', + //* DEBUG-DIE: */ ApplicationEntryPoint::exitApplication(sprintf('[%s:%d]: packageInstance->allAsArray=%s', __METHOD__, __LINE__, print_r($packageInstance->getAllAsArray(), TRUE))); + $rawData = sprintf('%s%s%s%s%d%s%s%s%s%s%s%s%s%s%s', $packageInstance->getSenderAddress(), NetworkPackageHandler::PACKAGE_DATA_SEPARATOR, + $packageInstance->getSenderId(), + NetworkPackageHandler::PACKAGE_DATA_SEPARATOR, $packageInstance->getSenderPort(), NetworkPackageHandler::PACKAGE_DATA_SEPARATOR, $packageInstance->getRecipientId(), diff --git a/application/hub/classes/recipient/dht/class_DhtRecipient.php b/application/hub/classes/recipient/dht/class_DhtRecipient.php index 026cf4961..bc7781af7 100644 --- a/application/hub/classes/recipient/dht/class_DhtRecipient.php +++ b/application/hub/classes/recipient/dht/class_DhtRecipient.php @@ -10,6 +10,7 @@ use Org\Shipsimu\Hub\Network\Recipient\BaseRecipient; use Org\Shipsimu\Hub\Network\Recipient\Recipient; // Import framework stuff +use Org\Mxchange\CoreFramework\EntryPoint\ApplicationEntryPoint; use Org\Mxchange\CoreFramework\Factory\ObjectFactory; use Org\Mxchange\CoreFramework\Lists\Listable; @@ -93,7 +94,7 @@ class DhtRecipient extends BaseRecipient implements Recipient { foreach ($recipients as $recipient) { // These array elements must exist for this loop: //* PRINTR-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('DHT-RECIPIENT: recipient=%s', print_r($recipient, TRUE))); - //* DEBUG-DIE: */ die(sprintf('[%s:%d]: recipient=%s', __METHOD__, __LINE__, print_r($recipient, TRUE))); + //* DEBUG-DIE: */ ApplicationEntryPoint::exitApplication(sprintf('[%s:%d]: recipient=%s', __METHOD__, __LINE__, print_r($recipient, TRUE))); if (empty($recipient[NodeDistributedHashTableDatabaseFrontend::DB_COLUMN_EXTERNAL_ADDRESS])) { // External UNL needs to be set throw new LogicException(sprintf('recipient[%s] is not set', NodeDistributedHashTableDatabaseFrontend::DB_COLUMN_EXTERNAL_ADDRESS)); diff --git a/application/hub/classes/registry/socket/class_SocketRegistry.php b/application/hub/classes/registry/socket/class_SocketRegistry.php index 2632e189c..598e305c9 100644 --- a/application/hub/classes/registry/socket/class_SocketRegistry.php +++ b/application/hub/classes/registry/socket/class_SocketRegistry.php @@ -13,6 +13,7 @@ use Org\Shipsimu\Hub\Network\Package\DeliverablePackage; use Org\Shipsimu\Hub\Registry\Socket\RegisterableSocket; // Import framework stuff +use Org\Mxchange\CoreFramework\EntryPoint\ApplicationEntryPoint; use Org\Mxchange\CoreFramework\Factory\ObjectFactory; use Org\Mxchange\CoreFramework\Generic\FrameworkInterface; use Org\Mxchange\CoreFramework\Registry\BaseRegistry; @@ -351,18 +352,18 @@ class SocketRegistry extends BaseRegistry implements Register, RegisterableSocke public function isIncomingSocketRegistered (Listenable $listenerInstance) { // Default is not found /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('SOCKET-REGISTRY: listenerInstance=%s (protocol: %s) - CALLED!', $listenerInstance->__toString(), strtoupper($listenerInstance->getProtocolName()))); - //* DEBUG-DIE: */ die(sprintf('[%s:%d]: this=%s', __METHOD__, __LINE__, print_r($this, TRUE))); + //* DEBUG-DIE: */ ApplicationEntryPoint::exitApplication(sprintf('[%s:%d]: this=%s', __METHOD__, __LINE__, print_r($this, TRUE))); $isRegistered = FALSE; // Search listener's socket sub-registry $registryInstance = $this->getInstance($listenerInstance->getProtocolName()); - //* DEBUG-DIE: */ die(sprintf('[%s:%d]: listenerInstance->protocolName=%s,registryInstance=%s', __METHOD__, __LINE__, $listenerInstance->getProtocolName(), print_r($registryInstance, TRUE))); + //* DEBUG-DIE: */ ApplicationEntryPoint::exitApplication(sprintf('[%s:%d]: listenerInstance->protocolName=%s,registryInstance=%s', __METHOD__, __LINE__, $listenerInstance->getProtocolName(), print_r($registryInstance, TRUE))); // Get all sockets from it foreach ($registryInstance->getInstanceRegistry() as $instanceKey => $socketInstance) { // Is this socket as requested? /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('SOCKET-REGISTRY: instanceKey=%s,socketInstance=%s,socketType=%s', $instanceKey, $socketInstance->__toString(), $socketInstance->getSocketType())); - //* DEBUG-DIE: */ die(sprintf('[%s:%d]: socketInstance=%s', __METHOD__, __LINE__, print_r($socketInstance, TRUE))); + //* DEBUG-DIE: */ ApplicationEntryPoint::exitApplication(sprintf('[%s:%d]: socketInstance=%s', __METHOD__, __LINE__, print_r($socketInstance, TRUE))); if ($socketInstance->getSocketType() == StorableSocket::CONNECTION_TYPE_INCOMING) { // Is found! $isRegistered = TRUE; diff --git a/application/hub/classes/tags/package/class_PackageTags.php b/application/hub/classes/tags/package/class_PackageTags.php index 3561fe8ba..ab8cf6a00 100644 --- a/application/hub/classes/tags/package/class_PackageTags.php +++ b/application/hub/classes/tags/package/class_PackageTags.php @@ -14,6 +14,7 @@ use Org\Shipsimu\Hub\Tag\Tagable; use Org\Shipsimu\Hub\Template\Engine\Xml\ObjectRegistry\XmlObjectRegistryTemplateEngine; // Import framework stuff +use Org\Mxchange\CoreFramework\EntryPoint\ApplicationEntryPoint; use Org\Mxchange\CoreFramework\Factory\Template\XmlTemplateEngineFactory; use Org\Mxchange\CoreFramework\Registry\GenericRegistry; @@ -124,7 +125,7 @@ class PackageTags extends BaseTag implements Tagable { $contentData = explode(NetworkPackageHandler::PACKAGE_MASK_SEPARATOR, $packageInstance->getPackageContent()); // Get the tags and store them locally - //* DEBUG-DIE: */ die(sprintf('[%s:%d]: contentData(%d)=%s', __METHOD__, __LINE__, count($contentData), print_r($contentData, TRUE))); + //* DEBUG-DIE: */ ApplicationEntryPoint::exitApplication(sprintf('[%s:%d]: contentData(%d)=%s', __METHOD__, __LINE__, count($contentData), print_r($contentData, TRUE))); $this->setTags(explode(NetworkPackageHandler::PACKAGE_TAGS_SEPARATOR, $contentData[NetworkPackageHandler::INDEX_TAGS])); } @@ -156,7 +157,7 @@ class PackageTags extends BaseTag implements Tagable { * the entry is invalid. */ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('PACKAGE-TAGS: entry[]=%s', gettype($entry))); - //* DEBUG-DIE: */ die(sprintf('[%s:%d] entry=%s', __METHOD__, __LINE__, print_r($entry, TRUE))); + //* DEBUG-DIE: */ ApplicationEntryPoint::exitApplication(sprintf('[%s:%d] entry=%s', __METHOD__, __LINE__, print_r($entry, TRUE))); if ((!is_array($entry)) || (count($entry) == 0) || (!isset($entry[XmlObjectRegistryTemplateEngine::OBJECT_TYPE_DATA_PROTOCOL])) || (!isset($entry[XmlObjectRegistryTemplateEngine::OBJECT_TYPE_DATA_RECIPIENT_TYPE]))) { // Invalid entry found throw new InvalidTagException(array($this, $tag), self::EXCEPTION_INVALID_TAG); diff --git a/application/hub/classes/tools/hub/class_HubTools.php b/application/hub/classes/tools/hub/class_HubTools.php index bbbbffde3..adcfae52c 100644 --- a/application/hub/classes/tools/hub/class_HubTools.php +++ b/application/hub/classes/tools/hub/class_HubTools.php @@ -12,6 +12,7 @@ use Org\Shipsimu\Hub\Node\Data\InvalidSessionIdException; // Import framework stuff use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap; +use Org\Mxchange\CoreFramework\EntryPoint\ApplicationEntryPoint; use Org\Mxchange\CoreFramework\Factory\ObjectFactory; // Import SPL stuff @@ -187,7 +188,7 @@ class HubTools extends BaseHubSystem { $recipientData = DhtObjectFactory::createDhtInstance('node')->findNodeByUniversalNodeLocator($locatorInstance); // Init variable - //* DEBUG-DIE: */ die(sprintf('[%s:%d]: recipientData=%s', __METHOD__, __LINE__, print_r($recipientData, TRUE))); + //* DEBUG-DIE: */ ApplicationEntryPoint::exitApplication(sprintf('[%s:%d]: recipientData=%s', __METHOD__, __LINE__, print_r($recipientData, TRUE))); $sessionId = NULL; // Is an entry found? diff --git a/application/hub/interfaces/delivery/package/class_DeliverablePackage.php b/application/hub/interfaces/delivery/package/class_DeliverablePackage.php index 4e085b85a..c7a705856 100644 --- a/application/hub/interfaces/delivery/package/class_DeliverablePackage.php +++ b/application/hub/interfaces/delivery/package/class_DeliverablePackage.php @@ -178,21 +178,6 @@ interface DeliverablePackage extends HubInterface { */ function setContentTags (array $contentTags); - /** - * Getter for content message - * - * @return $rawXml Content message - */ - function getRawXml (); - - /** - * Setter for content message - * - * @param $rawXml Content message - * @return void - */ - function setRawXml (string $rawXml); - /** * Getter for content checksum * diff --git a/core b/core index 57b4b400d..c30da7e11 160000 --- a/core +++ b/core @@ -1 +1 @@ -Subproject commit 57b4b400d2e4a35f92d83270477157df4ee7c2c4 +Subproject commit c30da7e118a91b814adb6e997a1e4a39d0f1cba4