From: Maxim Mamontov Date: Wed, 22 Jul 2015 17:57:41 +0000 (+0300) Subject: Removed some old experimental things. X-Git-Url: https://git.stg.codes/stg.git/commitdiff_plain/0b28a6a3f534a52b7e6734bc3a41058b3987aa10 Removed some old experimental things. --- diff --git a/stglibs/sgcp.lib/crypto.cpp b/stglibs/sgcp.lib/crypto.cpp deleted file mode 100644 index 2b2bb8f3..00000000 --- a/stglibs/sgcp.lib/crypto.cpp +++ /dev/null @@ -1,30 +0,0 @@ -#include "crypto.h" - -using STG::SGCP::CryptoProto; - -CryptoProto::CryptoProto(const std::string& key, TransportProto* underlying) - : m_underlying(underlying) -{ -} - -CryptoProto::~CryptoProto() -{ - delete m_underlying; -} - -void CryptoProto::connect(const std::string& address, uint16_t port) -{ - m_underlying->connect(address, port); -} - -ssize_t CryptoProto::write(const void* buf, size_t size) -{ - // TODO: to implement - return m_underlying->write(buf, size); -} - -ssize_t CryptoProto::read(void* buf, size_t size) -{ - // TODO: to implement - return m_underlying->read(buf, size); -} diff --git a/stglibs/sgcp.lib/crypto.h b/stglibs/sgcp.lib/crypto.h deleted file mode 100644 index 5f720d04..00000000 --- a/stglibs/sgcp.lib/crypto.h +++ /dev/null @@ -1,54 +0,0 @@ -#ifndef __STG_SGCP_CRYPTO_H__ -#define __STG_SGCP_CRYPTO_H__ - -/* - * 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 2 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, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* - * Author : Maxim Mamontov - */ - -#include "stg/sgcp_transport.h" - -#include "stg/os_int.h" - -#include - -#include // ssize_t - -namespace STG -{ -namespace SGCP -{ - -class CryptoProto : public TransportProto -{ - public: - CryptoProto(const std::string& key, TransportProto* underlying); - virtual ~CryptoProto(); - - virtual void connect(const std::string& address, uint16_t port); - virtual ssize_t write(const void* buf, size_t size); - virtual ssize_t read(void* buf, size_t size); - - private: - TransportProto* m_underlying; -}; - -} // namespace SGCP -} // namespace STG - -#endif diff --git a/stglibs/sgcp.lib/udp.cpp b/stglibs/sgcp.lib/udp.cpp deleted file mode 100644 index ebbb98e6..00000000 --- a/stglibs/sgcp.lib/udp.cpp +++ /dev/null @@ -1,52 +0,0 @@ -#include "udp.h" - -#include "stg/sgcp_utils.h" - -#include -#include - -#include -#include -#include -#include - -using STG::SGCP::UDPProto; - -UDPProto::UDPProto() - : m_sock(socket(AF_INET, SOCK_DGRAM, 0)) -{ -} - -UDPProto::~UDPProto() -{ - close(m_sock); -} - -void UDPProto::connect(const std::string& address, uint16_t port) -{ - std::vector addrs = resolve(address); - - for (size_t i = 0; i < addrs.size(); ++i) { - sockaddr_in addr; - addr.sin_family = AF_INET; - addr.sin_port = hton(port); - addr.sin_addr = addrs[i]; - - if (::connect(m_sock, reinterpret_cast(&addr), sizeof(addr)) == 0) - return; - - close(m_sock); - m_sock = socket(AF_INET, SOCK_DGRAM, 0); - } - throw Error("No more addresses to connect to."); -} - -ssize_t UDPProto::write(const void* buf, size_t size) -{ - return ::write(m_sock, buf, size); -} - -ssize_t UDPProto::read(void* buf, size_t size) -{ - return ::read(m_sock, buf, size); -} diff --git a/stglibs/sgcp.lib/udp.h b/stglibs/sgcp.lib/udp.h deleted file mode 100644 index b08978b4..00000000 --- a/stglibs/sgcp.lib/udp.h +++ /dev/null @@ -1,54 +0,0 @@ -#ifndef __STG_SGCP_UDP_H__ -#define __STG_SGCP_UDP_H__ - -/* - * 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 2 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, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* - * Author : Maxim Mamontov - */ - -#include "stg/sgcp_transport.h" - -#include "stg/os_int.h" - -#include - -#include // ssize_t - -namespace STG -{ -namespace SGCP -{ - -class UDPProto : public TransportProto -{ - public: - UDPProto(); - virtual ~UDPProto(); - - virtual void connect(const std::string& address, uint16_t port); - virtual ssize_t write(const void* buf, size_t size); - virtual ssize_t read(void* buf, size_t size); - - private: - int m_sock; -}; - -} // namespace SGCP -} // namespace STG - -#endif diff --git a/stglibs/sgcp.lib/utils.cpp b/stglibs/sgcp.lib/utils.cpp deleted file mode 100644 index 4c33e42f..00000000 --- a/stglibs/sgcp.lib/utils.cpp +++ /dev/null @@ -1,30 +0,0 @@ -#include "stg/sgcp_utils.h" - -#include -#include -#include - -std::vector STG::SGCP::resolve(const std::string& address) -{ - addrinfo* result = NULL; - - addrinfo hints; - memset(&hints, 0, sizeof(hints)); - - hints.ai_family = AF_INET; /* Allow IPv4 */ - hints.ai_socktype = 0; /* Datagram socket */ - hints.ai_flags = 0; /* For wildcard IP address */ - hints.ai_protocol = 0; /* Any protocol */ - hints.ai_canonname = NULL; - hints.ai_addr = NULL; - hints.ai_next = NULL; - - int res = getaddrinfo(address.c_str(), NULL, &hints, &result); - if (res != 0) - throw TransportProto::Error(gai_error(res)); - - std::vector as; - for (const addrinfo* p = result; p != NULL; p = p->next) - as.push_back(p->ai_addr.sin_addr); - return as; -}