From 723dd915774233aad29574472ec893df008404bd Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Sun, 2 Mar 2014 15:54:49 +0100 Subject: [PATCH] Added method to allow DHT bootstrap requests. Signed-off-by: Roland Haeder --- .../hub/main/nodes/class_BaseHubNode.php | 29 +++++++++++++++++++ .../dht/virgin/class_DhtVirginState.php | 3 ++ 2 files changed, 32 insertions(+) diff --git a/application/hub/main/nodes/class_BaseHubNode.php b/application/hub/main/nodes/class_BaseHubNode.php index 1f70cf741..80e31ff26 100644 --- a/application/hub/main/nodes/class_BaseHubNode.php +++ b/application/hub/main/nodes/class_BaseHubNode.php @@ -67,6 +67,11 @@ class BaseHubNode extends BaseHubSystem implements Updateable, AddableCriteria { */ private $acceptAnnouncements = FALSE; + /** + * Whether this node accepts DHT bootstrap requests (default: FALSE) + */ + private $acceptDhtBootstrap = FALSE; + /** * Protected constructor * @@ -638,6 +643,19 @@ class BaseHubNode extends BaseHubSystem implements Updateable, AddableCriteria { return $acceptAnnouncements; } + /** + * Checks whether this node accepts DHT bootstrap requests + * + * @return $acceptDhtBootstrap Whether this node accepts DHT bootstrap requests + */ + public final function isAcceptingDhtBootstrap () { + // Check it (this node must be active and not shutdown!) + $acceptDhtBootstrap = (($this->acceptDhtBootstrap === TRUE) && ($this->isNodeActive())); + + // Return it + return $acceptDhtBootstrap; + } + /** * Checks whether this node has attempted to announce itself * @@ -688,6 +706,17 @@ class BaseHubNode extends BaseHubSystem implements Updateable, AddableCriteria { $this->acceptAnnouncements = $acceptAnnouncements; } + /** + * Enables whether this node accepts DHT bootstrap requests + * + * @param $acceptDhtBootstrap Whether this node accepts DHT bootstrap requests (default: TRUE) + * @return void + */ + public final function enableAcceptDhtBootstrap ($acceptDhtBootstrap = TRUE) { + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NODE[' . __METHOD__ . ':' . __LINE__ . ']: Enabling DHT bootstrap requests ...'); + $this->acceptDhtBootstrap = $acceptDhtBootstrap; + } + /** * Checks wether this node is accepting node-list requests * diff --git a/application/hub/main/states/dht/virgin/class_DhtVirginState.php b/application/hub/main/states/dht/virgin/class_DhtVirginState.php index 52a255047..90da00503 100644 --- a/application/hub/main/states/dht/virgin/class_DhtVirginState.php +++ b/application/hub/main/states/dht/virgin/class_DhtVirginState.php @@ -51,6 +51,9 @@ class DhtVirginState extends BaseDhtState implements Stateable { // Set the dht instance $stateInstance->setDhtInstance($dhtInstance); + // Get node instance and enable DHT bootstrap requests + Registry::getRegistry()->getInstance('node')->enableAcceptDhtBootstrap(); + // Return the prepared instance return $stateInstance; } -- 2.39.5