*
* @return $unlData The UNL data array
*/
- public final function getUniversalNodeLocatorData () {
+ public final function getUniversalNodeLocatorDataArray () {
// Return UNL data array
return $this->universalNodeLocatorData;
}
// Return the generic array
return $unlData;
}
+
+ /**
+ * Gets an element from universalNodeLocatorData array
+ *
+ * @param $element Element in universalNodeLocatorData array
+ * @return $value Found value
+ */
+ protected final function getUniversalNodeLocatorDataElement ($element) {
+ // Is the element there?
+ assert(isset($this->universalNodeLocatorData[$element]));
+
+ // Return it
+ return $this->universalNodeLocatorData[$element];
+ }
+
+ /**
+ * "Getter" for currently saved UNL
+ *
+ * @return $unl Currently saved Universal Node Locator
+ */
+ public final function getCurrentUniversalNodeLocator () {
+ // Construct generic UNL
+ $unl = sprintf('%s://%s',
+ $this->getUniversalNodeLocatorDataElement(UniversalNodeLocator::UNL_PART_PROTOCOL),
+ $this->getAddressPart()
+ );
+
+ // Return it
+ return $unl;
+ }
+
+ /**
+ * Default implementation for returning address part, may not be suitable
+ * for IPv4/IPv6 protocol handlers. So you have to overwrite (NOT CHANGE!) this method.
+ *
+ * @return $address Address part for the final UNL
+ */
+ public function getAddressPart () {
+ // Return it
+ return $this->getUniversalNodeLocatorDataElement(UniversalNodeLocator::UNL_PART_ADDRESS);
+ }
+
+ /**
+ * If the found UNL (address) matches own external or internal address
+ *
+ * @return $ifMatches Whether the found UNL matches own addresss
+ */
+ public function isOwnAddress () {
+ // Get current UNL (from universalNodeLocatorData array)
+ $currentUnl = $this->getCurrentUniversalNodeLocator();
+
+ // Get own external UNL
+ $externalUnl = HubTools::determineOwnExternalAddress();
+
+ // Get internal UNL
+ $internalUnl = HubTools::determineOwnInternalAddress();
+
+ // Debug message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: currentUnl=' . $currentUnl . ',externalUnl=' . $externalUnl . ',internalUnl=' . $internalUnl);
+ //* DIE-DEBUG: */ die(__METHOD__.':currentUnl=' . $currentUnl . ',this='.print_r($this, TRUE));
+
+ // Is it the same?
+ $ifMatches = (($currentUnl === $externalUnl) || ($currentUnl === $internalUnl));
+
+ // Debug message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: ifMatches=' . intval($ifMatches));
+
+ // Return result
+ return $ifMatches;
+ }
}
// [EOF]