- 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 <roland@mxchange.org>
// 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
* 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.
// 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');
// 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');
$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]
$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]
);
$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]
/**
* 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
$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]
);
*/
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],
);
*/
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],
);
* @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]
* 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
-OS<?php
+<?php
/**
* An interface for ProtocolResolvers
*
*/
interface ProtocolResolver extends FrameworkInterface {
/**
- * 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
*/
- function resolveUniversalResourceLocatorFromNodeHelper (NodeHelper $nodeInstance);
+ 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]
/**
* 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
*/
* 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
// 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);
}
$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]
$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]);
// 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 => '',
);
}
// 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,
);
}
// 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,
);
}
// 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
);
*
* 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
// 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,
// 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
);
}
// 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,
// 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
);
}
// 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,
// 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
);
}
// 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,
* 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
// 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,
// 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
);
}
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) {
$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]);
// 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) {
* 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
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.
}
/**
- * 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;
* @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, $this->generateInternalUnl());
+ $criteriaInstance->addCriteria(NodeInformationDatabaseWrapper::DB_COLUMN_EXTERNAL_UNL, $this->generateExternalUnl());
}
/**
* @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
* @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
// 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 . ') ...');
// 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)) {
}
/**
- * 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
*/
}
/**
- * 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;
}
}
}
/**
- * 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
*/
}
/**
- * 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;
}
}
/**
* 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
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',
);
}
*
* @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 () {
+ protected function finishExternalAddress () {
// Pop the last entry
$this->getStackInstance()->popNamed('node_announcement');
}
/**
* 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';
/**
'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,
}
/**
- * 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);
}
/**
}
/**
- * 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');
}
/**
* 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
'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,
}
/**
- * 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);
}
/**
}
/**
- * 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');
}
/**
* 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
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
);
}
*
* @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 () {
+ protected function finishExternalAddress () {
// Pop the last entry
$this->getStackInstance()->popNamed('dht_bootstrap');
}
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';
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',
);
}
*
* @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 () {
+ protected function finishExternalAddress () {
// Pop the last entry
$this->getStackInstance()->popNamed('dht_publish');
}
$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();
// 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
}
}
/**
- * 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
}
/**
- * 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();
}
// 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';
$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,
// 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());
/**
* 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
*/
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());
$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,
)
);
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
<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>
+ <!-- Public external address //-->
+ <external-address>{?external_address?}</external-address>
+ <!-- Private internal address //-->
+ <internal-address>{?internal_address?}</internal-address>
<!-- Listener ports for both connections //-->
<listen-port>{?node_listen_port?}</listen-port>
</listener>
//-->
<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>
+ <my-internal-address>{?my_internal_address?}</my-internal-address>
<!--
This node's TCP/UDP listen port
//-->
//-->
<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
//-->
//-->
<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>
+ <my-internal-address>{?my_internal_address?}</my-internal-address>
<!--
This node's TCP/UDP listen port
//-->
//-->
<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
//-->
<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>
+ <!-- Public external address //-->
+ <external-address>{?external_address?}</external-address>
+ <!-- Private internal address //-->
+ <internal-address>{?internal_address?}</internal-address>
<!-- Listener ports for both connections //-->
<listen-port>{?node_listen_port?}</listen-port>
</listener>
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>
+ <!-- Public external address //-->
+ <external-address>{?external_address?}</external-address>
<!-- Listener ports for both connections //-->
<listen-port>{?listen_port?}</listen-port>
</listener>
-Subproject commit 3333662bc8456250b12127c35a9365b403c1f40a
+Subproject commit eea9aadff7619b2a5c25972f37b34a1b83d30891
--- /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