--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * This exception is thrown when a DHT bootstrap request from other nodes was
+ * received but this node doesn't accept such requests.
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub 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 <http://www.gnu.org/licenses/>.
+ */
+class DhtBootstrapNotAcceptedException extends FrameworkException {
+ /**
+ * The super constructor for all exceptions
+ *
+ * @param $messageArray Error message array
+ * @param $code Error code
+ * @return void
+ */
+ public function __construct (array $messageArray, $code) {
+ // Construct the message
+ $message = sprintf('[%s:%d] This node (%s) is not accepting DHT bootstrap requests, but got one from session-id=%s,ip=%s/%s,listen port=%s,status=%s,mode=%s',
+ $messageArray[0]->__toString(),
+ $this->getLine(),
+ $messageArray[1]->__toString(),
+ $messageArray[2][XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_SESSION_ID],
+ $messageArray[2][XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_EXTERNAL_IP],
+ $messageArray[2][XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_INTERNAL_IP],
+ $messageArray[2][XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_LISTEN_PORT],
+ $messageArray[2][XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_NODE_STATUS],
+ $messageArray[2][XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_NODE_MODE]
+ );
+
+ // Call parent exception constructor
+ parent::__construct($message, $code);
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+<?php
+/**
+ * This exception is thrown when an DHT bootstrap answer comes but this node
+ * didn't send out such request.
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub 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 <http://www.gnu.org/licenses/>.
+ */
+class NoDhtBootstrapAttemptedException extends FrameworkException {
+ /**
+ * The super constructor for all exceptions
+ *
+ * @param $messageArray Error message array
+ * @param $code Error code
+ * @return void
+ */
+ public function __construct (array $messageArray, $code) {
+ // Construct the message
+ $message = sprintf('[%s:%d] This node (%s) has not attempted to bootstrap its DHT, but got an answer from session-id=%s,ip=%s/%s,listen port=%s,status=%s.',
+ $messageArray[0]->__toString(),
+ $this->getLine(),
+ $messageArray[1]->__toString(),
+ $messageArray[2][XmlDhtBootstrapAnswerTemplateEngine::DHT_BOOTSTRAP_DATA_SESSION_ID],
+ $messageArray[2][XmlDhtBootstrapAnswerTemplateEngine::DHT_BOOTSTRAP_DATA_EXTERNAL_IP],
+ $messageArray[2][XmlDhtBootstrapAnswerTemplateEngine::DHT_BOOTSTRAP_DATA_INTERNAL_IP],
+ $messageArray[2][XmlDhtBootstrapAnswerTemplateEngine::DHT_BOOTSTRAP_DATA_LISTEN_PORT],
+ $messageArray[2][XmlDhtBootstrapAnswerTemplateEngine::DHT_BOOTSTRAP_DATA_NODE_STATUS]
+ );
+
+ // Call parent exception constructor
+ parent::__construct($message, $code);
+ }
+}
+
+// [EOF]
+?>
parent::__construct(__CLASS__);
// Set handler name
- $this->setHandlerName('message_announcement');
+ $this->setHandlerName('message_dht_bootstrap');
// Init message data array
$this->messageDataElements = array(
* @param $messageData An array with message data to handle
* @param $packageInstance An instance of a Receivable class
* @return void
- * @throws DhtBootstrapNotAcceptedException If this node does not accept announcements
+ * @throws DhtBootstrapNotAcceptedException If this node does not accept DHT bootstrap requests
*/
public function handleMessageData (array $messageData, Receivable $packageInstance) {
// Get node instance
$nodeInstance = Registry::getRegistry()->getInstance('node');
- // Is this node accepting announcements?
- if (!$nodeInstance->isAcceptingDhtBootstraps()) {
+ // Is this node accepting DHT bootstrap requests?
+ if (!$nodeInstance->isAcceptingDhtBootstrap()) {
/*
- * This node is not accepting announcements, then someone wants to
- * announce his node to a non-bootstrap and non-master node.
+ * This node is not accepting DHT bootstrap requests.
*/
throw new DhtBootstrapNotAcceptedException(array($this, $nodeInstance, $messageData), self::EXCEPTION_DHT_BOOTSTRAP_NOT_ACCEPTED);
} // END - if
- // Register the announcing node with this node
+ // Register the DHT bootstrap requesting node with this node
$this->registerNodeByMessageData($messageData);
// Prepare answer message to be delivered back to the other node