Added server side setting to allow the requirement of a client id from clients.
This commit is contained in:
parent
94942e1a92
commit
bc99024e4f
8 changed files with 18 additions and 5 deletions
|
@ -316,6 +316,9 @@ void MainWindow::loginError(Response::ResponseCode r, QString reasonStr, quint32
|
||||||
actRegister();
|
actRegister();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case Response::RespClientIdRequired:
|
||||||
|
QMessageBox::critical(this, tr("Error"), tr("This server requires client ID's. Your client is either failing to generate an ID or you are running a modified client.\nPlease close and reopen your client to try again."));
|
||||||
|
break;
|
||||||
case Response::RespAccountNotActivated: {
|
case Response::RespAccountNotActivated: {
|
||||||
bool ok = false;
|
bool ok = false;
|
||||||
QString token = QInputDialog::getText(this, tr("Account activation"), tr("Your account has not been activated yet.\nYou need to provide the activation token received in the activation email"), QLineEdit::Normal, QString(), &ok);
|
QString token = QInputDialog::getText(this, tr("Account activation"), tr("Your account has not been activated yet.\nYou need to provide the activation token received in the activation email"), QLineEdit::Normal, QString(), &ok);
|
||||||
|
|
|
@ -35,7 +35,7 @@ message Response {
|
||||||
RespActivationAccepted = 31; // Server accepted a reg user activation token
|
RespActivationAccepted = 31; // Server accepted a reg user activation token
|
||||||
RespActivationFailed = 32; // Server didn't accept a reg user activation token
|
RespActivationFailed = 32; // Server didn't accept a reg user activation token
|
||||||
RespRegistrationAcceptedNeedsActivation = 33; // Server accepted cient registration, but it will need token activation
|
RespRegistrationAcceptedNeedsActivation = 33; // Server accepted cient registration, but it will need token activation
|
||||||
RespClientIDRequired = 34; // Server requires client to generate and send its client id before allowing access
|
RespClientIdRequired = 34; // Server requires client to generate and send its client id before allowing access
|
||||||
}
|
}
|
||||||
enum ResponseType {
|
enum ResponseType {
|
||||||
JOIN_ROOM = 1000;
|
JOIN_ROOM = 1000;
|
||||||
|
|
|
@ -172,6 +172,8 @@ AuthenticationResult Server::loginUser(Server_ProtocolHandler *session, QString
|
||||||
|
|
||||||
if (clientid.isEmpty()){
|
if (clientid.isEmpty()){
|
||||||
// client id is empty, either out dated client or client has been modified
|
// client id is empty, either out dated client or client has been modified
|
||||||
|
if (getClientIdRequired())
|
||||||
|
return ClientIdRequired;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// update users database table with client id
|
// update users database table with client id
|
||||||
|
|
|
@ -28,7 +28,7 @@ class GameEventContainer;
|
||||||
class CommandContainer;
|
class CommandContainer;
|
||||||
class Command_JoinGame;
|
class Command_JoinGame;
|
||||||
|
|
||||||
enum AuthenticationResult { NotLoggedIn, PasswordRight, UnknownUser, WouldOverwriteOldSession, UserIsBanned, UsernameInvalid, RegistrationRequired, UserIsInactive };
|
enum AuthenticationResult { NotLoggedIn, PasswordRight, UnknownUser, WouldOverwriteOldSession, UserIsBanned, UsernameInvalid, RegistrationRequired, UserIsInactive, ClientIdRequired };
|
||||||
|
|
||||||
class Server : public QObject
|
class Server : public QObject
|
||||||
{
|
{
|
||||||
|
@ -56,6 +56,7 @@ public:
|
||||||
virtual QString getLoginMessage() const { return QString(); }
|
virtual QString getLoginMessage() const { return QString(); }
|
||||||
|
|
||||||
virtual bool getGameShouldPing() const { return false; }
|
virtual bool getGameShouldPing() const { return false; }
|
||||||
|
virtual bool getClientIdRequired() const { return false; }
|
||||||
virtual int getPingClockInterval() const { return 0; }
|
virtual int getPingClockInterval() const { return 0; }
|
||||||
virtual int getMaxGameInactivityTime() const { return 9999999; }
|
virtual int getMaxGameInactivityTime() const { return 9999999; }
|
||||||
virtual int getMaxPlayerInactivityTime() const { return 9999999; }
|
virtual int getMaxPlayerInactivityTime() const { return 9999999; }
|
||||||
|
|
|
@ -409,6 +409,7 @@ Response::ResponseCode Server_ProtocolHandler::cmdLogin(const Command_Login &cmd
|
||||||
return Response::RespUsernameInvalid;
|
return Response::RespUsernameInvalid;
|
||||||
}
|
}
|
||||||
case RegistrationRequired: return Response::RespRegistrationRequired;
|
case RegistrationRequired: return Response::RespRegistrationRequired;
|
||||||
|
case ClientIdRequired: return Response::RespClientIdRequired;
|
||||||
case UserIsInactive: return Response::RespAccountNotActivated;
|
case UserIsInactive: return Response::RespAccountNotActivated;
|
||||||
default: authState = res;
|
default: authState = res;
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,6 +46,9 @@ clientkeepalive=1
|
||||||
; considered disconnected; default is 15
|
; considered disconnected; default is 15
|
||||||
max_player_inactivity_time=15
|
max_player_inactivity_time=15
|
||||||
|
|
||||||
|
; More modern clients generate client IDs based on specific client side information. Enable this option to
|
||||||
|
' require that clients report the client ID in order to log into the server. Default is false
|
||||||
|
requireclientid=false
|
||||||
|
|
||||||
[authentication]
|
[authentication]
|
||||||
|
|
||||||
|
|
|
@ -142,8 +142,9 @@ bool Servatrice::initServer()
|
||||||
{
|
{
|
||||||
serverName = settingsCache->value("server/name", "My Cockatrice server").toString();
|
serverName = settingsCache->value("server/name", "My Cockatrice server").toString();
|
||||||
serverId = settingsCache->value("server/id", 0).toInt();
|
serverId = settingsCache->value("server/id", 0).toInt();
|
||||||
|
clientIdRequired = settingsCache->value("server/requireclientid",0).toBool();
|
||||||
bool regServerOnly = settingsCache->value("authentication/regonly", 0).toBool();
|
bool regServerOnly = settingsCache->value("authentication/regonly", 0).toBool();
|
||||||
|
|
||||||
const QString authenticationMethodStr = settingsCache->value("authentication/method").toString();
|
const QString authenticationMethodStr = settingsCache->value("authentication/method").toString();
|
||||||
if (authenticationMethodStr == "sql") {
|
if (authenticationMethodStr == "sql") {
|
||||||
qDebug() << "Authenticating method: sql";
|
qDebug() << "Authenticating method: sql";
|
||||||
|
@ -160,7 +161,8 @@ bool Servatrice::initServer()
|
||||||
qDebug() << "Authenticating method: none";
|
qDebug() << "Authenticating method: none";
|
||||||
authenticationMethod = AuthenticationNone;
|
authenticationMethod = AuthenticationNone;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
qDebug() << "Client ID Required: " << clientIdRequired;
|
||||||
bool maxUserLimitEnabled = settingsCache->value("security/enable_max_user_limit", false).toBool();
|
bool maxUserLimitEnabled = settingsCache->value("security/enable_max_user_limit", false).toBool();
|
||||||
qDebug() << "Maximum user limit enabled: " << maxUserLimitEnabled;
|
qDebug() << "Maximum user limit enabled: " << maxUserLimitEnabled;
|
||||||
|
|
||||||
|
|
|
@ -120,7 +120,7 @@ private:
|
||||||
QString shutdownReason;
|
QString shutdownReason;
|
||||||
int shutdownMinutes;
|
int shutdownMinutes;
|
||||||
QTimer *shutdownTimer;
|
QTimer *shutdownTimer;
|
||||||
bool isFirstShutdownMessage;
|
bool isFirstShutdownMessage, clientIdRequired;
|
||||||
|
|
||||||
mutable QMutex serverListMutex;
|
mutable QMutex serverListMutex;
|
||||||
QList<ServerProperties> serverList;
|
QList<ServerProperties> serverList;
|
||||||
|
@ -137,6 +137,7 @@ public:
|
||||||
QString getServerName() const { return serverName; }
|
QString getServerName() const { return serverName; }
|
||||||
QString getLoginMessage() const { QMutexLocker locker(&loginMessageMutex); return loginMessage; }
|
QString getLoginMessage() const { QMutexLocker locker(&loginMessageMutex); return loginMessage; }
|
||||||
bool getGameShouldPing() const { return true; }
|
bool getGameShouldPing() const { return true; }
|
||||||
|
bool getClientIdRequired() const { return clientIdRequired; }
|
||||||
int getPingClockInterval() const { return pingClockInterval; }
|
int getPingClockInterval() const { return pingClockInterval; }
|
||||||
int getMaxGameInactivityTime() const { return maxGameInactivityTime; }
|
int getMaxGameInactivityTime() const { return maxGameInactivityTime; }
|
||||||
int getMaxPlayerInactivityTime() const { return maxPlayerInactivityTime; }
|
int getMaxPlayerInactivityTime() const { return maxPlayerInactivityTime; }
|
||||||
|
|
Loading…
Reference in a new issue