diff options
-rw-r--r-- | client/Config.cpp | 2 | ||||
-rw-r--r-- | client/ProxyClientApp.cpp | 10 | ||||
-rw-r--r-- | client/UpdatedConfig.cpp | 8 |
3 files changed, 18 insertions, 2 deletions
diff --git a/client/Config.cpp b/client/Config.cpp index 7cfc4fb..40c24b2 100644 --- a/client/Config.cpp +++ b/client/Config.cpp @@ -98,7 +98,7 @@ Config::Config(): StaticProxySpeedLow(50) Logger::Info("Parsing config.cfg to determine initial configuration\n"); QString configPath = this_app->applicationDirPath()+ "/config.cfg"; ifstream configFile(configPath.toLocal8Bit().data(), std::ios::in); - if (!configFile) + if (!configFile.is_open()) { Logger::Fatal("Can't open file: config.cfg\n"); return; diff --git a/client/ProxyClientApp.cpp b/client/ProxyClientApp.cpp index e2968b0..4bc5648 100644 --- a/client/ProxyClientApp.cpp +++ b/client/ProxyClientApp.cpp @@ -12,6 +12,16 @@ using namespace std; ProxyClientApp::ProxyClientApp(int &argc, char *argv[]): QApplication(argc, argv) { + // check if initial config exists (config.cfg) + QString configPath = this_app->applicationDirPath()+ "/config.cfg"; + QFileInfo configInfo(configPath); + if (! configInfo.exists()) + { + Logger::Fatal("Initial configuration file (config.cfg) do not exist!\n"); + Logger::Fatal("Terminating!\n"); + return ; + } + /* initiates UpdatedConfig singleton that start sending configuration requests */ UpdatedConfig *cfg = UpdatedConfig::CurrentConfig(); connect(cfg, SIGNAL(updated()), diff --git a/client/UpdatedConfig.cpp b/client/UpdatedConfig.cpp index 9cf91dd..ac8ec10 100644 --- a/client/UpdatedConfig.cpp +++ b/client/UpdatedConfig.cpp @@ -27,7 +27,13 @@ UpdatedConfig::UpdatedConfig() activeSrvIndex = 0; time = 0; retryFailed = false; - + + if (servers.size() == 0) + { + Logger::Error("No server records present. Can't update configuration!\n"); + return; + } + client = new SslClient(QString::fromStdString(servers[0].host)); connect(client, SIGNAL(ReplyRecieved(SslClient::RequestType&, QByteArray&)), this, SLOT(gotServerReply(SslClient::RequestType&, QByteArray&))); |