Merge branch 'feature/auto_host_file_update_#50' into develop closes #50
commit
ea23834643
@ -0,0 +1,211 @@
|
||||
/*
|
||||
* Copyright (c) 2024 by Geoffrey F4FXL / KC3FRA
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include <cassert>
|
||||
|
||||
#include "HostsFilesManager.h"
|
||||
#include "HostFile.h"
|
||||
#include "StringUtils.h"
|
||||
#include "UDPReaderWriter.h"
|
||||
#include "Log.h"
|
||||
|
||||
std::string CHostsFilesManager::m_hostFilesDirectory("");
|
||||
std::string CHostsFilesManager::m_customFilesDirectory("");
|
||||
|
||||
bool CHostsFilesManager::m_dextraEnabled = false;
|
||||
bool CHostsFilesManager::m_dcsEnabled = false;
|
||||
bool CHostsFilesManager::m_dplusEnabled = false;
|
||||
bool CHostsFilesManager::m_xlxEnabled = false;
|
||||
|
||||
std::string CHostsFilesManager::m_dextraUrl("");
|
||||
std::string CHostsFilesManager::m_dcsUrl("");
|
||||
std::string CHostsFilesManager::m_dplusUrl("");
|
||||
std::string CHostsFilesManager::m_xlxUrl("");
|
||||
|
||||
CCacheManager * CHostsFilesManager::m_cache = nullptr;
|
||||
CTimer CHostsFilesManager::m_downloadTimer(1000U, 60 * 60 * 24);
|
||||
|
||||
HostFileDownloadCallback CHostsFilesManager::m_downloadCallback = nullptr;
|
||||
|
||||
void CHostsFilesManager::setHostFilesDirectories(const std::string & hostFilesDir, const std::string & customHostFilesDir)
|
||||
{
|
||||
m_hostFilesDirectory.assign(hostFilesDir);
|
||||
m_customFilesDirectory.assign(customHostFilesDir);
|
||||
}
|
||||
|
||||
void CHostsFilesManager::setDownloadCallback(HostFileDownloadCallback callback)
|
||||
{
|
||||
m_downloadCallback = callback;
|
||||
}
|
||||
|
||||
void CHostsFilesManager::setDextra(bool enabled, const std::string & url)
|
||||
{
|
||||
m_dextraEnabled = enabled;
|
||||
m_dextraUrl.assign(url);
|
||||
}
|
||||
|
||||
void CHostsFilesManager::setDPlus(bool enabled, const std::string & url)
|
||||
{
|
||||
m_dplusEnabled = enabled;
|
||||
m_dplusUrl.assign(url);
|
||||
}
|
||||
|
||||
void CHostsFilesManager::setDCS(bool enabled, const std::string & url)
|
||||
{
|
||||
m_dcsEnabled = enabled;
|
||||
m_dcsUrl.assign(url);
|
||||
}
|
||||
|
||||
void CHostsFilesManager::setXLX(bool enabled, const std::string & url)
|
||||
{
|
||||
m_xlxEnabled = enabled;
|
||||
m_xlxUrl.assign(url);
|
||||
}
|
||||
|
||||
void CHostsFilesManager::setCache(CCacheManager * cache)
|
||||
{
|
||||
assert(cache != nullptr);
|
||||
m_cache = cache;
|
||||
}
|
||||
|
||||
void CHostsFilesManager::clock(unsigned int ms)
|
||||
{
|
||||
m_downloadTimer.clock(ms);
|
||||
|
||||
if(m_downloadTimer.hasExpired()) {
|
||||
CLog::logInfo("Downloading hosts files after %u hours", m_downloadTimer.getTimeout() / 3600U);
|
||||
UpdateHostsAsync(); // call and forget
|
||||
m_downloadTimer.start();
|
||||
}
|
||||
}
|
||||
|
||||
void CHostsFilesManager::setDownloadTimeout(unsigned int seconds)
|
||||
{
|
||||
m_downloadTimer.start(seconds);
|
||||
}
|
||||
|
||||
bool CHostsFilesManager::UpdateHostsFromInternet()
|
||||
{
|
||||
CLog::logInfo("Updating hosts files from internet");
|
||||
bool ret = true;
|
||||
if(m_dextraEnabled && !m_dextraUrl.empty()) ret = m_downloadCallback(m_dextraUrl, m_hostFilesDirectory + "/" + DEXTRA_HOSTS_FILE_NAME) && ret;
|
||||
if(m_dcsEnabled && !m_dcsUrl.empty()) ret = m_downloadCallback(m_dcsUrl, m_hostFilesDirectory + "/" + DCS_HOSTS_FILE_NAME) && ret;
|
||||
if(m_dplusEnabled && !m_dplusUrl.empty()) ret = m_downloadCallback(m_dplusUrl, m_hostFilesDirectory + "/" + DPLUS_HOSTS_FILE_NAME) && ret;
|
||||
if(m_xlxEnabled && !m_xlxUrl.empty()) ret = m_downloadCallback(m_xlxUrl, m_hostFilesDirectory + "/" + XLX_HOSTS_FILE_NAME) && ret;
|
||||
|
||||
if(!ret) CLog::logWarning("Some hosts files failed to downlaod");
|
||||
|
||||
CHostsFilesManager::loadReflectors(m_hostFilesDirectory);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool CHostsFilesManager::UpdateHostsFromLocal()
|
||||
{
|
||||
CHostsFilesManager::loadReflectors(m_customFilesDirectory);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CHostsFilesManager::UpdateHosts()
|
||||
{
|
||||
bool ret = UpdateHostsFromInternet();
|
||||
UpdateHostsFromLocal() && ret;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
std::future<bool> CHostsFilesManager::UpdateHostsAsync()
|
||||
{
|
||||
auto fut = std::async(std::launch::async, UpdateHosts);
|
||||
return fut;
|
||||
}
|
||||
|
||||
void CHostsFilesManager::loadReflectors(const std::string & directory)
|
||||
{
|
||||
if (m_xlxEnabled) {
|
||||
std::string fileName = directory + "/" + XLX_HOSTS_FILE_NAME;
|
||||
loadReflectors(fileName, DP_DCS);
|
||||
}
|
||||
|
||||
if (m_dplusEnabled) {
|
||||
std::string fileName = directory + "/" + DPLUS_HOSTS_FILE_NAME;
|
||||
loadReflectors(fileName, DP_DPLUS);
|
||||
}
|
||||
|
||||
if (m_dextraEnabled) {
|
||||
std::string fileName = directory + "/" + DEXTRA_HOSTS_FILE_NAME;
|
||||
loadReflectors(fileName, DP_DEXTRA);
|
||||
}
|
||||
|
||||
if (m_dcsEnabled) {
|
||||
std::string fileName = directory + "/" + DCS_HOSTS_FILE_NAME;
|
||||
loadReflectors(fileName, DP_DCS);
|
||||
}
|
||||
}
|
||||
|
||||
void CHostsFilesManager::loadReflectors(const std::string & hostFileName, DSTAR_PROTOCOL proto)
|
||||
{
|
||||
if(m_cache == nullptr) {
|
||||
CLog::logDebug("HostsFilesManager cache not initilized");
|
||||
return;
|
||||
}
|
||||
|
||||
unsigned int count = 0U;
|
||||
|
||||
CHostFile hostFile(hostFileName, false);
|
||||
for (unsigned int i = 0U; i < hostFile.getCount(); i++) {
|
||||
std::string 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;
|
||||
|
||||
std::string addrText;
|
||||
addrText = CStringUtils::string_format("%u.%u.%u.%u", ucp[0U] & 0xFFU, ucp[1U] & 0xFFU, ucp[2U] & 0xFFU, ucp[3U] & 0xFFU);
|
||||
|
||||
if (lock)
|
||||
CLog::logInfo("Locking %s to %s", reflector.c_str(), addrText.c_str());
|
||||
|
||||
reflector.resize(LONG_CALLSIGN_LENGTH - 1U, ' ');
|
||||
reflector += "G";
|
||||
m_cache->updateGateway(reflector, addrText, proto, lock, true);
|
||||
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
std::string protoString;
|
||||
switch (proto)
|
||||
{
|
||||
case DP_DEXTRA:
|
||||
protoString = "DExtra";
|
||||
break;
|
||||
case DP_DCS:
|
||||
protoString = "DCS";
|
||||
break;
|
||||
case DP_DPLUS:
|
||||
protoString = "DPlus";
|
||||
break;
|
||||
default:
|
||||
// ???
|
||||
break;
|
||||
}
|
||||
|
||||
CLog::logInfo("Loaded %u of %u %s hosts from %s", count, hostFile.getCount(), protoString.c_str() , hostFileName.c_str());
|
||||
}
|
||||
@ -0,0 +1,70 @@
|
||||
/*
|
||||
* Copyright (c) 2024 by Geoffrey F4FXL / KC3FRA
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#ifndef HostsFilesManager_H
|
||||
#define HostsFilesManager_H
|
||||
|
||||
#include <string>
|
||||
#include <future>
|
||||
|
||||
#include "CacheManager.h"
|
||||
#include "Timer.h"
|
||||
#include "DStarDefines.h"
|
||||
|
||||
typedef bool (*HostFileDownloadCallback)(const std::string &, const std::string &);
|
||||
|
||||
class CHostsFilesManager {
|
||||
public:
|
||||
static void setHostFilesDirectories(const std::string & hostFilesDir, const std::string & customHostFilesDir);
|
||||
static void setDownloadCallback(HostFileDownloadCallback downloadCallback);
|
||||
static void setDextra(bool enabled, const std::string & dextraUrl);
|
||||
static void setDCS(bool enabled, const std::string & dcsUrl);
|
||||
static void setDPlus(bool enabled, const std::string & dplusUrl);
|
||||
static void setXLX(bool enabled, const std::string & xlxUrl);
|
||||
static void setCache(CCacheManager * cache);
|
||||
static void clock(unsigned int ms);
|
||||
static void setDownloadTimeout(unsigned int seconds);
|
||||
static bool UpdateHostsFromInternet();
|
||||
static bool UpdateHostsFromLocal();
|
||||
static bool UpdateHosts();
|
||||
static std::future<bool> UpdateHostsAsync();
|
||||
|
||||
private:
|
||||
static std::string m_hostFilesDirectory;
|
||||
static std::string m_customFilesDirectory;
|
||||
|
||||
static bool m_dextraEnabled;
|
||||
static bool m_dcsEnabled;
|
||||
static bool m_dplusEnabled;
|
||||
static bool m_xlxEnabled;
|
||||
|
||||
static std::string m_dextraUrl;
|
||||
static std::string m_dcsUrl;
|
||||
static std::string m_dplusUrl;
|
||||
static std::string m_xlxUrl;
|
||||
|
||||
static CCacheManager * m_cache;
|
||||
static CTimer m_downloadTimer;
|
||||
|
||||
static HostFileDownloadCallback m_downloadCallback;
|
||||
|
||||
static void loadReflectors(const std::string & directory);
|
||||
static void loadReflectors(const std::string & hostFileName, DSTAR_PROTOCOL proto);
|
||||
};
|
||||
|
||||
#endif
|
||||
@ -0,0 +1,207 @@
|
||||
/*
|
||||
* Copyright (C) 2021-2024 by Geoffrey Merck F4FXL / KC3FRA
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
#include <unistd.h>
|
||||
#include <string>
|
||||
#include <stdlib.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#include "HostsFilesManager.h"
|
||||
#include "CacheManager.h"
|
||||
#include "DStarDefines.h"
|
||||
|
||||
namespace HostsFilesManagerTests
|
||||
{
|
||||
class HostsFilesManager_UpdateHosts : public ::testing::Test
|
||||
{
|
||||
protected:
|
||||
std::string m_internetPath;
|
||||
std::string m_customPath;
|
||||
CCacheManager * m_cache;
|
||||
|
||||
HostsFilesManager_UpdateHosts() :
|
||||
m_internetPath(),
|
||||
m_customPath(),
|
||||
m_cache(nullptr)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
void SetUp() override
|
||||
{
|
||||
char buf[2048];
|
||||
auto size = ::readlink("/proc/self/exe", buf, 2048);
|
||||
if(size > 0) {
|
||||
std::string path(buf, size);
|
||||
auto lastSlashPos = path.find_last_of('/');
|
||||
path.resize(lastSlashPos);
|
||||
|
||||
m_internetPath = path + "/HostsFilesManager/internet/";
|
||||
m_customPath = path + "/HostsFilesManager/custom/";
|
||||
}
|
||||
|
||||
CHostsFilesManager::setDCS(false, "");
|
||||
CHostsFilesManager::setDextra(false, "");
|
||||
CHostsFilesManager::setXLX(false, "");
|
||||
CHostsFilesManager::setDPlus(false, "");
|
||||
|
||||
if(m_cache != nullptr) delete m_cache;
|
||||
m_cache = new CCacheManager();
|
||||
}
|
||||
|
||||
static bool dummyDownload(const std::string & a, const std::string & b)
|
||||
{
|
||||
std::cout << a << std::endl << b;
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
TEST_F(HostsFilesManager_UpdateHosts, DExtraFromInternet)
|
||||
{
|
||||
CHostsFilesManager::setDextra(true, "files are actually not downloaded, we want to to check that DEXtra Hosts are stored as DExtra");
|
||||
CHostsFilesManager::setHostFilesDirectories(m_internetPath, "specify invalid custom path as we do not want to override hosts from the internet");
|
||||
CHostsFilesManager::setDownloadCallback(HostsFilesManager_UpdateHosts::dummyDownload);
|
||||
CHostsFilesManager::setCache(m_cache);
|
||||
|
||||
CHostsFilesManager::UpdateHosts();
|
||||
auto gw = m_cache->findGateway("XRF123 G");
|
||||
|
||||
EXPECT_NE(gw, nullptr) << "DExtra host not found";
|
||||
EXPECT_STREQ(gw->getGateway().c_str(), "XRF123 G");
|
||||
EXPECT_EQ(gw->getAddress().s_addr, ::inet_addr("1.1.1.1")) << "Address missmatch";
|
||||
EXPECT_EQ(gw->getProtocol(), DP_DEXTRA) << "Protocol mismatch";
|
||||
}
|
||||
|
||||
|
||||
TEST_F(HostsFilesManager_UpdateHosts, DExtraFromInternetCustomOverride)
|
||||
{
|
||||
CHostsFilesManager::setDextra(true, "files are actually not downloaded, we want to to check that DEXtra Hosts are stored as DExtra");
|
||||
CHostsFilesManager::setHostFilesDirectories(m_internetPath, m_customPath);
|
||||
CHostsFilesManager::setDownloadCallback(HostsFilesManager_UpdateHosts::dummyDownload);
|
||||
CHostsFilesManager::setCache(m_cache);
|
||||
|
||||
CHostsFilesManager::UpdateHosts();
|
||||
auto gw = m_cache->findGateway("XRF123 G");
|
||||
|
||||
EXPECT_NE(gw, nullptr) << "DExtra host not found";
|
||||
EXPECT_STREQ(gw->getGateway().c_str(), "XRF123 G");
|
||||
EXPECT_EQ(gw->getAddress().s_addr, ::inet_addr("2.2.2.2")) << "Address missmatch";
|
||||
EXPECT_EQ(gw->getProtocol(), DP_DEXTRA) << "Protocol mismatch";
|
||||
}
|
||||
|
||||
TEST_F(HostsFilesManager_UpdateHosts, DCSFromInternet)
|
||||
{
|
||||
CHostsFilesManager::setDCS(true, "files are actually not downloaded, we want to to check that DEXtra Hosts are stored as DExtra");
|
||||
CHostsFilesManager::setHostFilesDirectories(m_internetPath, "specify invalid custom path as we do not want to override hosts from the internet");
|
||||
CHostsFilesManager::setDownloadCallback(HostsFilesManager_UpdateHosts::dummyDownload);
|
||||
CHostsFilesManager::setCache(m_cache);
|
||||
|
||||
CHostsFilesManager::UpdateHosts();
|
||||
auto gw = m_cache->findGateway("DCS123 G");
|
||||
|
||||
EXPECT_NE(gw, nullptr) << "DCS host not found";
|
||||
EXPECT_STREQ(gw->getGateway().c_str(), "DCS123 G");
|
||||
EXPECT_EQ(gw->getAddress().s_addr, ::inet_addr("1.1.1.1")) << "Address missmatch";
|
||||
EXPECT_EQ(gw->getProtocol(), DP_DCS) << "Protocol mismatch";
|
||||
}
|
||||
|
||||
|
||||
TEST_F(HostsFilesManager_UpdateHosts, DCSFromInternetCustomOverride)
|
||||
{
|
||||
CHostsFilesManager::setDCS(true, "files are actually not downloaded, we want to to check that DEXtra Hosts are stored as DExtra");
|
||||
CHostsFilesManager::setHostFilesDirectories(m_internetPath, m_customPath);
|
||||
CHostsFilesManager::setDownloadCallback(HostsFilesManager_UpdateHosts::dummyDownload);
|
||||
CHostsFilesManager::setCache(m_cache);
|
||||
|
||||
CHostsFilesManager::UpdateHosts();
|
||||
auto gw = m_cache->findGateway("DCS123 G");
|
||||
|
||||
EXPECT_NE(gw, nullptr) << "DCS host not found";
|
||||
EXPECT_STREQ(gw->getGateway().c_str(), "DCS123 G");
|
||||
EXPECT_EQ(gw->getAddress().s_addr, ::inet_addr("2.2.2.2")) << "Address missmatch";
|
||||
EXPECT_EQ(gw->getProtocol(), DP_DCS) << "Protocol mismatch";
|
||||
}
|
||||
|
||||
TEST_F(HostsFilesManager_UpdateHosts, DPlusFromInternet)
|
||||
{
|
||||
CHostsFilesManager::setDPlus(true, "files are actually not downloaded, we want to to check that DEXtra Hosts are stored as DExtra");
|
||||
CHostsFilesManager::setHostFilesDirectories(m_internetPath, "specify invalid custom path as we do not want to override hosts from the internet");
|
||||
CHostsFilesManager::setDownloadCallback(HostsFilesManager_UpdateHosts::dummyDownload);
|
||||
CHostsFilesManager::setCache(m_cache);
|
||||
|
||||
CHostsFilesManager::UpdateHosts();
|
||||
auto gw = m_cache->findGateway("REF123 G");
|
||||
|
||||
EXPECT_NE(gw, nullptr) << "DPlus host not found";
|
||||
EXPECT_STREQ(gw->getGateway().c_str(), "REF123 G");
|
||||
EXPECT_EQ(gw->getAddress().s_addr, ::inet_addr("1.1.1.1")) << "Address missmatch";
|
||||
EXPECT_EQ(gw->getProtocol(), DP_DPLUS) << "Protocol mismatch";
|
||||
}
|
||||
|
||||
|
||||
TEST_F(HostsFilesManager_UpdateHosts, DPlusFromInternetCustomOverride)
|
||||
{
|
||||
CHostsFilesManager::setDPlus(true, "files are actually not downloaded, we want to to check that DEXtra Hosts are stored as DExtra");
|
||||
CHostsFilesManager::setHostFilesDirectories(m_internetPath, m_customPath);
|
||||
CHostsFilesManager::setDownloadCallback(HostsFilesManager_UpdateHosts::dummyDownload);
|
||||
CHostsFilesManager::setCache(m_cache);
|
||||
|
||||
CHostsFilesManager::UpdateHosts();
|
||||
auto gw = m_cache->findGateway("REF123 G");
|
||||
|
||||
EXPECT_NE(gw, nullptr) << "DPlus host not found";
|
||||
EXPECT_STREQ(gw->getGateway().c_str(), "REF123 G");
|
||||
EXPECT_EQ(gw->getAddress().s_addr, ::inet_addr("2.2.2.2")) << "Address missmatch";
|
||||
EXPECT_EQ(gw->getProtocol(), DP_DPLUS) << "Protocol mismatch";
|
||||
}
|
||||
|
||||
TEST_F(HostsFilesManager_UpdateHosts, XLXFromInternet)
|
||||
{
|
||||
CHostsFilesManager::setXLX(true, "files are actually not downloaded, we want to to check that DEXtra Hosts are stored as DExtra");
|
||||
CHostsFilesManager::setHostFilesDirectories(m_internetPath, "specify invalid custom path as we do not want to override hosts from the internet");
|
||||
CHostsFilesManager::setDownloadCallback(HostsFilesManager_UpdateHosts::dummyDownload);
|
||||
CHostsFilesManager::setCache(m_cache);
|
||||
|
||||
CHostsFilesManager::UpdateHosts();
|
||||
auto gw = m_cache->findGateway("XLX123 G");
|
||||
|
||||
EXPECT_NE(gw, nullptr) << "XLX host not found";
|
||||
EXPECT_STREQ(gw->getGateway().c_str(), "XLX123 G");
|
||||
EXPECT_EQ(gw->getAddress().s_addr, ::inet_addr("1.1.1.1")) << "Address missmatch";
|
||||
EXPECT_EQ(gw->getProtocol(), DP_DCS) << "Protocol mismatch";
|
||||
}
|
||||
|
||||
|
||||
TEST_F(HostsFilesManager_UpdateHosts, XLXFromInternetCustomOverride)
|
||||
{
|
||||
CHostsFilesManager::setXLX(true, "files are actually not downloaded, we want to to check that DEXtra Hosts are stored as DExtra");
|
||||
CHostsFilesManager::setHostFilesDirectories(m_internetPath, m_customPath);
|
||||
CHostsFilesManager::setDownloadCallback(HostsFilesManager_UpdateHosts::dummyDownload);
|
||||
CHostsFilesManager::setCache(m_cache);
|
||||
|
||||
CHostsFilesManager::UpdateHosts();
|
||||
auto gw = m_cache->findGateway("XLX123 G");
|
||||
|
||||
EXPECT_NE(gw, nullptr) << "XLX host not found";
|
||||
EXPECT_STREQ(gw->getGateway().c_str(), "XLX123 G");
|
||||
EXPECT_EQ(gw->getAddress().s_addr, ::inet_addr("2.2.2.2")) << "Address missmatch";
|
||||
EXPECT_EQ(gw->getProtocol(), DP_DCS) << "Protocol mismatch";
|
||||
}
|
||||
}
|
||||
@ -0,0 +1 @@
|
||||
DCS123 2.2.2.2
|
||||
@ -0,0 +1 @@
|
||||
XRF123 2.2.2.2
|
||||
@ -0,0 +1 @@
|
||||
REF123 2.2.2.2
|
||||
@ -0,0 +1 @@
|
||||
XLX123 2.2.2.2
|
||||
@ -0,0 +1 @@
|
||||
DCS123 1.1.1.1
|
||||
@ -0,0 +1 @@
|
||||
XRF123 1.1.1.1
|
||||
@ -0,0 +1 @@
|
||||
REF123 1.1.1.1
|
||||
@ -0,0 +1 @@
|
||||
XLX123 1.1.1.1
|
||||
Loading…
Reference in new issue