Don't allow reflectors from the secondary hosts file to replace the ones

from the primary hosts file.
This commit is contained in:
Jonathan Naylor 2018-06-19 20:33:20 +01:00
parent 950a9c06ba
commit 248b0840d4

View File

@ -101,12 +101,15 @@ bool CReflectors::load()
char* p3 = ::strtok(NULL, " \t\r\n"); char* p3 = ::strtok(NULL, " \t\r\n");
if (p1 != NULL && p2 != NULL && p3 != NULL) { if (p1 != NULL && p2 != NULL && p3 != NULL) {
// Don't allow duplicate reflector ids from the secondary hosts file.
unsigned int id = (unsigned int)::atoi(p1);
if (find(id) == NULL) {
std::string host = std::string(p2); std::string host = std::string(p2);
in_addr address = CUDPSocket::lookup(host); in_addr address = CUDPSocket::lookup(host);
if (address.s_addr != INADDR_NONE) { if (address.s_addr != INADDR_NONE) {
CP25Reflector* refl = new CP25Reflector; CP25Reflector* refl = new CP25Reflector;
refl->m_id = (unsigned int)::atoi(p1); refl->m_id = id;
refl->m_address = address; refl->m_address = address;
refl->m_port = (unsigned int)::atoi(p3); refl->m_port = (unsigned int)::atoi(p3);
@ -114,6 +117,7 @@ bool CReflectors::load()
} }
} }
} }
}
::fclose(fp); ::fclose(fp);
} }