Now with latest "core".
Signed-off-by: Roland Haeder <roland@mxchange.org>
Conflicts:
application/hub/main/source/urls/class_CrawlerUploadedListUrlSource.php
core
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0
- * @copyright Copyright (c) 2007 - 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007 - 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
*
* This program is free software: you can redistribute it and/or modify
// Set this application in registry
Registry::getRegistry()->addInstance('app', $this);
- // Is no external IP set?
- if ($this->getConfigInstance()->getConfigEntry('external_ip') == '') {
- // Determine external IP
- $this->getConfigInstance()->setConfigEntry('external_ip', ConsoleTools::determineExternalIp());
+ // Is no external address set?
+ if ($this->getConfigInstance()->getConfigEntry('external_address') == '') {
+ // Determine external address
+ $this->getConfigInstance()->setConfigEntry('external_address', HubTools::determineOwnExternalAddress());
} // END - if
// Default response is console
* objects which would be rejected by the global network) please change
* hub_bootstrap_nodes (semicolon-seperated list) to your bootstrapper.
*
- * You can set external_ip to a hostname, e.g. me.homelinux.org, which will be
+ * You can set external_address to a hostname, e.g. me.homelinux.org, which will be
* included in the announcement. This is very useful for consumer DSL
* connections because they might be disconnected every 24 hours and rotate the
* IP number.
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0
- * @copyright Copyright (c) 2007 - 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007 - 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
*
* This program is free software: you can redistribute it and/or modify
// CFG: NODE-DEFAULT-MODE (can be 'regular', 'list', 'master' or 'boot', default is 'regular')
$cfg->setConfigEntry('node_default_mode', 'regular');
-// CFG: EXTERNAL-IP
-// Use this if auto-detection fails: $cfg->setConfigEntry('external_ip', '');
+// CFG: EXTERNAL-ADDRESS
+// Use this if auto-detection fails: $cfg->setConfigEntry('external_address', '');
-// CFG: ALLOW-PUBLISH-INTERNAL-IP
-// Use this in intranet-only environment: $cfg->setConfigEntry('allow_publish_internal_ip', 'Y');
+// CFG: ALLOW-PUBLISH-INTERNAL-ADDRESS
+// Use this in intranet-only environment: $cfg->setConfigEntry('allow_publish_internal_address', 'Y');
// CFG: HUB-BOOTSTRAP-NODES
-$cfg->setConfigEntry('hub_bootstrap_nodes', '188.138.90.169:9060');
+$cfg->setConfigEntry('hub_bootstrap_nodes', 'tcp://188.138.90.169:9060');
// [EOF]
?>
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0
- * @copyright Copyright (c) 2007 - 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007 - 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
*
* This program is free software: you can redistribute it and/or modify
// CFG: DHT-RECIPIENT-DISCOVERY-CLASS
$cfg->setConfigEntry('dht_recipient_discovery_class', 'DhtRecipientDiscovery');
+// CFG: UNL-DISCOVERY-CLASS
+$cfg->setConfigEntry('unl_discovery_class', 'UniversalNodeLocatorDiscovery');
+
+// CFG: PROTOCOL-DISCOVERY-CLASS
+$cfg->setConfigEntry('protocol_discovery_class', 'ProtocolDiscovery');
+
+// CFG: TCP-PROTOCOL-HANDLER-CLASS
+$cfg->setConfigEntry('tcp_protocol_handler_class', 'TcpProtocolHandler');
+
+// CFG: UNIVERSAL-NODE-LOCATOR-CLASS
+$cfg->setConfigEntry('universal_node_locator_class', 'UniversalNodeLocator');
+
// CFG: RECIPIENT-LIST-CLASS
$cfg->setConfigEntry('recipient_list_class', 'RecipientList');
// CFG: UDP-CONNECTION-HELPER-CLASS
$cfg->setConfigEntry('udp_connection_helper_class', 'UdpConnectionHelper');
+// CFG: HUB-COMMUNICATION-PROTOCOL-TYPE
+$cfg->setConfigEntry('hub_communication_protocol_type', 'tcp');
+
+// CFG: TCP-PROTOCOL-RESOLVER-CLASS
+$cfg->setConfigEntry('tcp_protocol_resolver_class', 'TcpProtocolResolver');
+
// CFG: TCP-BUFFER-LENGTH
$cfg->setConfigEntry('tcp_buffer_length', 1024);
// CFG: PRIVATE-KEY-HASH
$cfg->setConfigEntry('private_key_hash', '');
-// CFG: INTERNAL-IP
-$cfg->setConfigEntry('internal_ip', ConsoleTools::acquireSelfIPAddress());
+// CFG: EXTERNAL-ADDRESS
+$cfg->setConfigEntry('external_address', '');
-// CFG: EXTERNAL-IP
-$cfg->setConfigEntry('external_ip', '');
+// CFG: INTERNAL-ADDRESS
+$cfg->setConfigEntry('internal_address', '');
-// CFG: ALLOW-PUBLISH-INTERNAL-IP
-$cfg->setConfigEntry('allow_publish_internal_ip', 'N');
+// CFG: ALLOW-PUBLISH-INTERNAL-ADDRESS
+$cfg->setConfigEntry('allow_publish_internal_address', 'N');
// CFG: NODE-STATUS
$cfg->setConfigEntry('node_status', 'invalid');
// CFG: TASK-CRAWLER-URL-SOURCE-FOUND-RSS-MAX-RUNS
$cfg->setConfigEntry('task_crawler_uploaded_list_scanner_max_runs', 0);
-// CFG: CSV-FILE-PATH
-$cfg->setConfigEntry('csv_file_path', 'data/url_lists');
+// CFG: CRAWLER-CSV-FILE-PATH
+$cfg->setConfigEntry('crawler_csv_file_path', 'data/url_lists');
///////////////////////////////////////////////////////////////////////////////
// HTTP Configuration
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0
- * @copyright Copyright (c) 2007 - 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007 - 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
*
* This program is free software: you can redistribute it and/or modify
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0
- * @copyright Copyright (c) 2007 - 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007 - 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
*
* This program is free software: you can redistribute it and/or modify
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*/
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_IP],
- $messageArray[2][XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_INTERNAL_IP],
- $messageArray[2][XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_LISTEN_PORT],
+ $messageArray[2][XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_EXTERNAL_ADDRESS],
+ $messageArray[2][XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_INTERNAL_ADDRESS],
$messageArray[2][XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_NODE_STATUS],
$messageArray[2][XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_NODE_MODE]
);
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*/
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_IP],
- $messageArray[2][XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_INTERNAL_IP],
- $messageArray[2][XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_LISTEN_PORT],
+ $messageArray[2][XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_EXTERNAL_ADDRESS],
+ $messageArray[2][XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_INTERNAL_ADDRESS],
$messageArray[2][XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_NODE_STATUS]
);
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*/
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_IP],
- $messageArray[1][XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_INTERNAL_IP],
- $messageArray[1][XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_LISTEN_PORT],
+ $messageArray[1][XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_EXTERNAL_ADDRESS],
+ $messageArray[1][XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_INTERNAL_ADDRESS],
$messageArray[1][XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_NODE_STATUS],
$messageArray[1][XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_NODE_MODE]
);
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
/**
* This exception is thrown when a provided session id in a message cannot be
* verified. This can be the case when e.g. it doesn't match any records or the
- * IP/port combination doesn't match to it.
+ * address doesn't match to it.
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*/
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_IP],
- $messageArray[1][XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_INTERNAL_IP],
- $messageArray[1][XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_LISTEN_PORT],
+ $messageArray[1][XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_EXTERNAL_ADDRESS],
+ $messageArray[1][XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_INTERNAL_ADDRESS],
$messageArray[1][XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_NODE_STATUS]
);
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*/
public function __construct (array $messageArray, $code) {
// Construct the message
- $message = sprintf('[%s:%d] Node already registered: session-id=%s, external-ip=%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_IP],
- $msssageArray[1][NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_LISTEN_PORT],
+ $msssageArray[1][NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_EXTERNAL_ADDRESS]
);
// Call parent exception constructor
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*/
public function __construct (array $messageArray, $code) {
// Construct the message
- $message = sprintf('[%s:%d] Node not registered/missing: session-id=%s, external-ip=%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_IP],
- $msssageArray[1][NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_LISTEN_PORT],
+ $msssageArray[1][NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_EXTERNAL_ADDRESS]
);
// Call parent exception constructor
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0
- * @copyright Copyright (c) 2007 - 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007 - 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
*
* This program is free software: you can redistribute it and/or modify
// the inc/database.php script
require($cfg->getConfigEntry('base_path') . 'inc/database.php');
-// Get's our IP address
-ConsoleTools::acquireSelfIPAddress();
+// Get own internal address
+HubTools::determineOwnInternalAddress();
// [EOF]
?>
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
* @todo We need to find a better name for this interface
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
--- /dev/null
+<?php
+/**
+ * An interface for !!! discovery
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Core Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.shipsimu.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/>.
+ */
+interface Discoverable!!! extends Discoverable {
+}
+
+// [EOF]
+?>
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
interface Discoverable extends FrameworkInterface {
- /**
- * "Getter" for recipient iterator
- *
- * @return $iteratorInstance An instance of a Iterateable object
- */
- function getIterator ();
-
- /**
- * Clears all recipients for e.g. another package to deliver
- *
- * @return void
- */
- function clearRecipients ();
-
- /**
- * Checks whether the recipient list is empty
- *
- * @return $isEmpty Whether the recipient list is empty
- */
- function isRecipientListEmpty ();
}
// [EOF]
+++ /dev/null
-Deny from all
+++ /dev/null
-<?php
-/**
- * An interface for socket discovery
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @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.shipsimu.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/>.
- */
-interface DiscoverableDhtRecipient extends Discoverable {
- /**
- * Resolves one or more recipients for a DHT transfer by given package data.
- *
- * @param $packageData Valid package data array
- * @return $recipients An indexed array with DHT recipients
- */
- function resolveRecipientsByPackageData (array $packageData);
-}
-
-// [EOF]
-?>
+++ /dev/null
-Deny from all
+++ /dev/null
-<?php
-/**
- * An interface for recipient discovery
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @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.shipsimu.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/>.
- */
-interface DiscoverableNodeRecipient extends Discoverable, IteratorAggregate {
- /**
- * Tries to discover all recipients for given package data
- *
- * @param $packageData Raw package data array
- * @return void
- */
- function discoverRecipients (array $packageData);
-
- /**
- * Tries to discover all recipients by given decoded package data.
- *
- * @param $decodedData Raw raw package data array
- * @return void
- */
- function discoverRawRecipients (array $decodedData);
-
- /**
- * "Getter" for recipient iterator
- *
- * @return $iteratorInstance An instance of a Iterateable object
- */
- function getIterator ();
-
- /**
- * Clears all recipients for e.g. another package to deliver
- *
- * @return void
- */
- function clearRecipients ();
-}
-
-// [EOF]
-?>
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * An interface for protocol discovery
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Core Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.shipsimu.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/>.
+ */
+interface DiscoverableProtocol extends Discoverable {
+ /**
+ * "Discovers" the protocol type from given raw package data. This is done
+ * by looking at the 'recipient' field and extract the first part from it.
+ *
+ * @param $packageData Raw package data
+ * @return $protocolType Type of protocol, e.g. 'tcp' for TCP/IPv4 connections
+ */
+ function discoverProtocolByPackageData (array $packageData);
+}
+
+// [EOF]
+?>
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * An interface for recipient discovery
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Core Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.shipsimu.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/>.
+ */
+interface DiscoverableRecipient extends Discoverable {
+ /**
+ * "Getter" for recipient iterator
+ *
+ * @return $iteratorInstance An instance of a Iterateable object
+ */
+ function getIterator ();
+
+ /**
+ * Clears all recipients for e.g. another package to deliver
+ *
+ * @return void
+ */
+ function clearRecipients ();
+
+ /**
+ * Checks whether the recipient list is empty
+ *
+ * @return $isEmpty Whether the recipient list is empty
+ */
+ function isRecipientListEmpty ();
+}
+
+// [EOF]
+?>
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * An interface for DHT recipient discovery
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Core Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.shipsimu.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/>.
+ */
+interface DiscoverableDhtRecipient extends DiscoverableRecipient {
+ /**
+ * Resolves one or more recipients for a DHT transfer by given package data.
+ *
+ * @param $packageData Valid package data array
+ * @return $recipients An indexed array with DHT recipients
+ */
+ function resolveRecipientsByPackageData (array $packageData);
+}
+
+// [EOF]
+?>
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * An interface for node recipient discovery
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Core Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.shipsimu.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/>.
+ */
+interface DiscoverableNodeRecipient extends DiscoverableRecipient {
+ /**
+ * Tries to discover all recipients for given package data
+ *
+ * @param $packageData Raw package data array
+ * @return void
+ */
+ function discoverRecipients (array $packageData);
+
+ /**
+ * Tries to discover all recipients by given decoded package data.
+ *
+ * @param $decodedData Raw raw package data array
+ * @return void
+ */
+ function discoverRawRecipients (array $decodedData);
+}
+
+// [EOF]
+?>
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * An interface for socket discovery
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Core Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.shipsimu.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/>.
+ */
+interface DiscoverableSocket extends DiscoverableRecipient {
+ /**
+ * Tries to discover the right socket for given package data and returns a
+ * matching socket resource.
+ *
+ * @param $packageData Raw package data array
+ * @param $connectionType Type of connection, can be 'incoming' or 'outgoing', *NEVER* 'server'!
+ * @return $socketResource A valid socket resource
+ * @throws NoListGroupException If the procol group is not found in peer list
+ * @throws NullPointerException If listenerInstance is NULL
+ */
+ function discoverSocket (array $packageData, $connectionType);
+}
+
+// [EOF]
+?>
+++ /dev/null
-Deny from all
+++ /dev/null
-<?php
-/**
- * An interface for socket discovery
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @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.shipsimu.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/>.
- */
-interface DiscoverableSocket extends Discoverable {
- /**
- * Tries to discover the right socket for given package data and returns a
- * matching socket resource.
- *
- * @param $packageData Raw package data array
- * @param $connectionType Type of connection, can be 'incoming' or 'outgoing', *NEVER* 'server'!
- * @return $socketResource A valid socket resource
- * @throws NoListGroupException If the procol group is not found in peer list
- * @throws NullPointerException If listenerInstance is NULL
- */
- function discoverSocket (array $packageData, $connectionType);
-}
-
-// [EOF]
-?>
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * An interface for UNL discovery
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Core Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.shipsimu.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/>.
+ */
+interface DiscoverableUniversalNodeLocator extends Discoverable {
+ /**
+ * "Discovers" an instance of a LocateableNode class for given NodeHelper class
+ *
+ * @param $nodeInstance An instance of a NodeHelper class
+ * @return $unlInstance An instance of a LocateableNode class
+ */
+ function discoverUniversalNodeLocatorByNode (NodeHelper $nodeInstance);
+
+ /**
+ * "Discovers" the full universal node locator for given configuration entry
+ * which should represent the address part of the UNL. In case of an IP
+ * address, this *must not* include the port number as this is being found
+ * out for you.
+ *
+ * Valid values for $configKey: internal,external
+ *
+ * @param $configKey Key for address to get (valid: internal,external)
+ * @return $unl Universal node locator
+ */
+ function discoverUniversalNodeLocatorByConfiguredAddress ($configKey);
+}
+
+// [EOF]
+?>
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
* following data must always be present:
*
* - session-id (for finding the node's record together with below data)
- * - external-ip (hostname or IP number)
+ * - external-address (hostname or IP number)
* - listen-port (TCP/UDP listen port for inbound connections)
*
* @param $messageData An array with all minimum message data
- * @param $handlerInstance An instance of a Handleable class
+ * @param $handlerInstance An instance of a HandleableDataSet class
* @param $forceUpdate Optionally force update, don't register (default: register if not found)
* @return void
*/
- function registerNodeByMessageData (array $messageData, Handleable $handlerInstance, $forceUpdate = FALSE);
+ function registerNodeByMessageData (array $messageData, HandleableDataSet $handlerInstance, $forceUpdate = FALSE);
/**
* Queries the local DHT data(base) for a node list with all supported
* object types except the node by given session id.
*
* @param $messageData An array with message data from a node_list request
- * @param $handlerInstance An instance of a Handleable class
+ * @param $handlerInstance An instance of a HandleableDataSet class
* @param $excludeKey Array key which should be excluded
* @param $andKey Array of $separator-separated list of elements which all must match
* @param $separator Sepator char (1st parameter for explode() call)
* @return $nodeList An array with all found nodes
*/
- function queryLocalNodeListExceptByMessageData (array $messageData, Handleable $handlerInstance, $excludeKey, $andKey, $separator);
+ function queryLocalNodeListExceptByMessageData (array $messageData, HandleableDataSet $handlerInstance, $excludeKey, $andKey, $separator);
/**
* Inserts given node list array (from earlier database result produced by
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-interface HandleableAnswerStatus extends Handleable {
+interface HandleableAnswerStatus extends HandleableDataSet {
/**
* Handles given message data array
*
<?php
/**
- * Handleable chunks interface
+ * An interface for chunk handlers
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
+++ /dev/null
-<?php
-/**
- * A Handleable interface
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @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.shipsimu.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/>.
- */
-interface Handleable extends FrameworkInterface {
- /**
- * Adds all required elements from given array into data set instance
- *
- * @param $dataSetInstance An instance of a StoreableCriteria class
- * @param $messageData An array with all message data
- * @return void
- */
- function addArrayToDataSet (StoreableCriteria $dataSetInstance, array $messageData);
-}
-
-// [EOF]
-?>
<?php
/**
- * Handleable chunks interface
+ * An interface for message handlers
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-interface HandleableMessage extends Handleable {
+interface HandleableMessage extends HandleableDataSet {
/**
* Handles data array of the message
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-interface Networkable extends Handleable {
+interface Networkable extends HandleableDataSet {
/**
* Processes raw data from given resource. This is mostly useful for TCP
* package handling and is implemented in the TcpListener class
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-interface HandleableTask extends Handleable {
+interface HandleableTask extends HandleableDataSet {
/**
* Searches a task by given instance
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
* @todo Please find another name for this interface
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-interface ConnectionHelper extends Helper {
+interface ConnectionHelper extends HubHelper {
/**
* Sends raw package data to the recipient
*
function doShutdown ();
/**
- * Getter for port number to satify ProtocolHandler
+ * Getter for port number to satify HandleableProtocol
*
* @return $port The port number
*/
- function getPort ();
-
- /**
- * Getter for protocol
- *
- * @return $protocol Used protocol
- */
- function getProtocol ();
+ function getConnectionPort ();
/**
* Getter for IP address
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-interface HelpableDht extends Helper {
+interface HelpableDht extends HubHelper {
/**
* Loads the descriptor XML file
*
--- /dev/null
+<?php
+/**
+ * An general interface for hub helper classes
+ *
+ * @author Roland Haeder <webmaster@shipsimu.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.shipsimu.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/>.
+ */
+interface HubHelper extends Helper {
+ /**
+ * Tries to determine the used protocol for this package (this helper is helping to send out)
+ *
+ * @return $protocolType Type of protocol to use, usually TCP
+ */
+ function determineProtocolType ();
+}
+
+// [EOF]
+?>
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
* @todo Please find another name for this interface
<?php
/**
- * An interface for hub helper classes
+ * An interface for node helper classes
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-interface HelpableNode extends Helper {
+interface HelpableNode extends HubHelper {
/**
* Loads the descriptor XML file
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
* @todo We need to find a better name for this interface
function doSelfConnection (Taskable $taskInstance);
/**
- * "Getter for address:port combination
+ * Determines an instance of a LocateableNode class
*
- * @return $addressPort A address:port combination for this node
+ * @return $unlInstance An instance of a LocateableNode class for this node
*/
- function getAddressPort ();
+ function determineUniversalNodeLocator ();
/**
- * "Getter for address:port array
+ * "Getter for an array of an instance of a LocateableNode class
*
- * @return $addressPortArray An array address:port combination for this node
+ * @return $unlData An array of an instance of a LocateableNode class
*/
- function getAddressPortArray ();
+ function getUniversalNodeLocatorArray ();
/**
* Updates/refreshes node data (e.g. state).
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-interface Listenable extends ProtocolHandler {
+interface Listenable extends FrameworkInterface {
/**
* Initializes the listener by setting up the required socket server
*
* @return void
*/
function monitorIncomingRawData (Receivable $receiverInstance);
+
+ /**
+ * Getter for listen address
+ *
+ * @return $listenAddress The address this listener should listen on
+ */
+ function getListenAddress ();
+
+ /**
+ * Getter for listen port
+ *
+ * @return $listenPort The port this listener should listen on
+ */
+ function getListenPort ();
+
+ /**
+ * Getter for peer pool instance
+ *
+ * @return $poolInstance The peer pool instance we shall set
+ */
+ function getPoolInstance ();
}
// [EOF]
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * An interface for node locators (UNL mostly)
+ *
+ * @author Roland Haeder <webmaster@shipsimu.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.shipsimu.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/>.
+ */
+interface LocateableNode extends FrameworkInterface {
+}
+
+// [EOF]
+?>
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
* from given helper's template instance and pushing it on the 'undeclared'
* stack.
*
- * @param $helperInstance An instance of a Helper class
- * @param $protocol Name of used protocol (TCP/UDP)
+ * @param $helperInstance An instance of a HubHelper class
* @return void
*/
- function enqueueRawDataFromTemplate (Helper $helperInstance, $protocol);
+ function enqueueRawDataFromTemplate (HubHelper $helperInstance);
/**
* Checks whether a package has been enqueued for delivery.
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @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
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
+++ /dev/null
-<?php
-/**
- * An interface for protocol handlers
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @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.shipsimu.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/>.
- */
-interface ProtocolHandler extends FrameworkInterface {
- /**
- * Getter for port number to satify ProtocolHandler
- *
- * @return $port The port number
- */
- function getPort ();
-
- /**
- * Getter for protocol
- *
- * @return $protocol Used protocol
- */
- function getProtocol ();
-}
-
-// [EOF]
-?>
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*/
interface Recipient extends FrameworkInterface {
/**
- * Tries to resolve given recipient into session ids or ip:port combination
+ * Tries to resolve given recipient into session ids or Universal Node Locator
* depending on implementation (hint: Template Method Pattern)
*
* @param $recipient Recipient to resolve (e.g. could be a virtual recipient or direct session id)
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * An interface for ProtocolResolvers
+ *
+ * @author Roland Haeder <webmaster@shipsimu.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.shipsimu.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/>.
+ */
+interface ProtocolResolver extends FrameworkInterface {
+ /**
+ * Returns an instance of a LocateableNode class for a given NodeHelper
+ * instance or null if it was not found.
+ *
+ * @param $nodeInstance An instance of a NodeHelper class
+ * @return $unlInstance An instance of a LocateableNode class
+ */
+ function resolveUniversalNodeLocatorFromNodeHelper (NodeHelper $nodeInstance);
+
+ /**
+ * Returns the UNL as string from given configuration key.
+ *
+ * @param $configKey Configuration key for UNL address (valid: internal,external)
+ * @return $unl Universal node locator
+ */
+ function resolveUniversalNodeLocatorFromConfigKey ($configKey);
+}
+
+// [EOF]
+?>
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @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
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
* Chooses the right protocol from given package data
*
* @param $packageData Raw package data
- * @return $protocolName Name of the choosen procotol
+ * @return $protocolInstance An instance of a HandleableProtocol class
*/
function chooseProtocolFromPackageData (array $packageData);
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
/**
* Checks whether the local (*this*) node is registered in the DHT by
- * checking if the external ip/port is found.
+ * checking if the external address is found.
*
* @return $isRegistered Whether *this* node is registered in the DHT
*/
* Registeres a node by given message data.
*
* @param $messageData An array of all message data
- * @param $handlerInstance An instance of a Handleable class
+ * @param $handlerInstance An instance of a HandleableDataSet class
* @return void
*/
- function registerNodeByMessageData (array $messageData, Handleable $handlerInstance);
+ function registerNodeByMessageData (array $messageData, HandleableDataSet $handlerInstance);
/**
* Updates an existing entry in node list
*
* @param $messageData An array of all message data
- * @param $handlerInstance An instance of a Handleable class
+ * @param $handlerInstance An instance of a HandleableDataSet class
* @param $searchInstance An instance of LocalSearchCriteria class
* @return void
*/
- function updateNodeByMessageData (array $messageData, Handleable $handlerInstance, LocalSearchCriteria $searchInstance);
+ function updateNodeByMessageData (array $messageData, HandleableDataSet $handlerInstance, LocalSearchCriteria $searchInstance);
/**
* Determines whether the given node data is already inserted in the DHT
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0
- * @copyright Copyright (c) 2007 - 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007 - 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
*
* This program is free software: you can redistribute it and/or modify
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @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
*
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @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
*
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @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
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @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
*
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @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
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*/
private $minerInstance = NULL;
- /**
- * Listener instance
- */
- private $listenerInstance = NULL;
-
/**
* A network package handler instance
*/
*/
private $assemblerInstance = NULL;
+ /**
+ * Name of used protocol
+ */
+ private $protocolName = 'invalid';
+
/**
* Protected constructor
*
$this->minerInstance = $minerInstance;
}
- /**
- * Setter for listener instance
- *
- * @param $listenerInstance A Listenable instance
- * @return void
- */
- protected final function setListenerInstance (Listenable $listenerInstance) {
- $this->listenerInstance = $listenerInstance;
- }
-
- /**
- * Getter for listener instance
- *
- * @return $listenerInstance A Listenable instance
- */
- protected final function getListenerInstance () {
- return $this->listenerInstance;
- }
-
/**
* Setter for network package handler instance
*
/**
* Setter for session id
*
- * @param $sessionId The new session id
+ * @param $sessionId The new session id
* @return void
*/
protected final function setSessionId ($sessionId) {
/**
* Getter for session id
*
- * @return $sessionId Current session id
+ * @return $sessionId Current session id
*/
public final function getSessionId () {
return $this->getConfigInstance()->getConfigEntry('session_id');
}
+ /**
+ * Getter for protocol name
+ *
+ * @return $protocolName Name of used protocol
+ */
+ public final function getProtocolName () {
+ return $this->protocolName;
+ }
+
+ /**
+ * Setter for protocol name
+ *
+ * @param $protocolName Name of used protocol
+ * @return void
+ */
+ protected final function setProtocolName ($protocolName) {
+ $this->protocolName = $protocolName;
+ }
+
/**
* Constructs a callable method name from given socket error code. If the
* method is not found, a generic one is used.
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @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
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @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
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
* following data must always be present:
*
* - session-id (for finding the node's record together with below data)
- * - external-ip (hostname or IP number)
+ * - external-address (hostname or IP number)
* - listen-port (TCP/UDP listen port for inbound connections)
*
* @param $messageArray An array with all minimum message data
- * @param $handlerInstance An instance of a Handleable class
+ * @param $handlerInstance An instance of a HandleableDataSet class
* @param $forceUpdate Optionally force update, don't register (default: register if not found)
* @return void
* @throws NodeSessionIdVerficationException If the node was not found and update is forced
*/
- public function registerNodeByMessageData (array $messageData, Handleable $handlerInstance, $forceUpdate = FALSE) {
+ public function registerNodeByMessageData (array $messageData, HandleableDataSet $handlerInstance, $forceUpdate = FALSE) {
// Get a search criteria class
$searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class');
// Debug message
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-FACADE[' . __METHOD__ . ':' . __LINE__ . ']: state=' . $this->getPrintableState() . ',messageData=' . print_r($messageData, TRUE) . ',handlerInstance=' . $handlerInstance->__toString() . ',forceUpdate=' . intval($forceUpdate) . ',count(getSearchData())=' . count($handlerInstance->getSearchData()));
- // Search for the node's session id and external IP/hostname + TCP/UDP listen port
+ // Search for the node's session id and external address/hostname + TCP/UDP listen port
foreach ($handlerInstance->getSearchData() as $key) {
// Debug message
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-FACADE[' . __METHOD__ . ':' . __LINE__ . ']: state=' . $this->getPrintableState() . ',key=' . $key);
} else {
/*
* Do not register non-existent nodes here. This is maybe fatal,
- * caused by "stolen" session id and/or not matching IP
- * number/port combination.
+ * caused by "stolen" session id and/or not matching address.
*/
throw new NodeSessionIdVerficationException(array($this, $messageData), BaseHubSystem::EXCEPTION_NODE_SESSION_ID_NOT_VERIFYING);
}
* object types except the node by given session id.
*
* @param $messageData An array with message data from a node_list request
- * @param $handlerInstance An instance of a Handleable class
+ * @param $handlerInstance An instance of a HandleableDataSet class
* @param $excludeKey Array key which should be excluded
* @param $andKey Array of $separator-separated list of elements which all must match
* @param $separator Sepator char (1st parameter for explode() call)
* @return $nodeList An array with all found nodes
*/
- public function queryLocalNodeListExceptByMessageData (array $messageData, Handleable $handlerInstance, $excludeKey, $andKey, $separator) {
+ public function queryLocalNodeListExceptByMessageData (array $messageData, HandleableDataSet $handlerInstance, $excludeKey, $andKey, $separator) {
// Make sure both keys are there
assert((isset($messageData[$excludeKey])) && (isset($messageData[$andKey])));
--- /dev/null
+<?php
+/**
+ * A !!! discovery class
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Core Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.shipsimu.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 !!!Discovery extends BaseNodeDiscovery implements Discoverable,,,, Registerable {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+ }
+
+ /**
+ * Create an instance of this class
+ *
+ * @return $discoveryInstance An instance of this discovery class
+ */
+ public static final function create!!!Discovery () {
+ // Get an instance of this class
+ $discoveryInstance = new !!!Discovery();
+
+ // Return the prepared instance
+ return $discoveryInstance;
+ }
+}
+
+// [EOF]
+?>
<?php
/**
- * A PackageRecipient discovery class
+ * A general node discovery class
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
protected function __construct ($className) {
// Call parent constructor
parent::__construct($className);
-
- /*
- * Get recipients list instance and set it here for all discovery
- * implementations.
- */
- $listInstance = RecipientListFactory::createRecipientListInstance();
- $this->setListInstance($listInstance);
- }
-
- /**
- * Determines the protoctol name
- *
- * @param $packageData Valid package data
- * @return $protocolName Name of used protocol (TCP/UDP/etc.)
- */
- protected function determineProtocolByPackageData (array $packageData) {
- // First we need a tags instance
- $tagsInstance = PackageTagsFactory::createPackageTagsInstance();
-
- /*
- * We need to decide here which socket (TCP or UDP) should be used for
- * the actual data transmission. In this process we will find out if
- * the recipient of this package has already a known (registered) socket
- * and if so we can re-use it. If there is no socket registered, we try
- * to make a new connection (TCP or UDP) to the given IP:port.
- */
- $protocolName = $tagsInstance->chooseProtocolFromPackageData($packageData);
-
- // Return it
- return $protocolName;
- }
-
- /**
- * "Getter" for recipient iterator
- *
- * @return$iteratorInstance An instance of a Iterateable object
- */
- public final function getIterator () {
- // Get iterator from it
- $iteratorInstance = $this->getListInstance()->getIterator();
-
- // Return it
- return $iteratorInstance;
- }
-
- /**
- * Clears all recipients for e.g. another package to deliver. This method
- * simply clears the inner list instance.
- *
- * @return void
- */
- public final function clearRecipients () {
- // Clear the list
- $this->getListInstance()->clearList();
- }
-
- /**
- * Checks whether the recipient list is empty
- *
- * @return $isEmpty Whether the recipient list is empty
- */
- public final function isRecipientListEmpty () {
- // Check it ...
- $isEmpty = ($this->getListInstance()->count() == 0);
-
- // Return it
- return $isEmpty;
}
}
+++ /dev/null
-Deny from all
+++ /dev/null
-<?php
-/**
- * A DhtRecipient discovery class
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @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.shipsimu.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 DhtRecipientDiscovery extends BaseNodeDiscovery implements DiscoverableDhtRecipient, Registerable {
- /**
- * Protected constructor
- *
- * @return void
- */
- protected function __construct () {
- // Call parent constructor
- parent::__construct(__CLASS__);
- }
-
- /**
- * Create an instance of this class
- *
- * @return $discoveryInstance An instance of this discovery class
- */
- public static final function createDhtRecipientDiscovery () {
- // Get an instance of this class
- $discoveryInstance = new DhtRecipientDiscovery();
-
- // Get a DHT instance
- $dhtInstance = DhtObjectFactory::createDhtInstance('node');
-
- // Set it here
- $discoveryInstance->setDhtInstance($dhtInstance);
-
- // Return the prepared instance
- return $discoveryInstance;
- }
-
- /**
- * Resolves one or more recipients for a DHT transfer by given package data.
- *
- * @param $packageData Valid package data array
- * @return $recipients An indexed array with DHT recipients
- */
- public function resolveRecipientsByPackageData (array $packageData) {
- // Use facade to get recipients back
- $recipients = $this->getDhtInstance()->findRecipientsByPackageData($packageData);
-
- // Return it
- return $recipients;
- }
-}
-
-// [EOF]
-?>
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * A UniversalNodeLocator discovery class
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Core Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.shipsimu.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 UniversalNodeLocatorDiscovery extends BaseNodeDiscovery implements DiscoverableUniversalNodeLocator, Registerable {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+ }
+
+ /**
+ * Create an instance of this class
+ *
+ * @return $discoveryInstance An instance of this discovery class
+ */
+ public static final function createUniversalNodeLocatorDiscovery () {
+ // Get an instance of this class
+ $discoveryInstance = new UniversalNodeLocatorDiscovery();
+
+ // Return the prepared instance
+ return $discoveryInstance;
+ }
+
+ /**
+ * "Discovers" an instance of a LocateableNode class for given NodeHelper class
+ *
+ * @param $nodeInstance An instance of a NodeHelper class
+ * @return $unlInstance An instance of a LocateableNode class
+ */
+ public function discoverUniversalNodeLocatorByNode (NodeHelper $nodeInstance) {
+ /*
+ * First get an instance from the configured hub communication protocol
+ * type (which is mostly TCP, so you get a TcpProtocolResolver here).
+ */
+ $resolverInstance = ProtocolResolverFactory::createResolverFromConfiguredProtocol();
+
+ // Then resolve the node instance into an UNL instance
+ $unlInstance = $resolverInstance->resolveUniversalNodeLocatorFromNodeHelper($nodeInstance);
+
+ // ... and return it
+ return $unlInstance;
+ }
+
+ /**
+ * "Discovers" the full universal node locator for given configuration entry
+ * which should represent the address part of the UNL. In case of an IP
+ * address, this *must not* include the port number as this is being found
+ * out for you.
+ *
+ * Valid values for $configKey: internal,external
+ *
+ * @param $configKey Key for address to get (valid: internal,external)
+ * @return $unl Universal node locator
+ */
+ public function discoverUniversalNodeLocatorByConfiguredAddress ($configKey) {
+ // Debug message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('UNL-DISCOVERY[' . __METHOD__ . ':' . __LINE__ . ']:configKey=' . $configKey . ' - CALLED!');
+
+ // Is there cache?
+ if (!isset($GLOBALS[__METHOD__][$configKey])) {
+ // Validate config key
+ assert(($configKey == 'internal') || ($configKey == 'external'));
+
+ /*
+ * First get an instance from the configured hub communication protocol
+ * type (which is mostly TCP, so you get a TcpProtocolResolver here).
+ */
+ $resolverInstance = ProtocolResolverFactory::createResolverFromConfiguredProtocol();
+
+ // Get back the full UNL
+ $GLOBALS[__METHOD__][$configKey] = $resolverInstance->resolveUniversalNodeLocatorFromConfigKey($configKey);
+ } // END - if
+
+ // Return cached value
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('UNL-DISCOVERY[' . __METHOD__ . ':' . __LINE__ . ']:configKey=' . $configKey . ',unl=' . $GLOBALS[__METHOD__][$configKey] . ' - EXIT!');
+ return $GLOBALS[__METHOD__][$configKey];
+ }
+}
+
+// [EOF]
+?>
+++ /dev/null
-Deny from all
+++ /dev/null
-<?php
-/**
- * A PackageRecipient discovery class
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @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.shipsimu.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 PackageRecipientDiscovery extends BaseNodeDiscovery implements DiscoverableNodeRecipient, Registerable {
- /**
- * Protected constructor
- *
- * @return void
- */
- protected function __construct () {
- // Call parent constructor
- parent::__construct(__CLASS__);
- }
-
- /**
- * Create an instance of this class
- *
- * @return $discoveryInstance An instance of this discovery class
- */
- public static final function createPackageRecipientDiscovery () {
- // Get an instance of this class
- $discoveryInstance = new PackageRecipientDiscovery();
-
- // Return the prepared instance
- return $discoveryInstance;
- }
-
- /**
- * Tries to discover all recipients for given package data
- *
- * @param $packageData Raw package data array
- * @return void
- */
- public function discoverRecipients (array $packageData) {
- // This must be available
- //* DEBUG: */ print $this->__toString() . ': packageData=' . print_r($packageData, TRUE);
- assert(isset($packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT]));
-
- // First try out the direct recipient (session id)
- try {
- // Get instance (should not break)
- $recipientInstance = ObjectFactory::createObjectByConfiguredName('direct_recipient_class');
-
- // Try to solve it
- $recipientInstance->resolveRecipient($packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT], $this->getListInstance(), $packageData);
- } catch (FrameworkException $e) {
- // Didn't work, so try the non-generic, depending recipient field itself (this may fail)
- try {
- // Try to find the right class
- $recipientInstance = ObjectFactory::createObjectByConfiguredName(strtolower($packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT]) . '_recipient_class');
-
- // And try to solve again
- $recipientInstance->resolveRecipient($packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT], $this->getListInstance(), $packageData);
- } catch (FrameworkException $e) {
- // Could not find class, what ever failed
- $this->debugInstance($e->getMessage());
- }
- }
- }
-
- /**
- * Tries to discover all recipients by given decoded package data.
- *
- * @param $decodedData Raw raw package data array
- * @return void
- * @todo Add some validation of recipient field, e.g. ip:port is found
- * @todo The if() does only check for TCP, not UDP, e.g. try to get a $handlerInstance here
- */
- public function discoverRawRecipients (array $decodedData) {
- // This must be available
- assert(isset($decodedData[NetworkPackage::PACKAGE_DATA_RECIPIENT]));
-
- // First clear all recipients
- $this->clearRecipients();
-
- // Explode 'recipient', first element is the IP/hostname
- $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_listen_port'))) || ($recipient[0] == $this->getConfigInstance()->getServerAddress())) {
- /*
- * 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.
- */
-
- // Debug output (may flood)
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('RECIPIENT-DISCOVERY[' . __METHOD__ . ':' . __LINE__ . ']: Recipient ' . $recipient[0] . ' matches own ip (' . HubTools::determineOwnExternalIp() . ' or ' . $this->getConfigInstance()->getServerAddress() . ')');
- } else {
- // Debug output (may flood)
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('RECIPIENT-DISCOVERY[' . __METHOD__ . ':' . __LINE__ . ']: Recipient ' . $recipient[0] . ' is different than own external ip (' . HubTools::determineOwnExternalIp() . ') nor internal ip (' . $this->getConfigInstance()->getServerAddress() . '), need to forward (not yet implemented)!');
-
- // This package is to be delivered to someone else, so add it
- $this->getListInstance()->addEntry('ip_port', $decodedData[NetworkPackage::PACKAGE_DATA_RECIPIENT]);
- }
- }
-}
-
-// [EOF]
-?>
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * A Protocol discovery class
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Core Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.shipsimu.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 ProtocolDiscovery extends BaseNodeDiscovery implements DiscoverableProtocol, Registerable {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+ }
+
+ /**
+ * Create an instance of this class
+ *
+ * @return $discoveryInstance An instance of this discovery class
+ */
+ public static final function createProtocolDiscovery () {
+ // Get an instance of this class
+ $discoveryInstance = new ProtocolDiscovery();
+
+ // Return the prepared instance
+ return $discoveryInstance;
+ }
+
+ /**
+ * "Discovers" the protocol type from given raw package data. This is done
+ * by looking at the 'recipient' field and extract the first part from it.
+ *
+ * @param $packageData Raw package data
+ * @return $protocolType Type of protocol, e.g. 'tcp' for TCP/IPv4 connections
+ */
+ public function discoverProtocolByPackageData (array $packageData) {
+ //* DEBUG: */ die(__METHOD__ . ':packageData=' . print_r($packageData, TRUE));
+
+ /*
+ * "Explode" the 'recipient' array element into a new one, giving at
+ * least two entries: protocol://address
+ */
+ $recipient = explode(':', $packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT]);
+
+ // At least 2 entries must be found
+ assert(count($recipient) >= 2);
+
+ // Now get the first part (protocol type) and make all lower-case
+ $protocolType = strtolower($recipient[0]);
+
+ // Return it
+ // @TODO Add some validation here???
+ return $protocolType;
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * A !!! recipient discovery class
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Core Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.shipsimu.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 !!!RecipientDiscovery extends BaseRecipientDiscovery implements Discoverable,,,Recipient, Registerable {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+ }
+
+ /**
+ * Create an instance of this class
+ *
+ * @return $discoveryInstance An instance of this discovery class
+ */
+ public static final function create!!!Discovery () {
+ // Get an instance of this class
+ $discoveryInstance = new !!!Discovery();
+
+ // Return the prepared instance
+ return $discoveryInstance;
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+<?php
+/**
+ * A PackageRecipient discovery class
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Core Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.shipsimu.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 BaseRecipientDiscovery extends BaseNodeDiscovery implements DiscoverableRecipient {
+ /**
+ * Protected constructor
+ *
+ * @param $className Real class name
+ * @return void
+ */
+ protected function __construct ($className) {
+ // Call parent constructor
+ parent::__construct($className);
+
+ /*
+ * Get recipients list instance and set it here for all discovery
+ * implementations.
+ */
+ $listInstance = RecipientListFactory::createRecipientListInstance();
+ $this->setListInstance($listInstance);
+ }
+
+ /**
+ * Determines the protoctol name
+ *
+ * @param $packageData Valid package data
+ * @return $protocolInstance An instance of a HandleableProtocol class
+ */
+ protected function determineProtocolByPackageData (array $packageData) {
+ // First we need a tags instance
+ $tagsInstance = PackageTagsFactory::createPackageTagsInstance();
+
+ /*
+ * We need to decide here which socket (TCP or UDP) should be used for
+ * the actual data transmission. In this process we will find out if
+ * the recipient of this package has already a known (registered) socket
+ * and if so we can re-use it. If there is no socket registered, we try
+ * to make a new connection to the given Universal Node Locator.
+ */
+ $protocolInstance = $tagsInstance->chooseProtocolFromPackageData($packageData);
+
+ // Return it
+ return $protocolInstance;
+ }
+
+ /**
+ * "Getter" for recipient iterator
+ *
+ * @return$iteratorInstance An instance of a Iterateable object
+ */
+ public final function getIterator () {
+ // Get iterator from it
+ $iteratorInstance = $this->getListInstance()->getIterator();
+
+ // Return it
+ return $iteratorInstance;
+ }
+
+ /**
+ * Clears all recipients for e.g. another package to deliver. This method
+ * simply clears the inner list instance.
+ *
+ * @return void
+ */
+ public final function clearRecipients () {
+ // Clear the list
+ $this->getListInstance()->clearList();
+ }
+
+ /**
+ * Checks whether the recipient list is empty
+ *
+ * @return $isEmpty Whether the recipient list is empty
+ */
+ public final function isRecipientListEmpty () {
+ // Check it ...
+ $isEmpty = ($this->getListInstance()->count() == 0);
+
+ // Return it
+ return $isEmpty;
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * A DhtRecipient discovery class
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Core Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.shipsimu.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 DhtRecipientDiscovery extends BaseRecipientDiscovery implements DiscoverableDhtRecipient, Registerable {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+ }
+
+ /**
+ * Create an instance of this class
+ *
+ * @return $discoveryInstance An instance of this discovery class
+ */
+ public static final function createDhtRecipientDiscovery () {
+ // Get an instance of this class
+ $discoveryInstance = new DhtRecipientDiscovery();
+
+ // Get a DHT instance
+ $dhtInstance = DhtObjectFactory::createDhtInstance('node');
+
+ // Set it here
+ $discoveryInstance->setDhtInstance($dhtInstance);
+
+ // Return the prepared instance
+ return $discoveryInstance;
+ }
+
+ /**
+ * Resolves one or more recipients for a DHT transfer by given package data.
+ *
+ * @param $packageData Valid package data array
+ * @return $recipients An indexed array with DHT recipients
+ */
+ public function resolveRecipientsByPackageData (array $packageData) {
+ // Use facade to get recipients back
+ $recipients = $this->getDhtInstance()->findRecipientsByPackageData($packageData);
+
+ // Return it
+ return $recipients;
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * A PackageRecipient discovery class
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Core Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.shipsimu.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 PackageRecipientDiscovery extends BaseRecipientDiscovery implements DiscoverableNodeRecipient, Registerable {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+ }
+
+ /**
+ * Create an instance of this class
+ *
+ * @return $discoveryInstance An instance of this discovery class
+ */
+ public static final function createPackageRecipientDiscovery () {
+ // Get an instance of this class
+ $discoveryInstance = new PackageRecipientDiscovery();
+
+ // Return the prepared instance
+ return $discoveryInstance;
+ }
+
+ /**
+ * Tries to discover all recipients for given package data
+ *
+ * @param $packageData Raw package data array
+ * @return void
+ */
+ public function discoverRecipients (array $packageData) {
+ // This must be available
+ //* DEBUG: */ print $this->__toString() . ': packageData=' . print_r($packageData, TRUE);
+ assert(isset($packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT]));
+
+ // First try out the direct recipient (session id)
+ try {
+ // Get instance (should not break)
+ $recipientInstance = ObjectFactory::createObjectByConfiguredName('direct_recipient_class');
+
+ // Try to solve it
+ $recipientInstance->resolveRecipient($packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT], $this->getListInstance(), $packageData);
+ } catch (FrameworkException $e) {
+ // Didn't work, so try the non-generic, depending recipient field itself (this may fail)
+ try {
+ // Try to find the right class
+ $recipientInstance = ObjectFactory::createObjectByConfiguredName(strtolower($packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT]) . '_recipient_class');
+
+ // And try to solve again
+ $recipientInstance->resolveRecipient($packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT], $this->getListInstance(), $packageData);
+ } catch (FrameworkException $e) {
+ // Could not find class, what ever failed
+ $this->debugInstance($e->getMessage());
+ }
+ }
+ }
+
+ /**
+ * Tries to discover all recipients by given decoded package data.
+ *
+ * @param $decodedData Raw raw package data array
+ * @return void
+ * @todo Add some validation of recipient field, e.g. an Universal Node Locator is found
+ * @todo The if() does only check for TCP, not UDP, e.g. try to get a $handlerInstance here
+ */
+ public function discoverRawRecipients (array $decodedData) {
+ // This must be available
+ die(__METHOD__ . ': Unfinished' . PHP_EOL);
+ assert(isset($decodedData[NetworkPackage::PACKAGE_DATA_RECIPIENT]));
+
+ // First clear all recipients
+ $this->clearRecipients();
+
+ // Explode 'recipient', first element is the IP/hostname
+ $recipient = explode(':', $decodedData[NetworkPackage::PACKAGE_DATA_RECIPIENT]);
+
+ // Is the 'recipient' field same as this peer's IP?
+ if ((($recipient[0] == HubTools::determineOwnExternalAddress()) && ($recipient[1] == $this->getConfigInstance()->getConfigEntry('node_listen_port'))) || ($recipient[0] == $this->getConfigInstance()->getServerAddress())) {
+ /*
+ * Is same as own external address + TCP/UDP listen port or
+ * internal address, don't do anything here so other classes found
+ * an empty recipient list for internal (own) handling of the
+ * original content.
+ */
+
+ // Debug output (may flood)
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('RECIPIENT-DISCOVERY[' . __METHOD__ . ':' . __LINE__ . ']: Recipient ' . $recipient[0] . ' matches own ip (' . HubTools::determineOwnExternalAddress() . ' or ' . $this->getConfigInstance()->getServerAddress() . ')');
+ } else {
+ // Debug output (may flood)
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('RECIPIENT-DISCOVERY[' . __METHOD__ . ':' . __LINE__ . ']: Recipient ' . $recipient[0] . ' is different than own external address (' . HubTools::determineOwnExternalAddress() . ') nor internal address (' . $this->getConfigInstance()->getServerAddress() . '), need to forward (not yet implemented)!');
+
+ // This package is to be delivered to someone else, so add it
+ $this->getListInstance()->addEntry('unl', $decodedData[NetworkPackage::PACKAGE_DATA_RECIPIENT]);
+ }
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * A socket discovery class
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Core Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.shipsimu.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 PackageSocketDiscovery extends BaseRecipientDiscovery implements DiscoverableSocket, Registerable {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+ }
+
+ /**
+ * Create an instance of this class
+ *
+ * @return $discoveryInstance An instance of this discovery class
+ */
+ public static final function createPackageSocketDiscovery () {
+ // Get an instance of this class
+ $discoveryInstance = new PackageSocketDiscovery();
+
+ // Output debug message
+ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-DISCOVERY[' . __METHOD__ . ':' . __LINE__ . ']: Initialized.');
+
+ // Return the prepared instance
+ return $discoveryInstance;
+ }
+
+ /**
+ * Tries to dicover the right listener instance
+ *
+ * @param $protocolName Protocol name
+ * @param $packageData Raw package data
+ * @return $listenerInstance An instance of a Listenable instance or null
+ */
+ public function discoverListenerInstance ($protocolName, array $packageData) {
+ // Debug message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-DISCOVERY[' . __METHOD__ . ':' . __LINE__ . ']: protocolName=' . $protocolName . ' - ENTERED!');
+
+ /*
+ * Get the listener pool instance, we need to lookup the matching
+ * listener->poolInstance chain there.
+ */
+ $poolInstance = NodeObjectFactory::createNodeInstance()->getListenerPoolInstance();
+
+ // Init listener instance
+ $listenerInstance = NULL;
+
+ /*
+ * Now we need to choose again. It is whether we are speaking with a hub
+ * or with a client. So just handle it over to all listeners in this
+ * pool.
+ */
+ foreach ($poolInstance->getPoolEntriesInstance()->getArrayFromGroup($protocolName) as $listenerInstance) {
+ // Debug output
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-DISCOVERY[' . __METHOD__ . ':' . __LINE__ . ']: protocolName=' . $protocolName . ',listenerInstance=' . $listenerInstance->__toString());
+
+ // Does the listener want that package?
+ if ($listenerInstance->ifListenerAcceptsPackageData($packageData)) {
+ // This listener likes our package data, so abort here
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-DISCOVERY[' . __METHOD__ . ':' . __LINE__ . ']: Listener is accepting package data.');
+ break;
+ } // END - if
+
+ // Debug output
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-DISCOVERY[' . __METHOD__ . ':' . __LINE__ . ']: Listener is NOT accepting package data.');
+ } // END - foreach
+
+ // Return it
+ return $listenerInstance;
+ }
+
+ /**
+ * Tries to discover the right socket for given package data and returns a
+ * matching socket resource for that protocol.
+ *
+ * @param $packageData Raw package data array
+ * @param $connectionType Type of connection, can be 'incoming' or 'outgoing', *NEVER* 'server'!
+ * @return $socketResource A valid socket resource or FALSE if an error occured
+ * @throws NoListGroupException If the procol group is not found in peer list
+ * @throws NullPointerException If listenerInstance is NULL
+ */
+ public function discoverSocket (array $packageData, $connectionType) {
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: connectionType=' . $connectionType . ' - CALLED!');
+
+ // Assert on type
+ assert($connectionType != BaseConnectionHelper::CONNECTION_TYPE_SERVER);
+
+ // Determine protocol name
+ $protocolName = $this->determineProtocolByPackageData($packageData);
+
+ // Is it the same?
+ assert(strtoupper($protocolName) == $packageData[NetworkPackage::PACKAGE_DATA_PROTOCOL]);
+
+ // Get the listener instance
+ $listenerInstance = $this->discoverListenerInstance($protocolName, $packageData);
+
+ // If there is no listener who wants to have that package, we simply drop it here
+ if (is_null($listenerInstance)) {
+ // Abort with no resource
+ throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER);
+ } // END - if
+
+ // Debug message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('protocolName=' . $protocolName . ',packageData=' . print_r($packageData, TRUE));
+
+ /*
+ * Now we have the listener instance, we can determine the right
+ * resource to continue. The first step is to get the attached pool
+ * instance and pass over the whole package data to get the right
+ * socket.
+ */
+ $socketResource = $listenerInstance->getPoolInstance()->getSocketFromPackageData($packageData, $connectionType);
+
+ // Debug message
+ if (is_resource($socketResource)) {
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('socketResource[' . gettype($socketResource) . ']=' . $socketResource . ',error=' . socket_strerror(socket_last_error($socketResource)) . ',packageData=' . print_r($packageData, TRUE));
+ } else {
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('socketResource[' . gettype($socketResource) . ']=' . $socketResource . ',packageData=' . print_r($packageData, TRUE));
+ }
+
+ // Is it FALSE, the recipient isn't known to us and we have no connection to it
+ if (($socketResource === FALSE) || (!is_resource($socketResource)) || (socket_last_error($socketResource) > 0)) {
+ // Try to create a new socket resource
+ try {
+ // Possibly noisy debug message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-DISCOVERY[' . __METHOD__ . ':' . __LINE__ . ']: Trying to establish a ' . strtoupper($protocolName) . ' connection to ' . $packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT] . ' ...');
+
+ // Get a socket resource from our factory (if succeeded)
+ $socketResource = SocketFactory::createSocketFromPackageData($packageData, $protocolName);
+ } catch (SocketConnectionException $e) {
+ // The connection fails of being established, so log it away
+ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-DISCOVERY[' . __METHOD__ . ':' . __LINE__ . ']: Caught ' . $e->__toString() . ',message=' . $e->getMessage());
+ }
+ } // END - if
+
+ // Try to resolve the socket resource
+ try {
+ // Get the helper instance from registry
+ $helperInstance = Registry::getRegistry()->getInstance('connection');
+
+ // Possibly noisy debug message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-DISCOVERY[' . __METHOD__ . ':' . __LINE__ . ']: Going to resolve socket from peer state and given package data ...');
+
+ // Resolve the peer's state (but ignore return value)
+ PeerStateResolver::resolveStateByPackage($helperInstance, $packageData, $socketResource);
+ } catch (InvalidSocketException $e) {
+ // This cannot be fixed, so log it away
+ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-DISCOVERY[' . __METHOD__ . ':' . __LINE__ . ']: Cannot discover socket resource for recipient ' . $packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT] . ': ' . $e->getMessage());
+
+ // Make any failed attempts to 'FALSE'
+ $socketResource = FALSE;
+ }
+
+ // And return it
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-DISCOVERY[' . __METHOD__ . ':' . __LINE__ . ']: socketResource=' . $socketResource . ',packageData=' . print_r($packageData, TRUE));
+ return $socketResource;
+ }
+}
+
+// [EOF]
+?>
+++ /dev/null
-Deny from all
+++ /dev/null
-<?php
-/**
- * A socket discovery class
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @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.shipsimu.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 PackageSocketDiscovery extends BaseNodeDiscovery implements DiscoverableSocket, Registerable {
- /**
- * Protected constructor
- *
- * @return void
- */
- protected function __construct () {
- // Call parent constructor
- parent::__construct(__CLASS__);
- }
-
- /**
- * Create an instance of this class
- *
- * @return $discoveryInstance An instance of this discovery class
- */
- public static final function createPackageSocketDiscovery () {
- // Get an instance of this class
- $discoveryInstance = new PackageSocketDiscovery();
-
- // Output debug message
- self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-DISCOVERY[' . __METHOD__ . ':' . __LINE__ . ']: Initialized.');
-
- // Return the prepared instance
- return $discoveryInstance;
- }
-
- /**
- * Tries to dicover the right listener instance
- *
- * @param $protocolName Protocol name
- * @param $packageData Raw package data
- * @return $listenerInstance An instance of a Listenable instance or null
- */
- public function discoverListenerInstance ($protocolName, array $packageData) {
- // Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-DISCOVERY[' . __METHOD__ . ':' . __LINE__ . ']: protocolName=' . $protocolName . ' - ENTERED!');
-
- /*
- * Get the listener pool instance, we need to lookup the matching
- * listener->poolInstance chain there.
- */
- $poolInstance = NodeObjectFactory::createNodeInstance()->getListenerPoolInstance();
-
- // Init listener instance
- $listenerInstance = NULL;
-
- /*
- * Now we need to choose again. It is whether we are speaking with a hub
- * or with a client. So just handle it over to all listeners in this
- * pool.
- */
- foreach ($poolInstance->getPoolEntriesInstance()->getArrayFromGroup($protocolName) as $listenerInstance) {
- // Debug output
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-DISCOVERY[' . __METHOD__ . ':' . __LINE__ . ']: protocolName=' . $protocolName . ',listenerInstance=' . $listenerInstance->__toString());
-
- // Does the listener want that package?
- if ($listenerInstance->ifListenerAcceptsPackageData($packageData)) {
- // This listener likes our package data, so abort here
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-DISCOVERY[' . __METHOD__ . ':' . __LINE__ . ']: Listener is accepting package data.');
- break;
- } // END - if
-
- // Debug output
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-DISCOVERY[' . __METHOD__ . ':' . __LINE__ . ']: Listener is NOT accepting package data.');
- } // END - foreach
-
- // Return it
- return $listenerInstance;
- }
-
- /**
- * Tries to discover the right socket for given package data and returns a
- * matching socket resource for that protocol.
- *
- * @param $packageData Raw package data array
- * @param $connectionType Type of connection, can be 'incoming' or 'outgoing', *NEVER* 'server'!
- * @return $socketResource A valid socket resource or FALSE if an error occured
- * @throws NoListGroupException If the procol group is not found in peer list
- * @throws NullPointerException If listenerInstance is NULL
- */
- public function discoverSocket (array $packageData, $connectionType) {
- // Assert on type
- assert($connectionType != BaseConnectionHelper::CONNECTION_TYPE_SERVER);
-
- // Determine protocol name
- $protocolName = $this->determineProtocolByPackageData($packageData);
-
- // Is it the same?
- assert(strtoupper($protocolName) == $packageData[NetworkPackage::PACKAGE_DATA_PROTOCOL]);
-
- // Get the listener instance
- $listenerInstance = $this->discoverListenerInstance($protocolName, $packageData);
-
- // If there is no listener who wants to have that package, we simply drop it here
- if (is_null($listenerInstance)) {
- // Abort with no resource
- throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER);
- } // END - if
-
- // Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('protocolName=' . $protocolName . ',packageData=' . print_r($packageData, TRUE));
-
- /*
- * Now we have the listener instance, we can determine the right
- * resource to continue. The first step is to get the attached pool
- * instance and pass over the whole package data to get the right
- * socket.
- */
- $socketResource = $listenerInstance->getPoolInstance()->getSocketFromPackageData($packageData, $connectionType);
-
- // Debug message
- if (is_resource($socketResource)) {
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('socketResource[' . gettype($socketResource) . ']=' . $socketResource . ',error=' . socket_strerror(socket_last_error($socketResource)) . ',packageData=' . print_r($packageData, TRUE));
- } else {
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('socketResource[' . gettype($socketResource) . ']=' . $socketResource . ',packageData=' . print_r($packageData, TRUE));
- }
-
- // Is it FALSE, the recipient isn't known to us and we have no connection to it
- if (($socketResource === FALSE) || (!is_resource($socketResource)) || (socket_last_error($socketResource) > 0)) {
- // Try to create a new socket resource
- try {
- // Possibly noisy debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-DISCOVERY[' . __METHOD__ . ':' . __LINE__ . ']: Trying to establish a ' . strtoupper($protocolName) . ' connection to ' . $packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT] . ' ...');
-
- // Get a socket resource from our factory (if succeeded)
- $socketResource = SocketFactory::createSocketFromPackageData($packageData, $protocolName);
- } catch (SocketConnectionException $e) {
- // The connection fails of being established, so log it away
- self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-DISCOVERY[' . __METHOD__ . ':' . __LINE__ . ']: Caught ' . $e->__toString() . ',message=' . $e->getMessage());
- }
- } // END - if
-
- // Try to resolve the socket resource
- try {
- // Get the helper instance from registry
- $helperInstance = Registry::getRegistry()->getInstance('connection');
-
- // Possibly noisy debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-DISCOVERY[' . __METHOD__ . ':' . __LINE__ . ']: Going to resolve socket from peer state and given package data ...');
-
- // Resolve the peer's state (but ignore return value)
- PeerStateResolver::resolveStateByPackage($helperInstance, $packageData, $socketResource);
- } catch (InvalidSocketException $e) {
- // This cannot be fixed, so log it away
- self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-DISCOVERY[' . __METHOD__ . ':' . __LINE__ . ']: Cannot discover socket resource for recipient ' . $packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT] . ': ' . $e->getMessage());
-
- // Make any failed attempts to 'FALSE'
- $socketResource = FALSE;
- }
-
- // And return it
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-DISCOVERY[' . __METHOD__ . ':' . __LINE__ . ']: socketResource=' . $socketResource . ',packageData=' . print_r($packageData, TRUE));
- return $socketResource;
- }
-}
-
-// [EOF]
-?>
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @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
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
}
/**
- * Returns a singleton protocol handler instance. If an instance is
- * found in registry, it will be returned, else a new instance is created
- * and stored in the same registry entry.
+ * Returns a protocol handler based on given protocol type. This is mostly 'tcp'.
*
- * @param $messageType Protocol to create an object from
+ * @param $protocolType Protocol type to create/return a protocol handler instance for
* @return $handlerInstance A protocol handler instance
*/
- public static final function createProtocolHandlerInstance ($messageType) {
+ private static function createProtocolHandlerByType ($protocolType) {
// Do we have an instance in the registry?
- if (Registry::getRegistry()->instanceExists($messageType . '_protocol_handler')) {
+ if (Registry::getRegistry()->instanceExists($protocolType . '_protocol_handler')) {
// Then use this instance
- $handlerInstance = Registry::getRegistry()->getInstance($messageType . '_protocol_handler');
+ $handlerInstance = Registry::getRegistry()->getInstance($protocolType . '_protocol_handler');
} else {
// Now prepare the tags instance
- $handlerInstance = self::createObjectByConfiguredName($messageType . '_protocol_handler_class');
+ $handlerInstance = self::createObjectByConfiguredName($protocolType . '_protocol_handler_class');
// Set the instance in registry for further use
- Registry::getRegistry()->addInstance($messageType . '_protocol_handler', $handlerInstance);
+ Registry::getRegistry()->addInstance($protocolType . '_protocol_handler', $handlerInstance);
}
// Return the instance
return $handlerInstance;
}
+
+ /**
+ * Returns a singleton protocol handler instance from given HubHelper
+ * instance. If an instance is found in registry, it will be returned, else
+ * a new instance is created and stored in the same registry entry.
+ *
+ * @param $helperInstance An instance of a HubHelper class
+ * @return $handlerInstance A protocol handler instance
+ */
+ public static final function createProtocolHandlerFromRecipientHelper (HubHelper $helperInstance) {
+ // Get the protocol type from given helper instance
+ $protocolType = $helperInstance->determineProtocolType();
+
+ // Call super factory method
+ return self::createProtocolHandlerByType($protocolType);
+ }
+
+ /**
+ * Creates an instance of a protocol handler from given (raw) package data
+ *
+ * @param $packageData An array with raw package data
+ * @return $handlerInstance A protocol handler instance
+ */
+ public static final function createProtocolHandlerFromPackageData (array $packageData) {
+ // Now that there is no direct node instance available, a protocol discovery class is required
+ $discoveryInstance = ObjectFactory::createObjectByConfiguredName('protocol_discovery_class');
+
+ // "Discover" the protocol type
+ $protocolType = $discoveryInstance->discoverProtocolByPackageData($packageData);
+
+ // Call super factory method
+ return self::createProtocolHandlerByType($protocolType);
+ }
}
// [EOF]
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @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
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * A factory class for ProtocolResolver
+ *
+ * @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 ProtocolResolverFactory extends ObjectFactory {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+ }
+
+ /**
+ * Returns a singleton (registry-based) ProtocolResolver instance
+ *
+ * @return $resolverInstance An instance of a ProtocolResolver class
+ */
+ public static final function createResolverFromConfiguredProtocol () {
+ // Get the configured protocol
+ $protocolName = FrameworkConfiguration::getSelfInstance()->getConfigEntry('hub_communication_protocol_type');
+
+ // If there is no handler?
+ if (Registry::getRegistry()->instanceExists($protocolName . '_protocol_resolver')) {
+ // Get handler from registry
+ $resolverInstance = Registry::getRegistry()->getInstance($protocolName . '_protocol_resolver');
+ } else {
+ // Get the handler instance
+ $resolverInstance = self::createObjectByConfiguredName($protocolName . '_protocol_resolver_class');
+
+ // Add it to the registry
+ Registry::getRegistry()->addInstance($protocolName . '_protocol_resolver', $resolverInstance);
+ }
+
+ // Return the instance
+ return $resolverInstance;
+ }
+}
+
+// [EOF]
+?>
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @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
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
* @todo Find an interface for hub helper
* Creates a valid socket resource from given packae data and protocol
*
* @param $packageData Raw package data
- * @param $protocolName Protocol name (TCP/UDP)
+ * @param $protocolInstance An instance of a HandleableProtocol class
* @return $socketResource Socket resource
*/
- public static function createSocketFromPackageData (array $packageData, $protocolName) {
+ public static function createSocketFromPackageData (array $packageData, HandleableProtocol $protocolInstance) {
// Get an instance
$factoryInstance = new SocketFactory();
// Construct registry key
- $registryKey = 'socket_' . $protocolName . '_' . $packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT];
+ $registryKey = 'socket_' . $protocolInstance->getProtocolName() . '_' . $packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT];
// Debug message
//*NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-FACTORY[' . __METHOD__ . ':' . __LINE__ . ']: Trying to find a socket with registryKey=' . $registryKey);
//*NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-FACTORY[' . __METHOD__ . ':' . __LINE__ . ']: Using socket ' . $socketResource . '(' . gettype($socketResource) . ') from registry.');
} else {
// Construct configuration entry for object factory and get it
- $className = FrameworkConfiguration::getSelfInstance()->getConfigEntry($protocolName . '_connection_helper_class');
+ $className = FrameworkConfiguration::getSelfInstance()->getConfigEntry($protocolInstance->getProtocolName() . '_connection_helper_class');
// Debug message
//*NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-FACTORY[' . __METHOD__ . ':' . __LINE__ . ']: Going to use class ' . $className . ' for creating a socket resource ...');
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @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
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @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
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @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
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @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
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @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
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
// Init array
$this->dataXmlNodes = array(
- XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_EXTERNAL_IP => '',
- XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_INTERNAL_IP => '',
- XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_NODE_STATUS => '',
- XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_SESSION_ID => '',
- XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_LISTEN_PORT => 9060,
- BaseXmlAnswerTemplateEngine::ANSWER_STATUS => '',
+ XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_EXTERNAL_ADDRESS => '',
+ XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_INTERNAL_ADDRESS => '',
+ XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_NODE_STATUS => '',
+ XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_SESSION_ID => '',
+ BaseXmlAnswerTemplateEngine::ANSWER_STATUS => '',
);
}
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
// Init array
$this->dataXmlNodes = array(
- XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_EXTERNAL_IP => '',
- XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_INTERNAL_IP => '',
- XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_NODE_STATUS => '',
- XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_NODE_MODE => '',
- XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_SESSION_ID => '',
- XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_LISTEN_PORT => 9060,
+ XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_EXTERNAL_ADDRESS => '',
+ XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_INTERNAL_ADDRESS => '',
+ XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_NODE_STATUS => '',
+ XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_NODE_MODE => '',
+ XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_SESSION_ID => ''
);
}
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
// Init array
$this->dataXmlNodes = array(
- XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_EXTERNAL_IP => '',
- XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_INTERNAL_IP => '',
- 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,
+ XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_EXTERNAL_ADDRESS => '',
+ XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_INTERNAL_ADDRESS => '',
+ XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_NODE_STATUS => '',
+ XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_NODE_MODE => '',
+ XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_SESSION_ID => '',
);
}
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
// Init array
$this->searchData = array(
XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_SESSION_ID,
- XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_EXTERNAL_IP,
- XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_LISTEN_PORT
+ XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_EXTERNAL_ADDRESS,
);
// Set handler name
*
* The following array is being handled over:
*
- * my-external-ip => 1.2.3.4
- * my-internal-ip => 5.6.7.8
- * my-status => reachable
- * my-session-id => aaabbbcccdddeeefff123456789
- * my-tcp-port => 9060
- * my-udp-port => 9060
- * answer-status => OKAY
- * message_type => announcement_answer
+ * my-external-address => 1.2.3.4
+ * my-internal-address => 5.6.7.8
+ * my-status => reachable
+ * my-session-id => aaabbbcccdddeeefff123456789
+ * my-tcp-port => 9060
+ * my-udp-port => 9060
+ * answer-status => OKAY
+ * message_type => announcement_answer
*
* @param $messageData An array with all message data
* @return void
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @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
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
* 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 BaseHandler extends BaseHubSystem implements Handleable {
+class BaseHandler extends BaseHubSystem implements HandleableDataSet {
/**
* Handler name
*/
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
// Init message data array
$this->messageDataElements = array(
- XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_EXTERNAL_IP,
- XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_INTERNAL_IP,
+ XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_EXTERNAL_ADDRESS,
+ 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,
);
// Init message-data->configuration translation array
$this->messageToConfig = array(
- XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_EXTERNAL_IP => 'your_external_ip',
- XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_INTERNAL_IP => 'your_internal_ip',
- XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_SESSION_ID => 'your_session_id'
+ XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_EXTERNAL_ADDRESS => 'your_external_address',
+ XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_INTERNAL_ADDRESS => 'your_internal_address',
+ XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_SESSION_ID => 'your_session_id'
);
// Init config-copy array
$this->configCopy = array(
- XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_EXTERNAL_IP => 'external_ip',
- XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_INTERNAL_IP => 'internal_ip',
- XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_NODE_STATUS => 'node_status',
- XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_SESSION_ID => 'session_id',
- XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_LISTEN_PORT => 'node_listen_port',
+ XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_EXTERNAL_ADDRESS => 'external_address',
+ XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_INTERNAL_ADDRESS => 'internal_address',
+ XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_NODE_STATUS => 'node_status',
+ XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_SESSION_ID => 'session_id',
);
// Init array
$this->searchData = array(
- XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_EXTERNAL_IP,
- XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_LISTEN_PORT
+ XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_EXTERNAL_ADDRESS
);
}
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
// Init message data array
$this->messageDataElements = array(
- XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_EXTERNAL_IP,
- XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_INTERNAL_IP,
+ XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_EXTERNAL_ADDRESS,
+ XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_INTERNAL_ADDRESS,
XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_NODE_STATUS,
XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_SESSION_ID,
- XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_LISTEN_PORT,
BaseXmlAnswerTemplateEngine::ANSWER_STATUS,
);
// Init message-data->configuration translation array
$this->messageToConfig = array(
/*
- XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_EXTERNAL_IP => 'your_external_ip',
- XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_INTERNAL_IP => 'your_internal_ip',
- XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_SESSION_ID => 'your_session_id'
+ XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_EXTERNAL_ADDRESS => 'your_external_address',
+ XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_INTERNAL_ADDRESS => 'your_internal_address',
+ XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_SESSION_ID => 'your_session_id'
*/
);
// Init config-copy array
$this->configCopy = array(
- XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_EXTERNAL_IP => 'external_ip',
- XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_INTERNAL_IP => 'internal_ip',
- XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_NODE_STATUS => 'node_status',
- XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_SESSION_ID => 'session_id',
- XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_LISTEN_PORT => 'node_listen_port',
+ XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_EXTERNAL_ADDRESS => 'external_address',
+ XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_INTERNAL_ADDRESS => 'internal_address',
+ XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_NODE_STATUS => 'node_status',
+ XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_SESSION_ID => 'session_id',
);
// Init array
$this->searchData = array(
XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_SESSION_ID,
- XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_EXTERNAL_IP,
- XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_LISTEN_PORT
+ XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_EXTERNAL_ADDRESS,
);
}
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
// Init message data array
$this->messageDataElements = array(
- XmlDhtBootstrapAnswerTemplateEngine::DHT_BOOTSTRAP_DATA_EXTERNAL_IP,
- XmlDhtBootstrapAnswerTemplateEngine::DHT_BOOTSTRAP_DATA_INTERNAL_IP,
+ XmlDhtBootstrapAnswerTemplateEngine::DHT_BOOTSTRAP_DATA_EXTERNAL_ADDRESS,
+ 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,
);
// Init message-data->configuration translation array
$this->messageToConfig = array(
/*
- XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_EXTERNAL_IP => 'your_external_ip',
- XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_INTERNAL_IP => 'your_internal_ip',
- XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_SESSION_ID => 'your_session_id'
+ XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_EXTERNAL_ADDRESS => 'your_external_address',
+ XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_INTERNAL_ADDRESS => 'your_internal_address',
+ XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_SESSION_ID => 'your_session_id'
*/
);
// Init config-copy array
$this->configCopy = array(
- XmlDhtBootstrapAnswerTemplateEngine::DHT_BOOTSTRAP_DATA_EXTERNAL_IP => 'external_ip',
- XmlDhtBootstrapAnswerTemplateEngine::DHT_BOOTSTRAP_DATA_INTERNAL_IP => 'internal_ip',
- 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',
+ XmlDhtBootstrapAnswerTemplateEngine::DHT_BOOTSTRAP_DATA_EXTERNAL_ADDRESS => 'external_address',
+ XmlDhtBootstrapAnswerTemplateEngine::DHT_BOOTSTRAP_DATA_INTERNAL_ADDRESS => 'internal_address',
+ XmlDhtBootstrapAnswerTemplateEngine::DHT_BOOTSTRAP_DATA_NODE_STATUS => 'node_status',
+ XmlDhtBootstrapAnswerTemplateEngine::DHT_BOOTSTRAP_DATA_SESSION_ID => 'session_id',
);
// Init array
$this->searchData = array(
XmlDhtBootstrapAnswerTemplateEngine::DHT_BOOTSTRAP_DATA_SESSION_ID,
- XmlDhtBootstrapAnswerTemplateEngine::DHT_BOOTSTRAP_DATA_EXTERNAL_IP,
- XmlDhtBootstrapAnswerTemplateEngine::DHT_BOOTSTRAP_DATA_LISTEN_PORT
+ XmlDhtBootstrapAnswerTemplateEngine::DHT_BOOTSTRAP_DATA_EXTERNAL_ADDRESS,
);
}
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @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
*
// Init message data array
$this->messageDataElements = array(
- Xml???TemplateEngine::!!!_DATA_EXTERNAL_IP,
+ Xml???TemplateEngine::!!!_DATA_EXTERNAL_ADDRESS,
Xml???TemplateEngine::!!!_DATA_NODE_STATUS,
Xml???TemplateEngine::!!!_DATA_SESSION_ID,
Xml???TemplateEngine::!!!_DATA_LISTEN_PORT,
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
* following data must always be present:
*
* - session-id (for finding the node's record together with below data)
- * - external-ip (hostname or IP number)
+ * - external-address (hostname or IP number)
* - listen-port (TCP/UDP listen port for inbound connections)
*
* @param $messageArray An array with all minimum message data
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
// Init message data array
$this->messageDataElements = array(
- XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_EXTERNAL_IP,
- XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_INTERNAL_IP,
+ XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_EXTERNAL_ADDRESS,
+ XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_INTERNAL_ADDRESS,
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
$this->messageToConfig = array(
- XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_EXTERNAL_IP => 'your_external_ip',
- XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_INTERNAL_IP => 'your_internal_ip',
- XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_SESSION_ID => 'your_session_id'
+ XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_EXTERNAL_ADDRESS => 'your_external_address',
+ XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_INTERNAL_ADDRESS => 'your_internal_address',
+ XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_SESSION_ID => 'your_session_id'
);
// Init config-copy array
$this->configCopy = array(
- XmlDhtBootstrapAnswerTemplateEngine::DHT_BOOTSTRAP_DATA_EXTERNAL_IP => 'external_ip',
- XmlDhtBootstrapAnswerTemplateEngine::DHT_BOOTSTRAP_DATA_INTERNAL_IP => 'internal_ip',
- 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',
+ XmlDhtBootstrapAnswerTemplateEngine::DHT_BOOTSTRAP_DATA_EXTERNAL_ADDRESS => 'external_address',
+ XmlDhtBootstrapAnswerTemplateEngine::DHT_BOOTSTRAP_DATA_INTERNAL_ADDRESS => 'internal_address',
+ XmlDhtBootstrapAnswerTemplateEngine::DHT_BOOTSTRAP_DATA_NODE_STATUS => 'node_status',
+ XmlDhtBootstrapAnswerTemplateEngine::DHT_BOOTSTRAP_DATA_SESSION_ID => 'session_id',
);
// Init array
$this->searchData = array(
- XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_EXTERNAL_IP,
- XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_LISTEN_PORT
+ XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_EXTERNAL_ADDRESS,
);
}
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
}
/**
- * Checks whether the 'recipient' field matches our own address:port
- * combination.
+ * Checks whether the 'recipient' field matches our own an universal node
+ * locator.
*
* @param $packageData Raw package data
* @return $matches Whether it matches
* @todo This method will be moved to a better place
*/
- protected function ifRecipientMatchesOwnAddress (array $packageData) {
+ protected function ifRecipientMatchesOwnUniversalNodeLocator (array $packageData) {
// Construct own address first
- $ownAddress = NodeObjectFactory::createNodeInstance()->getAddressPort();
+ $ownAddress = NodeObjectFactory::createNodeInstance()->determineUniversalNodeLocator();
// Does it match?
$matches = ($ownAddress === $packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT]);
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @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
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
}
/**
- * Processes raw data from given resource. This is mostly useful for TCP
- * package handling and is implemented in the TcpListener class
+ * Processes raw data from given resource. This is mostly useful for UDP
+ * package handling and is implemented in the UdpListener class
*
* @param $socketArray A valid socket resource array
* @return void
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * A ??? protocol handler
+ *
+ * @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 ???ProtocolHandler extends BaseProtocolHandler implements HandleableProtocol, Registerable {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+
+ // Set handler name
+ $this->setHandlerName('|||_protocol');
+ }
+
+ /**
+ * Creates an instance of this class
+ *
+ * @return $handlerInstance An instance of a HandleableMessage class
+ */
+ public final static function create???ProtocolHandler () {
+ // Get new instance
+ $handlerInstance = new ???ProtocolHandler();
+
+ // Return the prepared instance
+ return $handlerInstance;
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+<?php
+/**
+ * A general handler for protocols such as TCP, UDP and others.
+ *
+ * @author Roland Haeder <webmaster@shipsimu.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.shipsimu.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 BaseProtocolHandler extends BaseHandler {
+ /**
+ * Protected constructor
+ *
+ * @param $className Name of the class
+ * @return void
+ */
+ protected function __construct ($className) {
+ // Call parent constructor
+ parent::__construct($className);
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * A Tcp protocol handler (IPv4)
+ *
+ * @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 TcpProtocolHandler extends BaseProtocolHandler implements HandleableProtocol, Registerable {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+
+ // Set handler name
+ $this->setHandlerName('tcp_protocol');
+ }
+
+ /**
+ * Creates an instance of this class
+ *
+ * @return $handlerInstance An instance of a HandleableMessage class
+ */
+ public final static function createTcpProtocolHandler () {
+ // Get new instance
+ $handlerInstance = new TcpProtocolHandler();
+
+ // Return the prepared instance
+ return $handlerInstance;
+ }
+}
+
+// [EOF]
+?>
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.ship-simu.org
* @todo Find an interface for hub helper
parent::__construct(__CLASS__);
// Set recipient type
- $this->setRecipientType(NetworkPackage::NETWORK_TARGET_!!!);
+ $this->setRecipientType(NetworkPackage::NETWORK_TARGET_```);
// Set package tags
$this->setPackageTags(array('???'));
$packageInstance = NetworkPackageFactory::createNetworkPackageInstance();
// Next, feed the content in. The network package class is a pipe-through class.
- $packageInstance->enqueueRawDataFromTemplate($this, NetworkPackage::PROTOCOL_TCP);
+ $packageInstance->enqueueRawDataFromTemplate($this);
}
}
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
* 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 BaseHubSystemHelper extends BaseHubSystem implements Helper {
+class BaseHubSystemHelper extends BaseHubSystem implements HubHelper {
/**
* Recipient type
*/
public final function setPackageTags (array $packageTags) {
$this->packageTags = $packageTags;
}
+
+ /**
+ * Tries to determine the used protocol for this package (this helper is helping to send out)
+ *
+ * @return $protocolType Type of protocol to use, usually TCP
+ * @todo 0% done
+ */
+ public function determineProtocolType () {
+ die(__METHOD__ . ':' . print_r($this, TRUE));
+ // Return it
+ }
}
// [EOF]
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.ship-simu.org
* @todo Find an interface for hub helper
parent::__construct(__CLASS__);
// Set protocol
- $this->setProtocol('!!!');
+ $this->setProtocolName('!!!');
}
/**
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
* 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 BaseConnectionHelper extends BaseHubSystemHelper implements Registerable, ProtocolHandler {
+class BaseConnectionHelper extends BaseHubSystemHelper implements Registerable {
// Exception codes
const EXCEPTION_UNSUPPORTED_ERROR_HANDLER = 0x9100;
const CONNECTION_TYPE_SERVER = 'server';
/**
- * Protocol used
+ * Name of used protocol for this connection
*/
- private $protocol = 'invalid';
+ private $connectionType = 'invalid';
/**
* Port number used
*/
- private $port = 0;
+ private $connectionPort = 0;
/**
* (IP) Adress used
*/
public final function __toString () {
// Class name representation
- $class = self::getConnectionClassName($this->getAddress(), $this->getPort(), parent::__toString());
+ $class = self::getConnectionClassName($this->getAddress(), $this->getConnectionPort(), parent::__toString());
// Return it
return $class;
}
/**
- * Getter for port number to satify ProtocolHandler
+ * Getter for connection type
*
- * @return $port The port number
+ * @return $connectionType Name of used protocol in this connection
*/
- public final function getPort () {
- return $this->port;
+ public final function getConnectionType () {
+ return $this->connectionType;
}
/**
- * Setter for port number to satify ProtocolHandler
+ * Setter for connection type
*
- * @param $port The port number
+ * @param $connectionType Name of used protocol in this connection
* @return void
*/
- protected final function setPort ($port) {
- $this->port = $port;
+ protected final function setConnectionType ($connectionType) {
+ $this->connectionType = $connectionType;
}
/**
- * Getter for protocol
+ * Getter for port number to satify HandleableProtocol
*
- * @return $protocol Used protocol
+ * @return $connectionPort The port number
*/
- public final function getProtocol () {
- return $this->protocol;
+ public final function getConnectionPort () {
+ return $this->connectionPort;
}
/**
- * Setter for protocol
+ * Setter for port number to satify HandleableProtocol
*
- * @param $protocol Used protocol
+ * @param $connectionPort The port number
* @return void
*/
- protected final function setProtocol ($protocol) {
- $this->protocol = $protocol;
+ protected final function setConenctionPort ($connectionPort) {
+ $this->connectionPort = $connectionPort;
}
/**
assert(strlen($rawData) > 0);
// Calculate buffer size
- $bufferSize = $this->getConfigInstance()->getConfigEntry($this->getProtocol() . '_buffer_length');
+ $bufferSize = $this->getConfigInstance()->getConfigEntry($this->getProtocolName() . '_buffer_length');
// Encode the raw data with our output-stream
$encodedData = $this->getOutputStreamInstance()->streamData($rawData);
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
* @todo Find an interface for hub helper
parent::__construct(__CLASS__);
// Set protocol
- $this->setProtocol('tcp');
+ $this->setProtocolName('tcp');
}
/**
// Try to solve the recipient
try {
// Resolve any session ids; 0 = IP, 1 = Port
- $recipientData = explode(':', HubTools::resolveSessionId($packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT]));
+ $resolved = HubTools::resolveSessionId($packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT]);
+ die(__METHOD__ . 'resolved=' . print_r($resolved, TRUE));
+
+ $recipientData = explode(':', $resolved);
} catch (NoValidHostnameException $e) {
// Debug message
self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-HELPER[' . __METHOD__ . ':' . __LINE__ . ']: Failed to resolve ' . $packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT] . ':' . $e->getMessage());
// Is the recipient equal as configured IP
- if (substr($packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT], 0, strlen($helperInstance->getConfigInstance()->getConfigEntry('external_ip'))) == $helperInstance->getConfigInstance()->getConfigEntry('external_ip')) {
- // This connects to shipsimu.org and requests /ip.php which will return our external IP number
- $recipientData[0] = ConsoleTools::determineExternalIp();
+ if (substr($packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT], 0, strlen($helperInstance->getConfigInstance()->getConfigEntry('external_address'))) == $helperInstance->getConfigInstance()->getConfigEntry('external_address')) {
+ // This may connect to shipsimu.org and requests 'ip.php' which will return our external IP address
+ $recipientData[0] = HubTools::determineExternalAddress();
- // Do we have hostname:ip match?
+ // Do we have ip:port match?
+ // @TODO Rewrite this test for UNLs
if (strpos($packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT], ':') === FALSE) {
- // No hostname:ip!
+ // No ip:port!
$helperInstance->debugInstance($packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT] . ' does not contain ":". Please fix this.');
} // END - if
- // "explode" the hostname:ip, so index 1 will be the port number
+ // "explode" the ip:port, so index 1 will be the port number
+ // @TODO Rewrite this test for UNLs
$recipientArray = explode(':', $packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT]);
// Add the port
$recipientData[1] = $recipientArray[1];
} else {
// It doesn't match, we need to take care of this later
- $helperInstance->debugInstance($packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT] . '!=' . $helperInstance->getConfigInstance()->getConfigEntry('external_ip'));
+ $helperInstance->debugInstance($packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT] . '!=' . $helperInstance->getConfigInstance()->getConfigEntry('external_address'));
}
}
- // Set ip/port
+ // Set address and maybe port
$helperInstance->setAddress($recipientData[0]);
- $helperInstance->setPort($recipientData[1]);
+ $helperInstance->setConnectionPort($recipientData[1]);
// Now connect to it
if (!$helperInstance->connectToPeerByRecipientData($recipientData)) {
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
* @todo Find an interface for hub helper
parent::__construct(__CLASS__);
// Set protocol
- $this->setProtocol('udp');
+ $this->setProtocolName('udp');
}
/**
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
* @todo Find an interface for hub helper
*/
public function sendPackage (Distributable $dhtInstance) {
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('HELPER[' . __METHOD__ . ':' . __LINE__ . ']: CALLED!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('HELPER[' . __METHOD__ . ':' . __LINE__ . ']: CALLED!');
/*
* Sanity check: Is the DHT in the approx. state? 'init' for bootstrap
$packageInstance = NetworkPackageFactory::createNetworkPackageInstance();
// Next, feed the content in. The network package class is a pipe-through class.
- $packageInstance->enqueueRawDataFromTemplate($this, NetworkPackage::PROTOCOL_TCP);
+ //* DEBUG: */ die(__METHOD__ . ':dhtInstance=' . print_r($dhtInstance, TRUE));
+ $packageInstance->enqueueRawDataFromTemplate($this);
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('HELPER[' . __METHOD__ . ':' . __LINE__ . ']: EXIT!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('HELPER[' . __METHOD__ . ':' . __LINE__ . ']: EXIT!');
}
}
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
* @todo Find an interface for hub helper
$packageInstance = NetworkPackageFactory::createNetworkPackageInstance();
// Next, feed the content in. The network package class is a pipe-through class.
- $packageInstance->enqueueRawDataFromTemplate($this, NetworkPackage::PROTOCOL_TCP);
+ $packageInstance->enqueueRawDataFromTemplate($this);
}
}
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @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
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
* @todo Find an interface for hub helper
$packageInstance = NetworkPackageFactory::createNetworkPackageInstance();
// Next, feed the content in. The network package class is a pipe-through class.
- $packageInstance->enqueueRawDataFromTemplate($this, NetworkPackage::PROTOCOL_TCP);
+ $packageInstance->enqueueRawDataFromTemplate($this);
}
}
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
* @todo Find an interface for hub helper
$packageInstance = NetworkPackageFactory::createNetworkPackageInstance();
// Next, feed the content in. The network package class is a pipe-through class.
- $packageInstance->enqueueRawDataFromTemplate($this, NetworkPackage::PROTOCOL_TCP);
+ $packageInstance->enqueueRawDataFromTemplate($this);
}
}
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
* @todo Find an interface for hub helper
$packageInstance = NetworkPackageFactory::createNetworkPackageInstance();
// Next, feed the content in. The network package class is a pipe-through class.
- $packageInstance->enqueueRawDataFromTemplate($this, NetworkPackage::PROTOCOL_TCP);
+ $packageInstance->enqueueRawDataFromTemplate($this);
}
}
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
* @todo Find an interface for hub helper
$packageInstance = NetworkPackageFactory::createNetworkPackageInstance();
// Next, feed the content in. The network package class is a pipe-through class.
- $packageInstance->enqueueRawDataFromTemplate($this, NetworkPackage::PROTOCOL_TCP);
+ $packageInstance->enqueueRawDataFromTemplate($this);
}
}
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.ship-simu.org
* @todo Find an interface for hub helper
$packageInstance = NetworkPackageFactory::createNetworkPackageInstance();
// Next, feed the content in. The network package class is a pipe-through class.
- $packageInstance->enqueueRawDataFromTemplate($this, NetworkPackage::PROTOCOL_|||);
+ $packageInstance->enqueueRawDataFromTemplate($this);
}
}
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
* @todo Find an interface for hub helper
$packageInstance = NetworkPackageFactory::createNetworkPackageInstance();
// Next, feed the content in. The network package class is a pipe-through class.
- $packageInstance->enqueueRawDataFromTemplate($this, NetworkPackage::PROTOCOL_TCP);
+ $packageInstance->enqueueRawDataFromTemplate($this);
}
}
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
* @todo Find an interface for hub helper
$packageInstance = NetworkPackageFactory::createNetworkPackageInstance();
// Next, feed the content in. The network package class is a pipe-through class.
- $packageInstance->enqueueRawDataFromTemplate($this, NetworkPackage::PROTOCOL_TCP);
+ $packageInstance->enqueueRawDataFromTemplate($this);
}
}
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
* @todo This current implementation is not recommended, use a
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @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
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
* @todo This current implementation is not recommended, use a
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
* @todo This current implementation is not recommended, use a
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @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
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
* @todo This current implementation is not recommended, use a
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @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
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
const EXCEPTION_FINAL_CHUNK_VERIFICATION = 0xa07;
const EXCEPTION_INVALID_DATA_CHECKSUM = 0xa08;
- /**
- * Used protocol (Default: invalid, which is indeed invalid...)
- */
- private $protocol = 'invalid';
-
/**
* Address (IP mostly) we shall listen on
*/
return $this->listenPort;
}
- /**
- * Getter for port number to satify ProtocolHandler
- *
- * @return $port The port number
- */
- public final function getPort () {
- return $this->getListenPort();
- }
-
/**
* "Setter" to set listen address from configuration entry
*
$this->setListenPort($this->getConfigInstance()->getConfigEntry($configEntry));
}
- /**
- * Setter for protocol
- *
- * @param $protocol Used protocol
- * @return void
- */
- protected final function setProtocol ($protocol) {
- $this->protocol = (string) $protocol;
- }
-
- /**
- * Getter for protocol
- *
- * @return $protocol Used protocol
- */
- public final function getProtocol () {
- return $this->protocol;
- }
-
/**
* Setter for blocking-mode
*
*/
public function accept (Visitor $visitorInstance) {
// Debug message
- //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(strtoupper($this->getProtocol()) . '-LISTENER[' . __METHOD__ . ':' . __LINE__ . ']: ' . $visitorInstance->__toString() . ' has visited ' . $this->__toString() . ' - START');
+ //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(strtoupper($this->getProtocolName()) . '-LISTENER[' . __METHOD__ . ':' . __LINE__ . ']: ' . $visitorInstance->__toString() . ' has visited ' . $this->__toString() . ' - START');
// Visit this listener
$visitorInstance->visitListener($this);
} // END - if
// Debug message
- //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(strtoupper($this->getProtocol()) . '-LISTENER[' . __METHOD__ . ':' . __LINE__ . ']: ' . $visitorInstance->__toString() . ' has visited ' . $this->__toString() . ' - FINISHED');
+ //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(strtoupper($this->getProtocolName()) . '-LISTENER[' . __METHOD__ . ':' . __LINE__ . ']: ' . $visitorInstance->__toString() . ' has visited ' . $this->__toString() . ' - FINISHED');
}
/**
<?php
/**
- * A decorator for the TcpListener to communicate to hubs
+ * A general decorator for listeners to communicate to hubs
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
return $this->getListenerInstance()->getListenPort();
}
- /**
- * Getter for port
- *
- * @return $port The port
- */
- public final function getPort () {
- return $this->getListenerInstance()->getPort();
- }
-
- /**
- * Getter for protocol
- *
- * @return $protocol The used protocol
- */
- public final function getProtocol () {
- return $this->getListenerInstance()->getProtocol();
- }
-
/**
* Accepts the visitor to process the visit "request"
*
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @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
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
parent::__construct(__CLASS__);
// Set the protocol to TCP
- $this->setProtocol('tcp');
+ $this->setProtocolName('tcp');
}
/**
$packageData = array(
NetworkPackage::PACKAGE_DATA_SENDER => $peerName . ':0',
NetworkPackage::PACKAGE_DATA_RECIPIENT => $this->getSessionId(),
- NetworkPackage::PACKAGE_DATA_PROTOCOL => $this->getProtocol(),
+ NetworkPackage::PACKAGE_DATA_PROTOCOL => $this->getProtocolName(),
NetworkPackage::PACKAGE_DATA_STATUS => NetworkPackage::PACKAGE_STATUS_FAKED
);
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
// Call parent constructor
parent::__construct(__CLASS__);
- // Set listener type
+ // Set listener type and protocol name
$this->setListenerType('peer');
+ $this->setProtocolName('tcp');
}
/**
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
// Call parent constructor
parent::__construct(__CLASS__);
- // Set listener type
+ // Set listener type and protocol name
$this->setListenerType('hub');
+ $this->setProtocolName('tcp');
}
/**
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @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
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
parent::__construct(__CLASS__);
// Set the protocol to UDP
- $this->setProtocol('udp');
+ $this->setProtocolName('udp');
}
/**
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
// Call parent constructor
parent::__construct(__CLASS__);
- // Set listener type
+ // Set listener type and protocol name
$this->setListenerType('peer');
+ $this->setProtocolName('udp');
}
/**
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
// Call parent constructor
parent::__construct(__CLASS__);
- // Set listener type
+ // Set listener type and protocol name
$this->setListenerType('hub');
+ $this->setProtocolName('udp');
}
/**
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @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
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
$listInstance = new RecipientList();
// Add groups:
- // 1.) ip:port combinations
- $listInstance->addGroup('ip_port');
+ // 1.) Universal Node Locators
+ $listInstance->addGroup('unl');
// 2.) Session ids
$listInstance->addGroup('session_id');
*/
public function clearList () {
// Clear both groups
- $this->clearGroups(array('ip_port', 'session_id'));
+ $this->clearGroups(array('unl', 'session_id'));
}
}
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
* @todo add some more special bootstrap things for this boot node
*/
public function doBootstrapping () {
+ // Get UNL
+ $unl = $this->detectOwnUniversalNodeLocator();
+
+ // Debug message
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: unl=' . $unl);
+
// Now check if the IP address matches one of the bootstrap nodes
- if ($this->ifAddressMatchesBootstrapNodes($this->getConfigInstance()->detectServerAddress())) {
+ if ($this->ifAddressMatchesBootstrapNodes($unl)) {
// Get our port from configuration
$ourPort = $this->getConfigInstance()->getConfigEntry('node_listen_port');
// Extract port
- $bootPort = substr($this->getBootIpPort(), -strlen($ourPort), strlen($ourPort));
+ $bootPort = substr($this->getBootUniversalNodeLocator(), -strlen($ourPort), strlen($ourPort));
// Is the port the same?
if ($bootPort == $ourPort) {
// It is the same!
- self::createDebugInstance(__CLASS__)->debugOutput('BOOTSTRAP: IP/port matches bootstrap node ' . $this->getBootIpPort() . '.');
+ self::createDebugInstance(__CLASS__)->debugOutput('BOOTSTRAP: UNL matches bootstrap node ' . $this->getBootUniversalNodeLocator() . '.');
// Now, does the mode match
if ($this->getRequestInstance()->getRequestElement('mode') == self::NODE_TYPE_BOOT) {
}
} else {
// IP does match, but no port
- self::createDebugInstance(__CLASS__)->debugOutput('BOOTSTRAP: WARNING: Our IP ' . $this->getConfigInstance()->detectServerAddress() . ' does match a known bootstrap-node but not the port ' . $ourPort . '/' . $bootPort . '.');
+ self::createDebugInstance(__CLASS__)->debugOutput('BOOTSTRAP: WARNING: Our UNL ' . $unl . ' does match a known bootstrap-node but not the port ' . $ourPort . '/' . $bootPort . '.');
}
} else {
// Node does not match any know bootstrap-node
- self::createDebugInstance(__CLASS__)->debugOutput('BOOTSTRAP: WARNING: Our IP ' . $this->getConfigInstance()->detectServerAddress() . ' does not match any known bootstrap-nodes.');
+ self::createDebugInstance(__CLASS__)->debugOutput('BOOTSTRAP: WARNING: Our UNL ' . $unl . ' does not match any known bootstrap-nodes.');
}
// Enable acceptance of announcements
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @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
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
const OBJECT_LIST_SEPARATOR = ',';
/**
- * IP/port number of bootstrap node
+ * Universal node locator of bootstrap node
*/
- private $bootIpPort = '';
+ private $bootUnl = '';
/**
* Whether this node is anncounced (keep on FALSE!)
NodeStateFactory::createNodeStateInstanceByName('init', $this);
}
- /**
- * Generates a random string from various data inluding UUID if PECL
- * extension uuid is installed.
- *
- * @param $length Length of the random part
- * @return $randomString Random string
- * @todo Make this code more generic and move it to CryptoHelper or
- */
- protected function generateRamdomString ($length) {
- // Get an RNG instance
- $rngInstance = ObjectFactory::createObjectByConfiguredName('rng_class');
-
- // Generate a pseudo-random string
- $randomString = $rngInstance->randomString($length) . ':' . $this->getBootIpPort() . ':' . $this->getRequestInstance()->getRequestElement('mode');
-
- // Add UUID for even more entropy for the hasher
- $randomString .= $this->getCryptoInstance()->createUuid();
-
- // Return it
- return $randomString;
- }
-
/**
* Generates a private key and hashes it (for speeding up things)
*
* @param $searchInstance An instance of a LocalSearchCriteria class
- * @return void
+ * @return void
*/
private function generatePrivateKeyAndHash (LocalSearchCriteria $searchInstance) {
// Get an RNG instance
}
/**
- * Getter for boot IP/port combination
+ * Generates a random string from various data inluding UUID if PECL
+ * extension uuid is installed.
*
- * @return $bootIpPort The IP/port combination of the boot node
+ * @param $length Length of the random part
+ * @return $randomString Random string
+ * @todo Make this code more generic and move it to CryptoHelper or
*/
- protected final function getBootIpPort () {
- return $this->bootIpPort;
+ protected function generateRamdomString ($length) {
+ // Get an RNG instance
+ $rngInstance = ObjectFactory::createObjectByConfiguredName('rng_class');
+
+ // Generate a pseudo-random string
+ $randomString = $rngInstance->randomString($length) . ':' . $this->getBootUniversalNodeLocator() . ':' . $this->getRequestInstance()->getRequestElement('mode');
+
+ // Add UUID for even more entropy for the hasher
+ $randomString .= $this->getCryptoInstance()->createUuid();
+
+ // Return it
+ return $randomString;
+ }
+
+ /**
+ * Getter for boot UNL (Universal Node Locator)
+ *
+ * @return $bootUnl The UNL (Universal Node Locator) of the boot node
+ */
+ protected final function getBootUniversalNodeLocator () {
+ return $this->bootUnl;
}
/**
$isFound = FALSE;
// Run through all configured IPs
- foreach (explode(BaseHubSystem::BOOTSTRAP_NODES_SEPARATOR, $this->getConfigInstance()->getConfigEntry('hub_bootstrap_nodes')) as $ipPort) {
- // Split it up in IP/port
- $ipPortArray = explode(':', $ipPort);
-
+ foreach (explode(BaseHubSystem::BOOTSTRAP_NODES_SEPARATOR, $this->getConfigInstance()->getConfigEntry('hub_bootstrap_nodes')) as $unl) {
// Does it match?
- if ($ipPortArray[0] == $remoteAddr) {
+ if ($unl == $remoteAddr) {
// Found it!
$isFound = TRUE;
- // Remember the port number
- $this->bootIpPort = $ipPort;
+ // Remember the UNL
+ $this->bootUnl = $unl;
// Output message
- self::createDebugInstance(__CLASS__)->debugOutput('BOOTSTRAP: ' . __FUNCTION__ . '[' . __METHOD__ . ':' . __LINE__ . ']: IP matches remote address ' . $ipPort . '.');
+ self::createDebugInstance(__CLASS__)->debugOutput('BOOTSTRAP: ' . __FUNCTION__ . '[' . __METHOD__ . ':' . __LINE__ . ']: UNL matches remote address ' . $unl . '.');
// Stop further searching
break;
- } elseif ($ipPortArray[0] == $this->getConfigInstance()->getConfigEntry('node_listen_addr')) {
+ } elseif ($unl == $this->getConfigInstance()->getConfigEntry('node_listen_addr')) {
/*
* IP matches listen address. At this point we really don't care
* if we can really listen on that address
$isFound = TRUE;
// Remember the port number
- $this->bootIpPort = $ipPort;
+ $this->bootUnl = $unl;
// Output message
- self::createDebugInstance(__CLASS__)->debugOutput('BOOTSTRAP: ' . __FUNCTION__ . '[' . __METHOD__ . ':' . __LINE__ . ']: IP matches listen address ' . $ipPort . '.');
+ self::createDebugInstance(__CLASS__)->debugOutput('BOOTSTRAP: ' . __FUNCTION__ . '[' . __METHOD__ . ':' . __LINE__ . ']: UNL matches listen address ' . $unl . '.');
// Stop further searching
break;
return $isFound;
}
+ /**
+ * Tries to detect own UNL (Universal Node Locator)
+ *
+ * @return $unl Node's own universal node locator
+ */
+ public function detectOwnUniversalNodeLocator () {
+ // 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
+
+ // Return it
+ return $GLOBALS[__METHOD__];
+ }
+
/**
* Outputs the console teaser. This should only be executed on startup or
* full restarts. This method generates some space around the teaser.
// Output all lines
self::createDebugInstance(__CLASS__)->debugOutput(' ');
self::createDebugInstance(__CLASS__)->debugOutput($app->getAppName() . ' v' . $app->getAppVersion() . ' - ' . $this->getRequestInstance()->getRequestElement('mode') . ' mode active');
- self::createDebugInstance(__CLASS__)->debugOutput('Copyright (c) 2007 - 2008 Roland Haeder, 2009 - 2012 Hub Developer Team');
+ self::createDebugInstance(__CLASS__)->debugOutput('Copyright (c) 2007 - 2008 Roland Haeder, 2009 - 2014 Hub Developer Team');
self::createDebugInstance(__CLASS__)->debugOutput(' ');
self::createDebugInstance(__CLASS__)->debugOutput('This program comes with ABSOLUTELY NO WARRANTY; for details see docs/COPYING.');
self::createDebugInstance(__CLASS__)->debugOutput('This is free software, and you are welcome to redistribute it under certain');
* @return void
*/
public function addElementsToDataSet (StoreableCriteria $criteriaInstance, Requestable $requestInstance = NULL) {
- // Make sure request instance is set as it is not optional
+ // Make sure the request instance is set as it is not optional.
assert($requestInstance instanceof Requestable);
// Add node number and type
$criteriaInstance->addCriteria(NodeInformationDatabaseWrapper::DB_COLUMN_PRIVATE_KEY, base64_encode($this->getPrivateKey()));
$criteriaInstance->addCriteria(NodeInformationDatabaseWrapper::DB_COLUMN_PRIVATE_KEY_HASH, $this->getPrivateKeyHash());
} // END - if
+
+ // Add own external and internal addresses as UNLs
+ $criteriaInstance->addCriteria(NodeInformationDatabaseWrapper::DB_COLUMN_INTERNAL_UNL, HubTools::determineOwnInternalAddress());
+ $criteriaInstance->addCriteria(NodeInformationDatabaseWrapper::DB_COLUMN_EXTERNAL_UNL, HubTools::determineOwnExternalAddress());
}
/**
}
/**
- * "Getter" for address:port combination
+ * Determines an instance of a LocateableNode class
*
- * @return $addressPort A address:port combination for this node
+ * @return $unlInstance An instance of a LocateableNode class for this node
*/
- public final function getAddressPort () {
- // Get IP and port
- $addressPort = $this->getConfigInstance()->detectServerAddress() . ':' . $this->getConfigInstance()->getConfigEntry('node_listen_port');
+ public function determineUniversalNodeLocator () {
+ // Debug message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NODE[' . __METHOD__ . ':' . __LINE__ . ']: CALLED!');
- // Return it
- return $addressPort;
+ // Determine UNL based on this node:
+ // 1) Get discovery class
+ $discoveryInstance = ObjectFactory::createObjectByConfiguredName('unl_discovery_class');
+
+ // 2) "Determine" it
+ $unlInstance = $discoveryInstance->discoverUniversalNodeLocatorByNode($this);
+
+ // 3) Return it
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NODE[' . __METHOD__ . ':' . __LINE__ . ']: unlInstance= ' . $unlInstance->__toString() . ' - EXIT!');
+ return $unlInstance;
}
/**
- * "Getter" for address:port array
+ * "Getter" for an array of an instance of a LocateableNode class
*
- * @return $addressPortArray An array of a address:port combination for this node
+ * @return $unlData An array from an instance of a LocateableNode class for this node
*/
- public final function getAddressPortArray () {
- // Get IP and port
- $addressPortArray = explode(':', $this->getAddressPort());
+ public final function getUniversalNodeLocatorArray () {
+ // Debug message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NODE[' . __METHOD__ . ':' . __LINE__ . ']: CALLED!');
+
+ // Get the Universal Node Locator (UNL) instance
+ $unlInstance = $this->determineUniversalNodeLocator();
+
+ // Make sure the instance is valid
+ // * DEBUG: */ $this->debugInstance('unlInstance[]=' . gettype($unlInstance));
+ assert($unlInstance instanceof LocateableNode);
+
+ // ... and the array from it
+ $unlData = $unlInstance->getUnlData();
// Return it
- return $addressPortArray;
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NODE[' . __METHOD__ . ':' . __LINE__ . ']: EXIT!');
+ return $unlData;
}
/**
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
* @todo Needs to add functionality for handling the object's type
*/
const PACKAGE_DATA_SENDER = 'sender';
const PACKAGE_DATA_RECIPIENT = 'recipient';
- const PACKAGE_DATA_PROTOCOL = 'protocol';
const PACKAGE_DATA_CONTENT = 'content';
const PACKAGE_DATA_STATUS = 'status';
const PACKAGE_DATA_SIGNATURE = 'signature';
// Now get an iterator
$iteratorInstance = $discoveryInstance->getIterator();
+ // Make sure the iterator instance is valid
+ assert($iteratorInstance instanceof Iterator);
+
// Rewind back to the beginning
$iteratorInstance->rewind();
$currentRecipient = $iteratorInstance->current();
// Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __METHOD__ . ':' . __LINE__ . ']: Setting recipient to ' . $currentRecipient . ',previous=' . $packageData[self::PACKAGE_DATA_RECIPIENT]);
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __METHOD__ . ':' . __LINE__ . ']: Setting recipient to ' . $currentRecipient . ',previous=' . $packageData[self::PACKAGE_DATA_RECIPIENT]);
// Set the recipient
$packageData[self::PACKAGE_DATA_RECIPIENT] = $currentRecipient;
$this->getStackInstance()->pushNamed(self::STACKER_NAME_DECLARED, $packageData);
// Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __METHOD__ . ':' . __LINE__ . ']: Package declared for recipient ' . $currentRecipient);
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __METHOD__ . ':' . __LINE__ . ']: Package declared for recipient ' . $currentRecipient);
// Skip to next entry
$iteratorInstance->next();
// Is it the same?
//$isSignatureValid =
- exit(__METHOD__.': signature='.$signature.chr(10).',decodedArray='.print_r($decodedArray, TRUE));
+ exit(__METHOD__ . ': signature=' . $signature . chr(10) . ',decodedArray=' . print_r($decodedArray, TRUE));
}
/**
* from given helper's template instance and pushing it on the 'undeclared'
* stack.
*
- * @param $helperInstance An instance of a Helper class
- * @param $protocol Name of used protocol (TCP/UDP)
+ * @param $helperInstance An instance of a HubHelper class
* @return void
*/
- public function enqueueRawDataFromTemplate (Helper $helperInstance, $protocolName) {
+ public function enqueueRawDataFromTemplate (HubHelper $helperInstance) {
+ // Debug message
+ //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ': CALLED!');
+
// Get the raw content ...
$content = $helperInstance->getTemplateInstance()->getRawTemplateData();
//* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('content(' . strlen($content) . ')=' . $content);
$this->getHashFromContent($content)
);
+ // Debug message
+ //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ': Enqueueing package for recipientType=' . $helperInstance->getRecipientType() . ' ...');
+
// Now prepare the temporary array and push it on the 'undeclared' stack
$this->getStackInstance()->pushNamed(self::STACKER_NAME_UNDECLARED, array(
self::PACKAGE_DATA_SENDER => $this->getSessionId(),
self::PACKAGE_DATA_RECIPIENT => $helperInstance->getRecipientType(),
- self::PACKAGE_DATA_PROTOCOL => $protocolName,
self::PACKAGE_DATA_CONTENT => $packageContent,
self::PACKAGE_DATA_STATUS => self::PACKAGE_STATUS_NEW,
self::PACKAGE_DATA_SIGNATURE => $this->generatePackageSignature($packageContent, $this->getSessionId())
));
+
+ // Debug message
+ //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ': EXIT!');
}
/**
* @throws NoTargetException If no target can't be determined
*/
public function declareEnqueuedPackage () {
+ // Debug message
+ //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ': CALLED!');
+
// Make sure this method isn't working if there is no package enqueued
if (!$this->isPackageEnqueued()) {
// This is not fatal but should be avoided
// Declare the raw package data for delivery
$this->declareRawPackageData($packageData);
+
+ // Debug message
+ //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ': EXIT!');
}
/**
* @return void
*/
public function processDeclaredPackage () {
+ // Debug message
+ //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ': CALLED!');
+
// Sanity check if we have packages declared
if (!$this->isPackageDeclared()) {
// This is not fatal but should be avoided
// Mark the package with status failed
$this->changePackageStatus($packageData, self::STACKER_NAME_DECLARED, self::PACKAGE_STATUS_FAILED);
}
+
+ // Debug message
+ //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ': EXIT!');
}
/**
* @return void
*/
public function sendWaitingPackage () {
+ // Debug message
+ /* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ': CALLED!');
+
// Sanity check if we have packages waiting for delivery
if (!$this->isPackageWaitingForDelivery()) {
// This is not fatal but should be avoided
// Mark package as failed
$this->changePackageStatus($packageData, self::STACKER_NAME_OUTGOING, self::PACKAGE_STATUS_FAILED);
}
+
+ // Debug message
+ /* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ': EXIT!');
}
/**
* @return void
*/
public function sendEncodedData () {
+ // Debug message
+ /* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ': CALLED!');
+
// Make sure there is pending encoded data
assert($this->isEncodedDataPending());
// Push array back in stack
$this->getStackInstance()->pushNamed(self::STACKER_NAME_OUTGOING_STREAM, $encodedDataArray);
+
+ // Debug message
+ /* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ': EXIT!');
}
///////////////////////////////////////////////////////////////////////////
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @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
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
* @return void
*/
protected final function addInstance ($group, $poolName, Visitable $visitableInstance) {
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('POOL[' . __METHOD__ . ':' . __LINE__ . ']: group=' . $group . ',poolName=' . $poolName . ',visitableInstance=' . $visitableInstance->__toString() . ' - CALLED!');
+
+ // Make sure the group is not 'invalid'
+ assert($group != 'invalid');
+
// Is the pool group there?
if (!$this->getPoolEntriesInstance()->isGroupSet($group)) {
// Create the missing pool group
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*/
public function addListener (Listenable $listenerInstance) {
// Add this listener instance to the instance list
- parent::addInstance($listenerInstance->getProtocol(), 'listener', $listenerInstance);
+ parent::addInstance($listenerInstance->getProtocolName(), 'listener', $listenerInstance);
// Debug message
self::createDebugInstance(__CLASS__)->debugOutput(
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
$socketResource = FALSE;
// Temporary resolve recipient field
- $recipientIpArray = explode(':', HubTools::resolveSessionId($packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT]));
+ die(__METHOD__ . ': UNFINISHED!' . PHP_EOL);
+ $unlData = explode(':', HubTools::resolveSessionId($packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT]));
- // Make sure it is a valid ip:port array (2 elements)
- assert(count($recipientIpArray) == 2);
+ // Make sure it is a valid Universal Node Locator array (3 elements)
+ assert(count($unlData) == 3);
// Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('POOL[' . __METHOD__ . ':' . __LINE__ . ']: Checking ' . count($this->getAllSockets()) . ' socket(s),recipientIpArray[0]=' . $recipientIpArray[0] . ',recipientIpArray[1]=' . $recipientIpArray[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();
// Get
// If the "peer" IP and recipient is same, use it
- if ($peerIp == $recipientIpArray[0]) {
+ if ($peerIp == $unlData[0]) {
// IPs match, so take the socket and quit this loop
$socketResource = $socketArray[self::SOCKET_ARRAY_RESOURCE];
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @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
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
return;
} elseif (!$this->getIteratorInstance()->valid()) {
// This producer's iterator has finished its assignment
- self::createDebugInstance(__CLASS__)->debugOutput('PRODUCER: Finished creating keys. iteratorinstance=' . $this->getIteratorInstance()->__toString() . '');
+ self::createDebugInstance(__CLASS__)->debugOutput('PRODUCER: Finished creating keys. iteratorInstance=' . $this->getIteratorInstance()->__toString() . '');
return;
}
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @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
*
}
/**
- * Tries to resolve given recipient into session ids or ip:port combination
+ * Tries to resolve given recipient into session ids or Universal Node Locator
* depending on implementation (hint: Template Method Pattern)
*
* @param $recipient Recipient to resolve (e.g. could be a virtual recipient or direct session id)
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
}
/**
- * Tries to resolve given recipient into session ids or ip:port combination
+ * Tries to resolve given recipient into session ids or Universal Node Locator
* depending on implementation (hint: Template Method Pattern). This
* implementation will add more than one recipient to the list as a DHT is
* distributed and the package might go to more than one recipient.
// Now "walk" through all elements and add them to the list
foreach ($recipients as $recipient) {
// These array elements must exist for this loop:
- assert(!empty($recipient[NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_EXTERNAL_IP]));
- assert(!empty($recipient[NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_LISTEN_PORT]));
+ // @TODO Unfinished
+ die(__METHOD__ . ':recipient=' . print_r($recipient, TRUE));
+ assert(!empty($recipient[NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_EXTERNAL_ADDRESS]));
// Put ip and port both together
- $ipPort = $recipient[NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_EXTERNAL_IP] . ':' . $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(' . $ipPort . ') ...');
- $listInstance->addEntry('ip_port', $ipPort);
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-RECIPIENT[' . __METHOD__ . ':' . __LINE__ . ']: Calling listInstance->addEntry(' . $unl . ') ...');
+ $listInstance->addEntry('unl', $unl);
} // END - foreach
// Debug message
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
}
/**
- * Tries to resolve given recipient into session ids or ip:port combination
+ * Tries to resolve given recipient into session ids or Universal Node Locator
* depending on implementation (hint: Template Method Pattern)
*
* @param $recipient Recipient to resolve (e.g. could be a virtual recipient or direct session id)
*/
public function resolveRecipient ($recipient, Listable $listInstance, array $packageData) {
// Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DIRECT-RECIPIENT: recipient=' . $recipient);
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DIRECT-RECIPIENT[' . __METHOD__ . ':' . __LINE__ . ']: recipient=' . $recipient);
// "Explode" all recipients
$recipients = explode(NetworkPackage::PACKAGE_RECIPIENT_SEPARATOR, $recipient);
// Try it on all
foreach ($recipients as $recipient) {
// Try to sole a single recipient
- $ipPort = HubTools::resolveSessionId($recipient);
+ $unlData = HubTools::resolveSessionId($recipient);
// Add it as recipient
- $listInstance->addEntry('ip_port', $ipPort);
+ $listInstance->addEntry('unl', $unlData);
} // END - foreach
}
}
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
}
/**
- * Tries to resolve given recipient into session ids or ip:port combination
+ * Tries to resolve given recipient into session ids or Universal Node Locator
* depending on implementation (hint: Template Method Pattern)
*
* @param $recipient Recipient to resolve (e.g. could be a virtual recipient or direct session id)
*/
public function resolveRecipient ($recipient, Listable $listInstance, array $packageData) {
// Make sure the recipient is valid
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SELF-RECIPIENT: recipient=' . $recipient);
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SELF-RECIPIENT[' . __METHOD__ . ':' . __LINE__ . ']: recipient=' . $recipient);
+ // @TODO Add more checks on data
assert($recipient == NetworkPackage::NETWORK_TARGET_SELF);
- // Determine own port
- $port = $this->getConfigInstance()->getConfigEntry('node_listen_port');
-
- // Determine IP or 'external_ip' if set
- $ip = HubTools::determineOwnExternalIp();
+ // Determine IP or 'external_address' if set
+ $unl = HubTools::determineOwnExternalAddress();
// Is it not empty?
- if (!empty($ip)) {
+ if (!empty($unl)) {
// Add it to the list
- $listInstance->addEntry('ip_port', $ip . ':' . $port);
+ $listInstance->addEntry('unl', $unl);
} // END - if
}
}
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
}
/**
- * Tries to resolve given recipient into session ids or ip:port combination
+ * Tries to resolve given recipient into session ids or Universal Node Locator
* depending on implementation (hint: Template Method Pattern)
*
* @param $recipient Recipient to resolve (e.g. could be a virtual recipient or direct session id)
assert($recipient == NetworkPackage::NETWORK_TARGET_UPPER);
// Get all bootstrap nodes
- foreach (explode(BaseHubSystem::BOOTSTRAP_NODES_SEPARATOR, $this->getConfigInstance()->getConfigEntry('hub_bootstrap_nodes')) as $ipPort) {
+ 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
- /* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('RECIPIENT-RESOLVER: Going to abort at maximum of ' . $this->getConfigInstance()->getConfigEntry('package_recipient_max_count') . ' recipients!');
+ /* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('RECIPIENT-RESOLVER[' . __METHOD__ . ':' . __LINE__ . ']: Going to abort at maximum of ' . $this->getConfigInstance()->getConfigEntry('package_recipient_max_count') . ' recipients!');
// Then stop adding more
break;
} // END - if
// Debug message
- /* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('RECIPIENT-RESOLVER: Adding node ' . $ipPort . ' as recipient.');
+ /* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('RECIPIENT-RESOLVER[' . __METHOD__ . ':' . __LINE__ . ']: Adding node ' . print_r($unlData, TRUE) . ' as recipient.');
// Add the entry
- $listInstance->addEntry('ip_port', $ipPort);
+ $listInstance->addEntry('unl', $unlData);
} // END - foreach
}
}
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
/**
* "Getter" to get a string respresentation for a key for the sub-registry
- * in this format: class:protocol:port
+ * in this format: class:type:port
*
* @param $connectionInstance An instance of a ConnectionHelper class
* @return $key A string representation of the socket for the registry
*/
private function getSubRegistryKey (ConnectionHelper $connectionInstance) {
- // Get protocol and port number and add both together
- $key = sprintf("%s:%s:%s",
+ // Get connection type and port number and add both together
+ $key = sprintf('%s:%s:%s',
$connectionInstance->__toString(),
- $connectionInstance->getProtocol(),
- $connectionInstance->getPort()
+ $connectionInstance->getConnectionType(),
+ $connectionInstance->getConnectionPort()
);
// Return resulting key
/**
* "Getter" to get a string respresentation of the protocol
*
- * @param $connectionInstance An instance of a ConnectionHelper class
- * @return $key A string representation of the protocol for the registry
+ * @param $connectionInstance An instance of a ConnectionHelper class
+ * @return $key A string representation of the protocol for the registry
*/
- private function getRegistryKeyFromProtocol (ConnectionHelper $connectionInstance) {
+ private function getRegistryKeyFromConnection (ConnectionHelper $connectionInstance) {
// Get the key
- $key = $connectionInstance->getProtocol();
+ $key = $connectionInstance->getProtocolName();
// Return resulting key
return $key;
* @param $connectionInstance An instance of a ConnectionHelper class
* @return $isRegistered Whether the protocol is registered
*/
- private function isProtocolRegistered (ConnectionHelper $connectionInstance) {
+ private function isConnectionRegistered (ConnectionHelper $connectionInstance) {
// Get the key
- $key = $this->getRegistryKeyFromProtocol($connectionInstance);
+ $key = $this->getRegistryKeyFromConnection($connectionInstance);
// Determine it
$isRegistered = $this->instanceExists($key);
$isRegistered = FALSE;
// First, check for the instance, there can be only once
- if ($this->isProtocolRegistered($connectionInstance)) {
+ if ($this->isConnectionRegistered($connectionInstance)) {
// That one is found so "get" a registry key from it
- $key = $this->getRegistryKeyFromProtocol($connectionInstance);
+ $key = $this->getRegistryKeyFromConnection($connectionInstance);
// Get the registry
$registryInstance = $this->getInstance($key);
} // END - if
// Does the instance exist?
- if (!$this->isProtocolRegistered($connectionInstance)) {
+ if (!$this->isConnectionRegistered($connectionInstance)) {
// No, not found so we create a sub registry (not needed to configure!)
$registryInstance = SubRegistry::createSubRegistry();
// Now we can create the sub-registry for this protocol
- $this->addInstance($this->getRegistryKeyFromProtocol($connectionInstance), $registryInstance);
+ $this->addInstance($this->getRegistryKeyFromConnection($connectionInstance), $registryInstance);
} else {
// Get the sub-registry back
- $registryInstance = $this->getInstance($this->getRegistryKeyFromProtocol($connectionInstance));
+ $registryInstance = $this->getInstance($this->getRegistryKeyFromConnection($connectionInstance));
}
// Get a key for sub-registries
} // END - if
// Now get the key from the protocol
- $key = $this->getRegistryKeyFromProtocol($connectionInstance);
+ $key = $this->getRegistryKeyFromConnection($connectionInstance);
// And get the registry
$registryInstance = $this->getInstance($key);
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
/**
* "Getter" to get a string respresentation for a key for the sub-registry
- * in this format: class:protocol:port
+ * in this format: class:type:port
*
- * @param $protocolInstance An instance of a ProtocolHandler class
+ * @param $connectionInstance An instance of a Listenable class
* @return $key A string representation of the socket for the registry
*/
- private function getSubRegistryKey (ProtocolHandler $protocolInstance) {
+ private function getSubRegistryKey (Listenable $connectionInstance) {
// Default address is invalid
$address = '*invalid*';
+ $port = 0;
// Which instance is it?
// @TODO Tested again base class, rewrite it to a generic interface!
- if ($protocolInstance instanceof BaseConnectionHelper) {
+ if ($connectionInstance instanceof BaseConnectionHelper) {
// Get address
- $address = $protocolInstance->getAddress();
- } elseif ($protocolInstance instanceof BaseListener) {
+ $address = $connectionInstance->getAddress();
+ $port = $connectionInstance->getConnectionPort();
+ } elseif ($connectionInstance instanceof BaseListener) {
// Get listen address
- $address = $protocolInstance->getListenAddress();
+ $address = $connectionInstance->getListenAddress();
+ $port = $connectionInstance->getListenPort();
} else {
// Not supported!
- $this->debugBackTrace('Unsupported protocolInstance=' . $protocolInstance->__toString() . ' detected. Please fix this!');
+ $this->debugBackTrace('Unsupported connectionInstance=' . $connectionInstance->__toString() . ' detected. Please fix this!');
}
- // Get protocol and port number and add both together
- $key = sprintf("%s:%s:%s:%s",
- $protocolInstance->__toString(),
- $protocolInstance->getProtocol(),
+ // Get connection type and port number and add both together
+ $key = sprintf('%s:%s:%s:%s',
+ $connectionInstance->__toString(),
+ $connectionInstance->getConnectionType(),
$address,
- $protocolInstance->getPort()
+ $port
);
// Return resulting key
}
/**
- * "Getter" to get a string respresentation of the protocol
+ * "Getter" to get a string respresentation of the listener
*
- * @param $protocolInstance An instance of a ProtocolHandler class
- * @return $key A string representation of the protocol for the registry
+ * @param $listenerInstance An instance of a Listenable class
+ * @return $key A string representation of the listener for the registry
*/
- private function getRegistryKeyFromProtocol (ProtocolHandler $protocolInstance) {
+ private function getRegistryKeyFromListener (Listenable $listenerInstance) {
// Get the key
- $key = $protocolInstance->getProtocol();
+ $key = $listenerInstance->getConnectionType();
// Return resulting key
return $key;
}
/**
- * Checks whether the given protocol is registered
+ * Checks whether the given listener is registered
*
- * @param $protocolInstance An instance of a ProtocolHandler class
- * @return $isRegistered Whether the protocol is registered
+ * @param $listenerInstance An instance of a Listenable class
+ * @return $isRegistered Whether the listener is registered
*/
- private function isProtocolRegistered (ProtocolHandler $protocolInstance) {
+ private function isListenerRegistered (Listenable $listenerInstance) {
// Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-REGISTRY[' . __METHOD__ . ':' . __LINE__ . ']:protocol=' . $protocolInstance->getProtocol() . ' - ENTERED!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-REGISTRY[' . __METHOD__ . ':' . __LINE__ . ']:listener=' . $listenerInstance->getConnectionType() . ' - ENTERED!');
// Get the key
- $key = $this->getRegistryKeyFromProtocol($protocolInstance);
+ $key = $this->getRegistryKeyFromListener($listenerInstance);
// Determine it
$isRegistered = $this->instanceExists($key);
// Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-REGISTRY[' . __METHOD__ . ':' . __LINE__ . ']:protocol=' . $protocolInstance->getProtocol() . ',isRegistered=' . intval($isRegistered) . ' - EXIT!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-REGISTRY[' . __METHOD__ . ':' . __LINE__ . ']:listener=' . $listenerInstance->getConnectionType() . ',isRegistered=' . intval($isRegistered) . ' - EXIT!');
// Return result
return $isRegistered;
* Checks whether given socket resource is registered. If $socketResource is
* FALSE only the instance will be checked.
*
- * @param $protocolInstance An instance of a ProtocolHandler class
+ * @param $listenerInstance An instance of a Listenable class
* @param $socketResource A valid socket resource
* @return $isRegistered Whether the given socket resource is registered
*/
- public function isSocketRegistered (ProtocolHandler $protocolInstance, $socketResource) {
+ public function isSocketRegistered (Listenable $listenerInstance, $socketResource) {
// Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-REGISTRY[' . __METHOD__ . ':' . __LINE__ . ']:protocol=' . $protocolInstance->getProtocol() . ',socketResource[' . gettype($socketResource) . ']=' . $socketResource . ' - ENTERED!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-REGISTRY[' . __METHOD__ . ':' . __LINE__ . ']:listener=' . $listenerInstance->getConnectionType() . ',socketResource[' . gettype($socketResource) . ']=' . $socketResource . ' - ENTERED!');
// Default is not registered
$isRegistered = FALSE;
// First, check for the instance, there can be only once
- if ($this->isProtocolRegistered($protocolInstance)) {
+ if ($this->isListenerRegistered($listenerInstance)) {
// That one is found so "get" a registry key from it
- $key = $this->getRegistryKeyFromProtocol($protocolInstance);
+ $key = $this->getRegistryKeyFromListener($listenerInstance);
// Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-REGISTRY[' . __METHOD__ . ':' . __LINE__ . ']: protocol=' . $protocolInstance->getProtocol() . ',socketResource[' . gettype($socketResource) . ']=' . $socketResource . ',key=' . $key . ' - Trying to get instance ...');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-REGISTRY[' . __METHOD__ . ':' . __LINE__ . ']: listener=' . $listenerInstance->getConnectionType() . ',socketResource[' . gettype($socketResource) . ']=' . $socketResource . ',key=' . $key . ' - Trying to get instance ...');
// Get the registry
$registryInstance = $this->getInstance($key);
// "Get" a key for the socket
- $socketKey = $this->getSubRegistryKey($protocolInstance);
+ $socketKey = $this->getSubRegistryKey($listenerInstance);
// Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-REGISTRY[' . __METHOD__ . ':' . __LINE__ . ']: protocol=' . $protocolInstance->getProtocol() . ',socketResource[' . gettype($socketResource) . ']=' . $socketResource . ',key=' . $key . ',socketKey=' . $socketKey . ' - Checking existence ...');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-REGISTRY[' . __METHOD__ . ':' . __LINE__ . ']: listener=' . $listenerInstance->getConnectionType() . ',socketResource[' . gettype($socketResource) . ']=' . $socketResource . ',key=' . $key . ',socketKey=' . $socketKey . ' - Checking existence ...');
// Is it there?
if ($registryInstance->instanceExists($socketKey)) {
} // END - if
// Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-REGISTRY[' . __METHOD__ . ':' . __LINE__ . ']:protocol=' . $protocolInstance->getProtocol() . ',socketResource[' . gettype($socketResource) . ']=' . $socketResource . ',isRegistered=' . intval($isRegistered) . ' - EXIT!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-REGISTRY[' . __METHOD__ . ':' . __LINE__ . ']:listener=' . $listenerInstance->getConnectionType() . ',socketResource[' . gettype($socketResource) . ']=' . $socketResource . ',isRegistered=' . intval($isRegistered) . ' - EXIT!');
// Return the result
return $isRegistered;
/**
* Registeres given socket for listener or throws an exception if it is already registered
*
- * @param $protocolInstance An instance of a ProtocolHandler class
+ * @param $listenerInstance An instance of a Listenable class
* @param $socketResource A valid socket resource
* @param $packageData Optional raw package data
* @throws SocketAlreadyRegisteredException If the given socket is already registered
* @return void
*/
- public function registerSocket (ProtocolHandler $protocolInstance, $socketResource, array $packageData = array()) {
+ public function registerSocket (Listenable $listenerInstance, $socketResource, array $packageData = array()) {
// Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-REGISTRY[' . __METHOD__ . ':' . __LINE__ . ']:protocol=' . $protocolInstance->getProtocol() . ',socketResource[' . gettype($socketResource) . ']=' . $socketResource . ' - ENTERED!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-REGISTRY[' . __METHOD__ . ':' . __LINE__ . ']:listener=' . $listenerInstance->getConnectionType() . ',socketResource[' . gettype($socketResource) . ']=' . $socketResource . ' - ENTERED!');
// Is the socket already registered?
- if ($this->isSocketRegistered($protocolInstance, $socketResource)) {
+ if ($this->isSocketRegistered($listenerInstance, $socketResource)) {
// Throw the exception
- throw new SocketAlreadyRegisteredException(array($protocolInstance, $socketResource), BaseListener::EXCEPTION_SOCKET_ALREADY_REGISTERED);
+ throw new SocketAlreadyRegisteredException(array($listenerInstance, $socketResource), BaseListener::EXCEPTION_SOCKET_ALREADY_REGISTERED);
} // END - if
// Does the instance exist?
- if (!$this->isProtocolRegistered($protocolInstance)) {
+ if (!$this->isListenerRegistered($listenerInstance)) {
// No, not found so we create a sub registry (not needed to configure!)
$registryInstance = SubRegistry::createSubRegistry();
- // Now we can create the sub-registry for this protocol
- $this->addInstance($this->getRegistryKeyFromProtocol($protocolInstance), $registryInstance);
+ // Now we can create the sub-registry for this listener
+ $this->addInstance($this->getRegistryKeyFromListener($listenerInstance), $registryInstance);
} else {
// Get the sub-registry back
- $registryInstance = $this->getInstance($this->getRegistryKeyFromProtocol($protocolInstance));
+ $registryInstance = $this->getInstance($this->getRegistryKeyFromListener($listenerInstance));
}
// Get a key for sub-registries
- $socketKey = $this->getSubRegistryKey($protocolInstance);
+ $socketKey = $this->getSubRegistryKey($listenerInstance);
// Get a socket container
- $socketInstance = ObjectFactory::CreateObjectByConfiguredName('socket_container_class', array($socketResource, $protocolInstance, $packageData));
+ $socketInstance = ObjectFactory::CreateObjectByConfiguredName('socket_container_class', array($socketResource, $listenerInstance, $packageData));
// We have a sub-registry, the socket key and the socket, now we need to put all together
/* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-REGISTRY[' . __METHOD__ . ':' . __LINE__ . ']: socketKey=' . $socketKey . ',socketResource[' . gettype($socketResource) . ']=' . $socketResource . ' - adding socket container instance ...');
/**
* Getter for given listener's socket resource
*
- * @param $protocolInstance An instance of a ProtocolHandler class
+ * @param $listenerInstance An instance of a Listenable class
* @return $socketResource A valid socket resource
* @throws NoSocketRegisteredException If the requested socket is not registered
*/
- public function getRegisteredSocketResource (ProtocolHandler $protocolInstance) {
+ public function getRegisteredSocketResource (Listenable $listenerInstance) {
// Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-REGISTRY[' . __METHOD__ . ':' . __LINE__ . ']:protocol=' . $protocolInstance->getProtocol() . ' - ENTERED!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-REGISTRY[' . __METHOD__ . ':' . __LINE__ . ']:listener=' . $listenerInstance->getConnectionType() . ' - ENTERED!');
// The socket must be registered before we can return it
- if (!$this->isProtocolRegistered($protocolInstance)) {
+ if (!$this->isListenerRegistered($listenerInstance)) {
// Throw the exception
- throw new NoSocketRegisteredException ($protocolInstance, self::SOCKET_NOT_REGISTERED);
+ throw new NoSocketRegisteredException ($listenerInstance, self::SOCKET_NOT_REGISTERED);
} // END - if
- // Now get the key from the protocol
- $key = $this->getRegistryKeyFromProtocol($protocolInstance);
+ // Now get the key from the listener
+ $key = $this->getRegistryKeyFromListener($listenerInstance);
// And get the registry
$registryInstance = $this->getInstance($key);
// Get a socket key
- $socketKey = $this->getSubRegistryKey($protocolInstance);
+ $socketKey = $this->getSubRegistryKey($listenerInstance);
// And the final socket resource
$socketResource = $registryInstance->getInstance($socketKey)->getSocketResource();
// Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-REGISTRY[' . __METHOD__ . ':' . __LINE__ . ']:protocol=' . $protocolInstance->getProtocol() . ',socketResource[' . gettype($socketResource) . ']=' . $socketResource . ' - EXIT!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-REGISTRY[' . __METHOD__ . ':' . __LINE__ . ']:listener=' . $listenerInstance->getConnectionType() . ',socketResource[' . gettype($socketResource) . ']=' . $socketResource . ' - EXIT!');
// Return the resource
return $socketResource;
* "Getter" for protocol/connection instance from given package data
*
* @param $packageData Raw package data
- * @return $protocolInstance An instance of a ProtocolHandler class
+ * @return $protocolInstance An instance of a HandleableProtocol class
*/
public function getHandlerInstanceFromPackageData (array $packageData) {
// Init protocol instance
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * A !!! protocol resolver class
+ *
+ * @author Roland Haeder <webmaster@shipsimu.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.shipsimu.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 !!!ProtocolResolver extends BaseProtocolResolver implements ProtocolResolver, Registerable {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+ }
+
+ /**
+ * Creates an instance of a !!! protocol resolver
+ *
+ * @return $resolverInstance The prepared command resolver instance
+ */
+ public static final function create!!!ProtocolResolver () {
+ // Create the new instance
+ $resolverInstance = new !!!ProtocolResolver();
+
+ // Return the prepared instance
+ return $resolverInstance;
+ }
+
+ /**
+ * Returns an instance of a LocateableNode class for a given NodeHelper
+ * instance or null if it was not found.
+ *
+ * @param $nodeInstance An instance of a NodeHelper class
+ * @return $unlInstance An instance of a LocateableNode class
+ * @todo 0% done
+ */
+ public function resolveUniversalNodeLocatorFromNodeHelper (NodeHelper $nodeInstance) {
+ $this->partialStub('Please implement this method. nodeInstance=' . $nodeInstance->__toString());
+ }
+
+ /**
+ * Returns the UNL as string from given configuration key.
+ *
+ * @param $configKey Configuration key for UNL address (valid: internal,external)
+ * @return $unl Universal node locator
+ * @todo 90% done
+ */
+ public function resolveUniversalNodeLocatorFromConfigKey ($configKey) {
+ // Put all together
+ $unl = sprintf('%s://%s',
+ $this->getProtocolName(),
+ $this->getConfigInstance()->getConfigEntry($configKey . '_address')
+ );
+
+ /*
+ * And return it. Please note that e.g. a FaxProtocolResolver will
+ * return a different UNL and therefore all protocol resolvers must do
+ * it on their own way.
+ */
+ return $unl;
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+<?php
+/**
+ * A generic protocol resolver class
+ *
+ * @author Roland Haeder <webmaster@shipsimu.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.shipsimu.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 BaseProtocolResolver extends BaseHubSystem {
+ /**
+ * Protected constructor
+ *
+ * @param $className Name of the class
+ * @return void
+ */
+ protected function __construct ($className) {
+ // Call parent constructor
+ parent::__construct($className);
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * A TCP protocol resolver class
+ *
+ * @author Roland Haeder <webmaster@shipsimu.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.shipsimu.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 TcpProtocolResolver extends BaseProtocolResolver implements ProtocolResolver, Registerable {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+
+ // Set protocol type
+ $this->setProtocolName('tcp');
+ }
+
+ /**
+ * Creates an instance of a TCP protocol resolver
+ *
+ * @return $resolverInstance The prepared command resolver instance
+ */
+ public static final function createTcpProtocolResolver () {
+ // Create the new instance
+ $resolverInstance = new TcpProtocolResolver();
+
+ // Return the prepared instance
+ return $resolverInstance;
+ }
+
+ /**
+ * Returns an instance of a LocateableNode class for a given NodeHelper
+ * instance or null if it was not found.
+ *
+ * @param $nodeInstance An instance of a NodeHelper class
+ * @return $unlInstance An instance of a LocateableNode class
+ * @todo 0% done
+ */
+ public function resolveUniversalNodeLocatorFromNodeHelper (NodeHelper $nodeInstance) {
+ // Get search instance (to lookup database result)
+ $searchInstance = $nodeInstance->getSearchInstance();
+
+ // Make sure the in stance is valid
+ assert($searchInstance instanceof SearchCriteria);
+
+ // Refetch and rewind iterator
+ $resultInstance = $nodeInstance->getWrapperInstance()->doSelectByCriteria($searchInstance);
+
+ // 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
+
+ // 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;
+ }
+
+ /**
+ * Returns the UNL as string from given configuration key.
+ *
+ * @param $configKey Configuration key for UNL address (valid: internal,external)
+ * @return $unl Universal node locator
+ */
+ public function resolveUniversalNodeLocatorFromConfigKey ($configKey) {
+ // Get address
+ $address = $this->getConfigInstance()->getConfigEntry($configKey . '_address');
+
+ // Is the address empty?
+ if (empty($address)) {
+ // Okay, then find it
+ switch ($configKey) {
+ case 'external': // External IP
+ $address = ConsoleTools::determineExternalAddress();
+ break;
+
+ case 'internal': // Internal IP
+ $address = ConsoleTools::acquireSelfIPAddress();
+ break;
+ } // END - switch
+ } // END - if
+
+ // Put all together
+ $unl = sprintf('%s://%s:%s',
+ $this->getProtocolName(),
+ $address,
+ $this->getConfigInstance()->getConfigEntry('node_listen_port')
+ );
+
+ /*
+ * And return it. Please note that e.g. a FaxProtocolResolver will
+ * return a different UNL and therefore all protocol resolvers must do
+ * it on their own way.
+ */
+ return $unl;
+ }
+}
+
+// [EOF]
+?>
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @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
*
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @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
*
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @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
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
parent::__construct(__CLASS__);
// "Cache" CSV path for faster usage
- $this->csvFilePath = $this->getConfigInstance()->getConfigEntry('base_path') . '/' . $this->getConfigInstance()->getConfigEntry('csv_file_path');
+ $this->csvFilePath = $this->getConfigInstance()->getConfigEntry('base_path') . '/' . $this->getConfigInstance()->getConfigEntry('crawler_csv_file_path');
// Initialize directory instance
$directoryInstance = ObjectFactory::createObjectByConfiguredName('directory_class', array($this->csvFilePath));
}
/**
- * Creates an instance of this class
- *
- * @return $sourceInstance An instance of a Source class
- */
- public final static function createCrawlerUploadedListUrlSource () {
- // Get new instance
- $sourceInstance = new CrawlerUploadedListUrlSource();
-
- // Init source
- $sourceInstance->initSource('crawler', 'uploaded_list');
-
- // Return the prepared instance
- return $sourceInstance;
- }
-
- /**
- * Checks whether a CSV file is found
+ * Checks whether a CSV file is found in configured path
*
* @return $isFound Whether a CSV file is found
*/
private function isCsvFileFound () {
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CRAWLER-SOURCE [' . __METHOD__ . ':' . __LINE__ . ']: CALLED!');
- // Is the instance valid?
+ // Is it valid?
if (!$this->getDirectoryInstance()->getDirectoryIteratorInstance()->valid()) {
- // Then rewind it
+ // Rewind to start
$this->getDirectoryInstance()->getDirectoryIteratorInstance()->rewind();
} // END - if
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CRAWLER-SOURCE [' . __METHOD__ . ':' . __LINE__ . ']: this->csvFileImported=' . print_r($this->csvFileImported, TRUE));
$directoryEntry = $this->getDirectoryInstance()->readDirectoryExcept(array_merge(array('.htaccess', '.', '..'), $this->csvFileImported));
- // The read entry has not to be empty and extension must be '.csv'
+ // Debug message
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CRAWLER-SOURCE[' . __METHOD__ . ':' . __LINE__ . '] directoryEntry(' . strlen($directoryEntry) . ')=' . $directoryEntry);
+
+ // Is it empty or wrong file extension?
if ((empty($directoryEntry)) || (substr($directoryEntry, -4, 4) != '.csv')) {
// Skip further processing
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CRAWLER-SOURCE[' . __METHOD__ . ':' . __LINE__ . '] directoryEntry(' . strlen($directoryEntry) . ')=' . $directoryEntry . ' - SKIPPED!');
return FALSE;
} // END - if
return TRUE;
}
+ /**
+ * Creates an instance of this class
+ *
+ * @return $sourceInstance An instance of a Source class
+ */
+ public final static function createCrawlerUploadedListUrlSource () {
+ // Get new instance
+ $sourceInstance = new CrawlerUploadedListUrlSource();
+
+ // Init source
+ $sourceInstance->initSource('crawler', 'uploaded_list');
+
+ // Return the prepared instance
+ return $sourceInstance;
+ }
+
/**
* Checks whether a CSV file has been loaded (added to the stack)
*
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @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
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @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
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
* @todo Create generic DHT interface
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @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
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @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
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
* @todo Find an interface for hub helper
class ConnectionStatisticsHelper extends BaseHubSystem {
/**
* Statistics array
+ * @TODO Add more protocols to use
*/
private static $connectionStatistics = array(
// Statistics for TCP connections
public static function isConnectRetryExhausted (ConnectionHelper $helperInstance) {
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-STATISTICS[' . __METHOD__ . ':' . __LINE__ . ']: helperInstance=' . $helperInstance->__toString() . ' - ENTERED!');
// Construct config entry
- $configEntry = $helperInstance->getProtocol() . '_connect_retry_max';
+ $configEntry = $helperInstance->getProtocolName() . '_connect_retry_max';
// Check it out
$isExhausted = (
(
- isset(self::$connectionStatistics[$helperInstance->getProtocol()][$helperInstance->__toString()]['retry_count'])
+ isset(self::$connectionStatistics[$helperInstance->getProtocolName()][$helperInstance->__toString()]['retry_count'])
) && (
- self::$connectionStatistics[$helperInstance->getProtocol()][$helperInstance->__toString()]['retry_count'] >= $helperInstance->getConfigInstance()->getConfigEntry($configEntry)
+ self::$connectionStatistics[$helperInstance->getProtocolName()][$helperInstance->__toString()]['retry_count'] >= $helperInstance->getConfigInstance()->getConfigEntry($configEntry)
)
);
public static function increaseConnectRetry (ConnectionHelper $helperInstance) {
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-STATISTICS[' . __METHOD__ . ':' . __LINE__ . ']: helperInstance=' . $helperInstance->__toString() . ' - ENTERED!');
// Is the counter there
- if (!isset(self::$connectionStatistics[$helperInstance->getProtocol()][$helperInstance->__toString()]['retry_count'])) {
+ if (!isset(self::$connectionStatistics[$helperInstance->getProtocolName()][$helperInstance->__toString()]['retry_count'])) {
// First attempt
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-STATISTICS[' . __METHOD__ . ':' . __LINE__ . ']: helperInstance=' . $helperInstance->__toString() . ' - FIRST!');
- self::$connectionStatistics[$helperInstance->getProtocol()][$helperInstance->__toString()]['retry_count'] = 1;
+ self::$connectionStatistics[$helperInstance->getProtocolName()][$helperInstance->__toString()]['retry_count'] = 1;
} else {
// Next attempt
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-STATISTICS[' . __METHOD__ . ':' . __LINE__ . ']: helperInstance=' . $helperInstance->__toString() . ' - INCREMENT!');
- self::$connectionStatistics[$helperInstance->getProtocol()][$helperInstance->__toString()]['retry_count']++;
+ self::$connectionStatistics[$helperInstance->getProtocolName()][$helperInstance->__toString()]['retry_count']++;
}
// Create/update 'last_update' for purging
// @TODO last_update is not being used at the moment
- self::$connectionStatistics[$helperInstance->getProtocol()][$helperInstance->__toString()]['last_update'] = time();
+ self::$connectionStatistics[$helperInstance->getProtocolName()][$helperInstance->__toString()]['last_update'] = time();
}
}
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @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
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
const EXCEPTION_INVALID_TAG = 0x160;
/**
- * Last found protocol
+ * Last found protocol instance
*/
- private $lastProtocol = 'invalid';
+ private $lastProtocol = NULL;
/**
* Last found recipient type
* @return void
*/
private function extractTagsFromPackageData (array $packageData) {
+ // Debug message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('TAGS[' . __METHOD__ . ':' . __LINE__ . ']: packageData=' . print_r($packageData, TRUE));
+
/*
* We take a look at the tags (in most cases only one is needed) so
* first we need the content data splitted up into all it's parts.
* shared over the whole hub-network. So if the "tag" (let's better say
* object type) isn't found in that XML the package won't be distributed.
*
+ * @param $packageData Raw package data
* @return void
* @throws InvalidTagException If a provided tag from the package data is invalid
*/
- private function verifyAllTags () {
+ private function verifyAllTags (array $packageData) {
// Get the registry
$objectRegistryInstance = ObjectTypeRegistryFactory::createObjectTypeRegistryInstance();
} // END - if
// Now save the last discovered protocol/recipient type
- $this->lastProtocol = $entry[XmlObjectRegistryTemplateEngine::OBJECT_TYPE_DATA_PROTOCOL];
+ $this->lastProtocol = ProtocolHandlerFactory::createProtocolHandlerFromPackageData($packageData);
$this->lastRecipientType = $entry[XmlObjectRegistryTemplateEngine::OBJECT_TYPE_DATA_RECIPIENT_TYPE];
} // END - foreach
}
* Chooses the right protocol from given package data
*
* @param $packageData Raw package data
- * @return $protocolName Name of the choosen procotol
+ * @return $lastProtocol An instance of the last used HandleableProtocol class
*/
public function chooseProtocolFromPackageData (array $packageData) {
// Extract the tags
$this->extractTagsFromPackageData($packageData);
// Now we need to verify every single tag
- $this->verifyAllTags();
-
- // Use the last found protocol for transmission
- $protocolName = $this->lastProtocol;
+ $this->verifyAllTags($packageData);
- // Return it
- return $protocolName;
+ // Return the last (and only) found protocol (e.g. 'tcp' is very usual)
+ return $this->lastProtocol;
}
/**
$this->extractTagsFromPackageData($packageData);
// Now we need to verify every single tag
- $this->verifyAllTags();
+ $this->verifyAllTags($packageData);
// Now simply check it out
$accepts = (($this->lastRecipientType == $listenerInstance->getListenerType()) && ($listenerInstance->getListenerType() != 'invalid'));
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @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
*
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @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
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @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
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
* @todo This template engine does not make use of setTemplateType()
/**
* Some XML nodes must be available for later data extraction
*/
- const ANNOUNCEMENT_DATA_SESSION_ID = 'session-id';
- const ANNOUNCEMENT_DATA_NODE_STATUS = 'node-status';
- const ANNOUNCEMENT_DATA_NODE_MODE = 'node-mode';
- const ANNOUNCEMENT_DATA_EXTERNAL_IP = 'external-ip';
- const ANNOUNCEMENT_DATA_INTERNAL_IP = 'internal-ip';
- const ANNOUNCEMENT_DATA_LISTEN_PORT = 'listen-port';
+ const ANNOUNCEMENT_DATA_SESSION_ID = 'session-id';
+ const ANNOUNCEMENT_DATA_NODE_STATUS = 'node-status';
+ const ANNOUNCEMENT_DATA_NODE_MODE = 'node-mode';
+ const ANNOUNCEMENT_DATA_EXTERNAL_ADDRESS = 'external-address';
+ const ANNOUNCEMENT_DATA_INTERNAL_ADDRESS = 'internal-address';
/**
* Protected constructor
'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_IP,
- self::ANNOUNCEMENT_DATA_INTERNAL_IP,
+ self::ANNOUNCEMENT_DATA_EXTERNAL_ADDRESS,
+ self::ANNOUNCEMENT_DATA_INTERNAL_ADDRESS,
'object-type-list',
);
}
$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
*
*
* @return void
*/
- protected function startExternalIp () {
+ protected function startExternalAddress () {
// Push the node name on the stacker
- $this->getStackInstance()->pushNamed('node_announcement', self::ANNOUNCEMENT_DATA_EXTERNAL_IP);
+ $this->getStackInstance()->pushNamed('node_announcement', self::ANNOUNCEMENT_DATA_EXTERNAL_ADDRESS);
}
/**
*
* @return void
*/
- protected function startInternalIp () {
+ protected function startInternalAddress () {
// Push the node name on the stacker
- $this->getStackInstance()->pushNamed('node_announcement', self::ANNOUNCEMENT_DATA_INTERNAL_IP);
+ $this->getStackInstance()->pushNamed('node_announcement', self::ANNOUNCEMENT_DATA_INTERNAL_ADDRESS);
}
/**
*
* @return void
*/
- protected function finishInternalIp () {
+ protected function finishInternalAddress () {
// Pop the last entry
$this->getStackInstance()->popNamed('node_announcement');
}
*
* @return void
*/
- protected function finishExternalIp () {
- // Pop the last entry
- $this->getStackInstance()->popNamed('node_announcement');
- }
-
- /**
- * Finishes the TCP/UDP listen port
- *
- * @return void
- */
- protected function finishListenPort () {
+ protected function finishExternalAddress () {
// Pop the last entry
$this->getStackInstance()->popNamed('node_announcement');
}
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
* @todo This template engine does not make use of setTemplateType()
/**
* Some XML nodes must be available for later data extraction
*/
- const ANNOUNCEMENT_DATA_SESSION_ID = 'my-session-id';
- 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_LISTEN_PORT = 'my-listen-port';
+ const ANNOUNCEMENT_DATA_SESSION_ID = 'my-session-id';
+ const ANNOUNCEMENT_DATA_NODE_STATUS = 'my-status';
+ const ANNOUNCEMENT_DATA_EXTERNAL_ADDRESS = 'my-external-address';
+ const ANNOUNCEMENT_DATA_INTERNAL_ADDRESS = 'my-internal-address';
/**
* Protected constructor
'my-data',
'your-data',
// Data from *this* node
- self::ANNOUNCEMENT_DATA_EXTERNAL_IP,
- self::ANNOUNCEMENT_DATA_INTERNAL_IP,
- self::ANNOUNCEMENT_DATA_LISTEN_PORT,
+ self::ANNOUNCEMENT_DATA_EXTERNAL_ADDRESS,
+ self::ANNOUNCEMENT_DATA_INTERNAL_ADDRESS,
self::ANNOUNCEMENT_DATA_NODE_STATUS,
self::ANNOUNCEMENT_DATA_SESSION_ID,
// Data from other node
- 'your-external-ip',
- 'your-internal-ip',
+ 'your-external-address',
+ 'your-internal-address',
'your-session-id',
// Answer status (generic field)
self::ANSWER_STATUS,
}
/**
- * Starts the my-external-ip
+ * Starts the my-external-address
*
* @return void
*/
- protected function startMyExternalIp () {
+ protected function startMyExternalAddress () {
// Push the node name on the stacker
- $this->getStackInstance()->pushNamed('node_announcement_answer', self::ANNOUNCEMENT_DATA_EXTERNAL_IP);
+ $this->getStackInstance()->pushNamed('node_announcement_answer', self::ANNOUNCEMENT_DATA_EXTERNAL_ADDRESS);
}
/**
- * Starts the my-internal-ip
+ * Starts the my-internal-address
*
* @return void
*/
- protected function startMyInternalIp () {
+ protected function startMyInternalAddress () {
// Push the node name on the stacker
- $this->getStackInstance()->pushNamed('node_announcement_answer', self::ANNOUNCEMENT_DATA_INTERNAL_IP);
- }
-
- /**
- * 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);
+ $this->getStackInstance()->pushNamed('node_announcement_answer', self::ANNOUNCEMENT_DATA_INTERNAL_ADDRESS);
}
/**
}
/**
- * Finishes the my-tcp-port
- *
- * @return void
- */
- protected function finishMyListenPort () {
- // Pop the last entry
- $this->getStackInstance()->popNamed('node_announcement_answer');
- }
-
- /**
- * Finishes the my-internal-ip
+ * Finishes the my-internal-address
*
* @return void
*/
- protected function finishMyInternalIp () {
+ protected function finishMyInternalAddress () {
// Pop the last entry
$this->getStackInstance()->popNamed('node_announcement_answer');
}
/**
- * Finishes the my-external-ip
+ * Finishes the my-external-address
*
* @return void
*/
- protected function finishMyExternalIp () {
+ protected function finishMyExternalAddress () {
// Pop the last entry
$this->getStackInstance()->popNamed('node_announcement_answer');
}
}
/**
- * Starts the your-external-ip
+ * Starts the your-external-address
*
* @return void
*/
- protected function startYourExternalIp () {
+ protected function startYourExternalAddress () {
// Push the node name on the stacker
- $this->getStackInstance()->pushNamed('node_announcement_answer', 'your-external-ip');
+ $this->getStackInstance()->pushNamed('node_announcement_answer', 'your-external-address');
}
/**
- * Starts the your-internal-ip
+ * Starts the your-internal-address
*
* @return void
*/
- protected function startYourInternalIp () {
+ protected function startYourInternalAddress () {
// Push the node name on the stacker
- $this->getStackInstance()->pushNamed('node_announcement_answer', 'your-internal-ip');
+ $this->getStackInstance()->pushNamed('node_announcement_answer', 'your-internal-address');
}
/**
}
/**
- * Finishes the your-internal-ip
+ * Finishes the your-internal-address
*
* @return void
*/
- protected function finishYourInternalIp () {
+ protected function finishYourInternalAddress () {
// Pop the last entry
$this->getStackInstance()->popNamed('node_announcement_answer');
}
/**
- * Finishes the your-external-ip
+ * Finishes the your-external-address
*
* @return void
*/
- protected function finishYourExternalIp () {
+ protected function finishYourExternalAddress () {
// Pop the last entry
$this->getStackInstance()->popNamed('node_announcement_answer');
}
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 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()
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
* @todo This template engine does not make use of setTemplateType()
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
* @todo This template engine does not make use of setTemplateType()
/**
* Some XML nodes must be available for later data extraction
*/
- const DHT_BOOTSTRAP_DATA_SESSION_ID = 'my-session-id';
- const DHT_BOOTSTRAP_DATA_NODE_STATUS = 'my-status';
- const DHT_BOOTSTRAP_DATA_EXTERNAL_IP = 'my-external-ip';
- const DHT_BOOTSTRAP_DATA_INTERNAL_IP = 'my-internal-ip';
- const DHT_BOOTSTRAP_DATA_LISTEN_PORT = 'my-listen-port';
- const DHT_BOOTSTRAP_DATA_NODE_LIST = 'dht-nodes-list';
+ const DHT_BOOTSTRAP_DATA_SESSION_ID = 'my-session-id';
+ 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_NODE_LIST = 'dht-nodes-list';
/**
* Protected constructor
'my-data',
'your-data',
// Data from *this* node
- self::DHT_BOOTSTRAP_DATA_EXTERNAL_IP,
- self::DHT_BOOTSTRAP_DATA_INTERNAL_IP,
- self::DHT_BOOTSTRAP_DATA_LISTEN_PORT,
+ self::DHT_BOOTSTRAP_DATA_EXTERNAL_ADDRESS,
+ self::DHT_BOOTSTRAP_DATA_INTERNAL_ADDRESS,
self::DHT_BOOTSTRAP_DATA_NODE_STATUS,
self::DHT_BOOTSTRAP_DATA_SESSION_ID,
// Data from other node
- 'your-external-ip',
- 'your-internal-ip',
+ 'your-external-address',
+ 'your-internal-address',
'your-session-id',
// Answer status (generic field)
self::ANSWER_STATUS,
}
/**
- * Starts the my-external-ip
+ * Starts the my-external-address
*
* @return void
*/
- protected function startMyExternalIp () {
+ protected function startMyExternalAddress () {
// Push the node name on the stacker
- $this->getStackInstance()->pushNamed('node_dht_bootstrap_answer', self::DHT_BOOTSTRAP_DATA_EXTERNAL_IP);
+ $this->getStackInstance()->pushNamed('node_dht_bootstrap_answer', self::DHT_BOOTSTRAP_DATA_EXTERNAL_ADDRESS);
}
/**
- * Starts the my-internal-ip
+ * Starts the my-internal-address
*
* @return void
*/
- protected function startMyInternalIp () {
+ protected function startMyInternalAddress () {
// Push the node name on the stacker
- $this->getStackInstance()->pushNamed('node_dht_bootstrap_answer', self::DHT_BOOTSTRAP_DATA_INTERNAL_IP);
- }
-
- /**
- * 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);
+ $this->getStackInstance()->pushNamed('node_dht_bootstrap_answer', self::DHT_BOOTSTRAP_DATA_INTERNAL_ADDRESS);
}
/**
}
/**
- * 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-ip
+ * Finishes the my-internal-address
*
* @return void
*/
- protected function finishMyInternalIp () {
+ protected function finishMyInternalAddress () {
// Pop the last entry
$this->getStackInstance()->popNamed('node_dht_bootstrap_answer');
}
/**
- * Finishes the my-external-ip
+ * Finishes the my-external-address
*
* @return void
*/
- protected function finishMyExternalIp () {
+ protected function finishMyExternalAddress () {
// Pop the last entry
$this->getStackInstance()->popNamed('node_dht_bootstrap_answer');
}
}
/**
- * Starts the your-external-ip
+ * Starts the your-external-address
*
* @return void
*/
- protected function startYourExternalIp () {
+ protected function startYourExternalAddress () {
// Push the node name on the stacker
- $this->getStackInstance()->pushNamed('node_dht_bootstrap_answer', 'your-external-ip');
+ $this->getStackInstance()->pushNamed('node_dht_bootstrap_answer', 'your-external-address');
}
/**
- * Starts the your-internal-ip
+ * Starts the your-internal-address
*
* @return void
*/
- protected function startYourInternalIp () {
+ protected function startYourInternalAddress () {
// Push the node name on the stacker
- $this->getStackInstance()->pushNamed('node_dht_bootstrap_answer', 'your-internal-ip');
+ $this->getStackInstance()->pushNamed('node_dht_bootstrap_answer', 'your-internal-address');
}
/**
}
/**
- * Finishes the your-internal-ip
+ * Finishes the your-internal-address
*
* @return void
*/
- protected function finishYourInternalIp () {
+ protected function finishYourInternalAddress () {
// Pop the last entry
$this->getStackInstance()->popNamed('node_dht_bootstrap_answer');
}
/**
- * Finishes the your-external-ip
+ * Finishes the your-external-address
*
* @return void
*/
- protected function finishYourExternalIp () {
+ protected function finishYourExternalAddress () {
// Pop the last entry
$this->getStackInstance()->popNamed('node_dht_bootstrap_answer');
}
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
* @todo This template engine does not make use of setTemplateType()
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 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()
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
* @todo This template engine does not make use of setTemplateType()
}
/**
- * Handles the template dependency for given node
+ * Handles the template dependency for given XML node
*
- * @param $node The node we should load a dependency template
+ * @param $node The XML node we should load a dependency template
* @param $templateDependency A template to load to satisfy dependencies
* @return void
*/
protected function handleTemplateDependency ($node, $templateDependency) {
- // Check that node is not empty
+ // Check that the XML node is not empty
assert(!empty($node));
// Is the template dependency set?
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
* @todo This template engine does not make use of setTemplateType()
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
* @todo This template engine does not make use of setTemplateType()
/**
* Some XML nodes must be available for later data extraction
*/
- const DHT_BOOTSTRAP_DATA_BOOTSTRAP_DATA = 'dht-bootstrap-data';
- const DHT_BOOTSTRAP_DATA_SESSION_ID = 'session-id';
- const DHT_BOOTSTRAP_DATA_NODE_STATUS = 'node-status';
- const DHT_BOOTSTRAP_DATA_NODE_MODE = 'node-mode';
- const DHT_BOOTSTRAP_DATA_EXTERNAL_IP = 'external-ip';
- const DHT_BOOTSTRAP_DATA_INTERNAL_IP = 'internal-ip';
- const DHT_BOOTSTRAP_DATA_LISTEN_PORT = 'listen-port';
+ const DHT_BOOTSTRAP_DATA_BOOTSTRAP_DATA = 'dht-bootstrap-data';
+ const DHT_BOOTSTRAP_DATA_SESSION_ID = 'session-id';
+ const DHT_BOOTSTRAP_DATA_NODE_STATUS = 'node-status';
+ const DHT_BOOTSTRAP_DATA_NODE_MODE = 'node-mode';
+ const DHT_BOOTSTRAP_DATA_EXTERNAL_ADDRESS = 'external-address';
+ const DHT_BOOTSTRAP_DATA_INTERNAL_ADDRESS = 'internal-address';
/**
* Protected constructor
'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_IP,
- self::DHT_BOOTSTRAP_DATA_INTERNAL_IP
+ self::DHT_BOOTSTRAP_DATA_EXTERNAL_ADDRESS,
+ self::DHT_BOOTSTRAP_DATA_INTERNAL_ADDRESS
);
}
$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
*
* @return void
*/
- protected function startExternalIp () {
+ protected function startExternalAddress () {
// Push the node name on the stacker
- $this->getStackInstance()->pushNamed('dht_bootstrap', self::DHT_BOOTSTRAP_DATA_EXTERNAL_IP);
+ $this->getStackInstance()->pushNamed('dht_bootstrap', self::DHT_BOOTSTRAP_DATA_EXTERNAL_ADDRESS);
}
/**
*
* @return void
*/
- protected function startInternalIp () {
+ protected function startInternalAddress () {
// Push the node name on the stacker
- $this->getStackInstance()->pushNamed('dht_bootstrap', self::DHT_BOOTSTRAP_DATA_INTERNAL_IP);
+ $this->getStackInstance()->pushNamed('dht_bootstrap', self::DHT_BOOTSTRAP_DATA_INTERNAL_ADDRESS);
}
/**
*
* @return void
*/
- protected function finishInternalIp () {
+ protected function finishInternalAddress () {
// Pop the last entry
$this->getStackInstance()->popNamed('dht_bootstrap');
}
*
* @return void
*/
- protected function finishExternalIp () {
- // Pop the last entry
- $this->getStackInstance()->popNamed('dht_bootstrap');
- }
-
- /**
- * Finishes the TCP/UDP listen port
- *
- * @return void
- */
- protected function finishListenPort () {
+ protected function finishExternalAddress () {
// Pop the last entry
$this->getStackInstance()->popNamed('dht_bootstrap');
}
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
* @todo This template engine does not make use of setTemplateType()
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
* @todo This template engine does not make use of setTemplateType()
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
* @todo This template engine does not make use of setTemplateType()
const PUBLISH_DATA_SESSION_ID = 'session-id';
const PUBLISH_DATA_NODE_STATUS = 'node-status';
const PUBLISH_DATA_NODE_MODE = 'node-mode';
- const PUBLISH_DATA_EXTERNAL_IP = 'external-ip';
- const PUBLISH_DATA_LISTEN_PORT = 'listen-port';
+ const PUBLISH_DATA_EXTERNAL_ADDRESS = 'external-address';
const PUBLISH_DATA_PRIVATE_KEY_HASH = 'private-key-hash';
const PUBLISH_DATA_ACCEPTED_OBJECT_TYPES = 'accepted-object-types';
'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,
self::PUBLISH_DATA_SESSION_ID,
- self::PUBLISH_DATA_EXTERNAL_IP,
+ self::PUBLISH_DATA_EXTERNAL_ADDRESS,
'object-type-list',
);
}
$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
*
*
* @return void
*/
- protected function startExternalIp () {
+ protected function startExternalAddress () {
// Push the node name on the stacker
- $this->getStackInstance()->pushNamed('dht_publish', self::PUBLISH_DATA_EXTERNAL_IP);
+ $this->getStackInstance()->pushNamed('dht_publish', self::PUBLISH_DATA_EXTERNAL_ADDRESS);
}
/**
*
* @return void
*/
- protected function finishExternalIp () {
- // Pop the last entry
- $this->getStackInstance()->popNamed('dht_publish');
- }
-
- /**
- * Finishes the TCP/UDP listen port
- *
- * @return void
- */
- protected function finishListenPort () {
+ protected function finishExternalAddress () {
// Pop the last entry
$this->getStackInstance()->popNamed('dht_publish');
}
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
* @todo This template engine does not make use of setTemplateType()
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
}
/**
- * Resolves a session id into an ip:port combination. The opposite method
- * is resolveSessionIdByIpPort()
+ * Resolves a session id into an instance of a LocateableNode class. The opposite method
+ * is resolveSessionIdByUniversalNodeLocator()
*
* @param $sessionId A valid session id
- * @return $recipientIpPort Recipient as ip:port combination
+ * @return $recipientUniversalNodeLocator Recipient as Universal Node Locator
*/
- protected function resolveIpPortBySessionId ($sessionId) {
+ protected function resolveUniversalNodeLocatorBySessionId ($sessionId) {
// Init variable
- $recipientIpPort = 'invalid:invalid';
+ die(__METHOD__ . ': UNFINISHED: sessionId=' . $sessionId . PHP_EOL);
+ $recipientUniversalNodeLocator = 'invalid://invalid:invalid';
- // And ask it for ip:port by given session id
+ // And ask it for Universal Node Locator by given session id
$recipient = $this->getDhtInstance()->findNodeLocalBySessionId($sessionId);
// Is the recipient valid?
- if ((isset($recipient[NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_EXTERNAL_IP])) && (isset($recipient[NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_LISTEN_PORT]))) {
+ if (isset($recipient[NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_EXTERNAL_ADDRESS])) {
// Then use this
- $recipientIpPort = $recipient[NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_EXTERNAL_IP] . ':' . $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();
// Is the session id the same?
if ($nodeInstance->getSessionId() == $sessionId) {
- // Then get the ip:port from it, assume TCP by default
- $recipientIpPort = self::determineOwnExternalIp() . ':' . $nodeInstance->getConfigInstance()->getConfigEntry('node_listen_port');
+ // Then get an instance of a LocateableNode class from it, assume TCP by default
+ $recipientUniversalNodeLocator = self::determineOwnExternalAddress() . ':' . $nodeInstance->getConfigInstance()->getConfigEntry('node_listen_port');
} // END - if
}
// Return result
- return $recipientIpPort;
+ return $recipientUniversalNodeLocator;
}
/**
- * Resolves a ip:port combination into a session id. The "opposite" method
- * is resolveIpPortBySessionId().
+ * Resolves a Universal Node Locator into a session id. The "opposite" method
+ * is resolveUniversalNodeLocatorBySessionId().
*
- * @param $ipPort Ip:port combination
- * @return $sessionId Valid session id
+ * @param $unlInstance Universal Node Locator
+ * @return $sessionId Valid session id
*/
- public static function resolveSessionIdByIpPort ($ipPort) {
+ public static function resolveSessionIdByUniversalNodeLocator (LocateableNode $unlInstance) {
// Get an own instance
$selfInstance = self::getSelfInstance();
- // And ask it for session id by given ip:port
- $recipient = $selfInstance->getDhtInstance()->findNodeByIpPort($ipPort);
- die(__METHOD__.':recipient=<pre>'.print_r($recipient, TRUE).'</pre>' . PHP_EOL);
+ // And ask it for session id by given Universal Node Locator
+ $recipient = $selfInstance->getDhtInstance()->findNodeByUniversalNodeLocator($unlInstance);
+ die(__METHOD__.':recipient='.print_r($recipient, TRUE));
// Return result
return $sessionId;
}
/**
- * Resolves given session id into an ip:port combination, if ip:port is set, it won't be translated
+ * Resolves given session id into an instance of a LocateableNode class, if Universal Node Locator is set, it won't be translated
*
- * @param $sessionId Session id or ip:port combination
- * @return $recipient Recipient as ip:port combination
- * @throws InvalidSessionIdException If the provided session id is invalid (and no ip:port combination)
+ * @param $address Session id or Universal Node Locator
+ * @return $recipient Recipient as Universal Node Locator
+ * @throws InvalidSessionIdException If the provided session id is invalid (and no Universal Node Locator)
* @throws NoValidHostnameException If the provided hostname cannot be resolved into an IP address
*/
- public static function resolveSessionId ($sessionId) {
+ public static function resolveSessionId ($address) {
// Get an own instance
$selfInstance = self::getSelfInstance();
- // Default is direct ip:port
- $recipient = $sessionId;
+ // Default is direct Universal Node Locator
+ $recipient = $address;
- // Does it match a direct ip:port? (hint: see www.regexlib.com for the regular expression)
- if (preg_match('/((25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9])\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[0-9])):([0-9]{3,5})/', $sessionId)) {
- // Direct ip:port found
- self::createDebugInstance(__CLASS__)->debugOutput('HUB-TOOLS[' . __METHOD__ . ':' . __LINE__ . ']: Direct ip:port ' . $sessionId . ' detected.');
- } elseif (isset($selfInstance->sessionIdCache[$sessionId])) {
+ // Does it match a direct Universal Node Locator? (hint: see www.regexlib.com for the regular expression)
+ if (preg_match('/([a-z0-9]{3,10})\/\/:([a-z0-9\.]{5,})/', $address)) {
+ // @TODO ((25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9])\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[0-9])):([0-9]{3,5})
+ // Direct Universal Node Locator found
+ self::createDebugInstance(__CLASS__)->debugOutput('HUB-TOOLS[' . __METHOD__ . ':' . __LINE__ . ']: Direct Universal Node Locator ' . $address . ' detected.');
+ } elseif (isset($selfInstance->sessionIdCache[$address])) {
// Debug message
self::createDebugInstance(__CLASS__)->debugOutput('HUB-TOOLS[' . __METHOD__ . ':' . __LINE__ . ']: Using entry from sessionIdCache[] array.');
// Found in cache!
- $recipient = $selfInstance->sessionIdCache[$sessionId];
+ $recipient = $selfInstance->sessionIdCache[$address];
// Debug message
- self::createDebugInstance(__CLASS__)->debugOutput('HUB-TOOLS[' . __METHOD__ . ':' . __LINE__ . ']: sessionIdCache[' . $sessionId . ']=' . $recipient);
- } elseif (preg_match('/([a-zA-Z0-9]([a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,6}:([0-9]{3,5})/', $sessionId)) {
- // Hostname:port found
- self::createDebugInstance(__CLASS__)->debugOutput('HUB-TOOLS[' . __METHOD__ . ':' . __LINE__ . ']: hostname:port ' . $sessionId . ' detected.');
-
- // Hostname:port found
- $hostnameArray = explode(':', $sessionId);
-
- /*
- * Try to resolve it and add port again
- * @TODO Please try to encapsulate this PHP call into an own class
- */
- $recipient = gethostbyname($hostnameArray[0]) . ':' . $hostnameArray[1];
-
- // Is it valid?
- if ($recipient == $sessionId) {
- // Resolving hostname->IP failed!
- throw new NoValidHostnameException($hostnameArray, self::EXCEPTION_HOSTNAME_NOT_FOUND);
- } // END - if
-
- // Debug message
- self::createDebugInstance(__CLASS__)->debugOutput('HUB-TOOLS[' . __METHOD__ . ':' . __LINE__ . ']: hostname:port ' . $sessionId . ' resolved to ' . $recipient);
- } elseif (preg_match('/([a-f0-9]{' . $selfInstance->getSessionIdLength() . '})/', $sessionId)) {
+ self::createDebugInstance(__CLASS__)->debugOutput('HUB-TOOLS[' . __METHOD__ . ':' . __LINE__ . ']: sessionIdCache[' . $address . ']=' . $recipient);
+ } elseif (preg_match('/([a-f0-9]{' . $selfInstance->getSessionIdLength() . '})/', $address)) {
// Debug message
self::createDebugInstance(__CLASS__)->debugOutput('HUB-TOOLS[' . __METHOD__ . ':' . __LINE__ . ']: Using internal session id resolver.');
- // Resolve session id into a ip:port combination
- $recipient = $selfInstance->resolveIpPortBySessionId($sessionId);
+ // Resolve session id into an instance of a LocateableNode class
+ $recipient = $selfInstance->resolveUniversalNodeLocatorBySessionId($address);
// Debug message
- self::createDebugInstance(__CLASS__)->debugOutput('HUB-TOOLS[' . __METHOD__ . ':' . __LINE__ . ']: Session id ' . $sessionId . ' resolved to ' . $recipient);
+ self::createDebugInstance(__CLASS__)->debugOutput('HUB-TOOLS[' . __METHOD__ . ':' . __LINE__ . ']: Session id ' . $address . ' resolved to ' . $recipient);
} else {
- // Invalid session id
- throw new InvalidSessionIdException($sessionId, self::EXCEPTION_SESSION_ID_IS_INVALID);
+ // Invalid session id/UNL
+ throw new InvalidSessionIdException($address, self::EXCEPTION_SESSION_ID_IS_INVALID);
}
// Return it
}
/**
- * Determine IP or 'external_ip' if set
+ * Determine UNL or 'external_address' if set
*
- * @return $ip The determined external ip of this node
+ * @return $unl The determined external UNL of this node
*/
- public static function determineOwnExternalIp () {
- // Is the external_ip config entry set?
- if (FrameworkConfiguration::getSelfInstance()->getConfigEntry('external_ip') != '') {
- // Use it as external ip
- $ip = FrameworkConfiguration::getSelfInstance()->getConfigEntry('external_ip');
+ public static function determineOwnExternalAddress () {
+ // Is the external_address config entry set?
+ if (FrameworkConfiguration::getSelfInstance()->getConfigEntry('external_address') != '') {
+ // Use it as external address
+ $unl = FrameworkConfiguration::getSelfInstance()->getConfigEntry('external_address');
} else {
- // Determine own external ip by connecting to my (coder) server at 188.138.90.169
- $ip = ConsoleTools::determineExternalIp();
+ // Determine own external address by connecting to my (coder) server at 188.138.90.169
+ $unl = self::determineExternalUniversalNodeLocator();
}
// Return it
- return $ip;
+ return $unl;
}
/**
- * Determine IP or 'internal_ip' if set
+ * Determine UNL or 'internal_address' if set
*
- * @return $ip The determined external ip of this node
+ * @return $unl The determined internal UNL of this node
*/
- public static function determineOwnInternalIp () {
- // Is the internal_ip config entry set?
- if (FrameworkConfiguration::getSelfInstance()->getConfigEntry('allow_publish_internal_ip') == 'N') {
- // Not allowed to publish internal IP, so use external
- $ip = self::determineOwnExternalIp();
- } elseif (FrameworkConfiguration::getSelfInstance()->getConfigEntry('internal_ip') != '') {
- // Use it as internal ip
- $ip = FrameworkConfiguration::getSelfInstance()->getConfigEntry('internal_ip');
+ public static function determineOwnInternalAddress () {
+ // Is the internal_address config entry set?
+ if (FrameworkConfiguration::getSelfInstance()->getConfigEntry('allow_publish_internal_address') == 'N') {
+ // Not allowed to publish internal address, so use external
+ $unl = self::determineOwnExternalAddress();
+ } elseif (FrameworkConfiguration::getSelfInstance()->getConfigEntry('internal_address') != '') {
+ // Use it as internal address
+ $unl = FrameworkConfiguration::getSelfInstance()->getConfigEntry('internal_address');
} else {
- // Determine own internal ip by connecting to my (coder) server at 188.138.90.169
- $ip = ConsoleTools::acquireSelfIPAddress();
+ // Determine own internal address by connecting to my (coder) server at 188.138.90.169
+ $unl = self::determineInternalUniversalNodeLocator();
}
// Return it
- return $ip;
+ return $unl;
+ }
+
+ /**
+ * Determines the UNL (Universal Node Locator) for the internal address
+ *
+ * @return $internalUnl Internal UNL
+ */
+ public static function determineInternalUniversalNodeLocator () {
+ // Debug message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NODE[' . __METHOD__ . ':' . __LINE__ . ']: CALLED!');
+
+ // Is there cache? (This shortens a lot calls)
+ if (!isset($GLOBALS[__METHOD__])) {
+ // Determine UNL based on this node:
+ // 1) Get discovery class
+ $discoveryInstance = ObjectFactory::createObjectByConfiguredName('unl_discovery_class');
+
+ // 2) "Determine" it
+ $GLOBALS[__METHOD__] = $discoveryInstance->discoverUniversalNodeLocatorByConfiguredAddress('internal');
+
+ // Make sure it is valid
+ // @TODO Find a better validation than empty()
+ assert(!empty($GLOBALS[__METHOD__]));
+ } // END - if
+
+ // Return it
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NODE[' . __METHOD__ . ':' . __LINE__ . ']: unl=' . $GLOBALS[__METHOD__] . ' - EXIT!');
+ return $GLOBALS[__METHOD__];
+ }
+
+ /**
+ * Determines the UNL (Universal Node Locator) for the external address
+ *
+ * @return $externalUnl External UNL
+ */
+ public static function determineExternalUniversalNodeLocator () {
+ // Debug message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NODE[' . __METHOD__ . ':' . __LINE__ . ']: CALLED!');
+
+ // Is there cache? (This shortens a lot calls)
+ if (!isset($GLOBALS[__METHOD__])) {
+ // Determine UNL based on this node:
+ // 1) Get discovery class
+ $discoveryInstance = ObjectFactory::createObjectByConfiguredName('unl_discovery_class');
+
+ // 2) "Determine" it
+ $GLOBALS[__METHOD__] = $discoveryInstance->discoverUniversalNodeLocatorByConfiguredAddress('external');
+
+ // Make sure it is valid
+ // @TODO Find a better validation than empty()
+ assert(!empty($GLOBALS[__METHOD__]));
+ } // END - if
+
+ // Return it
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NODE[' . __METHOD__ . ':' . __LINE__ . ']: unl=' . $GLOBALS[__METHOD__] . ' - EXIT!');
+ return $GLOBALS[__METHOD__];
}
}
--- /dev/null
+Deny from all
--- /dev/null
+<?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]
+?>
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @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
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @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
*
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @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
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub; Developer Team
+ * @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
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
// Constants for database column names
const DB_COLUMN_NODE_ID = 'node_id';
const DB_COLUMN_SESSION_ID = 'session_id';
- const DB_COLUMN_EXTERNAL_IP = 'external_ip';
- const DB_COLUMN_LISTEN_PORT = 'listen_port';
+ const DB_COLUMN_EXTERNAL_ADDRESS = 'external_address';
const DB_COLUMN_PRIVATE_KEY_HASH = 'private_key_hash';
const DB_COLUMN_NODE_MODE = 'node_mode';
const DB_COLUMN_ACCEPTED_OBJECTS = 'accepted_object_types';
$elements = array(
self::DB_COLUMN_NODE_ID,
self::DB_COLUMN_SESSION_ID,
- self::DB_COLUMN_EXTERNAL_IP,
- self::DB_COLUMN_LISTEN_PORT,
+ self::DB_COLUMN_EXTERNAL_ADDRESS,
self::DB_COLUMN_PRIVATE_KEY_HASH,
self::DB_COLUMN_NODE_MODE,
self::DB_COLUMN_ACCEPTED_OBJECTS,
* @return $searchInstance An instance of a SearchCriteria class
*/
private function prepareSearchInstance (array $nodeData) {
+ // Debug message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-WRAPPER[' . __METHOD__ . ':' . __LINE__ . ']: CALLED!');
+
// Assert on array elements
assert(isset($nodeData[self::DB_COLUMN_NODE_ID]));
$searchInstance->addCriteria(self::DB_COLUMN_NODE_ID, $nodeData[self::DB_COLUMN_NODE_ID]);
$searchInstance->setLimit(1);
+ // Debug message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-WRAPPER[' . __METHOD__ . ':' . __LINE__ . ']: EXIT!');
+
// Return it
return $searchInstance;
}
* @return $dataSetInstance An instance of a StoreableCriteria class
*/
private function prepareLocalDataSetInstance () {
+ // Debug message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-WRAPPER[' . __METHOD__ . ':' . __LINE__ . ']: CALLED!');
+
// Get node/request instances
$nodeInstance = NodeObjectFactory::createNodeInstance();
$requestInstance = ApplicationHelper::getSelfInstance()->getRequestInstance();
// Set the primary key
$dataSetInstance->setUniqueKey(self::DB_COLUMN_NODE_ID);
- // Get ip:port combination and "explode" it
- $ipPort = $nodeInstance->getAddressPortArray();
+ // Get Universal Node Locator and "explode" it
+ $unlInstance = $nodeInstance->determineUniversalNodeLocator();
+
+ // Get UNL data from it
+ $unlData = $unlInstance->getUnlData();
// Make sure both is valid
- assert(($ipPort[0] !== 'invalid') && ($ipPort[1] !== 'invalid'));
+ // @TODO Bad check on UNL, better use a proper validator
+ assert(isset($unlData[NodeInformationDatabaseWrapper::DB_COLUMN_EXTERNAL_UNL]));
+ assert($unlData[NodeInformationDatabaseWrapper::DB_COLUMN_EXTERNAL_UNL] !== 'invalid');
// Get an array of all accepted object types
$objectList = $nodeInstance->getListFromAcceptedObjectTypes();
// Add public node data
$dataSetInstance->addCriteria(self::DB_COLUMN_NODE_MODE , $requestInstance->getRequestElement('mode'));
- $dataSetInstance->addCriteria(self::DB_COLUMN_EXTERNAL_IP , $ipPort[0]);
- $dataSetInstance->addCriteria(self::DB_COLUMN_LISTEN_PORT , $ipPort[1]);
+ $dataSetInstance->addCriteria(self::DB_COLUMN_EXTERNAL_ADDRESS, $unlData[NodeInformationDatabaseWrapper::DB_COLUMN_EXTERNAL_UNL]);
$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());
$dataSetInstance->addCriteria(self::DB_COLUMN_ACCEPTED_OBJECTS, implode(BaseHubNode::OBJECT_LIST_SEPARATOR, $objectList));
$dataSetInstance->addCriteria(self::DB_COLUMN_ACCEPT_BOOTSTRAP, $this->translateBooleanToYesNo($nodeInstance->isAcceptingDhtBootstrap()));
+ // Debug message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-WRAPPER[' . __METHOD__ . ':' . __LINE__ . ']: EXIT!');
+
// Return it
return $dataSetInstance;
}
/**
* Checks whether the local (*this*) node is registered in the DHT by
- * checking if the external ip/port is found.
+ * checking if the external address is found.
*
* @return $isRegistered Whether *this* node is registered in the DHT
*/
public function isLocalNodeRegistered () {
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-WRAPPER[' . __METHOD__ . ':' . __LINE__ . ']: CALLED!');
+ // Debug message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-WRAPPER[' . __METHOD__ . ':' . __LINE__ . ']: CALLED!');
// Get a search criteria instance
$searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class');
// Get node instance
$nodeInstance = NodeObjectFactory::createNodeInstance();
- // Get ip:port combination and "explode" it
- $ipPort = $nodeInstance->getAddressPortArray();
+ // Get Universal Node Locator and "explode" it
+ $unlData = $nodeInstance->getUniversalNodeLocatorArray();
- /*
- * Make sure both is not 'invalid' which means that the resolver
- * didn't work.
- */
- assert(($ipPort[0] !== 'invalid') && ($ipPort[1] !== 'invalid'));
+ // Make sure the external address is set and not invalid
+ // @TODO Bad check on UNL, better use a proper validator
+ assert(isset($unlData[NodeInformationDatabaseWrapper::DB_COLUMN_EXTERNAL_UNL]));
+ assert($unlData[NodeInformationDatabaseWrapper::DB_COLUMN_EXTERNAL_UNL] != 'invalid');
- // Add ip:port/node id as criteria
- $searchInstance->addCriteria(self::DB_COLUMN_EXTERNAL_IP, $ipPort[0]);
- $searchInstance->addCriteria(self::DB_COLUMN_LISTEN_PORT, $ipPort[1]);
- $searchInstance->addCriteria(self::DB_COLUMN_NODE_ID , $nodeInstance->getNodeId());
- $searchInstance->addCriteria(self::DB_COLUMN_SESSION_ID , $nodeInstance->getSessionId());
+ // Add Universal Node Locator/node id as criteria
+ $searchInstance->addCriteria(self::DB_COLUMN_EXTERNAL_ADDRESS, $unlData[NodeInformationDatabaseWrapper::DB_COLUMN_EXTERNAL_UNL]);
+ $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
// Cache result of if there is an entry, valid() will tell us if an entry is there
$isRegistered = $resultInstance->valid();
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-WRAPPER[' . __METHOD__ . ':' . __LINE__ . ']: isRegistered=' . intval($isRegistered) . ' - EXIT!');
+ // Debug message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-WRAPPER[' . __METHOD__ . ':' . __LINE__ . ']: isRegistered=' . intval($isRegistered) . ' - EXIT!');
// Return result
return $isRegistered;
* @return void
*/
public function registerLocalNode () {
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-WRAPPER[' . __METHOD__ . ':' . __LINE__ . ']: CALLED!');
+ // Debug message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-WRAPPER[' . __METHOD__ . ':' . __LINE__ . ']: CALLED!');
// Assert to make sure this method is called with no record in DB (the actual backend of the DHT)
assert(!$this->isLocalNodeRegistered());
// "Insert" this dataset instance completely into the database
$this->queryInsertDataSet($dataSetInstance);
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-WRAPPER[' . __METHOD__ . ':' . __LINE__ . ']: EXIT!');
+ // Debug message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-WRAPPER[' . __METHOD__ . ':' . __LINE__ . ']: EXIT!');
}
/**
* @return void
*/
public function updateLocalNode () {
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-WRAPPER[' . __METHOD__ . ':' . __LINE__ . ']: CALLED!');
+ // Debug message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-WRAPPER[' . __METHOD__ . ':' . __LINE__ . ']: CALLED!');
// Assert to make sure this method is called with one record in DB (the actual backend of the DHT)
assert($this->isLocalNodeRegistered());
// Update DHT database record
$this->queryUpdateDataSet($dataSetInstance);
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-WRAPPER[' . __METHOD__ . ':' . __LINE__ . ']: EXIT!');
+ // Debug message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-WRAPPER[' . __METHOD__ . ':' . __LINE__ . ']: EXIT!');
}
/**
* @return $nodeData Node data array
*/
public function findNodeLocalBySessionId ($sessionId) {
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-WRAPPER[' . __METHOD__ . ':' . __LINE__ . ']: sessionId=' . $sessionId . ' - CALLED!');
+ // Debug message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-WRAPPER[' . __METHOD__ . ':' . __LINE__ . ']: sessionId=' . $sessionId . ' - CALLED!');
// Get search criteria
$searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class');
// Query database and get a result instance back
$resultInstance = $this->doSelectByCriteria($searchInstance);
+ // Debug message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-WRAPPER[' . __METHOD__ . ':' . __LINE__ . ']: resultInstance->valid()=' . intval($resultInstance->valid()) . ' - EXIT!');
+
// Return result instance
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-WRAPPER[' . __METHOD__ . ':' . __LINE__ . ']: resultInstance->valid()=' . intval($resultInstance->valid()) . ' - EXIT!');
return $resultInstance;
}
* Registeres a node by given message data.
*
* @param $messageData An array of all message data
- * @param $handlerInstance An instance of a Handleable class
+ * @param $handlerInstance An instance of a HandleableDataSet class
* @return void
*/
- public function registerNodeByMessageData (array $messageData, Handleable $handlerInstance) {
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-WRAPPER[' . __METHOD__ . ':' . __LINE__ . ']: handlerInstance=' . $handlerInstance->__toString() . ' - CALLED!');
+ public function registerNodeByMessageData (array $messageData, HandleableDataSet $handlerInstance) {
+ // Debug message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-WRAPPER[' . __METHOD__ . ':' . __LINE__ . ']: handlerInstance=' . $handlerInstance->__toString() . ' - CALLED!');
// Get a data set instance
$dataSetInstance = ObjectFactory::createObjectByConfiguredName('dataset_criteria_class', array(self::DB_TABLE_NODE_DHT));
// Run the "INSERT" query
$this->queryInsertDataSet($dataSetInstance);
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-WRAPPER[' . __METHOD__ . ':' . __LINE__ . '] - EXIT!');
+ // Debug message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-WRAPPER[' . __METHOD__ . ':' . __LINE__ . '] - EXIT!');
}
/**
* Updates an existing entry in node list
*
* @param $messageData An array of all message data
- * @param $handlerInstance An instance of a Handleable class
+ * @param $handlerInstance An instance of a HandleableDataSet class
* @param $searchInstance An instance of LocalSearchCriteria class
* @return void
*/
- public function updateNodeByMessageData (array $messageData, Handleable $handlerInstance, LocalSearchCriteria $searchInstance) {
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-WRAPPER[' . __METHOD__ . ':' . __LINE__ . ']: CALLED!');
+ public function updateNodeByMessageData (array $messageData, HandleableDataSet $handlerInstance, LocalSearchCriteria $searchInstance) {
+ // Debug message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-WRAPPER[' . __METHOD__ . ':' . __LINE__ . ']: CALLED!');
// Get a data set instance
$dataSetInstance = ObjectFactory::createObjectByConfiguredName('dataset_criteria_class', array(self::DB_TABLE_NODE_DHT));
// Run the "UPDATE" query
$this->queryUpdateDataSet($dataSetInstance);
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-WRAPPER[' . __METHOD__ . ':' . __LINE__ . ']: EXIT!');
+ // Debug message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-WRAPPER[' . __METHOD__ . ':' . __LINE__ . ']: EXIT!');
}
/**
* @return $isRegistered Whether the given node data is already inserted
*/
public function isNodeRegistered (array $nodeData) {
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-WRAPPER[' . __METHOD__ . ':' . __LINE__ . ']: CALLED!');
+ // Debug message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-WRAPPER[' . __METHOD__ . ':' . __LINE__ . ']: CALLED!');
// Assert on array elements
assert(isset($nodeData[self::DB_COLUMN_NODE_ID]));
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-WRAPPER[' . __METHOD__ . ':' . __LINE__ . ']: node-id=' . $nodeData[self::DB_COLUMN_NODE_ID]);
+ // Debug message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-WRAPPER[' . __METHOD__ . ':' . __LINE__ . ']: node-id=' . $nodeData[self::DB_COLUMN_NODE_ID]);
// Get search criteria
$searchInstance = $this->prepareSearchInstance($nodeData);
$searchInstance,
// Only look for these array elements ("keys")
array(
- self::DB_COLUMN_NODE_ID => TRUE,
- self::DB_COLUMN_EXTERNAL_IP => TRUE,
- self::DB_COLUMN_LISTEN_PORT => TRUE,
+ self::DB_COLUMN_NODE_ID => TRUE,
+ self::DB_COLUMN_EXTERNAL_ADDRESS => TRUE
)
);
// Check if there is an entry
$isRegistered = $resultInstance->valid();
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-WRAPPER[' . __METHOD__ . ':' . __LINE__ . ']: isRegistered=' . intval($isRegistered) . ' - EXIT!');
+ // Debug message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-WRAPPER[' . __METHOD__ . ':' . __LINE__ . ']: isRegistered=' . intval($isRegistered) . ' - EXIT!');
// Return registration status
return $isRegistered;
* @throws NodeAlreadyRegisteredException If the node is already registered
*/
public function registerNode (array $nodeData) {
+ // Debug message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-WRAPPER[' . __METHOD__ . ':' . __LINE__ . ']: CALLED!');
+
// Assert on array elements
assert(isset($nodeData[self::DB_COLUMN_NODE_ID]));
// @TODO Unimplemented part
$this->partialStub('nodeData=' . print_r($nodeData, TRUE));
+
+ // Debug message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-WRAPPER[' . __METHOD__ . ':' . __LINE__ . ']: EXIT!');
}
/**
* @throws NodeDataMissingException If the node's data is missing
*/
public function updateNode (array $nodeData) {
+ // Debug message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-WRAPPER[' . __METHOD__ . ':' . __LINE__ . ']: CALLED!');
+
// Assert on array elements
assert(isset($nodeData[self::DB_COLUMN_NODE_ID]));
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-WRAPPER[' . __METHOD__ . ':' . __LINE__ . ']: Updating DHT entry for node-id=' . $nodeData[self::DB_COLUMN_NODE_ID] . ' ...');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-WRAPPER[' . __METHOD__ . ':' . __LINE__ . ']: Updating DHT entry for node-id=' . $nodeData[self::DB_COLUMN_NODE_ID] . ' ...');
// Is the node registered?
if (!$this->isNodeRegistered($nodeData)) {
$nodeInstance = NodeObjectFactory::createNodeInstance();
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-WRAPPER[' . __METHOD__ . ':' . __LINE__ . ']: nodeData=' . print_r($nodeData, TRUE));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-WRAPPER[' . __METHOD__ . ':' . __LINE__ . ']: nodeData=' . print_r($nodeData, TRUE));
// Add all array elements
$nodeInstance->addArrayToDataSet($dataSetInstance, $nodeData);
// Run the "UPDATE" query
$this->queryUpdateDataSet($dataSetInstance);
+
+ // Debug message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-WRAPPER[' . __METHOD__ . ':' . __LINE__ . ']: EXIT!');
}
/**
// Check pending entries
$hasUnpublished = $this->unpublishedEntriesInstance->valid();
+ // Debug message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-WRAPPER[' . __METHOD__ . ':' . __LINE__ . ']: EXIT!');
+
// Return it
return $hasUnpublished;
}
* @todo Add timestamp to dataset instance
*/
public function initEntryPublication () {
+ // Debug message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-WRAPPER[' . __METHOD__ . ':' . __LINE__ . ']: CALLED!');
+
/*
* Make sure that hasUnpublishedEntries() has been called first by
* asserting on the "cached" object instance. This "caching" saves some
// Run the "UPDATE" query
$this->queryUpdateDataSet($dataSetInstance);
+
+ // Debug message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-WRAPPER[' . __METHOD__ . ':' . __LINE__ . ']: EXIT!');
}
/**
* @return $recipients An indexed array with DHT recipients
*/
public function getResultFromExcludedSender (array $packageData) {
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-WRAPPER[' . __METHOD__ . ':' . __LINE__ . ']: CALLED!');
+ // Debug message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-WRAPPER[' . __METHOD__ . ':' . __LINE__ . ']: CALLED!');
// Assert on required array field
assert(isset($packageData[NetworkPackage::PACKAGE_DATA_SENDER]));
// Get a result instance back from DHT database wrapper.
$resultInstance = $this->doSelectByCriteria($searchInstance);
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-WRAPPER[' . __METHOD__ . ':' . __LINE__ . ']: EXIT!');
+ // Debug message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-WRAPPER[' . __METHOD__ . ':' . __LINE__ . ']: EXIT!');
// Return result instance
return $resultInstance;
* @return $recipients An indexed array with DHT recipients
*/
public function getResultFromKeyValue ($key, $value) {
+ // Debug message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-WRAPPER[' . __METHOD__ . ':' . __LINE__ . ']: CALLED!');
+
// Get max recipients
$maxRecipients = $this->getConfigInstance()->getConfigEntry('max_dht_recipients');
// Get a result instance back from DHT database wrapper.
$resultInstance = $this->doSelectByCriteria($searchInstance);
+ // Debug message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-WRAPPER[' . __METHOD__ . ':' . __LINE__ . ']: EXIT!');
+
// Return result instance
return $resultInstance;
}
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
const DB_COLUMN_PRIVATE_KEY = 'private_key';
const DB_COLUMN_PRIVATE_KEY_HASH = 'private_key_hash';
const DB_COLUMN_NODE_MODE = 'node_mode';
+ const DB_COLUMN_INTERNAL_UNL = 'internal_unl';
+ const DB_COLUMN_EXTERNAL_UNL = 'external_unl';
/**
* Protected constructor
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
$senderData = explode(':', HubTools::resolveSessionId($packageData[NetworkPackage::PACKAGE_DATA_SENDER]));
// Just make sure that 'invalid:invalid' is not being processed
- assert(($senderData[0] != 'invalid') && ($senderData[1] != 'invalid'));
+ assert(($senderData[0] != 'invalid') && ($senderData[1] != 'invalid') && ($senderData[2] != 'invalid'));
// Add ip address and port
$dataSetInstance->addCriteria(self::DB_COLUMN_PEER_IP , $senderData[0]);
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
@author Roland Haeder <webmaster@ship-simu.org>
@version 0.0.0
-@copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+@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
@author Roland Haeder <webmaster@ship-simu.org>
@version 0.0.0
-@copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+@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
<session-id>{?session_id?}</session-id>
<!-- Data from our listeners (e.g. which port) //-->
<listener>
- <!-- Public external IP address //-->
- <external-ip>{?external_ip?}</external-ip>
- <!-- Private internal IP address //-->
- <internal-ip>{?internal_ip?}</internal-ip>
- <!-- Listener ports for both connections //-->
- <listen-port>{?node_listen_port?}</listen-port>
+ <!-- Public external address //-->
+ <external-address>{?external_address?}</external-address>
+ <!-- Private internal address //-->
+ <internal-address>{?internal_address?}</internal-address>
</listener>
</announcement-data>
</announcement>
@author Roland Haeder <webmaster@ship-simu.org>
@version 0.0.0
-@copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+@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
//-->
<my-data>
<!--
- This node's external IP/hostname
+ This node's external address
//-->
- <my-external-ip>{?my_external_ip?}</my-external-ip>
+ <my-external-address>{?my_external_address?}</my-external-address>
<!--
- This node's internal IP/hostname
+ This node's internal address
//-->
- <my-internal-ip>{?my_internal_ip?}</my-internal-ip>
- <!--
- This node's TCP/UDP listen port
- //-->
- <my-listen-port>{?my_listen_port?}</my-listen-port>
+ <my-internal-address>{?my_internal_address?}</my-internal-address>
<!--
This node's session id
//-->
//-->
<your-data>
<!--
- Other node's external IP/hostname
+ Other node's external address
//-->
- <your-external-ip>{?your_external_ip?}</your-external-ip>
+ <your-external-address>{?your_external_address?}</your-external-address>
<!--
- Other node's internal IP/hostname
+ Other node's internal address
//-->
- <your-internal-ip>{?your_internal_ip?}</your-internal-ip>
+ <your-internal-address>{?your_internal_address?}</your-internal-address>
<!--
Other node's session id
//-->
@author Roland Haeder <webmaster@ship-simu.org>
@version 0.0.0
-@copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+@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
//-->
<my-data>
<!--
- This node's external IP/hostname
+ This node's external address
//-->
- <my-external-ip>{?my_external_ip?}</my-external-ip>
+ <my-external-address>{?my_external_address?}</my-external-address>
<!--
- This node's internal IP/hostname
+ This node's internal address
//-->
- <my-internal-ip>{?my_internal_ip?}</my-internal-ip>
- <!--
- This node's TCP/UDP listen port
- //-->
- <my-listen-port>{?my_listen_port?}</my-listen-port>
+ <my-internal-address>{?my_internal_address?}</my-internal-address>
<!--
This node's session id
//-->
//-->
<your-data>
<!--
- Other node's external IP/hostname
+ Other node's external address
//-->
- <your-external-ip>{?your_external_ip?}</your-external-ip>
+ <your-external-address>{?your_external_address?}</your-external-address>
<!--
- Other node's internal IP/hostname
+ Other node's internal address
//-->
- <your-internal-ip>{?your_internal_ip?}</your-internal-ip>
+ <your-internal-address>{?your_internal_address?}</your-internal-address>
<!--
Other node's session id
//-->
@author Roland Haeder <webmaster@ship-simu.org>
@version 0.0.0
-@copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+@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
@author Roland Haeder <webmaster@ship-simu.org>
@version 0.0.0
-@copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+@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
@author Roland Haeder <webmaster@ship-simu.org>
@version 0.0.0
-@copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+@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
@author Roland Haeder <webmaster@ship-simu.org>
@version 0.0.0
-@copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+@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
<session-id>{?session_id?}</session-id>
<!-- Data from our listeners (e.g. which port) //-->
<listener>
- <!-- Public external IP address //-->
- <external-ip>{?external_ip?}</external-ip>
- <!-- Private internal IP address //-->
- <internal-ip>{?internal_ip?}</internal-ip>
- <!-- Listener ports for both connections //-->
- <listen-port>{?node_listen_port?}</listen-port>
+ <!-- Public external address //-->
+ <external-address>{?external_address?}</external-address>
+ <!-- Private internal address //-->
+ <internal-address>{?internal_address?}</internal-address>
</listener>
</dht-bootstrap-data>
</dht-bootstrap>
@author Roland Haeder <webmaster@ship-simu.org>
@version 0.0.0
-@copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+@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
Array
(
[node_mode] => regular
- [external_ip] => 192.168.2.3
+ [external_address] => 192.168.2.3
[listen_port] => 9061
[node_id] => 38fc625d3d9aa05654bfc90a7aea7ff72c883f1573
[session_id] => 38fc625d3dabe9ff09b54253b298e91985191472a3
<accepted-object-types>{?accepted_object_types?}</accepted-object-types>
<!-- Data from our listeners (e.g. which port) //-->
<listener>
- <!-- Public external IP address //-->
- <external-ip>{?external_ip?}</external-ip>
- <!-- Listener ports for both connections //-->
- <listen-port>{?listen_port?}</listen-port>
+ <!-- Public external address //-->
+ <external-address>{?external_address?}</external-address>
</listener>
</publish-data>
</publish>
@author Roland Haeder <webmaster@ship-simu.org>
@version 0.0.0
-@copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+@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
@author Roland Haeder <webmaster@ship-simu.org>
@version 0.0.0
-@copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+@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
//-->
<object-max-spread>1</object-max-spread>
<!--
- The protocol we should use for transmission. Valid values can be
- 'tcp' or 'udp', without the quotes.
+ The protocol we should use for transmission. Valid is 'unl' without
+ the quotes.
//-->
<object-protocol>tcp</object-protocol>
<!--
<object-name>self_connect</object-name>
<object-recipient-limitation>self</object-recipient-limitation>
<object-max-spread>self</object-max-spread>
- <object-protocol>tcp</object-protocol>
+ <object-protocol>unl</object-protocol>
<object-recipient-type>hub</object-recipient-type>
</object-list-entry>
<object-list-entry>
<object-name>announcement_answer</object-name>
<object-recipient-limitation>direct</object-recipient-limitation>
<object-max-spread>1</object-max-spread>
- <object-protocol>tcp</object-protocol>
+ <object-protocol>unl</object-protocol>
<object-recipient-type>hub</object-recipient-type>
</object-list-entry>
<object-list-entry>
<object-name>request_node_list</object-name>
<object-recipient-limitation>upper</object-recipient-limitation>
<object-max-spread>1</object-max-spread>
- <object-protocol>tcp</object-protocol>
+ <object-protocol>unl</object-protocol>
<object-recipient-type>hub</object-recipient-type>
</object-list-entry>
<object-list-entry>
<object-name>request_node_list_answer</object-name>
<object-recipient-limitation>direct</object-recipient-limitation>
<object-max-spread>1</object-max-spread>
- <object-protocol>tcp</object-protocol>
+ <object-protocol>unl</object-protocol>
<object-recipient-type>hub</object-recipient-type>
</object-list-entry>
<object-list-entry>
<object-name>dht_bootstrap</object-name>
<object-recipient-limitation>all</object-recipient-limitation>
<object-max-spread>3</object-max-spread>
- <object-protocol>tcp</object-protocol>
- <object-recipient-type>all</object-recipient-type>
+ <object-protocol>unl</object-protocol>
+ <object-recipient-type>hub</object-recipient-type>
</object-list-entry>
<object-list-entry>
<object-name>dht_bootstrap_answer</object-name>
<object-recipient-limitation>direct</object-recipient-limitation>
<object-max-spread>1</object-max-spread>
- <object-protocol>tcp</object-protocol>
+ <object-protocol>unl</object-protocol>
<object-recipient-type>hub</object-recipient-type>
</object-list-entry>
<object-list-entry>
<object-name>dht_publish_entry</object-name>
<object-recipient-limitation>all</object-recipient-limitation>
<object-max-spread>4</object-max-spread>
- <object-protocol>tcp</object-protocol>
+ <object-protocol>unl</object-protocol>
<object-recipient-type>hub</object-recipient-type>
</object-list-entry>
</object-list>
@author Roland Haeder <webmaster@ship-simu.org>
@version 0.0.0
-@copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+@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
@author Roland Haeder <webmaster@ship-simu.org>
@version 0.0.0
-@copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+@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
-Subproject commit 7c82fc25abc53c41e45953f4c3d9f50ed982b75c
+Subproject commit 3288f03df9e42997670846535cc0390f080599e5
--- /dev/null
+#!/bin/sh
+
+echo "$0: Searching for PHP scripts (except 3rd party) ..."
+PHP=`find -type f -name "*.php" | grep -v "third_party"`
+
+for SCRIPT in ${PHP};
+do
+ HEADER=`cat ${SCRIPT} | head -n 1 | grep -v "<?"`
+
+ FOOTER=`cat ${SCRIPT} | tail -n 1 | grep -v "?>"`
+
+ if [ -n "${HEADER}" ];
+ then
+ echo "$0: Script '${SCRIPT}' has non-typical header."
+ fi
+
+ if [ -n "${FOOTER}" ];
+ then
+ echo "$0: Script '${SCRIPT}' has non-typical footer."
+ fi
+done
+
+echo "$0: All done."
+exit 0
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*