]> git.mxchange.org Git - hub.git/commitdiff
Rewrites, some more methods:
authorRoland Häder <roland@mxchange.org>
Thu, 7 Feb 2013 21:36:13 +0000 (21:36 +0000)
committerRoland Häder <roland@mxchange.org>
Thu, 7 Feb 2013 21:36:13 +0000 (21:36 +0000)
- Added missing database "table" 'node_dht'
- Added methods for local node data handling
- There is now no more need for separate TCP/UDP ports

28 files changed:
.gitattributes
application/hub/config-local.php-dist
application/hub/config.php
application/hub/exceptions/announcement/class_AnnouncementNotAcceptedException.php
application/hub/exceptions/announcement/class_NoAnnouncementAttemptedException.php
application/hub/exceptions/node/class_NodeSessionIdVerficationException.php
application/hub/interfaces/helper/nodes/class_NodeHelper.php
application/hub/interfaces/wrapper/class_NodeDhtWrapper.php
application/hub/main/database/wrapper/node/class_NodeDistributedHashTableDatabaseWrapper.php
application/hub/main/database/wrapper/states/class_PeerStateLookupDatabaseWrapper.php
application/hub/main/dht/node/class_NodeDhtFacade.php
application/hub/main/discovery/package/class_PackageRecipientDiscovery.php
application/hub/main/filter/tags/answer/class_PackageAnnouncementAnswerTagFilter.php
application/hub/main/filter/tags/class_PackageAnnouncementTagFilter.php
application/hub/main/handler/answer-status/announcement/class_AnnouncementAnswerOkayHandler.php
application/hub/main/handler/message-types/anouncement/class_NodeMessageAnnouncementHandler.php
application/hub/main/handler/message-types/answer/class_NodeMessageAnnouncementAnswerHandler.php
application/hub/main/handler/message-types/class_
application/hub/main/handler/message-types/class_BaseMessageHandler.php
application/hub/main/handler/network/class_BaseRawDataHandler.php
application/hub/main/nodes/boot/class_HubBootNode.php
application/hub/main/nodes/class_BaseHubNode.php
application/hub/main/template/announcement/class_XmlAnnouncementTemplateEngine.php
application/hub/main/template/answer/announcement/class_XmlAnnouncementAnswerTemplateEngine.php
application/hub/main/tools/class_HubTools.php
application/hub/templates/xml/announcement/announcement.xml
application/hub/templates/xml/answer/announcement/announcement_answer.xml
db/node_dht/.htaccess [new file with mode: 0644]

index 39f3e3323a581d93d90bd669f25caeb054a89128..6f8d3d4a3c0e3cbbeae78e4f39e21f73adb13323 100644 (file)
@@ -712,6 +712,7 @@ db/cruncher_projects/.htaccess svneol=native#text/plain
 db/cruncher_units/.htaccess svneol=native#text/plain
 db/news/.htaccess -text svneol=unset#text/plain
 db/node_data/.htaccess -text svneol=unset#text/plain
+db/node_dht/.htaccess -text svneol=unset#text/plain
 db/node_states/.htaccess -text svneol=unset#text/plain
 db/peer_states/.htaccess -text svneol=unset#text/plain
 docs/AUTHORS.txt svneol=native#text/plain
index 7d63bc911861ab5a104cd2e02f73d4bb5821bc2b..2df73dfc0798e0d617634f68171e440218f73f65 100644 (file)
@@ -39,11 +39,8 @@ $cfg = FrameworkConfiguration::getSelfInstance();
 // CFG: NODE-LISTEN-ADDR
 $cfg->setConfigEntry('node_listen_addr', '0.0.0.0');
 
-// CFG: NODE-TCP-LISTEN-PORT
-$cfg->setConfigEntry('node_tcp_listen_port', 9060);
-
-// CFG: NODE-UDP-LISTEN-PORT
-$cfg->setConfigEntry('node_udp_listen_port', 9060);
+// CFG: NODE-LISTEN-PORT
+$cfg->setConfigEntry('node_listen_port', 9060);
 
 // CFG: NODE-DEFAULT-MODE (can be 'regular', 'list', 'master' or 'boot', default is 'regular')
 $cfg->setConfigEntry('node_default_mode', 'regular');
index 970c197d94715cb0ff45e618cbaa3504fe41a189..4063d372b44d945deedec469a569444a6ee1987f 100644 (file)
@@ -27,11 +27,8 @@ $cfg = FrameworkConfiguration::getSelfInstance();
 // CFG: NODE-LISTEN-ADDR
 $cfg->setConfigEntry('node_listen_addr', '0.0.0.0');
 
-// CFG: NODE-TCP-LISTEN-PORT
-$cfg->setConfigEntry('node_tcp_listen_port', 9060);
-
-// CFG: NODE-UDP-LISTEN-PORT
-$cfg->setConfigEntry('node_udp_listen_port', 9060);
+// CFG: NODE-LISTEN-PORT
+$cfg->setConfigEntry('node_listen_port', 9060);
 
 // CFG: NODE-DEFAULT-MODE (can be 'regular', 'list', 'master' or 'boot', default is 'regular')
 $cfg->setConfigEntry('node_default_mode', 'regular');
index 072f86ade0d2384c33694b599e05afba8cdb5f4c..1d32a57f0934894c24ce1dece933c77860674a82 100644 (file)
@@ -39,8 +39,7 @@ class AnnouncementNotAcceptedException extends FrameworkException {
                        $messageArray[2][XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_SESSION_ID],
                        $messageArray[2][XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_EXTERNAL_IP],
                        $messageArray[2][XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_INTERNAL_IP],
-                       $messageArray[2][XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_TCP_PORT],
-                       $messageArray[2][XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_UDP_PORT],
+                       $messageArray[2][XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_LISTEN_PORT],
                        $messageArray[2][XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_NODE_STATUS],
                        $messageArray[2][XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_NODE_MODE]
                );
index 6363de18f8d59ff84a483fd08c71cecda9e638d1..46d249cc84fde582dc534aee23923e220ec142d4 100644 (file)
@@ -39,8 +39,7 @@ class NoAnnouncementAttemptedException extends FrameworkException {
                        $messageArray[2][XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_SESSION_ID],
                        $messageArray[2][XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_EXTERNAL_IP],
                        $messageArray[2][XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_INTERNAL_IP],
-                       $messageArray[2][XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_TCP_PORT],
-                       $messageArray[2][XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_UDP_PORT],
+                       $messageArray[2][XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_LISTEN_PORT],
                        $messageArray[2][XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_NODE_STATUS]
                );
 
index 657fb8d56f356210072d99cbc33b98f52cd3b0aa..1593f605f2ebb1bb9ff263ae6c2db98cfac04815 100644 (file)
@@ -39,8 +39,7 @@ class NodeSessionIdVerficationException extends FrameworkException {
                        $messageArray[1][XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_SESSION_ID],
                        $messageArray[1][XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_EXTERNAL_IP],
                        $messageArray[1][XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_INTERNAL_IP],
-                       $messageArray[1][XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_TCP_PORT],
-                       $messageArray[1][XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_UDP_PORT],
+                       $messageArray[1][XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_LISTEN_PORT],
                        $messageArray[1][XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_NODE_STATUS]
                );
 
index eaaf5879cd74694e82d20424668a80c54958195a..eaf24ce945ad2dd0a9341a0ad9896784ace8bc3e 100644 (file)
@@ -111,10 +111,9 @@ interface NodeHelper extends Helper {
        /**
         * "Getter for address:port combination
         *
-        * @param       $handlerInstance        An instance of a Networkable class
-        * @return      $addressPort            A address:port combination for this node
+        * @return      $addressPort    A address:port combination for this node
         */
-       function getAddressPort (Networkable $handlerInstance);
+       function getAddressPort ();
 
        /**
         * Adds hub data elements to a given dataset instance
index 9ef9950f53a368057ba16ad94103f0e4c9e2479e..37a5b12972bb9c066fe17363067507c90ee806c2 100644 (file)
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
 interface NodeDhtWrapper extends DatabaseWrapper {
+       /**
+        * Checks whether the local (*this*) node is registered in the DHT by
+        * checking if the external ip/port is found.
+        *
+        * @return      $isRegistered   Whether *this* node is registered in the DHT
+        */
+       function isLocalNodeRegistered ();
+
+       /**
+        * Updates local (*this*) node data in DHT, this is but not limited to the
+        * session id, ip number (and/or hostname) and port number.
+        *
+        * @return      void
+        */
+       function updateLocalNode();
+
+       /**
+        * Registeres the local (*this*) node with its data in the DHT.
+        *
+        * @return      void
+        */
+       function registerLocalNode();
 }
 
 // [EOF]
index b9ea83a50407413b03b5f40e7e7537aa5c6cb3c6..1d7bc252ba3e49f339ddb8a2933b170cdf748c06 100644 (file)
@@ -25,6 +25,10 @@ class NodeDistributedHashTableDatabaseWrapper extends BaseDatabaseWrapper implem
        // Constants for database table names
        const DB_TABLE_NODE_DHT = 'node_dht';
 
+       // Constants for database column names
+       const DB_COLUMN_SESSION_ID = 'session_id';
+       const DB_COLUMN_IP_PORT    = 'ip_port';
+
        /**
         * Protected constructor
         *
@@ -50,6 +54,52 @@ class NodeDistributedHashTableDatabaseWrapper extends BaseDatabaseWrapper implem
                // Return the instance
                return $wrapperInstance;
        }
+
+       /**
+        * Checks whether the local (*this*) node is registered in the DHT by
+        * checking if the external ip/port is found.
+        *
+        * @return      $isRegistered   Whether *this* node is registered in the DHT
+        */
+       public function isLocalNodeRegistered () {
+               // Get node instance
+               $nodeInstance = Registry::getRegistry()->getInstance('node');
+
+               // Get a dataset instance
+               $searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class');
+
+               // Add ip:port as criteria
+               $searchInstance->addCriteria(self::DB_COLUMN_IP_PORT, $nodeInstance->getAddressPort());
+               $searchInstance->setLimit(1);
+
+               // Query database and get a result instance back
+               $resultInstance = $this->doSelectByCriteria($searchInstance);
+
+               // Is there an entry?
+               $isRegistered = $resultInstance->next();
+
+               // Return result
+               return $isRegistered;
+       }
+
+       /**
+        * Updates local (*this*) node data in DHT, this is but not limited to the
+        * session id, ip number (and/or hostname) and port number.
+        *
+        * @return      void
+        */
+       public function updateLocalNode () {
+               $this->partialStub('Not implemented yet.');
+       }
+
+       /**
+        * Registeres the local (*this*) node with its data in the DHT.
+        *
+        * @return      void
+        */
+       public function registerLocalNode () {
+               $this->partialStub('Not implemented yet.');
+       }
 }
 
 // [EOF]
index 42366edf9fa8af7ebb86e46cfc475186cc0c2eee..b8b70fb198c16582c83a2a108db75bb500677540 100644 (file)
@@ -92,9 +92,6 @@ class PeerStateLookupDatabaseWrapper extends BaseDatabaseWrapper implements Look
                // Debug message
                //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DATABASE-WRAPPER: ' . __FUNCTION__ . ' called with packageData()=' . count($packageData) . ' - ENTERED!');
 
-               // Is always new peer by default
-               $isNewPeer = true;
-
                // Is the package valid?
                if (!isset($packageData[NetworkPackage::PACKAGE_DATA_SENDER])) {
                        // Invalid package found, please report this
index 44efb9a1b92cc5971eb4ee50ddbfcc9a582dc66f..dd6d13a1c8a05c299109b3687fa898b92cc8d457 100644 (file)
@@ -52,13 +52,20 @@ class NodeDhtFacade extends BaseDht implements Distributable, Registerable {
        }
 
        /**
-        * Initializes the distributable hash table (DHT)
+        * Initializes the distributed hash table (DHT)
         *
         * @return      void
         * @todo        Please implement this method
         */
        public function initDht () {
-               $this->partialStub('Please implement this method.');
+               // Is the local node registered?
+               if ($this->getWrapperInstance()->isLocalNodeRegistered()) {
+                       // Then only update session id
+                       $this->getWrapperInstance()->updateLocalNode();
+               } else {
+                       // No, so register it
+                       $this->getWrapperInstance()->registerLocalNode();
+               }
        }
 }
 
index 896f5b4c6bcc50b5ab1b8ac3b5edcce440ac100f..6843d14b5a415ad5402ba64cb8449ff38b1fa78d 100644 (file)
@@ -85,7 +85,7 @@ class PackageRecipientDiscovery extends BaseHubDiscovery implements Discoverable
                        // The target 'self' is always the external IP address!
                        case NetworkPackage::NETWORK_TARGET_SELF:
                                // Determine own port
-                               $port = $this->getConfigInstance()->getConfigEntry('node_' . $this->determineProtocolByPackageData($packageData) . '_listen_port');
+                               $port = $this->getConfigInstance()->getConfigEntry('node_listen_port');
 
                                // Determine IP or 'external_ip' if set
                                $ip = HubTools::determineOwnExternalIp();
@@ -142,9 +142,9 @@ class PackageRecipientDiscovery extends BaseHubDiscovery implements Discoverable
                $recipient = explode(':', $decodedData[NetworkPackage::PACKAGE_DATA_RECIPIENT]);
 
                // Is the 'recipient' field same as this peer's IP?
-               if ((($recipient[0] == HubTools::determineOwnExternalIp()) && ($recipient[1] == $this->getConfigInstance()->getConfigEntry('node_tcp_listen_port'))) || ($recipient[0] == $this->getConfigInstance()->getServerAddress())) {
+               if ((($recipient[0] == HubTools::determineOwnExternalIp()) && ($recipient[1] == $this->getConfigInstance()->getConfigEntry('node_listen_port'))) || ($recipient[0] == $this->getConfigInstance()->getServerAddress())) {
                        /*
-                        * Is same as own external IP+TCP port or internal IP, don't do anything here so other
+                        * Is same as own external IP + TCP/UDP listen port or internal IP, don't do anything here so other
                         * classes found an empty recipient list for internal (own) handling
                         * of the original content.
                         */
index d8777510b081f185bcd810bbacb093146c8a595f..6dbe3868f607b5c1e2e9e84676d0f8786569f469 100644 (file)
@@ -37,8 +37,7 @@ class PackageAnnouncementAnswerTagFilter extends BaseNodeFilter implements Filte
                        XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_INTERNAL_IP   => '',
                        XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_NODE_STATUS   => '',
                        XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_SESSION_ID    => '',
-                       XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_TCP_PORT      => 9060,
-                       XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_UDP_PORT      => 9060,
+                       XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_LISTEN_PORT   => 9060,
                        BaseXmlAnswerTemplateEngine::ANSWER_STATUS                           => '',
                );
        }
index 3593f52368cfc768da7ae2214ad9ed0b70dc98e0..2a7b688fde975a928ee703b69c3ef66b3ef18a88 100644 (file)
@@ -38,8 +38,7 @@ class PackageAnnouncementTagFilter extends BaseNodeFilter implements FilterableP
                        XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_NODE_STATUS => '',
                        XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_NODE_MODE   => '',
                        XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_SESSION_ID  => '',
-                       XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_TCP_PORT    => 9060,
-                       XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_UDP_PORT    => 9060
+                       XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_LISTEN_PORT => 9060,
                );
        }
 
index 39e792ed2f5c190af77f3d270ffb3cca3d33bf22..1b1b12b830c87b50b0f4617acd6c9011b654c795 100644 (file)
@@ -68,7 +68,7 @@ class AnnouncementAnswerOkayHandler extends BaseAnserStatusHandler implements Ha
                // Lookup external session id/external IP/port
                $searchInstance->addCriteria('node_session_id' , $messageData[XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_SESSION_ID]);
                $searchInstance->addCriteria('node_external_ip', $messageData[XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_EXTERNAL_IP]);
-               $searchInstance->addCriteria('node_tcp_port'   , $messageData[XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_TCP_PORT]);
+               $searchInstance->addCriteria('node_listen_port', $messageData[XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_LISTEN_PORT]);
 
                // Only one entry is fine
                $searchInstance->setLimit(1);
index 357f9e372fac24ffad2df632cb1fa2f86ecab69d..cc48b0481d9552687fb46bf9589c9ee066a1be7d 100644 (file)
@@ -41,8 +41,7 @@ class NodeMessageAnnouncementHandler extends BaseMessageHandler implements Handl
                        XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_NODE_STATUS,
                        XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_NODE_MODE,
                        XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_SESSION_ID,
-                       XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_TCP_PORT,
-                       XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_UDP_PORT
+                       XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_LISTEN_PORT,
                );
 
                // Init message-data->configuration translation array
@@ -58,15 +57,14 @@ class NodeMessageAnnouncementHandler extends BaseMessageHandler implements Handl
                        XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_INTERNAL_IP => 'internal_ip',
                        XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_NODE_STATUS => 'node_status',
                        XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_SESSION_ID  => 'session_id',
-                       XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_TCP_PORT    => 'node_tcp_listen_port',
-                       XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_UDP_PORT    => 'node_udp_listen_port'
+                       XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_LISTEN_PORT => 'node_listen_port',
                );
 
                // Init array
                $this->searchData = array(
                        XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_SESSION_ID,
                        XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_EXTERNAL_IP,
-                       XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_TCP_PORT
+                       XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_LISTEN_PORT
                );
        }
 
index e34b51c1c77830b447144fcb873e3137cc8b6ff7..cd2db6bd297f4d7fd8484a1e5d9671d2bb3bd4e2 100644 (file)
@@ -40,8 +40,7 @@ class NodeMessageAnnouncementAnswerHandler extends BaseMessageHandler implements
                        XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_INTERNAL_IP,
                        XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_NODE_STATUS,
                        XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_SESSION_ID,
-                       XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_TCP_PORT,
-                       XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_UDP_PORT,
+                       XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_LISTEN_PORT,
                        BaseXmlAnswerTemplateEngine::ANSWER_STATUS,
                );
 
@@ -60,15 +59,14 @@ class NodeMessageAnnouncementAnswerHandler extends BaseMessageHandler implements
                        XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_INTERNAL_IP => 'internal_ip',
                        XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_NODE_STATUS => 'node_status',
                        XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_SESSION_ID  => 'session_id',
-                       XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_TCP_PORT    => 'node_tcp_listen_port',
-                       XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_UDP_PORT    => 'node_udp_listen_port'
+                       XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_LISTEN_PORT => 'node_listen_port',
                );
 
                // Init array
                $this->searchData = array(
                        XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_SESSION_ID,
                        XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_EXTERNAL_IP,
-                       XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_TCP_PORT
+                       XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_LISTEN_PORT
                );
        }
 
index a3a98b6ff480d9b51eb76af5f2adccbf3354c4c8..98b417ed7323730f2ec290ab1a031f1c2ebc5971 100644 (file)
@@ -39,8 +39,7 @@ class NodeMessage???Handler extends BaseMessageHandler implements HandleableMess
                        Xml???TemplateEngine::!!!_DATA_EXTERNAL_IP,
                        Xml???TemplateEngine::!!!_DATA_NODE_STATUS,
                        Xml???TemplateEngine::!!!_DATA_SESSION_ID,
-                       Xml???TemplateEngine::!!!_DATA_TCP_PORT,
-                       Xml???TemplateEngine::!!!_DATA_UDP_PORT
+                       Xml???TemplateEngine::!!!_DATA_LISTEN_PORT,
                );
        }
 
index 864c3d37fd6a3aca98476efd1eb4d50ff28741f4..8c347b407567c4fa9fffe54c45d7fa3a847eabcc 100644 (file)
@@ -59,7 +59,7 @@ abstract class BaseMessageHandler extends BaseDataHandler {
         *
         * - session-id  (for finding the node's record together with below data)
         * - external-ip (hostname or IP number)
-        * - tcp-port    (TCP port for inbound connections)
+        * - listen-port (TCP/UDP listen port for inbound connections)
         *
         * @param       $messageArray   An array with all minimum message data
         * @return      void
@@ -78,7 +78,7 @@ abstract class BaseMessageHandler extends BaseDataHandler {
                // Debug message
                /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('MESSAGE-HANDLER: messageData=' . print_r($messageData, true));
 
-               // Search for the node's session id and external IP/hostname + TCP port
+               // Search for the node's session id and external IP/hostname + TCP/UDP listen port
                foreach ($this->searchData as $key) {
                        // Debug message
                        /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('MESSAGE-HANDLER: messageData[' . $key . ']=' . $messageData[$key]);
index 96147ecb3afb5ff0a4bd652e38fb1085109cdb1b..57857bfcdacb6815fbfe7203b213f2df1fc9f7e2 100644 (file)
@@ -147,7 +147,7 @@ class BaseRawDataHandler extends BaseHandler {
         */
        protected function ifRecipientMatchesOwnAddress (array $packageData) {
                // Construct own address first
-               $ownAddress = Registry::getRegistry()->getInstance('node')->getAddressPort($this);
+               $ownAddress = Registry::getRegistry()->getInstance('node')->getAddressPort();
 
                // Does it match?
                $matches = ($ownAddress === $packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT]);
index ef05db54ac23e2889c1c9258530632d32c1b8515..166cdb263330794c0727267831961bdbf4bdd36b 100644 (file)
@@ -61,7 +61,7 @@ class HubBootNode extends BaseHubNode implements NodeHelper, Registerable {
                // Now check if the IP address matches one of the bootstrap nodes
                if ($this->ifAddressMatchesBootstrappingNodes($this->getConfigInstance()->detectServerAddress())) {
                        // Get our port from configuration
-                       $ourPort = $this->getConfigInstance()->getConfigEntry('node_tcp_listen_port');
+                       $ourPort = $this->getConfigInstance()->getConfigEntry('node_listen_port');
 
                        // Extract port
                        $bootPort = substr($this->getBootIpPort(), -strlen($ourPort), strlen($ourPort));
index 8f3d1864dae58a8d8f9031beadfe1a56ca9361d1..f5b854b27411351a6cbc0748c4123f5f592a10b0 100644 (file)
@@ -573,7 +573,7 @@ class BaseHubNode extends BaseHubSystem implements Updateable {
                 * All nodes can now use the same configuration entry because it can be
                 * customized in config-local.php.
                 */
-               $listenerInstance->setListenPortByConfiguration('node_tcp_listen_port');
+               $listenerInstance->setListenPortByConfiguration('node_listen_port');
 
                // Initialize the listener
                $listenerInstance->initListener();
@@ -600,7 +600,7 @@ class BaseHubNode extends BaseHubSystem implements Updateable {
                 * All nodes can now use the same configuration entry because it can be
                 * customized in config-local.php.
                 */
-               $listenerInstance->setListenPortByConfiguration('node_udp_listen_port');
+               $listenerInstance->setListenPortByConfiguration('node_listen_port');
 
                // Initialize the listener
                $listenerInstance->initListener();
@@ -723,15 +723,11 @@ class BaseHubNode extends BaseHubSystem implements Updateable {
        /**
         * "Getter" for address:port combination
         *
-        * @param       $handlerInstance        An instance of a Networkable class
-        * @return      $addressPort            A address:port combination for this node
+        * @return      $addressPort    A address:port combination for this node
         */
-       public final function getAddressPort (Networkable $handlerInstance) {
-               // Construct config entry
-               $configEntry = 'node_' . $handlerInstance->getHandlerName() . '_listen_port';
-
+       public final function getAddressPort () {
                // Get IP and port
-               $addressPort = $this->getConfigInstance()->detectServerAddress() . ':' . $this->getConfigInstance()->getConfigEntry($configEntry);
+               $addressPort = $this->getConfigInstance()->detectServerAddress() . ':' . $this->getConfigInstance()->getConfigEntry('node_listen_port');
 
                // Return it
                return $addressPort;
index e0fdbd70a990244bd43728fabf35f4836c09ee6c..684e6dafc8991caf75ec35f954ecbb7965be1508 100644 (file)
@@ -31,8 +31,7 @@ class XmlAnnouncementTemplateEngine extends BaseXmlTemplateEngine implements Com
        const ANNOUNCEMENT_DATA_NODE_MODE   = 'node-mode';
        const ANNOUNCEMENT_DATA_EXTERNAL_IP = 'external-ip';
        const ANNOUNCEMENT_DATA_INTERNAL_IP = 'internal-ip';
-       const ANNOUNCEMENT_DATA_TCP_PORT    = 'tcp-port';
-       const ANNOUNCEMENT_DATA_UDP_PORT    = 'udp-port';
+       const ANNOUNCEMENT_DATA_LISTEN_PORT = 'listen-port';
 
        /**
         * Protected constructor
@@ -49,8 +48,7 @@ class XmlAnnouncementTemplateEngine extends BaseXmlTemplateEngine implements Com
                        'listener',
                        self::ANNOUNCEMENT_DATA_NODE_STATUS,
                        self::ANNOUNCEMENT_DATA_NODE_MODE,
-                       self::ANNOUNCEMENT_DATA_TCP_PORT,
-                       self::ANNOUNCEMENT_DATA_UDP_PORT,
+                       self::ANNOUNCEMENT_DATA_LISTEN_PORT,
                        self::ANNOUNCEMENT_DATA_SESSION_ID,
                        self::ANNOUNCEMENT_DATA_EXTERNAL_IP,
                        self::ANNOUNCEMENT_DATA_INTERNAL_IP,
@@ -164,23 +162,13 @@ class XmlAnnouncementTemplateEngine extends BaseXmlTemplateEngine implements Com
        }
 
        /**
-        * Starts the TCP port
+        * Starts the TCP/UDP listen port
         *
         * @return      void
         */
-       protected function startTcpPort () {
+       protected function startListenPort () {
                // Push the node name on the stacker
-               $this->getStackerInstance()->pushNamed('node_announcement', self::ANNOUNCEMENT_DATA_TCP_PORT);
-       }
-
-       /**
-        * Starts the UDP port
-        *
-        * @return      void
-        */
-       protected function startUdpPort () {
-               // Push the node name on the stacker
-               $this->getStackerInstance()->pushNamed('node_announcement', self::ANNOUNCEMENT_DATA_UDP_PORT);
+               $this->getStackerInstance()->pushNamed('node_announcement', self::ANNOUNCEMENT_DATA_LISTEN_PORT);
        }
 
        /**
@@ -284,21 +272,11 @@ class XmlAnnouncementTemplateEngine extends BaseXmlTemplateEngine implements Com
        }
 
        /**
-        * Finishes the UDP port
-        *
-        * @return      void
-        */
-       protected function finishUdpPort () {
-               // Pop the last entry
-               $this->getStackerInstance()->popNamed('node_announcement');
-       }
-
-       /**
-        * Finishes the TCP port
+        * Finishes the TCP/UDP listen port
         *
         * @return      void
         */
-       protected function finishTcpPort () {
+       protected function finishListenPort () {
                // Pop the last entry
                $this->getStackerInstance()->popNamed('node_announcement');
        }
index 5245f5a329068f3b69a168b034fbf687e7123af5..17feefd456b20ee14dad667ee2f53b4857260e0b 100644 (file)
@@ -30,8 +30,7 @@ class XmlAnnouncementAnswerTemplateEngine extends BaseXmlAnswerTemplateEngine im
        const ANNOUNCEMENT_DATA_NODE_STATUS   = 'my-status';
        const ANNOUNCEMENT_DATA_EXTERNAL_IP   = 'my-external-ip';
        const ANNOUNCEMENT_DATA_INTERNAL_IP   = 'my-internal-ip';
-       const ANNOUNCEMENT_DATA_TCP_PORT      = 'my-tcp-port';
-       const ANNOUNCEMENT_DATA_UDP_PORT      = 'my-udp-port';
+       const ANNOUNCEMENT_DATA_LISTEN_PORT      = 'my-listen-port';
 
        /**
         * Protected constructor
@@ -50,8 +49,7 @@ class XmlAnnouncementAnswerTemplateEngine extends BaseXmlAnswerTemplateEngine im
                        // Data from *this* node
                        self::ANNOUNCEMENT_DATA_EXTERNAL_IP,
                        self::ANNOUNCEMENT_DATA_INTERNAL_IP,
-                       self::ANNOUNCEMENT_DATA_TCP_PORT,
-                       self::ANNOUNCEMENT_DATA_UDP_PORT,
+                       self::ANNOUNCEMENT_DATA_LISTEN_PORT,
                        self::ANNOUNCEMENT_DATA_NODE_STATUS,
                        self::ANNOUNCEMENT_DATA_SESSION_ID,
                        // Data from other node
@@ -164,19 +162,9 @@ class XmlAnnouncementAnswerTemplateEngine extends BaseXmlAnswerTemplateEngine im
         *
         * @return      void
         */
-       protected function startMyTcpPort () {
+       protected function startMyListenPort () {
                // Push the node name on the stacker
-               $this->getStackerInstance()->pushNamed('node_announcement_answer', self::ANNOUNCEMENT_DATA_TCP_PORT);
-       }
-
-       /**
-        * Starts the my-udp-port
-        *
-        * @return      void
-        */
-       protected function startMyUdpPort () {
-               // Push the node name on the stacker
-               $this->getStackerInstance()->pushNamed('node_announcement_answer', self::ANNOUNCEMENT_DATA_UDP_PORT);
+               $this->getStackerInstance()->pushNamed('node_announcement_answer', self::ANNOUNCEMENT_DATA_LISTEN_PORT);
        }
 
        /**
@@ -219,22 +207,12 @@ class XmlAnnouncementAnswerTemplateEngine extends BaseXmlAnswerTemplateEngine im
                $this->getStackerInstance()->popNamed('node_announcement_answer');
        }
 
-       /**
-        * Finishes the my-udp-port
-        *
-        * @return      void
-        */
-       protected function finishMyUdpPort () {
-               // Pop the last entry
-               $this->getStackerInstance()->popNamed('node_announcement_answer');
-       }
-
        /**
         * Finishes the my-tcp-port
         *
         * @return      void
         */
-       protected function finishMyTcpPort () {
+       protected function finishMyListenPort () {
                // Pop the last entry
                $this->getStackerInstance()->popNamed('node_announcement_answer');
        }
index ad25728bbe3e6c427428a07fa36af7b47229eb52..e69c4f7dcde1beacc24676c31e68dbbde5323015 100644 (file)
@@ -103,7 +103,7 @@ class HubTools extends BaseHubSystem {
                        // Is the session id the same?
                        if ($nodeInstance->getSessionId() == $sessionId) {
                                // Then get the ip:port from it, assume TCP by default
-                               $recipient = self::determineOwnExternalIp() . ':' . $nodeInstance->getConfigInstance()->getConfigEntry('node_' . strtolower($protocol) . '_listen_port');
+                               $recipient = self::determineOwnExternalIp() . ':' . $nodeInstance->getConfigInstance()->getConfigEntry('node_listen_port');
                        } // END - if
                } // END - if
 
index 542e60a48acd62814609dd98341d2babcc680880..0243619748b0beaee261d09c912ff3b31af4ba92 100644 (file)
@@ -38,8 +38,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
                        <!-- Private internal IP address //-->
                        <internal-ip>{?internal_ip?}</internal-ip>
                        <!-- Listener ports for both connections //-->
-                       <tcp-port>{?node_tcp_listen_port?}</tcp-port>
-                       <udp-port>{?node_udp_listen_port?}</udp-port>
+                       <listen-port>{?node_listen_port?}</listen-port>
                </listener>
        </announcement-data>
 </announcement>
index 706869311eff01ad9d89a816a60ee1c4407efab7..cf57528d62e83115d0990467a4f0f4dee371aaf4 100644 (file)
@@ -36,13 +36,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
                //-->
                <my-internal-ip>{?my_internal_ip?}</my-internal-ip>
                <!--
-               This node's TCP port
+               This node's TCP/UDP listen port
                //-->
-               <my-tcp-port>{?my_tcp_port?}</my-tcp-port>
-               <!--
-               This node's UDP port
-               //-->
-               <my-udp-port>{?my_udp_port?}</my-udp-port>
+               <my-listen-port>{?my_listen_port?}</my-listen-port>
                <!--
                This node's session id
                //-->
diff --git a/db/node_dht/.htaccess b/db/node_dht/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all