diff --git a/Common/DCSHandler.cpp b/Common/DCSHandler.cpp index d0ad548..601cb69 100644 --- a/Common/DCSHandler.cpp +++ b/Common/DCSHandler.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2012,2013,2015 by Jonathan Naylor G4KLX + * Copyright (C) 2012,2013,2015,2026 by Jonathan Naylor G4KLX * Copyright (C) 2021 by Geoffrey Merck F4FXL / KC3FRA * * This program is free software; you can redistribute it and/or modify @@ -34,8 +34,6 @@ bool CDCSHandler::m_stateChange = false; GATEWAY_TYPE CDCSHandler::m_gatewayType = GT_REPEATER; -CHeaderLogger* CDCSHandler::m_headerLogger = NULL; - CCallsignList* CDCSHandler::m_whiteList = NULL; CCallsignList* CDCSHandler::m_blackList = NULL; @@ -123,11 +121,6 @@ void CDCSHandler::setDCSProtocolIncoming(CDCSProtocolHandler* handler) m_incoming = handler; } -void CDCSHandler::setHeaderLogger(CHeaderLogger* logger) -{ - m_headerLogger = logger; -} - void CDCSHandler::setGatewayType(GATEWAY_TYPE type) { m_gatewayType = type; @@ -542,10 +535,6 @@ void CDCSHandler::processInt(CAMBEData& data) return; if (m_dcsId == 0x00U) { // && seqNo == 0U) { - // Write to Header.log if it's enabled - if (m_headerLogger != NULL) - m_headerLogger->write("DCS", header); - m_dcsId = id; m_dcsSeq = 0x00U; m_inactivityTimer.start(); @@ -588,10 +577,6 @@ void CDCSHandler::processInt(CAMBEData& data) return; if (m_dcsId == 0x00U) { // && seqNo == 0U) { - // Write to Header.log if it's enabled - if (m_headerLogger != NULL) - m_headerLogger->write("DCS", header); - m_dcsId = id; m_dcsSeq = 0x00U; m_inactivityTimer.start(); @@ -841,38 +826,6 @@ bool CDCSHandler::stateChange() return stateChange; } -void CDCSHandler::writeStatus(std::ofstream& file) -{ - for (unsigned int i = 0U; i < m_maxReflectors; i++) { - CDCSHandler* reflector = m_reflectors[i]; - if (reflector != NULL) { - struct tm* tm = ::gmtime(&reflector->m_time); - - switch (reflector->m_direction) { - case DIR_OUTGOING: - if (reflector->m_linkState == DCS_LINKED) { - std::string text; - text = CStringUtils::string_format("%04d-%02d-%02d %02d:%02d:%02d: DCS link - Type: Repeater Rptr: %s Refl: %s Dir: Outgoing\n", - tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec, - reflector->m_repeater.c_str(), GET_DISP_REFLECTOR(reflector).c_str()); - file << text; - } - break; - - case DIR_INCOMING: - if (reflector->m_linkState == DCS_LINKED) { - std::string text; - text = CStringUtils::string_format("%04d-%02d-%02d %02d:%02d:%02d: DCS link - Type: Repeater Rptr: %s Refl: %s Dir: Incoming\n", - tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec, - reflector->m_repeater.c_str(), GET_DISP_REFLECTOR(reflector).c_str()); - file << text; - } - break; - } - } - } -} - unsigned int CDCSHandler::calcBackoff() { if (m_tryCount >= 7U) { diff --git a/Common/DCSHandler.h b/Common/DCSHandler.h index bb50f5e..a542977 100644 --- a/Common/DCSHandler.h +++ b/Common/DCSHandler.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2012,2013,2015 by Jonathan Naylor G4KLX + * Copyright (C) 2012,2013,2015,2026 by Jonathan Naylor G4KLX * Copyright (C) 2021 by Geoffrey Merck F4FXL / KC3FRA * * This program is free software; you can redistribute it and/or modify @@ -28,7 +28,6 @@ #include "DCSProtocolHandlerPool.h" #include "ReflectorCallback.h" #include "DStarDefines.h" -#include "HeaderLogger.h" #include "CallsignList.h" #include "ConnectData.h" #include "AMBEData.h" @@ -50,7 +49,6 @@ public: static void setDCSProtocolHandlerPool(CDCSProtocolHandlerPool* pool); static void setDCSProtocolIncoming(CDCSProtocolHandler* handler); - static void setHeaderLogger(CHeaderLogger* logger); static void setGatewayType(GATEWAY_TYPE type); static void link(IReflectorCallback* handler, const std::string& repeater, const std::string& reflector, const in_addr& address); @@ -68,7 +66,6 @@ public: static void clock(unsigned int ms); static bool stateChange(); - static void writeStatus(std::ofstream& file); static void setWhiteList(CCallsignList* list); static void setBlackList(CCallsignList* list); @@ -102,8 +99,6 @@ private: static GATEWAY_TYPE m_gatewayType; - static CHeaderLogger* m_headerLogger; - static CCallsignList* m_whiteList; static CCallsignList* m_blackList; diff --git a/Common/DDHandler.cpp b/Common/DDHandler.cpp index 047a1da..bacc409 100644 --- a/Common/DDHandler.cpp +++ b/Common/DDHandler.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2011,2012,2013,2018 by Jonathan Naylor G4KLX + * Copyright (C) 2011,2012,2013,2018,2026 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 @@ -51,7 +51,6 @@ const unsigned char TOALL_MULTICAST_ADDRESS[] = {0x01U, 0x00U, 0x5EU, 0x00U, 0x0 const unsigned char DX_MULTICAST_ADDRESS[] = {0x01U, 0x00U, 0x5EU, 0x00U, 0x00U, 0x23U}; CIRCDDB* CDDHandler::m_irc = NULL; -CHeaderLogger* CDDHandler::m_headerLogger = NULL; int CDDHandler::m_fd = -1; unsigned int CDDHandler::m_maxRoutes = 0U; CEthernet** CDDHandler::m_list = NULL; @@ -160,11 +159,6 @@ void CDDHandler::setLogging(bool enabled, const std::string& dir) m_logEnabled = enabled; } -void CDDHandler::setHeaderLogger(CHeaderLogger* logger) -{ - m_headerLogger = logger; -} - void CDDHandler::setIRC(CIRCDDB* irc) { assert(irc != NULL); @@ -188,10 +182,6 @@ void CDDHandler::process(CDDData& data) std::string rptCall2 = data.getRptCall2(); if (!m_timer.isRunning() || m_timer.hasExpired()) { - // Write to Header.log if it's enabled - if (m_headerLogger != NULL) - m_headerLogger->write("Repeater", data); - if (m_irc != NULL) { m_irc->sendHeardWithTXMsg(myCall1, myCall2, yourCall, rptCall1, rptCall2, flag1, flag2, flag3, "", "Digital Data "); m_irc->sendHeardWithTXStats(myCall1, myCall2, yourCall, rptCall1, rptCall2, flag1, flag2, flag3, 1, 0, -1); @@ -229,8 +219,6 @@ void CDDHandler::process(CDDData& data) if (m_list[i] == NULL) { m_list[i] = ethernet; found = true; - if (m_logEnabled) - writeStatus(*ethernet); break; } } @@ -363,35 +351,3 @@ void CDDHandler::finalise() delete[] m_list; } -void CDDHandler::writeStatus(const CEthernet& ethernet) -{ - std::string fullName = DDMODE_BASE_NAME; - - if (!m_name.empty()) { - fullName += "_"; - fullName += m_name; - } - - fullName = m_logDir + "/" + fullName + ".log"; - - std::ofstream file; - file.open(fullName, std::ios::app); - if (!file.is_open()) { - CLog::logError("Unable to open %s for writing", fullName.c_str()); - return; - } - - std::string callsign = ethernet.getCallsign(); - unsigned char* address = ethernet.getAddress(); - - time_t timeNow = ::time(NULL); - struct tm* tm = ::gmtime(&timeNow); - - std::string text = CStringUtils::string_format("%04d-%02d-%02d %02d:%02d:%02d: %02X:%02X:%02X:%02X:%02X:%02X %s\n", - tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec, - address[0], address[1], address[2], address[3], address[4], address[5], callsign.c_str()); - - file << text; - - file.close(); -} diff --git a/Common/DDHandler.h b/Common/DDHandler.h index 602e453..2111b0d 100644 --- a/Common/DDHandler.h +++ b/Common/DDHandler.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2011,2012 by Jonathan Naylor G4KLX + * Copyright (C) 2011,2012,2026 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 @@ -19,7 +19,6 @@ #ifndef DDHandler_H #define DDHandler_H -#include "HeaderLogger.h" #include "DDData.h" #include "IRCDDB.h" #include "Timer.h" @@ -43,7 +42,6 @@ public: static void initialise(unsigned int maxRoutes, const std::string& name); static void setLogging(bool enabled, const std::string& dir); - static void setHeaderLogger(CHeaderLogger* logger); static void setIRC(CIRCDDB* irc); static void process(CDDData& data); @@ -56,7 +54,6 @@ public: private: static CIRCDDB* m_irc; - static CHeaderLogger* m_headerLogger; static int m_fd; static unsigned int m_maxRoutes; static CEthernet** m_list; @@ -65,8 +62,6 @@ private: static std::string m_logDir; static std::string m_name; static CTimer m_timer; - - static void writeStatus(const CEthernet& ethernet); }; #endif diff --git a/Common/DExtraHandler.cpp b/Common/DExtraHandler.cpp index 0268b19..9d1d043 100644 --- a/Common/DExtraHandler.cpp +++ b/Common/DExtraHandler.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010-2015 by Jonathan Naylor G4KLX + * Copyright (C) 2010-2015,2026 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 @@ -33,8 +33,6 @@ CDExtraProtocolHandler* CDExtraHandler::m_incoming = NULL; bool CDExtraHandler::m_stateChange = false; -CHeaderLogger* CDExtraHandler::m_headerLogger = NULL; - CCallsignList* CDExtraHandler::m_whiteList = NULL; CCallsignList* CDExtraHandler::m_blackList = NULL; @@ -152,11 +150,6 @@ void CDExtraHandler::setDExtraProtocolHandlerPool(CDExtraProtocolHandlerPool* po m_pool = pool; } -void CDExtraHandler::setHeaderLogger(CHeaderLogger* logger) -{ - m_headerLogger = logger; -} - void CDExtraHandler::setMaxDongles(unsigned int maxDongles) { m_maxDongles = maxDongles; @@ -620,10 +613,6 @@ void CDExtraHandler::processInt(CHeaderData& header) if (m_dExtraId != 0x00U) return; - // Write to Header.log if it's enabled - if (m_headerLogger != NULL) - m_headerLogger->write("DExtra", header); - m_dExtraId = id; m_dExtraSeq = 0x00U; m_inactivityTimer.start(); @@ -648,10 +637,6 @@ void CDExtraHandler::processInt(CHeaderData& header) if (m_dExtraId != 0x00U) return; - // Write to Header.log if it's enabled - if (m_headerLogger != NULL) - m_headerLogger->write("DExtra", header); - m_dExtraId = id; m_dExtraSeq = 0x00U; m_inactivityTimer.start(); @@ -677,10 +662,6 @@ void CDExtraHandler::processInt(CHeaderData& header) if (m_dExtraId != 0x00U) return; - // Write to Header.log if it's enabled - if (m_headerLogger != NULL) - m_headerLogger->write("DExtra", header); - m_dExtraId = id; m_dExtraSeq = 0x00U; m_inactivityTimer.start(); @@ -947,46 +928,6 @@ bool CDExtraHandler::stateChange() return stateChange; } -void CDExtraHandler::writeStatus(std::ofstream& file) -{ - for (unsigned int i = 0U; i < m_maxReflectors; i++) { - CDExtraHandler* reflector = m_reflectors[i]; - if (reflector != NULL) { - std::string text; - - struct tm* tm = ::gmtime(&reflector->m_time); - - switch (reflector->m_direction) { - case DIR_OUTGOING: - if (reflector->m_linkState == DEXTRA_LINKED) { - text = CStringUtils::string_format("%04d-%02d-%02d %02d:%02d:%02d: DExtra link - Type: Repeater Rptr: %s Refl: %s Dir: Outgoing\n", - tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec, - reflector->m_repeater.c_str(), reflector->m_reflector.c_str()); - - file << text; - } - break; - - case DIR_INCOMING: - if (reflector->m_linkState == DEXTRA_LINKED) { - if (reflector->m_repeater.empty()) - text = CStringUtils::string_format("%04d-%02d-%02d %02d:%02d:%02d: DExtra link - Type: Dongle User: %s Dir: Incoming\n", - tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec, - reflector->m_reflector.c_str()); - else - text = CStringUtils::string_format("%04d-%02d-%02d %02d:%02d:%02d: DExtra link - Type: Repeater Rptr: %s Refl: %s Dir: Incoming\n", - tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec, - reflector->m_repeater.c_str(), reflector->m_reflector.c_str()); - - file << text; - } - break; - } - - } - } -} - unsigned int CDExtraHandler::calcBackoff() { if (m_tryCount >= 7U) { diff --git a/Common/DExtraHandler.h b/Common/DExtraHandler.h index 0ac616f..69ea1d2 100644 --- a/Common/DExtraHandler.h +++ b/Common/DExtraHandler.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010-2013,2015 by Jonathan Naylor G4KLX + * Copyright (C) 2010-2013,2015,2026 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 @@ -27,7 +27,6 @@ #include "DExtraProtocolHandlerPool.h" #include "ReflectorCallback.h" #include "DStarDefines.h" -#include "HeaderLogger.h" #include "CallsignList.h" #include "ConnectData.h" #include "HeaderData.h" @@ -49,7 +48,6 @@ public: static void setCallsign(const std::string& callsign); static void setDExtraProtocolHandlerPool(CDExtraProtocolHandlerPool* pool); static void setDExtraProtocolIncoming(CDExtraProtocolHandler* handler); - static void setHeaderLogger(CHeaderLogger* logger); static void setMaxDongles(unsigned int maxDongles); static void link(IReflectorCallback* handler, const std::string& repeater, const std::string& reflector, const in_addr& address, unsigned int& localPort); @@ -68,7 +66,6 @@ public: static void clock(unsigned int ms); static bool stateChange(); - static void writeStatus(std::ofstream& file); static void setWhiteList(CCallsignList* list); static void setBlackList(CCallsignList* list); @@ -105,8 +102,6 @@ private: static bool m_stateChange; - static CHeaderLogger* m_headerLogger; - static CCallsignList* m_whiteList; static CCallsignList* m_blackList; diff --git a/Common/DPlusHandler.cpp b/Common/DPlusHandler.cpp index 178eefd..2722fa6 100644 --- a/Common/DPlusHandler.cpp +++ b/Common/DPlusHandler.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2012,2013,2015 by Jonathan Naylor G4KLX + * Copyright (C) 2012,2013,2015,2026 by Jonathan Naylor G4KLX * Copyright (c) 2021 by Geoffrey Merck F4FXL / KC3FRA * * This program is free software; you can redistribute it and/or modify @@ -39,7 +39,6 @@ CDPlusProtocolHandler* CDPlusHandler::m_incoming = NULL; bool CDPlusHandler::m_stateChange = false; CDPlusAuthenticator* CDPlusHandler::m_authenticator = NULL; -CHeaderLogger* CDPlusHandler::m_headerLogger = NULL; CCallsignList* CDPlusHandler::m_whiteList = NULL; CCallsignList* CDPlusHandler::m_blackList = NULL; @@ -165,11 +164,6 @@ void CDPlusHandler::setDPlusLogin(const std::string& dplusLogin) m_dplusLogin = dplusLogin; } -void CDPlusHandler::setHeaderLogger(CHeaderLogger* logger) -{ - m_headerLogger = logger; -} - void CDPlusHandler::setMaxDongles(unsigned int maxDongles) { m_maxDongles = maxDongles; @@ -597,10 +591,6 @@ void CDPlusHandler::processInt(CHeaderData& header) if (m_dPlusId != 0x00U) return; - // Write to Header.log if it's enabled - if (m_headerLogger != NULL) - m_headerLogger->write("DPlus", header); - m_dPlusId = id; m_dPlusSeq = 0x00U; m_inactivityTimer.start(); @@ -627,10 +617,6 @@ void CDPlusHandler::processInt(CHeaderData& header) if (m_dPlusId != 0x00U) return; - // Write to Header.log if it's enabled - if (m_headerLogger != NULL) - m_headerLogger->write(("DPlus"), header); - m_dPlusId = id; m_dPlusSeq = 0x00U; m_inactivityTimer.start(); @@ -911,36 +897,6 @@ bool CDPlusHandler::stateChange() return stateChange; } -void CDPlusHandler::writeStatus(std::ofstream& file) -{ - for (unsigned int i = 0U; i < m_maxReflectors; i++) { - CDPlusHandler* reflector = m_reflectors[i]; - if (reflector != NULL) { - std::string text; - - struct tm* tm = ::gmtime(&reflector->m_time); - - if (reflector->m_linkState == DPLUS_LINKED) { - switch (reflector->m_direction) { - case DIR_OUTGOING: - text = CStringUtils::string_format("%04d-%02d-%02d %02d:%02d:%02d: DPlus link - Type: Dongle Rptr: %s Refl: %s Dir: Outgoing\n", - tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec, - reflector->m_repeater.c_str(), reflector->m_reflector.c_str()); - break; - - case DIR_INCOMING: - text = CStringUtils::string_format("%04d-%02d-%02d %02d:%02d:%02d: DPlus link - Type: Dongle User: %s Dir: Incoming\n", - tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec, - reflector->m_reflector.c_str()); - break; - } - - file << text; - } - } - } -} - unsigned int CDPlusHandler::calcBackoff() { if (m_tryCount >= 7U) { diff --git a/Common/DPlusHandler.h b/Common/DPlusHandler.h index 78b5b7a..fa8c4a4 100644 --- a/Common/DPlusHandler.h +++ b/Common/DPlusHandler.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2012,2013,2015 by Jonathan Naylor G4KLX + * Copyright (C) 2012,2013,2015,2026 by Jonathan Naylor G4KLX * Copyright (c) 2021 by Geoffrey Merck F4FXL / KC3FRA * * This program is free software; you can redistribute it and/or modify @@ -29,7 +29,6 @@ #include "ReflectorCallback.h" #include "CacheManager.h" #include "DStarDefines.h" -#include "HeaderLogger.h" #include "CallsignList.h" #include "ConnectData.h" #include "HeaderData.h" @@ -53,7 +52,6 @@ public: static void setDPlusProtocolHandlerPool(CDPlusProtocolHandlerPool* pool); static void setDPlusProtocolIncoming(CDPlusProtocolHandler* handler); static void setDPlusLogin(const std::string& dplusLogin); - static void setHeaderLogger(CHeaderLogger* logger); static void setMaxDongles(unsigned int maxDongles); static void startAuthenticator(const std::string& address, CCacheManager* cache); @@ -75,7 +73,6 @@ public: static void clock(unsigned int ms); static bool stateChange(); - static void writeStatus(std::ofstream& file); static void setWhiteList(CCallsignList* list); static void setBlackList(CCallsignList* list); @@ -112,7 +109,6 @@ private: static bool m_stateChange; - static CHeaderLogger* m_headerLogger; static CDPlusAuthenticator* m_authenticator; static CCallsignList* m_whiteList; diff --git a/Common/Defs.h b/Common/Defs.h index 01edb0c..100cd37 100644 --- a/Common/Defs.h +++ b/Common/Defs.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010-2015 by Jonathan Naylor G4KLX + * Copyright (C) 2010-2015,2026 by Jonathan Naylor G4KLX * Copyright (c) 2017 by Thomas A. Early N7TAE * Copyright (c) 2021 by Geoffrey Merck F4FXL / KC3FRA * @@ -28,11 +28,7 @@ const std::string DPLUS_HOSTS_FILE_NAME("DPlus_Hosts.txt"); const std::string XLX_HOSTS_FILE_NAME("XLX_Hosts.txt"); const std::string GATEWAY_HOSTS_FILE_NAME("Gateway_Hosts.txt"); -const std::string LINKS_BASE_NAME("Links"); -const std::string TEXT_BASE_NAME("Text"); -const std::string USERS_BASE_NAME("Users"); const std::string STARNET_BASE_NAME("STARnet"); -const std::string HEADERS_BASE_NAME("Headers"); const std::string DDMODE_BASE_NAME("DDMode"); enum RECONNECT { diff --git a/Common/G2Handler.cpp b/Common/G2Handler.cpp index 1aaf362..f0b1d36 100644 --- a/Common/G2Handler.cpp +++ b/Common/G2Handler.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010,2012 by Jonathan Naylor G4KLX + * Copyright (C) 2010,2012,2026 by Jonathan Naylor G4KLX * copyright (c) 2021 by Geoffrey Merck F4FXL / KC3FRA * * This program is free software; you can redistribute it and/or modify @@ -33,8 +33,6 @@ CG2Handler** CG2Handler::m_routes = NULL; CG2ProtocolHandlerPool* CG2Handler::m_handler = NULL; -CHeaderLogger* CG2Handler::m_headerLogger = NULL; - CG2Handler::CG2Handler(CRepeaterHandler* repeater, const in_addr& address, unsigned int id) : m_repeater(repeater), m_address(address), @@ -67,11 +65,6 @@ void CG2Handler::setG2ProtocolHandlerPool(CG2ProtocolHandlerPool* handler) m_handler = handler; } -void CG2Handler::setHeaderLogger(CHeaderLogger* logger) -{ - m_headerLogger = logger; -} - void CG2Handler::process(CHeaderData& header) { // Is this a busy reply? @@ -86,10 +79,6 @@ void CG2Handler::process(CHeaderData& header) // Check to see if this is for StarNet CStarNetHandler* handler = CStarNetHandler::findStarNet(header); if (handler != NULL) { - // Write to Header.log if it's enabled - if (m_headerLogger != NULL) - m_headerLogger->write("StarNet", header); - handler->process(header); return; } @@ -115,10 +104,6 @@ void CG2Handler::process(CHeaderData& header) if (m_routes[i] == NULL) { m_routes[i] = route; - // Write to Header.log if it's enabled - if (m_headerLogger != NULL) - m_headerLogger->write("G2", header); - repeater->process(header, DIR_INCOMING, AS_G2); return; } diff --git a/Common/G2Handler.h b/Common/G2Handler.h index 89f3291..692aa2e 100644 --- a/Common/G2Handler.h +++ b/Common/G2Handler.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010,2012 by Jonathan Naylor G4KLX + * Copyright (C) 2010,2012,2026 by Jonathan Naylor G4KLX * copyright (c) 2021 by Geoffrey Merck F4FXL / KC3FRA * * This program is free software; you can redistribute it and/or modify @@ -25,7 +25,6 @@ #include "G2ProtocolHandlerPool.h" #include "RepeaterHandler.h" #include "DStarDefines.h" -#include "HeaderLogger.h" #include "HeaderData.h" #include "AMBEData.h" #include "Timer.h" @@ -35,7 +34,6 @@ public: static void initialise(unsigned int maxRoutes); static void setG2ProtocolHandlerPool(CG2ProtocolHandlerPool* handler); - static void setHeaderLogger(CHeaderLogger* logger); static void process(CHeaderData& header); static void process(CAMBEData& header); @@ -56,8 +54,6 @@ private: static CG2ProtocolHandlerPool* m_handler; - static CHeaderLogger* m_headerLogger; - CRepeaterHandler* m_repeater; in_addr m_address; unsigned int m_id; diff --git a/Common/HeaderLogger.cpp b/Common/HeaderLogger.cpp deleted file mode 100644 index 98bae8c..0000000 --- a/Common/HeaderLogger.cpp +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Copyright (C) 2010,2011,2012,2014 by Jonathan Naylor G4KLX - * Copyright (C) 2021 by Geoffrey Merck F4FXL / KC3FRA - * - * 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 - -#include "HeaderLogger.h" -#include "Defs.h" -#include "Log.h" -#include "StringUtils.h" - -#include -#include -#include - -CHeaderLogger::CHeaderLogger(const std::string& dir, const std::string& name) : -m_dir(dir), -m_name(name), -m_file() -{ -} - -CHeaderLogger::~CHeaderLogger() -{ -} - -bool CHeaderLogger::open() -{ - std::string fullName = HEADERS_BASE_NAME; - - if (!m_name.empty()) { - fullName += "_"; - fullName += m_name; - } - - fullName = m_dir + "/" + fullName + ".log"; - - m_file.open(fullName, std::ios::app); - if (!m_file.is_open()) { - CLog::logError("Cannot open %s file for appending", fullName.c_str()); - return false; - } - - return true; -} - -void CHeaderLogger::write(const std::string& type, const CHeaderData& header) -{ - assert(!type.empty()); - - time_t timeNow = ::time(NULL); - struct tm* tm = ::gmtime(&timeNow); - - char* t = ::inet_ntoa(header.getYourAddress()); - std::string address(t); - - std::string text = CStringUtils::string_format("%04d-%02d-%02d %02d:%02d:%02d: %s header - My: %s/%s Your: %s Rpt1: %s Rpt2: %s Flags: %02X %02X %02X (%s:%u)\n", - tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec, type.c_str(), - header.getMyCall1().c_str(), header.getMyCall2().c_str(), header.getYourCall().c_str(), - header.getRptCall1().c_str(), header.getRptCall2().c_str(), header.getFlag1(), header.getFlag2(), - header.getFlag3(), address.c_str(), header.getYourPort()); - - m_file << text; - m_file.flush(); -} - -void CHeaderLogger::write(const std::string& type, const CDDData& data) -{ - assert(!type.empty()); - - time_t timeNow = ::time(NULL); - struct tm* tm = ::gmtime(&timeNow); - - std::string text; - CStringUtils::string_format("%04d-%02d-%02d %02d:%02d:%02d: %s header - My: %s/%s Your: %s Rpt1: %s Rpt2: %s Flags: %02X %02X %02X\n", - tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec, type, - data.getMyCall1().c_str(), data.getMyCall2().c_str(), data.getYourCall().c_str(), - data.getRptCall1().c_str(), data.getRptCall2().c_str(), data.getFlag1(), data.getFlag2(), - data.getFlag3()); - - m_file << text; - m_file.flush(); -} - -void CHeaderLogger::close() -{ - m_file.close(); -} diff --git a/Common/HeaderLogger.h b/Common/HeaderLogger.h deleted file mode 100644 index 434b1b5..0000000 --- a/Common/HeaderLogger.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (C) 2010-2013 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 HeaderLogger_H -#define HeaderLogger_H - -#include -#include -#include - -#include "HeaderData.h" -#include "DDData.h" - -class CHeaderLogger { -public: - CHeaderLogger(const std::string& dir, const std::string& name = ""); - ~CHeaderLogger(); - - bool open(); - - void write(const std::string& type, const CHeaderData& header); - void write(const std::string& type, const CDDData& header); - - void close(); - -private: - std::string m_dir; - std::string m_name; - std::ofstream m_file; -}; - -#endif diff --git a/Common/RepeaterHandler.cpp b/Common/RepeaterHandler.cpp index b100cf1..bc973a5 100644 --- a/Common/RepeaterHandler.cpp +++ b/Common/RepeaterHandler.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010-2015,2018 by Jonathan Naylor G4KLX + * Copyright (C) 2010-2015,2018,2026 by Jonathan Naylor G4KLX * Copyright (c) 2021 by Geoffrey Merck F4FXL / KC3FRA * * This program is free software; you can redistribute it and/or modify @@ -57,8 +57,6 @@ bool CRepeaterHandler::m_infoEnabled = true; bool CRepeaterHandler::m_echoEnabled = true; bool CRepeaterHandler::m_dtmfEnabled = true; -CHeaderLogger* CRepeaterHandler::m_headerLogger = NULL; - CAPRSHandler* CRepeaterHandler::m_outgoingAprsHandler = NULL; //handles APRS/DPRS frames coming from radio to network CAPRSHandler* CRepeaterHandler::m_incomingAprsHandler = NULL; //handles APRS/DPRS frames coming from network to radio @@ -315,11 +313,6 @@ void CRepeaterHandler::setDTMFEnabled(bool enabled) m_dtmfEnabled = enabled; } -void CRepeaterHandler::setHeaderLogger(CHeaderLogger* logger) -{ - m_headerLogger = logger; -} - void CRepeaterHandler::setAPRSHandlers(CAPRSHandler* outgoingAprsHandler, CAPRSHandler* incomingAprsHandler) { m_outgoingAprsHandler = outgoingAprsHandler; @@ -585,10 +578,6 @@ void CRepeaterHandler::processRepeater(CHeaderData& header) if (m_outgoingAprsHandler != NULL) m_outgoingAprsHandler->writeHeader(m_rptCallsign, header); - // Write to Header.log if it's enabled - if (m_headerLogger != NULL) - m_headerLogger->write("Repeater", header); - // Reset the DTMF decoder m_dtmf.reset(); diff --git a/Common/RepeaterHandler.h b/Common/RepeaterHandler.h index 7587472..f825a21 100644 --- a/Common/RepeaterHandler.h +++ b/Common/RepeaterHandler.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010-2015,2018 by Jonathan Naylor G4KLX + * Copyright (C) 2010-2015,2018,2026 by Jonathan Naylor G4KLX * Copyright (c) 2021 by Geoffrey Merck F4FXL / KC3FRA * * This program is free software; you can redistribute it and/or modify @@ -33,7 +33,6 @@ #endif #include "TextCollector.h" #include "CacheManager.h" -#include "HeaderLogger.h" #include "CallsignList.h" #include "DRATSServer.h" #include "CCSCallback.h" @@ -73,7 +72,6 @@ public: static void setDExtraEnabled(bool enabled); static void setDPlusEnabled(bool enabled); static void setDCSEnabled(bool enabled); - static void setHeaderLogger(CHeaderLogger* logger); static void setAPRSHandlers(CAPRSHandler* outgoingAprsHandler, CAPRSHandler* incomingAprsHandler); static void setInfoEnabled(bool enabled); static void setEchoEnabled(bool enabled); @@ -167,8 +165,6 @@ private: static bool m_echoEnabled; static bool m_dtmfEnabled; - static CHeaderLogger* m_headerLogger; - static CAPRSHandler* m_outgoingAprsHandler; static CAPRSHandler* m_incomingAprsHandler; diff --git a/DStarGateway/DStarGatewayThread.cpp b/DStarGateway/DStarGatewayThread.cpp index 2ee47cd..062d3e1 100644 --- a/DStarGateway/DStarGatewayThread.cpp +++ b/DStarGateway/DStarGatewayThread.cpp @@ -34,7 +34,6 @@ #endif #include "DExtraHandler.h" #include "DPlusHandler.h" -#include "HeaderLogger.h" #include "ConnectData.h" #ifdef USE_CCS #include "CCSHandler.h" @@ -98,7 +97,6 @@ m_logEnabled(false), m_logIRCDDB(false), m_ddModeEnabled(false), m_lastStatus(IS_DISABLED), -m_statusTimer1(1000U, 1U), // 1 second m_statusTimer2(1000U, 1U), // 1 second m_remoteEnabled(false), m_remotePassword(), @@ -142,24 +140,6 @@ void* CDStarGatewayThread::Entry() // CHostsFilesManager::setDownloadCallback(CHostsFileDownloader::download); CHostsFilesManager::UpdateHosts(); - // Truncate the old Links.log file - std::string fullName = m_logDir + "/" + LINKS_BASE_NAME + ".log"; - if (!m_name.empty()) { - fullName += fullName + m_name; - } - CUtils::truncateFile(fullName); - CLog::logInfo("Truncating %s", fullName.c_str()); - -#ifdef USE_STARNET - // Truncate the old StarNet.log file - std::string fullName = m_logDir + "/" + STARNET_BASE_NAME + ".log"; - if (!m_name.empty()) { - fullName += fullName + m_name; - } - CUtils::truncateFile(fullName); - CLog::logInfo("Truncating %s", fullName.c_str()); -#endif - std::string dextraAddress = m_dextraEnabled ? m_gatewayAddress : LOOPBACK_ADDRESS; m_dextraPool = new CDExtraProtocolHandlerPool(DEXTRA_PORT, dextraAddress); // Allocate the incoming port @@ -211,34 +191,18 @@ void* CDStarGatewayThread::Entry() CLog::logInfo("Starting the ircDDB Gateway thread"); - CHeaderLogger* headerLogger = NULL; - if (m_logEnabled) { - m_statusTimer1.start(); - - headerLogger = new CHeaderLogger(m_logDir, m_name); - ret = headerLogger->open(); - if (!ret) { - delete headerLogger; - headerLogger = NULL; - } - } - CG2Handler::setG2ProtocolHandlerPool(m_g2HandlerPool); - CG2Handler::setHeaderLogger(headerLogger); CDExtraHandler::setCallsign(m_gatewayCallsign); - CDExtraHandler::setHeaderLogger(headerLogger); CDExtraHandler::setMaxDongles(m_dextraMaxDongles); CDPlusHandler::setCallsign(m_gatewayCallsign); CDPlusHandler::setDPlusLogin(m_dplusLogin); - CDPlusHandler::setHeaderLogger(headerLogger); CDPlusHandler::setMaxDongles(m_dplusMaxDongles); if (m_dplusEnabled) CDPlusHandler::startAuthenticator(m_gatewayAddress, &m_cache); CDCSHandler::setGatewayType(m_gatewayType); - CDCSHandler::setHeaderLogger(headerLogger); CRepeaterHandler::setLocalAddress(m_gatewayAddress); CRepeaterHandler::setG2HandlerPool(m_g2HandlerPool); @@ -252,7 +216,6 @@ void* CDStarGatewayThread::Entry() CRepeaterHandler::setDExtraEnabled(m_dextraEnabled); CRepeaterHandler::setDPlusEnabled(m_dplusEnabled); CRepeaterHandler::setDCSEnabled(m_dcsEnabled); - CRepeaterHandler::setHeaderLogger(headerLogger); CRepeaterHandler::setAPRSHandlers(m_outgoingAprsHandler, m_incomingAprsHandler); CRepeaterHandler::setInfoEnabled(m_infoEnabled); CRepeaterHandler::setEchoEnabled(m_echoEnabled); @@ -289,7 +252,6 @@ void* CDStarGatewayThread::Entry() if (m_ddModeEnabled) { CDDHandler::initialise(MAX_DD_ROUTES, m_name); CDDHandler::setLogging(m_logEnabled, m_logDir); - CDDHandler::setHeaderLogger(headerLogger); if (m_irc != NULL) CDDHandler::setIRC(m_irc); @@ -298,7 +260,6 @@ void* CDStarGatewayThread::Entry() #ifdef USE_CCS std::string ccsAddress = m_ccsEnabled ? m_gatewayAddress : LOOPBACK_ADDRESS; CCCSHandler::setLocalAddress(ccsAddress); - CCCSHandler::setHeaderLogger(headerLogger); CCCSHandler::setHost(m_ccsHost); #endif @@ -383,25 +344,6 @@ void* CDStarGatewayThread::Entry() if (m_outgoingAprsHandler != NULL) m_outgoingAprsHandler->clock(ms); - if (m_logEnabled) { - m_statusTimer1.clock(ms); - if (m_statusTimer1.hasExpired()) { - bool ret1 = CDExtraHandler::stateChange(); - bool ret2 = CDPlusHandler::stateChange(); - bool ret3 = CDCSHandler::stateChange(); -#ifdef USE_CCS - bool ret4 = CCCSHandler::stateChange(); - if (ret1 || ret2 || ret3 || ret4) - writeStatus(); -#else - if (ret1 || ret2 || ret3) - writeStatus(); -#endif - - m_statusTimer1.start(); - } - } - ::std::this_thread::sleep_for(std::chrono::milliseconds(TIME_PER_TIC_MS)); } #ifndef DEBUG_DSTARGW @@ -477,11 +419,6 @@ void* CDStarGatewayThread::Entry() delete m_outgoingAprsHandler; } - if (headerLogger != NULL) { - headerLogger->close(); - delete headerLogger; - } - CHeaderData::finalise(); CG2Handler::finalise(); CDExtraHandler::finalise(); @@ -1150,33 +1087,6 @@ void CDStarGatewayThread::processDD() } } -void CDStarGatewayThread::writeStatus() -{ - std::string fullName = LINKS_BASE_NAME; - - if (!m_name.empty()) { - fullName += "_" + m_name; - } - - fullName = m_logDir + "/" + LINKS_BASE_NAME + ".log"; - - std::ofstream file; - file.open(fullName, std::fstream::trunc); - if (!file.is_open()) { - CLog::logError("Unable to open %s for writing", fullName.c_str()); - return; - } - - CDExtraHandler::writeStatus(file); - CDPlusHandler::writeStatus(file); - CDCSHandler::writeStatus(file); -#ifdef USE_CCS - CCCSHandler::writeStatus(file); -#endif - - file.close(); -} - CDStarGatewayStatusData* CDStarGatewayThread::getStatus() const { bool aprsStatus = false; diff --git a/DStarGateway/DStarGatewayThread.h b/DStarGateway/DStarGatewayThread.h index 9fc1f02..87d99af 100644 --- a/DStarGateway/DStarGatewayThread.h +++ b/DStarGateway/DStarGatewayThread.h @@ -121,7 +121,6 @@ private: bool m_logIRCDDB; bool m_ddModeEnabled; IRCDDB_STATUS m_lastStatus; - CTimer m_statusTimer1; CTimer m_statusTimer2; bool m_remoteEnabled; std::string m_remotePassword; @@ -147,8 +146,6 @@ private: void processG2(); void processDD(); - void writeStatus(); - void readStatusFiles(); void readStatusFile(const std::string& filename, unsigned int n, std::string& var); }; diff --git a/Makefile b/Makefile index ffb7f8a..098f677 100644 --- a/Makefile +++ b/Makefile @@ -91,15 +91,6 @@ clean: -include $(DEPS) -# install, uninstall and removehostfiles need root priviledges -.PHONY: newhostfiles -newhostfiles : - @echo "Fetching new host files" - @mkdir -p $(DATA_DIR) - @wget http://www.pistar.uk/downloads/DExtra_Hosts.txt -nv -O $(DATA_DIR)/DExtra_Hosts.txt - @wget http://www.pistar.uk/downloads/DCS_Hosts.txt -nv -O $(DATA_DIR)/DCS_Hosts.txt - @wget http://www.pistar.uk/downloads/DPlus_Hosts.txt -nv -O $(DATA_DIR)/DPlus_Hosts.txt - .PHONY: install install : DStarGateway/dstargateway DGWRemoteControl/dgwremotecontrol # install accessories