From: Roland Häder <roland@mxchange.org>
Date: Fri, 27 Apr 2012 20:31:31 +0000 (+0000)
Subject: Some important improvements:
X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=b52519b557d5c0b68eeb988a72770044c2737560;p=hub.git

Some important improvements:
- The recipient IP must now match with external IP + TCP port (please fix this!)
- ... or the reciepient IP must match with own (internal) IP
- TODOs.txt updated
---

diff --git a/application/hub/main/discovery/package/class_PackageRecipientDiscovery.php b/application/hub/main/discovery/package/class_PackageRecipientDiscovery.php
index 6c70284b6..7ed996ca3 100644
--- a/application/hub/main/discovery/package/class_PackageRecipientDiscovery.php
+++ b/application/hub/main/discovery/package/class_PackageRecipientDiscovery.php
@@ -98,6 +98,7 @@ class PackageRecipientDiscovery extends BaseHubDiscovery implements Discoverable
 	 * @param	$decodedData	Decoded raw package data array
 	 * @return	void
 	 * @todo	Add some validation of recipient field, e.g. ip:port is found
+	 * @todo	The if() does only check for TCP, not UDP, e.g. try to get a $handlerInstance here
 	 */
 	public function discoverDecodedRecipients (array $decodedData) {
 		// First clear all recipients
@@ -107,18 +108,18 @@ class PackageRecipientDiscovery extends BaseHubDiscovery implements Discoverable
 		$recipient = explode(':', $decodedData[NetworkPackage::PACKAGE_DATA_RECIPIENT]);
 
 		// Is the 'recipient' field same as this peer's IP?
-		if ($recipient[0] == HubTools::determineOwnExternalIp()) {
+		if ((($recipient[0] == HubTools::determineOwnExternalIp()) && ($recipient[1] == $this->getConfigInstance()->getConfigEntry('node_tcp_listen_port'))) || ($recipient[0] == ConsoleTools::acquireSelfIPAddress())) {
 			/*
-			 * Is same as own external IP, don't do anything here so other
+			 * Is same as own external IP+TCP port or internal IP, don't do anything here so other
 			 * classes found an empty recipient list for internal (own) handling
 			 * of the original content.
 			 */
 
 			// Debug output (may flood)
-			/* NOISY-DEBUG: */ $this->debugOutput('RECIPIENT-DISCOVERY: Recipient ' . $recipient[0] . ' matches own ip (' .  HubTools::determineOwnExternalIp() . ')');
+			/* NOISY-DEBUG: */ $this->debugOutput('RECIPIENT-DISCOVERY: Recipient ' . $recipient[0] . ' matches own ip (' .  HubTools::determineOwnExternalIp() . ' or ' . ConsoleTools::acquireSelfIPAddress() . ')');
 		} else {
 			// Debug output (may flood)
-			/* NOISY-DEBUG: */ $this->debugOutput('RECIPIENT-DISCOVERY: Recipient ' . $recipient[0] . ' is different than own ip (' .  HubTools::determineOwnExternalIp() . '), need to forward (not yet implemented)!');
+			/* NOISY-DEBUG: */ $this->debugOutput('RECIPIENT-DISCOVERY: Recipient ' . $recipient[0] . ' is different than own external ip (' .  HubTools::determineOwnExternalIp() . ') nor internal ip (' . ConsoleTools::acquireSelfIPAddress() . '), need to forward (not yet implemented)!');
 
 			// This package is to be delivered to someone else, so add it
 			$this->getListInstance()->addEntry('ip_port', $decodedData[NetworkPackage::PACKAGE_DATA_RECIPIENT]);
diff --git a/docs/TODOs.txt b/docs/TODOs.txt
index ee4879dd8..469471630 100644
--- a/docs/TODOs.txt
+++ b/docs/TODOs.txt
@@ -23,6 +23,7 @@
 ./application/hub/main/database/wrapper/states/class_PeerStateLookupDatabaseWrapper.php:177:	 * @todo	Unfinished area
 ./application/hub/main/database/wrapper/states/class_PeerStateLookupDatabaseWrapper.php:219:	 * @todo	Unfinished area
 ./application/hub/main/discovery/package/class_PackageRecipientDiscovery.php:100:	 * @todo	Add some validation of recipient field, e.g. ip:port is found
+./application/hub/main/discovery/package/class_PackageRecipientDiscovery.php:101:	 * @todo	The if() does only check for TCP, not UDP, e.g. try to get a $handlerInstance here
 ./application/hub/main/factories/socket/class_SocketFactory.php:10: * @todo		Find an interface for hub helper
 ./application/hub/main/filter/bootstrap/chat/class_ChatBootstrapGenericActivationFilter.php:54:	 * @todo	Maybe we want to do somthing more here?
 ./application/hub/main/filter/bootstrap/cruncher/class_CruncherBootstrapBufferQueueInitializerFilter.php:54:	 * @todo	0% done