From 189bf9781c1e477df39577d405cce1467ece674f Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Mon, 29 May 2017 17:59:14 +0200 Subject: [PATCH] Continued: - imported HelpableNode - imported SocketDiscoveryFactory, DiscoverableSocket - imported ProtocolHandlerFactory - imported BaseProtocolHandler and made it abstract - imported BaseIpV4ProtocolHandler and it needs to be abstract - need to implement setter/getter for protocolName - added missing namespaces to configuration entries MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- .../class_PackageRecipientDiscovery.php | 1 + .../socket/class_PackageSocketDiscovery.php | 2 ++ .../handler/class_ProtocolHandlerFactory.php | 1 + .../class_PackageSelfConnectTagFilter.php | 4 +-- .../hub/classes/handler/protocol/class_ | 1 + .../protocol/class_BaseProtocolHandler.php | 26 ++++++++++++++++++- .../ipv4/class_BaseIpV4ProtocolHandler.php | 3 ++- .../ipv4/tcp/class_TcpProtocolHandler.php | 7 +++-- .../ipv4/tcp/class_TcpConnectionHelper.php | 1 + .../class_NodeAnnouncementHelper.php | 1 + ...ss_NodeAnnouncementMessageAnswerHelper.php | 1 + ...ss_NodeDhtBootstrapMessageAnswerHelper.php | 1 + ...NodeRequestNodeListMessageAnswerHelper.php | 1 + application/hub/classes/helper/node/class_ | 1 + .../class_NodeSelfConnectHelper.php | 1 + .../class_NodeRequestNodeListHelper.php | 1 + .../classes/package/class_NetworkPackage.php | 1 + .../pools/peer/class_DefaultPeerPool.php | 1 + .../hub/classes/tags/class_BaseTag.php | 6 ----- .../tags/package/class_PackageTags.php | 1 + .../class_XmlSelfConnectTemplateEngine.php | 4 +-- application/hub/config.php | 6 ++--- .../helper/node/class_HelpableNode.php | 2 +- .../hub/interfaces/tags/class_Tagable.php | 4 +++ 24 files changed, 56 insertions(+), 22 deletions(-) diff --git a/application/hub/classes/discovery/recipient/package/class_PackageRecipientDiscovery.php b/application/hub/classes/discovery/recipient/package/class_PackageRecipientDiscovery.php index 918a1e4f0..feb0bc4ee 100644 --- a/application/hub/classes/discovery/recipient/package/class_PackageRecipientDiscovery.php +++ b/application/hub/classes/discovery/recipient/package/class_PackageRecipientDiscovery.php @@ -5,6 +5,7 @@ namespace Hub\Discovery\Network\Recipient; // Import hub-specific sutff use Hub\Discovery\Recipient\BaseRecipientDiscovery; use Hub\Discovery\Recipient\Node\DiscoverableNodeRecipient; +use Hub\Factory\Handler\Protocol\ProtocolHandlerFactory; use Hub\Network\Package\NetworkPackage; use Hub\Node\Data\InvalidSessionIdException; use Hub\Tools\HubTools; diff --git a/application/hub/classes/discovery/recipient/socket/class_PackageSocketDiscovery.php b/application/hub/classes/discovery/recipient/socket/class_PackageSocketDiscovery.php index ed2fd132f..695a197fb 100644 --- a/application/hub/classes/discovery/recipient/socket/class_PackageSocketDiscovery.php +++ b/application/hub/classes/discovery/recipient/socket/class_PackageSocketDiscovery.php @@ -5,6 +5,8 @@ namespace Hub\Network\Discovery\Socket; // Import hub-specific stuff use Hub\Container\Socket\StorableSocket; use Hub\Discovery\Recipient\BaseRecipientDiscovery; +use Hub\Discovery\Protocol\ProtocolDiscovery; +use Hub\Discovery\Socket\DiscoverableSocket; use Hub\Factory\Node\NodeObjectFactory; use Hub\Factory\Socket\SocketFactory; use Hub\Generic\BaseHubSystem; diff --git a/application/hub/classes/factories/handler/class_ProtocolHandlerFactory.php b/application/hub/classes/factories/handler/class_ProtocolHandlerFactory.php index 685d6acd7..392efe55e 100644 --- a/application/hub/classes/factories/handler/class_ProtocolHandlerFactory.php +++ b/application/hub/classes/factories/handler/class_ProtocolHandlerFactory.php @@ -3,6 +3,7 @@ namespace Hub\Factory\Handler\Protocol; // Import application-specific stuff +use Hub\Discovery\Protocol\ProtocolDiscovery; use Hub\Helper\HubHelper; // Import framework stuff diff --git a/application/hub/classes/filter/tags/class_PackageSelfConnectTagFilter.php b/application/hub/classes/filter/tags/class_PackageSelfConnectTagFilter.php index 5c59c323c..2d2696065 100644 --- a/application/hub/classes/filter/tags/class_PackageSelfConnectTagFilter.php +++ b/application/hub/classes/filter/tags/class_PackageSelfConnectTagFilter.php @@ -110,7 +110,5 @@ class PackageSelfConnectTagFilter extends BaseNodeFilter implements FilterablePa // Please don't call this method throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); } -} -// [EOF] -?> +} diff --git a/application/hub/classes/handler/protocol/class_ b/application/hub/classes/handler/protocol/class_ index beada8cf3..e0af2a97a 100644 --- a/application/hub/classes/handler/protocol/class_ +++ b/application/hub/classes/handler/protocol/class_ @@ -3,6 +3,7 @@ namespace Hub\Handler\Protocol\; // Import appplication-specific stuff +use Hub\Handler\Protocol\BaseProtocolHandler; use Hub\Handler\Protocol\HandleableProtocol; // Import framework stuff diff --git a/application/hub/classes/handler/protocol/class_BaseProtocolHandler.php b/application/hub/classes/handler/protocol/class_BaseProtocolHandler.php index 17a39d73d..3e94c30de 100644 --- a/application/hub/classes/handler/protocol/class_BaseProtocolHandler.php +++ b/application/hub/classes/handler/protocol/class_BaseProtocolHandler.php @@ -32,12 +32,17 @@ use CoreFramework\Handler\BaseHandler; * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -class BaseProtocolHandler extends BaseHandler implements HandleableProtocol { +abstract class BaseProtocolHandler extends BaseHandler implements HandleableProtocol { /** * Whole UNL instance */ private $universalNodeLocatorInstance = NULL; + /** + * Name of used protocol + */ + private $protocolName = 'invalid'; + /** * Protected constructor * @@ -148,6 +153,25 @@ class BaseProtocolHandler extends BaseHandler implements HandleableProtocol { return $this->universalNodeLocatorData[$element]; } + /** + * Getter for protocol name + * + * @return $protocolName Name of used protocol + */ + public final function getProtocolName () { + return $this->protocolName; + } + + /** + * Setter for protocol name + * + * @param $protocolName Name of used protocol + * @return void + */ + protected final function setProtocolName ($protocolName) { + $this->protocolName = $protocolName; + } + /** * Getter for UNL instance * diff --git a/application/hub/classes/handler/protocol/ipv4/class_BaseIpV4ProtocolHandler.php b/application/hub/classes/handler/protocol/ipv4/class_BaseIpV4ProtocolHandler.php index 70056e263..e00ebb10a 100644 --- a/application/hub/classes/handler/protocol/ipv4/class_BaseIpV4ProtocolHandler.php +++ b/application/hub/classes/handler/protocol/ipv4/class_BaseIpV4ProtocolHandler.php @@ -3,6 +3,7 @@ namespace Hub\Handler\Protocol\Network\IpV4; // Import application-specific stuff +use Hub\Handler\Protocol\BaseProtocolHandler; use Hub\Locator\Node\LocateableNode; use Hub\Network\Package\NetworkPackage; @@ -28,7 +29,7 @@ use Hub\Network\Package\NetworkPackage; * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -class BaseIpV4ProtocolHandler extends BaseProtocolHandler { +abstract class BaseIpV4ProtocolHandler extends BaseProtocolHandler { /** * Port number */ diff --git a/application/hub/classes/handler/protocol/ipv4/tcp/class_TcpProtocolHandler.php b/application/hub/classes/handler/protocol/ipv4/tcp/class_TcpProtocolHandler.php index 332a995a9..a22706bee 100644 --- a/application/hub/classes/handler/protocol/ipv4/tcp/class_TcpProtocolHandler.php +++ b/application/hub/classes/handler/protocol/ipv4/tcp/class_TcpProtocolHandler.php @@ -1,8 +1,9 @@ +} diff --git a/application/hub/classes/helper/connection/ipv4/tcp/class_TcpConnectionHelper.php b/application/hub/classes/helper/connection/ipv4/tcp/class_TcpConnectionHelper.php index da33a3f54..f73a38a53 100644 --- a/application/hub/classes/helper/connection/ipv4/tcp/class_TcpConnectionHelper.php +++ b/application/hub/classes/helper/connection/ipv4/tcp/class_TcpConnectionHelper.php @@ -4,6 +4,7 @@ namespace Hub\Helper\Connection\Tcp; // Import application-specific stuff use Hub\Container\Socket\StorableSocket; +use Hub\Factory\Handler\Protocol\ProtocolHandlerFactory; use Hub\Factory\Socket\SocketFactory; use Hub\Helper\Connection\ConnectionHelper; use Hub\Locator\Node\LocateableNode; diff --git a/application/hub/classes/helper/node/announcement/class_NodeAnnouncementHelper.php b/application/hub/classes/helper/node/announcement/class_NodeAnnouncementHelper.php index 003985fdb..c5928ab32 100644 --- a/application/hub/classes/helper/node/announcement/class_NodeAnnouncementHelper.php +++ b/application/hub/classes/helper/node/announcement/class_NodeAnnouncementHelper.php @@ -7,6 +7,7 @@ use Hub\Factory\Network\NetworkPackageFactory; use Hub\Helper\Node\BaseNodeHelper; use Hub\Helper\Node\NodeHelper; use Hub\Network\Package\NetworkPackage; +use Hub\Node\Helper\HelpableNode; // Import framework stuff use CoreFramework\Factory\Template\XmlTemplateEngineFactory; diff --git a/application/hub/classes/helper/node/answer/announcement/class_NodeAnnouncementMessageAnswerHelper.php b/application/hub/classes/helper/node/answer/announcement/class_NodeAnnouncementMessageAnswerHelper.php index 0a879d50d..b8308a5cb 100644 --- a/application/hub/classes/helper/node/answer/announcement/class_NodeAnnouncementMessageAnswerHelper.php +++ b/application/hub/classes/helper/node/answer/announcement/class_NodeAnnouncementMessageAnswerHelper.php @@ -5,6 +5,7 @@ namespace Hub\Node\Helper\Answer\Announcement; // Import application-specific stuff use Hub\Factory\Network\NetworkPackageFactory; use Hub\Helper\Node\NodeHelper; +use Hub\Node\Helper\HelpableNode; // Import framework stuff use CoreFramework\Factory\Template\XmlTemplateEngineFactory; diff --git a/application/hub/classes/helper/node/answer/dht/class_NodeDhtBootstrapMessageAnswerHelper.php b/application/hub/classes/helper/node/answer/dht/class_NodeDhtBootstrapMessageAnswerHelper.php index c39146760..bd78c34a4 100644 --- a/application/hub/classes/helper/node/answer/dht/class_NodeDhtBootstrapMessageAnswerHelper.php +++ b/application/hub/classes/helper/node/answer/dht/class_NodeDhtBootstrapMessageAnswerHelper.php @@ -5,6 +5,7 @@ namespace Hub\Node\Helper\Answer\Dht\Bootstrap; // Import application-specific stuff use Hub\Factory\Network\NetworkPackageFactory; use Hub\Helper\Node\NodeHelper; +use Hub\Node\Helper\HelpableNode; use Hub\Template\Engine\Xml\Dht\Bootstrap\XmlDhtBootstrapTemplateEngine; // Import framework stuff diff --git a/application/hub/classes/helper/node/answer/requests/class_NodeRequestNodeListMessageAnswerHelper.php b/application/hub/classes/helper/node/answer/requests/class_NodeRequestNodeListMessageAnswerHelper.php index 16f662ec4..d7a208741 100644 --- a/application/hub/classes/helper/node/answer/requests/class_NodeRequestNodeListMessageAnswerHelper.php +++ b/application/hub/classes/helper/node/answer/requests/class_NodeRequestNodeListMessageAnswerHelper.php @@ -5,6 +5,7 @@ namespace Hub\Node\Helper\Answer\Request\NodeList; // Import application-specific stuff use Hub\Factory\Network\NetworkPackageFactory; use Hub\Helper\Node\NodeHelper; +use Hub\Node\Helper\HelpableNode; // Import framework stuff use CoreFramework\Factory\Template\XmlTemplateEngineFactory; diff --git a/application/hub/classes/helper/node/class_ b/application/hub/classes/helper/node/class_ index 87a2b3bbf..908c32e61 100644 --- a/application/hub/classes/helper/node/class_ +++ b/application/hub/classes/helper/node/class_ @@ -7,6 +7,7 @@ use Hub\Factory\Network\NetworkPackageFactory; use Hub\Helper\Node\BaseNodeHelper; use Hub\Helper\Node\NodeHelper; use Hub\Network\Package\NetworkPackage; +use Hub\Node\Helper\HelpableNode; /** * A ??? hub helper class diff --git a/application/hub/classes/helper/node/connection/class_NodeSelfConnectHelper.php b/application/hub/classes/helper/node/connection/class_NodeSelfConnectHelper.php index 59bba1473..00dc7f0e6 100644 --- a/application/hub/classes/helper/node/connection/class_NodeSelfConnectHelper.php +++ b/application/hub/classes/helper/node/connection/class_NodeSelfConnectHelper.php @@ -7,6 +7,7 @@ use Hub\Factory\Network\NetworkPackageFactory; use Hub\Helper\Node\BaseNodeHelper; use Hub\Helper\Node\NodeHelper; use Hub\Network\Package\NetworkPackage; +use Hub\Node\Helper\HelpableNode; use Hub\Tag\Tagable; // Import framework stuff diff --git a/application/hub/classes/helper/node/requests/class_NodeRequestNodeListHelper.php b/application/hub/classes/helper/node/requests/class_NodeRequestNodeListHelper.php index f1ae9860d..d3b0932b4 100644 --- a/application/hub/classes/helper/node/requests/class_NodeRequestNodeListHelper.php +++ b/application/hub/classes/helper/node/requests/class_NodeRequestNodeListHelper.php @@ -7,6 +7,7 @@ use Hub\Factory\Network\NetworkPackageFactory; use Hub\Helper\Node\BaseNodeHelper; use Hub\Helper\Node\NodeHelper; use Hub\Network\Package\NetworkPackage; +use Hub\Node\Helper\HelpableNode; // Import framework stuff use CoreFramework\Factory\Template\XmlTemplateEngineFactory; diff --git a/application/hub/classes/package/class_NetworkPackage.php b/application/hub/classes/package/class_NetworkPackage.php index 8c33927cb..115cfad7a 100644 --- a/application/hub/classes/package/class_NetworkPackage.php +++ b/application/hub/classes/package/class_NetworkPackage.php @@ -8,6 +8,7 @@ use Hub\Database\Frontend\Node\Dht\NodeDistributedHashTableDatabaseWrapper; use Hub\Factory\Assembler\Package\PackageAssemblerFactory; use Hub\Factory\Dht\DhtObjectFactory; use Hub\Factory\Discovery\Package\PackageDiscoveryFactory; +use Hub\Factory\Discovery\Socket\SocketDiscoveryFactory; use Hub\Factory\Information\Connection\ConnectionInfoFactory; use Hub\Factory\Node\NodeObjectFactory; use Hub\Generic\BaseHubSystem; diff --git a/application/hub/classes/pools/peer/class_DefaultPeerPool.php b/application/hub/classes/pools/peer/class_DefaultPeerPool.php index 61c3309f1..8bcb68880 100644 --- a/application/hub/classes/pools/peer/class_DefaultPeerPool.php +++ b/application/hub/classes/pools/peer/class_DefaultPeerPool.php @@ -5,6 +5,7 @@ namespace Hub\Pool\Peer; // Import application-specific stuff use Hub\Container\Socket\StorableSocket; use Hub\Connection\InvalidConnectionTypeException; +use Hub\Factory\Handler\Protocol\ProtocolHandlerFactory; use Hub\Listener\Listenable; use Hub\Locator\Node\LocateableNode; use Hub\Network\Package\NetworkPackage; diff --git a/application/hub/classes/tags/class_BaseTag.php b/application/hub/classes/tags/class_BaseTag.php index cdc33767e..6de66a680 100644 --- a/application/hub/classes/tags/class_BaseTag.php +++ b/application/hub/classes/tags/class_BaseTag.php @@ -31,12 +31,6 @@ use CoreFramework\Registry\Registerable; * along with this program. If not, see . */ class BaseTag extends BaseHubSystem implements Registerable { - /** - * Constants for tags - */ - const TAG_SELF_CONNECT = 'self_connect'; - const TAG_CLAIM_MINING_REWARD = 'claim_reward'; - /** * An array with all tags */ diff --git a/application/hub/classes/tags/package/class_PackageTags.php b/application/hub/classes/tags/package/class_PackageTags.php index f85fc7249..b2d24d840 100644 --- a/application/hub/classes/tags/package/class_PackageTags.php +++ b/application/hub/classes/tags/package/class_PackageTags.php @@ -3,6 +3,7 @@ namespace Hub\Tag\Package; // Import application-specific stuff +use Hub\Factory\Handler\Protocol\ProtocolHandlerFactory; use Hub\Factory\Registry\Object\ObjectTypeRegistryFactory; use Hub\Listener\Listenable; use Hub\Network\Package\NetworkPackage; diff --git a/application/hub/classes/template/connect/class_XmlSelfConnectTemplateEngine.php b/application/hub/classes/template/connect/class_XmlSelfConnectTemplateEngine.php index 711e6e3ec..2854022fb 100644 --- a/application/hub/classes/template/connect/class_XmlSelfConnectTemplateEngine.php +++ b/application/hub/classes/template/connect/class_XmlSelfConnectTemplateEngine.php @@ -192,7 +192,5 @@ class XmlSelfConnectTemplateEngine extends BaseXmlTemplateEngine implements Comp // Pop the last entry $this->getStackInstance()->popNamed('node_self_connect'); } -} -// [EOF] -?> +} diff --git a/application/hub/config.php b/application/hub/config.php index 89f6d8e52..1d015adc9 100644 --- a/application/hub/config.php +++ b/application/hub/config.php @@ -346,7 +346,7 @@ $cfg->setConfigEntry('node_dht_bootstrap_answer_template_type', 'xml/answer/dht_ $cfg->setConfigEntry('node_request_node_list_answer_template_type', 'xml/answer/requests'); // CFG: NODE-SELF-CONNECT-TEMPLATE-CLASS -$cfg->setConfigEntry('node_self_connect_template_class', 'XmlSelfConnectTemplateEngine'); +$cfg->setConfigEntry('node_self_connect_template_class', 'Hub\Template\Engine\Xml\SelfConnect\XmlSelfConnectTemplateEngine'); // CFG: NODE-SELF-CONNECT-TEMPLATE-TYPE $cfg->setConfigEntry('node_self_connect_template_type', 'xml/self_connect'); @@ -724,7 +724,7 @@ $cfg->setConfigEntry('ipc_socket_file_name', 'php_hub_ipc_socket'); $cfg->setConfigEntry('package_recipient_discovery_class', 'Hub\Discovery\Network\Recipient\PackageRecipientDiscovery'); // CFG: SOCKET-DISCOVERY-CLASS -$cfg->setConfigEntry('socket_discovery_class', 'PackageSocketDiscovery'); +$cfg->setConfigEntry('socket_discovery_class', 'Hub\Network\Discovery\Socket\PackageSocketDiscovery'); // CFG: DHT-RECIPIENT-DISCOVERY-CLASS $cfg->setConfigEntry('dht_recipient_discovery_class', 'Hub\Discovery\Recipient\Dht\DhtRecipientDiscovery'); @@ -733,7 +733,7 @@ $cfg->setConfigEntry('dht_recipient_discovery_class', 'Hub\Discovery\Recipient\D $cfg->setConfigEntry('unl_discovery_class', 'Hub\Discovery\Locator\UniversalNodeLocatorDiscovery'); // CFG: TCP-PROTOCOL-HANDLER-CLASS -$cfg->setConfigEntry('tcp_protocol_handler_class', 'TcpProtocolHandler'); +$cfg->setConfigEntry('tcp_protocol_handler_class', 'Hub\Handler\Protocol\Network\IpV4\Tcp\TcpProtocolHandler'); // CFG: UNIVERSAL-NODE-LOCATOR-CLASS $cfg->setConfigEntry('universal_node_locator_class', 'Hub\Locator\Node\UniversalNodeLocator'); diff --git a/application/hub/interfaces/helper/node/class_HelpableNode.php b/application/hub/interfaces/helper/node/class_HelpableNode.php index 5ff2a0a49..9991399d6 100644 --- a/application/hub/interfaces/helper/node/class_HelpableNode.php +++ b/application/hub/interfaces/helper/node/class_HelpableNode.php @@ -1,6 +1,6 @@ . */ interface Tagable extends HubInterface { + // Constants for tags + const TAG_SELF_CONNECT = 'self_connect'; + const TAG_CLAIM_MINING_REWARD = 'claim_reward'; + /** * Chooses the right protocol from given package data * -- 2.39.5