mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-11-26 17:16:20 +00:00
Changed: Minor changes
This commit is contained in:
parent
535f5b8bde
commit
44c61c03e5
1 changed files with 15 additions and 15 deletions
|
@ -109,7 +109,7 @@ CMySQLResult::CMySQLResult(MYSQL_RES* res)
|
||||||
|
|
||||||
/// Constructor
|
/// Constructor
|
||||||
CMySQLResult::CMySQLResult(MYSQL* database)
|
CMySQLResult::CMySQLResult(MYSQL* database)
|
||||||
{
|
{
|
||||||
_Result = mysql_store_result(database);
|
_Result = mysql_store_result(database);
|
||||||
}
|
}
|
||||||
/// Destructor
|
/// Destructor
|
||||||
|
@ -174,7 +174,7 @@ MYSQL_ROW CMySQLResult::fetchRow()
|
||||||
/* ***************************************************************************
|
/* ***************************************************************************
|
||||||
Doc :
|
Doc :
|
||||||
|
|
||||||
When an entity is added in the service mirror, the service checks if its name is in the name cache. If
|
When an entity is added in the service mirror, the service checks if its name is in the name cache. If
|
||||||
the string ID is not known, the server ask the IOS for the string.
|
the string ID is not known, the server ask the IOS for the string.
|
||||||
|
|
||||||
When the IOS sends back a string, the server broadcasts this string to the connected clients.
|
When the IOS sends back a string, the server broadcasts this string to the connected clients.
|
||||||
|
@ -275,7 +275,7 @@ void clientWantsToConnect ( TSockId from, void *arg )
|
||||||
nlinfo ("Add client %d", Clients.size());
|
nlinfo ("Add client %d", Clients.size());
|
||||||
Clients.push_back (new CMonitorClient(from));
|
Clients.push_back (new CMonitorClient(from));
|
||||||
|
|
||||||
|
|
||||||
CMonitorService &ms = getMonitorService();
|
CMonitorService &ms = getMonitorService();
|
||||||
|
|
||||||
// send params about this sever the client
|
// send params about this sever the client
|
||||||
|
@ -284,7 +284,7 @@ void clientWantsToConnect ( TSockId from, void *arg )
|
||||||
uint32 version = 0;
|
uint32 version = 0;
|
||||||
msgout.serial(version);
|
msgout.serial(version);
|
||||||
msgout.serial(ms.LoginRequired);
|
msgout.serial(ms.LoginRequired);
|
||||||
Server->send(msgout, from);
|
Server->send(msgout, from);
|
||||||
Clients.back()->Authentificated = !ms.LoginRequired;
|
Clients.back()->Authentificated = !ms.LoginRequired;
|
||||||
|
|
||||||
|
|
||||||
|
@ -333,7 +333,7 @@ void clientSetWindow (CMessage &msgin, TSockId from, CCallbackNetBase &netbase)
|
||||||
for (uint i = 0; i < Clients.size(); ++i)
|
for (uint i = 0; i < Clients.size(); ++i)
|
||||||
{
|
{
|
||||||
if (Clients[i]->getSock() == from && Clients[i]->Authentificated)
|
if (Clients[i]->getSock() == from && Clients[i]->Authentificated)
|
||||||
{
|
{
|
||||||
nlinfo ("Client %d sets window (%.0f,%.0f) (%.0f,%.0f)", i, xmin, ymin, xmax, ymax);
|
nlinfo ("Client %d sets window (%.0f,%.0f) (%.0f,%.0f)", i, xmin, ymin, xmax, ymax);
|
||||||
Clients[i]->setWindow(xmin,ymin,xmax,ymax);
|
Clients[i]->setWindow(xmin,ymin,xmax,ymax);
|
||||||
Clients[i]->resetVision();
|
Clients[i]->resetVision();
|
||||||
|
@ -377,7 +377,7 @@ void clientAuthentication(CMessage &msgin, TSockId from, CCallbackNetBase &netba
|
||||||
{
|
{
|
||||||
if (!Clients[i]->Authentificated && Clients[i]->getSock() == from)
|
if (!Clients[i]->Authentificated && Clients[i]->getSock() == from)
|
||||||
{
|
{
|
||||||
if (!Clients[i]->BadLogin) // don't allow new login attempt while thisflag is set
|
if (!Clients[i]->BadLogin) // don't allow new login attempt while this flag is set
|
||||||
{
|
{
|
||||||
// escape login
|
// escape login
|
||||||
char esccapedLogin[100];
|
char esccapedLogin[100];
|
||||||
|
@ -391,7 +391,7 @@ void clientAuthentication(CMessage &msgin, TSockId from, CCallbackNetBase &netba
|
||||||
CMySQLResult sqlResult(DatabaseConnection);
|
CMySQLResult sqlResult(DatabaseConnection);
|
||||||
if (sqlResult.success() && sqlResult.numRows() == 1)
|
if (sqlResult.success() && sqlResult.numRows() == 1)
|
||||||
{
|
{
|
||||||
MYSQL_ROW row = sqlResult.fetchRow();
|
MYSQL_ROW row = sqlResult.fetchRow();
|
||||||
if (sqlResult.numFields() == 1)
|
if (sqlResult.numFields() == 1)
|
||||||
{
|
{
|
||||||
if (strlen(row[0]) > 2)
|
if (strlen(row[0]) > 2)
|
||||||
|
@ -411,19 +411,19 @@ void clientAuthentication(CMessage &msgin, TSockId from, CCallbackNetBase &netba
|
||||||
Clients[i]->Authentificated = true;
|
Clients[i]->Authentificated = true;
|
||||||
// password is good
|
// password is good
|
||||||
CMessage msgout;
|
CMessage msgout;
|
||||||
msgout.setType("AUTHENT_VALID");
|
msgout.setType("AUTHENT_VALID");
|
||||||
Server->send(msgout, from);
|
Server->send(msgout, from);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// fail the authentication
|
// fail the authentication
|
||||||
// Do not send result immediatly to avoid a potential hacker
|
// Do not send result immediatly to avoid a potential hacker
|
||||||
// to try a dictionnary or that dort of things
|
// to try a dictionnary or that dort of things
|
||||||
BadLoginClients.insert(std::pair<NLMISC::TTime, NLMISC::CRefPtr<CMonitorClient> >(
|
BadLoginClients.insert(std::pair<NLMISC::TTime, NLMISC::CRefPtr<CMonitorClient> >(
|
||||||
NLMISC::CTime::getLocalTime() + LOGIN_RETRY_DELAY_IN_MILLISECONDS,
|
NLMISC::CTime::getLocalTime() + LOGIN_RETRY_DELAY_IN_MILLISECONDS,
|
||||||
(NLMISC::CRefPtr<CMonitorClient>)Clients[i]));
|
(NLMISC::CRefPtr<CMonitorClient>)Clients[i]));
|
||||||
Clients[i]->BadLogin =true;
|
Clients[i]->BadLogin =true;
|
||||||
return;
|
return;
|
||||||
|
@ -531,9 +531,9 @@ void CMonitorService::init ()
|
||||||
|
|
||||||
// ***************************************************************************
|
// ***************************************************************************
|
||||||
|
|
||||||
void CMonitorService::release ()
|
void CMonitorService::release ()
|
||||||
{
|
{
|
||||||
disconnectFromDatabase();
|
disconnectFromDatabase();
|
||||||
// release sub systems
|
// release sub systems
|
||||||
// CMessages::release();
|
// CMessages::release();
|
||||||
CMirrors::release();
|
CMirrors::release();
|
||||||
|
@ -572,7 +572,7 @@ bool CMonitorService::update ()
|
||||||
client.update();
|
client.update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sent bad login msg to clients at the right time
|
// Sent bad login msg to clients at the right time
|
||||||
NLMISC::TTime currentTime = NLMISC::CTime::getLocalTime();
|
NLMISC::TTime currentTime = NLMISC::CTime::getLocalTime();
|
||||||
while (!BadLoginClients.empty() && BadLoginClients.begin()->first <= currentTime)
|
while (!BadLoginClients.empty() && BadLoginClients.begin()->first <= currentTime)
|
||||||
|
@ -581,9 +581,9 @@ bool CMonitorService::update ()
|
||||||
if (client != NULL)
|
if (client != NULL)
|
||||||
{
|
{
|
||||||
CMessage msgout;
|
CMessage msgout;
|
||||||
msgout.setType("AUTHENT_INVALID");
|
msgout.setType("AUTHENT_INVALID");
|
||||||
Server->send(msgout, client->getSock());
|
Server->send(msgout, client->getSock());
|
||||||
client->BadLogin = false; // allow to accept login again for that client
|
client->BadLogin = false; // allow to accept login again for that client
|
||||||
}
|
}
|
||||||
BadLoginClients.erase(BadLoginClients.begin());
|
BadLoginClients.erase(BadLoginClients.begin());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue