]> git.mxchange.org Git - hub.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Mon, 9 May 2022 20:45:18 +0000 (22:45 +0200)
committerRoland Häder <roland@mxchange.org>
Mon, 9 May 2022 20:45:18 +0000 (22:45 +0200)
- renamed $content to $rawTemplateData to reflect its real purpose
- added more (also dying) debug lines

application/hub/classes/container/socket/class_SocketContainer.php
application/hub/classes/handler/package/class_NetworkPackageHandler.php
application/hub/classes/nodes/class_BaseHubNode.php
application/hub/classes/registry/socket/class_SocketRegistry.php

index 0ca5d1dd13315cbe4e2c28012df4a2264246ee42..e65cb7b2b17d21fd5f4102cce5d10bde86a40935 100644 (file)
@@ -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?
index 0b7f23a383ba64439f468367a9b6dfff817016e7..b3951ece29655287ce5a7f2c1dc55ae4e9f90b74 100644 (file)
@@ -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
index 44a2781748dda491e5e2cd25c67ed369d8e2a0b8..e901e8f38dd732db70be717a64d6dd9077e8db00 100644 (file)
@@ -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;
 
index f61a2340ce50e911cd83d66c8cc48ea0bddcf4d6..d7a5b9ff318d4ed78acfc3b464e7a36e075c746b 100644 (file)
@@ -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())));