|
|
|
@ -28,6 +28,8 @@
|
|
|
|
|
|
|
|
|
|
CReflectors::CReflectors(const std::string& hostsFile, unsigned int reloadTime) :
|
|
|
|
|
m_hostsFile(hostsFile),
|
|
|
|
|
m_parrotAddress(),
|
|
|
|
|
m_parrotPort(0U),
|
|
|
|
|
m_reflectors(),
|
|
|
|
|
m_search(),
|
|
|
|
|
m_timer(1000U, reloadTime * 60U)
|
|
|
|
@ -61,20 +63,22 @@ static bool refComparison(const CYSFReflector* r1, const CYSFReflector* r2)
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool CReflectors::load()
|
|
|
|
|
void CReflectors::setParrot(const std::string& address, unsigned int port)
|
|
|
|
|
{
|
|
|
|
|
FILE* fp = ::fopen(m_hostsFile.c_str(), "rt");
|
|
|
|
|
if (fp == NULL) {
|
|
|
|
|
LogWarning("Cannot open the YSF Hosts file - %s", m_hostsFile.c_str());
|
|
|
|
|
return false;
|
|
|
|
|
m_parrotAddress = address;
|
|
|
|
|
m_parrotPort = port;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool CReflectors::load()
|
|
|
|
|
{
|
|
|
|
|
// Clear out the old reflector list
|
|
|
|
|
for (std::vector<CYSFReflector*>::iterator it = m_reflectors.begin(); it != m_reflectors.end(); ++it)
|
|
|
|
|
delete *it;
|
|
|
|
|
|
|
|
|
|
m_reflectors.clear();
|
|
|
|
|
|
|
|
|
|
FILE* fp = ::fopen(m_hostsFile.c_str(), "rt");
|
|
|
|
|
if (fp != NULL) {
|
|
|
|
|
char buffer[100U];
|
|
|
|
|
while (::fgets(buffer, 100U, fp) != NULL) {
|
|
|
|
|
if (buffer[0U] == '#')
|
|
|
|
@ -109,6 +113,19 @@ bool CReflectors::load()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
::fclose(fp);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Add the Parrot entry
|
|
|
|
|
if (m_parrotPort > 0U) {
|
|
|
|
|
CYSFReflector* refl = new CYSFReflector;
|
|
|
|
|
refl->m_id = "00001";
|
|
|
|
|
refl->m_name = "ZZ Parrot ";
|
|
|
|
|
refl->m_desc = "Parrot ";
|
|
|
|
|
refl->m_address = CUDPSocket::lookup(m_parrotAddress);
|
|
|
|
|
refl->m_port = m_parrotPort;
|
|
|
|
|
refl->m_count = "000";
|
|
|
|
|
m_reflectors.push_back(refl);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
size_t size = m_reflectors.size();
|
|
|
|
|
if (size == 0U)
|
|
|
|
|