]> git.mxchange.org Git - hub.git/commitdiff
Continued with refacturing:
authorRoland Haeder <roland@mxchange.org>
Tue, 23 Dec 2014 12:55:43 +0000 (13:55 +0100)
committerRoland Haeder <roland@mxchange.org>
Tue, 23 Dec 2014 12:55:43 +0000 (13:55 +0100)
- Removed no longer needed port which was only for TCP/UDP connections
- Added UniversalNodeLocator class
- Some parts are now "basicly finished", still there is a lot work to do
- Updated 'core' to latest commit id

Signed-off-by: Roland Haeder <roland@mxchange.org>
38 files changed:
application/hub/config.php
application/hub/exceptions/announcement/class_AnnouncementNotAcceptedException.php
application/hub/exceptions/announcement/class_NoAnnouncementAttemptedException.php
application/hub/exceptions/dht/class_DhtBootstrapNotAcceptedException.php
application/hub/exceptions/node/class_NodeSessionIdVerficationException.php
application/hub/exceptions/wrapper/class_NodeAlreadyRegisteredException.php
application/hub/exceptions/wrapper/class_NodeDataMissingException.php
application/hub/interfaces/helper/nodes/class_NodeHelper.php
application/hub/main/discovery/node/class_UniversalNodeLocatorDiscovery.php
application/hub/main/filter/tags/answer/class_PackageAnnouncementAnswerTagFilter.php
application/hub/main/filter/tags/class_PackageAnnouncementTagFilter.php
application/hub/main/filter/tags/class_PackageDhtBootstrapTagFilter.php
application/hub/main/handler/answer-status/announcement/class_AnnouncementAnswerOkayHandler.php
application/hub/main/handler/message-types/announcement/class_NodeMessageAnnouncementHandler.php
application/hub/main/handler/message-types/answer/class_NodeMessageAnnouncementAnswerHandler.php
application/hub/main/handler/message-types/answer/class_NodeMessageDhtBootstrapAnswerHandler.php
application/hub/main/handler/message-types/dht/class_NodeMessageDhtBootstrapHandler.php
application/hub/main/nodes/class_BaseHubNode.php
application/hub/main/pools/peer/class_DefaultPeerPool.php
application/hub/main/recipient/dht/class_DhtRecipient.php
application/hub/main/recipient/direct/class_DirectRecipient.php
application/hub/main/recipient/upper/class_UpperRecipient.php
application/hub/main/resolver/protocol/tcp/class_TcpProtocolResolver.php
application/hub/main/template/announcement/class_XmlAnnouncementTemplateEngine.php
application/hub/main/template/answer/announcement/class_XmlAnnouncementAnswerTemplateEngine.php
application/hub/main/template/answer/dht/class_XmlDhtBootstrapAnswerTemplateEngine.php
application/hub/main/template/dht/class_XmlDhtBootstrapTemplateEngine.php
application/hub/main/template/publish/class_XmlDhtPublishEntryTemplateEngine.php
application/hub/main/tools/class_HubTools.php
application/hub/main/unl/.htaccess [new file with mode: 0644]
application/hub/main/unl/class_UniversalNodeLocator.php [new file with mode: 0644]
application/hub/main/wrapper/node/class_NodeDistributedHashTableDatabaseWrapper.php
application/hub/templates/xml/announcement/announcement.xml
application/hub/templates/xml/answer/announcement/announcement_answer.xml
application/hub/templates/xml/answer/dht_bootstrap/dht_bootstrap_answer.xml
application/hub/templates/xml/dht_bootstrap/dht_bootstrap.xml
application/hub/templates/xml/dht_publish/publish.xml
core

index b68b510004e0f98c6ebb6913c8d26b1852fcb3f3..bb5c4e6369dfab46c19d3dbbf53a63357aa9e27e 100644 (file)
@@ -729,9 +729,12 @@ $cfg->setConfigEntry('socket_discovery_class', 'PackageSocketDiscovery');
 // CFG: DHT-RECIPIENT-DISCOVERY-CLASS
 $cfg->setConfigEntry('dht_recipient_discovery_class', 'DhtRecipientDiscovery');
 
-// CFG: UNIVERSAL-NODE-LOCATOR-DISCOVERY-CLASS
+// CFG: UNL-DISCOVERY-CLASS
 $cfg->setConfigEntry('unl_discovery_class', 'UniversalNodeLocatorDiscovery');
 
+// CFG: UNIVERSAL-NODE-LOCATOR-CLASS
+$cfg->setConfigEntry('universal_node_locator_class', 'UniversalNodeLocator');
+
 // CFG: RECIPIENT-LIST-CLASS
 $cfg->setConfigEntry('recipient_list_class', 'RecipientList');
 
index 8ec66001ed3ceb6745801b2a9eb6e21f86c8df1e..3004802cd2eb399dc1ca3a29c37f5066de4ed35e 100644 (file)
@@ -32,14 +32,13 @@ class AnnouncementNotAcceptedException extends FrameworkException {
         */
        public function __construct (array $messageArray, $code) {
                // Construct the message
-               $message = sprintf('[%s:%d] This node (%s) is not accepting announcements, but got one from session-id=%s,ip=%s/%s,listen port=%s,status=%s,mode=%s',
+               $message = sprintf('[%s:%d] This node (%s) is not accepting announcements, but got one from session-id=%s,unl=%s/%s,status=%s,mode=%s',
                        $messageArray[0]->__toString(),
                        $this->getLine(),
                        $messageArray[1]->__toString(),
                        $messageArray[2][XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_SESSION_ID],
                        $messageArray[2][XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_EXTERNAL_ADDRESS],
                        $messageArray[2][XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_INTERNAL_ADDRESS],
-                       $messageArray[2][XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_LISTEN_PORT],
                        $messageArray[2][XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_NODE_STATUS],
                        $messageArray[2][XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_NODE_MODE]
                );
index 9f96fdd812f5d519fc273f4aeb9b21f09e3b3430..a9531006048e2a9ab350b86e15416b74e1ffb503 100644 (file)
@@ -32,14 +32,13 @@ class NoAnnouncementAttemptedException extends FrameworkException {
         */
        public function __construct (array $messageArray, $code) {
                // Construct the message
-               $message = sprintf('[%s:%d] This node (%s) has not attempted to announce itself, but got an answer from session-id=%s,ip=%s/%s,listen port=%s,status=%s.',
+               $message = sprintf('[%s:%d] This node (%s) has not attempted to announce itself, but got an answer from session-id=%s,unl=%s/%s,status=%s.',
                        $messageArray[0]->__toString(),
                        $this->getLine(),
                        $messageArray[1]->__toString(),
                        $messageArray[2][XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_SESSION_ID],
                        $messageArray[2][XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_EXTERNAL_ADDRESS],
                        $messageArray[2][XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_INTERNAL_ADDRESS],
-                       $messageArray[2][XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_LISTEN_PORT],
                        $messageArray[2][XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_NODE_STATUS]
                );
 
index b8f196af361b3acf85994b6c483e969cdf10e28f..e2637e3aebb34823759a582106e66a56ef640f4a 100644 (file)
@@ -32,14 +32,13 @@ class DhtBootstrapNotAcceptedException extends FrameworkException {
         */
        public function __construct (array $messageArray, $code) {
                // Construct the message
-               $message = sprintf('[%s:%d] This node (%s) is not accepting DHT bootstrap requests, but got one from session-id=%s,ip=%s/%s,listen port=%s,status=%s,mode=%s',
+               $message = sprintf('[%s:%d] This node (%s) is not accepting DHT bootstrap requests, but got one from session-id=%s,unl=%s/%s,status=%s,mode=%s',
                        $messageArray[0]->__toString(),
                        $this->getLine(),
                        $messageArray[0]->getNodeInstance()->__toString(),
                        $messageArray[1][XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_SESSION_ID],
                        $messageArray[1][XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_EXTERNAL_ADDRESS],
                        $messageArray[1][XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_INTERNAL_ADDRESS],
-                       $messageArray[1][XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_LISTEN_PORT],
                        $messageArray[1][XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_NODE_STATUS],
                        $messageArray[1][XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_NODE_MODE]
                );
index 93640c0e78584ca09a6be5a8ccadf54e85ece24d..1acf2b29edc44ac853665153695f57984e6df620 100644 (file)
@@ -33,13 +33,12 @@ class NodeSessionIdVerficationException extends FrameworkException {
         */
        public function __construct (array $messageArray, $code) {
                // Construct the message
-               $message = sprintf('[%s:%d] Session id %s cannot be verfied. ip=%s/%s,listen port=%s,status=%s.',
+               $message = sprintf('[%s:%d] Session id %s cannot be verfied. unl=%s/%s,status=%s.',
                        $messageArray[0]->__toString(),
                        $this->getLine(),
                        $messageArray[1][XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_SESSION_ID],
                        $messageArray[1][XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_EXTERNAL_ADDRESS],
                        $messageArray[1][XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_INTERNAL_ADDRESS],
-                       $messageArray[1][XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_LISTEN_PORT],
                        $messageArray[1][XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_NODE_STATUS]
                );
 
index 887cfd69cfc2e4cfc097a66d26d657660f0c9d9e..318782cb70daa6d68b18a6dbe56ceca01bd1f99a 100644 (file)
@@ -31,12 +31,11 @@ class NodeAlreadyRegisteredException extends FrameworkException {
         */
        public function __construct (array $messageArray, $code) {
                // Construct the message
-               $message = sprintf('[%s:%d] Node already registered: session-id=%s, external-address=%s, listen-port=%s',
+               $message = sprintf('[%s:%d] Node already registered: session-id=%s, external-address=%s',
                        $messageArray[0]->__toString(),
                        $this->getLine(),
                        $msssageArray[1][NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_SESSION_ID],
-                       $msssageArray[1][NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_EXTERNAL_ADDRESS],
-                       $msssageArray[1][NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_LISTEN_PORT],
+                       $msssageArray[1][NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_EXTERNAL_ADDRESS]
                );
 
                // Call parent exception constructor
index 4187ba2e625535d1e12303ce81d53aff333cec71..c2de8a4be7876b5605a6bde70881b1bcffb91d98 100644 (file)
@@ -31,12 +31,11 @@ class NodeDataMissingException extends FrameworkException {
         */
        public function __construct (array $messageArray, $code) {
                // Construct the message
-               $message = sprintf('[%s:%d] Node not registered/missing: session-id=%s, external-address=%s, listen-port=%s',
+               $message = sprintf('[%s:%d] Node not registered/missing: session-id=%s, external-address=%s',
                        $messageArray[0]->__toString(),
                        $this->getLine(),
                        $msssageArray[1][NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_SESSION_ID],
-                       $msssageArray[1][NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_EXTERNAL_ADDRESS],
-                       $msssageArray[1][NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_LISTEN_PORT],
+                       $msssageArray[1][NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_EXTERNAL_ADDRESS]
                );
 
                // Call parent exception constructor
index 59e0760cfb71a1a85559d1c3f9e5f931d99693c0..31354fa47a9a99c42e62878e9737425ae0198630 100644 (file)
@@ -118,7 +118,7 @@ interface NodeHelper extends Helper, AddableCriteria {
        /**
         * "Getter for an array of an instance of a LocateableNode class
         *
-        * @return      $unlArray       An array of an instance of a LocateableNode class
+        * @return      $unlData        An array of an instance of a LocateableNode class
         */
        function getUniversalNodeLocatorArray ();
 
index b3e0ee1b1b6c5600e84c054edbcacd7a3c166d09..551e4a17742e59efc1b0231b55578708ebf99577 100644 (file)
@@ -60,7 +60,9 @@ class UniversalNodeLocatorDiscovery extends BaseNodeDiscovery implements Discove
 
                // Then resolve the node instance into an UNL instance
                $unlInstance = $resolverInstance->resolveUniversalNodeLocatorFromNodeHelper($nodeInstance);
-               die(__METHOD__ . ':unlInstance=' . print_r($unlInstance, TRUE));
+
+               // ... and return it
+               return $unlInstance;
        }
 
        /**
index 290fba128047360c05c1ee5d7a63fb90ffd86562..b355d51f00067bdc8b4782d8d9ec304a888bf9b2 100644 (file)
@@ -37,7 +37,6 @@ class PackageAnnouncementAnswerTagFilter extends BaseNodeFilter implements Filte
                        XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_INTERNAL_ADDRESS => '',
                        XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_NODE_STATUS      => '',
                        XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_SESSION_ID       => '',
-                       XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_LISTEN_PORT      => 9060,
                        BaseXmlAnswerTemplateEngine::ANSWER_STATUS                              => '',
                );
        }
index 5dac03418558aee63b8e9980059a740fd3dfd11f..e075372e49e01d292e11127d06420ebd3202938b 100644 (file)
@@ -37,8 +37,7 @@ class PackageAnnouncementTagFilter extends BaseNodeFilter implements FilterableP
                        XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_INTERNAL_ADDRESS => '',
                        XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_NODE_STATUS      => '',
                        XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_NODE_MODE        => '',
-                       XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_SESSION_ID       => '',
-                       XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_LISTEN_PORT      => 9060,
+                       XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_SESSION_ID       => ''
                );
        }
 
index 151137d30b56b1ed93359ef19d3492e7a54abc79..0a878f73071f85ffcdd9ccca6310c4ed71db60e0 100644 (file)
@@ -38,7 +38,6 @@ class PackageDhtBootstrapTagFilter extends BaseNodeFilter implements FilterableP
                        XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_NODE_STATUS      => '',
                        XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_NODE_MODE        => '',
                        XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_SESSION_ID       => '',
-                       XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_LISTEN_PORT      => 9060,
                );
        }
 
index 53775e3aed370523557aa0d1d346005c1bcf5888..e3e06646fe0638e5313586a1dfa2d35873f3b591 100644 (file)
@@ -35,7 +35,6 @@ class AnnouncementAnswerOkayHandler extends BaseAnserStatusHandler implements Ha
                $this->searchData = array(
                        XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_SESSION_ID,
                        XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_EXTERNAL_ADDRESS,
-                       XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_LISTEN_PORT
                );
 
                // Set handler name
index dc83f404a09b7175f48c99c5cb966fb32a33e8b9..3c20cb41fc10278003872c5c5f9facdc3133e40a 100644 (file)
@@ -41,7 +41,6 @@ class NodeMessageAnnouncementHandler extends BaseMessageHandler implements Handl
                        XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_NODE_STATUS,
                        XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_NODE_MODE,
                        XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_SESSION_ID,
-                       XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_LISTEN_PORT,
                );
 
                // Init message-data->configuration translation array
@@ -57,13 +56,11 @@ class NodeMessageAnnouncementHandler extends BaseMessageHandler implements Handl
                        XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_INTERNAL_ADDRESS => 'internal_address',
                        XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_NODE_STATUS      => 'node_status',
                        XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_SESSION_ID       => 'session_id',
-                       XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_LISTEN_PORT      => 'node_listen_port',
                );
 
                // Init array
                $this->searchData = array(
-                       XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_EXTERNAL_ADDRESS,
-                       XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_LISTEN_PORT
+                       XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_EXTERNAL_ADDRESS
                );
        }
 
index 02cafcdf62ba3208457ca8c95745ee7282d40199..3e97cfb93b3194b9006c36ec86fa70375ce0d715 100644 (file)
@@ -40,7 +40,6 @@ class NodeMessageAnnouncementAnswerHandler extends BaseMessageHandler implements
                        XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_INTERNAL_ADDRESS,
                        XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_NODE_STATUS,
                        XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_SESSION_ID,
-                       XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_LISTEN_PORT,
                        BaseXmlAnswerTemplateEngine::ANSWER_STATUS,
                );
 
@@ -59,14 +58,12 @@ class NodeMessageAnnouncementAnswerHandler extends BaseMessageHandler implements
                        XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_INTERNAL_ADDRESS => 'internal_address',
                        XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_NODE_STATUS      => 'node_status',
                        XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_SESSION_ID       => 'session_id',
-                       XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_LISTEN_PORT      => 'node_listen_port',
                );
 
                // Init array
                $this->searchData = array(
                        XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_SESSION_ID,
                        XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_EXTERNAL_ADDRESS,
-                       XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_LISTEN_PORT
                );
        }
 
index d981b685fc28667a5d7fd88a6dc2e6171ae62e67..4de6abb5941a0fa9d87818e9f968ad62ae10115a 100644 (file)
@@ -40,7 +40,6 @@ class NodeMessageDhtBootstrapAnswerHandler extends BaseMessageHandler implements
                        XmlDhtBootstrapAnswerTemplateEngine::DHT_BOOTSTRAP_DATA_INTERNAL_ADDRESS,
                        XmlDhtBootstrapAnswerTemplateEngine::DHT_BOOTSTRAP_DATA_NODE_STATUS,
                        XmlDhtBootstrapAnswerTemplateEngine::DHT_BOOTSTRAP_DATA_SESSION_ID,
-                       XmlDhtBootstrapAnswerTemplateEngine::DHT_BOOTSTRAP_DATA_LISTEN_PORT,
                        BaseXmlAnswerTemplateEngine::ANSWER_STATUS,
                );
 
@@ -59,14 +58,12 @@ class NodeMessageDhtBootstrapAnswerHandler extends BaseMessageHandler implements
                        XmlDhtBootstrapAnswerTemplateEngine::DHT_BOOTSTRAP_DATA_INTERNAL_ADDRESS => 'internal_address',
                        XmlDhtBootstrapAnswerTemplateEngine::DHT_BOOTSTRAP_DATA_NODE_STATUS      => 'node_status',
                        XmlDhtBootstrapAnswerTemplateEngine::DHT_BOOTSTRAP_DATA_SESSION_ID       => 'session_id',
-                       XmlDhtBootstrapAnswerTemplateEngine::DHT_BOOTSTRAP_DATA_LISTEN_PORT      => 'node_listen_port',
                );
 
                // Init array
                $this->searchData = array(
                        XmlDhtBootstrapAnswerTemplateEngine::DHT_BOOTSTRAP_DATA_SESSION_ID,
                        XmlDhtBootstrapAnswerTemplateEngine::DHT_BOOTSTRAP_DATA_EXTERNAL_ADDRESS,
-                       XmlDhtBootstrapAnswerTemplateEngine::DHT_BOOTSTRAP_DATA_LISTEN_PORT
                );
        }
 
index ee5ce6334c9149ab3c40b03cb0d4c12085dbe3a3..c793a6fb0377b0a12561d43c04885822495c783b 100644 (file)
@@ -41,7 +41,6 @@ class NodeMessageDhtBootstrapHandler extends BaseMessageHandler implements Handl
                        XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_NODE_STATUS,
                        XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_NODE_MODE,
                        XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_SESSION_ID,
-                       XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_LISTEN_PORT,
                );
 
                // Init message-data->configuration translation array
@@ -57,13 +56,11 @@ class NodeMessageDhtBootstrapHandler extends BaseMessageHandler implements Handl
                        XmlDhtBootstrapAnswerTemplateEngine::DHT_BOOTSTRAP_DATA_INTERNAL_ADDRESS => 'internal_address',
                        XmlDhtBootstrapAnswerTemplateEngine::DHT_BOOTSTRAP_DATA_NODE_STATUS      => 'node_status',
                        XmlDhtBootstrapAnswerTemplateEngine::DHT_BOOTSTRAP_DATA_SESSION_ID       => 'session_id',
-                       XmlDhtBootstrapAnswerTemplateEngine::DHT_BOOTSTRAP_DATA_LISTEN_PORT      => 'node_listen_port',
                );
 
                // Init array
                $this->searchData = array(
                        XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_EXTERNAL_ADDRESS,
-                       XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_LISTEN_PORT
                );
        }
 
index dc3eb68cd6f6ced39071a30aa21bdc8b98995ad5..ea4fb11d27c077344c3b447f7198fd0a29413c3b 100644 (file)
@@ -153,7 +153,7 @@ class BaseHubNode extends BaseHubSystem implements Updateable, AddableCriteria {
         */
        private function generateExternalUnl () {
                // Debug message
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NODE[' . __METHOD__ . ':' . __LINE__ . ']: CALLED!');
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NODE[' . __METHOD__ . ':' . __LINE__ . ']: CALLED!');
 
                // Is there cache? (This shortens a lot calls)
                if (!isset($GLOBALS[__METHOD__])) {
@@ -166,7 +166,7 @@ class BaseHubNode extends BaseHubSystem implements Updateable, AddableCriteria {
                } // END - if
 
                // Return it
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NODE[' . __METHOD__ . ':' . __LINE__ . ']: unl=' . $GLOBALS[__METHOD__] . ' - EXIT!');
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NODE[' . __METHOD__ . ':' . __LINE__ . ']: unl=' . $GLOBALS[__METHOD__] . ' - EXIT!');
                return $GLOBALS[__METHOD__];
        }
 
@@ -213,10 +213,6 @@ class BaseHubNode extends BaseHubSystem implements Updateable, AddableCriteria {
 
                // Run through all configured IPs
                foreach (explode(BaseHubSystem::BOOTSTRAP_NODES_SEPARATOR, $this->getConfigInstance()->getConfigEntry('hub_bootstrap_nodes')) as $unl) {
-                       // @TODO Unfinished
-                       die(__METHOD__ . ':' . print_r($this, TRUE));
-                       die(__METHOD__ . ': unl=' . $unl . ',remoteAddr=' . $remoteAddr);
-
                        // Does it match?
                        if ($unl == $remoteAddr) {
                                // Found it!
@@ -226,7 +222,7 @@ class BaseHubNode extends BaseHubSystem implements Updateable, AddableCriteria {
                                $this->bootUnl = $unl;
 
                                // Output message
-                               self::createDebugInstance(__CLASS__)->debugOutput('BOOTSTRAP: ' . __FUNCTION__ . '[' . __METHOD__ . ':' . __LINE__ . ']: IP matches remote address ' . $unl->__toString() . '.');
+                               self::createDebugInstance(__CLASS__)->debugOutput('BOOTSTRAP: ' . __FUNCTION__ . '[' . __METHOD__ . ':' . __LINE__ . ']: IP matches remote address ' . $unl . '.');
 
                                // Stop further searching
                                break;
@@ -241,7 +237,7 @@ class BaseHubNode extends BaseHubSystem implements Updateable, AddableCriteria {
                                $this->bootUnl = $unl;
 
                                // Output message
-                               self::createDebugInstance(__CLASS__)->debugOutput('BOOTSTRAP: ' . __FUNCTION__ . '[' . __METHOD__ . ':' . __LINE__ . ']: IP matches listen address ' . $unl->__toString() . '.');
+                               self::createDebugInstance(__CLASS__)->debugOutput('BOOTSTRAP: ' . __FUNCTION__ . '[' . __METHOD__ . ':' . __LINE__ . ']: IP matches listen address ' . $unl . '.');
 
                                // Stop further searching
                                break;
@@ -258,11 +254,23 @@ class BaseHubNode extends BaseHubSystem implements Updateable, AddableCriteria {
         * @return      $unl    Node's own universal node locator
         */
        public function detectOwnUniversalNodeLocator () {
-               // Get the UNL array back
-               $unlArray = $this->getUniversalNodeLocatorArray();
+               // Is "cache" set?
+               if (!isset($GLOBALS[__METHOD__])) {
+                       // Get the UNL array back
+                       $unlData = $this->getUniversalNodeLocatorArray();
+
+                       // There are 2 UNLs, internal and external.
+                       if ($this->getConfigInstance()->getConfigEntry('allow_publish_internal_address') == 'N') {
+                               // Public "external" UNL address
+                               $GLOBALS[__METHOD__] = $unlData[NodeInformationDatabaseWrapper::DB_COLUMN_EXTERNAL_UNL];
+                       } else {
+                               // Non-public "internal" UNL address
+                               $GLOBALS[__METHOD__] = $unlData[NodeInformationDatabaseWrapper::DB_COLUMN_INTERNAL_UNL];
+                       }
+               } // END - if
 
-               // @TODO
-               die(__METHOD__ . ':unlArray=' . print_r($unlArray, TRUE));
+               // Return it
+               return $GLOBALS[__METHOD__];
        }
 
        /**
@@ -756,7 +764,7 @@ class BaseHubNode extends BaseHubSystem implements Updateable, AddableCriteria {
         */
        public function determineUniversalNodeLocator () {
                // Debug message
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NODE[' . __METHOD__ . ':' . __LINE__ . ']: CALLED!');
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NODE[' . __METHOD__ . ':' . __LINE__ . ']: CALLED!');
 
                // Determine UNL based on this node:
                // 1) Get discovery class
@@ -766,28 +774,28 @@ class BaseHubNode extends BaseHubSystem implements Updateable, AddableCriteria {
                $unlInstance = $discoveryInstance->discoverUniversalNodeLocatorByNode($this);
 
                // 3) Return it
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NODE[' . __METHOD__ . ':' . __LINE__ . ']: unlInstance= ' . $unlInstance->__toString() . ' - EXIT!');
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NODE[' . __METHOD__ . ':' . __LINE__ . ']: unlInstance= ' . $unlInstance->__toString() . ' - EXIT!');
                return $unlInstance;
        }
 
        /**
         * "Getter" for an array of an instance of a LocateableNode class
         *
-        * @return      $unlArray       An array from an instance of a LocateableNode class for this node
+        * @return      $unlData        An array from an instance of a LocateableNode class for this node
         */
        public final function getUniversalNodeLocatorArray () {
                // Debug message
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NODE[' . __METHOD__ . ':' . __LINE__ . ']: CALLED!');
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NODE[' . __METHOD__ . ':' . __LINE__ . ']: CALLED!');
 
                // Get the Universal Node Locator (UNL) instance
                $unlInstance = $this->determineUniversalNodeLocator();
 
-               // @TODO Unfinished
-               die(__METHOD__ . ':unlInstance[' . gettype($unlInstance) . ']=' . print_r($unlInstance, TRUE));
+               // ... and the array from it
+               $unlData = $unlInstance->getUnlData();
 
                // Return it
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NODE[' . __METHOD__ . ':' . __LINE__ . ']: EXIT!');
-               return $unlArray;
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NODE[' . __METHOD__ . ':' . __LINE__ . ']: EXIT!');
+               return $unlData;
        }
 
        /**
index 22069fcb63be3392de1580b431eee10a68b5af19..c0bfd31861b8d0ee79324dd0627acd83edf22e38 100644 (file)
@@ -222,13 +222,13 @@ class DefaultPeerPool extends BasePool implements PoolablePeer {
 
                // Temporary resolve recipient field
                die(__METHOD__ . ': UNFINISHED!' . PHP_EOL);
-               $unlArray = explode(':', HubTools::resolveSessionId($packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT]));
+               $unlData = explode(':', HubTools::resolveSessionId($packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT]));
 
                // Make sure it is a valid Universal Node Locator array (3 elements)
-               assert(count($unlArray) == 3);
+               assert(count($unlData) == 3);
 
                // Debug message
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('POOL[' . __METHOD__ . ':' . __LINE__ . ']: Checking ' . count($this->getAllSockets()) . ' socket(s),unlArray[0]=' . $unlArray[0] . ',unlArray[1]=' . $unlArray[1] . ' ...');
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('POOL[' . __METHOD__ . ':' . __LINE__ . ']: Checking ' . count($this->getAllSockets()) . ' socket(s),unlData[0]=' . $unlData[0] . ',unlData[1]=' . $unlData[1] . ' ...');
 
                // Default is all sockets
                $sockets = $this->getAllSockets();
@@ -259,7 +259,7 @@ class DefaultPeerPool extends BasePool implements PoolablePeer {
 
                        // Get
                        // If the "peer" IP and recipient is same, use it
-                       if ($peerIp == $unlArray[0]) {
+                       if ($peerIp == $unlData[0]) {
                                // IPs match, so take the socket and quit this loop
                                $socketResource = $socketArray[self::SOCKET_ARRAY_RESOURCE];
 
index c6bfea60304c73271a449a458e86deba1fd04d6d..3ccba6b66418c007e44fbdb2292a02671fdd3b07 100644 (file)
@@ -76,10 +76,9 @@ class DhtRecipient extends BaseRecipient implements Recipient {
                        // @TODO Unfinished
                        die(__METHOD__ . ':recipient=' . print_r($recipient, TRUE));
                        assert(!empty($recipient[NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_EXTERNAL_ADDRESS]));
-                       assert(!empty($recipient[NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_LISTEN_PORT]));
 
                        // Put ip and port both together
-                       $unl = $recipient[NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_EXTERNAL_ADDRESS] . ':' . $recipient[NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_LISTEN_PORT];
+                       $unl = $recipient[NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_EXTERNAL_ADDRESS];
 
                        // Add it to the list
                        //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-RECIPIENT[' . __METHOD__ . ':' . __LINE__ . ']: Calling listInstance->addEntry(' . $unl . ') ...');
index 0ed776e902bd700c4c44c076e2f2bb2344211cb9..c93110cbe686c6c5cf9b59950b6a6a8a5ade762f 100644 (file)
@@ -68,10 +68,10 @@ class DirectRecipient extends BaseRecipient implements Recipient {
                // Try it on all
                foreach ($recipients as $recipient) {
                        // Try to sole a single recipient
-                       $unlArray = HubTools::resolveSessionId($recipient);
+                       $unlData = HubTools::resolveSessionId($recipient);
 
                        // Add it as recipient
-                       $listInstance->addEntry('unl', $unlArray);
+                       $listInstance->addEntry('unl', $unlData);
                } // END - foreach
        }
 }
index 33d45ffeab06fa4d066d00bbcf374f795159e9c1..d76fc7a258a209621562bf115ba71ae76df068f3 100644 (file)
@@ -61,7 +61,7 @@ class UpperRecipient extends BaseRecipient implements Recipient {
                assert($recipient == NetworkPackage::NETWORK_TARGET_UPPER);
 
                // Get all bootstrap nodes
-               foreach (explode(BaseHubSystem::BOOTSTRAP_NODES_SEPARATOR, $this->getConfigInstance()->getConfigEntry('hub_bootstrap_nodes')) as $unlArray) {
+               foreach (explode(BaseHubSystem::BOOTSTRAP_NODES_SEPARATOR, $this->getConfigInstance()->getConfigEntry('hub_bootstrap_nodes')) as $unlData) {
                        // Is maximum reached?
                        if ($listInstance->count() == $this->getConfigInstance()->getConfigEntry('package_recipient_max_count')) {
                                // Debug message
@@ -72,10 +72,10 @@ class UpperRecipient extends BaseRecipient implements Recipient {
                        } // END - if
 
                        // Debug message
-                       /* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('RECIPIENT-RESOLVER: Adding node ' . print_r($unlArray, TRUE) . ' as recipient.');
+                       /* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('RECIPIENT-RESOLVER: Adding node ' . print_r($unlData, TRUE) . ' as recipient.');
 
                        // Add the entry
-                       $listInstance->addEntry('unl', $unlArray);
+                       $listInstance->addEntry('unl', $unlData);
                } // END - foreach
        }
 }
index 8a3aae4bf4f5a01c33bba2dab2e088ff1124ca36..32f86bad3e4a230cc44a21d604801b0e2fbea414 100644 (file)
@@ -57,24 +57,32 @@ class TcpProtocolResolver extends BaseProtocolResolver implements ProtocolResolv
         * @todo        0% done
         */
        public function resolveUniversalNodeLocatorFromNodeHelper (NodeHelper $nodeInstance) {
-               // Get result instance
-               $resultInstance = $nodeInstance->getResultInstance();
+               // Get search instance (to lookup database result)
+               $searchInstance = $nodeInstance->getSearchInstance();
 
-               // Make sure the result instance is valid
-               assert($resultInstance instanceof SearchableResult);
+               // Make sure the in stance is valid
+               assert($searchInstance instanceof SearchCriteria);
 
-               // Rewind iterator
-               $resultInstance->rewind();
+               // Refetch and rewind iterator
+               $resultInstance = $nodeInstance->getWrapperInstance()->doSelectByCriteria($searchInstance);
 
-               // Lookup node's id
-               while ($resultInstance->next()) {
-                       // Get current entry
-                       $current = $resultInstance->current();
+               // 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
 
-                       // Do we have found an entry?
-                       // $nodeInstance->getNodeId()
-                       die(print_r($current, TRUE));
-               } // END - while
+               // Get current entry
+               $current = $resultInstance->current();
+
+               // This should always be the case, if not your database file might be damaged.
+               assert($nodeInstance->getNodeId() == $current[NodeInformationDatabaseWrapper::DB_COLUMN_NODE_ID]);
+
+               // Get UNL instance and handle over all data
+               $unlInstance = ObjectFactory::createObjectByConfiguredName('universal_node_locator_class', array($current));
+
+               // Return resolved instance
+               return $unlInstance;
        }
 
        /**
index e5701d43a4647ad9411f2023df4ab6358fa8f627..0da0cc86bd8335abcd6099c70b8606a1a30a1256 100644 (file)
@@ -31,7 +31,6 @@ class XmlAnnouncementTemplateEngine extends BaseXmlTemplateEngine implements Com
        const ANNOUNCEMENT_DATA_NODE_MODE        = 'node-mode';
        const ANNOUNCEMENT_DATA_EXTERNAL_ADDRESS = 'external-address';
        const ANNOUNCEMENT_DATA_INTERNAL_ADDRESS = 'internal-address';
-       const ANNOUNCEMENT_DATA_LISTEN_PORT      = 'listen-port';
 
        /**
         * Protected constructor
@@ -48,7 +47,6 @@ class XmlAnnouncementTemplateEngine extends BaseXmlTemplateEngine implements Com
                        'listener',
                        self::ANNOUNCEMENT_DATA_NODE_STATUS,
                        self::ANNOUNCEMENT_DATA_NODE_MODE,
-                       self::ANNOUNCEMENT_DATA_LISTEN_PORT,
                        self::ANNOUNCEMENT_DATA_SESSION_ID,
                        self::ANNOUNCEMENT_DATA_EXTERNAL_ADDRESS,
                        self::ANNOUNCEMENT_DATA_INTERNAL_ADDRESS,
@@ -161,16 +159,6 @@ class XmlAnnouncementTemplateEngine extends BaseXmlTemplateEngine implements Com
                $this->getStackInstance()->pushNamed('node_announcement', 'listener');
        }
 
-       /**
-        * Starts the TCP/UDP listen port
-        *
-        * @return      void
-        */
-       protected function startListenPort () {
-               // Push the node name on the stacker
-               $this->getStackInstance()->pushNamed('node_announcement', self::ANNOUNCEMENT_DATA_LISTEN_PORT);
-       }
-
        /**
         * Starts the session id
         *
@@ -271,16 +259,6 @@ class XmlAnnouncementTemplateEngine extends BaseXmlTemplateEngine implements Com
                $this->getStackInstance()->popNamed('node_announcement');
        }
 
-       /**
-        * Finishes the TCP/UDP listen port
-        *
-        * @return      void
-        */
-       protected function finishListenPort () {
-               // Pop the last entry
-               $this->getStackInstance()->popNamed('node_announcement');
-       }
-
        /**
         * Finishes the listener
         *
index 17a3bda18d39039de578bc3049d6c851050c1218..f70a05f554e587e0b46db912e86b5d4660845160 100644 (file)
@@ -30,7 +30,6 @@ class XmlAnnouncementAnswerTemplateEngine extends BaseXmlAnswerTemplateEngine im
        const ANNOUNCEMENT_DATA_NODE_STATUS      = 'my-status';
        const ANNOUNCEMENT_DATA_EXTERNAL_ADDRESS = 'my-external-address';
        const ANNOUNCEMENT_DATA_INTERNAL_ADDRESS = 'my-internal-address';
-       const ANNOUNCEMENT_DATA_LISTEN_PORT      = 'my-listen-port';
 
        /**
         * Protected constructor
@@ -49,7 +48,6 @@ class XmlAnnouncementAnswerTemplateEngine extends BaseXmlAnswerTemplateEngine im
                        // Data from *this* node
                        self::ANNOUNCEMENT_DATA_EXTERNAL_ADDRESS,
                        self::ANNOUNCEMENT_DATA_INTERNAL_ADDRESS,
-                       self::ANNOUNCEMENT_DATA_LISTEN_PORT,
                        self::ANNOUNCEMENT_DATA_NODE_STATUS,
                        self::ANNOUNCEMENT_DATA_SESSION_ID,
                        // Data from other node
@@ -157,16 +155,6 @@ class XmlAnnouncementAnswerTemplateEngine extends BaseXmlAnswerTemplateEngine im
                $this->getStackInstance()->pushNamed('node_announcement_answer', self::ANNOUNCEMENT_DATA_INTERNAL_ADDRESS);
        }
 
-       /**
-        * Starts the my-tcp-port
-        *
-        * @return      void
-        */
-       protected function startMyListenPort () {
-               // Push the node name on the stacker
-               $this->getStackInstance()->pushNamed('node_announcement_answer', self::ANNOUNCEMENT_DATA_LISTEN_PORT);
-       }
-
        /**
         * Starts the my-session-id
         *
@@ -207,16 +195,6 @@ class XmlAnnouncementAnswerTemplateEngine extends BaseXmlAnswerTemplateEngine im
                $this->getStackInstance()->popNamed('node_announcement_answer');
        }
 
-       /**
-        * Finishes the my-tcp-port
-        *
-        * @return      void
-        */
-       protected function finishMyListenPort () {
-               // Pop the last entry
-               $this->getStackInstance()->popNamed('node_announcement_answer');
-       }
-
        /**
         * Finishes the my-internal-address
         *
index f5e26d7a36f659560b1910d608b772389f599043..b9a94872bd1b4c887af6145bc5cafb1083b0d153 100644 (file)
@@ -30,7 +30,6 @@ class XmlDhtBootstrapAnswerTemplateEngine extends BaseXmlAnswerTemplateEngine im
        const DHT_BOOTSTRAP_DATA_NODE_STATUS      = 'my-status';
        const DHT_BOOTSTRAP_DATA_EXTERNAL_ADDRESS = 'my-external-address';
        const DHT_BOOTSTRAP_DATA_INTERNAL_ADDRESS = 'my-internal-address';
-       const DHT_BOOTSTRAP_DATA_LISTEN_PORT      = 'my-listen-port';
        const DHT_BOOTSTRAP_DATA_NODE_LIST        = 'dht-nodes-list';
 
        /**
@@ -50,7 +49,6 @@ class XmlDhtBootstrapAnswerTemplateEngine extends BaseXmlAnswerTemplateEngine im
                        // Data from *this* node
                        self::DHT_BOOTSTRAP_DATA_EXTERNAL_ADDRESS,
                        self::DHT_BOOTSTRAP_DATA_INTERNAL_ADDRESS,
-                       self::DHT_BOOTSTRAP_DATA_LISTEN_PORT,
                        self::DHT_BOOTSTRAP_DATA_NODE_STATUS,
                        self::DHT_BOOTSTRAP_DATA_SESSION_ID,
                        // Data from other node
@@ -160,16 +158,6 @@ class XmlDhtBootstrapAnswerTemplateEngine extends BaseXmlAnswerTemplateEngine im
                $this->getStackInstance()->pushNamed('node_dht_bootstrap_answer', self::DHT_BOOTSTRAP_DATA_INTERNAL_ADDRESS);
        }
 
-       /**
-        * Starts the my-tcp-port
-        *
-        * @return      void
-        */
-       protected function startMyListenPort () {
-               // Push the node name on the stacker
-               $this->getStackInstance()->pushNamed('node_dht_bootstrap_answer', self::DHT_BOOTSTRAP_DATA_LISTEN_PORT);
-       }
-
        /**
         * Starts the my-session-id
         *
@@ -230,16 +218,6 @@ class XmlDhtBootstrapAnswerTemplateEngine extends BaseXmlAnswerTemplateEngine im
                $this->getStackInstance()->popNamed('node_dht_bootstrap_answer');
        }
 
-       /**
-        * Finishes the my-tcp-port
-        *
-        * @return      void
-        */
-       protected function finishMyListenPort () {
-               // Pop the last entry
-               $this->getStackInstance()->popNamed('node_dht_bootstrap_answer');
-       }
-
        /**
         * Finishes the my-internal-address
         *
index 47e08cec0ed009140aceda7467a9d3dc230c0bc4..9b95cc37c5a7a32f9b559f91fe296a80e1b51f76 100644 (file)
@@ -32,7 +32,6 @@ class XmlDhtBootstrapTemplateEngine extends BaseXmlTemplateEngine implements Com
        const DHT_BOOTSTRAP_DATA_NODE_MODE        = 'node-mode';
        const DHT_BOOTSTRAP_DATA_EXTERNAL_ADDRESS = 'external-address';
        const DHT_BOOTSTRAP_DATA_INTERNAL_ADDRESS = 'internal-address';
-       const DHT_BOOTSTRAP_DATA_LISTEN_PORT      = 'listen-port';
 
        /**
         * Protected constructor
@@ -49,7 +48,6 @@ class XmlDhtBootstrapTemplateEngine extends BaseXmlTemplateEngine implements Com
                        'listener',
                        self::DHT_BOOTSTRAP_DATA_NODE_STATUS,
                        self::DHT_BOOTSTRAP_DATA_NODE_MODE,
-                       self::DHT_BOOTSTRAP_DATA_LISTEN_PORT,
                        self::DHT_BOOTSTRAP_DATA_SESSION_ID,
                        self::DHT_BOOTSTRAP_DATA_EXTERNAL_ADDRESS,
                        self::DHT_BOOTSTRAP_DATA_INTERNAL_ADDRESS
@@ -161,16 +159,6 @@ class XmlDhtBootstrapTemplateEngine extends BaseXmlTemplateEngine implements Com
                $this->getStackInstance()->pushNamed('dht_bootstrap', 'listener');
        }
 
-       /**
-        * Starts the TCP/UDP listen port
-        *
-        * @return      void
-        */
-       protected function startListenPort () {
-               // Push the node name on the stacker
-               $this->getStackInstance()->pushNamed('dht_bootstrap', self::DHT_BOOTSTRAP_DATA_LISTEN_PORT);
-       }
-
        /**
         * Starts the public ip
         *
@@ -231,16 +219,6 @@ class XmlDhtBootstrapTemplateEngine extends BaseXmlTemplateEngine implements Com
                $this->getStackInstance()->popNamed('dht_bootstrap');
        }
 
-       /**
-        * Finishes the TCP/UDP listen port
-        *
-        * @return      void
-        */
-       protected function finishListenPort () {
-               // Pop the last entry
-               $this->getStackInstance()->popNamed('dht_bootstrap');
-       }
-
        /**
         * Finishes the listener
         *
index 9cbd20c4efdc76f4a9ac74f9dcf17b31433afaa2..0360090adc68d16a5b382a426ede87f7bbde305d 100644 (file)
@@ -31,7 +31,6 @@ class XmlDhtPublishEntryTemplateEngine extends BaseXmlTemplateEngine implements
        const PUBLISH_DATA_NODE_STATUS           = 'node-status';
        const PUBLISH_DATA_NODE_MODE             = 'node-mode';
        const PUBLISH_DATA_EXTERNAL_ADDRESS      = 'external-address';
-       const PUBLISH_DATA_LISTEN_PORT           = 'listen-port';
        const PUBLISH_DATA_PRIVATE_KEY_HASH      = 'private-key-hash';
        const PUBLISH_DATA_ACCEPTED_OBJECT_TYPES = 'accepted-object-types';
 
@@ -50,7 +49,6 @@ class XmlDhtPublishEntryTemplateEngine extends BaseXmlTemplateEngine implements
                        'listener',
                        self::PUBLISH_DATA_NODE_STATUS,
                        self::PUBLISH_DATA_NODE_MODE,
-                       self::PUBLISH_DATA_LISTEN_PORT,
                        self::PUBLISH_DATA_PRIVATE_KEY_HASH,
                        self::PUBLISH_DATA_ACCEPTED_OBJECT_TYPES,
                        self::PUBLISH_DATA_NODE_ID,
@@ -165,16 +163,6 @@ class XmlDhtPublishEntryTemplateEngine extends BaseXmlTemplateEngine implements
                $this->getStackInstance()->pushNamed('dht_publish', 'listener');
        }
 
-       /**
-        * Starts the TCP/UDP listen port
-        *
-        * @return      void
-        */
-       protected function startListenPort () {
-               // Push the node name on the stacker
-               $this->getStackInstance()->pushNamed('dht_publish', self::PUBLISH_DATA_LISTEN_PORT);
-       }
-
        /**
         * Starts accepted object types
         *
@@ -295,16 +283,6 @@ class XmlDhtPublishEntryTemplateEngine extends BaseXmlTemplateEngine implements
                $this->getStackInstance()->popNamed('dht_publish');
        }
 
-       /**
-        * Finishes the TCP/UDP listen port
-        *
-        * @return      void
-        */
-       protected function finishListenPort () {
-               // Pop the last entry
-               $this->getStackInstance()->popNamed('dht_publish');
-       }
-
        /**
         * Finishes hash from private key
         *
index d550b64a05c176850f7b5e9be6cc5d27fb7dc5d6..1784578d413bbe0e1cad489eb1126472ef3b7121 100644 (file)
@@ -101,9 +101,9 @@ class HubTools extends BaseHubSystem {
                $recipient = $this->getDhtInstance()->findNodeLocalBySessionId($sessionId);
 
                // Is the recipient valid?
-               if ((isset($recipient[NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_EXTERNAL_ADDRESS])) && (isset($recipient[NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_LISTEN_PORT]))) {
+               if (isset($recipient[NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_EXTERNAL_ADDRESS])) {
                        // Then use this
-                       $recipientUniversalNodeLocator = $recipient[NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_EXTERNAL_ADDRESS] . ':' . $recipient[NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_LISTEN_PORT];
+                       $recipientUniversalNodeLocator = $recipient[NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_EXTERNAL_ADDRESS];
                } else {
                        // Get the instance, this might throw a NPE
                        $nodeInstance = NodeObjectFactory::createNodeInstance();
diff --git a/application/hub/main/unl/.htaccess b/application/hub/main/unl/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/application/hub/main/unl/class_UniversalNodeLocator.php b/application/hub/main/unl/class_UniversalNodeLocator.php
new file mode 100644 (file)
index 0000000..7f857a0
--- /dev/null
@@ -0,0 +1,98 @@
+<?php
+/**
+ * A UniversalNodeLocator
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.ship-simu.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
+ * 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 <http://www.gnu.org/licenses/>.
+ */
+class UniversalNodeLocator extends BaseFrameworkSystem implements LocateableNode {
+       /**
+        * UNL data array
+        */
+       private $unlData = array();
+
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+       }
+
+       /**
+        * Creates an instance of this class
+        *
+        * @param       $current                An array with "raw" data from the database layer for the UNL. This parameter is optional.
+        * @return      $unlInstance    An instance of a LocateableNode class
+        */
+       public final static function createUniversalNodeLocator (array $current = array()) {
+               // Get new instance
+               $unlInstance = new UniversalNodeLocator();
+
+               // Init instance
+               $unlInstance->initUniversalNodeLocator($current);
+
+               // Return the prepared instance
+               return $unlInstance;
+       }
+
+       /**
+        * Initializes the UNL instance by givena array. If an entry is found, it
+        * will be copied, otherwise the entry is set empty.
+        *
+        * @param       $current        An array with "raw" data from the database layer for the UNL. This parameter is optional.
+        * @return      void
+        */
+       private function initUniversalNodeLocator (array $current = array()) {
+               // Init UNL array
+               $this->unlData = array();
+
+               // Copy all found entries
+               foreach (array(
+                       NodeInformationDatabaseWrapper::DB_COLUMN_NODE_ID,
+                       NodeInformationDatabaseWrapper::DB_COLUMN_SESSION_ID,
+                       NodeInformationDatabaseWrapper::DB_COLUMN_PRIVATE_KEY_HASH,
+                       NodeInformationDatabaseWrapper::DB_COLUMN_NODE_MODE,
+                       NodeInformationDatabaseWrapper::DB_COLUMN_INTERNAL_UNL,
+                       NodeInformationDatabaseWrapper::DB_COLUMN_EXTERNAL_UNL) as $key) {
+                               // Init entry
+                               $this->unlData[$key] = NULL;
+
+                               // Is the key found?
+                               if (isset($current[$key])) {
+                                       // The copy the entry
+                                       $this->unlData[$key] = $current[$key];
+                               } // END - if
+               } // END - foreach
+       }
+
+       /**
+        * Getter for UNL data array
+        *
+        * @return      $unlData        An array with UNL data
+        */
+       public final function getUnlData () {
+               return $this->unlData;
+       }
+}
+
+// [EOF]
+?>
index 218e5163bb98bd27a16fe63b93c982a76ad02e5b..87d4232ea116d7f345fce91bbe3f2a54121b38e8 100644 (file)
@@ -34,7 +34,6 @@ class NodeDistributedHashTableDatabaseWrapper extends BaseDatabaseWrapper implem
        const DB_COLUMN_NODE_ID            = 'node_id';
        const DB_COLUMN_SESSION_ID         = 'session_id';
        const DB_COLUMN_EXTERNAL_ADDRESS   = 'external_address';
-       const DB_COLUMN_LISTEN_PORT        = 'listen_port';
        const DB_COLUMN_PRIVATE_KEY_HASH   = 'private_key_hash';
        const DB_COLUMN_NODE_MODE          = 'node_mode';
        const DB_COLUMN_ACCEPTED_OBJECTS   = 'accepted_object_types';
@@ -87,7 +86,6 @@ class NodeDistributedHashTableDatabaseWrapper extends BaseDatabaseWrapper implem
                        self::DB_COLUMN_NODE_ID,
                        self::DB_COLUMN_SESSION_ID,
                        self::DB_COLUMN_EXTERNAL_ADDRESS,
-                       self::DB_COLUMN_LISTEN_PORT,
                        self::DB_COLUMN_PRIVATE_KEY_HASH,
                        self::DB_COLUMN_NODE_MODE,
                        self::DB_COLUMN_ACCEPTED_OBJECTS,
@@ -149,7 +147,7 @@ class NodeDistributedHashTableDatabaseWrapper extends BaseDatabaseWrapper implem
                $dataSetInstance->setUniqueKey(self::DB_COLUMN_NODE_ID);
 
                // Get Universal Node Locator and "explode" it
-               $unl = $nodeInstance->getUniversalNodeLocatorArray();
+               $unlInstance = $nodeInstance->determineUniversalNodeLocator();
 
                // Make sure both is valid
                assert(($unl[0] !== 'invalid') && ($unl[1] !== 'invalid') && ($unl[2] !== 'invalid'));
@@ -162,8 +160,7 @@ class NodeDistributedHashTableDatabaseWrapper extends BaseDatabaseWrapper implem
 
                // Add public node data
                $dataSetInstance->addCriteria(self::DB_COLUMN_NODE_MODE       , $requestInstance->getRequestElement('mode'));
-               $dataSetInstance->addCriteria(self::DB_COLUMN_EXTERNAL_ADDRESS     , $unl[0]);
-               $dataSetInstance->addCriteria(self::DB_COLUMN_LISTEN_PORT     , $unl[1]);
+               $dataSetInstance->addCriteria(self::DB_COLUMN_EXTERNAL_ADDRESS, $unl[0]);
                $dataSetInstance->addCriteria(self::DB_COLUMN_NODE_ID         , $nodeInstance->getNodeId());
                $dataSetInstance->addCriteria(self::DB_COLUMN_SESSION_ID      , $nodeInstance->getSessionId());
                $dataSetInstance->addCriteria(self::DB_COLUMN_PRIVATE_KEY_HASH, $nodeInstance->getPrivateKeyHash());
@@ -191,19 +188,18 @@ class NodeDistributedHashTableDatabaseWrapper extends BaseDatabaseWrapper implem
                $nodeInstance = NodeObjectFactory::createNodeInstance();
 
                // Get Universal Node Locator and "explode" it
-               $unl = $nodeInstance->getUniversalNodeLocatorArray();
+               $unlData = $nodeInstance->getUniversalNodeLocatorArray();
 
                /*
                 * Make sure both is not 'invalid' which means that the resolver
                 * didn't work.
                 */
-               assert(($unl[0] !== 'invalid') && ($unl[1] !== 'invalid') && ($unl[2] !== 'invalid'));
+               die(__METHOD__ . ':unlData[' . gettype($unlData) . ']=' . print_r($unlData, TRUE) . PHP_EOL);
 
                // Add Universal Node Locator/node id as criteria
                $searchInstance->addCriteria(self::DB_COLUMN_EXTERNAL_ADDRESS, $unl[0]);
-               $searchInstance->addCriteria(self::DB_COLUMN_LISTEN_PORT, $unl[1]);
-               $searchInstance->addCriteria(self::DB_COLUMN_NODE_ID    , $nodeInstance->getNodeId());
-               $searchInstance->addCriteria(self::DB_COLUMN_SESSION_ID , $nodeInstance->getSessionId());
+               $searchInstance->addCriteria(self::DB_COLUMN_NODE_ID         , $nodeInstance->getNodeId());
+               $searchInstance->addCriteria(self::DB_COLUMN_SESSION_ID      , $nodeInstance->getSessionId());
                $searchInstance->setLimit(1);
 
                // Query database and get a result instance back
@@ -380,8 +376,7 @@ class NodeDistributedHashTableDatabaseWrapper extends BaseDatabaseWrapper implem
                        // Only look for these array elements ("keys")
                        array(
                                self::DB_COLUMN_NODE_ID          => TRUE,
-                               self::DB_COLUMN_EXTERNAL_ADDRESS => TRUE,
-                               self::DB_COLUMN_LISTEN_PORT      => TRUE,
+                               self::DB_COLUMN_EXTERNAL_ADDRESS => TRUE
                        )
                );
 
index 32b33e55595bd196a64748c4fc7db1b6a2dca208..b8c1dcb320017103e218149ec0f71223319a366c 100644 (file)
@@ -37,8 +37,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
                        <external-address>{?external_address?}</external-address>
                        <!-- Private internal address //-->
                        <internal-address>{?internal_address?}</internal-address>
-                       <!-- Listener ports for both connections //-->
-                       <listen-port>{?node_listen_port?}</listen-port>
                </listener>
        </announcement-data>
 </announcement>
index 456403fd48ffe9fc79811a0b047a16de7b899d19..ce2e18eee397c2a53b54899616e662d7fa0e5777 100644 (file)
@@ -36,10 +36,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
                //-->
                <my-internal-address>{?my_internal_address?}</my-internal-address>
                <!--
-               This node's TCP/UDP listen port
-               //-->
-               <my-listen-port>{?my_listen_port?}</my-listen-port>
-               <!--
                This node's session id
                //-->
                <my-session-id>{?my_session_id?}</my-session-id>
index 6b5f570244ce73c378663b300fd9a06ec0fb2b8a..d30993ad7ccff6bea71ad5529591acfbf4335952 100644 (file)
@@ -37,10 +37,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
                //-->
                <my-internal-address>{?my_internal_address?}</my-internal-address>
                <!--
-               This node's TCP/UDP listen port
-               //-->
-               <my-listen-port>{?my_listen_port?}</my-listen-port>
-               <!--
                This node's session id
                //-->
                <my-session-id>{?my_session_id?}</my-session-id>
index 06f9eab673da33a0b90c575489389c128e774db8..ba0a81ea1b1eb59289ffadc121208fd967303d41 100644 (file)
@@ -46,8 +46,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
                        <external-address>{?external_address?}</external-address>
                        <!-- Private internal address //-->
                        <internal-address>{?internal_address?}</internal-address>
-                       <!-- Listener ports for both connections //-->
-                       <listen-port>{?node_listen_port?}</listen-port>
                </listener>
        </dht-bootstrap-data>
 </dht-bootstrap>
index c6b8604ab3bd6c47289aa1142f5277a28de91e69..156f0d249f3f1e206d10c51c20f35c11035bd720 100644 (file)
@@ -63,8 +63,6 @@ Array
                <listener>
                        <!-- Public external address //-->
                        <external-address>{?external_address?}</external-address>
-                       <!-- Listener ports for both connections //-->
-                       <listen-port>{?listen_port?}</listen-port>
                </listener>
        </publish-data>
 </publish>
diff --git a/core b/core
index eea9aadff7619b2a5c25972f37b34a1b83d30891..7bb55d2b90d5a32710bc0bb220cff5720194a6eb 160000 (submodule)
--- a/core
+++ b/core
@@ -1 +1 @@
-Subproject commit eea9aadff7619b2a5c25972f37b34a1b83d30891
+Subproject commit 7bb55d2b90d5a32710bc0bb220cff5720194a6eb