]> git.mxchange.org Git - hub.git/blobdiff - application/hub/main/nodes/class_BaseHubNode.php
More rewrites (and code stops):
[hub.git] / application / hub / main / nodes / class_BaseHubNode.php
index bacb47134709339c6ae3f7ee9926b2e6b594d0bb..08746675e1db898d2c5dde09f0ce4f5f01580f60 100644 (file)
@@ -37,9 +37,9 @@ class BaseHubNode extends BaseHubSystem implements Updateable, AddableCriteria {
        const OBJECT_LIST_SEPARATOR = ',';
 
        /**
-        * IP/port number of bootstrap node
+        * Universal node locator of bootstrap node
         */
-       private $bootIpPort = '';
+       private $bootUniversalNodeLocator = '';
 
        /**
         * Whether this node is anncounced (keep on FALSE!)
@@ -111,7 +111,7 @@ class BaseHubNode extends BaseHubSystem implements Updateable, AddableCriteria {
                $rngInstance = ObjectFactory::createObjectByConfiguredName('rng_class');
 
                // Generate a pseudo-random string
-               $randomString = $rngInstance->randomString($length) . ':' . $this->getBootIpPort() . ':' . $this->getRequestInstance()->getRequestElement('mode');
+               $randomString = $rngInstance->randomString($length) . ':' . $this->getBootUniversalNodeLocator() . ':' . $this->getRequestInstance()->getRequestElement('mode');
 
                // Add UUID for even more entropy for the hasher
                $randomString .= $this->getCryptoInstance()->createUuid();
@@ -147,10 +147,10 @@ class BaseHubNode extends BaseHubSystem implements Updateable, AddableCriteria {
        /**
         * Getter for boot IP/port combination
         *
-        * @return      $bootIpPort             The IP/port combination of the boot node
+        * @return      $bootUniversalNodeLocator               The IP/port combination of the boot node
         */
-       protected final function getBootIpPort () {
-               return $this->bootIpPort;
+       protected final function getBootUniversalNodeLocator () {
+               return $this->bootUniversalNodeLocator;
        }
 
        /**
@@ -164,24 +164,26 @@ class BaseHubNode extends BaseHubSystem implements Updateable, AddableCriteria {
                $isFound = FALSE;
 
                // Run through all configured IPs
-               foreach (explode(BaseHubSystem::BOOTSTRAP_NODES_SEPARATOR, $this->getConfigInstance()->getConfigEntry('hub_bootstrap_nodes')) as $ipPort) {
-                       // Split it up in IP/port
-                       $ipPortArray = explode(':', $ipPort);
+               foreach (explode(BaseHubSystem::BOOTSTRAP_NODES_SEPARATOR, $this->getConfigInstance()->getConfigEntry('hub_bootstrap_nodes')) as $unl) {
+                       // Get back an array from the UNL
+                       $unlArray = HubTools::getArrayFromUniversalNodeLocator($unl);
+                       // @TODO Unfinished
+                       die(__METHOD__ . ':' . print_r($unlArray, TRUE));
 
                        // Does it match?
-                       if ($ipPortArray[0] == $remoteAddr) {
+                       if ($unlArray[0] == $remoteAddr) {
                                // Found it!
                                $isFound = TRUE;
 
                                // Remember the port number
-                               $this->bootIpPort = $ipPort;
+                               $this->bootUniversalNodeLocator = $unl;
 
                                // Output message
-                               self::createDebugInstance(__CLASS__)->debugOutput('BOOTSTRAP: ' . __FUNCTION__ . '[' . __METHOD__ . ':' . __LINE__ . ']: IP matches remote address ' . $ipPort . '.');
+                               self::createDebugInstance(__CLASS__)->debugOutput('BOOTSTRAP: ' . __FUNCTION__ . '[' . __METHOD__ . ':' . __LINE__ . ']: IP matches remote address ' . $unl . '.');
 
                                // Stop further searching
                                break;
-                       } elseif ($ipPortArray[0] == $this->getConfigInstance()->getConfigEntry('node_listen_addr')) {
+                       } elseif ($unlArray[0] == $this->getConfigInstance()->getConfigEntry('node_listen_addr')) {
                                /*
                                 * IP matches listen address. At this point we really don't care
                                 * if we can really listen on that address
@@ -189,10 +191,10 @@ class BaseHubNode extends BaseHubSystem implements Updateable, AddableCriteria {
                                $isFound = TRUE;
 
                                // Remember the port number
-                               $this->bootIpPort = $ipPort;
+                               $this->bootUniversalNodeLocator = $unl;
 
                                // Output message
-                               self::createDebugInstance(__CLASS__)->debugOutput('BOOTSTRAP: ' . __FUNCTION__ . '[' . __METHOD__ . ':' . __LINE__ . ']: IP matches listen address ' . $ipPort . '.');
+                               self::createDebugInstance(__CLASS__)->debugOutput('BOOTSTRAP: ' . __FUNCTION__ . '[' . __METHOD__ . ':' . __LINE__ . ']: IP matches listen address ' . $unl . '.');
 
                                // Stop further searching
                                break;
@@ -684,29 +686,31 @@ class BaseHubNode extends BaseHubSystem implements Updateable, AddableCriteria {
        }
 
        /**
-        * "Getter" for address:port combination
+        * Determines the universal node locator
         *
-        * @return      $addressPort    A address:port combination for this node
+        * @return      $unl    A an universal node locator for this node
         */
-       public final function getAddressPort () {
+       public final function determineUniversalNodeLocator () {
                // Get IP and port
-               $addressPort = $this->getConfigInstance()->detectServerAddress() . ':' . $this->getConfigInstance()->getConfigEntry('node_listen_port');
+               $unl = $this->getConfigInstance()->detectServerAddress() . ':' . $this->getConfigInstance()->getConfigEntry('node_listen_port');
 
                // Return it
-               return $addressPort;
+               return $unl;
        }
 
        /**
-        * "Getter" for address:port array
+        * "Getter" for universal node locator array
         *
-        * @return      $addressPortArray       An array of a address:port combination for this node
+        * @return      $unlArray       An array of the universal node locator for this node
         */
-       public final function getAddressPortArray () {
+       public final function getUniversalNodeLocatorArray () {
                // Get IP and port
-               $addressPortArray = explode(':', $this->getAddressPort());
+               // @TODO Unfinished
+               die(__METHOD__ . ':' . print_r($this, TRUE));
+               $unlArray = explode(':', $this->determineUniversalNodeLocator());
 
                // Return it
-               return $addressPortArray;
+               return $unlArray;
        }
 
        /**