do not wait network to be available

pull/783/head
Ömer Şiar Baysal 3 weeks ago
parent ac27accf08
commit f7ccd66c23
  1. 6
      src/config.cpp
  2. 2
      src/config.h
  3. 44
      src/minidexed.cpp

@ -208,6 +208,7 @@ void CConfig::Load (void)
m_INetworkIPAddress = m_Properties.GetIPAddress("NetworkIPAddress") != 0; m_INetworkIPAddress = m_Properties.GetIPAddress("NetworkIPAddress") != 0;
m_INetworkSubnetMask = m_Properties.GetIPAddress("NetworkSubnetMask") != 0; m_INetworkSubnetMask = m_Properties.GetIPAddress("NetworkSubnetMask") != 0;
m_INetworkDefaultGateway = m_Properties.GetIPAddress("NetworkDefaultGateway") != 0; m_INetworkDefaultGateway = m_Properties.GetIPAddress("NetworkDefaultGateway") != 0;
m_bSyslogEnabled = m_Properties.GetNumber ("SyslogEnabled", 0) != 0;
m_INetworkDNSServer = m_Properties.GetIPAddress("NetworkDNSServer") != 0; m_INetworkDNSServer = m_Properties.GetIPAddress("NetworkDNSServer") != 0;
const u8 *pSyslogServerIP = m_Properties.GetIPAddress ("NetworkSyslogServerIPAddress"); const u8 *pSyslogServerIP = m_Properties.GetIPAddress ("NetworkSyslogServerIPAddress");
@ -774,6 +775,11 @@ CIPAddress CConfig::GetNetworkDNSServer (void) const
return m_INetworkDNSServer; return m_INetworkDNSServer;
} }
bool CConfig::GetSyslogEnabled (void) const
{
return m_bSyslogEnabled;
}
CIPAddress CConfig::GetNetworkSyslogServerIPAddress (void) const CIPAddress CConfig::GetNetworkSyslogServerIPAddress (void) const
{ {
return m_INetworkSyslogServerIPAddress; return m_INetworkSyslogServerIPAddress;

@ -248,6 +248,7 @@ public:
CIPAddress GetNetworkSubnetMask (void) const; CIPAddress GetNetworkSubnetMask (void) const;
CIPAddress GetNetworkDefaultGateway (void) const; CIPAddress GetNetworkDefaultGateway (void) const;
CIPAddress GetNetworkDNSServer (void) const; CIPAddress GetNetworkDNSServer (void) const;
bool GetSyslogEnabled (void) const;
CIPAddress GetNetworkSyslogServerIPAddress (void) const; CIPAddress GetNetworkSyslogServerIPAddress (void) const;
private: private:
@ -373,6 +374,7 @@ private:
CIPAddress m_INetworkSubnetMask; CIPAddress m_INetworkSubnetMask;
CIPAddress m_INetworkDefaultGateway; CIPAddress m_INetworkDefaultGateway;
CIPAddress m_INetworkDNSServer; CIPAddress m_INetworkDNSServer;
bool m_bSyslogEnabled;
CIPAddress m_INetworkSyslogServerIPAddress; CIPAddress m_INetworkSyslogServerIPAddress;
}; };

@ -2200,7 +2200,6 @@ void CMiniDexed::UpdateNetwork()
//CNetSubSystem* const pNet = CNetSubSystem::Get(); //CNetSubSystem* const pNet = CNetSubSystem::Get();
if (!m_pNet) if (!m_pNet)
return; return;
//add wired network check as well //add wired network check as well
//add wired network check as well //add wired network check as well
bool bNetIsRunning = m_pNet->IsRunning(); bool bNetIsRunning = m_pNet->IsRunning();
@ -2209,7 +2208,7 @@ void CMiniDexed::UpdateNetwork()
else if (m_pNetDevice->GetType() == NetDeviceTypeWLAN) else if (m_pNetDevice->GetType() == NetDeviceTypeWLAN)
bNetIsRunning &= m_WPASupplicant.IsConnected(); bNetIsRunning &= m_WPASupplicant.IsConnected();
if (!m_bNetworkInit) if (!m_bNetworkInit && bNetIsRunning)
{ {
m_bNetworkInit = true; m_bNetworkInit = true;
CString IPString; CString IPString;
@ -2248,7 +2247,21 @@ void CMiniDexed::UpdateNetwork()
{ {
LOGPANIC ("Cannot publish mdns service"); LOGPANIC ("Cannot publish mdns service");
} }
// syslog configuration
if (m_pConfig->GetSyslogEnabled())
{
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);
}
}
m_bNetworkReady = true; m_bNetworkReady = true;
} }
@ -2290,12 +2303,10 @@ bool CMiniDexed::InitNetwork()
if (m_pConfig->GetNetworkEnabled () && (strcmp(m_pConfig->GetNetworkType(), "wifi") == 0)) if (m_pConfig->GetNetworkEnabled () && (strcmp(m_pConfig->GetNetworkType(), "wifi") == 0))
{ {
LOGNOTE("Initializing WLAN"); LOGNOTE("Initializing WLAN");
NetDeviceType = NetDeviceTypeWLAN;
if (m_WLAN.Initialize() && m_WPASupplicant.Initialize()) if (m_WLAN.Initialize())
{ {
LOGNOTE("wlan and wpasupplicant initialized"); LOGNOTE("WLAN initialized");
NetDeviceType = NetDeviceTypeWLAN;
} }
else else
LOGERR("Failed to initialize WLAN"); LOGERR("Failed to initialize WLAN");
@ -2319,29 +2330,18 @@ bool CMiniDexed::InitNetwork()
m_pConfig->GetNetworkHostname(), m_pConfig->GetNetworkHostname(),
NetDeviceType NetDeviceType
); );
if (!m_pNet->Initialize(false))
if (!m_pNet->Initialize())
{ {
LOGERR("Failed to initialize network subsystem"); LOGERR("Failed to initialize network subsystem");
delete m_pNet; delete m_pNet;
m_pNet = nullptr; m_pNet = nullptr;
} }
m_pNetDevice = CNetDevice::GetNetDevice(NetDeviceType); m_pNetDevice = CNetDevice::GetNetDevice(NetDeviceType);
// WPASupplicant needs to be started after netdevice available
// syslog configuration if (m_pConfig->GetNetworkEnabled () && (strcmp(m_pConfig->GetNetworkType(), "wifi") == 0))
CIPAddress ServerIP = m_pConfig->GetNetworkSyslogServerIPAddress();
if (ServerIP.IsSet () && !ServerIP.IsNull ())
{ {
static const u16 usServerPort = 8514; // standard port is 514 if (!m_WPASupplicant.Initialize()) LOGERR("Failed to initialize WPASupplicant");
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; return m_pNet != nullptr;
} }

Loading…
Cancel
Save