From 46ccb9ca12ae45bf60a93e0cfe6d4eb063fdfe28 Mon Sep 17 00:00:00 2001 From: probonopd Date: Sun, 17 Nov 2024 19:01:29 +0000 Subject: [PATCH] Do not hardcode syslog server https://github.com/rsta2/circle/discussions/506#discussioncomment-11284425 --- src/config.cpp | 7 ++++++- src/minidexed.cpp | 22 ++++++++++++---------- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/src/config.cpp b/src/config.cpp index 40ad095..cc689f8 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -209,7 +209,12 @@ void CConfig::Load (void) m_INetworkSubnetMask = m_Properties.GetIPAddress("NetworkSubnetMask") != 0; m_INetworkDefaultGateway = m_Properties.GetIPAddress("NetworkDefaultGateway") != 0; m_INetworkDNSServer = m_Properties.GetIPAddress("NetworkDNSServer") != 0; - m_INetworkSyslogServerIPAddress = m_Properties.GetIPAddress("NetworkSyslogServerIPAddress") != 0; + + const u8 *pSyslogServerIP = m_Properties.GetIPAddress ("NetworkSyslogServerIPAddress"); + if (pSyslogServerIP) + { + m_INetworkSyslogServerIPAddress.Set (pSyslogServerIP); + } } unsigned CConfig::GetToneGenerators (void) const diff --git a/src/minidexed.cpp b/src/minidexed.cpp index f61c835..57c9c86 100644 --- a/src/minidexed.cpp +++ b/src/minidexed.cpp @@ -2329,16 +2329,18 @@ bool CMiniDexed::InitNetwork() m_pNetDevice = CNetDevice::GetNetDevice(NetDeviceType); - // Syslog configuration - static const u8 SysLogServer[] = {192, 168, 0, 143}; // FIXME: Don't hardcode this, use m_INetworkSyslogServerIPAddress instead - static const u16 usServerPort = 8514; // standard port is 514 - CIPAddress ServerIP (SysLogServer); - CString IPString; - ServerIP.Format (&IPString); - LOGNOTE ( "Sending log messages to %s:%u", - (const char *) IPString, (unsigned) usServerPort); - - new CSysLogDaemon (m_pNet, ServerIP, usServerPort); + // syslog configuration + CIPAddress ServerIP = m_pConfig->GetNetworkSyslogServerIPAddress(); + if (ServerIP.IsSet () && !ServerIP.IsNull ()) + { + static const u16 usServerPort = 8514; // standard port is 514 + CString IPString; + ServerIP.Format (&IPString); + LOGNOTE ("Sending log messages to syslog server %s:%u", + (const char *) IPString, (unsigned) usServerPort); + + new CSysLogDaemon (m_pNet, ServerIP, usServerPort); + } } return m_pNet != nullptr;