예제 #1
0
void CIRCDDBGatewayThread::loadGateways()
{
	wxFileName fileName(wxFileName::GetHomeDir(), GATEWAY_HOSTS_FILE_NAME);
	if (!fileName.IsFileReadable())
		return;

	unsigned int count = 0U;

	CHostFile hostFile(fileName.GetFullPath(), false);
	for (unsigned int i = 0U; i < hostFile.getCount(); i++) {
		wxString gateway = hostFile.getName(i);
		in_addr address  = CUDPReaderWriter::lookup(hostFile.getAddress(i));

		if (address.s_addr != INADDR_NONE) {
			unsigned char* ucp = (unsigned char*)&address;

			wxString addrText;
			addrText.Printf(wxT("%u.%u.%u.%u"), ucp[0U] & 0xFFU, ucp[1U] & 0xFFU, ucp[2U] & 0xFFU, ucp[3U] & 0xFFU);

			wxLogMessage(wxT("Locking %s to %s"), gateway.c_str(), addrText.c_str());

			gateway.Append(wxT("        "));
			gateway.Truncate(LONG_CALLSIGN_LENGTH - 1U);
			gateway.Append(wxT("G"));
			m_cache.updateGateway(gateway, addrText, DP_DEXTRA, true, false);

			count++;
		}
	}

	wxLogMessage(wxT("Loaded %u of %u gateways from %s"), count, hostFile.getCount(), fileName.GetFullPath().c_str());
}
예제 #2
0
void CIRCDDBGatewayThread::loadDCSReflectors(const wxString& fileName)
{
	unsigned int count = 0U;

	CHostFile hostFile(fileName, false);
	for (unsigned int i = 0U; i < hostFile.getCount(); i++) {
		wxString reflector = hostFile.getName(i);
		in_addr address    = CUDPReaderWriter::lookup(hostFile.getAddress(i));
		bool lock          = hostFile.getLock(i);

		if (address.s_addr != INADDR_NONE) {
			unsigned char* ucp = (unsigned char*)&address;

			wxString addrText;
			addrText.Printf(wxT("%u.%u.%u.%u"), ucp[0U] & 0xFFU, ucp[1U] & 0xFFU, ucp[2U] & 0xFFU, ucp[3U] & 0xFFU);

			if (lock)
				wxLogMessage(wxT("Locking %s to %s"), reflector.c_str(), addrText.c_str());

			reflector.Append(wxT("        "));
			reflector.Truncate(LONG_CALLSIGN_LENGTH - 1U);
			reflector.Append(wxT("G"));
			m_cache.updateGateway(reflector, addrText, DP_DCS, lock, true);

			count++;
		}
	}

	wxLogMessage(wxT("Loaded %u of %u DCS reflectors from %s"), count, hostFile.getCount(), fileName.c_str());
}
void CIRCDDBGatewayThread::loadDPlusReflectors()
{
	wxFileName fileName(wxFileName::GetHomeDir(), DPLUS_HOSTS_FILE_NAME);

	if (!fileName.IsFileReadable()) {
		wxLogMessage(wxT("File %s not readable"), fileName.GetFullPath().c_str());
#if defined(__WINDOWS__)
		fileName.Assign(::wxGetCwd(), DPLUS_HOSTS_FILE_NAME);
#else
		fileName.Assign(wxT(DATA_DIR), DPLUS_HOSTS_FILE_NAME);
#endif
		if (!fileName.IsFileReadable())
			wxLogMessage(wxT("File %s not readable"), fileName.GetFullPath().c_str());
	}

	unsigned int count = 0U;

	CHostFile hostFile(fileName.GetFullPath(), true);
	for (unsigned int i = 0U; i < hostFile.getCount(); i++) {
		wxString reflector = hostFile.getName(i);
		in_addr address    = CUDPReaderWriter::lookup(hostFile.getAddress(i));
		bool lock          = hostFile.getLock(i);

		if (address.s_addr != INADDR_NONE) {
			unsigned char* ucp = (unsigned char*)&address;

			wxString addrText;
			addrText.Printf(wxT("%u.%u.%u.%u"), ucp[0U] & 0xFFU, ucp[1U] & 0xFFU, ucp[2U] & 0xFFU, ucp[3U] & 0xFFU);

			if (lock)
				wxLogMessage(wxT("Locking %s to %s"), reflector.c_str(), addrText.c_str());

			reflector.Append(wxT("        "));
			reflector.Truncate(LONG_CALLSIGN_LENGTH - 1U);
			reflector.Append(wxT("G"));
			m_cache.updateGateway(reflector, addrText, DP_DPLUS, lock, true);

			count++;
		}
	}

	wxLogMessage(wxT("Loaded %u of %u D-Plus reflectors"), count, hostFile.getCount());
}
예제 #4
0
void CIRCDDBGatewayThread::setCCS(bool enabled, const wxString& host)
{
	m_ccsEnabled = enabled;

	wxFileName fileName(wxFileName::GetHomeDir(), CCS_HOSTS_FILE_NAME);

	if (!fileName.IsFileReadable()) {
		wxLogMessage(wxT("File %s not readable"), fileName.GetFullPath().c_str());
#if defined(__WINDOWS__)
		fileName.Assign(::wxGetCwd(), CCS_HOSTS_FILE_NAME);
#else
		fileName.Assign(wxT(DATA_DIR), CCS_HOSTS_FILE_NAME);
#endif
		if (!fileName.IsFileReadable()) {
			wxLogMessage(wxT("File %s not readable"), fileName.GetFullPath().c_str());
			m_ccsEnabled = false;
			return;
		}
	}

	CHostFile hostFile(fileName.GetFullPath(), true);

	m_ccsHost = hostFile.getAddress(host);
}