From: Roland Häder Date: Mon, 9 May 2022 20:45:18 +0000 (+0200) Subject: Continued: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=5ca30b108ec5240a289c3c51ed462cce8686edf8;p=hub.git Continued: - renamed $content to $rawTemplateData to reflect its real purpose - added more (also dying) debug lines --- diff --git a/application/hub/classes/container/socket/class_SocketContainer.php b/application/hub/classes/container/socket/class_SocketContainer.php index 0ca5d1dd1..e65cb7b2b 100644 --- a/application/hub/classes/container/socket/class_SocketContainer.php +++ b/application/hub/classes/container/socket/class_SocketContainer.php @@ -201,6 +201,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita // Get current package data $packageInstance = $this->getPackageDataInstance(); + /* DEBUG-DIE: */ if ($this->getSocketType() == StorableSocket::CONNECTION_TYPE_INCOMING) { die(sprintf('[%s:%d]: this=%s', __METHOD__, __LINE__, print_r($this, TRUE))); } //* DEBUG-DIE: */ if ($this->getSocketType() == StorableSocket::CONNECTION_TYPE_INCOMING) { die(sprintf('[%s:%d]: packageInstance=%s', __METHOD__, __LINE__, print_r($packageInstance, TRUE))); } // So, does both match? diff --git a/application/hub/classes/handler/package/class_NetworkPackageHandler.php b/application/hub/classes/handler/package/class_NetworkPackageHandler.php index 0b7f23a38..b3951ece2 100644 --- a/application/hub/classes/handler/package/class_NetworkPackageHandler.php +++ b/application/hub/classes/handler/package/class_NetworkPackageHandler.php @@ -719,6 +719,7 @@ class NetworkPackageHandler extends BaseHubHandler implements Deliverable, Recei $sentBytes = 0; // Get the right connection instance + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-HANDLER: Invoking this->registryInstance->determineInfoInstanceByPackageInstance(%s) ...', gettype($packageInstance))); $infoInstance = $this->getRegistryInstance()->determineInfoInstanceByPackageInstance($packageInstance); // Test helper instance @@ -843,19 +844,20 @@ class NetworkPackageHandler extends BaseHubHandler implements Deliverable, Recei public function enqueueRawDataFromTemplate (HubHelper $helperInstance) { // Get the raw content ... /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: helperInstance=' . $helperInstance->__toString() . ' - CALLED!'); - $content = $helperInstance->getTemplateInstance()->getRawTemplateData(); + $rawTemplateData = $helperInstance->getTemplateInstance()->getRawTemplateData(); // Should not be empty - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-HANDLER: content(%d)=%s', strlen($content), $content)); - if (empty($content)) { + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-HANDLER: rawTemplateData(%d)=%s', strlen($rawTemplateData), $rawTemplateData)); + if (empty($rawTemplateData)) { // Abort here - throw new UnexpectedValueException('Parameter "content" is empty'); + throw new UnexpectedValueException('Variable "rawTemplateData" is unexpectly empty.'); } // ... and compress it - $compressed = $this->getCompressorInstance()->compressStream($content); + $compressed = $this->getCompressorInstance()->compressStream($rawTemplateData); // Add magic in front of it and hash behind it, including BASE64 encoding + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-HANDLER: compressed()=%d', strlen($compressed))); $packageContent = sprintf(self::PACKAGE_MASK, // 1.) Compressor's extension $this->getCompressorInstance()->getCompressorExtension(), @@ -884,7 +886,7 @@ class NetworkPackageHandler extends BaseHubHandler implements Deliverable, Recei /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-HANDLER: Setting packageContent=%s ...', $packageContent)); $packageInstance->setPackageContent($packageContent); $packageInstance->setPackageStatus(self::PACKAGE_STATUS_NEW); - $packageInstance->setContentHash($this->generatePackageHash($content, $this->getNodeInstance()->getSessionId())); + $packageInstance->setContentHash($this->generatePackageHash($rawTemplateData, $this->getNodeInstance()->getSessionId())); $packageInstance->setSenderPrivateKeyHash($this->getNodeInstance()->getNodePrivateKeyHash()); // Now prepare the temporary array and push it on the 'undeclared' stack diff --git a/application/hub/classes/nodes/class_BaseHubNode.php b/application/hub/classes/nodes/class_BaseHubNode.php index 44a278174..e901e8f38 100644 --- a/application/hub/classes/nodes/class_BaseHubNode.php +++ b/application/hub/classes/nodes/class_BaseHubNode.php @@ -232,8 +232,16 @@ abstract class BaseHubNode extends BaseHubSystem implements Updateable, AddableC * * @param $remoteAddr IP address to checkout against our bootstrapping list * @return $isFound Whether the IP is found + * @throws InvalidArgumentException If a parameter is empty */ protected function ifAddressMatchesBootstrapNodes (string $remoteAddr) { + // Check parameter + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-HUB-NODE: remoteAddr=%s - CALLED!', $remoteAddr)); + if (empty($remoteAddr)) { + // Invalid parameter + throw new InvalidArgumentException('Parameter "remoteAddr" is empty'); + } + // By default nothing is found $isFound = FALSE; diff --git a/application/hub/classes/registry/socket/class_SocketRegistry.php b/application/hub/classes/registry/socket/class_SocketRegistry.php index f61a2340c..d7a5b9ff3 100644 --- a/application/hub/classes/registry/socket/class_SocketRegistry.php +++ b/application/hub/classes/registry/socket/class_SocketRegistry.php @@ -287,7 +287,7 @@ class SocketRegistry extends BaseRegistry implements Register, RegisterableSocke // Init info instance /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('SOCKET-REGISTRY: packageInstance=%s - CALLED!', $packageInstance)); $infoInstance = NULL; - //* DEBUG-DIE: */ die(__METHOD__ . ':packageData=' . print_r($packageData, TRUE)); + //* DEBUG-DIE: */ die(__METHOD__ . ':packageInstance=' . print_r($packageInstance, TRUE)); // Get all keys and check them /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('SOCKET-REGISTRY: this->instanceRegistry()=%d', count($this->getInstanceRegistry())));