*/
private function __construct () {
// Call parent constructor
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('HUB-TOOLS: CONSTRUCTOR!');
parent::__construct(__CLASS__);
// Init salt length
$this->sessionIdLength = 32 + FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('salt_length');
+
+ // Trace message
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('HUB-TOOLS: EXIT!!');
}
/**
*
* @retuen $selfInstance An instance of this class
*/
- public static final function getSelfInstance () {
+ public static final function getSelfInstance (): HubTools {
// Is the instance set
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('HUB-TOOLS: self::selfInstance[]=%s - CALLED!', gettype(self::$selfInstance)));
if (is_null(self::$selfInstance)) {
// Then set it
self::$selfInstance = new HubTools();
}
// Return own instance
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('HUB-TOOLS: self::selfInstance=%s - EXIT!', self::$selfInstance->__toString()));
return self::$selfInstance;
}
*/
protected function resolveUniversalNodeLocatorBySessionId (string $sessionId): string {
// Validate parameter
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('HUB-TOOLS: sessionId=%s - CALLED!', $sessionId));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('HUB-TOOLS: sessionId=%s - CALLED!', $sessionId));
if (empty($sessionId)) {
// Throw exception
throw new InvalidArgumentException('Parameter "sessionId" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
$recipientUnl = $recipient[NodeDistributedHashTableDatabaseFrontend::DB_COLUMN_EXTERNAL_ADDRESS];
} else {
// Get the instance, this might throw a NPE
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('HUB-TOOLS: Creating node instance ...');
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage('HUB-TOOLS: Creating node instance ...');
$nodeInstance = NodeObjectFactory::createNodeInstance();
// Is the session id the same?
}
// Return result
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('HUB-TOOLS: recipientUnl=%s - EXIT!', $recipientUnl));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('HUB-TOOLS: recipientUnl=%s - EXIT!', $recipientUnl));
return $recipientUnl;
}
*/
public static function resolveNodeIdBySessionId (string $sessionId): string {
// Validate parameter
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('HUB-TOOLS: sessionId=%s - CALLED!', $sessionId));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('HUB-TOOLS: sessionId=%s - CALLED!', $sessionId));
if (empty($sessionId)) {
// Throw exception
throw new InvalidArgumentException('Parameter "sessionId" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
$nodeData = DhtObjectFactory::createDhtInstance('node')->findNodeLocalBySessionId($sessionId);
// Make sure the node id is there
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('HUB-TOOLS: sessionId=' . $sessionId . ', nodeData[' . gettype($nodeData) . ']=' . print_r($nodeData, TRUE));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage('HUB-TOOLS: sessionId=' . $sessionId . ', nodeData[' . gettype($nodeData) . ']=' . print_r($nodeData, TRUE));
assert(isset($nodeData[NodeDistributedHashTableDatabaseFrontend::DB_COLUMN_NODE_ID]));
// Return it
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('HUB-TOOLS: nodeId=%s - EXIT!', $nodeData[NodeDistributedHashTableDatabaseFrontend::DB_COLUMN_NODE_ID]));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('HUB-TOOLS: nodeId=%s - EXIT!', $nodeData[NodeDistributedHashTableDatabaseFrontend::DB_COLUMN_NODE_ID]));
return $nodeData[NodeDistributedHashTableDatabaseFrontend::DB_COLUMN_NODE_ID];
}
*/
public static function resolveSessionIdByUniversalNodeLocator (LocateableNode $locatorInstance): string {
// Get an own instance
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('HUB-TOOLS: locatorInstance=%s - CALLED!', $locatorInstance->__toString()));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('HUB-TOOLS: locatorInstance=%s - CALLED!', $locatorInstance->__toString()));
$selfInstance = self::getSelfInstance();
// And ask it for session id by given Universal Node Locator
$sessionId = NULL;
// Is an entry found?
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('HUB-TOOLS: recipientData()=%d', count($recipientData)));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('HUB-TOOLS: recipientData()=%d', count($recipientData)));
if (count($recipientData) > 0) {
// Get session id
$sessionId = $recipientData[NodeDistributedHashTableDatabaseFrontend::DB_COLUMN_SESSION_ID];
}
// Return result
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('HUB-TOOLS: sessionId[%s]=%s - EXIT!', gettype($sessionId), $sessionId));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('HUB-TOOLS: sessionId[%s]=%s - EXIT!', gettype($sessionId), $sessionId));
return $sessionId;
}
*/
public static function resolveSessionIdToUnl (string $address): string {
// Is the parameter valid?
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('HUB-TOOLS: address=%s - CALLED!', $address));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('HUB-TOOLS: address=%s - CALLED!', $address));
if (empty($address)) {
// No empty address
throw new InvalidArgumentException('Parameter "address" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
if (preg_match('/([a-z0-9]{3,10})\/\/:([a-z0-9\.]{5,})/', $address)) {
// @TODO ((25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9])\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[0-9])):([0-9]{3,5})
// Direct Universal Node Locator found
- self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('HUB-TOOLS: Direct Universal Node Locator ' . $address . ' detected.');
+ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage('HUB-TOOLS: Direct Universal Node Locator ' . $address . ' detected.');
} elseif (preg_match('/([a-f0-9]{' . $selfInstance->getSessionIdLength() . '})/', $address)) {
// Resolve session id into an instance of a LocateableNode class
- /* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('HUB-TOOLS: Using internal session id resolver.');
+ /* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage('HUB-TOOLS: Using internal session id resolver.');
$recipient = $selfInstance->resolveUniversalNodeLocatorBySessionId($address);
// Debug message
- /* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('HUB-TOOLS: Session id ' . $address . ' resolved to ' . $recipient);
+ /* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage('HUB-TOOLS: Session id ' . $address . ' resolved to ' . $recipient);
} else {
// Invalid session id/UNL
throw new InvalidSessionIdException($address, self::EXCEPTION_SESSION_ID_IS_INVALID);
}
// Return it
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('HUB-TOOLS: recipient=%s - EXIT!', $recipient));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('HUB-TOOLS: recipient=%s - EXIT!', $recipient));
return $recipient;
}
*/
public static function determineOwnExternalAddress (): string {
// Is the external_address config entry set?
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('HUB-TOOLS: CALLED!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('HUB-TOOLS: CALLED!');
if (isset(self::$cachedAddresses[DiscoverableUniversalNodeLocator::UNL_TYPE_EXTERNAL])) {
// Get entry from cache
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('HUB-TOOLS: Getting external address from cache ...');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage('HUB-TOOLS: Getting external address from cache ...');
$unl = self::$cachedAddresses[DiscoverableUniversalNodeLocator::UNL_TYPE_EXTERNAL];
} elseif (FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('external_address') != '') {
// Use it as external address
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('HUB-TOOLS: Getting config entry external_address ...');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage('HUB-TOOLS: Getting config entry external_address ...');
$unl = FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('external_address');
self::$cachedAddresses[DiscoverableUniversalNodeLocator::UNL_TYPE_EXTERNAL] = $unl;
} else {
// Determine own external address by connecting to home server at 188.138.90.169
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('HUB-TOOLS: Invoking self::determineExternalUniversalNodeLocator() ...');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage('HUB-TOOLS: Invoking self::determineExternalUniversalNodeLocator() ...');
$unl = self::determineExternalUniversalNodeLocator();
self::$cachedAddresses[DiscoverableUniversalNodeLocator::UNL_TYPE_EXTERNAL] = $unl;
}
// Return it
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('HUB-TOOLS: unl=' . $unl . ' - EXIT!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('HUB-TOOLS: unl=' . $unl . ' - EXIT!');
return $unl;
}
*/
public static function determineOwnInternalAddress (): string {
// Is the internal_address config entry set?
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('HUB-TOOLS: CALLED!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('HUB-TOOLS: CALLED!');
if (isset(self::$cachedAddresses[DiscoverableUniversalNodeLocator::UNL_TYPE_INTERNAL])) {
// Get entry from cache
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('HUB-TOOLS: Getting internal address from cache ...');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage('HUB-TOOLS: Getting internal address from cache ...');
$unl = self::$cachedAddresses[DiscoverableUniversalNodeLocator::UNL_TYPE_INTERNAL];
} elseif (FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('allow_publish_internal_address') == 'N') {
// Not allowed to publish internal address, so use external
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('HUB-TOOLS: Invoking self::determineOwnExternalAddress() as allow_publish_internal_address=N is set ...');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage('HUB-TOOLS: Invoking self::determineOwnExternalAddress() as allow_publish_internal_address=N is set ...');
$unl = self::determineOwnExternalAddress();
self::$cachedAddresses[DiscoverableUniversalNodeLocator::UNL_TYPE_INTERNAL] = $unl;
} elseif (FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('internal_address') != '') {
// Use it as internal address
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('HUB-TOOLS: Getting config entry internal_address ...');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage('HUB-TOOLS: Getting config entry internal_address ...');
$unl = FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('internal_address');
self::$cachedAddresses[DiscoverableUniversalNodeLocator::UNL_TYPE_INTERNAL] = $unl;
} else {
// Determine own internal address
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('HUB-TOOLS: Invoking self::determineInternalUniversalNodeLocator() ...');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage('HUB-TOOLS: Invoking self::determineInternalUniversalNodeLocator() ...');
$unl = self::determineInternalUniversalNodeLocator();
self::$cachedAddresses[DiscoverableUniversalNodeLocator::UNL_TYPE_INTERNAL] = $unl;
}
// Return it
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('HUB-TOOLS: unl=' . $unl . ' - EXIT!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('HUB-TOOLS: unl=' . $unl . ' - EXIT!');
return $unl;
}
*/
public static function determineInternalUniversalNodeLocator () {
// Determine UNL based on this node:
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('HUB-TOOLS: CALLED!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('HUB-TOOLS: CALLED!');
// 1) Get discovery class
$discoveryInstance = ObjectFactory::createObjectByConfiguredName('unl_discovery_class');
$unl = $discoveryInstance->discoverUniversalNodeLocatorByConfiguredAddress(DiscoverableUniversalNodeLocator::UNL_TYPE_INTERNAL);
// Return it
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('HUB-TOOLS: unl=' . $unl . ' - EXIT!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('HUB-TOOLS: unl=' . $unl . ' - EXIT!');
return $unl;
}
*/
public static function determineExternalUniversalNodeLocator (): string {
// Determine UNL based on this node:
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('HUB-TOOLS: CALLED!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('HUB-TOOLS: CALLED!');
// 1) Get discovery class
$discoveryInstance = ObjectFactory::createObjectByConfiguredName('unl_discovery_class');
$unl = $discoveryInstance->discoverUniversalNodeLocatorByConfiguredAddress(DiscoverableUniversalNodeLocator::UNL_TYPE_EXTERNAL);
// Return it
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('HUB-TOOLS: unl=' . $unl . ' - EXIT!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('HUB-TOOLS: unl=' . $unl . ' - EXIT!');
return $unl;
}