]> git.mxchange.org Git - hub.git/commitdiff
Added method to allow DHT bootstrap requests.
authorRoland Haeder <roland@mxchange.org>
Sun, 2 Mar 2014 14:54:49 +0000 (15:54 +0100)
committerRoland Haeder <roland@mxchange.org>
Sun, 2 Mar 2014 14:54:49 +0000 (15:54 +0100)
Signed-off-by: Roland Haeder <roland@mxchange.org>
application/hub/main/nodes/class_BaseHubNode.php
application/hub/main/states/dht/virgin/class_DhtVirginState.php

index 1f70cf7419c289eb4a18a8d3e6ce4514c8e2008f..80e31ff2624b698c6b8fad6a121db1f2ea94cc7f 100644 (file)
@@ -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
         *
index 52a255047e69fdb616580ff638289be1d13f2d10..90da00503c7f61c48d430db76f42ee0a3c00eb85 100644 (file)
@@ -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;
        }