From cce216b983ed4e36869046e7c537f47d34734340 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sat, 1 Jun 2013 19:35:16 +0300 Subject: Add alternate host name to servers list. First try will be by hostname, if it failed in name resolution will be used alt host name This allow connect to server with static ip address even if dns is broken. --- src/net/ea/network.cpp | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'src/net/ea/network.cpp') diff --git a/src/net/ea/network.cpp b/src/net/ea/network.cpp index 2b9c048f7..085901743 100644 --- a/src/net/ea/network.cpp +++ b/src/net/ea/network.cpp @@ -105,6 +105,7 @@ bool Network::connect(ServerInfo server) server.hostname.c_str(), server.port); mServer.hostname = server.hostname; + mServer.althostname = server.althostname; mServer.port = server.port; // Reset to sane values @@ -190,13 +191,18 @@ bool Network::realConnect() if (TcpNet::resolveHost(&ipAddress, mServer.hostname.c_str(), mServer.port) == -1) { - const std::string errorMessage = std::string( - // TRANSLATORS: error message - _("Unable to resolve host \"")).append( - mServer.hostname).append("\""); - setError(errorMessage); - logger->log("TcpNet::ResolveHost: %s", errorMessage.c_str()); - return false; + if (mServer.althostname.empty() || TcpNet::resolveHost(&ipAddress, + mServer.althostname.c_str(), mServer.port) == -1) + { + const std::string errorMessage = std::string( + // TRANSLATORS: error message + _("Unable to resolve host \"")).append( + mServer.hostname).append("\""); + setError(errorMessage); + logger->log("TcpNet::ResolveHost: %s", errorMessage.c_str()); + return false; + } + logger->log("using alt host name: %s", mServer.althostname.c_str()); } mState = CONNECTING; -- cgit v1.2.3-70-g09d2