Skip to content

Commit

Permalink
Adding different error messages for connection failure with IPv6 (pok…
Browse files Browse the repository at this point in the history
  • Loading branch information
lotodore authored and q4z1 committed Apr 5, 2017
1 parent 0ed9863 commit 6bf732f
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
12 changes: 12 additions & 0 deletions src/gui/qt/startwindow/startwindowimpl.cpp
Expand Up @@ -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."),
Expand Down
13 changes: 11 additions & 2 deletions src/net/common/clientstate.cpp
Expand Up @@ -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());
}
}
}
}
Expand All @@ -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);
}
}
}

Expand Down
2 changes: 2 additions & 0 deletions src/net/socket_msg.h
Expand Up @@ -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
Expand Down

0 comments on commit 6bf732f

Please sign in to comment.