*/
public function __construct (array $messageArray, $code) {
// Construct the message
- $message = sprintf('[%s:%d] This node (%s) is not accepting announcements, but got one from session-id=%s,unl=%s/%s,status=%s,mode=%s',
+ $message = sprintf('[%s:%d] This node (%s) is not accepting announcements, but got one from session-id=%s,hash=%s,unl=%s/%s,status=%s,mode=%s',
$messageArray[0]->__toString(),
$this->getLine(),
$messageArray[1]->__toString(),
$messageArray[2][XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_SESSION_ID],
+ $messageArray[2][XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_PRIVATE_KEY_HASH],
$messageArray[2][XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_EXTERNAL_ADDRESS],
$messageArray[2][XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_INTERNAL_ADDRESS],
$messageArray[2][XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_NODE_STATUS],
*/
public function __construct (array $messageArray, $code) {
// Construct the message
- $message = sprintf('[%s:%d] This node (%s) has not attempted to announce itself, but got an answer from session-id=%s,unl=%s/%s,status=%s.',
+ $message = sprintf('[%s:%d] This node (%s) has not attempted to announce itself, but got an answer from session-id=%s,hash=%s,unl=%s/%s,status=%s.',
$messageArray[0]->__toString(),
$this->getLine(),
$messageArray[1]->__toString(),
$messageArray[2][XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_SESSION_ID],
+ $messageArray[2][XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_PRIVATE_KEY_HASH],
$messageArray[2][XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_EXTERNAL_ADDRESS],
$messageArray[2][XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_INTERNAL_ADDRESS],
$messageArray[2][XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_NODE_STATUS]
*/
public function __construct (array $messageArray, $code) {
// Construct the message
- $message = sprintf('[%s:%d] Session id %s cannot be verfied. unl.external=%s,unl.internal=%s,status=%s.',
+ $message = sprintf('[%s:%d] Session id %s cannot be verfied. hash=%s,unl.external=%s,unl.internal=%s,status=%s.',
$messageArray[0]->__toString(),
$this->getLine(),
$messageArray[1][XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_SESSION_ID],
+ $messageArray[1][XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_PRIVATE_KEY_HASH],
$messageArray[1][XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_EXTERNAL_ADDRESS],
$messageArray[1][XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_INTERNAL_ADDRESS],
$messageArray[1][XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_NODE_STATUS]
XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_NODE_STATUS => '',
XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_NODE_MODE => '',
XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_SESSION_ID => ''
+ XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_PRIVATE_KEY_HASH => ''
);
}
XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_NODE_STATUS,
XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_NODE_MODE,
XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_SESSION_ID,
+ XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_PRIVATE_KEY_HASH,
);
// Init message-data->configuration translation array
XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_EXTERNAL_ADDRESS => 'your_external_address',
XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_INTERNAL_ADDRESS => 'your_internal_address',
XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_SESSION_ID => 'your_session_id'
+ XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_PRIVATE_KEY_HASH => 'your_private_key_hash'
);
// Init config-copy array
XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_INTERNAL_ADDRESS => 'internal_address',
XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_NODE_STATUS => 'node_status',
XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_SESSION_ID => 'session_id',
+ XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_PRIVATE_KEY_HASH => 'private_key_hash',
);
// Init array
XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_INTERNAL_ADDRESS,
XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_NODE_STATUS,
XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_SESSION_ID,
+ XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_PRIVATE_KEY_HASH,
BaseXmlAnswerTemplateEngine::ANSWER_STATUS,
);
XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_EXTERNAL_ADDRESS => 'your_external_address',
XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_INTERNAL_ADDRESS => 'your_internal_address',
XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_SESSION_ID => 'your_session_id'
+ XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_PRIVATE_KEY_HASH => 'your_private_key_hash'
*/
);
// Init config-copy array
$this->configCopy = array(
- XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_EXTERNAL_ADDRESS => 'external_address',
- XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_INTERNAL_ADDRESS => 'internal_address',
- XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_NODE_STATUS => 'node_status',
- XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_SESSION_ID => 'session_id',
+ XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_EXTERNAL_ADDRESS => 'external_address',
+ XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_INTERNAL_ADDRESS => 'internal_address',
+ XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_NODE_STATUS => 'node_status',
+ XmlAnnouncementAnswerTemplateEngine::OAANNOUNCEMENT_DATA_SESSION_ID => 'session_id',
+ XmlAnnouncementAnswerTemplateEngine::OAANNOUNCEMENT_DATA_PRIVATE_KEY_HASH => 'private_key_hash',
);
// Init array
// Ask DHT for session id
$senderData = $dhtInstance->findNodeLocalBySessionId($sessionId);
- // Make sure the element 'private_key_hash' is there
- assert(isset($senderData[NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_PRIVATE_KEY_HASH]));
-
- // Return it
- //* DEBUG-DIE */ die('senderData=' . print_r($senderData, TRUE));
- return $senderData[NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_PRIVATE_KEY_HASH];
+ // Is an entry found?
+ if (count($senderData) > 0) {
+ // Make sure the element 'private_key_hash' is there
+ /* NOISY-DEBUG */ self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __METHOD__ . ':' . __LINE__ . ']: senderData=' . print_r($senderData, TRUE));
+ assert(isset($senderData[NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_PRIVATE_KEY_HASH]));
+
+ // Return it
+ return $senderData[NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_PRIVATE_KEY_HASH];
+ } // END - if
}
/**
* Some XML nodes must be available for later data extraction
*/
const ANNOUNCEMENT_DATA_SESSION_ID = 'session-id';
+ const ANNOUNCEMENT_DATA_PRIVATE_KEY_HASH = 'private-key-hash';
const ANNOUNCEMENT_DATA_NODE_STATUS = 'node-status';
const ANNOUNCEMENT_DATA_NODE_MODE = 'node-mode';
const ANNOUNCEMENT_DATA_EXTERNAL_ADDRESS = 'external-address';
self::ANNOUNCEMENT_DATA_NODE_STATUS,
self::ANNOUNCEMENT_DATA_NODE_MODE,
self::ANNOUNCEMENT_DATA_SESSION_ID,
+ self::ANNOUNCEMENT_DATA_PRIVATE_KEY_HASH,
self::ANNOUNCEMENT_DATA_EXTERNAL_ADDRESS,
self::ANNOUNCEMENT_DATA_INTERNAL_ADDRESS,
'object-type-list',
$this->getStackInstance()->pushNamed('node_announcement', self::ANNOUNCEMENT_DATA_SESSION_ID);
}
+ /**
+ * Starts the private key hash
+ *
+ * @return void
+ */
+ protected function startPrivateKeyHash () {
+ // Push the node name on the stacker
+ $this->getStackInstance()->pushNamed('node_announcement', self::ANNOUNCEMENT_DATA_PRIVATE_KEY_HASH);
+ }
+
/**
* Starts the public ip
*
$this->getStackInstance()->popNamed('node_announcement');
}
+ /**
+ * Finishes the private key hash
+ *
+ * @return void
+ */
+ protected function finishPrivateKeyHash () {
+ // Pop the last entry
+ $this->getStackInstance()->popNamed('node_announcement');
+ }
+
/**
* Finishes the session id
*
* Some XML nodes must be available for later data extraction
*/
const ANNOUNCEMENT_DATA_SESSION_ID = 'my-session-id';
+ const ANNOUNCEMENT_DATA_PRIVATE_KEY_HASH = 'my-private-key-hash';
const ANNOUNCEMENT_DATA_NODE_STATUS = 'my-status';
const ANNOUNCEMENT_DATA_EXTERNAL_ADDRESS = 'my-external-address';
const ANNOUNCEMENT_DATA_INTERNAL_ADDRESS = 'my-internal-address';
self::ANNOUNCEMENT_DATA_INTERNAL_ADDRESS,
self::ANNOUNCEMENT_DATA_NODE_STATUS,
self::ANNOUNCEMENT_DATA_SESSION_ID,
+ self::ANNOUNCEMENT_DATA_PRIVATE_KEY_HASH,
// Data from other node
'your-external-address',
'your-internal-address',
*/
protected function startMySessionId () {
// Push the node name on the stacker
- $this->getStackInstance()->pushNamed('node_announcement_answer', self::ANNOUNCEMENT_DATA_SESSION_ID);
+ $this->getStackInstance()->pushNamed('node_announcement_answer', self::OHANNOUNCEMENT_DATA_SESSION_ID);
+ }
+
+ /**
+ * Starts the my-private-key-hash
+ *
+ * @return void
+ */
+ protected function startMyPrivateKeyHash () {
+ // Push the node name on the stacker
+ $this->getStackInstance()->pushNamed('node_announcement_answer', self::OHANNOUNCEMENT_DATA_PRIVATE_KEY_HASH);
}
/**
$this->getStackInstance()->popNamed('node_announcement_answer');
}
+ /**
+ * Finishes the my-private-key-hash
+ *
+ * @return void
+ */
+ protected function finishMyPrivateKeyhash () {
+ // Pop the last entry
+ $this->getStackInstance()->popNamed('node_announcement_answer');
+ }
+
/**
* Finishes the my-session-id
*
$this->getStackInstance()->pushNamed('node_announcement_answer', 'your-session-id');
}
+ /**
+ * Starts the your-private-key-hash
+ *
+ * @return void
+ */
+ protected function startYourPrivateKeyHash () {
+ // Push the node name on the stacker
+ $this->getStackInstance()->pushNamed('node_announcement_answer', 'your-private-key-hash');
+ }
+
+ /**
+ * Finishes the your-private-key-hash
+ *
+ * @return void
+ */
+ protected function finishYourPrivateKeyHash () {
+ // Pop the last entry
+ $this->getStackInstance()->popNamed('node_announcement_answer');
+ }
+
/**
* Finishes the your-session-id
*
* Some XML nodes must be available for later data extraction
*/
const DHT_BOOTSTRAP_DATA_SESSION_ID = 'my-session-id';
+ const DHT_BOOTSTRAP_DATA_PRIVATE_KEY_HASH = 'my-private-key-hash';
const DHT_BOOTSTRAP_DATA_NODE_STATUS = 'my-status';
const DHT_BOOTSTRAP_DATA_EXTERNAL_ADDRESS = 'my-external-address';
const DHT_BOOTSTRAP_DATA_INTERNAL_ADDRESS = 'my-internal-address';
$this->getStackInstance()->pushNamed('node_dht_bootstrap_answer', self::DHT_BOOTSTRAP_DATA_SESSION_ID);
}
+ /**
+ * Starts the my-private-key-hash
+ *
+ * @return void
+ */
+ protected function startMyPrivateKeyHash () {
+ // Push the node name on the stacker
+ $this->getStackInstance()->pushNamed('node_dht_bootstrap_answer', self::DHT_BOOTSTRAP_DATA_PRIVATE_KEY_HASH);
+ }
+
/**
* Starts the my-status
*
$this->getStackInstance()->popNamed('node_dht_bootstrap_answer');
}
+ /**
+ * Finishes the my-private-key-hash
+ *
+ * @return void
+ */
+ protected function finishMyPrivateKeyHash () {
+ // Pop the last entry
+ $this->getStackInstance()->popNamed('node_dht_bootstrap_answer');
+ }
+
/**
* Finishes the my-session-id
*
$this->getStackInstance()->pushNamed('node_dht_bootstrap_answer', 'your-session-id');
}
+ /**
+ * Starts the your-private-key-hash
+ *
+ * @return void
+ */
+ protected function startYourPrivateKeyHash () {
+ // Push the node name on the stacker
+ $this->getStackInstance()->pushNamed('node_dht_bootstrap_answer', 'your-private-key-hash');
+ }
+
+ /**
+ * Finishes the your-private-key-hash
+ *
+ * @return void
+ */
+ protected function finishYourPrivateKeyHash () {
+ // Pop the last entry
+ $this->getStackInstance()->popNamed('node_dht_bootstrap_answer');
+ }
+
/**
* Finishes the your-session-id
*
<node-mode>{?node_default_mode?}</node-mode>
<!-- The session id. This should be announced to all other hubs. //-->
<session-id>{?session_id?}</session-id>
+ <!-- The private key's hash. This should be announced to all other hubs. //-->
+ <private-key-hash>{?private_key_hash?}</private-key-hash>
<!-- Data from our listeners (e.g. which port) //-->
<listener>
<!-- Public external address //-->
//-->
<my-session-id>{?my_session_id?}</my-session-id>
<!--
+ This node's private key hash
+ //-->
+ <my-private-key-hash>{?my_private_key_hash?}</my-private-key-hash>
+ <!--
This node's status
//-->
<my-status>{?my_status?}</my-status>
Other node's session id
//-->
<your-session-id>{?your_session_id?}</your-session-id>
+ <!--
+ Other node's private key hash
+ //-->
+ <your-private-key-hash>{?your_private_key_hash?}</your-private-key-hash>
</your-data>
<!--
Status of this answer. This can be something like OKAY if all went fine or
//-->
<my-session-id>{?my_session_id?}</my-session-id>
<!--
+ This node's private key hash
+ //-->
+ <my-private-key-hash>{?my_private_key_hash?}</my-private-key-hash>
+ <!--
This node's status
//-->
<my-status>{?my_status?}</my-status>
Other node's session id
//-->
<your-session-id>{?your_session_id?}</your-session-id>
+ <!--
+ Other node's private key hash
+ //-->
+ <your-private-key-hash>{?your_private_key_hash?}</your-private-key-hash>
</your-data>
<!--
Status of this answer. This can be something like OKAY if all went fine or