From 4550bf73a3d276e7f63a767b3800f176ba99368c Mon Sep 17 00:00:00 2001 From: Jonathan Naylor Date: Wed, 19 Sep 2018 21:36:55 +0100 Subject: [PATCH] Remove the xreflector callsign server. --- Common/CallsignServer.cpp | 173 -------------------------- Common/CallsignServer.h | 54 -------- Common/Common.vcxproj | 2 - Common/Common.vcxproj.filters | 6 - Common/Makefile | 2 +- ircDDBGateway/IRCDDBGatewayThread.cpp | 10 -- 6 files changed, 1 insertion(+), 246 deletions(-) delete mode 100644 Common/CallsignServer.cpp delete mode 100644 Common/CallsignServer.h diff --git a/Common/CallsignServer.cpp b/Common/CallsignServer.cpp deleted file mode 100644 index 94e59d7..0000000 --- a/Common/CallsignServer.cpp +++ /dev/null @@ -1,173 +0,0 @@ -/* - * Copyright (C) 2012,2013,2014 by Jonathan Naylor G4KLX - * - * 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., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#include "TCPReaderWriterClient.h" -#include "CallsignServer.h" -#include "DStarDefines.h" -#include "Utils.h" -#include "Defs.h" - -const wxString CALLSERVER_HOSTNAME = wxT("dns.xreflector.net"); -const unsigned int CALLSERVER_PORT = 20001U; - -const unsigned int TCP_TIMEOUT = 10U; - -CCallsignServer::CCallsignServer(const wxString& callsign, const wxString& address, CCacheManager* cache) : -wxThread(wxTHREAD_JOINABLE), -m_callsign(callsign), -m_address(address), -m_cache(cache), -m_timer(1U, 1U * 3600U), // 1 hour -m_killed(false) -{ - wxASSERT(!callsign.IsEmpty()); - wxASSERT(cache != NULL); -} - -CCallsignServer::~CCallsignServer() -{ -} - -void CCallsignServer::start() -{ - process(CALLSERVER_HOSTNAME, CALLSERVER_PORT); - - Create(); - Run(); -} - -void* CCallsignServer::Entry() -{ - wxLogMessage(wxT("Starting the Callsign Server thread")); - - m_timer.start(); - - try { - while (!m_killed) { - if (m_timer.hasExpired()) { - process(CALLSERVER_HOSTNAME, CALLSERVER_PORT); - m_timer.start(); - } - - Sleep(1000UL); - - m_timer.clock(); - } - } - catch (std::exception& e) { - wxString message(e.what(), wxConvLocal); - wxLogError(wxT("Exception raised in the Callsign Server thread - \"%s\""), message.c_str()); - } - catch (...) { - wxLogError(wxT("Unknown exception raised in the Callsign Server thread")); - } - - wxLogMessage(wxT("Stopping the Callsign Server thread")); - - return NULL; -} - -void CCallsignServer::stop() -{ - m_killed = true; - - Wait(); -} - -void CCallsignServer::process(const wxString& hostname, unsigned int port) -{ - CTCPReaderWriterClient socket(hostname, port, m_address); - - bool ret = socket.open(); - if (!ret) { - wxLogMessage(wxT("Cannot connect to %s"), hostname.c_str()); - return; - } - - // Space for 5000 entries - unsigned int length = 5000U * (6U + 1U + 15U + 1U); - - unsigned char* buffer = new unsigned char[length + 1U]; - ::memset(buffer, ' ', 29U); - - for (unsigned int i = 0U; i < m_callsign.Len() && i < LONG_CALLSIGN_LENGTH - 1U; i++) - buffer[i + 0U] = m_callsign.GetChar(i); - - ::memcpy(buffer + 9U, "ircDDB Gateway", 14U); - - socket.write(buffer, 29U); - - unsigned int offset = 0U; - - int n = socket.read(buffer, length, TCP_TIMEOUT); - if (n >= 0) - offset += n; - - while (n >= 0 && offset < length) { - n = socket.read(buffer + offset, length - offset, TCP_TIMEOUT); - if (n == 0) - Sleep(TCP_TIMEOUT * 1000UL); - else if (n > 0) - offset += n; - } - - buffer[offset] = 0x00U; - - unsigned int count = 0U; - - char* p = (char*)buffer; - - for (;;) { - // Split into lines - char* p1 = ::strchr(p, 0x0A); - if (p1 != NULL) - *p1 = 0x00; - - if (::strncmp(p, "DCS", 3U) == 0) { - char* p2 = ::strtok(p, " \t\r\n"); - char* p3 = ::strtok(NULL, " \t\r\n"); - - if (p2 != NULL && p3 != NULL) { - wxString name = wxString(p2, wxConvLocal); - wxString address = wxString(p3, wxConvLocal); - - if (!address.IsSameAs(wxT("0.0.0.0"))) { - wxLogMessage(wxT("DCS: %s\t%s"), name.c_str(), address.c_str()); - - name.resize(LONG_CALLSIGN_LENGTH - 1U, wxT(' ')); - name.Append(wxT("G")); - m_cache->updateGateway(name, address, DP_DCS, false, true); - - count++; - } - } - } - - if (p1 == NULL) - break; - - p = p1 + 1U; - } - - wxLogMessage(wxT("Registered with %s using callsign %s"), hostname.c_str(), m_callsign.Left(LONG_CALLSIGN_LENGTH - 1U).c_str()); - - wxLogMessage(wxT("Loaded %u DCS reflectors from %s"), count, hostname.c_str()); - - delete[] buffer; - socket.close(); -} diff --git a/Common/CallsignServer.h b/Common/CallsignServer.h deleted file mode 100644 index 1238a44..0000000 --- a/Common/CallsignServer.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (C) 2012,2014 by Jonathan Naylor G4KLX - * - * 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., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#ifndef CallsignServer_H -#define CallsignServer_H - -#include "CacheManager.h" -#include "Timer.h" - -#include - -#if defined(__WINDOWS__) -#include "Inaddr.h" -#else -#include -#endif - -class CCallsignServer : public wxThread { -public: - CCallsignServer(const wxString& callsign, const wxString& address, CCacheManager* cache); - virtual ~CCallsignServer(); - - virtual void start(); - - virtual void* Entry(); - - virtual void stop(); - -private: - wxString m_callsign; - wxString m_address; - CCacheManager* m_cache; - CTimer m_timer; - bool m_killed; - - void process(const wxString& hostname, unsigned int port); -}; - -#endif diff --git a/Common/Common.vcxproj b/Common/Common.vcxproj index 10fcc19..385be90 100644 --- a/Common/Common.vcxproj +++ b/Common/Common.vcxproj @@ -154,7 +154,6 @@ - @@ -219,7 +218,6 @@ - diff --git a/Common/Common.vcxproj.filters b/Common/Common.vcxproj.filters index a42af77..6163926 100644 --- a/Common/Common.vcxproj.filters +++ b/Common/Common.vcxproj.filters @@ -35,9 +35,6 @@ Source Files - - Source Files - Source Files @@ -226,9 +223,6 @@ Header Files - - Header Files - Header Files diff --git a/Common/Makefile b/Common/Makefile index 9e569ad..d8549e7 100644 --- a/Common/Makefile +++ b/Common/Makefile @@ -1,5 +1,5 @@ OBJECTS = AMBEData.o AnnouncementUnit.o APRSCollector.o APRSWriter.o APRSWriterThread.o AudioUnit.o CacheManager.o CallsignList.o \ - CallsignServer.o CCITTChecksum.o ConnectData.o DCSHandler.o DCSProtocolHandler.o \ + CCITTChecksum.o ConnectData.o DCSHandler.o DCSProtocolHandler.o \ DCSProtocolHandlerPool.o DDData.o DDHandler.o DExtraHandler.o DExtraProtocolHandler.o DExtraProtocolHandlerPool.o \ DPlusAuthenticator.o DPlusHandler.o DPlusProtocolHandler.o DPlusProtocolHandlerPool.o DRATSServer.o DTMF.o \ DummyRepeaterProtocolHandler.o DVTOOLFileReader.o EchoUnit.o G2Handler.o G2ProtocolHandler.o GatewayCache.o \ diff --git a/ircDDBGateway/IRCDDBGatewayThread.cpp b/ircDDBGateway/IRCDDBGatewayThread.cpp index 7f6eaf3..b3f0c81 100644 --- a/ircDDBGateway/IRCDDBGatewayThread.cpp +++ b/ircDDBGateway/IRCDDBGatewayThread.cpp @@ -20,7 +20,6 @@ #include "IRCDDBGatewayDefs.h" #include "RepeaterHandler.h" #include "StarNetHandler.h" -#include "CallsignServer.h" #include "DExtraHandler.h" #include "DPlusHandler.h" #include "HeaderLogger.h" @@ -320,12 +319,6 @@ void CIRCDDBGatewayThread::run() m_statusFileTimer.start(); - CCallsignServer* server = NULL; - if (m_dextraEnabled || m_dcsEnabled) { - server = new CCallsignServer(m_gatewayCallsign, m_gatewayAddress, &m_cache); - server->start(); - } - wxStopWatch stopWatch; stopWatch.Start(); @@ -413,9 +406,6 @@ void CIRCDDBGatewayThread::run() if (m_ddModeEnabled) CDDHandler::finalise(); - if (server != NULL) - server->stop(); - m_dextraPool->close(); delete m_dextraPool;