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