From e4d5c1fc75d9a717eaf4530f2c9ec0731f917108 Mon Sep 17 00:00:00 2001 From: Roland 'Quix0r' Haeder Date: Tue, 11 Feb 2014 22:38:16 +0100 Subject: [PATCH] Added DHT recipient discovery interface (wrong computer :-( ). Signed-off-by: Roland 'Quix0r' Haeder --- application/hub/config.php | 7 ++- .../class_DiscoverableDhtRecipient.php | 35 +++++++++++++ ...hp => class_DiscoverableNodeRecipient.php} | 2 +- application/hub/main/discovery/dht/.htaccess | 1 + .../dht/class_DhtRecipientDiscovery.php | 50 +++++++++++++++++++ .../class_PackageRecipientDiscovery.php | 2 +- 6 files changed, 93 insertions(+), 4 deletions(-) create mode 100644 application/hub/interfaces/discovery/class_DiscoverableDhtRecipient.php rename application/hub/interfaces/discovery/{class_DiscoverableRecipient.php => class_DiscoverableNodeRecipient.php} (95%) create mode 100644 application/hub/main/discovery/dht/.htaccess create mode 100644 application/hub/main/discovery/dht/class_DhtRecipientDiscovery.php diff --git a/application/hub/config.php b/application/hub/config.php index 7f734fe38..316f6188d 100644 --- a/application/hub/config.php +++ b/application/hub/config.php @@ -660,12 +660,15 @@ $cfg->setConfigEntry('socket_registry_class', 'SocketRegistry'); // CFG: SOCKET-CONTAINER-CLASS $cfg->setConfigEntry('socket_container_class', 'SocketContainer'); -// CFG: PACKAGE-RECIPIENT-DISCOVERY +// CFG: PACKAGE-RECIPIENT-DISCOVERY-CLASS $cfg->setConfigEntry('package_recipient_discovery_class', 'PackageRecipientDiscovery'); -// CFG: SOCKET-DISCOVERY +// CFG: SOCKET-DISCOVERY-CLASS $cfg->setConfigEntry('socket_discovery_class', 'PackageSocketDiscovery'); +// CFG: DHT-RECIPIENT-DISCOVERY-CLASS +$cfg->setConfigEntry('dht_recipient_discovery_class', 'DhtRecipientDiscovery'); + // CFG: RECIPIENT-LIST-CLASS $cfg->setConfigEntry('recipient_list_class', 'RecipientList'); diff --git a/application/hub/interfaces/discovery/class_DiscoverableDhtRecipient.php b/application/hub/interfaces/discovery/class_DiscoverableDhtRecipient.php new file mode 100644 index 000000000..f1c686441 --- /dev/null +++ b/application/hub/interfaces/discovery/class_DiscoverableDhtRecipient.php @@ -0,0 +1,35 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +interface DiscoverableDhtRecipient extends FrameworkInterface { + /** + * Resolves one or more recipients for a DHT transfer by given package data. + * + * @param $packageData Valid package data array + * @return $recipients An indexed array with DHT recipients + */ + function resolveRecipientsByPackageData (array $packageData); +} + +// [EOF] +?> diff --git a/application/hub/interfaces/discovery/class_DiscoverableRecipient.php b/application/hub/interfaces/discovery/class_DiscoverableNodeRecipient.php similarity index 95% rename from application/hub/interfaces/discovery/class_DiscoverableRecipient.php rename to application/hub/interfaces/discovery/class_DiscoverableNodeRecipient.php index d7c2e43b0..9ec820615 100644 --- a/application/hub/interfaces/discovery/class_DiscoverableRecipient.php +++ b/application/hub/interfaces/discovery/class_DiscoverableNodeRecipient.php @@ -21,7 +21,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -interface DiscoverableRecipient extends FrameworkInterface, IteratorAggregate { +interface DiscoverableNodeRecipient extends FrameworkInterface, IteratorAggregate { /** * Tries to discover all recipients for given package data * diff --git a/application/hub/main/discovery/dht/.htaccess b/application/hub/main/discovery/dht/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/main/discovery/dht/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/main/discovery/dht/class_DhtRecipientDiscovery.php b/application/hub/main/discovery/dht/class_DhtRecipientDiscovery.php new file mode 100644 index 000000000..732e8ee84 --- /dev/null +++ b/application/hub/main/discovery/dht/class_DhtRecipientDiscovery.php @@ -0,0 +1,50 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class DhtRecipientDiscovery extends BaseHubDiscovery implements DiscoverableNodeRecipient, Registerable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Create an instance of this class + * + * @return $discoveryInstance An instance of this discovery class + */ + public static final function createDhtRecipientDiscovery () { + // Get an instance of this class + $discoveryInstance = new DhtRecipientDiscovery(); + + // Return the prepared instance + return $discoveryInstance; + } +} + +// [EOF] +?> diff --git a/application/hub/main/discovery/package/class_PackageRecipientDiscovery.php b/application/hub/main/discovery/package/class_PackageRecipientDiscovery.php index bea97ed06..3530eaaa3 100644 --- a/application/hub/main/discovery/package/class_PackageRecipientDiscovery.php +++ b/application/hub/main/discovery/package/class_PackageRecipientDiscovery.php @@ -21,7 +21,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -class PackageRecipientDiscovery extends BaseHubDiscovery implements DiscoverableRecipient, Registerable { +class PackageRecipientDiscovery extends BaseHubDiscovery implements DiscoverableNodeRecipient, Registerable { /** * Protected constructor * -- 2.39.5