From 46981f4588ed503f114f2a807d715eb0c087d551 Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Mon, 15 Dec 2014 21:23:31 +0100 Subject: [PATCH] Continued rewriting: - IPs are a little "static" which means that you only connect to Internet nodes. Universal node locators (UNL) give you the ability to connect also to node which are not available over the internet, such as "fax nodes". - Updated core - Added new script for finding bad scripts - Added more stuff towards refacturing to protocol handler - Introduced discoverUniversalNodeLocatorByConfiguredAddress() - Introduced resolveUniversalNodeLocatorFromConfigKey() - Other rewrites Signed-off-by: Roland Haeder --- application/hub/class_ApplicationHelper.php | 8 +-- application/hub/config-local.php-dist | 10 +-- application/hub/config.php | 12 ++-- ...class_AnnouncementNotAcceptedException.php | 4 +- ...class_NoAnnouncementAttemptedException.php | 4 +- ...class_DhtBootstrapNotAcceptedException.php | 4 +- ...lass_NodeSessionIdVerficationException.php | 6 +- .../class_NodeAlreadyRegisteredException.php | 4 +- .../class_NodeDataMissingException.php | 4 +- ...class_DiscoverableUniversalNodeLocator.php | 13 ++++ .../node/class_DistributableNode.php | 2 +- .../resolver/class_ProtocolResolver.php | 16 +++-- .../wrapper/class_NodeDhtWrapper.php | 2 +- .../hub/main/dht/node/class_NodeDhtFacade.php | 7 +- .../class_UniversalNodeLocatorDiscovery.php | 37 ++++++++++- .../class_PackageRecipientDiscovery.php | 13 ++-- ...ass_PackageAnnouncementAnswerTagFilter.php | 12 ++-- .../class_PackageAnnouncementTagFilter.php | 12 ++-- .../class_PackageDhtBootstrapTagFilter.php | 12 ++-- .../class_AnnouncementAnswerOkayHandler.php | 18 ++--- .../class_NodeMessageAnnouncementHandler.php | 22 +++---- ...s_NodeMessageAnnouncementAnswerHandler.php | 22 +++---- ...s_NodeMessageDhtBootstrapAnswerHandler.php | 22 +++---- .../hub/main/handler/message-types/class_ | 2 +- .../class_BaseMessageHandler.php | 2 +- .../class_NodeMessageDhtBootstrapHandler.php | 22 +++---- .../tcp/class_TcpConnectionHelper.php | 10 +-- .../hub/main/nodes/boot/class_HubBootNode.php | 2 +- .../hub/main/nodes/class_BaseHubNode.php | 65 +++++++++++++++++-- .../main/recipient/dht/class_DhtRecipient.php | 4 +- .../recipient/self/class_SelfRecipient.php | 4 +- application/hub/main/resolver/protocol/class_ | 32 +++++++-- .../tcp/class_TcpProtocolResolver.php | 49 ++++++++++++-- .../class_XmlAnnouncementTemplateEngine.php | 28 ++++---- ...ss_XmlAnnouncementAnswerTemplateEngine.php | 56 ++++++++-------- ...ss_XmlDhtBootstrapAnswerTemplateEngine.php | 60 ++++++++--------- .../class_XmlDhtBootstrapTemplateEngine.php | 30 ++++----- ...class_XmlDhtPublishEntryTemplateEngine.php | 10 +-- application/hub/main/tools/class_HubTools.php | 46 ++++++------- ...odeDistributedHashTableDatabaseWrapper.php | 16 ++--- .../class_NodeInformationDatabaseWrapper.php | 2 + .../xml/announcement/announcement.xml | 8 +-- .../announcement/announcement_answer.xml | 16 ++--- .../dht_bootstrap/dht_bootstrap_answer.xml | 16 ++--- .../xml/dht_bootstrap/dht_bootstrap.xml | 8 +-- .../hub/templates/xml/dht_publish/publish.xml | 6 +- core | 2 +- find-bad-php.sh | 24 +++++++ 48 files changed, 492 insertions(+), 294 deletions(-) create mode 100755 find-bad-php.sh diff --git a/application/hub/class_ApplicationHelper.php b/application/hub/class_ApplicationHelper.php index 7352bc010..c20e60d77 100644 --- a/application/hub/class_ApplicationHelper.php +++ b/application/hub/class_ApplicationHelper.php @@ -152,10 +152,10 @@ class ApplicationHelper extends BaseFrameworkSystem implements ManageableApplica // 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', ConsoleTools::determineExternalAddress()); } // END - if // Default response is console diff --git a/application/hub/config-local.php-dist b/application/hub/config-local.php-dist index 33430f29c..5f4bff07a 100644 --- a/application/hub/config-local.php-dist +++ b/application/hub/config-local.php-dist @@ -9,7 +9,7 @@ * 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. @@ -45,11 +45,11 @@ $cfg->setConfigEntry('node_listen_port', 9060); // CFG: NODE-DEFAULT-MODE (can be 'regular', 'list', 'master' or 'boot', default is 'regular') $cfg->setConfigEntry('node_default_mode', 'regular'); -// 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', 'tcp://188.138.90.169:9060'); diff --git a/application/hub/config.php b/application/hub/config.php index f6196ff8b..b68b51000 100644 --- a/application/hub/config.php +++ b/application/hub/config.php @@ -784,14 +784,14 @@ $cfg->setConfigEntry('private_key', ''); // CFG: PRIVATE-KEY-HASH $cfg->setConfigEntry('private_key_hash', ''); -// CFG: INTERNAL-IP -$cfg->setConfigEntry('internal_ip', ConsoleTools::acquireSelfIPAddress()); +// CFG: INTERNAL-ADDRESS +$cfg->setConfigEntry('internal_address', ConsoleTools::acquireSelfIPAddress()); -// CFG: EXTERNAL-IP -$cfg->setConfigEntry('external_ip', ''); +// CFG: EXTERNAL-ADDRESS +$cfg->setConfigEntry('external_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'); diff --git a/application/hub/exceptions/announcement/class_AnnouncementNotAcceptedException.php b/application/hub/exceptions/announcement/class_AnnouncementNotAcceptedException.php index 46ac205cd..8ec66001e 100644 --- a/application/hub/exceptions/announcement/class_AnnouncementNotAcceptedException.php +++ b/application/hub/exceptions/announcement/class_AnnouncementNotAcceptedException.php @@ -37,8 +37,8 @@ class AnnouncementNotAcceptedException extends FrameworkException { $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_EXTERNAL_ADDRESS], + $messageArray[2][XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_INTERNAL_ADDRESS], $messageArray[2][XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_LISTEN_PORT], $messageArray[2][XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_NODE_STATUS], $messageArray[2][XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_NODE_MODE] diff --git a/application/hub/exceptions/announcement/class_NoAnnouncementAttemptedException.php b/application/hub/exceptions/announcement/class_NoAnnouncementAttemptedException.php index c5500752d..9f96fdd81 100644 --- a/application/hub/exceptions/announcement/class_NoAnnouncementAttemptedException.php +++ b/application/hub/exceptions/announcement/class_NoAnnouncementAttemptedException.php @@ -37,8 +37,8 @@ class NoAnnouncementAttemptedException extends FrameworkException { $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_EXTERNAL_ADDRESS], + $messageArray[2][XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_INTERNAL_ADDRESS], $messageArray[2][XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_LISTEN_PORT], $messageArray[2][XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_NODE_STATUS] ); diff --git a/application/hub/exceptions/dht/class_DhtBootstrapNotAcceptedException.php b/application/hub/exceptions/dht/class_DhtBootstrapNotAcceptedException.php index ad8c18bce..b8f196af3 100644 --- a/application/hub/exceptions/dht/class_DhtBootstrapNotAcceptedException.php +++ b/application/hub/exceptions/dht/class_DhtBootstrapNotAcceptedException.php @@ -37,8 +37,8 @@ class DhtBootstrapNotAcceptedException extends FrameworkException { $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_EXTERNAL_ADDRESS], + $messageArray[1][XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_INTERNAL_ADDRESS], $messageArray[1][XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_LISTEN_PORT], $messageArray[1][XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_NODE_STATUS], $messageArray[1][XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_NODE_MODE] diff --git a/application/hub/exceptions/node/class_NodeSessionIdVerficationException.php b/application/hub/exceptions/node/class_NodeSessionIdVerficationException.php index d91f14453..93640c0e7 100644 --- a/application/hub/exceptions/node/class_NodeSessionIdVerficationException.php +++ b/application/hub/exceptions/node/class_NodeSessionIdVerficationException.php @@ -2,7 +2,7 @@ /** * 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 * @version 0.0.0 @@ -37,8 +37,8 @@ class NodeSessionIdVerficationException extends FrameworkException { $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_EXTERNAL_ADDRESS], + $messageArray[1][XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_INTERNAL_ADDRESS], $messageArray[1][XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_LISTEN_PORT], $messageArray[1][XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_NODE_STATUS] ); diff --git a/application/hub/exceptions/wrapper/class_NodeAlreadyRegisteredException.php b/application/hub/exceptions/wrapper/class_NodeAlreadyRegisteredException.php index 84da0b169..887cfd69c 100644 --- a/application/hub/exceptions/wrapper/class_NodeAlreadyRegisteredException.php +++ b/application/hub/exceptions/wrapper/class_NodeAlreadyRegisteredException.php @@ -31,11 +31,11 @@ class NodeAlreadyRegisteredException extends FrameworkException { */ public function __construct (array $messageArray, $code) { // Construct the message - $message = sprintf('[%s:%d] Node already registered: session-id=%s, external-ip=%s, listen-port=%s', + $message = sprintf('[%s:%d] Node already registered: session-id=%s, external-address=%s, listen-port=%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_EXTERNAL_ADDRESS], $msssageArray[1][NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_LISTEN_PORT], ); diff --git a/application/hub/exceptions/wrapper/class_NodeDataMissingException.php b/application/hub/exceptions/wrapper/class_NodeDataMissingException.php index a9cd0090a..4187ba2e6 100644 --- a/application/hub/exceptions/wrapper/class_NodeDataMissingException.php +++ b/application/hub/exceptions/wrapper/class_NodeDataMissingException.php @@ -31,11 +31,11 @@ class NodeDataMissingException extends FrameworkException { */ public function __construct (array $messageArray, $code) { // Construct the message - $message = sprintf('[%s:%d] Node not registered/missing: session-id=%s, external-ip=%s, listen-port=%s', + $message = sprintf('[%s:%d] Node not registered/missing: session-id=%s, external-address=%s, listen-port=%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_EXTERNAL_ADDRESS], $msssageArray[1][NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_LISTEN_PORT], ); diff --git a/application/hub/interfaces/discovery/unl/class_DiscoverableUniversalNodeLocator.php b/application/hub/interfaces/discovery/unl/class_DiscoverableUniversalNodeLocator.php index 9885b370e..769389fcb 100644 --- a/application/hub/interfaces/discovery/unl/class_DiscoverableUniversalNodeLocator.php +++ b/application/hub/interfaces/discovery/unl/class_DiscoverableUniversalNodeLocator.php @@ -29,6 +29,19 @@ interface DiscoverableUniversalNodeLocator extends Discoverable { * @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] diff --git a/application/hub/interfaces/distributable/node/class_DistributableNode.php b/application/hub/interfaces/distributable/node/class_DistributableNode.php index 5f5596f8e..9461918a5 100644 --- a/application/hub/interfaces/distributable/node/class_DistributableNode.php +++ b/application/hub/interfaces/distributable/node/class_DistributableNode.php @@ -35,7 +35,7 @@ interface DistributableNode extends Distributable { * 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 diff --git a/application/hub/interfaces/resolver/class_ProtocolResolver.php b/application/hub/interfaces/resolver/class_ProtocolResolver.php index 84bc584c9..d33a49233 100644 --- a/application/hub/interfaces/resolver/class_ProtocolResolver.php +++ b/application/hub/interfaces/resolver/class_ProtocolResolver.php @@ -1,4 +1,4 @@ -OSdebugOutput('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); @@ -208,8 +208,7 @@ class NodeDhtFacade extends BaseDht implements DistributableNode, Registerable { } 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); } diff --git a/application/hub/main/discovery/node/class_UniversalNodeLocatorDiscovery.php b/application/hub/main/discovery/node/class_UniversalNodeLocatorDiscovery.php index 8011b3aa6..b3e0ee1b1 100644 --- a/application/hub/main/discovery/node/class_UniversalNodeLocatorDiscovery.php +++ b/application/hub/main/discovery/node/class_UniversalNodeLocatorDiscovery.php @@ -59,9 +59,44 @@ class UniversalNodeLocatorDiscovery extends BaseNodeDiscovery implements Discove $resolverInstance = ProtocolResolverFactory::createResolverFromConfiguredProtocol(); // Then resolve the node instance into an UNL instance - $unlInstance = $resolverInstance->resolveUniversalResourceLocatorFromNodeHelper($nodeInstance); + $unlInstance = $resolverInstance->resolveUniversalNodeLocatorFromNodeHelper($nodeInstance); die(__METHOD__ . ':unlInstance=' . print_r($unlInstance, TRUE)); } + + /** + * "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] diff --git a/application/hub/main/discovery/recipient/package/class_PackageRecipientDiscovery.php b/application/hub/main/discovery/recipient/package/class_PackageRecipientDiscovery.php index 9fa8fe942..dbde1508d 100644 --- a/application/hub/main/discovery/recipient/package/class_PackageRecipientDiscovery.php +++ b/application/hub/main/discovery/recipient/package/class_PackageRecipientDiscovery.php @@ -98,18 +98,19 @@ class PackageRecipientDiscovery extends BaseRecipientDiscovery implements Discov $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())) { + if ((($recipient[0] == HubTools::determineOwnExternalAddress()) && ($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. + * 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::determineOwnExternalIp() . ' or ' . $this->getConfigInstance()->getServerAddress() . ')'); + /* 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 ip (' . HubTools::determineOwnExternalIp() . ') nor internal ip (' . $this->getConfigInstance()->getServerAddress() . '), need to forward (not yet implemented)!'); + /* 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]); diff --git a/application/hub/main/filter/tags/answer/class_PackageAnnouncementAnswerTagFilter.php b/application/hub/main/filter/tags/answer/class_PackageAnnouncementAnswerTagFilter.php index c8b88ca9a..290fba128 100644 --- a/application/hub/main/filter/tags/answer/class_PackageAnnouncementAnswerTagFilter.php +++ b/application/hub/main/filter/tags/answer/class_PackageAnnouncementAnswerTagFilter.php @@ -33,12 +33,12 @@ class PackageAnnouncementAnswerTagFilter extends BaseNodeFilter implements Filte // 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 => '', + XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_LISTEN_PORT => 9060, + BaseXmlAnswerTemplateEngine::ANSWER_STATUS => '', ); } diff --git a/application/hub/main/filter/tags/class_PackageAnnouncementTagFilter.php b/application/hub/main/filter/tags/class_PackageAnnouncementTagFilter.php index 6b3cb8f6f..5dac03418 100644 --- a/application/hub/main/filter/tags/class_PackageAnnouncementTagFilter.php +++ b/application/hub/main/filter/tags/class_PackageAnnouncementTagFilter.php @@ -33,12 +33,12 @@ class PackageAnnouncementTagFilter extends BaseNodeFilter implements FilterableP // 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 => '', + XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_LISTEN_PORT => 9060, ); } diff --git a/application/hub/main/filter/tags/class_PackageDhtBootstrapTagFilter.php b/application/hub/main/filter/tags/class_PackageDhtBootstrapTagFilter.php index beb2edd14..151137d30 100644 --- a/application/hub/main/filter/tags/class_PackageDhtBootstrapTagFilter.php +++ b/application/hub/main/filter/tags/class_PackageDhtBootstrapTagFilter.php @@ -33,12 +33,12 @@ class PackageDhtBootstrapTagFilter extends BaseNodeFilter implements FilterableP // 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 => '', + XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_LISTEN_PORT => 9060, ); } diff --git a/application/hub/main/handler/answer-status/announcement/class_AnnouncementAnswerOkayHandler.php b/application/hub/main/handler/answer-status/announcement/class_AnnouncementAnswerOkayHandler.php index e5d11f7cc..53775e3ae 100644 --- a/application/hub/main/handler/answer-status/announcement/class_AnnouncementAnswerOkayHandler.php +++ b/application/hub/main/handler/answer-status/announcement/class_AnnouncementAnswerOkayHandler.php @@ -34,7 +34,7 @@ class AnnouncementAnswerOkayHandler extends BaseAnserStatusHandler implements Ha // Init array $this->searchData = array( XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_SESSION_ID, - XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_EXTERNAL_IP, + XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_EXTERNAL_ADDRESS, XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_LISTEN_PORT ); @@ -94,14 +94,14 @@ class AnnouncementAnswerOkayHandler extends BaseAnserStatusHandler implements Ha * * 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 diff --git a/application/hub/main/handler/message-types/announcement/class_NodeMessageAnnouncementHandler.php b/application/hub/main/handler/message-types/announcement/class_NodeMessageAnnouncementHandler.php index 1c8111bcf..dc83f404a 100644 --- a/application/hub/main/handler/message-types/announcement/class_NodeMessageAnnouncementHandler.php +++ b/application/hub/main/handler/message-types/announcement/class_NodeMessageAnnouncementHandler.php @@ -36,8 +36,8 @@ class NodeMessageAnnouncementHandler extends BaseMessageHandler implements Handl // 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, @@ -46,23 +46,23 @@ class NodeMessageAnnouncementHandler extends BaseMessageHandler implements Handl // 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', + XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_LISTEN_PORT => 'node_listen_port', ); // Init array $this->searchData = array( - XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_EXTERNAL_IP, + XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_EXTERNAL_ADDRESS, XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_LISTEN_PORT ); } diff --git a/application/hub/main/handler/message-types/answer/class_NodeMessageAnnouncementAnswerHandler.php b/application/hub/main/handler/message-types/answer/class_NodeMessageAnnouncementAnswerHandler.php index 0fd0d7bde..02cafcdf6 100644 --- a/application/hub/main/handler/message-types/answer/class_NodeMessageAnnouncementAnswerHandler.php +++ b/application/hub/main/handler/message-types/answer/class_NodeMessageAnnouncementAnswerHandler.php @@ -36,8 +36,8 @@ class NodeMessageAnnouncementAnswerHandler extends BaseMessageHandler implements // 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, @@ -47,25 +47,25 @@ class NodeMessageAnnouncementAnswerHandler extends BaseMessageHandler implements // 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', + XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_LISTEN_PORT => 'node_listen_port', ); // Init array $this->searchData = array( XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_SESSION_ID, - XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_EXTERNAL_IP, + XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_EXTERNAL_ADDRESS, XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_LISTEN_PORT ); } diff --git a/application/hub/main/handler/message-types/answer/class_NodeMessageDhtBootstrapAnswerHandler.php b/application/hub/main/handler/message-types/answer/class_NodeMessageDhtBootstrapAnswerHandler.php index 10be08466..d981b685f 100644 --- a/application/hub/main/handler/message-types/answer/class_NodeMessageDhtBootstrapAnswerHandler.php +++ b/application/hub/main/handler/message-types/answer/class_NodeMessageDhtBootstrapAnswerHandler.php @@ -36,8 +36,8 @@ class NodeMessageDhtBootstrapAnswerHandler extends BaseMessageHandler implements // 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, @@ -47,25 +47,25 @@ class NodeMessageDhtBootstrapAnswerHandler extends BaseMessageHandler implements // 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', + XmlDhtBootstrapAnswerTemplateEngine::DHT_BOOTSTRAP_DATA_LISTEN_PORT => 'node_listen_port', ); // Init array $this->searchData = array( XmlDhtBootstrapAnswerTemplateEngine::DHT_BOOTSTRAP_DATA_SESSION_ID, - XmlDhtBootstrapAnswerTemplateEngine::DHT_BOOTSTRAP_DATA_EXTERNAL_IP, + XmlDhtBootstrapAnswerTemplateEngine::DHT_BOOTSTRAP_DATA_EXTERNAL_ADDRESS, XmlDhtBootstrapAnswerTemplateEngine::DHT_BOOTSTRAP_DATA_LISTEN_PORT ); } diff --git a/application/hub/main/handler/message-types/class_ b/application/hub/main/handler/message-types/class_ index 074cc3e03..131e3c1c8 100644 --- a/application/hub/main/handler/message-types/class_ +++ b/application/hub/main/handler/message-types/class_ @@ -36,7 +36,7 @@ class NodeMessage???Handler extends BaseMessageHandler implements HandleableMess // 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, diff --git a/application/hub/main/handler/message-types/class_BaseMessageHandler.php b/application/hub/main/handler/message-types/class_BaseMessageHandler.php index f852722e7..78902af71 100644 --- a/application/hub/main/handler/message-types/class_BaseMessageHandler.php +++ b/application/hub/main/handler/message-types/class_BaseMessageHandler.php @@ -58,7 +58,7 @@ abstract class BaseMessageHandler extends BaseDataHandler { * 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 diff --git a/application/hub/main/handler/message-types/dht/class_NodeMessageDhtBootstrapHandler.php b/application/hub/main/handler/message-types/dht/class_NodeMessageDhtBootstrapHandler.php index 232259573..ee5ce6334 100644 --- a/application/hub/main/handler/message-types/dht/class_NodeMessageDhtBootstrapHandler.php +++ b/application/hub/main/handler/message-types/dht/class_NodeMessageDhtBootstrapHandler.php @@ -36,8 +36,8 @@ class NodeMessageDhtBootstrapHandler extends BaseMessageHandler implements Handl // 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, @@ -46,23 +46,23 @@ class NodeMessageDhtBootstrapHandler extends BaseMessageHandler implements Handl // 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', + XmlDhtBootstrapAnswerTemplateEngine::DHT_BOOTSTRAP_DATA_LISTEN_PORT => 'node_listen_port', ); // Init array $this->searchData = array( - XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_EXTERNAL_IP, + XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_EXTERNAL_ADDRESS, XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_LISTEN_PORT ); } diff --git a/application/hub/main/helper/connection/tcp/class_TcpConnectionHelper.php b/application/hub/main/helper/connection/tcp/class_TcpConnectionHelper.php index 9cbd20fcd..0734089b0 100644 --- a/application/hub/main/helper/connection/tcp/class_TcpConnectionHelper.php +++ b/application/hub/main/helper/connection/tcp/class_TcpConnectionHelper.php @@ -99,9 +99,9 @@ class TcpConnectionHelper extends BaseConnectionHelper implements ConnectionHelp 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 connects to shipsimu.org and requests /ip.php which will return our external address + $recipientData[0] = ConsoleTools::determineExternalAddress(); // Do we have hostname:ip match? if (strpos($packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT], ':') === FALSE) { @@ -116,11 +116,11 @@ class TcpConnectionHelper extends BaseConnectionHelper implements ConnectionHelp $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]); diff --git a/application/hub/main/nodes/boot/class_HubBootNode.php b/application/hub/main/nodes/boot/class_HubBootNode.php index 984e2c861..ed7a894f7 100644 --- a/application/hub/main/nodes/boot/class_HubBootNode.php +++ b/application/hub/main/nodes/boot/class_HubBootNode.php @@ -69,7 +69,7 @@ class HubBootNode extends BaseHubNode implements NodeHelper, Registerable { // Is the port the same? if ($bootPort == $ourPort) { // It is the same! - self::createDebugInstance(__CLASS__)->debugOutput('BOOTSTRAP: IP/port matches bootstrap node ' . $this->getBootUniversalNodeLocator() . '.'); + 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) { diff --git a/application/hub/main/nodes/class_BaseHubNode.php b/application/hub/main/nodes/class_BaseHubNode.php index 398f32aa8..dc3eb68cd 100644 --- a/application/hub/main/nodes/class_BaseHubNode.php +++ b/application/hub/main/nodes/class_BaseHubNode.php @@ -102,7 +102,7 @@ class BaseHubNode extends BaseHubSystem implements Updateable, AddableCriteria { * 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 @@ -122,6 +122,54 @@ class BaseHubNode extends BaseHubSystem implements Updateable, AddableCriteria { self::createDebugInstance(__CLASS__)->debugOutput('BOOTSTRAP: Created new private key with hash: ' . $this->getPrivateKeyHash() . ''); } + /** + * Generates an UNL (Universal Node Locator) for the internal address + * + * @return $internalUnl Internal UNL + */ + private function generateInternalUnl () { + // 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'); + } // END - if + + // Return it + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NODE[' . __METHOD__ . ':' . __LINE__ . ']: unl=' . $GLOBALS[__METHOD__] . ' - EXIT!'); + return $GLOBALS[__METHOD__]; + } + + /** + * Generates an UNL (Universal Node Locator) for the external address + * + * @return $externalUnl External UNL + */ + private function generateExternalUnl () { + // 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'); + } // END - if + + // Return it + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NODE[' . __METHOD__ . ':' . __LINE__ . ']: unl=' . $GLOBALS[__METHOD__] . ' - EXIT!'); + return $GLOBALS[__METHOD__]; + } + /** * Generates a random string from various data inluding UUID if PECL * extension uuid is installed. @@ -145,9 +193,9 @@ class BaseHubNode extends BaseHubSystem implements Updateable, AddableCriteria { } /** - * Getter for boot IP/port combination + * Getter for boot UNL (Universal Node Locator) * - * @return $bootUnl The IP/port combination of the boot node + * @return $bootUnl The UNL (Universal Node Locator) of the boot node */ protected final function getBootUniversalNodeLocator () { return $this->bootUnl; @@ -348,7 +396,7 @@ class BaseHubNode extends BaseHubSystem implements Updateable, AddableCriteria { * @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 @@ -368,6 +416,10 @@ class BaseHubNode extends BaseHubSystem implements Updateable, AddableCriteria { $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, $this->generateInternalUnl()); + $criteriaInstance->addCriteria(NodeInformationDatabaseWrapper::DB_COLUMN_EXTERNAL_UNL, $this->generateExternalUnl()); } /** @@ -703,12 +755,14 @@ class BaseHubNode extends BaseHubSystem implements Updateable, AddableCriteria { * @return $unlInstance An instance of a LocateableNode class for this node */ public function determineUniversalNodeLocator () { + // Debug message /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NODE[' . __METHOD__ . ':' . __LINE__ . ']: CALLED!'); + // Determine UNL based on this node: // 1) Get discovery class $discoveryInstance = ObjectFactory::createObjectByConfiguredName('unl_discovery_class'); - // 2) "Determine it + // 2) "Determine" it $unlInstance = $discoveryInstance->discoverUniversalNodeLocatorByNode($this); // 3) Return it @@ -722,6 +776,7 @@ class BaseHubNode extends BaseHubSystem implements Updateable, AddableCriteria { * @return $unlArray An array from an instance of a LocateableNode class for this node */ public final function getUniversalNodeLocatorArray () { + // Debug message /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NODE[' . __METHOD__ . ':' . __LINE__ . ']: CALLED!'); // Get the Universal Node Locator (UNL) instance diff --git a/application/hub/main/recipient/dht/class_DhtRecipient.php b/application/hub/main/recipient/dht/class_DhtRecipient.php index 40a4efd28..c6bfea603 100644 --- a/application/hub/main/recipient/dht/class_DhtRecipient.php +++ b/application/hub/main/recipient/dht/class_DhtRecipient.php @@ -75,11 +75,11 @@ class DhtRecipient extends BaseRecipient implements Recipient { // These array elements must exist for this loop: // @TODO Unfinished die(__METHOD__ . ':recipient=' . print_r($recipient, TRUE)); - assert(!empty($recipient[NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_EXTERNAL_IP])); + assert(!empty($recipient[NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_EXTERNAL_ADDRESS])); assert(!empty($recipient[NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_LISTEN_PORT])); // Put ip and port both together - $unl = $recipient[NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_EXTERNAL_IP] . ':' . $recipient[NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_LISTEN_PORT]; + $unl = $recipient[NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_EXTERNAL_ADDRESS] . ':' . $recipient[NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_LISTEN_PORT]; // Add it to the list //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-RECIPIENT[' . __METHOD__ . ':' . __LINE__ . ']: Calling listInstance->addEntry(' . $unl . ') ...'); diff --git a/application/hub/main/recipient/self/class_SelfRecipient.php b/application/hub/main/recipient/self/class_SelfRecipient.php index 85d29eab8..d3262368e 100644 --- a/application/hub/main/recipient/self/class_SelfRecipient.php +++ b/application/hub/main/recipient/self/class_SelfRecipient.php @@ -65,8 +65,8 @@ class SelfRecipient extends BaseRecipient implements Recipient { // 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 + $ip = HubTools::determineOwnExternalAddress(); // Is it not empty? if (!empty($ip)) { diff --git a/application/hub/main/resolver/protocol/class_ b/application/hub/main/resolver/protocol/class_ index 8246fbca6..232d884c1 100644 --- a/application/hub/main/resolver/protocol/class_ +++ b/application/hub/main/resolver/protocol/class_ @@ -33,7 +33,7 @@ class !!!ProtocolResolver extends BaseProtocolResolver implements ProtocolResolv } /** - * Creates an instance of a !!! command resolver with a given default command + * Creates an instance of a !!! protocol resolver * * @return $resolverInstance The prepared command resolver instance */ @@ -46,15 +46,37 @@ class !!!ProtocolResolver extends BaseProtocolResolver implements ProtocolResolv } /** - * Returns an command instance for a given request class or null if - * it was not found + * 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 resolveUniversalResourceLocatorFromNodeHelper (NodeHelper $nodeInstance) { - $this->partialStub('Please implement this method.'); + 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; } } diff --git a/application/hub/main/resolver/protocol/tcp/class_TcpProtocolResolver.php b/application/hub/main/resolver/protocol/tcp/class_TcpProtocolResolver.php index 41a1f6d20..8a3aae4bf 100644 --- a/application/hub/main/resolver/protocol/tcp/class_TcpProtocolResolver.php +++ b/application/hub/main/resolver/protocol/tcp/class_TcpProtocolResolver.php @@ -36,7 +36,7 @@ class TcpProtocolResolver extends BaseProtocolResolver implements ProtocolResolv } /** - * Creates an instance of a Tcp command resolver with a given default command + * Creates an instance of a TCP protocol resolver * * @return $resolverInstance The prepared command resolver instance */ @@ -49,15 +49,54 @@ class TcpProtocolResolver extends BaseProtocolResolver implements ProtocolResolv } /** - * Returns an command instance for a given NodeHelper instance or null if it - * was not found. + * 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 resolveUniversalResourceLocatorFromNodeHelper (NodeHelper $nodeInstance) { - $this->partialStub('Please implement this method.'); + public function resolveUniversalNodeLocatorFromNodeHelper (NodeHelper $nodeInstance) { + // Get result instance + $resultInstance = $nodeInstance->getResultInstance(); + + // Make sure the result instance is valid + assert($resultInstance instanceof SearchableResult); + + // Rewind iterator + $resultInstance->rewind(); + + // Lookup node's id + while ($resultInstance->next()) { + // Get current entry + $current = $resultInstance->current(); + + // Do we have found an entry? + // $nodeInstance->getNodeId() + die(print_r($current, TRUE)); + } // END - while + } + + /** + * 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) { + // Put all together + $unl = sprintf('%s://%s:%s', + $this->getProtocolName(), + $this->getConfigInstance()->getConfigEntry($configKey . '_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; } } diff --git a/application/hub/main/template/announcement/class_XmlAnnouncementTemplateEngine.php b/application/hub/main/template/announcement/class_XmlAnnouncementTemplateEngine.php index 0ca17982a..e5701d43a 100644 --- a/application/hub/main/template/announcement/class_XmlAnnouncementTemplateEngine.php +++ b/application/hub/main/template/announcement/class_XmlAnnouncementTemplateEngine.php @@ -26,12 +26,12 @@ class XmlAnnouncementTemplateEngine extends BaseXmlTemplateEngine implements Com /** * 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'; + const ANNOUNCEMENT_DATA_LISTEN_PORT = 'listen-port'; /** * Protected constructor @@ -50,8 +50,8 @@ class XmlAnnouncementTemplateEngine extends BaseXmlTemplateEngine implements Com 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', ); } @@ -186,9 +186,9 @@ class XmlAnnouncementTemplateEngine extends BaseXmlTemplateEngine implements Com * * @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); } /** @@ -196,9 +196,9 @@ class XmlAnnouncementTemplateEngine extends BaseXmlTemplateEngine implements Com * * @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); } /** @@ -256,7 +256,7 @@ class XmlAnnouncementTemplateEngine extends BaseXmlTemplateEngine implements Com * * @return void */ - protected function finishInternalIp () { + protected function finishInternalAddress () { // Pop the last entry $this->getStackInstance()->popNamed('node_announcement'); } @@ -266,7 +266,7 @@ class XmlAnnouncementTemplateEngine extends BaseXmlTemplateEngine implements Com * * @return void */ - protected function finishExternalIp () { + protected function finishExternalAddress () { // Pop the last entry $this->getStackInstance()->popNamed('node_announcement'); } diff --git a/application/hub/main/template/answer/announcement/class_XmlAnnouncementAnswerTemplateEngine.php b/application/hub/main/template/answer/announcement/class_XmlAnnouncementAnswerTemplateEngine.php index d4f0dc738..17a3bda18 100644 --- a/application/hub/main/template/answer/announcement/class_XmlAnnouncementAnswerTemplateEngine.php +++ b/application/hub/main/template/answer/announcement/class_XmlAnnouncementAnswerTemplateEngine.php @@ -26,10 +26,10 @@ class XmlAnnouncementAnswerTemplateEngine extends BaseXmlAnswerTemplateEngine im /** * 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_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'; const ANNOUNCEMENT_DATA_LISTEN_PORT = 'my-listen-port'; /** @@ -47,14 +47,14 @@ class XmlAnnouncementAnswerTemplateEngine extends BaseXmlAnswerTemplateEngine im 'my-data', 'your-data', // Data from *this* node - self::ANNOUNCEMENT_DATA_EXTERNAL_IP, - self::ANNOUNCEMENT_DATA_INTERNAL_IP, + self::ANNOUNCEMENT_DATA_EXTERNAL_ADDRESS, + self::ANNOUNCEMENT_DATA_INTERNAL_ADDRESS, self::ANNOUNCEMENT_DATA_LISTEN_PORT, self::ANNOUNCEMENT_DATA_NODE_STATUS, self::ANNOUNCEMENT_DATA_SESSION_ID, // Data from other node - 'your-external-ip', - 'your-internal-ip', + 'your-external-address', + 'your-internal-address', 'your-session-id', // Answer status (generic field) self::ANSWER_STATUS, @@ -138,23 +138,23 @@ class XmlAnnouncementAnswerTemplateEngine extends BaseXmlAnswerTemplateEngine im } /** - * 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); + $this->getStackInstance()->pushNamed('node_announcement_answer', self::ANNOUNCEMENT_DATA_INTERNAL_ADDRESS); } /** @@ -218,21 +218,21 @@ class XmlAnnouncementAnswerTemplateEngine extends BaseXmlAnswerTemplateEngine im } /** - * 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'); } @@ -258,23 +258,23 @@ class XmlAnnouncementAnswerTemplateEngine extends BaseXmlAnswerTemplateEngine im } /** - * 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'); } /** @@ -298,21 +298,21 @@ class XmlAnnouncementAnswerTemplateEngine extends BaseXmlAnswerTemplateEngine im } /** - * 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'); } diff --git a/application/hub/main/template/answer/dht/class_XmlDhtBootstrapAnswerTemplateEngine.php b/application/hub/main/template/answer/dht/class_XmlDhtBootstrapAnswerTemplateEngine.php index aaeaa6e65..f5e26d7a3 100644 --- a/application/hub/main/template/answer/dht/class_XmlDhtBootstrapAnswerTemplateEngine.php +++ b/application/hub/main/template/answer/dht/class_XmlDhtBootstrapAnswerTemplateEngine.php @@ -26,12 +26,12 @@ class XmlDhtBootstrapAnswerTemplateEngine extends BaseXmlAnswerTemplateEngine im /** * 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_LISTEN_PORT = 'my-listen-port'; + const DHT_BOOTSTRAP_DATA_NODE_LIST = 'dht-nodes-list'; /** * Protected constructor @@ -48,14 +48,14 @@ class XmlDhtBootstrapAnswerTemplateEngine extends BaseXmlAnswerTemplateEngine im 'my-data', 'your-data', // Data from *this* node - self::DHT_BOOTSTRAP_DATA_EXTERNAL_IP, - self::DHT_BOOTSTRAP_DATA_INTERNAL_IP, + self::DHT_BOOTSTRAP_DATA_EXTERNAL_ADDRESS, + self::DHT_BOOTSTRAP_DATA_INTERNAL_ADDRESS, self::DHT_BOOTSTRAP_DATA_LISTEN_PORT, self::DHT_BOOTSTRAP_DATA_NODE_STATUS, self::DHT_BOOTSTRAP_DATA_SESSION_ID, // Data from other node - 'your-external-ip', - 'your-internal-ip', + 'your-external-address', + 'your-internal-address', 'your-session-id', // Answer status (generic field) self::ANSWER_STATUS, @@ -141,23 +141,23 @@ class XmlDhtBootstrapAnswerTemplateEngine extends BaseXmlAnswerTemplateEngine im } /** - * 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); + $this->getStackInstance()->pushNamed('node_dht_bootstrap_answer', self::DHT_BOOTSTRAP_DATA_INTERNAL_ADDRESS); } /** @@ -241,21 +241,21 @@ class XmlDhtBootstrapAnswerTemplateEngine extends BaseXmlAnswerTemplateEngine im } /** - * 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'); } @@ -281,23 +281,23 @@ class XmlDhtBootstrapAnswerTemplateEngine extends BaseXmlAnswerTemplateEngine im } /** - * 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'); } /** @@ -321,21 +321,21 @@ class XmlDhtBootstrapAnswerTemplateEngine extends BaseXmlAnswerTemplateEngine im } /** - * 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'); } diff --git a/application/hub/main/template/dht/class_XmlDhtBootstrapTemplateEngine.php b/application/hub/main/template/dht/class_XmlDhtBootstrapTemplateEngine.php index 151a59887..47e08cec0 100644 --- a/application/hub/main/template/dht/class_XmlDhtBootstrapTemplateEngine.php +++ b/application/hub/main/template/dht/class_XmlDhtBootstrapTemplateEngine.php @@ -26,13 +26,13 @@ class XmlDhtBootstrapTemplateEngine extends BaseXmlTemplateEngine implements Com /** * 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'; + const DHT_BOOTSTRAP_DATA_LISTEN_PORT = 'listen-port'; /** * Protected constructor @@ -51,8 +51,8 @@ class XmlDhtBootstrapTemplateEngine extends BaseXmlTemplateEngine implements Com 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 ); } @@ -176,9 +176,9 @@ class XmlDhtBootstrapTemplateEngine extends BaseXmlTemplateEngine implements Com * * @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); } /** @@ -186,9 +186,9 @@ class XmlDhtBootstrapTemplateEngine extends BaseXmlTemplateEngine implements Com * * @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); } /** @@ -216,7 +216,7 @@ class XmlDhtBootstrapTemplateEngine extends BaseXmlTemplateEngine implements Com * * @return void */ - protected function finishInternalIp () { + protected function finishInternalAddress () { // Pop the last entry $this->getStackInstance()->popNamed('dht_bootstrap'); } @@ -226,7 +226,7 @@ class XmlDhtBootstrapTemplateEngine extends BaseXmlTemplateEngine implements Com * * @return void */ - protected function finishExternalIp () { + protected function finishExternalAddress () { // Pop the last entry $this->getStackInstance()->popNamed('dht_bootstrap'); } diff --git a/application/hub/main/template/publish/class_XmlDhtPublishEntryTemplateEngine.php b/application/hub/main/template/publish/class_XmlDhtPublishEntryTemplateEngine.php index 305aab162..9cbd20c4e 100644 --- a/application/hub/main/template/publish/class_XmlDhtPublishEntryTemplateEngine.php +++ b/application/hub/main/template/publish/class_XmlDhtPublishEntryTemplateEngine.php @@ -30,7 +30,7 @@ class XmlDhtPublishEntryTemplateEngine extends BaseXmlTemplateEngine implements 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_EXTERNAL_ADDRESS = 'external-address'; const PUBLISH_DATA_LISTEN_PORT = 'listen-port'; const PUBLISH_DATA_PRIVATE_KEY_HASH = 'private-key-hash'; const PUBLISH_DATA_ACCEPTED_OBJECT_TYPES = 'accepted-object-types'; @@ -55,7 +55,7 @@ class XmlDhtPublishEntryTemplateEngine extends BaseXmlTemplateEngine implements 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', ); } @@ -220,9 +220,9 @@ class XmlDhtPublishEntryTemplateEngine extends BaseXmlTemplateEngine implements * * @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); } /** @@ -290,7 +290,7 @@ class XmlDhtPublishEntryTemplateEngine extends BaseXmlTemplateEngine implements * * @return void */ - protected function finishExternalIp () { + protected function finishExternalAddress () { // Pop the last entry $this->getStackInstance()->popNamed('dht_publish'); } diff --git a/application/hub/main/tools/class_HubTools.php b/application/hub/main/tools/class_HubTools.php index c2c6197e5..d550b64a0 100644 --- a/application/hub/main/tools/class_HubTools.php +++ b/application/hub/main/tools/class_HubTools.php @@ -101,9 +101,9 @@ class HubTools extends BaseHubSystem { $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])) && (isset($recipient[NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_LISTEN_PORT]))) { // Then use this - $recipientUniversalNodeLocator = $recipient[NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_EXTERNAL_IP] . ':' . $recipient[NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_LISTEN_PORT]; + $recipientUniversalNodeLocator = $recipient[NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_EXTERNAL_ADDRESS] . ':' . $recipient[NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_LISTEN_PORT]; } else { // Get the instance, this might throw a NPE $nodeInstance = NodeObjectFactory::createNodeInstance(); @@ -111,7 +111,7 @@ class HubTools extends BaseHubSystem { // Is the session id the same? if ($nodeInstance->getSessionId() == $sessionId) { // Then get an instance of a LocateableNode class from it, assume TCP by default - $recipientUniversalNodeLocator = self::determineOwnExternalIp() . ':' . $nodeInstance->getConfigInstance()->getConfigEntry('node_listen_port'); + $recipientUniversalNodeLocator = self::determineOwnExternalAddress() . ':' . $nodeInstance->getConfigInstance()->getConfigEntry('node_listen_port'); } // END - if } @@ -186,18 +186,18 @@ class HubTools extends BaseHubSystem { } /** - * Determine IP or 'external_ip' if set + * Determine IP or 'external_address' if set * - * @return $ip The determined external ip of this node + * @return $ip The determined external address 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 + $ip = 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 + $ip = ConsoleTools::determineExternalAddress(); } // Return it @@ -205,20 +205,20 @@ class HubTools extends BaseHubSystem { } /** - * Determine IP or 'internal_ip' if set + * Determine IP or 'internal_address' if set * - * @return $ip The determined external ip of this node + * @return $ip The determined external address 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 + $ip = self::determineOwnExternalAddress(); + } elseif (FrameworkConfiguration::getSelfInstance()->getConfigEntry('internal_address') != '') { + // Use it as internal address + $ip = FrameworkConfiguration::getSelfInstance()->getConfigEntry('internal_address'); } else { - // Determine own internal ip by connecting to my (coder) server at 188.138.90.169 + // Determine own internal address by connecting to my (coder) server at 188.138.90.169 $ip = ConsoleTools::acquireSelfIPAddress(); } diff --git a/application/hub/main/wrapper/node/class_NodeDistributedHashTableDatabaseWrapper.php b/application/hub/main/wrapper/node/class_NodeDistributedHashTableDatabaseWrapper.php index 928eb3310..218e5163b 100644 --- a/application/hub/main/wrapper/node/class_NodeDistributedHashTableDatabaseWrapper.php +++ b/application/hub/main/wrapper/node/class_NodeDistributedHashTableDatabaseWrapper.php @@ -33,7 +33,7 @@ class NodeDistributedHashTableDatabaseWrapper extends BaseDatabaseWrapper implem // 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_EXTERNAL_ADDRESS = 'external_address'; const DB_COLUMN_LISTEN_PORT = 'listen_port'; const DB_COLUMN_PRIVATE_KEY_HASH = 'private_key_hash'; const DB_COLUMN_NODE_MODE = 'node_mode'; @@ -86,7 +86,7 @@ class NodeDistributedHashTableDatabaseWrapper extends BaseDatabaseWrapper implem $elements = array( self::DB_COLUMN_NODE_ID, self::DB_COLUMN_SESSION_ID, - self::DB_COLUMN_EXTERNAL_IP, + self::DB_COLUMN_EXTERNAL_ADDRESS, self::DB_COLUMN_LISTEN_PORT, self::DB_COLUMN_PRIVATE_KEY_HASH, self::DB_COLUMN_NODE_MODE, @@ -162,7 +162,7 @@ class NodeDistributedHashTableDatabaseWrapper extends BaseDatabaseWrapper implem // Add public node data $dataSetInstance->addCriteria(self::DB_COLUMN_NODE_MODE , $requestInstance->getRequestElement('mode')); - $dataSetInstance->addCriteria(self::DB_COLUMN_EXTERNAL_IP , $unl[0]); + $dataSetInstance->addCriteria(self::DB_COLUMN_EXTERNAL_ADDRESS , $unl[0]); $dataSetInstance->addCriteria(self::DB_COLUMN_LISTEN_PORT , $unl[1]); $dataSetInstance->addCriteria(self::DB_COLUMN_NODE_ID , $nodeInstance->getNodeId()); $dataSetInstance->addCriteria(self::DB_COLUMN_SESSION_ID , $nodeInstance->getSessionId()); @@ -177,7 +177,7 @@ class NodeDistributedHashTableDatabaseWrapper extends BaseDatabaseWrapper implem /** * 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 */ @@ -200,7 +200,7 @@ class NodeDistributedHashTableDatabaseWrapper extends BaseDatabaseWrapper implem assert(($unl[0] !== 'invalid') && ($unl[1] !== 'invalid') && ($unl[2] !== 'invalid')); // Add Universal Node Locator/node id as criteria - $searchInstance->addCriteria(self::DB_COLUMN_EXTERNAL_IP, $unl[0]); + $searchInstance->addCriteria(self::DB_COLUMN_EXTERNAL_ADDRESS, $unl[0]); $searchInstance->addCriteria(self::DB_COLUMN_LISTEN_PORT, $unl[1]); $searchInstance->addCriteria(self::DB_COLUMN_NODE_ID , $nodeInstance->getNodeId()); $searchInstance->addCriteria(self::DB_COLUMN_SESSION_ID , $nodeInstance->getSessionId()); @@ -379,9 +379,9 @@ class NodeDistributedHashTableDatabaseWrapper extends BaseDatabaseWrapper implem $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, + self::DB_COLUMN_LISTEN_PORT => TRUE, ) ); diff --git a/application/hub/main/wrapper/node/class_NodeInformationDatabaseWrapper.php b/application/hub/main/wrapper/node/class_NodeInformationDatabaseWrapper.php index 7445a87ce..a7632edb8 100644 --- a/application/hub/main/wrapper/node/class_NodeInformationDatabaseWrapper.php +++ b/application/hub/main/wrapper/node/class_NodeInformationDatabaseWrapper.php @@ -32,6 +32,8 @@ class NodeInformationDatabaseWrapper extends BaseDatabaseWrapper implements Node 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 diff --git a/application/hub/templates/xml/announcement/announcement.xml b/application/hub/templates/xml/announcement/announcement.xml index 944ee01ab..32b33e555 100644 --- a/application/hub/templates/xml/announcement/announcement.xml +++ b/application/hub/templates/xml/announcement/announcement.xml @@ -33,10 +33,10 @@ along with this program. If not, see {?session_id?} - - {?external_ip?} - - {?internal_ip?} + + {?external_address?} + + {?internal_address?} {?node_listen_port?} diff --git a/application/hub/templates/xml/answer/announcement/announcement_answer.xml b/application/hub/templates/xml/answer/announcement/announcement_answer.xml index 8421fe801..456403fd4 100644 --- a/application/hub/templates/xml/answer/announcement/announcement_answer.xml +++ b/application/hub/templates/xml/answer/announcement/announcement_answer.xml @@ -28,13 +28,13 @@ along with this program. If not, see //--> - {?my_external_ip?} + {?my_external_address?} - {?my_internal_ip?} + {?my_internal_address?} @@ -54,13 +54,13 @@ along with this program. If not, see //--> - {?your_external_ip?} + {?your_external_address?} - {?your_internal_ip?} + {?your_internal_address?} diff --git a/application/hub/templates/xml/answer/dht_bootstrap/dht_bootstrap_answer.xml b/application/hub/templates/xml/answer/dht_bootstrap/dht_bootstrap_answer.xml index a4fa6f2c4..6b5f57024 100644 --- a/application/hub/templates/xml/answer/dht_bootstrap/dht_bootstrap_answer.xml +++ b/application/hub/templates/xml/answer/dht_bootstrap/dht_bootstrap_answer.xml @@ -29,13 +29,13 @@ along with this program. If not, see //--> - {?my_external_ip?} + {?my_external_address?} - {?my_internal_ip?} + {?my_internal_address?} @@ -55,13 +55,13 @@ along with this program. If not, see //--> - {?your_external_ip?} + {?your_external_address?} - {?your_internal_ip?} + {?your_internal_address?} diff --git a/application/hub/templates/xml/dht_bootstrap/dht_bootstrap.xml b/application/hub/templates/xml/dht_bootstrap/dht_bootstrap.xml index 70482d8d8..06f9eab67 100644 --- a/application/hub/templates/xml/dht_bootstrap/dht_bootstrap.xml +++ b/application/hub/templates/xml/dht_bootstrap/dht_bootstrap.xml @@ -42,10 +42,10 @@ along with this program. If not, see {?session_id?} - - {?external_ip?} - - {?internal_ip?} + + {?external_address?} + + {?internal_address?} {?node_listen_port?} diff --git a/application/hub/templates/xml/dht_publish/publish.xml b/application/hub/templates/xml/dht_publish/publish.xml index f40eea3de..c6b8604ab 100644 --- a/application/hub/templates/xml/dht_publish/publish.xml +++ b/application/hub/templates/xml/dht_publish/publish.xml @@ -37,7 +37,7 @@ along with this program. If not, see 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 @@ -61,8 +61,8 @@ Array {?accepted_object_types?} - - {?external_ip?} + + {?external_address?} {?listen_port?} diff --git a/core b/core index 3333662bc..eea9aadff 160000 --- a/core +++ b/core @@ -1 +1 @@ -Subproject commit 3333662bc8456250b12127c35a9365b403c1f40a +Subproject commit eea9aadff7619b2a5c25972f37b34a1b83d30891 diff --git a/find-bad-php.sh b/find-bad-php.sh new file mode 100755 index 000000000..1d530b3af --- /dev/null +++ b/find-bad-php.sh @@ -0,0 +1,24 @@ +#!/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 ""` + + 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 -- 2.39.2