From cc14e80697952f838137707073547160bf2b7c36 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Sun, 17 Feb 2013 22:40:05 +0000 Subject: [PATCH] Added missing XML, config entries for DHT bootstrap --- .gitattributes | 3 + application/hub/config.php | 20 +- .../interfaces/package/class_Deliverable.php | 4 +- .../main/connectors/class_BaseConnector.php | 37 +- application/hub/main/connectors/query/class_ | 93 +---- .../query/class_BaseQueryConnector.php | 37 +- .../query/local/class_LocalQueryConnector.php | 139 +------- application/hub/main/connectors/queues/class_ | 60 +--- .../queues/class_BaseQueueConnector.php | 37 +- .../local/class_LocalQueueConnector.php | 107 +----- .../class_PackageRecipientDiscovery.php | 14 +- .../main/helper/class_BaseHubSystemHelper.php | 2 +- .../hub/main/package/class_NetworkPackage.php | 4 +- .../class_XmlBootstrapTemplateEngine.php | 335 +---------------- .../class_XmlDhtBootstrapTemplateEngine.php | 336 ++++++++++++++++++ .../hub/templates/xml/dht_bootstrap/.htaccess | 1 + .../templates/xml/dht_bootstrap/bootstrap.xml | 25 ++ 17 files changed, 399 insertions(+), 855 deletions(-) create mode 100644 application/hub/main/template/bootstrap/class_XmlDhtBootstrapTemplateEngine.php create mode 100644 application/hub/templates/xml/dht_bootstrap/.htaccess create mode 100644 application/hub/templates/xml/dht_bootstrap/bootstrap.xml diff --git a/.gitattributes b/.gitattributes index 535e7c302..c3652a7fd 100644 --- a/.gitattributes +++ b/.gitattributes @@ -690,6 +690,7 @@ application/hub/main/template/answer/announcement/.htaccess -text svneol=unset#t application/hub/main/template/answer/requests/.htaccess -text svneol=unset#text/plain application/hub/main/template/bootstrap/.htaccess -text svneol=unset#text/plain application/hub/main/template/bootstrap/class_XmlBootstrapTemplateEngine.php svneol=native#text/plain +application/hub/main/template/bootstrap/class_XmlDhtBootstrapTemplateEngine.php svneol=native#text/plain application/hub/main/template/connect/.htaccess -text svneol=unset#text/plain application/hub/main/template/connect/class_XmlSelfConnectTemplateEngine.php svneol=native#text/plain application/hub/main/template/entries/.htaccess -text svneol=unset#text/plain @@ -734,6 +735,8 @@ application/hub/templates/xml/cruncher/.htaccess svneol=native#text/plain application/hub/templates/xml/cruncher/producer/.htaccess svneol=native#text/plain application/hub/templates/xml/cruncher/producer/test_unit.xml svneol=native#text/plain application/hub/templates/xml/cruncher/producer/work_unit.xml svneol=native#text/plain +application/hub/templates/xml/dht_bootstrap/.htaccess -text svneol=unset#text/plain +application/hub/templates/xml/dht_bootstrap/bootstrap.xml svneol=native#text/plain application/hub/templates/xml/entries/.htaccess -text svneol=unset#text/plain application/hub/templates/xml/node/.htaccess -text svneol=unset#text/plain application/hub/templates/xml/node/node_status.xml svneol=native#text/plain diff --git a/application/hub/config.php b/application/hub/config.php index 4c8e70e35..6f88c4439 100644 --- a/application/hub/config.php +++ b/application/hub/config.php @@ -57,12 +57,6 @@ $cfg->setConfigEntry('peer_state_lookup_db_wrapper_class', 'PeerStateLookupDatab // CFG: WEB-CONTENT-TYPE $cfg->setConfigEntry('web_content_type', ''); -// CFG: QUERY-CONNECTOR-CLASS -$cfg->setConfigEntry('query_connector_class', 'LocalQueryConnector'); - -// CFG: QUEUE-CONNECTOR-CLASS -$cfg->setConfigEntry('queue_connector_class', 'LocalQueueConnector'); - // CFG: LISTENER-POOL-CLAS $cfg->setConfigEntry('listener_pool_class', 'DefaultListenerPool'); @@ -253,11 +247,14 @@ $cfg->setConfigEntry('node_request_node_list_answer_template_class', 'XmlRequest $cfg->setConfigEntry('node_request_node_list_entries_template_class', 'XmlRequestNodeListEntryTemplateEngine'); // CFG: DHT-BOOTSTRAP-TEMPLATE-CLASS -$cfg->setConfigEntry('dht_bootstrap_template_class', 'XmlBootstrapTemplateEngine'); +$cfg->setConfigEntry('dht_bootstrap_template_class', 'XmlDhtBootstrapTemplateEngine'); // CFG: NODE-MESSAGE-TEMPLATE-EXTENSION $cfg->setConfigEntry('node_message_template_extension', '.xml'); +// CFG: DHT-MESSAGE-TEMPLATE-EXTENSION +$cfg->setConfigEntry('dht_message_template_extension', '.xml'); + // CFG: NODE-ANNOUNCEMENT-ANSWER-TEMPLATE-EXTENSION $cfg->setConfigEntry('node_announcement_answer_template_extension', '.xml'); @@ -312,6 +309,9 @@ $cfg->setConfigEntry('node_object_registry_stacker_class', 'FiLoStacker'); // CFG: NODE-OBJECT-TYPE-REGISTRY-CLASS $cfg->setConfigEntry('node_object_type_registry_class', 'ObjectTypeRegistry'); +// CFG: DHT-BOOTSTRAP-TEMPLATE-TYPE +$cfg->setConfigEntry('dht_bootstrap_template_type', 'xml/dht_bootstrap'); + // CFG: CODE-TEMPLATE-TYPE $cfg->setConfigEntry('code_template_type', 'xml'); @@ -327,6 +327,9 @@ $cfg->setConfigEntry('node_raw_data_stacker_class', 'FiFoStacker'); // CFG: CHUNK-HANDLER-STACKER-CLASS $cfg->setConfigEntry('chunk_handler_stacker_class', 'FiFoStacker'); +// CFG: DHT-BOOTSTRAP-STACKER-CLASS +$cfg->setConfigEntry('dht_bootstrap_stacker_class', 'FiFoStacker'); + // CFG: PRODUCER-OUTGOING-QUEUE $cfg->setConfigEntry('producer_outgoing_queue', 'FiFoStacker'); @@ -408,6 +411,9 @@ $cfg->setConfigEntry('stacker_chunk_raw_data_max_size', 100); // CFG: STACKER-DECODED-PACKAGE-MAX-SIZE $cfg->setConfigEntry('stacker_decoded_package_max_size', 100); +// CFG: STACKER-DHT-BOOTSTRAP-MAX-SIZE +$cfg->setConfigEntry('stacker_dht_bootstrap_max_size', 10); + // CFG: NEWS-MAIN-LIMIT $cfg->setConfigEntry('news_main_limit', 5); diff --git a/application/hub/interfaces/package/class_Deliverable.php b/application/hub/interfaces/package/class_Deliverable.php index bf854dc06..17f148c4b 100644 --- a/application/hub/interfaces/package/class_Deliverable.php +++ b/application/hub/interfaces/package/class_Deliverable.php @@ -27,11 +27,11 @@ interface Deliverable extends FrameworkInterface { * from given helper's template instance and pushing it on the 'undeclared' * stack. * - * @param $helperInstance An instance of a HelpableNode class + * @param $helperInstance An instance of a Helper class * @param $protocol Name of used protocol (TCP/UDP) * @return void */ - function enqueueRawDataFromTemplate (HelpableNode $helperInstance, $protocol); + function enqueueRawDataFromTemplate (Helper $helperInstance, $protocol); /** * Checks whether a package has been enqueued for delivery. diff --git a/application/hub/main/connectors/class_BaseConnector.php b/application/hub/main/connectors/class_BaseConnector.php index f29462163..f551ef47b 100644 --- a/application/hub/main/connectors/class_BaseConnector.php +++ b/application/hub/main/connectors/class_BaseConnector.php @@ -1,38 +1,3 @@ - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 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 . - */ -class BaseConnector extends BaseHubSystem { - /** - * Protected constructor - * - * @param $className Name of the class - * @return void - */ - protected function __construct ($className) { - // Call parent constructor - parent::__construct($className); - } -} - -// [EOF] +// @DEPRECATED ?> diff --git a/application/hub/main/connectors/query/class_ b/application/hub/main/connectors/query/class_ index 720a18d62..f551ef47b 100644 --- a/application/hub/main/connectors/query/class_ +++ b/application/hub/main/connectors/query/class_ @@ -1,94 +1,3 @@ - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * @todo Find an interface for: handleAllQueries() - * - * 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 . - */ -class ???QueryConnector extends BaseQueryConnector implements Connectable, Visitable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this query connector class - * - * @param $nodeInstance An instance of a node - * @return $connectorInstance An instance of this query connector class - */ - public final static function create???QueryConnector (NodeHelper $nodeInstance) { - // Create the instance - $connectorInstance = new ???QueryConnector(); - - // Set the node instance - $connectorInstance->setNodeInstance($nodeInstance); - - // Get a list instance - $listInstance = ObjectFactory::createObjectByConfiguredName('!!!_query_list_class'); - - // Set it in the connector - $connectorInstance->setListInstance($listInstance); - - // Finally return the connector - return $connectorInstance; - } - - /** - * Accepts the visitor to process the visit "request" - * - * @param $visitorInstance An instance of a Visitor class - * @return void - */ - public function accept (Visitor $visitorInstance) { - // Visit the query connector - $visitorInstance->visitQuery($this); - } - - /** - * Handles all unsent queries and should be called from a visitor - * - * @return void - * @todo 0% done - */ - public function handleAllQueries () { - $this->partialStub('Please implement this method.'); - } - - /** - * Processes all pending queries. This method should be called by the - * ActiveTaskVisitor class and should use an iterator on all pending - * queries. - * - * @return void - * @todo 0% done - */ - public function processAllPendingQueries () { - $this->partialStub('Please implement this method.'); - } -} - -// [EOF] +// @DEPRECATED ?> diff --git a/application/hub/main/connectors/query/class_BaseQueryConnector.php b/application/hub/main/connectors/query/class_BaseQueryConnector.php index 23f74daa2..f551ef47b 100644 --- a/application/hub/main/connectors/query/class_BaseQueryConnector.php +++ b/application/hub/main/connectors/query/class_BaseQueryConnector.php @@ -1,38 +1,3 @@ - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 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 . - */ -class BaseQueryConnector extends BaseConnector { - /** - * Protected constructor - * - * @param $className Name of the class - * @return void - */ - protected function __construct ($className) { - // Call parent constructor - parent::__construct($className); - } -} - -// [EOF] +// @DEPRECATED ?> diff --git a/application/hub/main/connectors/query/local/class_LocalQueryConnector.php b/application/hub/main/connectors/query/local/class_LocalQueryConnector.php index 42121451e..f551ef47b 100644 --- a/application/hub/main/connectors/query/local/class_LocalQueryConnector.php +++ b/application/hub/main/connectors/query/local/class_LocalQueryConnector.php @@ -1,140 +1,3 @@ - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * @todo Find an interface for: handleAllQueries() - * - * 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 . - */ -class LocalQueryConnector extends BaseQueryConnector implements Connectable, Visitable { - /** - * The query class instance - */ - private $queryInstance = NULL; - - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Init query instance - $this->queryInstance = ObjectFactory::createObjectByConfiguredName('local_query_class'); - } - - /** - * Creates an instance of this query connector class - * - * @param $nodeInstance An instance of a node - * @return $connectorInstance An instance of this query connector class - */ - public static final function createLocalQueryConnector (NodeHelper $nodeInstance) { - // Create the instance - $connectorInstance = new LocalQueryConnector(); - - // Set the node instance - $connectorInstance->setNodeInstance($nodeInstance); - - // Get a list instance - $listInstance = ObjectFactory::createObjectByConfiguredName('local_query_list_class'); - - // Set it in the connector - $connectorInstance->setListInstance($listInstance); - - // Prepare iterator instance - $iteratorInstance = $listInstance->getListIterator(); - - // Set it, too - $connectorInstance->setIteratorInstance($iteratorInstance); - - // Finally return the connector - return $connectorInstance; - } - - /** - * Handles the in the list avaiable query (current) and hands it over to the - * query processor instance - * - * @return void - * @TODO 0% done: Unfinished work here - */ - private function handleCurrentQuery () { - // Is there a query available? - if (!$this->getIteratorInstance()->valid()) { - // Simply abort here - return; - } // END - if - - // Get the current query - $currentQuery = $this->getIteratorInstance()->current(); - - // Only while construction, else it would output to much! - /* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONNECTOR: Handling query ' . $currentQuery); - } - - /** - * Accepts the visitor to process the visit "request" - * - * @param $visitorInstance An instance of a Visitor class - * @return void - */ - public function accept (Visitor $visitorInstance) { - // Visit the query connector - $visitorInstance->visitQueryConnector($this); - - // Visit the query as well - $this->queryInstance->accept($visitorInstance); - } - - /** - * Handles all pending queries. This method should be called by the - * ActiveTaskVisitor class and should use an iterator on all pending - * queries. - * - * @return void - */ - public function handlePending () { - // Should we rewind? - if (!$this->getIteratorInstance()->valid()) { - // Rewind to the beginning for next loop - $this->getIteratorInstance()->rewind(); - - // Still not valid? - if ($this->getIteratorInstance()->valid()) { - /* - * Then silently abort here because the queue is empty and to - * save some calls. - */ - return; - } // END - if - } // END - if - - // Try to execute the task - $this->handleCurrentQuery(); - - // Go to next entry - $this->getIteratorInstance()->next(); - } -} - -// [EOF] +// @DEPRECATED ?> diff --git a/application/hub/main/connectors/queues/class_ b/application/hub/main/connectors/queues/class_ index faf079b1a..f551ef47b 100644 --- a/application/hub/main/connectors/queues/class_ +++ b/application/hub/main/connectors/queues/class_ @@ -1,61 +1,3 @@ - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 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 . - */ -class ???QueueConnector extends BaseQueueConnector implements Connectable, Queueable, Visitable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this queue connector class - * - * @return $connectorInstance An instance of this queue connector class - */ - public final static function create???QueueConnector () { - // Create the instance - $connectorInstance = new ???QueueConnector(); - - // Finally return it - return $connectorInstance; - } - - /** - * Accepts the visitor to process the visit "request" - * - * @param $visitorInstance An instance of a Visitor class - * @return void - */ - public function accept (Visitor $visitorInstance) { - // Visit the query connector - $visitorInstance->visitQueue($this); - } -} - -// [EOF] +// @DEPRECATED ?> diff --git a/application/hub/main/connectors/queues/class_BaseQueueConnector.php b/application/hub/main/connectors/queues/class_BaseQueueConnector.php index 6e70c8618..f551ef47b 100644 --- a/application/hub/main/connectors/queues/class_BaseQueueConnector.php +++ b/application/hub/main/connectors/queues/class_BaseQueueConnector.php @@ -1,38 +1,3 @@ - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 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 . - */ -class BaseQueueConnector extends BaseConnector { - /** - * Protected constructor - * - * @param $className Name of the class - * @return void - */ - protected function __construct ($className) { - // Call parent constructor - parent::__construct($className); - } -} - -// [EOF] +// @DEPRECATED ?> diff --git a/application/hub/main/connectors/queues/local/class_LocalQueueConnector.php b/application/hub/main/connectors/queues/local/class_LocalQueueConnector.php index 6398afa34..f551ef47b 100644 --- a/application/hub/main/connectors/queues/local/class_LocalQueueConnector.php +++ b/application/hub/main/connectors/queues/local/class_LocalQueueConnector.php @@ -1,108 +1,3 @@ - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 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 . - */ -class LocalQueueConnector extends BaseQueueConnector implements Connectable, Queueable, Visitable { - /** - * Protected constructor - * - * @param $className Name of the class - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this queue connector class - * - * @param $nodeInstance An instance of a hub node - * @return $connectorInstance An instance of this queue connector class - */ - public static final function createLocalQueueConnector (NodeHelper $nodeInstance) { - // Create the instance - $connectorInstance = new LocalQueueConnector(); - - // Set the node instance - $connectorInstance->setNodeInstance($nodeInstance); - - // Finally return it - return $connectorInstance; - } - - /** - * Handles the in the list avaiable queues (current) and hands it over to the - * queues processor instance - * - * @return void - * @TODO 0% done: Unfinished work here - */ - private function handleCurrentQueues () { - // Is there a queues available? - if (!$this->getIteratorInstance()->valid()) { - // Simply abort here - return; - } // END - if - - // Get the current queues - $currentQueues = $this->getIteratorInstance()->current(); - - // Only while construction, else it would output to much! - /* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONNECTOR: Handling queue entry ' . $currentQueues); - } - - /** - * Handles all pending queues. This method should be called by the - * ActiveTaskVisitor class and should use an iterator on all pending - * queues. - * - * @return void - */ - public function handlePending () { - // Should we rewind? - if (!$this->getIteratorInstance()->valid()) { - // Rewind to the beginning for next loop - $this->getIteratorInstance()->rewind(); - } // END - if - - // Try to execute the task - $this->handleCurrentQueue(); - - // Go to next entry - $this->getIteratorInstance()->next(); - } - - /** - * Accepts the visitor to process the visit "request" - * - * @param $visitorInstance An instance of a Visitor class - * @return void - */ - public function accept (Visitor $visitorInstance) { - // Visit the query connector - $visitorInstance->visitQueue($this); - } -} - -// [EOF] +// @DEPRECATED ?> diff --git a/application/hub/main/discovery/package/class_PackageRecipientDiscovery.php b/application/hub/main/discovery/package/class_PackageRecipientDiscovery.php index f862936b6..6bd982d83 100644 --- a/application/hub/main/discovery/package/class_PackageRecipientDiscovery.php +++ b/application/hub/main/discovery/package/class_PackageRecipientDiscovery.php @@ -57,12 +57,12 @@ class PackageRecipientDiscovery extends BaseHubDiscovery implements Discoverable * * @param $packageData Raw package data array * @return void + * @todo Find a better way than this switch/case/default thing */ public function discoverRecipients (array $packageData) { // We do some rudimentary checks but this might be a bit ugly switch ($packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT]) { - // All upper hubs, these are currently the bootstrap nodes and later on prepended list-nodes - case NetworkPackage::NETWORK_TARGET_UPPER_NODES: + case NetworkPackage::NETWORK_TARGET_UPPER_NODES: // All upper hubs, these are currently the bootstrap nodes and later on prepended list-nodes // Get all bootstrap nodes foreach (explode(BaseHubSystem::BOOTSTRAP_NODES_SEPARATOR, $this->getConfigInstance()->getConfigEntry('hub_bootstrap_nodes')) as $ipPort) { // Is maximum reached? @@ -82,8 +82,7 @@ class PackageRecipientDiscovery extends BaseHubDiscovery implements Discoverable } // END - foreach break; - // The target 'self' is always the external IP address! - case NetworkPackage::NETWORK_TARGET_SELF: + case NetworkPackage::NETWORK_TARGET_SELF: // The target 'self' is always the external IP address! // Determine own port $port = $this->getConfigInstance()->getConfigEntry('node_listen_port'); @@ -97,8 +96,11 @@ class PackageRecipientDiscovery extends BaseHubDiscovery implements Discoverable } // END - if break; - // This may be a direct recipient (node's session id) - default: + case NetworkPackage::NETWORK_TARGET_DHT: // The target 'dht' is a list from local DHT query + $this->partialStub('DHT recipient unimplemented: packageData=' . print_r($packageData, true)); + break; + + default: // This may be a direct recipient (node's session id) /* * Try to solve it, if an exception comes back, it is not a * session-id, nor IP:port and not a hostname:port combination. diff --git a/application/hub/main/helper/class_BaseHubSystemHelper.php b/application/hub/main/helper/class_BaseHubSystemHelper.php index 79b80d1a5..a2debcbf1 100644 --- a/application/hub/main/helper/class_BaseHubSystemHelper.php +++ b/application/hub/main/helper/class_BaseHubSystemHelper.php @@ -21,7 +21,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -class BaseHubSystemHelper extends BaseHubSystem { +class BaseHubSystemHelper extends BaseHubSystem implements Helper { /** * Recipient type */ diff --git a/application/hub/main/package/class_NetworkPackage.php b/application/hub/main/package/class_NetworkPackage.php index 9aca332c0..7ab871a12 100644 --- a/application/hub/main/package/class_NetworkPackage.php +++ b/application/hub/main/package/class_NetworkPackage.php @@ -592,11 +592,11 @@ class NetworkPackage extends BaseHubSystem implements Deliverable, Receivable, R * from given helper's template instance and pushing it on the 'undeclared' * stack. * - * @param $helperInstance An instance of a HelpableNode class + * @param $helperInstance An instance of a Helper class * @param $protocol Name of used protocol (TCP/UDP) * @return void */ - public function enqueueRawDataFromTemplate (HelpableNode $helperInstance, $protocolName) { + public function enqueueRawDataFromTemplate (Helper $helperInstance, $protocolName) { // Get the raw content ... $content = $helperInstance->getTemplateInstance()->getRawTemplateData(); //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('content(' . strlen($content) . ')=' . $content); diff --git a/application/hub/main/template/bootstrap/class_XmlBootstrapTemplateEngine.php b/application/hub/main/template/bootstrap/class_XmlBootstrapTemplateEngine.php index 50bf15e65..f551ef47b 100644 --- a/application/hub/main/template/bootstrap/class_XmlBootstrapTemplateEngine.php +++ b/application/hub/main/template/bootstrap/class_XmlBootstrapTemplateEngine.php @@ -1,336 +1,3 @@ - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * @todo This template engine does not make use of setTemplateType() - * - * 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 . - */ -class XmlBootstrapTemplateEngine extends BaseXmlTemplateEngine implements CompileableTemplate, Registerable { - /** - * Some XML nodes must be available for later data extraction - */ - const BOOTSTRAP_DATA_SESSION_ID = 'session-id'; - const BOOTSTRAP_DATA_NODE_STATUS = 'node-status'; - const BOOTSTRAP_DATA_NODE_MODE = 'node-mode'; - const BOOTSTRAP_DATA_EXTERNAL_IP = 'external-ip'; - const BOOTSTRAP_DATA_INTERNAL_IP = 'internal-ip'; - const BOOTSTRAP_DATA_LISTEN_PORT = 'listen-port'; - - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Init array - $this->subNodes = array( - 'bootstrap-data', - 'listener', - self::BOOTSTRAP_DATA_NODE_STATUS, - self::BOOTSTRAP_DATA_NODE_MODE, - self::BOOTSTRAP_DATA_LISTEN_PORT, - self::BOOTSTRAP_DATA_SESSION_ID, - self::BOOTSTRAP_DATA_EXTERNAL_IP, - self::BOOTSTRAP_DATA_INTERNAL_IP, - 'object-type-list', - ); - } - - /** - * Creates an instance of the class TemplateEngine and prepares it for usage - * - * @return $templateInstance An instance of TemplateEngine - * @throws BasePathIsEmptyException If the provided $templateBasePath is empty - * @throws InvalidBasePathStringException If $templateBasePath is no string - * @throws BasePathIsNoDirectoryException If $templateBasePath is no - * directory or not found - * @throws BasePathReadProtectedException If $templateBasePath is - * read-protected - */ - public static final function createXmlBootstrapTemplateEngine () { - // Get a new instance - $templateInstance = new XmlBootstrapTemplateEngine(); - - // Init template instance - $templateInstance->initXmlTemplateEngine('node', 'bootstrap'); - - // Return the prepared instance - return $templateInstance; - } - - /** - * Currently not used - * - * @param $resource XML parser resource (currently ignored) - * @param $characters Characters to handle - * @return void - */ - public function characterHandler ($resource, $characters) { - // Trim all spaces away - $characters = trim($characters); - - // Is this string empty? - if (empty($characters)) { - // Then skip it silently - return false; - } // END - if - - /* - * Assign the found characters to variable and use the last entry from - * stack as the name. - */ - parent::assignVariable($this->getStackerInstance()->getNamed('node_bootstrap'), $characters); - } - - /** - * Getter for cache file (FQFN) - * - * @return $fqfn Full-qualified file name of the menu cache - */ - public function getMenuCacheFqfn () { - $this->partialStub('Please implement this method.'); - } - - /** - * Starts the bootstrap - * - * @return void - */ - protected function startBootstrap () { - // Push the node name on the stacker - $this->getStackerInstance()->pushNamed('node_bootstrap', 'node_bootstrap'); - } - - /** - * Starts the bootstrap data - * - * @return void - */ - protected function startBootstrapData () { - // Push the node name on the stacker - $this->getStackerInstance()->pushNamed('node_bootstrap', 'bootstrap-data'); - } - - /** - * Starts the node status - * - * @return void - */ - protected function startNodeStatus () { - // Push the node name on the stacker - $this->getStackerInstance()->pushNamed('node_bootstrap', self::BOOTSTRAP_DATA_NODE_STATUS); - } - - /** - * Starts the node-mode - * - * @return void - */ - protected function startNodeMode () { - // Push the node name on the stacker - $this->getStackerInstance()->pushNamed('node_bootstrap', self::BOOTSTRAP_DATA_NODE_MODE); - } - - /** - * Starts the listener - * - * @return void - */ - protected function startListener () { - // Push the node name on the stacker - $this->getStackerInstance()->pushNamed('node_bootstrap', 'listener'); - } - - /** - * Starts the TCP/UDP listen port - * - * @return void - */ - protected function startListenPort () { - // Push the node name on the stacker - $this->getStackerInstance()->pushNamed('node_bootstrap', self::BOOTSTRAP_DATA_LISTEN_PORT); - } - - /** - * Starts the session id - * - * @return void - */ - protected function startSessionId () { - // Push the node name on the stacker - $this->getStackerInstance()->pushNamed('node_bootstrap', self::BOOTSTRAP_DATA_SESSION_ID); - } - - /** - * Starts the public ip - * - * @return void - */ - protected function startExternalIp () { - // Push the node name on the stacker - $this->getStackerInstance()->pushNamed('node_bootstrap', self::BOOTSTRAP_DATA_EXTERNAL_IP); - } - - /** - * Starts the private ip - * - * @return void - */ - protected function startInternalIp () { - // Push the node name on the stacker - $this->getStackerInstance()->pushNamed('node_bootstrap', self::BOOTSTRAP_DATA_INTERNAL_IP); - } - - /** - * Starts the object type list - * - * @return void - */ - protected function startObjectTypeList () { - // Push the node name on the stacker - $this->getStackerInstance()->pushNamed('node_bootstrap', 'object-type-list'); - } - - /** - * Starts the object type - * - * @return void - */ - protected function startObjectType () { - // Push the node name on the stacker - $this->getStackerInstance()->pushNamed('node_bootstrap', 'object-type'); - } - - /** - * Finishes the object type - * - * @return void - */ - protected function finishObjectType () { - // Pop the last entry - $this->getStackerInstance()->popNamed('node_bootstrap'); - } - - /** - * Finishes the object type list - * - * @return void - */ - protected function finishObjectTypeList () { - // Pop the last entry - $this->getStackerInstance()->popNamed('node_bootstrap'); - } - - /** - * Finishes the session id - * - * @return void - */ - protected function finishSessionId () { - // Pop the last entry - $this->getStackerInstance()->popNamed('node_bootstrap'); - } - - /** - * Finishes the private ip - * - * @return void - */ - protected function finishInternalIp () { - // Pop the last entry - $this->getStackerInstance()->popNamed('node_bootstrap'); - } - - /** - * Finishes the public ip - * - * @return void - */ - protected function finishExternalIp () { - // Pop the last entry - $this->getStackerInstance()->popNamed('node_bootstrap'); - } - - /** - * Finishes the TCP/UDP listen port - * - * @return void - */ - protected function finishListenPort () { - // Pop the last entry - $this->getStackerInstance()->popNamed('node_bootstrap'); - } - - /** - * Finishes the listener - * - * @return void - */ - protected function finishListener () { - // Pop the last entry - $this->getStackerInstance()->popNamed('node_bootstrap'); - } - - /** - * Finishes the node mode - * - * @return void - */ - protected function finishNodeMode () { - // Pop the last entry - $this->getStackerInstance()->popNamed('node_bootstrap'); - } - - /** - * Finishes the node status - * - * @return void - */ - protected function finishNodeStatus () { - // Pop the last entry - $this->getStackerInstance()->popNamed('node_bootstrap'); - } - - /** - * Finishes the bootstrap data - * - * @return void - */ - protected function finishBootstrapData () { - // Pop the last entry - $this->getStackerInstance()->popNamed('node_bootstrap'); - } - - /** - * Finishes the bootstrap - * - * @return void - */ - protected function finishBootstrap () { - // Pop the last entry - $this->getStackerInstance()->popNamed('node_bootstrap'); - } -} - -// [EOF] +// @DEPRECATED ?> diff --git a/application/hub/main/template/bootstrap/class_XmlDhtBootstrapTemplateEngine.php b/application/hub/main/template/bootstrap/class_XmlDhtBootstrapTemplateEngine.php new file mode 100644 index 000000000..fd1606333 --- /dev/null +++ b/application/hub/main/template/bootstrap/class_XmlDhtBootstrapTemplateEngine.php @@ -0,0 +1,336 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * @todo This template engine does not make use of setTemplateType() + * + * 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 . + */ +class XmlDhtBootstrapTemplateEngine extends BaseXmlTemplateEngine implements CompileableTemplate, Registerable { + /** + * Some XML nodes must be available for later data extraction + */ + const BOOTSTRAP_DATA_SESSION_ID = 'session-id'; + const BOOTSTRAP_DATA_NODE_STATUS = 'node-status'; + const BOOTSTRAP_DATA_NODE_MODE = 'node-mode'; + const BOOTSTRAP_DATA_EXTERNAL_IP = 'external-ip'; + const BOOTSTRAP_DATA_INTERNAL_IP = 'internal-ip'; + const BOOTSTRAP_DATA_LISTEN_PORT = 'listen-port'; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Init array + $this->subNodes = array( + 'bootstrap-data', + 'listener', + self::BOOTSTRAP_DATA_NODE_STATUS, + self::BOOTSTRAP_DATA_NODE_MODE, + self::BOOTSTRAP_DATA_LISTEN_PORT, + self::BOOTSTRAP_DATA_SESSION_ID, + self::BOOTSTRAP_DATA_EXTERNAL_IP, + self::BOOTSTRAP_DATA_INTERNAL_IP, + 'object-type-list', + ); + } + + /** + * Creates an instance of the class TemplateEngine and prepares it for usage + * + * @return $templateInstance An instance of TemplateEngine + * @throws BasePathIsEmptyException If the provided $templateBasePath is empty + * @throws InvalidBasePathStringException If $templateBasePath is no string + * @throws BasePathIsNoDirectoryException If $templateBasePath is no + * directory or not found + * @throws BasePathReadProtectedException If $templateBasePath is + * read-protected + */ + public static final function createXmlDhtBootstrapTemplateEngine () { + // Get a new instance + $templateInstance = new XmlDhtBootstrapTemplateEngine(); + + // Init template instance + $templateInstance->initXmlTemplateEngine('dht', 'bootstrap'); + + // Return the prepared instance + return $templateInstance; + } + + /** + * Currently not used + * + * @param $resource XML parser resource (currently ignored) + * @param $characters Characters to handle + * @return void + */ + public function characterHandler ($resource, $characters) { + // Trim all spaces away + $characters = trim($characters); + + // Is this string empty? + if (empty($characters)) { + // Then skip it silently + return false; + } // END - if + + /* + * Assign the found characters to variable and use the last entry from + * stack as the name. + */ + parent::assignVariable($this->getStackerInstance()->getNamed('dht_bootstrap'), $characters); + } + + /** + * Getter for cache file (FQFN) + * + * @return $fqfn Full-qualified file name of the menu cache + */ + public function getMenuCacheFqfn () { + $this->partialStub('Please implement this method.'); + } + + /** + * Starts the bootstrap + * + * @return void + */ + protected function startBootstrap () { + // Push the node name on the stacker + $this->getStackerInstance()->pushNamed('dht_bootstrap', 'bootstrap'); + } + + /** + * Starts the bootstrap data + * + * @return void + */ + protected function startBootstrapData () { + // Push the node name on the stacker + $this->getStackerInstance()->pushNamed('dht_bootstrap', 'bootstrap-data'); + } + + /** + * Starts the node status + * + * @return void + */ + protected function startNodeStatus () { + // Push the node name on the stacker + $this->getStackerInstance()->pushNamed('dht_bootstrap', self::BOOTSTRAP_DATA_NODE_STATUS); + } + + /** + * Starts the node-mode + * + * @return void + */ + protected function startNodeMode () { + // Push the node name on the stacker + $this->getStackerInstance()->pushNamed('dht_bootstrap', self::BOOTSTRAP_DATA_NODE_MODE); + } + + /** + * Starts the listener + * + * @return void + */ + protected function startListener () { + // Push the node name on the stacker + $this->getStackerInstance()->pushNamed('dht_bootstrap', 'listener'); + } + + /** + * Starts the TCP/UDP listen port + * + * @return void + */ + protected function startListenPort () { + // Push the node name on the stacker + $this->getStackerInstance()->pushNamed('dht_bootstrap', self::BOOTSTRAP_DATA_LISTEN_PORT); + } + + /** + * Starts the session id + * + * @return void + */ + protected function startSessionId () { + // Push the node name on the stacker + $this->getStackerInstance()->pushNamed('dht_bootstrap', self::BOOTSTRAP_DATA_SESSION_ID); + } + + /** + * Starts the public ip + * + * @return void + */ + protected function startExternalIp () { + // Push the node name on the stacker + $this->getStackerInstance()->pushNamed('dht_bootstrap', self::BOOTSTRAP_DATA_EXTERNAL_IP); + } + + /** + * Starts the private ip + * + * @return void + */ + protected function startInternalIp () { + // Push the node name on the stacker + $this->getStackerInstance()->pushNamed('dht_bootstrap', self::BOOTSTRAP_DATA_INTERNAL_IP); + } + + /** + * Starts the object type list + * + * @return void + */ + protected function startObjectTypeList () { + // Push the node name on the stacker + $this->getStackerInstance()->pushNamed('dht_bootstrap', 'object-type-list'); + } + + /** + * Starts the object type + * + * @return void + */ + protected function startObjectType () { + // Push the node name on the stacker + $this->getStackerInstance()->pushNamed('dht_bootstrap', 'object-type'); + } + + /** + * Finishes the object type + * + * @return void + */ + protected function finishObjectType () { + // Pop the last entry + $this->getStackerInstance()->popNamed('dht_bootstrap'); + } + + /** + * Finishes the object type list + * + * @return void + */ + protected function finishObjectTypeList () { + // Pop the last entry + $this->getStackerInstance()->popNamed('dht_bootstrap'); + } + + /** + * Finishes the session id + * + * @return void + */ + protected function finishSessionId () { + // Pop the last entry + $this->getStackerInstance()->popNamed('dht_bootstrap'); + } + + /** + * Finishes the private ip + * + * @return void + */ + protected function finishInternalIp () { + // Pop the last entry + $this->getStackerInstance()->popNamed('dht_bootstrap'); + } + + /** + * Finishes the public ip + * + * @return void + */ + protected function finishExternalIp () { + // Pop the last entry + $this->getStackerInstance()->popNamed('dht_bootstrap'); + } + + /** + * Finishes the TCP/UDP listen port + * + * @return void + */ + protected function finishListenPort () { + // Pop the last entry + $this->getStackerInstance()->popNamed('dht_bootstrap'); + } + + /** + * Finishes the listener + * + * @return void + */ + protected function finishListener () { + // Pop the last entry + $this->getStackerInstance()->popNamed('dht_bootstrap'); + } + + /** + * Finishes the node mode + * + * @return void + */ + protected function finishNodeMode () { + // Pop the last entry + $this->getStackerInstance()->popNamed('dht_bootstrap'); + } + + /** + * Finishes the node status + * + * @return void + */ + protected function finishNodeStatus () { + // Pop the last entry + $this->getStackerInstance()->popNamed('dht_bootstrap'); + } + + /** + * Finishes the bootstrap data + * + * @return void + */ + protected function finishBootstrapData () { + // Pop the last entry + $this->getStackerInstance()->popNamed('dht_bootstrap'); + } + + /** + * Finishes the bootstrap + * + * @return void + */ + protected function finishBootstrap () { + // Pop the last entry + $this->getStackerInstance()->popNamed('dht_bootstrap'); + } +} + +// [EOF] +?> diff --git a/application/hub/templates/xml/dht_bootstrap/.htaccess b/application/hub/templates/xml/dht_bootstrap/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/templates/xml/dht_bootstrap/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/templates/xml/dht_bootstrap/bootstrap.xml b/application/hub/templates/xml/dht_bootstrap/bootstrap.xml new file mode 100644 index 000000000..709fa8943 --- /dev/null +++ b/application/hub/templates/xml/dht_bootstrap/bootstrap.xml @@ -0,0 +1,25 @@ + + + + -- 2.39.5