summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Borisov <borisov.alexandr@rambler.ru>2011-12-04 22:38:58 +0200
committerAlex Borisov <borisov.alexandr@rambler.ru>2011-12-04 22:38:58 +0200
commit4fc3551822a57a3b26d0c4540e205f9b340f9899 (patch)
tree520054bf470b426c3f8a80a440bee83db89e721d
parent34e4c314ed4934fbb3ace49e664430f6be44e578 (diff)
FIX reconnection bug & server entry parser
-rw-r--r--client/Config.cpp11
-rw-r--r--client/Config.h2
-rw-r--r--client/UpdatedConfig.cpp7
-rw-r--r--client/config.cfg5
-rw-r--r--client/main.cpp6
5 files changed, 17 insertions, 14 deletions
diff --git a/client/Config.cpp b/client/Config.cpp
index 40c24b2..38ff50f 100644
--- a/client/Config.cpp
+++ b/client/Config.cpp
@@ -73,20 +73,17 @@ void Config::FileEntry::Parse(string entry, ActionType _action)
/*
* ServerEntry nested class section
*/
-Config::ServerEntry::ServerEntry(string entry)
-{
- ServerEntry();
-
+Config::ServerEntry::ServerEntry(string& entry): host("127.0.0.1"), timeout(120), retryTimeout(60)
+{
/* processing server entry e.g.: "8.8.8.8 600 60" */
size_t start = 0, end = 0;
end = entry.find(' ');
host = entry.substr(start, end);
start = end+1;
- end = entry.find(' ');
+ end = entry.find(' ', start);
timeout = atoi(entry.substr(start, end).c_str());
start = end+1;
- end = entry.find(' ');
- retryTimeout = atoi(entry.substr(start, end).c_str());
+ retryTimeout = atoi(entry.substr(start).c_str());
}
diff --git a/client/Config.h b/client/Config.h
index 466f93a..5254361 100644
--- a/client/Config.h
+++ b/client/Config.h
@@ -225,7 +225,7 @@ protected:
* @brief initilize ServerEntry instance from config file entry<br/>
* @param entry config file entry value, e.g.: '8.8.8.8:8080 600 60'
*/
- ServerEntry(string entry);
+ ServerEntry(string& entry);
/**
* @brief Hostname or address of server<br/>
diff --git a/client/UpdatedConfig.cpp b/client/UpdatedConfig.cpp
index 860042d..9ebae8a 100644
--- a/client/UpdatedConfig.cpp
+++ b/client/UpdatedConfig.cpp
@@ -35,7 +35,7 @@ UpdatedConfig::UpdatedConfig()
return;
}
- client = new SslClient(QString::fromStdString(servers[0].host));
+ client = new SslClient(QString::fromLocal8Bit(servers[0].host.c_str()));
connect(client, SIGNAL(ReplyRecieved(SslClient::RequestType&, QByteArray&)),
this, SLOT(gotServerReply(SslClient::RequestType&, QByteArray&)));
connect(client, SIGNAL(ConnectionError()),
@@ -68,6 +68,11 @@ void UpdatedConfig::update()
{
activeSrvIndex = 0;
}
+ ServerEntry current = servers[activeSrvIndex];
+ client->SetServerAddr(QString::fromLocal8Bit(current.host.c_str()));
+ configUpdateTimer->stop();
+ configUpdateTimer->setInterval(current.retryTimeout * 1000);
+ configUpdateTimer->start();
}
retryFailed = false;
}
diff --git a/client/config.cfg b/client/config.cfg
index e50d599..b6a77a9 100644
--- a/client/config.cfg
+++ b/client/config.cfg
@@ -1,10 +1,9 @@
config_update_interval=300;
client_update_interval=60000;
-server=127.0.0.1 10 10
+server=127.0.0.1 10 10;
server=192.168.1.100 600 60;
welcome_msg=Welcome to the proxy configurator!;
config_downloaded_msg=Config downloaded successfully;
top_panel_text=Top Panel;
bottom_panel_text=Bottom Panel;
-speed_visibility=1;
-
+speed_visibility=1;
diff --git a/client/main.cpp b/client/main.cpp
index f3c3d3d..f7da59e 100644
--- a/client/main.cpp
+++ b/client/main.cpp
@@ -33,8 +33,6 @@ int main(int argc, char *argv[])
dir = QString::fromStdString(path.substr(0, p));
}
- Logger::Trace("Application path: %s\n", dir.toStdString().c_str());
-
// check if client should be update
QFileInfo newClient(dir + PathSlash + "client.bin.latest");
if (newClient.exists())
@@ -55,6 +53,10 @@ int main(int argc, char *argv[])
// check if initial config exists (config.cfg)
// without it application is useless
QFileInfo configInfo(dir + PathSlash + "config.cfg");
+
+ fprintf(stderr, "%s\n", configInfo.fileName().toStdString().c_str());
+
+
if (! configInfo.exists())
{
Logger::Fatal("Initial configuration file (config.cfg) do not exist!\n");