From c2e26c508efe2349303b520473e62d7f6b607d1f Mon Sep 17 00:00:00 2001 From: Jonathan Naylor Date: Wed, 16 Jan 2019 20:50:59 +0000 Subject: [PATCH 1/2] Remove UDP hole puncher. --- Common/G2ProtocolHandler.cpp | 12 ------------ Common/G2ProtocolHandler.h | 2 -- ircDDBGateway/IRCDDBGatewayThread.cpp | 3 --- 3 files changed, 17 deletions(-) diff --git a/Common/G2ProtocolHandler.cpp b/Common/G2ProtocolHandler.cpp index 7d1fc7e..8f68b98 100644 --- a/Common/G2ProtocolHandler.cpp +++ b/Common/G2ProtocolHandler.cpp @@ -144,18 +144,6 @@ CAMBEData* CG2ProtocolHandler::readAMBE() return data; } -void CG2ProtocolHandler::punchUDPHole(const wxString& address) -{ - unsigned char buffer[1]; - ::memset(buffer, 0, 1); - - in_addr addr = CUDPReaderWriter::lookup(address); - - //wxLogError(wxT("Punching hole to %s"), address.mb_str()); - - m_socket.write(buffer, 1, addr, G2_DV_PORT); -} - void CG2ProtocolHandler::close() { m_socket.close(); diff --git a/Common/G2ProtocolHandler.h b/Common/G2ProtocolHandler.h index 8b74bd5..3a87834 100644 --- a/Common/G2ProtocolHandler.h +++ b/Common/G2ProtocolHandler.h @@ -52,8 +52,6 @@ public: CHeaderData* readHeader(); CAMBEData* readAMBE(); - void punchUDPHole(const wxString& addr); - void close(); private: diff --git a/ircDDBGateway/IRCDDBGatewayThread.cpp b/ircDDBGateway/IRCDDBGatewayThread.cpp index 9da5110..268a04d 100644 --- a/ircDDBGateway/IRCDDBGatewayThread.cpp +++ b/ircDDBGateway/IRCDDBGatewayThread.cpp @@ -719,7 +719,6 @@ void CIRCDDBGatewayThread::processIrcDDB() if (!address.IsEmpty()) { wxLogMessage(wxT("USER: %s %s %s %s"), user.c_str(), repeater.c_str(), gateway.c_str(), address.c_str()); m_cache.updateUser(user, repeater, gateway, address, timestamp, DP_DEXTRA, false, false); - m_g2Handler->punchUDPHole(address); } else { wxLogMessage(wxT("USER: %s NOT FOUND"), user.c_str()); } @@ -736,7 +735,6 @@ void CIRCDDBGatewayThread::processIrcDDB() if (!address.IsEmpty()) { wxLogMessage(wxT("REPEATER: %s %s %s"), repeater.c_str(), gateway.c_str(), address.c_str()); m_cache.updateRepeater(repeater, gateway, address, DP_DEXTRA, false, false); - m_g2Handler->punchUDPHole(address); } else { wxLogMessage(wxT("REPEATER: %s NOT FOUND"), repeater.c_str()); } @@ -754,7 +752,6 @@ void CIRCDDBGatewayThread::processIrcDDB() if (!address.IsEmpty()) { wxLogMessage(wxT("GATEWAY: %s %s"), gateway.c_str(), address.c_str()); m_cache.updateGateway(gateway, address, DP_DEXTRA, false, false); - m_g2Handler->punchUDPHole(address); } else { wxLogMessage(wxT("GATEWAY: %s NOT FOUND"), gateway.c_str()); } From 875bba83c1237f9a5b788de00a131dbd1ee14ddf Mon Sep 17 00:00:00 2001 From: Jonathan Naylor Date: Wed, 16 Jan 2019 20:51:23 +0000 Subject: [PATCH 2/2] Update logger to the latest wxWidgets API. --- Common/Logger.cpp | 13 ++++++------- Common/Logger.h | 7 ++++--- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Common/Logger.cpp b/Common/Logger.cpp index 1771c2e..6aa789b 100644 --- a/Common/Logger.cpp +++ b/Common/Logger.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2002,2003,2009,2011,2012 by Jonathan Naylor G4KLX + * Copyright (C) 2002,2003,2009,2011,2012,2019 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 @@ -55,11 +55,10 @@ CLogger::~CLogger() delete m_file; } -void CLogger::DoLog(wxLogLevel level, const wxChar* msg, time_t timestamp) +void CLogger::DoLogRecord(wxLogLevel level, const wxString& msg, const wxLogRecordInfo& info) { wxASSERT(m_file != NULL); wxASSERT(m_file->IsOpened()); - wxASSERT(msg != NULL); wxString letter; @@ -75,18 +74,18 @@ void CLogger::DoLog(wxLogLevel level, const wxChar* msg, time_t timestamp) default: letter = wxT("U"); break; } - struct tm* tm = ::gmtime(×tamp); + struct tm* tm = ::gmtime(&info.timestamp); wxString message; - message.Printf(wxT("%s: %04d-%02d-%02d %02d:%02d:%02d: %s\n"), letter.c_str(), tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec, msg); + message.Printf(wxT("%s: %04d-%02d-%02d %02d:%02d:%02d: %s\n"), letter.c_str(), tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec, msg.c_str()); - DoLogString(message.c_str(), timestamp); + writeLog(message.c_str(), info.timestamp); if (level == wxLOG_FatalError) ::abort(); } -void CLogger::DoLogString(const wxChar* msg, time_t timestamp) +void CLogger::writeLog(const wxChar* msg, time_t timestamp) { wxASSERT(m_file != NULL); wxASSERT(m_file->IsOpened()); diff --git a/Common/Logger.h b/Common/Logger.h index 29523df..b9ca2c2 100644 --- a/Common/Logger.h +++ b/Common/Logger.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2002,2003,2009,2011,2012 by Jonathan Naylor G4KLX + * Copyright (C) 2002,2003,2009,2011,2012,2019 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 @@ -28,14 +28,15 @@ public: CLogger(const wxString& directory, const wxString& name); virtual ~CLogger(); - virtual void DoLog(wxLogLevel level, const wxChar* msg, time_t timestamp); - virtual void DoLogString(const wxChar* msg, time_t timestamp); + virtual void DoLogRecord(wxLogLevel level, const wxString& msg, const wxLogRecordInfo& info); private: wxString m_name; wxFFile* m_file; wxFileName m_fileName; int m_day; + + void writeLog(const wxChar* msg, time_t timestamp); }; #endif