From 6bf732f219f9b6a3149c456fc06ff314d8a3dce0 Mon Sep 17 00:00:00 2001 From: lotodore Date: Sat, 10 May 2014 21:06:50 +0200 Subject: [PATCH] Adding different error messages for connection failure with IPv6 (#276). --- src/gui/qt/startwindow/startwindowimpl.cpp | 12 ++++++++++++ src/net/common/clientstate.cpp | 13 +++++++++++-- src/net/socket_msg.h | 2 ++ 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/src/gui/qt/startwindow/startwindowimpl.cpp b/src/gui/qt/startwindow/startwindowimpl.cpp index fa931c2f..11d94b93 100644 --- a/src/gui/qt/startwindow/startwindowimpl.cpp +++ b/src/gui/qt/startwindow/startwindowimpl.cpp @@ -774,12 +774,24 @@ void startWindowImpl::networkError(int errorID, int /*osErrorID*/) QMessageBox::Close); } break; + case ERR_SOCK_CONNECT_IPV6_FAILED: { + MyMessageBox::warning(this, tr("Network Error"), + tr("Could not connect to the server.\n\nPlease note: IPv6 is enabled in the settings. The connection fails if your provider does not support IPv6.\nThis may be fixed by unchecking the \"Use IPv6\" checkbox in the settings."), + QMessageBox::Close); + } + break; case ERR_SOCK_CONNECT_TIMEOUT: { MyMessageBox::warning(this, tr("Network Error"), tr("Connection timed out.\nPlease check the server address.\n\nIf the server is behind a NAT-Router, make sure port forwarding has been set up on server side."), QMessageBox::Close); } break; + case ERR_SOCK_CONNECT_IPV6_TIMEOUT: { + MyMessageBox::warning(this, tr("Network Error"), + tr("Connection timed out.\nPlease check the server address.\n\nPlease note: IPv6 is enabled in the settings. The connection fails if your provider does not support IPv6.\nThis may be fixed by unchecking the \"Use IPv6\" checkbox in the settings."), + QMessageBox::Close); + } + break; case ERR_SOCK_SELECT_FAILED: { MyMessageBox::warning(this, tr("Network Error"), tr("Internal network error: \"select\" failed."), diff --git a/src/net/common/clientstate.cpp b/src/net/common/clientstate.cpp index c03be7d2..c943d92b 100644 --- a/src/net/common/clientstate.cpp +++ b/src/net/common/clientstate.cpp @@ -517,7 +517,11 @@ ClientStateStartConnect::HandleConnect(const boost::system::error_code& ec, boos client)); } else { if (ec != boost::asio::error::operation_aborted) { - throw ClientException(__FILE__, __LINE__, ERR_SOCK_CONNECT_FAILED, ec.value()); + if (client->GetContext().GetAddrFamily() == AF_INET6) { + throw ClientException(__FILE__, __LINE__, ERR_SOCK_CONNECT_IPV6_FAILED, ec.value()); + } else { + throw ClientException(__FILE__, __LINE__, ERR_SOCK_CONNECT_FAILED, ec.value()); + } } } } @@ -529,7 +533,12 @@ ClientStateStartConnect::TimerTimeout(const boost::system::error_code& ec, boost if (!ec && &client->GetState() == this) { boost::system::error_code ec; client->GetContext().GetSessionData()->GetAsioSocket()->close(ec); - throw ClientException(__FILE__, __LINE__, ERR_SOCK_CONNECT_TIMEOUT, 0); + if (client->GetContext().GetAddrFamily() == AF_INET6) { + throw ClientException(__FILE__, __LINE__, ERR_SOCK_CONNECT_IPV6_TIMEOUT, 0); + } + else { + throw ClientException(__FILE__, __LINE__, ERR_SOCK_CONNECT_TIMEOUT, 0); + } } } diff --git a/src/net/socket_msg.h b/src/net/socket_msg.h index d65fe604..0dcf9e7b 100644 --- a/src/net/socket_msg.h +++ b/src/net/socket_msg.h @@ -61,6 +61,8 @@ #define ERR_SOCK_TRANSFER_INVALID_URL 26 #define ERR_SOCK_TRANSFER_SELECT_FAILED 27 #define ERR_SOCK_TRANSFER_FAILED 28 +#define ERR_SOCK_CONNECT_IPV6_FAILED 29 +#define ERR_SOCK_CONNECT_IPV6_TIMEOUT 30 // The following errors are game errors. #define ERR_NET_VERSION_NOT_SUPPORTED 101 #define ERR_NET_SERVER_MAINTENANCE 102