|
@@ -8,34 +8,33 @@
|
|
// Inhalt der MainServer Klasse aus MainServer.h
|
|
// Inhalt der MainServer Klasse aus MainServer.h
|
|
// Konstruktor
|
|
// Konstruktor
|
|
MainServer::MainServer( InitDatei *zDat )
|
|
MainServer::MainServer( InitDatei *zDat )
|
|
-: Thread()
|
|
|
|
|
|
+ : Thread()
|
|
{
|
|
{
|
|
sslServerThread = 0;
|
|
sslServerThread = 0;
|
|
- Network::Start( 100 );
|
|
|
|
- std::cout << "MS: Verbindung mit Datenbank wird hergestellt...\n";
|
|
|
|
- db = new MSDatenbank( zDat );
|
|
|
|
- clients = 0;
|
|
|
|
- empfangen = 0;
|
|
|
|
- gesendet = 0;
|
|
|
|
- dat = zDat->getThis();
|
|
|
|
|
|
+ Network::Start( 100 );
|
|
|
|
+ std::cout << "MS: Verbindung mit Datenbank wird hergestellt...\n";
|
|
|
|
+ db = new MSDatenbank( zDat );
|
|
|
|
+ clients = 0;
|
|
|
|
+ empfangen = 0;
|
|
|
|
+ gesendet = 0;
|
|
|
|
+ dat = zDat->getThis();
|
|
serverSSL = new SSLServer();
|
|
serverSSL = new SSLServer();
|
|
serverSSL->setPrivateKeyPassword( zDat->zWert( "SSLPasswort" )->getText() );
|
|
serverSSL->setPrivateKeyPassword( zDat->zWert( "SSLPasswort" )->getText() );
|
|
serverSSL->setCertificateFile( zDat->zWert( "SSLCert" )->getText() );
|
|
serverSSL->setCertificateFile( zDat->zWert( "SSLCert" )->getText() );
|
|
serverSSL->setPrivateKeyFile( zDat->zWert( "SSLKey" )->getText() );
|
|
serverSSL->setPrivateKeyFile( zDat->zWert( "SSLKey" )->getText() );
|
|
- server = new Server();
|
|
|
|
- aServer = new SSLServer();
|
|
|
|
|
|
+ server = new Server();
|
|
|
|
+ aServer = new SSLServer();
|
|
aServer->setPrivateKeyPassword( zDat->zWert( "SSLPasswort" )->getText() );
|
|
aServer->setPrivateKeyPassword( zDat->zWert( "SSLPasswort" )->getText() );
|
|
aServer->setCertificateFile( zDat->zWert( "SSLCert" )->getText() );
|
|
aServer->setCertificateFile( zDat->zWert( "SSLCert" )->getText() );
|
|
aServer->setPrivateKeyFile( zDat->zWert( "SSLKey" )->getText() );
|
|
aServer->setPrivateKeyFile( zDat->zWert( "SSLKey" )->getText() );
|
|
- std::cout << "MS: Starten des Admin Servers...\n";
|
|
|
|
- if( !aServer->verbinde( (unsigned short)TextZuInt( zDat->zWert( "AdminServerPort" )->getText(), 10 ), 10 ) )
|
|
|
|
- {
|
|
|
|
- std::cout << "MS: Der Admin Server konnte nicht gestartet werden. Das Programm wird beendet.\n";
|
|
|
|
- exit( 1 );
|
|
|
|
- }
|
|
|
|
- end = 0;
|
|
|
|
- InitializeCriticalSection( &cs );
|
|
|
|
- ref = 1;
|
|
|
|
|
|
+ std::cout << "MS: Starten des Admin Servers...\n";
|
|
|
|
+ if( !aServer->verbinde( (unsigned short)TextZuInt( zDat->zWert( "AdminServerPort" )->getText(), 10 ), 10 ) )
|
|
|
|
+ {
|
|
|
|
+ std::cout << "MS: Der Admin Server konnte nicht gestartet werden. Das Programm wird beendet.\n";
|
|
|
|
+ exit( 1 );
|
|
|
|
+ }
|
|
|
|
+ end = 0;
|
|
|
|
+ InitializeCriticalSection( &cs );
|
|
if( zDat->zWert( "Aktiv" )->istGleich( "TRUE" ) )
|
|
if( zDat->zWert( "Aktiv" )->istGleich( "TRUE" ) )
|
|
serverStarten();
|
|
serverStarten();
|
|
}
|
|
}
|
|
@@ -43,40 +42,40 @@ MainServer::MainServer( InitDatei *zDat )
|
|
// Destruktor
|
|
// Destruktor
|
|
MainServer::~MainServer()
|
|
MainServer::~MainServer()
|
|
{
|
|
{
|
|
- ende();
|
|
|
|
|
|
+ ende();
|
|
serverSSL->trenne();
|
|
serverSSL->trenne();
|
|
if( sslServerThread )
|
|
if( sslServerThread )
|
|
delete sslServerThread;
|
|
delete sslServerThread;
|
|
serverSSL->release();
|
|
serverSSL->release();
|
|
- server->trenne();
|
|
|
|
- server->release();
|
|
|
|
- aServer->trenne();
|
|
|
|
- aServer->release();
|
|
|
|
- dat->release();
|
|
|
|
- db->release();
|
|
|
|
- Network::Exit();
|
|
|
|
- DeleteCriticalSection( &cs );
|
|
|
|
|
|
+ server->trenne();
|
|
|
|
+ server->release();
|
|
|
|
+ aServer->trenne();
|
|
|
|
+ aServer->release();
|
|
|
|
+ dat->release();
|
|
|
|
+ db->release();
|
|
|
|
+ Network::Exit();
|
|
|
|
+ DeleteCriticalSection( &cs );
|
|
}
|
|
}
|
|
|
|
|
|
// nicht constant
|
|
// nicht constant
|
|
void MainServer::runn()
|
|
void MainServer::runn()
|
|
{
|
|
{
|
|
- while( !end && aServer->isConnected() )
|
|
|
|
- {
|
|
|
|
- SSLSKlient *klient;
|
|
|
|
- klient = aServer->getKlient();
|
|
|
|
- if( end && klient )
|
|
|
|
- {
|
|
|
|
- klient->trenne();
|
|
|
|
- klient = klient->release();
|
|
|
|
- Sleep( 1000 );
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
- if( !klient )
|
|
|
|
- continue;
|
|
|
|
- MSAKlient *clHandle = new MSAKlient( klient, getThis() );
|
|
|
|
- clHandle->start();
|
|
|
|
- }
|
|
|
|
|
|
+ while( !end && aServer->isConnected() )
|
|
|
|
+ {
|
|
|
|
+ SSLSKlient *klient;
|
|
|
|
+ klient = aServer->getKlient();
|
|
|
|
+ if( end && klient )
|
|
|
|
+ {
|
|
|
|
+ klient->trenne();
|
|
|
|
+ klient = klient->release();
|
|
|
|
+ Sleep( 1000 );
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ if( !klient )
|
|
|
|
+ continue;
|
|
|
|
+ MSAKlient * clHandle = new MSAKlient( klient, (MainServer *)getThis() );
|
|
|
|
+ clHandle->start();
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
void MainServer::thread()
|
|
void MainServer::thread()
|
|
@@ -84,7 +83,7 @@ void MainServer::thread()
|
|
MainServer *ms = this;
|
|
MainServer *ms = this;
|
|
if( sslServerThread )
|
|
if( sslServerThread )
|
|
delete sslServerThread;
|
|
delete sslServerThread;
|
|
- sslServerThread = new AsynchronCall( [ ms ]()
|
|
|
|
|
|
+ sslServerThread = new AsynchronCall( [ ms ]()
|
|
{
|
|
{
|
|
while( ms->serverSSL->isConnected() )
|
|
while( ms->serverSSL->isConnected() )
|
|
{
|
|
{
|
|
@@ -99,96 +98,96 @@ void MainServer::thread()
|
|
if( !klient )
|
|
if( !klient )
|
|
continue;
|
|
continue;
|
|
Framework::getThreadRegister()->cleanUpClosedThreads();
|
|
Framework::getThreadRegister()->cleanUpClosedThreads();
|
|
- MSKlientSSL *clHandle = new MSKlientSSL( klient, ms->getThis() );
|
|
|
|
|
|
+ MSKlientSSL * clHandle = new MSKlientSSL( klient, (MainServer *)ms->getThis() );
|
|
clHandle->start();
|
|
clHandle->start();
|
|
ms->clients++;
|
|
ms->clients++;
|
|
}
|
|
}
|
|
} );
|
|
} );
|
|
- while( server->isConnected() )
|
|
|
|
- {
|
|
|
|
- SKlient *klient;
|
|
|
|
- klient = server->getKlient();
|
|
|
|
- if( !klient )
|
|
|
|
- continue;
|
|
|
|
- Framework::getThreadRegister()->cleanUpClosedThreads();
|
|
|
|
- MSKlient *clHandle = new MSKlient( klient, getThis() );
|
|
|
|
- clHandle->start();
|
|
|
|
- clients++;
|
|
|
|
- }
|
|
|
|
- run = 0;
|
|
|
|
|
|
+ while( server->isConnected() )
|
|
|
|
+ {
|
|
|
|
+ SKlient *klient;
|
|
|
|
+ klient = server->getKlient();
|
|
|
|
+ if( !klient )
|
|
|
|
+ continue;
|
|
|
|
+ Framework::getThreadRegister()->cleanUpClosedThreads();
|
|
|
|
+ MSKlient * clHandle = new MSKlient( klient, (MainServer *)getThis() );
|
|
|
|
+ clHandle->start();
|
|
|
|
+ clients++;
|
|
|
|
+ }
|
|
|
|
+ run = 0;
|
|
}
|
|
}
|
|
|
|
|
|
void MainServer::close()
|
|
void MainServer::close()
|
|
{
|
|
{
|
|
serverSSL->trenne();
|
|
serverSSL->trenne();
|
|
- server->trenne();
|
|
|
|
|
|
+ server->trenne();
|
|
#ifdef WIN32
|
|
#ifdef WIN32
|
|
- warteAufThread( 1000 );
|
|
|
|
|
|
+ warteAufThread( 1000 );
|
|
#endif
|
|
#endif
|
|
- ende();
|
|
|
|
- run = 0;
|
|
|
|
- end = 1;
|
|
|
|
- Klient *klient = new Klient();
|
|
|
|
- klient->verbinde( aServer->getPort(), "127.0.0.1" );
|
|
|
|
- Sleep( 500 );
|
|
|
|
- aServer->trenne();
|
|
|
|
- klient->release();
|
|
|
|
|
|
+ ende();
|
|
|
|
+ run = 0;
|
|
|
|
+ end = 1;
|
|
|
|
+ Klient *klient = new Klient();
|
|
|
|
+ klient->verbinde( aServer->getPort(), "127.0.0.1" );
|
|
|
|
+ Sleep( 500 );
|
|
|
|
+ aServer->trenne();
|
|
|
|
+ klient->release();
|
|
}
|
|
}
|
|
|
|
|
|
bool MainServer::serverStarten()
|
|
bool MainServer::serverStarten()
|
|
{
|
|
{
|
|
- if( run )
|
|
|
|
- return 1;
|
|
|
|
- bool ret = server->verbinde( (unsigned short)TextZuInt( dat->zWert( "ServerPort" )->getText(), 10 ), 10 );
|
|
|
|
|
|
+ if( run )
|
|
|
|
+ return 1;
|
|
|
|
+ bool ret = server->verbinde( (unsigned short)TextZuInt( dat->zWert( "ServerPort" )->getText(), 10 ), 10 );
|
|
ret &= serverSSL->verbinde( (unsigned short)TextZuInt( dat->zWert( "SSLPort" )->getText(), 10 ), 10 );
|
|
ret &= serverSSL->verbinde( (unsigned short)TextZuInt( dat->zWert( "SSLPort" )->getText(), 10 ), 10 );
|
|
- start();
|
|
|
|
- return ret;
|
|
|
|
|
|
+ start();
|
|
|
|
+ return ret;
|
|
}
|
|
}
|
|
|
|
|
|
void MainServer::serverBeenden()
|
|
void MainServer::serverBeenden()
|
|
{
|
|
{
|
|
- if( !run )
|
|
|
|
- return;
|
|
|
|
- server->trenne();
|
|
|
|
|
|
+ if( !run )
|
|
|
|
+ return;
|
|
|
|
+ server->trenne();
|
|
serverSSL->trenne();
|
|
serverSSL->trenne();
|
|
#ifdef WIN32
|
|
#ifdef WIN32
|
|
- warteAufThread( 1000 );
|
|
|
|
|
|
+ warteAufThread( 1000 );
|
|
#endif
|
|
#endif
|
|
- ende();
|
|
|
|
- server->release();
|
|
|
|
- server = new Server();
|
|
|
|
- run = 0;
|
|
|
|
|
|
+ ende();
|
|
|
|
+ server->release();
|
|
|
|
+ server = new Server();
|
|
|
|
+ run = 0;
|
|
}
|
|
}
|
|
|
|
|
|
void MainServer::addGesendet( int bytes )
|
|
void MainServer::addGesendet( int bytes )
|
|
{
|
|
{
|
|
- gesendet += bytes;
|
|
|
|
|
|
+ gesendet += bytes;
|
|
}
|
|
}
|
|
|
|
|
|
void MainServer::addEmpfangen( int bytes )
|
|
void MainServer::addEmpfangen( int bytes )
|
|
{
|
|
{
|
|
- empfangen += empfangen;
|
|
|
|
|
|
+ empfangen += empfangen;
|
|
}
|
|
}
|
|
|
|
|
|
void MainServer::clientTrennung()
|
|
void MainServer::clientTrennung()
|
|
{
|
|
{
|
|
- clients--;
|
|
|
|
|
|
+ clients--;
|
|
}
|
|
}
|
|
|
|
|
|
// constant
|
|
// constant
|
|
Server *MainServer::zServer() const
|
|
Server *MainServer::zServer() const
|
|
{
|
|
{
|
|
- return server;
|
|
|
|
|
|
+ return server;
|
|
}
|
|
}
|
|
|
|
|
|
MSDatenbank *MainServer::zDB() const
|
|
MSDatenbank *MainServer::zDB() const
|
|
{
|
|
{
|
|
- return db;
|
|
|
|
|
|
+ return db;
|
|
}
|
|
}
|
|
|
|
|
|
bool MainServer::hatClients() const
|
|
bool MainServer::hatClients() const
|
|
{
|
|
{
|
|
- return clients > 0;
|
|
|
|
|
|
+ return clients > 0;
|
|
}
|
|
}
|
|
|
|
|
|
InitDatei *MainServer::zInit() const
|
|
InitDatei *MainServer::zInit() const
|
|
@@ -196,222 +195,203 @@ InitDatei *MainServer::zInit() const
|
|
return dat;
|
|
return dat;
|
|
}
|
|
}
|
|
|
|
|
|
-// Reference Counting
|
|
|
|
-MainServer *MainServer::getThis()
|
|
|
|
-{
|
|
|
|
- EnterCriticalSection( &cs );
|
|
|
|
- ref++;
|
|
|
|
- LeaveCriticalSection( &cs );
|
|
|
|
- return this;
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-MainServer *MainServer::release()
|
|
|
|
-{
|
|
|
|
- EnterCriticalSection( &cs );
|
|
|
|
- ref--;
|
|
|
|
- LeaveCriticalSection( &cs );
|
|
|
|
- if( !ref )
|
|
|
|
- delete this;
|
|
|
|
- return 0;
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
|
|
|
|
// Inhalt der MSKlient Klasse aus MainServer.h
|
|
// Inhalt der MSKlient Klasse aus MainServer.h
|
|
// Konstruktor
|
|
// Konstruktor
|
|
-MSAKlient::MSAKlient( SSLSKlient *klient, MainServer *ms )
|
|
|
|
-: Thread()
|
|
|
|
|
|
+MSAKlient::MSAKlient( SSLSKlient * klient, MainServer * ms )
|
|
|
|
+ : Thread()
|
|
{
|
|
{
|
|
- this->klient = klient;
|
|
|
|
- name = new Text( "" );
|
|
|
|
- passwort = new Text( "" );
|
|
|
|
- adminId = 0;
|
|
|
|
- this->ms = ms;
|
|
|
|
|
|
+ this->klient = klient;
|
|
|
|
+ name = new Text( "" );
|
|
|
|
+ passwort = new Text( "" );
|
|
|
|
+ adminId = 0;
|
|
|
|
+ this->ms = ms;
|
|
}
|
|
}
|
|
|
|
|
|
// Destruktor
|
|
// Destruktor
|
|
MSAKlient::~MSAKlient()
|
|
MSAKlient::~MSAKlient()
|
|
{
|
|
{
|
|
- klient->trenne();
|
|
|
|
- klient->release();
|
|
|
|
- ms->release();
|
|
|
|
- name->release();
|
|
|
|
- passwort->release();
|
|
|
|
|
|
+ klient->trenne();
|
|
|
|
+ klient->release();
|
|
|
|
+ ms->release();
|
|
|
|
+ name->release();
|
|
|
|
+ passwort->release();
|
|
}
|
|
}
|
|
|
|
|
|
// nicht constant
|
|
// nicht constant
|
|
void MSAKlient::thread()
|
|
void MSAKlient::thread()
|
|
{
|
|
{
|
|
- while( 1 )
|
|
|
|
- {
|
|
|
|
- char c = 0;
|
|
|
|
- if( !klient->getNachricht( &c, 1 ) )
|
|
|
|
- break;
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- bool br = 0;
|
|
|
|
- switch( c )
|
|
|
|
- {
|
|
|
|
- case 1: // Login
|
|
|
|
- if( 1 )
|
|
|
|
- {
|
|
|
|
- klient->sende( "\1", 1 );
|
|
|
|
- unsigned char nLen = 0;
|
|
|
|
- klient->getNachricht( (char*)&nLen, 1 );
|
|
|
|
- char *n = new char[ nLen + 1 ];
|
|
|
|
- n[ (int)nLen ] = 0;
|
|
|
|
- if( nLen )
|
|
|
|
- klient->getNachricht( n, nLen );
|
|
|
|
- unsigned char pLen = 0;
|
|
|
|
- klient->getNachricht( (char*)&pLen, 1 );
|
|
|
|
- char *p = new char[ pLen + 1 ];
|
|
|
|
- p[ (int)pLen ] = 0;
|
|
|
|
- if( pLen )
|
|
|
|
- klient->getNachricht( p, pLen );
|
|
|
|
- int adminId = ms->zDB()->istAdministrator( n, p );
|
|
|
|
- if( adminId )
|
|
|
|
- {
|
|
|
|
- klient->sende( "\1", 1 );
|
|
|
|
- name->setText( n );
|
|
|
|
- passwort->setText( p );
|
|
|
|
- this->adminId = adminId;
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- errorZuKlient( "Falsche Kombination aus Name und Passwort." );
|
|
|
|
- delete[] n;
|
|
|
|
- delete[] p;
|
|
|
|
- }
|
|
|
|
- break;
|
|
|
|
- case 2: // Logout
|
|
|
|
- adminId = 0;
|
|
|
|
- name->setText( "" );
|
|
|
|
- passwort->setText( "" );
|
|
|
|
- klient->sende( "\1", 1 );
|
|
|
|
- break;
|
|
|
|
- case 3: // Trennen
|
|
|
|
- br = 1;
|
|
|
|
- klient->sende( "\1", 1 );
|
|
|
|
- break;
|
|
|
|
- case 4: // Server starten
|
|
|
|
- if( !adminId )
|
|
|
|
- errorZuKlient( "Du musst dich einloggen." );
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- if( ms->zDB()->adminHatRecht( adminId, Admin_Recht::MSStarten ) )
|
|
|
|
- {
|
|
|
|
- if( !ms->serverStarten() )
|
|
|
|
- errorZuKlient( "Beim starten des Servers ist ein Fehler aufgetreten." );
|
|
|
|
- else
|
|
|
|
- klient->sende( "\1", 1 );
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- errorZuKlient( "Du bist nicht berechtigt den Server zu starten." );
|
|
|
|
- }
|
|
|
|
- break;
|
|
|
|
- case 5: // Server beenden
|
|
|
|
- if( !adminId )
|
|
|
|
- errorZuKlient( "Du musst dich einloggen." );
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- if( ms->zDB()->adminHatRecht( adminId, Admin_Recht::MSBeenden ) )
|
|
|
|
- {
|
|
|
|
- ms->serverBeenden();
|
|
|
|
- klient->sende( "\1", 1 );
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- errorZuKlient( "Du bist nicht berechtigt den Server zu beenden." );
|
|
|
|
- }
|
|
|
|
- break;
|
|
|
|
- case 6: // Programm Schließen
|
|
|
|
- if( !adminId )
|
|
|
|
- errorZuKlient( "Du musst dich einloggen." );
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- bool ok = 0;
|
|
|
|
- if( ms->isRunning() )
|
|
|
|
- {
|
|
|
|
- if( ms->zDB()->adminHatRecht( adminId, Admin_Recht::MSBeenden ) )
|
|
|
|
- {
|
|
|
|
- ms->serverBeenden();
|
|
|
|
- ok = 1;
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- errorZuKlient( "Du bist nicht berechtigt den Server zu beenden." );
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- ok = 1;
|
|
|
|
- if( ok && ms->hatClients() )
|
|
|
|
- {
|
|
|
|
- errorZuKlient( "Es sind noch Klients Online. Bitte versuche es später erneut." );
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
- if( ok )
|
|
|
|
- {
|
|
|
|
- klient->sende( "\1", 1 );
|
|
|
|
- std::cout << "MS: Der Server wird von Benutzer " << adminId << " heruntergefahren.\n";
|
|
|
|
- ms->close();
|
|
|
|
- br = 1;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- break;
|
|
|
|
- case 7: // Progtamm abstürzen
|
|
|
|
- if( !adminId )
|
|
|
|
- errorZuKlient( "Du musst dich einloggen." );
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- bool ok = 0;
|
|
|
|
- if( ms->isRunning() )
|
|
|
|
- {
|
|
|
|
- if( ms->zDB()->adminHatRecht( adminId, Admin_Recht::MSBeenden ) )
|
|
|
|
- {
|
|
|
|
- ms->serverBeenden();
|
|
|
|
- ok = 1;
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- errorZuKlient( "Du bist nicht berechtigt den Server zu beenden." );
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- ok = 1;
|
|
|
|
- if( ok )
|
|
|
|
- {
|
|
|
|
- klient->sende( "\1", 1 );
|
|
|
|
- std::cout << "MS: Der Server wurde von Benutzer " << adminId << " terminiert.\n";
|
|
|
|
- ms->close();
|
|
|
|
- br = 1;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- break;
|
|
|
|
- case 8: // Status Frage
|
|
|
|
- if( 1 )
|
|
|
|
- {
|
|
|
|
- klient->sende( "\1", 1 );
|
|
|
|
- char status = (int)ms->isRunning();
|
|
|
|
- klient->sende( &status, 1 );
|
|
|
|
- }
|
|
|
|
- break;
|
|
|
|
|
|
+ while( 1 )
|
|
|
|
+ {
|
|
|
|
+ char c = 0;
|
|
|
|
+ if( !klient->getNachricht( &c, 1 ) )
|
|
|
|
+ break;
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ bool br = 0;
|
|
|
|
+ switch( c )
|
|
|
|
+ {
|
|
|
|
+ case 1: // Login
|
|
|
|
+ if( 1 )
|
|
|
|
+ {
|
|
|
|
+ klient->sende( "\1", 1 );
|
|
|
|
+ unsigned char nLen = 0;
|
|
|
|
+ klient->getNachricht( (char *)& nLen, 1 );
|
|
|
|
+ char *n = new char[ nLen + 1 ];
|
|
|
|
+ n[ (int)nLen ] = 0;
|
|
|
|
+ if( nLen )
|
|
|
|
+ klient->getNachricht( n, nLen );
|
|
|
|
+ unsigned char pLen = 0;
|
|
|
|
+ klient->getNachricht( (char *)& pLen, 1 );
|
|
|
|
+ char *p = new char[ pLen + 1 ];
|
|
|
|
+ p[ (int)pLen ] = 0;
|
|
|
|
+ if( pLen )
|
|
|
|
+ klient->getNachricht( p, pLen );
|
|
|
|
+ int adminId = ms->zDB()->istAdministrator( n, p );
|
|
|
|
+ if( adminId )
|
|
|
|
+ {
|
|
|
|
+ klient->sende( "\1", 1 );
|
|
|
|
+ name->setText( n );
|
|
|
|
+ passwort->setText( p );
|
|
|
|
+ this->adminId = adminId;
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ errorZuKlient( "Falsche Kombination aus Name und Passwort." );
|
|
|
|
+ delete[] n;
|
|
|
|
+ delete[] p;
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+ case 2: // Logout
|
|
|
|
+ adminId = 0;
|
|
|
|
+ name->setText( "" );
|
|
|
|
+ passwort->setText( "" );
|
|
|
|
+ klient->sende( "\1", 1 );
|
|
|
|
+ break;
|
|
|
|
+ case 3: // Trennen
|
|
|
|
+ br = 1;
|
|
|
|
+ klient->sende( "\1", 1 );
|
|
|
|
+ break;
|
|
|
|
+ case 4: // Server starten
|
|
|
|
+ if( !adminId )
|
|
|
|
+ errorZuKlient( "Du musst dich einloggen." );
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ if( ms->zDB()->adminHatRecht( adminId, Admin_Recht::MSStarten ) )
|
|
|
|
+ {
|
|
|
|
+ if( !ms->serverStarten() )
|
|
|
|
+ errorZuKlient( "Beim starten des Servers ist ein Fehler aufgetreten." );
|
|
|
|
+ else
|
|
|
|
+ klient->sende( "\1", 1 );
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ errorZuKlient( "Du bist nicht berechtigt den Server zu starten." );
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+ case 5: // Server beenden
|
|
|
|
+ if( !adminId )
|
|
|
|
+ errorZuKlient( "Du musst dich einloggen." );
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ if( ms->zDB()->adminHatRecht( adminId, Admin_Recht::MSBeenden ) )
|
|
|
|
+ {
|
|
|
|
+ ms->serverBeenden();
|
|
|
|
+ klient->sende( "\1", 1 );
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ errorZuKlient( "Du bist nicht berechtigt den Server zu beenden." );
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+ case 6: // Programm Schließen
|
|
|
|
+ if( !adminId )
|
|
|
|
+ errorZuKlient( "Du musst dich einloggen." );
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ bool ok = 0;
|
|
|
|
+ if( ms->isRunning() )
|
|
|
|
+ {
|
|
|
|
+ if( ms->zDB()->adminHatRecht( adminId, Admin_Recht::MSBeenden ) )
|
|
|
|
+ {
|
|
|
|
+ ms->serverBeenden();
|
|
|
|
+ ok = 1;
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ errorZuKlient( "Du bist nicht berechtigt den Server zu beenden." );
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ ok = 1;
|
|
|
|
+ if( ok &&ms->hatClients() )
|
|
|
|
+ {
|
|
|
|
+ errorZuKlient( "Es sind noch Klients Online. Bitte versuche es später erneut." );
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ if( ok )
|
|
|
|
+ {
|
|
|
|
+ klient->sende( "\1", 1 );
|
|
|
|
+ std::cout << "MS: Der Server wird von Benutzer " << adminId << " heruntergefahren.\n";
|
|
|
|
+ ms->close();
|
|
|
|
+ br = 1;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+ case 7: // Progtamm abstürzen
|
|
|
|
+ if( !adminId )
|
|
|
|
+ errorZuKlient( "Du musst dich einloggen." );
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ bool ok = 0;
|
|
|
|
+ if( ms->isRunning() )
|
|
|
|
+ {
|
|
|
|
+ if( ms->zDB()->adminHatRecht( adminId, Admin_Recht::MSBeenden ) )
|
|
|
|
+ {
|
|
|
|
+ ms->serverBeenden();
|
|
|
|
+ ok = 1;
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ errorZuKlient( "Du bist nicht berechtigt den Server zu beenden." );
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ ok = 1;
|
|
|
|
+ if( ok )
|
|
|
|
+ {
|
|
|
|
+ klient->sende( "\1", 1 );
|
|
|
|
+ std::cout << "MS: Der Server wurde von Benutzer " << adminId << " terminiert.\n";
|
|
|
|
+ ms->close();
|
|
|
|
+ br = 1;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+ case 8: // Status Frage
|
|
|
|
+ if( 1 )
|
|
|
|
+ {
|
|
|
|
+ klient->sende( "\1", 1 );
|
|
|
|
+ char status = (int)ms->isRunning();
|
|
|
|
+ klient->sende( &status, 1 );
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
case 9: // Patch Server Liste
|
|
case 9: // Patch Server Liste
|
|
if( adminId )
|
|
if( adminId )
|
|
{
|
|
{
|
|
- Array< ServerData* > d;
|
|
|
|
|
|
+ Array< ServerData * > d;
|
|
if( ms->zDB()->getPatchServerList( &d ) )
|
|
if( ms->zDB()->getPatchServerList( &d ) )
|
|
klient->sende( "\1", 1 );
|
|
klient->sende( "\1", 1 );
|
|
else
|
|
else
|
|
errorZuKlient( "Fehler beim Abruf der Patch Server Tabelle." );
|
|
errorZuKlient( "Fehler beim Abruf der Patch Server Tabelle." );
|
|
int anz = d.getEintragAnzahl();
|
|
int anz = d.getEintragAnzahl();
|
|
- klient->sende( (char*)&anz, 4 );
|
|
|
|
|
|
+ klient->sende( (char *)& anz, 4 );
|
|
for( int i = 0; i < anz; i++ )
|
|
for( int i = 0; i < anz; i++ )
|
|
{
|
|
{
|
|
ServerData *s = d.get( i );
|
|
ServerData *s = d.get( i );
|
|
- klient->sende( (char*)&s->id, 4 );
|
|
|
|
- klient->sende( (char*)&s->port, 2 );
|
|
|
|
- klient->sende( (char*)&s->adminPort, 2 );
|
|
|
|
|
|
+ klient->sende( (char *)& s->id, 4 );
|
|
|
|
+ klient->sende( (char *)& s->port, 2 );
|
|
|
|
+ klient->sende( (char *)& s->adminPort, 2 );
|
|
unsigned char len = (unsigned char)s->name.getLength();
|
|
unsigned char len = (unsigned char)s->name.getLength();
|
|
- klient->sende( (char*)&len, 1 );
|
|
|
|
|
|
+ klient->sende( (char *)& len, 1 );
|
|
klient->sende( s->name, len );
|
|
klient->sende( s->name, len );
|
|
len = (unsigned char)s->ip.getLength();
|
|
len = (unsigned char)s->ip.getLength();
|
|
- klient->sende( (char*)&len, 1 );
|
|
|
|
|
|
+ klient->sende( (char *)& len, 1 );
|
|
klient->sende( s->ip, len );
|
|
klient->sende( s->ip, len );
|
|
len = (unsigned char)s->status.getLength();
|
|
len = (unsigned char)s->status.getLength();
|
|
- klient->sende( (char*)&len, 1 );
|
|
|
|
|
|
+ klient->sende( (char *)& len, 1 );
|
|
klient->sende( s->status, len );
|
|
klient->sende( s->status, len );
|
|
delete s;
|
|
delete s;
|
|
}
|
|
}
|
|
@@ -425,21 +405,21 @@ void MSAKlient::thread()
|
|
{
|
|
{
|
|
klient->sende( "\1", 1 );
|
|
klient->sende( "\1", 1 );
|
|
int id = 0;
|
|
int id = 0;
|
|
- klient->getNachricht( (char*)&id, 4 );
|
|
|
|
|
|
+ klient->getNachricht( (char *)& id, 4 );
|
|
ServerDetails d;
|
|
ServerDetails d;
|
|
if( ms->zDB()->getPatchServerDetails( id, &d ) )
|
|
if( ms->zDB()->getPatchServerDetails( id, &d ) )
|
|
{
|
|
{
|
|
klient->sende( "\1", 1 );
|
|
klient->sende( "\1", 1 );
|
|
unsigned char len = (unsigned char)d.name.getLength();
|
|
unsigned char len = (unsigned char)d.name.getLength();
|
|
- klient->sende( (char*)&len, 1 );
|
|
|
|
|
|
+ klient->sende( (char *)& len, 1 );
|
|
klient->sende( d.name, len );
|
|
klient->sende( d.name, len );
|
|
len = (unsigned char)d.ip.getLength();
|
|
len = (unsigned char)d.ip.getLength();
|
|
- klient->sende( (char*)&len, 1 );
|
|
|
|
|
|
+ klient->sende( (char *)& len, 1 );
|
|
klient->sende( d.ip, len );
|
|
klient->sende( d.ip, len );
|
|
- klient->sende( (char*)&d.port, 2 );
|
|
|
|
- klient->sende( (char*)&d.adminPort, 2 );
|
|
|
|
- klient->sende( (char*)&d.tasks, 4 );
|
|
|
|
- klient->sende( (char*)&d.maxTasks, 4 );
|
|
|
|
|
|
+ klient->sende( (char *)& d.port, 2 );
|
|
|
|
+ klient->sende( (char *)& d.adminPort, 2 );
|
|
|
|
+ klient->sende( (char *)& d.tasks, 4 );
|
|
|
|
+ klient->sende( (char *)& d.maxTasks, 4 );
|
|
}
|
|
}
|
|
else
|
|
else
|
|
errorZuKlient( "Fehler beim abrufen der Server Details." );
|
|
errorZuKlient( "Fehler beim abrufen der Server Details." );
|
|
@@ -448,32 +428,32 @@ void MSAKlient::thread()
|
|
errorZuKlient( "Du musst dich einloggen." );
|
|
errorZuKlient( "Du musst dich einloggen." );
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
- default:
|
|
|
|
- errorZuKlient( "Unbekannte Nachricht!" );
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
- if( br )
|
|
|
|
- break;
|
|
|
|
- ms->addEmpfangen( klient->getDownloadBytes( 1 ) );
|
|
|
|
- ms->addGesendet( klient->getUploadBytes( 1 ) );
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- ms->addEmpfangen( klient->getDownloadBytes( 1 ) );
|
|
|
|
- ms->addGesendet( klient->getUploadBytes( 1 ) );
|
|
|
|
- delete this;
|
|
|
|
|
|
+ default:
|
|
|
|
+ errorZuKlient( "Unbekannte Nachricht!" );
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ if( br )
|
|
|
|
+ break;
|
|
|
|
+ ms->addEmpfangen( klient->getDownloadBytes( 1 ) );
|
|
|
|
+ ms->addGesendet( klient->getUploadBytes( 1 ) );
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ ms->addEmpfangen( klient->getDownloadBytes( 1 ) );
|
|
|
|
+ ms->addGesendet( klient->getUploadBytes( 1 ) );
|
|
|
|
+ delete this;
|
|
}
|
|
}
|
|
|
|
|
|
void MSAKlient::errorZuKlient( const char *nachricht ) const // sendet eine Fehlernachricht zum Klient
|
|
void MSAKlient::errorZuKlient( const char *nachricht ) const // sendet eine Fehlernachricht zum Klient
|
|
{
|
|
{
|
|
- klient->sende( "\3", 1 );
|
|
|
|
- char len = (char)textLength( nachricht );
|
|
|
|
- klient->sende( &len, 1 );
|
|
|
|
- klient->sende( nachricht, len );
|
|
|
|
|
|
+ klient->sende( "\3", 1 );
|
|
|
|
+ char len = (char)textLength( nachricht );
|
|
|
|
+ klient->sende( &len, 1 );
|
|
|
|
+ klient->sende( nachricht, len );
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
// Konstruktor
|
|
// Konstruktor
|
|
-MSKlientSSL::MSKlientSSL( SSLSKlient *klient, MainServer *ms )
|
|
|
|
|
|
+MSKlientSSL::MSKlientSSL( SSLSKlient * klient, MainServer * ms )
|
|
{
|
|
{
|
|
this->klient = klient;
|
|
this->klient = klient;
|
|
klientNummer = 0;
|
|
klientNummer = 0;
|
|
@@ -510,8 +490,8 @@ void MSKlientSSL::thread()
|
|
{
|
|
{
|
|
int port = TextZuInt( ms->zInit()->zWert( "ServerPort" )->getText(), 10 );
|
|
int port = TextZuInt( ms->zInit()->zWert( "ServerPort" )->getText(), 10 );
|
|
klient->sende( "\1", 1 );
|
|
klient->sende( "\1", 1 );
|
|
- klient->sende( (char*)&port, 4 );
|
|
|
|
- klient->sende( (char*)&klientNummer, 4 );
|
|
|
|
|
|
+ klient->sende( (char *)& port, 4 );
|
|
|
|
+ klient->sende( (char *)& klientNummer, 4 );
|
|
char len = (char)key->getLength();
|
|
char len = (char)key->getLength();
|
|
klient->sende( &len, 1 );
|
|
klient->sende( &len, 1 );
|
|
if( len )
|
|
if( len )
|
|
@@ -554,391 +534,121 @@ void MSKlientSSL::errorZuKlient( const char *nachricht ) const // sendet eine Fe
|
|
|
|
|
|
// Inhalt der MSKlient Klasse aus MainServer.h
|
|
// Inhalt der MSKlient Klasse aus MainServer.h
|
|
// Konstruktor
|
|
// Konstruktor
|
|
-MSKlient::MSKlient( SKlient *klient, MainServer *ms )
|
|
|
|
-: Thread()
|
|
|
|
|
|
+MSKlient::MSKlient( SKlient * klient, MainServer * ms )
|
|
|
|
+ : Thread()
|
|
{
|
|
{
|
|
- this->klient = klient;
|
|
|
|
- unsigned char key[ 20 ] = { 199, 164, 172, 55, 246, 16, 155, 8, 151, 176, 250, 181, 227, 133, 30, 41, 200, 26, 7, 151 };
|
|
|
|
- klient->setSendeKey( (char*)key, 20 );
|
|
|
|
- klient->setEmpfangKey( (char*)key, 20 );
|
|
|
|
- klientNummer = 0;
|
|
|
|
- this->ms = ms;
|
|
|
|
- encrypted = 0;
|
|
|
|
|
|
+ this->klient = klient;
|
|
|
|
+ unsigned char key[ 20 ] = { 199, 164, 172, 55, 246, 16, 155, 8, 151, 176, 250, 181, 227, 133, 30, 41, 200, 26, 7, 151 };
|
|
|
|
+ klient->setSendeKey( (char *)key, 20 );
|
|
|
|
+ klient->setEmpfangKey( (char *)key, 20 );
|
|
|
|
+ klientNummer = 0;
|
|
|
|
+ this->ms = ms;
|
|
|
|
+ encrypted = 0;
|
|
}
|
|
}
|
|
|
|
|
|
// Destruktor
|
|
// Destruktor
|
|
MSKlient::~MSKlient()
|
|
MSKlient::~MSKlient()
|
|
{
|
|
{
|
|
- ms->clientTrennung();
|
|
|
|
- ms->release();
|
|
|
|
- klient->release();
|
|
|
|
|
|
+ ms->clientTrennung();
|
|
|
|
+ ms->release();
|
|
|
|
+ klient->release();
|
|
}
|
|
}
|
|
|
|
|
|
// nicht constant
|
|
// nicht constant
|
|
void MSKlient::thread()
|
|
void MSKlient::thread()
|
|
{
|
|
{
|
|
- while( 1 )
|
|
|
|
- {
|
|
|
|
- char c = 0;
|
|
|
|
- if( ( !encrypted && !klient->getNachricht( &c, 1 ) ) || ( encrypted && !klient->getNachrichtEncrypted( &c, 1 ) ) )
|
|
|
|
- break;
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- bool br = 0;
|
|
|
|
- switch( c )
|
|
|
|
- {
|
|
|
|
- case 0:
|
|
|
|
- encrypted = 1;
|
|
|
|
- break;
|
|
|
|
- case 1: // Client Identifikation
|
|
|
|
- if( 1 )
|
|
|
|
- {
|
|
|
|
- if( encrypted )
|
|
|
|
- klient->getNachrichtEncrypted( (char*)&klientNummer, 4 );
|
|
|
|
- else
|
|
|
|
- klient->getNachricht( (char*)&klientNummer, 4 );
|
|
|
|
- bool ret1 = 0;
|
|
|
|
- if( !klientNummer )
|
|
|
|
- {
|
|
|
|
- klientNummer = ms->zDB()->getNextClientId();
|
|
|
|
- if( encrypted )
|
|
|
|
- {
|
|
|
|
- Text *key = ms->zDB()->getKlientKey( klientNummer );
|
|
|
|
- if( key )
|
|
|
|
- {
|
|
|
|
- klient->sendeEncrypted( "\1", 1 );
|
|
|
|
- klient->sendeEncrypted( (char*)&klientNummer, 4 );
|
|
|
|
- char len = (char)key->getLength();
|
|
|
|
- klient->sendeEncrypted( &len, 1 );
|
|
|
|
- if( len )
|
|
|
|
- klient->sendeEncrypted( key->getText(), len );
|
|
|
|
- klient->setEmpfangKey( *key, len );
|
|
|
|
- klient->setSendeKey( *key, len );
|
|
|
|
- key->release();
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- errorZuKlient( "Es konnte kein Schlüssel ermittelt werden." );
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- klient->sende( "\1", 1 );
|
|
|
|
- klient->sende( (char*)&klientNummer, 4 );
|
|
|
|
- }
|
|
|
|
- ret1 = 1;
|
|
|
|
- }
|
|
|
|
- if( !ms->zDB()->proveRegisteredClient( klientNummer ) )
|
|
|
|
- errorZuKlient( "Deine Client Nummer ist nicht aktiv!" );
|
|
|
|
- else if( !ret1 )
|
|
|
|
- {
|
|
|
|
- if( encrypted )
|
|
|
|
- {
|
|
|
|
- Text *key = ms->zDB()->getKlientKey( klientNummer );
|
|
|
|
- if( !key )
|
|
|
|
- errorZuKlient( "Es konnte kein Schlüssel ermittelt werden." );
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- klient->sendeEncrypted( "\1", 1 );
|
|
|
|
- klient->setEmpfangKey( *key, key->getLength() );
|
|
|
|
- klient->setSendeKey( *key, key->getLength() );
|
|
|
|
- key->release();
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- klient->sende( "\1", 1 );
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- break;
|
|
|
|
- case 3: // Verbindungsende
|
|
|
|
- br = 1;
|
|
|
|
- if( encrypted )
|
|
|
|
- klient->sendeEncrypted( "\1", 1 );
|
|
|
|
- else
|
|
|
|
- klient->sende( "\1", 1 );
|
|
|
|
- break;
|
|
|
|
- case 6: // frage nach Server
|
|
|
|
- if( 1 )
|
|
|
|
- {
|
|
|
|
- char serverTyp = 0;
|
|
|
|
- if( encrypted )
|
|
|
|
- klient->getNachrichtEncrypted( &serverTyp, 1 );
|
|
|
|
- else
|
|
|
|
- klient->getNachricht( &serverTyp, 1 );
|
|
|
|
- switch( serverTyp )
|
|
|
|
- {
|
|
|
|
- case 1: // Register Server
|
|
|
|
- if( klientNummer )
|
|
|
|
- {
|
|
|
|
- int sNum = ms->zDB()->suchRegisterServer( klientNummer );
|
|
|
|
- if( sNum )
|
|
|
|
- {
|
|
|
|
- unsigned char *msg = ms->zDB()->getServerPortIp( sNum );
|
|
|
|
- if( msg )
|
|
|
|
- {
|
|
|
|
- if( encrypted )
|
|
|
|
- {
|
|
|
|
- klient->sendeEncrypted( "\2", 1 );
|
|
|
|
- klient->sendeEncrypted( (char*)msg, 6 );
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- klient->sende( "\2", 1 );
|
|
|
|
- klient->sende( (char*)msg, 6 );
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- errorZuKlient( "Aufgrund eines unerwarteten Fehlers konnte dir kein\nRegistrierungsserver zugewiesen werden!" );
|
|
|
|
- delete[]msg;
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- errorZuKlient( "Der Server ist derzeit ausgelastet!" );
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- errorZuKlient( "Du besitzt noch keine Client Nummer!" );
|
|
|
|
- break;
|
|
|
|
- case 2: // Patch Server
|
|
|
|
- if( klientNummer )
|
|
|
|
- {
|
|
|
|
- int sNum = ms->zDB()->suchPatchServer( klientNummer );
|
|
|
|
- if( sNum )
|
|
|
|
- {
|
|
|
|
- unsigned char *msg = ms->zDB()->getServerPortIp( sNum );
|
|
|
|
- if( msg )
|
|
|
|
- {
|
|
|
|
- if( encrypted )
|
|
|
|
- {
|
|
|
|
- klient->sendeEncrypted( "\2", 1 );
|
|
|
|
- klient->sendeEncrypted( (char*)msg, 6 );
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- klient->sende( "\2", 1 );
|
|
|
|
- klient->sende( (char*)msg, 6 );
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- errorZuKlient( "Aufgrund eines unerwarteten Fehlers konnte dir kein\nPatchserver zugewiesen werden!" );
|
|
|
|
- delete[]msg;
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- errorZuKlient( "Der Server ist derzeit ausgelastet!" );
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- errorZuKlient( "Du besitzt noch keine Client Nummer!" );
|
|
|
|
- break;
|
|
|
|
- case 3: // Login Server
|
|
|
|
- if( klientNummer )
|
|
|
|
- {
|
|
|
|
- int sNum = ms->zDB()->suchLoginServer( klientNummer );
|
|
|
|
- if( sNum )
|
|
|
|
- {
|
|
|
|
- unsigned char *msg = ms->zDB()->getServerPortIp( sNum );
|
|
|
|
- if( msg )
|
|
|
|
- {
|
|
|
|
- if( encrypted )
|
|
|
|
- {
|
|
|
|
- klient->sendeEncrypted( "\2", 1 );
|
|
|
|
- klient->sendeEncrypted( (char*)msg, 6 );
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- klient->sende( "\2", 1 );
|
|
|
|
- klient->sende( (char*)msg, 6 );
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- errorZuKlient( "Aufgrund eines unerwarteten Fehlers konnte dir kein\nLoginserver zugewiesen werden!" );
|
|
|
|
- delete[]msg;
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- errorZuKlient( "Der Server ist derzeit ausgelastet!" );
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- errorZuKlient( "Du besitzt noch keine Client Nummer!" );
|
|
|
|
- break;
|
|
|
|
- case 4: // Informations Server
|
|
|
|
- if( klientNummer )
|
|
|
|
- {
|
|
|
|
- int sNum = ms->zDB()->suchInformationServer( klientNummer );
|
|
|
|
- if( sNum )
|
|
|
|
- {
|
|
|
|
- unsigned char *msg = ms->zDB()->getServerPortIp( sNum );
|
|
|
|
- if( msg )
|
|
|
|
- {
|
|
|
|
- if( encrypted )
|
|
|
|
- {
|
|
|
|
- klient->sendeEncrypted( "\2", 1 );
|
|
|
|
- klient->sendeEncrypted( (char*)msg, 6 );
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- klient->sende( "\2", 1 );
|
|
|
|
- klient->sende( (char*)msg, 6 );
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- errorZuKlient( "Aufgrund eines unerwarteten Fehlers konnte dir kein\nInformationserver zugewiesen werden!" );
|
|
|
|
- delete[]msg;
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- errorZuKlient( "Der Server ist derzeit ausgelastet!" );
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- errorZuKlient( "Du besitzt noch keine Client Nummer!" );
|
|
|
|
- break;
|
|
|
|
- case 5: // Chat Server
|
|
|
|
- if( klientNummer )
|
|
|
|
- {
|
|
|
|
- int sNum = ms->zDB()->suchChatServer( klientNummer );
|
|
|
|
- if( sNum )
|
|
|
|
- {
|
|
|
|
- unsigned char *msg = ms->zDB()->getServerPortIp( sNum );
|
|
|
|
- if( msg )
|
|
|
|
- {
|
|
|
|
- if( encrypted )
|
|
|
|
- {
|
|
|
|
- klient->sendeEncrypted( "\2", 1 );
|
|
|
|
- klient->sendeEncrypted( (char*)msg, 6 );
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- klient->sende( "\2", 1 );
|
|
|
|
- klient->sende( (char*)msg, 6 );
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- errorZuKlient( "Aufgrund eines unerwarteten Fehlers konnte dir kein\nChatserver zugewiesen werden!" );
|
|
|
|
- delete[]msg;
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- errorZuKlient( "Der Server ist derzeit ausgelastet!" );
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- errorZuKlient( "Du besitzt noch keine Client Nummer!" );
|
|
|
|
- break;
|
|
|
|
- case 6: // Anmeldung Server
|
|
|
|
- if( klientNummer )
|
|
|
|
- {
|
|
|
|
- int sNum = ms->zDB()->suchAnmeldungServer( klientNummer );
|
|
|
|
- if( sNum )
|
|
|
|
- {
|
|
|
|
- unsigned char *msg = ms->zDB()->getServerPortIp( sNum );
|
|
|
|
- if( msg )
|
|
|
|
- {
|
|
|
|
- if( encrypted )
|
|
|
|
- {
|
|
|
|
- klient->sendeEncrypted( "\2", 1 );
|
|
|
|
- klient->sendeEncrypted( (char*)msg, 6 );
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- klient->sende( "\2", 1 );
|
|
|
|
- klient->sende( (char*)msg, 6 );
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- errorZuKlient( "Aufgrund eines unerwarteten Fehlers konnte dir kein\nAnmeldungserver zugewiesen werden!" );
|
|
|
|
- delete[]msg;
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- errorZuKlient( "Der Server ist derzeit ausgelastet!" );
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- errorZuKlient( "Du besitzt noch keine Client Nummer!" );
|
|
|
|
- break;
|
|
|
|
- case 7: // Shop Server
|
|
|
|
- if( klientNummer )
|
|
|
|
- {
|
|
|
|
- int sNum = ms->zDB()->suchShopServer( klientNummer );
|
|
|
|
- if( sNum )
|
|
|
|
- {
|
|
|
|
- unsigned char *msg = ms->zDB()->getServerPortIp( sNum );
|
|
|
|
- if( msg )
|
|
|
|
- {
|
|
|
|
- if( encrypted )
|
|
|
|
- {
|
|
|
|
- klient->sendeEncrypted( "\2", 1 );
|
|
|
|
- klient->sendeEncrypted( (char*)msg, 6 );
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- klient->sende( "\2", 1 );
|
|
|
|
- klient->sende( (char*)msg, 6 );
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- errorZuKlient( "Aufgrund eines unerwarteten Fehlers konnte dir kein\nShopserver zugewiesen werden!" );
|
|
|
|
- delete[]msg;
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- errorZuKlient( "Der Server ist derzeit ausgelastet!" );
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- errorZuKlient( "Du besitzt noch keine Client Nummer!" );
|
|
|
|
- break;
|
|
|
|
- case 8: // Erhaltung Server
|
|
|
|
- if( klientNummer )
|
|
|
|
- {
|
|
|
|
- int sNum = ms->zDB()->suchErhaltungServer( klientNummer );
|
|
|
|
- if( sNum )
|
|
|
|
- {
|
|
|
|
- unsigned char *msg = ms->zDB()->getServerPortIp( sNum );
|
|
|
|
- if( msg )
|
|
|
|
- {
|
|
|
|
- if( encrypted )
|
|
|
|
- {
|
|
|
|
- klient->sendeEncrypted( "\2", 1 );
|
|
|
|
- klient->sendeEncrypted( (char*)msg, 6 );
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- klient->sende( "\2", 1 );
|
|
|
|
- klient->sende( (char*)msg, 6 );
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- errorZuKlient( "Aufgrund eines unerwarteten Fehlers konnte dir kein\nPatchserver zugewiesen werden!" );
|
|
|
|
- delete[]msg;
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- errorZuKlient( "Der Server ist derzeit ausgelastet!" );
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- errorZuKlient( "Du besitzt noch keine Client Nummer!" );
|
|
|
|
- break;
|
|
|
|
- case 9: // News Server
|
|
|
|
- if( klientNummer )
|
|
|
|
- {
|
|
|
|
- int sNum = ms->zDB()->suchNewsServer( klientNummer );
|
|
|
|
- if( sNum )
|
|
|
|
- {
|
|
|
|
- unsigned char *msg = ms->zDB()->getServerPortIp( sNum );
|
|
|
|
- if( msg )
|
|
|
|
- {
|
|
|
|
- if( encrypted )
|
|
|
|
- {
|
|
|
|
- klient->sendeEncrypted( "\2", 1 );
|
|
|
|
- klient->sendeEncrypted( (char*)msg, 6 );
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- klient->sende( "\2", 1 );
|
|
|
|
- klient->sende( (char*)msg, 6 );
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- errorZuKlient( "Aufgrund eines unerwarteten Fehlers konnte dir kein\nNewsserver zugewiesen werden!" );
|
|
|
|
- delete[]msg;
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- errorZuKlient( "Der Server ist derzeit ausgelastet!" );
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- errorZuKlient( "Du besitzt noch keine Client Nummer!" );
|
|
|
|
- break;
|
|
|
|
- case 0xA: // Minigame Server
|
|
|
|
|
|
+ while( 1 )
|
|
|
|
+ {
|
|
|
|
+ char c = 0;
|
|
|
|
+ if( ( !encrypted && !klient->getNachricht( &c, 1 ) ) || ( encrypted && !klient->getNachrichtEncrypted( &c, 1 ) ) )
|
|
|
|
+ break;
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ bool br = 0;
|
|
|
|
+ switch( c )
|
|
|
|
+ {
|
|
|
|
+ case 0:
|
|
|
|
+ encrypted = 1;
|
|
|
|
+ break;
|
|
|
|
+ case 1: // Client Identifikation
|
|
|
|
+ if( 1 )
|
|
|
|
+ {
|
|
|
|
+ if( encrypted )
|
|
|
|
+ klient->getNachrichtEncrypted( (char *)& klientNummer, 4 );
|
|
|
|
+ else
|
|
|
|
+ klient->getNachricht( (char *)& klientNummer, 4 );
|
|
|
|
+ bool ret1 = 0;
|
|
|
|
+ if( !klientNummer )
|
|
|
|
+ {
|
|
|
|
+ klientNummer = ms->zDB()->getNextClientId();
|
|
|
|
+ if( encrypted )
|
|
|
|
+ {
|
|
|
|
+ Text *key = ms->zDB()->getKlientKey( klientNummer );
|
|
|
|
+ if( key )
|
|
|
|
+ {
|
|
|
|
+ klient->sendeEncrypted( "\1", 1 );
|
|
|
|
+ klient->sendeEncrypted( (char *)& klientNummer, 4 );
|
|
|
|
+ char len = (char)key->getLength();
|
|
|
|
+ klient->sendeEncrypted( &len, 1 );
|
|
|
|
+ if( len )
|
|
|
|
+ klient->sendeEncrypted( key->getText(), len );
|
|
|
|
+ klient->setEmpfangKey( *key, len );
|
|
|
|
+ klient->setSendeKey( *key, len );
|
|
|
|
+ key->release();
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ errorZuKlient( "Es konnte kein Schlüssel ermittelt werden." );
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ klient->sende( "\1", 1 );
|
|
|
|
+ klient->sende( (char *)& klientNummer, 4 );
|
|
|
|
+ }
|
|
|
|
+ ret1 = 1;
|
|
|
|
+ }
|
|
|
|
+ if( !ms->zDB()->proveRegisteredClient( klientNummer ) )
|
|
|
|
+ errorZuKlient( "Deine Client Nummer ist nicht aktiv!" );
|
|
|
|
+ else if( !ret1 )
|
|
|
|
+ {
|
|
|
|
+ if( encrypted )
|
|
|
|
+ {
|
|
|
|
+ Text *key = ms->zDB()->getKlientKey( klientNummer );
|
|
|
|
+ if( !key )
|
|
|
|
+ errorZuKlient( "Es konnte kein Schlüssel ermittelt werden." );
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ klient->sendeEncrypted( "\1", 1 );
|
|
|
|
+ klient->setEmpfangKey( *key, key->getLength() );
|
|
|
|
+ klient->setSendeKey( *key, key->getLength() );
|
|
|
|
+ key->release();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ klient->sende( "\1", 1 );
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+ case 3: // Verbindungsende
|
|
|
|
+ br = 1;
|
|
|
|
+ if( encrypted )
|
|
|
|
+ klient->sendeEncrypted( "\1", 1 );
|
|
|
|
+ else
|
|
|
|
+ klient->sende( "\1", 1 );
|
|
|
|
+ break;
|
|
|
|
+ case 6: // frage nach Server
|
|
|
|
+ if( 1 )
|
|
|
|
+ {
|
|
|
|
+ char serverTyp = 0;
|
|
|
|
+ if( encrypted )
|
|
|
|
+ klient->getNachrichtEncrypted( &serverTyp, 1 );
|
|
|
|
+ else
|
|
|
|
+ klient->getNachricht( &serverTyp, 1 );
|
|
|
|
+ switch( serverTyp )
|
|
|
|
+ {
|
|
|
|
+ case 1: // Register Server
|
|
if( klientNummer )
|
|
if( klientNummer )
|
|
{
|
|
{
|
|
- int sNum = ms->zDB()->suchMinigameServer( klientNummer );
|
|
|
|
|
|
+ int sNum = ms->zDB()->suchRegisterServer( klientNummer );
|
|
if( sNum )
|
|
if( sNum )
|
|
{
|
|
{
|
|
unsigned char *msg = ms->zDB()->getServerPortIp( sNum );
|
|
unsigned char *msg = ms->zDB()->getServerPortIp( sNum );
|
|
@@ -947,16 +657,16 @@ void MSKlient::thread()
|
|
if( encrypted )
|
|
if( encrypted )
|
|
{
|
|
{
|
|
klient->sendeEncrypted( "\2", 1 );
|
|
klient->sendeEncrypted( "\2", 1 );
|
|
- klient->sendeEncrypted( (char*)msg, 6 );
|
|
|
|
|
|
+ klient->sendeEncrypted( (char *)msg, 6 );
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
klient->sende( "\2", 1 );
|
|
klient->sende( "\2", 1 );
|
|
- klient->sende( (char*)msg, 6 );
|
|
|
|
|
|
+ klient->sende( (char *)msg, 6 );
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else
|
|
else
|
|
- errorZuKlient( "Aufgrund eines unerwarteten Fehlers konnte dir kein\nMinigameserver zugewiesen werden!" );
|
|
|
|
|
|
+ errorZuKlient( "Aufgrund eines unerwarteten Fehlers konnte dir kein\nRegistrierungsserver zugewiesen werden!" );
|
|
delete[]msg;
|
|
delete[]msg;
|
|
}
|
|
}
|
|
else
|
|
else
|
|
@@ -965,464 +675,734 @@ void MSKlient::thread()
|
|
else
|
|
else
|
|
errorZuKlient( "Du besitzt noch keine Client Nummer!" );
|
|
errorZuKlient( "Du besitzt noch keine Client Nummer!" );
|
|
break;
|
|
break;
|
|
- default:
|
|
|
|
- errorZuKlient( "Die Art des Servers ist nicht bekannt!\0" );
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- break;
|
|
|
|
- case 7: // client unregistrierung
|
|
|
|
- if( klientNummer )
|
|
|
|
- {
|
|
|
|
- int accountId = ms->zDB()->clientistEingeloggt( klientNummer );
|
|
|
|
- if( accountId )
|
|
|
|
- {
|
|
|
|
- Array< int > *ret = new Array< int >();
|
|
|
|
- int anzahl = ms->zDB()->logoutKlient( klientNummer, ret );
|
|
|
|
- if( anzahl > 0 )
|
|
|
|
- {
|
|
|
|
- int jetzt = 0;
|
|
|
|
- int chAnz = ret->get( jetzt );
|
|
|
|
- jetzt++;
|
|
|
|
- for( int i = 0; i < chAnz; i++ )
|
|
|
|
- {
|
|
|
|
- int chatroomId = ret->get( jetzt );
|
|
|
|
- jetzt++;
|
|
|
|
- if( chatroomId )
|
|
|
|
- {
|
|
|
|
- MSGWeiterleitung *weiter = new MSGWeiterleitung( ms->getThis() );
|
|
|
|
- weiter->spielerLeavesChatroom( chatroomId, accountId );
|
|
|
|
- weiter->release();
|
|
|
|
- if( ret->get( jetzt ) )
|
|
|
|
- {
|
|
|
|
- MSGWeiterleitung *weiter = new MSGWeiterleitung( ms->getThis() );
|
|
|
|
- weiter->setChatroomAdmin( chatroomId, ms->zDB()->getChatroomAdmin( chatroomId ) );
|
|
|
|
- weiter->release();
|
|
|
|
- }
|
|
|
|
- jetzt++;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- if( ret->get( jetzt ) == 1 )
|
|
|
|
- {
|
|
|
|
- jetzt++;
|
|
|
|
- MSGWeiterleitung *weiter = new MSGWeiterleitung( ms->getThis() );
|
|
|
|
- weiter->spielErstelltAbbrechen( ret->get( jetzt ) );
|
|
|
|
- weiter->release();
|
|
|
|
- }
|
|
|
|
- jetzt++;
|
|
|
|
- if( ret->get( jetzt ) == 1 )
|
|
|
|
- {
|
|
|
|
- jetzt++;
|
|
|
|
- int gruppeId = ret->get( jetzt );
|
|
|
|
- MSGWeiterleitung *weiter = new MSGWeiterleitung( ms->getThis() );
|
|
|
|
- weiter->spielerLeavesGruppe( gruppeId, accountId );
|
|
|
|
- weiter->release();
|
|
|
|
- jetzt++;
|
|
|
|
- if( ret->get( jetzt ) )
|
|
|
|
- {
|
|
|
|
- MSGWeiterleitung *weiter = new MSGWeiterleitung( ms->getThis() );
|
|
|
|
- weiter->setGruppeAdmin( gruppeId, ms->zDB()->getGruppeAdmin( gruppeId ) );
|
|
|
|
- weiter->release();
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- else if( ret->get( jetzt ) == 2 )
|
|
|
|
- {
|
|
|
|
- jetzt++;
|
|
|
|
- int gruppeId = ret->get( jetzt );
|
|
|
|
- MSGWeiterleitung *weiter = new MSGWeiterleitung( ms->getThis() );
|
|
|
|
- weiter->kickSpielerAusGruppe( gruppeId );
|
|
|
|
- weiter->release();
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- MSGWeiterleitung *weiter = new MSGWeiterleitung( ms->getThis() );
|
|
|
|
- weiter->patchServerKlientAbsturz( klientNummer );
|
|
|
|
- weiter->registerServerKlientAbsturz( klientNummer );
|
|
|
|
- weiter->loginServerKlientAbsturz( klientNummer );
|
|
|
|
- weiter->informationServerKlientAbsturz( klientNummer );
|
|
|
|
- weiter->chatServerKlientAbsturz( klientNummer );
|
|
|
|
- weiter->anmeldungServerKlientAbsturz( klientNummer );
|
|
|
|
- weiter->spielServerKlientAbsturz( klientNummer );
|
|
|
|
- weiter->shopServerKlientAbsturz( klientNummer );
|
|
|
|
- weiter->newsServerKlientAbsturz( klientNummer );
|
|
|
|
- weiter->historieServerKlientAbsturz( klientNummer );
|
|
|
|
- weiter->kartenServerKlientAbsturz( klientNummer );
|
|
|
|
- weiter->editorServerKlientAbsturz( klientNummer );
|
|
|
|
- weiter->minigameServerKlientAbsturz( klientNummer );
|
|
|
|
- weiter->release();
|
|
|
|
- int *treffer = ms->zDB()->unregisterClient( klientNummer, 0 );
|
|
|
|
- if( !treffer )
|
|
|
|
- errorZuKlient( "Der Klient konnte nicht entfernt werden." );
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- if( encrypted )
|
|
|
|
- klient->sendeEncrypted( "\1", 1 );
|
|
|
|
- else
|
|
|
|
- klient->sende( "\1", 1 );
|
|
|
|
- }
|
|
|
|
- delete[]treffer;
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- errorZuKlient( "Du besitzt noch keine Client Nummer!" );
|
|
|
|
- break;
|
|
|
|
- default:
|
|
|
|
- errorZuKlient( "Unbekannte Nachricht!" );
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
- if( br )
|
|
|
|
- break;
|
|
|
|
- ms->addEmpfangen( klient->getDownloadBytes( 1 ) );
|
|
|
|
- ms->addGesendet( klient->getUploadBytes( 1 ) );
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- ms->addEmpfangen( klient->getDownloadBytes( 1 ) );
|
|
|
|
- ms->addGesendet( klient->getUploadBytes( 1 ) );
|
|
|
|
- delete this;
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-void MSKlient::errorZuKlient( const char *nachricht ) const // sendet eine Fehlernachricht zum Klient
|
|
|
|
-{
|
|
|
|
- if( encrypted )
|
|
|
|
- {
|
|
|
|
- klient->sendeEncrypted( "\3", 1 );
|
|
|
|
- char len = (char)textLength( nachricht );
|
|
|
|
- klient->sendeEncrypted( &len, 1 );
|
|
|
|
- klient->sendeEncrypted( nachricht, len );
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- klient->sende( "\3", 1 );
|
|
|
|
- char len = (char)textLength( nachricht );
|
|
|
|
- klient->sende( &len, 1 );
|
|
|
|
- klient->sende( nachricht, len );
|
|
|
|
- }
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-// Inhalt der MSGWeiterleitung Klasse aus LoginServer.h
|
|
|
|
-// Konstruktor
|
|
|
|
-MSGWeiterleitung::MSGWeiterleitung( MainServer *ms )
|
|
|
|
-{
|
|
|
|
- this->ms = ms;
|
|
|
|
- ref = 1;
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// Destruktor
|
|
|
|
-MSGWeiterleitung::~MSGWeiterleitung()
|
|
|
|
-{
|
|
|
|
- ms->release();
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// nicht constant
|
|
|
|
-bool MSGWeiterleitung::patchServerKlientAbsturz( int klientId )
|
|
|
|
-{
|
|
|
|
- Text *ip = new Text();
|
|
|
|
- int port = 0;
|
|
|
|
- if( !ms->zDB()->getPatchServer( klientId, ip, &port ) )
|
|
|
|
- {
|
|
|
|
- ip->release();
|
|
|
|
- return 0;
|
|
|
|
- }
|
|
|
|
- Klient *k = new Klient();
|
|
|
|
- unsigned char key[ 20 ] = { 102, 139, 140, 143, 52, 52, 194, 167, 97, 106, 23, 72, 170, 121, 213, 178, 28, 28, 124, 185 };
|
|
|
|
- k->setSendeKey( (char*)key, 20 );
|
|
|
|
- k->setEmpfangKey( (char*)key, 20 );
|
|
|
|
- k->verbinde( (unsigned short)port, ip->getText() );
|
|
|
|
- ip->release();
|
|
|
|
- char ret = 0;
|
|
|
|
- k->sende( "\0", 1 ); // Verkeyung aktivieren
|
|
|
|
- k->sendeEncrypted( "\2\2", 2 );
|
|
|
|
- k->sendeEncrypted( (char*)&klientId, 4 );
|
|
|
|
- k->getNachrichtEncrypted( &ret, 1 );
|
|
|
|
- bool erf = ret == 1;
|
|
|
|
- k->sendeEncrypted( "\3", 1 );
|
|
|
|
- k->getNachrichtEncrypted( &ret, 1 );
|
|
|
|
- ms->addEmpfangen( k->getDownloadBytes( 1 ) );
|
|
|
|
- ms->addGesendet( k->getUploadBytes( 1 ) );
|
|
|
|
- k->trenne();
|
|
|
|
- k->release();
|
|
|
|
- return erf;
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-bool MSGWeiterleitung::registerServerKlientAbsturz( int klientId )
|
|
|
|
-{
|
|
|
|
- Text *ip = new Text();
|
|
|
|
- int port = 0;
|
|
|
|
- if( !ms->zDB()->getRegisterServer( klientId, ip, &port ) )
|
|
|
|
- {
|
|
|
|
- ip->release();
|
|
|
|
- return 0;
|
|
|
|
- }
|
|
|
|
- Klient *k = new Klient();
|
|
|
|
- unsigned char key[ 20 ] = { 186, 186, 179, 126, 216, 207, 123, 154, 168, 149, 51, 221, 6, 193, 160, 141, 164, 126, 44, 242 };
|
|
|
|
- k->setSendeKey( (char*)key, 20 );
|
|
|
|
- k->setEmpfangKey( (char*)key, 20 );
|
|
|
|
- k->verbinde( (unsigned short)port, ip->getText() );
|
|
|
|
- ip->release();
|
|
|
|
- char ret = 0;
|
|
|
|
- k->sendeEncrypted( "\2\2", 2 );
|
|
|
|
- k->sendeEncrypted( (char*)&klientId, 4 );
|
|
|
|
- k->getNachrichtEncrypted( &ret, 1 );
|
|
|
|
- bool erf = ret == 1;
|
|
|
|
- k->sendeEncrypted( "\3", 1 );
|
|
|
|
- k->getNachrichtEncrypted( &ret, 1 );
|
|
|
|
- ms->addEmpfangen( k->getDownloadBytes( 1 ) );
|
|
|
|
- ms->addGesendet( k->getUploadBytes( 1 ) );
|
|
|
|
- k->trenne();
|
|
|
|
- k->release();
|
|
|
|
- return erf;
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-bool MSGWeiterleitung::loginServerKlientAbsturz( int klientId )
|
|
|
|
-{
|
|
|
|
- Text *ip = new Text();
|
|
|
|
- int port = 0;
|
|
|
|
- if( !ms->zDB()->getLoginServer( klientId, ip, &port ) )
|
|
|
|
- {
|
|
|
|
- ip->release();
|
|
|
|
- return 0;
|
|
|
|
- }
|
|
|
|
- Klient *k = new Klient();
|
|
|
|
- unsigned char key[ 20 ] = { 143, 166, 245, 235, 76, 75, 116, 80, 26, 178, 142, 176, 109, 53, 106, 222, 223, 55, 139, 111 };
|
|
|
|
- k->setSendeKey( (char*)key, 20 );
|
|
|
|
- k->setEmpfangKey( (char*)key, 20 );
|
|
|
|
- k->verbinde( (unsigned short)port, ip->getText() );
|
|
|
|
- ip->release();
|
|
|
|
- char ret = 0;
|
|
|
|
- k->sendeEncrypted( "\2\2", 2 );
|
|
|
|
- k->sendeEncrypted( (char*)&klientId, 4 );
|
|
|
|
- k->getNachrichtEncrypted( &ret, 1 );
|
|
|
|
- bool erf = ret == 1;
|
|
|
|
- k->sendeEncrypted( "\3", 1 );
|
|
|
|
- k->getNachrichtEncrypted( &ret, 1 );
|
|
|
|
- ms->addEmpfangen( k->getDownloadBytes( 1 ) );
|
|
|
|
- ms->addGesendet( k->getUploadBytes( 1 ) );
|
|
|
|
- k->trenne();
|
|
|
|
- k->release();
|
|
|
|
- return erf;
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-bool MSGWeiterleitung::informationServerKlientAbsturz( int klientId )
|
|
|
|
-{
|
|
|
|
- Text *ip = new Text();
|
|
|
|
- int port = 0;
|
|
|
|
- if( !ms->zDB()->getInformationServer( klientId, ip, &port ) )
|
|
|
|
- {
|
|
|
|
- ip->release();
|
|
|
|
- return 0;
|
|
|
|
- }
|
|
|
|
- Klient *k = new Klient();
|
|
|
|
- unsigned char key[ 20 ] = { 231, 246, 125, 32, 88, 172, 229, 223, 246, 138, 74, 64, 142, 245, 217, 218, 162, 62, 103, 50 };
|
|
|
|
- k->setSendeKey( (char*)key, 20 );
|
|
|
|
- k->setEmpfangKey( (char*)key, 20 );
|
|
|
|
- k->verbinde( (unsigned short)port, ip->getText() );
|
|
|
|
- ip->release();
|
|
|
|
- char ret = 0;
|
|
|
|
- k->sendeEncrypted( "\2\2", 2 );
|
|
|
|
- k->sendeEncrypted( (char*)&klientId, 4 );
|
|
|
|
- k->getNachrichtEncrypted( &ret, 1 );
|
|
|
|
- bool erf = ret == 1;
|
|
|
|
- k->sendeEncrypted( "\3", 1 );
|
|
|
|
- k->getNachrichtEncrypted( &ret, 1 );
|
|
|
|
- ms->addEmpfangen( k->getDownloadBytes( 1 ) );
|
|
|
|
- ms->addGesendet( k->getUploadBytes( 1 ) );
|
|
|
|
- k->trenne();
|
|
|
|
- k->release();
|
|
|
|
- return erf;
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-bool MSGWeiterleitung::chatServerKlientAbsturz( int klientId )
|
|
|
|
-{
|
|
|
|
- Text *ip = new Text();
|
|
|
|
- int port = 0;
|
|
|
|
- if( !ms->zDB()->getChatServer( klientId, ip, &port ) )
|
|
|
|
- {
|
|
|
|
- ip->release();
|
|
|
|
- return 0;
|
|
|
|
- }
|
|
|
|
- Klient *k = new Klient();
|
|
|
|
- unsigned char key[ 20 ] = { 78, 20, 190, 133, 10, 175, 51, 96, 62, 1, 180, 194, 126, 50, 211, 154, 105, 227, 22, 101 };
|
|
|
|
- k->setSendeKey( (char*)key, 20 );
|
|
|
|
- k->setEmpfangKey( (char*)key, 20 );
|
|
|
|
- k->verbinde( (unsigned short)port, ip->getText() );
|
|
|
|
- ip->release();
|
|
|
|
- char ret = 0;
|
|
|
|
- k->sendeEncrypted( "\2\2", 2 );
|
|
|
|
- k->sendeEncrypted( (char*)&klientId, 4 );
|
|
|
|
- k->getNachrichtEncrypted( &ret, 1 );
|
|
|
|
- bool erf = ret == 1;
|
|
|
|
- k->sendeEncrypted( "\3", 1 );
|
|
|
|
- k->getNachrichtEncrypted( &ret, 1 );
|
|
|
|
- ms->addEmpfangen( k->getDownloadBytes( 1 ) );
|
|
|
|
- ms->addGesendet( k->getUploadBytes( 1 ) );
|
|
|
|
- k->trenne();
|
|
|
|
- k->release();
|
|
|
|
- return erf;
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-bool MSGWeiterleitung::anmeldungServerKlientAbsturz( int klientId )
|
|
|
|
-{
|
|
|
|
- Text *ip = new Text();
|
|
|
|
- int port = 0;
|
|
|
|
- if( !ms->zDB()->getAnmeldungServer( klientId, ip, &port ) )
|
|
|
|
- {
|
|
|
|
- ip->release();
|
|
|
|
- return 0;
|
|
|
|
- }
|
|
|
|
- Klient *k = new Klient();
|
|
|
|
- unsigned char key[ 20 ] = { 158, 10, 37, 155, 117, 58, 28, 197, 132, 76, 252, 83, 84, 222, 11, 125, 240, 218, 25, 201 };
|
|
|
|
- k->setSendeKey( (char*)key, 20 );
|
|
|
|
- k->setEmpfangKey( (char*)key, 20 );
|
|
|
|
- k->verbinde( (unsigned short)port, ip->getText() );
|
|
|
|
- ip->release();
|
|
|
|
- char ret = 0;
|
|
|
|
- k->sendeEncrypted( "\2\2", 2 );
|
|
|
|
- k->sendeEncrypted( (char*)&klientId, 4 );
|
|
|
|
- k->getNachrichtEncrypted( &ret, 1 );
|
|
|
|
- bool erf = ret == 1;
|
|
|
|
- k->sendeEncrypted( "\3", 1 );
|
|
|
|
- k->getNachrichtEncrypted( &ret, 1 );
|
|
|
|
- ms->addEmpfangen( k->getDownloadBytes( 1 ) );
|
|
|
|
- ms->addGesendet( k->getUploadBytes( 1 ) );
|
|
|
|
- k->trenne();
|
|
|
|
- k->release();
|
|
|
|
- return erf;
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-bool MSGWeiterleitung::spielServerKlientAbsturz( int klientId )
|
|
|
|
-{
|
|
|
|
- Text *ip = new Text();
|
|
|
|
- int port = 0;
|
|
|
|
- if( !ms->zDB()->getSpielServer( klientId, ip, &port ) )
|
|
|
|
- {
|
|
|
|
- ip->release();
|
|
|
|
- return 0;
|
|
|
|
- }
|
|
|
|
- Klient *k = new Klient();
|
|
|
|
- unsigned char key[ 20 ] = { 253, 234, 211, 132, 121, 230, 95, 145, 201, 13, 43, 77, 153, 223, 253, 69, 234, 43, 52, 99 };
|
|
|
|
- k->setSendeKey( (char*)key, 20 );
|
|
|
|
- k->setEmpfangKey( (char*)key, 20 );
|
|
|
|
- k->verbinde( (unsigned short)port, ip->getText() );
|
|
|
|
- ip->release();
|
|
|
|
- char ret = 0;
|
|
|
|
- k->sendeEncrypted( "\2\2", 2 );
|
|
|
|
- k->sendeEncrypted( (char*)&klientId, 4 );
|
|
|
|
- k->getNachrichtEncrypted( &ret, 1 );
|
|
|
|
- bool erf = ret == 1;
|
|
|
|
- k->sendeEncrypted( "\3", 1 );
|
|
|
|
- k->getNachrichtEncrypted( &ret, 1 );
|
|
|
|
- ms->addEmpfangen( k->getDownloadBytes( 1 ) );
|
|
|
|
- ms->addGesendet( k->getUploadBytes( 1 ) );
|
|
|
|
- k->trenne();
|
|
|
|
- k->release();
|
|
|
|
- return erf;
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-bool MSGWeiterleitung::shopServerKlientAbsturz( int klientId )
|
|
|
|
-{
|
|
|
|
- Text *ip = new Text();
|
|
|
|
- int port = 0;
|
|
|
|
- if( !ms->zDB()->getShopServer( klientId, ip, &port ) )
|
|
|
|
- {
|
|
|
|
- ip->release();
|
|
|
|
- return 0;
|
|
|
|
- }
|
|
|
|
- Klient *k = new Klient();
|
|
|
|
- unsigned char key[ 20 ] = { 218, 226, 231, 216, 68, 63, 132, 155, 49, 235, 239, 0, 19, 23, 116, 244, 235, 21, 189, 53 };
|
|
|
|
- k->setSendeKey( (char*)key, 20 );
|
|
|
|
- k->setEmpfangKey( (char*)key, 20 );
|
|
|
|
- k->verbinde( (unsigned short)port, ip->getText() );
|
|
|
|
- ip->release();
|
|
|
|
- char ret = 0;
|
|
|
|
- k->sendeEncrypted( "\2\2", 2 );
|
|
|
|
- k->sendeEncrypted( (char*)&klientId, 4 );
|
|
|
|
- k->getNachrichtEncrypted( &ret, 1 );
|
|
|
|
- bool erf = ret == 1;
|
|
|
|
- k->sendeEncrypted( "\3", 1 );
|
|
|
|
- k->getNachrichtEncrypted( &ret, 1 );
|
|
|
|
- ms->addEmpfangen( k->getDownloadBytes( 1 ) );
|
|
|
|
- ms->addGesendet( k->getUploadBytes( 1 ) );
|
|
|
|
- k->trenne();
|
|
|
|
- k->release();
|
|
|
|
- return erf;
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-bool MSGWeiterleitung::newsServerKlientAbsturz( int klientId )
|
|
|
|
-{
|
|
|
|
- Text *ip = new Text();
|
|
|
|
- int port = 0;
|
|
|
|
- if( !ms->zDB()->getNewsServer( klientId, ip, &port ) )
|
|
|
|
- {
|
|
|
|
- ip->release();
|
|
|
|
- return 0;
|
|
|
|
- }
|
|
|
|
- Klient *k = new Klient();
|
|
|
|
- unsigned char key[ 20 ] = { 4, 150, 243, 145, 204, 71, 253, 88, 4, 51, 189, 207, 189, 248, 231, 40, 106, 7, 182, 5 };
|
|
|
|
- k->setSendeKey( (char*)key, 20 );
|
|
|
|
- k->setEmpfangKey( (char*)key, 20 );
|
|
|
|
- k->verbinde( (unsigned short)port, ip->getText() );
|
|
|
|
- ip->release();
|
|
|
|
- char ret = 0;
|
|
|
|
- k->sendeEncrypted( "\2\2", 2 );
|
|
|
|
- k->sendeEncrypted( (char*)&klientId, 4 );
|
|
|
|
- k->getNachrichtEncrypted( &ret, 1 );
|
|
|
|
- bool erf = ret == 1;
|
|
|
|
- k->sendeEncrypted( "\3", 1 );
|
|
|
|
- k->getNachrichtEncrypted( &ret, 1 );
|
|
|
|
- ms->addEmpfangen( k->getDownloadBytes( 1 ) );
|
|
|
|
- ms->addGesendet( k->getUploadBytes( 1 ) );
|
|
|
|
- k->trenne();
|
|
|
|
- k->release();
|
|
|
|
- return erf;
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-bool MSGWeiterleitung::historieServerKlientAbsturz( int klientId )
|
|
|
|
-{
|
|
|
|
- Text *ip = new Text();
|
|
|
|
- int port = 0;
|
|
|
|
- if( !ms->zDB()->getHistorieServer( klientId, ip, &port ) )
|
|
|
|
- {
|
|
|
|
- ip->release();
|
|
|
|
- return 0;
|
|
|
|
- }
|
|
|
|
- Klient *k = new Klient();
|
|
|
|
- unsigned char key[ 20 ] = { 207, 30, 72, 46, 30, 50, 56, 213, 82, 107, 14, 201, 149, 58, 110, 138, 228, 241, 52, 54 };
|
|
|
|
- k->setSendeKey( (char*)key, 20 );
|
|
|
|
- k->setEmpfangKey( (char*)key, 20 );
|
|
|
|
- k->verbinde( (unsigned short)port, ip->getText() );
|
|
|
|
- ip->release();
|
|
|
|
- char ret = 0;
|
|
|
|
- k->sendeEncrypted( "\2\2", 2 );
|
|
|
|
- k->sendeEncrypted( (char*)&klientId, 4 );
|
|
|
|
- k->getNachrichtEncrypted( &ret, 1 );
|
|
|
|
- bool erf = ret == 1;
|
|
|
|
- k->sendeEncrypted( "\3", 1 );
|
|
|
|
- k->getNachrichtEncrypted( &ret, 1 );
|
|
|
|
- ms->addEmpfangen( k->getDownloadBytes( 1 ) );
|
|
|
|
- ms->addGesendet( k->getUploadBytes( 1 ) );
|
|
|
|
- k->trenne();
|
|
|
|
- k->release();
|
|
|
|
- return erf;
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-bool MSGWeiterleitung::kartenServerKlientAbsturz( int klientId )
|
|
|
|
-{
|
|
|
|
- Text *ip = new Text();
|
|
|
|
- int port = 0;
|
|
|
|
- if( !ms->zDB()->getKartenServer( klientId, ip, &port ) )
|
|
|
|
- {
|
|
|
|
- ip->release();
|
|
|
|
- return 0;
|
|
|
|
- }
|
|
|
|
- Klient *k = new Klient();
|
|
|
|
|
|
+ case 2: // Patch Server
|
|
|
|
+ if( klientNummer )
|
|
|
|
+ {
|
|
|
|
+ int sNum = ms->zDB()->suchPatchServer( klientNummer );
|
|
|
|
+ if( sNum )
|
|
|
|
+ {
|
|
|
|
+ unsigned char *msg = ms->zDB()->getServerPortIp( sNum );
|
|
|
|
+ if( msg )
|
|
|
|
+ {
|
|
|
|
+ if( encrypted )
|
|
|
|
+ {
|
|
|
|
+ klient->sendeEncrypted( "\2", 1 );
|
|
|
|
+ klient->sendeEncrypted( (char *)msg, 6 );
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ klient->sende( "\2", 1 );
|
|
|
|
+ klient->sende( (char *)msg, 6 );
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ errorZuKlient( "Aufgrund eines unerwarteten Fehlers konnte dir kein\nPatchserver zugewiesen werden!" );
|
|
|
|
+ delete[]msg;
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ errorZuKlient( "Der Server ist derzeit ausgelastet!" );
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ errorZuKlient( "Du besitzt noch keine Client Nummer!" );
|
|
|
|
+ break;
|
|
|
|
+ case 3: // Login Server
|
|
|
|
+ if( klientNummer )
|
|
|
|
+ {
|
|
|
|
+ int sNum = ms->zDB()->suchLoginServer( klientNummer );
|
|
|
|
+ if( sNum )
|
|
|
|
+ {
|
|
|
|
+ unsigned char *msg = ms->zDB()->getServerPortIp( sNum );
|
|
|
|
+ if( msg )
|
|
|
|
+ {
|
|
|
|
+ if( encrypted )
|
|
|
|
+ {
|
|
|
|
+ klient->sendeEncrypted( "\2", 1 );
|
|
|
|
+ klient->sendeEncrypted( (char *)msg, 6 );
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ klient->sende( "\2", 1 );
|
|
|
|
+ klient->sende( (char *)msg, 6 );
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ errorZuKlient( "Aufgrund eines unerwarteten Fehlers konnte dir kein\nLoginserver zugewiesen werden!" );
|
|
|
|
+ delete[]msg;
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ errorZuKlient( "Der Server ist derzeit ausgelastet!" );
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ errorZuKlient( "Du besitzt noch keine Client Nummer!" );
|
|
|
|
+ break;
|
|
|
|
+ case 4: // Informations Server
|
|
|
|
+ if( klientNummer )
|
|
|
|
+ {
|
|
|
|
+ int sNum = ms->zDB()->suchInformationServer( klientNummer );
|
|
|
|
+ if( sNum )
|
|
|
|
+ {
|
|
|
|
+ unsigned char *msg = ms->zDB()->getServerPortIp( sNum );
|
|
|
|
+ if( msg )
|
|
|
|
+ {
|
|
|
|
+ if( encrypted )
|
|
|
|
+ {
|
|
|
|
+ klient->sendeEncrypted( "\2", 1 );
|
|
|
|
+ klient->sendeEncrypted( (char *)msg, 6 );
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ klient->sende( "\2", 1 );
|
|
|
|
+ klient->sende( (char *)msg, 6 );
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ errorZuKlient( "Aufgrund eines unerwarteten Fehlers konnte dir kein\nInformationserver zugewiesen werden!" );
|
|
|
|
+ delete[]msg;
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ errorZuKlient( "Der Server ist derzeit ausgelastet!" );
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ errorZuKlient( "Du besitzt noch keine Client Nummer!" );
|
|
|
|
+ break;
|
|
|
|
+ case 5: // Chat Server
|
|
|
|
+ if( klientNummer )
|
|
|
|
+ {
|
|
|
|
+ int sNum = ms->zDB()->suchChatServer( klientNummer );
|
|
|
|
+ if( sNum )
|
|
|
|
+ {
|
|
|
|
+ unsigned char *msg = ms->zDB()->getServerPortIp( sNum );
|
|
|
|
+ if( msg )
|
|
|
|
+ {
|
|
|
|
+ if( encrypted )
|
|
|
|
+ {
|
|
|
|
+ klient->sendeEncrypted( "\2", 1 );
|
|
|
|
+ klient->sendeEncrypted( (char *)msg, 6 );
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ klient->sende( "\2", 1 );
|
|
|
|
+ klient->sende( (char *)msg, 6 );
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ errorZuKlient( "Aufgrund eines unerwarteten Fehlers konnte dir kein\nChatserver zugewiesen werden!" );
|
|
|
|
+ delete[]msg;
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ errorZuKlient( "Der Server ist derzeit ausgelastet!" );
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ errorZuKlient( "Du besitzt noch keine Client Nummer!" );
|
|
|
|
+ break;
|
|
|
|
+ case 6: // Anmeldung Server
|
|
|
|
+ if( klientNummer )
|
|
|
|
+ {
|
|
|
|
+ int sNum = ms->zDB()->suchAnmeldungServer( klientNummer );
|
|
|
|
+ if( sNum )
|
|
|
|
+ {
|
|
|
|
+ unsigned char *msg = ms->zDB()->getServerPortIp( sNum );
|
|
|
|
+ if( msg )
|
|
|
|
+ {
|
|
|
|
+ if( encrypted )
|
|
|
|
+ {
|
|
|
|
+ klient->sendeEncrypted( "\2", 1 );
|
|
|
|
+ klient->sendeEncrypted( (char *)msg, 6 );
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ klient->sende( "\2", 1 );
|
|
|
|
+ klient->sende( (char *)msg, 6 );
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ errorZuKlient( "Aufgrund eines unerwarteten Fehlers konnte dir kein\nAnmeldungserver zugewiesen werden!" );
|
|
|
|
+ delete[]msg;
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ errorZuKlient( "Der Server ist derzeit ausgelastet!" );
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ errorZuKlient( "Du besitzt noch keine Client Nummer!" );
|
|
|
|
+ break;
|
|
|
|
+ case 7: // Shop Server
|
|
|
|
+ if( klientNummer )
|
|
|
|
+ {
|
|
|
|
+ int sNum = ms->zDB()->suchShopServer( klientNummer );
|
|
|
|
+ if( sNum )
|
|
|
|
+ {
|
|
|
|
+ unsigned char *msg = ms->zDB()->getServerPortIp( sNum );
|
|
|
|
+ if( msg )
|
|
|
|
+ {
|
|
|
|
+ if( encrypted )
|
|
|
|
+ {
|
|
|
|
+ klient->sendeEncrypted( "\2", 1 );
|
|
|
|
+ klient->sendeEncrypted( (char *)msg, 6 );
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ klient->sende( "\2", 1 );
|
|
|
|
+ klient->sende( (char *)msg, 6 );
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ errorZuKlient( "Aufgrund eines unerwarteten Fehlers konnte dir kein\nShopserver zugewiesen werden!" );
|
|
|
|
+ delete[]msg;
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ errorZuKlient( "Der Server ist derzeit ausgelastet!" );
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ errorZuKlient( "Du besitzt noch keine Client Nummer!" );
|
|
|
|
+ break;
|
|
|
|
+ case 8: // Erhaltung Server
|
|
|
|
+ if( klientNummer )
|
|
|
|
+ {
|
|
|
|
+ int sNum = ms->zDB()->suchErhaltungServer( klientNummer );
|
|
|
|
+ if( sNum )
|
|
|
|
+ {
|
|
|
|
+ unsigned char *msg = ms->zDB()->getServerPortIp( sNum );
|
|
|
|
+ if( msg )
|
|
|
|
+ {
|
|
|
|
+ if( encrypted )
|
|
|
|
+ {
|
|
|
|
+ klient->sendeEncrypted( "\2", 1 );
|
|
|
|
+ klient->sendeEncrypted( (char *)msg, 6 );
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ klient->sende( "\2", 1 );
|
|
|
|
+ klient->sende( (char *)msg, 6 );
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ errorZuKlient( "Aufgrund eines unerwarteten Fehlers konnte dir kein\nPatchserver zugewiesen werden!" );
|
|
|
|
+ delete[]msg;
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ errorZuKlient( "Der Server ist derzeit ausgelastet!" );
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ errorZuKlient( "Du besitzt noch keine Client Nummer!" );
|
|
|
|
+ break;
|
|
|
|
+ case 9: // News Server
|
|
|
|
+ if( klientNummer )
|
|
|
|
+ {
|
|
|
|
+ int sNum = ms->zDB()->suchNewsServer( klientNummer );
|
|
|
|
+ if( sNum )
|
|
|
|
+ {
|
|
|
|
+ unsigned char *msg = ms->zDB()->getServerPortIp( sNum );
|
|
|
|
+ if( msg )
|
|
|
|
+ {
|
|
|
|
+ if( encrypted )
|
|
|
|
+ {
|
|
|
|
+ klient->sendeEncrypted( "\2", 1 );
|
|
|
|
+ klient->sendeEncrypted( (char *)msg, 6 );
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ klient->sende( "\2", 1 );
|
|
|
|
+ klient->sende( (char *)msg, 6 );
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ errorZuKlient( "Aufgrund eines unerwarteten Fehlers konnte dir kein\nNewsserver zugewiesen werden!" );
|
|
|
|
+ delete[]msg;
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ errorZuKlient( "Der Server ist derzeit ausgelastet!" );
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ errorZuKlient( "Du besitzt noch keine Client Nummer!" );
|
|
|
|
+ break;
|
|
|
|
+ case 0xA: // Minigame Server
|
|
|
|
+ if( klientNummer )
|
|
|
|
+ {
|
|
|
|
+ int sNum = ms->zDB()->suchMinigameServer( klientNummer );
|
|
|
|
+ if( sNum )
|
|
|
|
+ {
|
|
|
|
+ unsigned char *msg = ms->zDB()->getServerPortIp( sNum );
|
|
|
|
+ if( msg )
|
|
|
|
+ {
|
|
|
|
+ if( encrypted )
|
|
|
|
+ {
|
|
|
|
+ klient->sendeEncrypted( "\2", 1 );
|
|
|
|
+ klient->sendeEncrypted( (char *)msg, 6 );
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ klient->sende( "\2", 1 );
|
|
|
|
+ klient->sende( (char *)msg, 6 );
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ errorZuKlient( "Aufgrund eines unerwarteten Fehlers konnte dir kein\nMinigameserver zugewiesen werden!" );
|
|
|
|
+ delete[]msg;
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ errorZuKlient( "Der Server ist derzeit ausgelastet!" );
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ errorZuKlient( "Du besitzt noch keine Client Nummer!" );
|
|
|
|
+ break;
|
|
|
|
+ default:
|
|
|
|
+ errorZuKlient( "Die Art des Servers ist nicht bekannt!\0" );
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+ case 7: // client unregistrierung
|
|
|
|
+ if( klientNummer )
|
|
|
|
+ {
|
|
|
|
+ int accountId = ms->zDB()->clientistEingeloggt( klientNummer );
|
|
|
|
+ if( accountId )
|
|
|
|
+ {
|
|
|
|
+ Array< int > *ret = new Array< int >();
|
|
|
|
+ int anzahl = ms->zDB()->logoutKlient( klientNummer, ret );
|
|
|
|
+ if( anzahl > 0 )
|
|
|
|
+ {
|
|
|
|
+ int jetzt = 0;
|
|
|
|
+ int chAnz = ret->get( jetzt );
|
|
|
|
+ jetzt++;
|
|
|
|
+ for( int i = 0; i < chAnz; i++ )
|
|
|
|
+ {
|
|
|
|
+ int chatroomId = ret->get( jetzt );
|
|
|
|
+ jetzt++;
|
|
|
|
+ if( chatroomId )
|
|
|
|
+ {
|
|
|
|
+ MSGWeiterleitung *weiter = new MSGWeiterleitung( (MainServer *)ms->getThis() );
|
|
|
|
+ weiter->spielerLeavesChatroom( chatroomId, accountId );
|
|
|
|
+ weiter->release();
|
|
|
|
+ if( ret->get( jetzt ) )
|
|
|
|
+ {
|
|
|
|
+ MSGWeiterleitung *weiter = new MSGWeiterleitung( (MainServer *)ms->getThis() );
|
|
|
|
+ weiter->setChatroomAdmin( chatroomId, ms->zDB()->getChatroomAdmin( chatroomId ) );
|
|
|
|
+ weiter->release();
|
|
|
|
+ }
|
|
|
|
+ jetzt++;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if( ret->get( jetzt ) == 1 )
|
|
|
|
+ {
|
|
|
|
+ jetzt++;
|
|
|
|
+ MSGWeiterleitung *weiter = new MSGWeiterleitung( (MainServer *)ms->getThis() );
|
|
|
|
+ weiter->spielErstelltAbbrechen( ret->get( jetzt ) );
|
|
|
|
+ weiter->release();
|
|
|
|
+ }
|
|
|
|
+ jetzt++;
|
|
|
|
+ if( ret->get( jetzt ) == 1 )
|
|
|
|
+ {
|
|
|
|
+ jetzt++;
|
|
|
|
+ int gruppeId = ret->get( jetzt );
|
|
|
|
+ MSGWeiterleitung *weiter = new MSGWeiterleitung( (MainServer *)ms->getThis() );
|
|
|
|
+ weiter->spielerLeavesGruppe( gruppeId, accountId );
|
|
|
|
+ weiter->release();
|
|
|
|
+ jetzt++;
|
|
|
|
+ if( ret->get( jetzt ) )
|
|
|
|
+ {
|
|
|
|
+ MSGWeiterleitung *weiter = new MSGWeiterleitung( (MainServer *)ms->getThis() );
|
|
|
|
+ weiter->setGruppeAdmin( gruppeId, ms->zDB()->getGruppeAdmin( gruppeId ) );
|
|
|
|
+ weiter->release();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ else if( ret->get( jetzt ) == 2 )
|
|
|
|
+ {
|
|
|
|
+ jetzt++;
|
|
|
|
+ int gruppeId = ret->get( jetzt );
|
|
|
|
+ MSGWeiterleitung *weiter = new MSGWeiterleitung( (MainServer *)ms->getThis() );
|
|
|
|
+ weiter->kickSpielerAusGruppe( gruppeId );
|
|
|
|
+ weiter->release();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ MSGWeiterleitung *weiter = new MSGWeiterleitung( (MainServer *)ms->getThis() );
|
|
|
|
+ weiter->patchServerKlientAbsturz( klientNummer );
|
|
|
|
+ weiter->registerServerKlientAbsturz( klientNummer );
|
|
|
|
+ weiter->loginServerKlientAbsturz( klientNummer );
|
|
|
|
+ weiter->informationServerKlientAbsturz( klientNummer );
|
|
|
|
+ weiter->chatServerKlientAbsturz( klientNummer );
|
|
|
|
+ weiter->anmeldungServerKlientAbsturz( klientNummer );
|
|
|
|
+ weiter->spielServerKlientAbsturz( klientNummer );
|
|
|
|
+ weiter->shopServerKlientAbsturz( klientNummer );
|
|
|
|
+ weiter->newsServerKlientAbsturz( klientNummer );
|
|
|
|
+ weiter->historieServerKlientAbsturz( klientNummer );
|
|
|
|
+ weiter->kartenServerKlientAbsturz( klientNummer );
|
|
|
|
+ weiter->editorServerKlientAbsturz( klientNummer );
|
|
|
|
+ weiter->minigameServerKlientAbsturz( klientNummer );
|
|
|
|
+ weiter->release();
|
|
|
|
+ int *treffer = ms->zDB()->unregisterClient( klientNummer, 0 );
|
|
|
|
+ if( !treffer )
|
|
|
|
+ errorZuKlient( "Der Klient konnte nicht entfernt werden." );
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ if( encrypted )
|
|
|
|
+ klient->sendeEncrypted( "\1", 1 );
|
|
|
|
+ else
|
|
|
|
+ klient->sende( "\1", 1 );
|
|
|
|
+ }
|
|
|
|
+ delete[]treffer;
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ errorZuKlient( "Du besitzt noch keine Client Nummer!" );
|
|
|
|
+ break;
|
|
|
|
+ default:
|
|
|
|
+ errorZuKlient( "Unbekannte Nachricht!" );
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ if( br )
|
|
|
|
+ break;
|
|
|
|
+ ms->addEmpfangen( klient->getDownloadBytes( 1 ) );
|
|
|
|
+ ms->addGesendet( klient->getUploadBytes( 1 ) );
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ ms->addEmpfangen( klient->getDownloadBytes( 1 ) );
|
|
|
|
+ ms->addGesendet( klient->getUploadBytes( 1 ) );
|
|
|
|
+ delete this;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void MSKlient::errorZuKlient( const char *nachricht ) const // sendet eine Fehlernachricht zum Klient
|
|
|
|
+{
|
|
|
|
+ if( encrypted )
|
|
|
|
+ {
|
|
|
|
+ klient->sendeEncrypted( "\3", 1 );
|
|
|
|
+ char len = (char)textLength( nachricht );
|
|
|
|
+ klient->sendeEncrypted( &len, 1 );
|
|
|
|
+ klient->sendeEncrypted( nachricht, len );
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ klient->sende( "\3", 1 );
|
|
|
|
+ char len = (char)textLength( nachricht );
|
|
|
|
+ klient->sende( &len, 1 );
|
|
|
|
+ klient->sende( nachricht, len );
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+// Inhalt der MSGWeiterleitung Klasse aus LoginServer.h
|
|
|
|
+// Konstruktor
|
|
|
|
+MSGWeiterleitung::MSGWeiterleitung( MainServer * ms )
|
|
|
|
+{
|
|
|
|
+ this->ms = ms;
|
|
|
|
+ ref = 1;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+// Destruktor
|
|
|
|
+MSGWeiterleitung::~MSGWeiterleitung()
|
|
|
|
+{
|
|
|
|
+ ms->release();
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+// nicht constant
|
|
|
|
+bool MSGWeiterleitung::patchServerKlientAbsturz( int klientId )
|
|
|
|
+{
|
|
|
|
+ Text *ip = new Text();
|
|
|
|
+ int port = 0;
|
|
|
|
+ if( !ms->zDB()->getPatchServer( klientId, ip, &port ) )
|
|
|
|
+ {
|
|
|
|
+ ip->release();
|
|
|
|
+ return 0;
|
|
|
|
+ }
|
|
|
|
+ Klient *k = new Klient();
|
|
|
|
+ unsigned char key[ 20 ] = { 102, 139, 140, 143, 52, 52, 194, 167, 97, 106, 23, 72, 170, 121, 213, 178, 28, 28, 124, 185 };
|
|
|
|
+ k->setSendeKey( (char *)key, 20 );
|
|
|
|
+ k->setEmpfangKey( (char *)key, 20 );
|
|
|
|
+ k->verbinde( (unsigned short)port, ip->getText() );
|
|
|
|
+ ip->release();
|
|
|
|
+ char ret = 0;
|
|
|
|
+ k->sende( "\0", 1 ); // Verkeyung aktivieren
|
|
|
|
+ k->sendeEncrypted( "\2\2", 2 );
|
|
|
|
+ k->sendeEncrypted( (char *)& klientId, 4 );
|
|
|
|
+ k->getNachrichtEncrypted( &ret, 1 );
|
|
|
|
+ bool erf = ret == 1;
|
|
|
|
+ k->sendeEncrypted( "\3", 1 );
|
|
|
|
+ k->getNachrichtEncrypted( &ret, 1 );
|
|
|
|
+ ms->addEmpfangen( k->getDownloadBytes( 1 ) );
|
|
|
|
+ ms->addGesendet( k->getUploadBytes( 1 ) );
|
|
|
|
+ k->trenne();
|
|
|
|
+ k->release();
|
|
|
|
+ return erf;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+bool MSGWeiterleitung::registerServerKlientAbsturz( int klientId )
|
|
|
|
+{
|
|
|
|
+ Text *ip = new Text();
|
|
|
|
+ int port = 0;
|
|
|
|
+ if( !ms->zDB()->getRegisterServer( klientId, ip, &port ) )
|
|
|
|
+ {
|
|
|
|
+ ip->release();
|
|
|
|
+ return 0;
|
|
|
|
+ }
|
|
|
|
+ Klient *k = new Klient();
|
|
|
|
+ unsigned char key[ 20 ] = { 186, 186, 179, 126, 216, 207, 123, 154, 168, 149, 51, 221, 6, 193, 160, 141, 164, 126, 44, 242 };
|
|
|
|
+ k->setSendeKey( (char *)key, 20 );
|
|
|
|
+ k->setEmpfangKey( (char *)key, 20 );
|
|
|
|
+ k->verbinde( (unsigned short)port, ip->getText() );
|
|
|
|
+ ip->release();
|
|
|
|
+ char ret = 0;
|
|
|
|
+ k->sendeEncrypted( "\2\2", 2 );
|
|
|
|
+ k->sendeEncrypted( (char *)& klientId, 4 );
|
|
|
|
+ k->getNachrichtEncrypted( &ret, 1 );
|
|
|
|
+ bool erf = ret == 1;
|
|
|
|
+ k->sendeEncrypted( "\3", 1 );
|
|
|
|
+ k->getNachrichtEncrypted( &ret, 1 );
|
|
|
|
+ ms->addEmpfangen( k->getDownloadBytes( 1 ) );
|
|
|
|
+ ms->addGesendet( k->getUploadBytes( 1 ) );
|
|
|
|
+ k->trenne();
|
|
|
|
+ k->release();
|
|
|
|
+ return erf;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+bool MSGWeiterleitung::loginServerKlientAbsturz( int klientId )
|
|
|
|
+{
|
|
|
|
+ Text *ip = new Text();
|
|
|
|
+ int port = 0;
|
|
|
|
+ if( !ms->zDB()->getLoginServer( klientId, ip, &port ) )
|
|
|
|
+ {
|
|
|
|
+ ip->release();
|
|
|
|
+ return 0;
|
|
|
|
+ }
|
|
|
|
+ Klient *k = new Klient();
|
|
|
|
+ unsigned char key[ 20 ] = { 143, 166, 245, 235, 76, 75, 116, 80, 26, 178, 142, 176, 109, 53, 106, 222, 223, 55, 139, 111 };
|
|
|
|
+ k->setSendeKey( (char *)key, 20 );
|
|
|
|
+ k->setEmpfangKey( (char *)key, 20 );
|
|
|
|
+ k->verbinde( (unsigned short)port, ip->getText() );
|
|
|
|
+ ip->release();
|
|
|
|
+ char ret = 0;
|
|
|
|
+ k->sendeEncrypted( "\2\2", 2 );
|
|
|
|
+ k->sendeEncrypted( (char *)& klientId, 4 );
|
|
|
|
+ k->getNachrichtEncrypted( &ret, 1 );
|
|
|
|
+ bool erf = ret == 1;
|
|
|
|
+ k->sendeEncrypted( "\3", 1 );
|
|
|
|
+ k->getNachrichtEncrypted( &ret, 1 );
|
|
|
|
+ ms->addEmpfangen( k->getDownloadBytes( 1 ) );
|
|
|
|
+ ms->addGesendet( k->getUploadBytes( 1 ) );
|
|
|
|
+ k->trenne();
|
|
|
|
+ k->release();
|
|
|
|
+ return erf;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+bool MSGWeiterleitung::informationServerKlientAbsturz( int klientId )
|
|
|
|
+{
|
|
|
|
+ Text *ip = new Text();
|
|
|
|
+ int port = 0;
|
|
|
|
+ if( !ms->zDB()->getInformationServer( klientId, ip, &port ) )
|
|
|
|
+ {
|
|
|
|
+ ip->release();
|
|
|
|
+ return 0;
|
|
|
|
+ }
|
|
|
|
+ Klient *k = new Klient();
|
|
|
|
+ unsigned char key[ 20 ] = { 231, 246, 125, 32, 88, 172, 229, 223, 246, 138, 74, 64, 142, 245, 217, 218, 162, 62, 103, 50 };
|
|
|
|
+ k->setSendeKey( (char *)key, 20 );
|
|
|
|
+ k->setEmpfangKey( (char *)key, 20 );
|
|
|
|
+ k->verbinde( (unsigned short)port, ip->getText() );
|
|
|
|
+ ip->release();
|
|
|
|
+ char ret = 0;
|
|
|
|
+ k->sendeEncrypted( "\2\2", 2 );
|
|
|
|
+ k->sendeEncrypted( (char *)& klientId, 4 );
|
|
|
|
+ k->getNachrichtEncrypted( &ret, 1 );
|
|
|
|
+ bool erf = ret == 1;
|
|
|
|
+ k->sendeEncrypted( "\3", 1 );
|
|
|
|
+ k->getNachrichtEncrypted( &ret, 1 );
|
|
|
|
+ ms->addEmpfangen( k->getDownloadBytes( 1 ) );
|
|
|
|
+ ms->addGesendet( k->getUploadBytes( 1 ) );
|
|
|
|
+ k->trenne();
|
|
|
|
+ k->release();
|
|
|
|
+ return erf;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+bool MSGWeiterleitung::chatServerKlientAbsturz( int klientId )
|
|
|
|
+{
|
|
|
|
+ Text *ip = new Text();
|
|
|
|
+ int port = 0;
|
|
|
|
+ if( !ms->zDB()->getChatServer( klientId, ip, &port ) )
|
|
|
|
+ {
|
|
|
|
+ ip->release();
|
|
|
|
+ return 0;
|
|
|
|
+ }
|
|
|
|
+ Klient *k = new Klient();
|
|
|
|
+ unsigned char key[ 20 ] = { 78, 20, 190, 133, 10, 175, 51, 96, 62, 1, 180, 194, 126, 50, 211, 154, 105, 227, 22, 101 };
|
|
|
|
+ k->setSendeKey( (char *)key, 20 );
|
|
|
|
+ k->setEmpfangKey( (char *)key, 20 );
|
|
|
|
+ k->verbinde( (unsigned short)port, ip->getText() );
|
|
|
|
+ ip->release();
|
|
|
|
+ char ret = 0;
|
|
|
|
+ k->sendeEncrypted( "\2\2", 2 );
|
|
|
|
+ k->sendeEncrypted( (char *)& klientId, 4 );
|
|
|
|
+ k->getNachrichtEncrypted( &ret, 1 );
|
|
|
|
+ bool erf = ret == 1;
|
|
|
|
+ k->sendeEncrypted( "\3", 1 );
|
|
|
|
+ k->getNachrichtEncrypted( &ret, 1 );
|
|
|
|
+ ms->addEmpfangen( k->getDownloadBytes( 1 ) );
|
|
|
|
+ ms->addGesendet( k->getUploadBytes( 1 ) );
|
|
|
|
+ k->trenne();
|
|
|
|
+ k->release();
|
|
|
|
+ return erf;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+bool MSGWeiterleitung::anmeldungServerKlientAbsturz( int klientId )
|
|
|
|
+{
|
|
|
|
+ Text *ip = new Text();
|
|
|
|
+ int port = 0;
|
|
|
|
+ if( !ms->zDB()->getAnmeldungServer( klientId, ip, &port ) )
|
|
|
|
+ {
|
|
|
|
+ ip->release();
|
|
|
|
+ return 0;
|
|
|
|
+ }
|
|
|
|
+ Klient *k = new Klient();
|
|
|
|
+ unsigned char key[ 20 ] = { 158, 10, 37, 155, 117, 58, 28, 197, 132, 76, 252, 83, 84, 222, 11, 125, 240, 218, 25, 201 };
|
|
|
|
+ k->setSendeKey( (char *)key, 20 );
|
|
|
|
+ k->setEmpfangKey( (char *)key, 20 );
|
|
|
|
+ k->verbinde( (unsigned short)port, ip->getText() );
|
|
|
|
+ ip->release();
|
|
|
|
+ char ret = 0;
|
|
|
|
+ k->sendeEncrypted( "\2\2", 2 );
|
|
|
|
+ k->sendeEncrypted( (char *)& klientId, 4 );
|
|
|
|
+ k->getNachrichtEncrypted( &ret, 1 );
|
|
|
|
+ bool erf = ret == 1;
|
|
|
|
+ k->sendeEncrypted( "\3", 1 );
|
|
|
|
+ k->getNachrichtEncrypted( &ret, 1 );
|
|
|
|
+ ms->addEmpfangen( k->getDownloadBytes( 1 ) );
|
|
|
|
+ ms->addGesendet( k->getUploadBytes( 1 ) );
|
|
|
|
+ k->trenne();
|
|
|
|
+ k->release();
|
|
|
|
+ return erf;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+bool MSGWeiterleitung::spielServerKlientAbsturz( int klientId )
|
|
|
|
+{
|
|
|
|
+ Text *ip = new Text();
|
|
|
|
+ int port = 0;
|
|
|
|
+ if( !ms->zDB()->getSpielServer( klientId, ip, &port ) )
|
|
|
|
+ {
|
|
|
|
+ ip->release();
|
|
|
|
+ return 0;
|
|
|
|
+ }
|
|
|
|
+ Klient *k = new Klient();
|
|
|
|
+ unsigned char key[ 20 ] = { 253, 234, 211, 132, 121, 230, 95, 145, 201, 13, 43, 77, 153, 223, 253, 69, 234, 43, 52, 99 };
|
|
|
|
+ k->setSendeKey( (char *)key, 20 );
|
|
|
|
+ k->setEmpfangKey( (char *)key, 20 );
|
|
|
|
+ k->verbinde( (unsigned short)port, ip->getText() );
|
|
|
|
+ ip->release();
|
|
|
|
+ char ret = 0;
|
|
|
|
+ k->sendeEncrypted( "\2\2", 2 );
|
|
|
|
+ k->sendeEncrypted( (char *)& klientId, 4 );
|
|
|
|
+ k->getNachrichtEncrypted( &ret, 1 );
|
|
|
|
+ bool erf = ret == 1;
|
|
|
|
+ k->sendeEncrypted( "\3", 1 );
|
|
|
|
+ k->getNachrichtEncrypted( &ret, 1 );
|
|
|
|
+ ms->addEmpfangen( k->getDownloadBytes( 1 ) );
|
|
|
|
+ ms->addGesendet( k->getUploadBytes( 1 ) );
|
|
|
|
+ k->trenne();
|
|
|
|
+ k->release();
|
|
|
|
+ return erf;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+bool MSGWeiterleitung::shopServerKlientAbsturz( int klientId )
|
|
|
|
+{
|
|
|
|
+ Text *ip = new Text();
|
|
|
|
+ int port = 0;
|
|
|
|
+ if( !ms->zDB()->getShopServer( klientId, ip, &port ) )
|
|
|
|
+ {
|
|
|
|
+ ip->release();
|
|
|
|
+ return 0;
|
|
|
|
+ }
|
|
|
|
+ Klient *k = new Klient();
|
|
|
|
+ unsigned char key[ 20 ] = { 218, 226, 231, 216, 68, 63, 132, 155, 49, 235, 239, 0, 19, 23, 116, 244, 235, 21, 189, 53 };
|
|
|
|
+ k->setSendeKey( (char *)key, 20 );
|
|
|
|
+ k->setEmpfangKey( (char *)key, 20 );
|
|
|
|
+ k->verbinde( (unsigned short)port, ip->getText() );
|
|
|
|
+ ip->release();
|
|
|
|
+ char ret = 0;
|
|
|
|
+ k->sendeEncrypted( "\2\2", 2 );
|
|
|
|
+ k->sendeEncrypted( (char *)& klientId, 4 );
|
|
|
|
+ k->getNachrichtEncrypted( &ret, 1 );
|
|
|
|
+ bool erf = ret == 1;
|
|
|
|
+ k->sendeEncrypted( "\3", 1 );
|
|
|
|
+ k->getNachrichtEncrypted( &ret, 1 );
|
|
|
|
+ ms->addEmpfangen( k->getDownloadBytes( 1 ) );
|
|
|
|
+ ms->addGesendet( k->getUploadBytes( 1 ) );
|
|
|
|
+ k->trenne();
|
|
|
|
+ k->release();
|
|
|
|
+ return erf;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+bool MSGWeiterleitung::newsServerKlientAbsturz( int klientId )
|
|
|
|
+{
|
|
|
|
+ Text *ip = new Text();
|
|
|
|
+ int port = 0;
|
|
|
|
+ if( !ms->zDB()->getNewsServer( klientId, ip, &port ) )
|
|
|
|
+ {
|
|
|
|
+ ip->release();
|
|
|
|
+ return 0;
|
|
|
|
+ }
|
|
|
|
+ Klient *k = new Klient();
|
|
|
|
+ unsigned char key[ 20 ] = { 4, 150, 243, 145, 204, 71, 253, 88, 4, 51, 189, 207, 189, 248, 231, 40, 106, 7, 182, 5 };
|
|
|
|
+ k->setSendeKey( (char *)key, 20 );
|
|
|
|
+ k->setEmpfangKey( (char *)key, 20 );
|
|
|
|
+ k->verbinde( (unsigned short)port, ip->getText() );
|
|
|
|
+ ip->release();
|
|
|
|
+ char ret = 0;
|
|
|
|
+ k->sendeEncrypted( "\2\2", 2 );
|
|
|
|
+ k->sendeEncrypted( (char *)& klientId, 4 );
|
|
|
|
+ k->getNachrichtEncrypted( &ret, 1 );
|
|
|
|
+ bool erf = ret == 1;
|
|
|
|
+ k->sendeEncrypted( "\3", 1 );
|
|
|
|
+ k->getNachrichtEncrypted( &ret, 1 );
|
|
|
|
+ ms->addEmpfangen( k->getDownloadBytes( 1 ) );
|
|
|
|
+ ms->addGesendet( k->getUploadBytes( 1 ) );
|
|
|
|
+ k->trenne();
|
|
|
|
+ k->release();
|
|
|
|
+ return erf;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+bool MSGWeiterleitung::historieServerKlientAbsturz( int klientId )
|
|
|
|
+{
|
|
|
|
+ Text *ip = new Text();
|
|
|
|
+ int port = 0;
|
|
|
|
+ if( !ms->zDB()->getHistorieServer( klientId, ip, &port ) )
|
|
|
|
+ {
|
|
|
|
+ ip->release();
|
|
|
|
+ return 0;
|
|
|
|
+ }
|
|
|
|
+ Klient *k = new Klient();
|
|
|
|
+ unsigned char key[ 20 ] = { 207, 30, 72, 46, 30, 50, 56, 213, 82, 107, 14, 201, 149, 58, 110, 138, 228, 241, 52, 54 };
|
|
|
|
+ k->setSendeKey( (char *)key, 20 );
|
|
|
|
+ k->setEmpfangKey( (char *)key, 20 );
|
|
|
|
+ k->verbinde( (unsigned short)port, ip->getText() );
|
|
|
|
+ ip->release();
|
|
|
|
+ char ret = 0;
|
|
|
|
+ k->sendeEncrypted( "\2\2", 2 );
|
|
|
|
+ k->sendeEncrypted( (char *)& klientId, 4 );
|
|
|
|
+ k->getNachrichtEncrypted( &ret, 1 );
|
|
|
|
+ bool erf = ret == 1;
|
|
|
|
+ k->sendeEncrypted( "\3", 1 );
|
|
|
|
+ k->getNachrichtEncrypted( &ret, 1 );
|
|
|
|
+ ms->addEmpfangen( k->getDownloadBytes( 1 ) );
|
|
|
|
+ ms->addGesendet( k->getUploadBytes( 1 ) );
|
|
|
|
+ k->trenne();
|
|
|
|
+ k->release();
|
|
|
|
+ return erf;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+bool MSGWeiterleitung::kartenServerKlientAbsturz( int klientId )
|
|
|
|
+{
|
|
|
|
+ Text *ip = new Text();
|
|
|
|
+ int port = 0;
|
|
|
|
+ if( !ms->zDB()->getKartenServer( klientId, ip, &port ) )
|
|
|
|
+ {
|
|
|
|
+ ip->release();
|
|
|
|
+ return 0;
|
|
|
|
+ }
|
|
|
|
+ Klient *k = new Klient();
|
|
unsigned char key[ 20 ] = { 24, 15, 53, 87, 38, 73, 154, 38, 246, 90, 39, 133, 11, 199, 22, 80, 26, 132, 95, 54 };
|
|
unsigned char key[ 20 ] = { 24, 15, 53, 87, 38, 73, 154, 38, 246, 90, 39, 133, 11, 199, 22, 80, 26, 132, 95, 54 };
|
|
- k->setSendeKey( (char*)key, 20 );
|
|
|
|
- k->setEmpfangKey( (char*)key, 20 );
|
|
|
|
|
|
+ k->setSendeKey( (char *)key, 20 );
|
|
|
|
+ k->setEmpfangKey( (char *)key, 20 );
|
|
k->verbinde( (unsigned short)port, ip->getText() );
|
|
k->verbinde( (unsigned short)port, ip->getText() );
|
|
ip->release();
|
|
ip->release();
|
|
char ret = 0;
|
|
char ret = 0;
|
|
k->sendeEncrypted( "\2\2", 2 );
|
|
k->sendeEncrypted( "\2\2", 2 );
|
|
- k->sendeEncrypted( (char*)&klientId, 4 );
|
|
|
|
|
|
+ k->sendeEncrypted( (char *)& klientId, 4 );
|
|
k->getNachrichtEncrypted( &ret, 1 );
|
|
k->getNachrichtEncrypted( &ret, 1 );
|
|
bool erf = ret == 1;
|
|
bool erf = ret == 1;
|
|
k->sendeEncrypted( "\3", 1 );
|
|
k->sendeEncrypted( "\3", 1 );
|
|
@@ -1445,13 +1425,13 @@ bool MSGWeiterleitung::editorServerKlientAbsturz( int klientId )
|
|
}
|
|
}
|
|
Klient *k = new Klient();
|
|
Klient *k = new Klient();
|
|
unsigned char key[ 20 ] = { 55, 124, 19, 204, 23, 5, 59, 75, 247, 138, 119, 111, 57, 250, 206, 187, 165, 6, 247, 151 };
|
|
unsigned char key[ 20 ] = { 55, 124, 19, 204, 23, 5, 59, 75, 247, 138, 119, 111, 57, 250, 206, 187, 165, 6, 247, 151 };
|
|
- k->setSendeKey( (char*)key, 20 );
|
|
|
|
- k->setEmpfangKey( (char*)key, 20 );
|
|
|
|
|
|
+ k->setSendeKey( (char *)key, 20 );
|
|
|
|
+ k->setEmpfangKey( (char *)key, 20 );
|
|
k->verbinde( (unsigned short)port, ip->getText() );
|
|
k->verbinde( (unsigned short)port, ip->getText() );
|
|
ip->release();
|
|
ip->release();
|
|
char ret = 0;
|
|
char ret = 0;
|
|
k->sendeEncrypted( "\2\2", 2 );
|
|
k->sendeEncrypted( "\2\2", 2 );
|
|
- k->sendeEncrypted( (char*)&klientId, 4 );
|
|
|
|
|
|
+ k->sendeEncrypted( (char *)& klientId, 4 );
|
|
k->getNachrichtEncrypted( &ret, 1 );
|
|
k->getNachrichtEncrypted( &ret, 1 );
|
|
bool erf = ret == 1;
|
|
bool erf = ret == 1;
|
|
k->sendeEncrypted( "\3", 1 );
|
|
k->sendeEncrypted( "\3", 1 );
|
|
@@ -1474,13 +1454,13 @@ bool MSGWeiterleitung::minigameServerKlientAbsturz( int klientId )
|
|
}
|
|
}
|
|
Klient *k = new Klient();
|
|
Klient *k = new Klient();
|
|
unsigned char key[ 20 ] = { 88, 103, 192, 232, 69, 54, 57, 3, 239, 138, 234, 172, 126, 72, 81, 55, 205, 97, 59, 255 };
|
|
unsigned char key[ 20 ] = { 88, 103, 192, 232, 69, 54, 57, 3, 239, 138, 234, 172, 126, 72, 81, 55, 205, 97, 59, 255 };
|
|
- k->setSendeKey( (char*)key, 20 );
|
|
|
|
- k->setEmpfangKey( (char*)key, 20 );
|
|
|
|
|
|
+ k->setSendeKey( (char *)key, 20 );
|
|
|
|
+ k->setEmpfangKey( (char *)key, 20 );
|
|
k->verbinde( (unsigned short)port, ip->getText() );
|
|
k->verbinde( (unsigned short)port, ip->getText() );
|
|
ip->release();
|
|
ip->release();
|
|
char ret = 0;
|
|
char ret = 0;
|
|
k->sendeEncrypted( "\2\2", 2 );
|
|
k->sendeEncrypted( "\2\2", 2 );
|
|
- k->sendeEncrypted( (char*)&klientId, 4 );
|
|
|
|
|
|
+ k->sendeEncrypted( (char *)& klientId, 4 );
|
|
k->getNachrichtEncrypted( &ret, 1 );
|
|
k->getNachrichtEncrypted( &ret, 1 );
|
|
bool erf = ret == 1;
|
|
bool erf = ret == 1;
|
|
k->sendeEncrypted( "\3", 1 );
|
|
k->sendeEncrypted( "\3", 1 );
|
|
@@ -1494,248 +1474,248 @@ bool MSGWeiterleitung::minigameServerKlientAbsturz( int klientId )
|
|
|
|
|
|
bool MSGWeiterleitung::spielErstelltAbbrechen( int spielErstelltId )
|
|
bool MSGWeiterleitung::spielErstelltAbbrechen( int spielErstelltId )
|
|
{
|
|
{
|
|
- bool ret = 1;
|
|
|
|
- Text *ip = new Text( "" );
|
|
|
|
- unsigned short port = 0;
|
|
|
|
- ret = ret & ms->zDB()->getSpielServerPortIp( spielErstelltId, &port, ip );
|
|
|
|
- if( ip->getLength() )
|
|
|
|
- {
|
|
|
|
- Klient *klient = new Klient();
|
|
|
|
- unsigned char key[ 20 ] = { 253, 234, 211, 132, 121, 230, 95, 145, 201, 13, 43, 77, 153, 223, 253, 69, 234, 43, 52, 99 };
|
|
|
|
- klient->setSendeKey( (char*)key, 20 );
|
|
|
|
- klient->setEmpfangKey( (char*)key, 20 );
|
|
|
|
- ret = ret & klient->verbinde( port, ip->getText() );
|
|
|
|
- ret = ret & klient->sendeEncrypted( "\x8\x1", 2 );
|
|
|
|
- char res = 0;
|
|
|
|
- ret = ret & klient->getNachrichtEncrypted( &res, 1 );
|
|
|
|
- if( res )
|
|
|
|
- {
|
|
|
|
- ret = ret & klient->sendeEncrypted( (char*)&spielErstelltId, 4 );
|
|
|
|
- ret = ret & klient->getNachrichtEncrypted( &res, 1 );
|
|
|
|
- }
|
|
|
|
- ret = (char)ret & res;
|
|
|
|
- ret = ret & klient->sendeEncrypted( "\x8\x0", 2 );
|
|
|
|
- ret = ret & klient->getNachrichtEncrypted( &res, 1 );
|
|
|
|
- ret = (char)ret & res;
|
|
|
|
- ms->addEmpfangen( klient->getDownloadBytes( 1 ) );
|
|
|
|
- ms->addGesendet( klient->getUploadBytes( 1 ) );
|
|
|
|
- klient->trenne();
|
|
|
|
- klient = klient->release();
|
|
|
|
- ip->release();
|
|
|
|
- }
|
|
|
|
- return ret;
|
|
|
|
|
|
+ bool ret = 1;
|
|
|
|
+ Text *ip = new Text( "" );
|
|
|
|
+ unsigned short port = 0;
|
|
|
|
+ ret = ret & ms->zDB()->getSpielServerPortIp( spielErstelltId, &port, ip );
|
|
|
|
+ if( ip->getLength() )
|
|
|
|
+ {
|
|
|
|
+ Klient *klient = new Klient();
|
|
|
|
+ unsigned char key[ 20 ] = { 253, 234, 211, 132, 121, 230, 95, 145, 201, 13, 43, 77, 153, 223, 253, 69, 234, 43, 52, 99 };
|
|
|
|
+ klient->setSendeKey( (char *)key, 20 );
|
|
|
|
+ klient->setEmpfangKey( (char *)key, 20 );
|
|
|
|
+ ret = ret & klient->verbinde( port, ip->getText() );
|
|
|
|
+ ret = ret & klient->sendeEncrypted( "\x8\x1", 2 );
|
|
|
|
+ char res = 0;
|
|
|
|
+ ret = ret & klient->getNachrichtEncrypted( &res, 1 );
|
|
|
|
+ if( res )
|
|
|
|
+ {
|
|
|
|
+ ret = ret & klient->sendeEncrypted( (char *)& spielErstelltId, 4 );
|
|
|
|
+ ret = ret & klient->getNachrichtEncrypted( &res, 1 );
|
|
|
|
+ }
|
|
|
|
+ ret = (char)ret & res;
|
|
|
|
+ ret = ret & klient->sendeEncrypted( "\x8\x0", 2 );
|
|
|
|
+ ret = ret & klient->getNachrichtEncrypted( &res, 1 );
|
|
|
|
+ ret = (char)ret & res;
|
|
|
|
+ ms->addEmpfangen( klient->getDownloadBytes( 1 ) );
|
|
|
|
+ ms->addGesendet( klient->getUploadBytes( 1 ) );
|
|
|
|
+ klient->trenne();
|
|
|
|
+ klient = klient->release();
|
|
|
|
+ ip->release();
|
|
|
|
+ }
|
|
|
|
+ return ret;
|
|
}
|
|
}
|
|
|
|
|
|
bool MSGWeiterleitung::spielerLeavesGruppe( int gruppeId, int accountId )
|
|
bool MSGWeiterleitung::spielerLeavesGruppe( int gruppeId, int accountId )
|
|
{
|
|
{
|
|
- bool ret = 1;
|
|
|
|
- Array< int > *accId = new Array< int >();
|
|
|
|
- int anzahl = ms->zDB()->getSpielerAusGruppe( gruppeId, accId );
|
|
|
|
- for( int i = 0; i < anzahl; i++ )
|
|
|
|
- {
|
|
|
|
- int account = accId->get( i );
|
|
|
|
- if( account == accountId )
|
|
|
|
- continue;
|
|
|
|
- Text *ip = new Text( "" );
|
|
|
|
- unsigned short port = 0;
|
|
|
|
- ret = ret & ms->zDB()->getChatServerPortIp( account, &port, ip );
|
|
|
|
- if( ip->getLength() )
|
|
|
|
- {
|
|
|
|
- Klient *klient = new Klient();
|
|
|
|
- unsigned char key[ 20 ] = { 78, 20, 190, 133, 10, 175, 51, 96, 62, 1, 180, 194, 126, 50, 211, 154, 105, 227, 22, 101 };
|
|
|
|
- klient->setSendeKey( (char*)key, 20 );
|
|
|
|
- klient->setEmpfangKey( (char*)key, 20 );
|
|
|
|
- ret = ret & klient->verbinde( port, ip->getText() );
|
|
|
|
- ret = ret & klient->sendeEncrypted( "\5\x15", 2 );
|
|
|
|
- char res = 0;
|
|
|
|
- ret = ret & klient->getNachrichtEncrypted( &res, 1 );
|
|
|
|
- if( res )
|
|
|
|
- {
|
|
|
|
- ret = ret & klient->sendeEncrypted( (char*)&account, 4 );
|
|
|
|
- ret = ret & klient->sendeEncrypted( (char*)&accountId, 4 );
|
|
|
|
- ret = ret & klient->sendeEncrypted( (char*)&gruppeId, 4 );
|
|
|
|
- ret = ret & klient->getNachrichtEncrypted( &res, 1 );
|
|
|
|
- }
|
|
|
|
- ret = (char)ret & res;
|
|
|
|
- ret = ret & klient->sendeEncrypted( "\5\x18", 2 );
|
|
|
|
- res = 0;
|
|
|
|
- ret = ret & klient->getNachrichtEncrypted( &res, 1 );
|
|
|
|
- if( res )
|
|
|
|
- {
|
|
|
|
- ret = ret & klient->sendeEncrypted( (char*)&account, 4 );
|
|
|
|
- ret = ret & klient->sendeEncrypted( (char*)&gruppeId, 4 );
|
|
|
|
- ret = ret & klient->getNachrichtEncrypted( &res, 1 );
|
|
|
|
- }
|
|
|
|
- ret = (char)ret & res;
|
|
|
|
- ms->addEmpfangen( klient->getDownloadBytes( 1 ) );
|
|
|
|
- ms->addGesendet( klient->getUploadBytes( 1 ) );
|
|
|
|
- klient->trenne();
|
|
|
|
- klient = klient->release();
|
|
|
|
- }
|
|
|
|
- ip->release();
|
|
|
|
- }
|
|
|
|
- accId->release();
|
|
|
|
- return ret;
|
|
|
|
|
|
+ bool ret = 1;
|
|
|
|
+ Array< int > *accId = new Array< int >();
|
|
|
|
+ int anzahl = ms->zDB()->getSpielerAusGruppe( gruppeId, accId );
|
|
|
|
+ for( int i = 0; i < anzahl; i++ )
|
|
|
|
+ {
|
|
|
|
+ int account = accId->get( i );
|
|
|
|
+ if( account == accountId )
|
|
|
|
+ continue;
|
|
|
|
+ Text * ip = new Text( "" );
|
|
|
|
+ unsigned short port = 0;
|
|
|
|
+ ret = ret & ms->zDB()->getChatServerPortIp( account, &port, ip );
|
|
|
|
+ if( ip->getLength() )
|
|
|
|
+ {
|
|
|
|
+ Klient *klient = new Klient();
|
|
|
|
+ unsigned char key[ 20 ] = { 78, 20, 190, 133, 10, 175, 51, 96, 62, 1, 180, 194, 126, 50, 211, 154, 105, 227, 22, 101 };
|
|
|
|
+ klient->setSendeKey( (char *)key, 20 );
|
|
|
|
+ klient->setEmpfangKey( (char *)key, 20 );
|
|
|
|
+ ret = ret & klient->verbinde( port, ip->getText() );
|
|
|
|
+ ret = ret & klient->sendeEncrypted( "\5\x15", 2 );
|
|
|
|
+ char res = 0;
|
|
|
|
+ ret = ret & klient->getNachrichtEncrypted( &res, 1 );
|
|
|
|
+ if( res )
|
|
|
|
+ {
|
|
|
|
+ ret = ret & klient->sendeEncrypted( (char *)& account, 4 );
|
|
|
|
+ ret = ret & klient->sendeEncrypted( (char *)& accountId, 4 );
|
|
|
|
+ ret = ret & klient->sendeEncrypted( (char *)& gruppeId, 4 );
|
|
|
|
+ ret = ret & klient->getNachrichtEncrypted( &res, 1 );
|
|
|
|
+ }
|
|
|
|
+ ret = (char)ret & res;
|
|
|
|
+ ret = ret & klient->sendeEncrypted( "\5\x18", 2 );
|
|
|
|
+ res = 0;
|
|
|
|
+ ret = ret & klient->getNachrichtEncrypted( &res, 1 );
|
|
|
|
+ if( res )
|
|
|
|
+ {
|
|
|
|
+ ret = ret & klient->sendeEncrypted( (char *)& account, 4 );
|
|
|
|
+ ret = ret & klient->sendeEncrypted( (char *)& gruppeId, 4 );
|
|
|
|
+ ret = ret & klient->getNachrichtEncrypted( &res, 1 );
|
|
|
|
+ }
|
|
|
|
+ ret = (char)ret & res;
|
|
|
|
+ ms->addEmpfangen( klient->getDownloadBytes( 1 ) );
|
|
|
|
+ ms->addGesendet( klient->getUploadBytes( 1 ) );
|
|
|
|
+ klient->trenne();
|
|
|
|
+ klient = klient->release();
|
|
|
|
+ }
|
|
|
|
+ ip->release();
|
|
|
|
+ }
|
|
|
|
+ accId->release();
|
|
|
|
+ return ret;
|
|
}
|
|
}
|
|
|
|
|
|
bool MSGWeiterleitung::setGruppeAdmin( int gruppeId, int adminId )
|
|
bool MSGWeiterleitung::setGruppeAdmin( int gruppeId, int adminId )
|
|
{
|
|
{
|
|
- if( !adminId || !gruppeId )
|
|
|
|
- return 0;
|
|
|
|
- bool ret = 1;
|
|
|
|
- Array< int > *accId = new Array< int >();
|
|
|
|
- int anzahl = ms->zDB()->getSpielerAusGruppe( gruppeId, accId );
|
|
|
|
- for( int i = 0; i < anzahl; i++ )
|
|
|
|
- {
|
|
|
|
- int account = accId->get( i );
|
|
|
|
- Text *ip = new Text( "" );
|
|
|
|
- unsigned short port = 0;
|
|
|
|
- ret = ret & ms->zDB()->getChatServerPortIp( account, &port, ip );
|
|
|
|
- if( ip->getLength() )
|
|
|
|
- {
|
|
|
|
- Klient *klient = new Klient();
|
|
|
|
- unsigned char key[ 20 ] = { 78, 20, 190, 133, 10, 175, 51, 96, 62, 1, 180, 194, 126, 50, 211, 154, 105, 227, 22, 101 };
|
|
|
|
- klient->setSendeKey( (char*)key, 20 );
|
|
|
|
- klient->setEmpfangKey( (char*)key, 20 );
|
|
|
|
- ret = ret & klient->verbinde( port, ip->getText() );
|
|
|
|
- ret = ret & klient->sendeEncrypted( "\5\x1B", 2 );
|
|
|
|
- char res = 0;
|
|
|
|
- ret = ret & klient->getNachrichtEncrypted( &res, 1 );
|
|
|
|
- if( res )
|
|
|
|
- {
|
|
|
|
- ret = ret & klient->sendeEncrypted( (char*)&account, 4 );
|
|
|
|
- ret = ret & klient->sendeEncrypted( (char*)&adminId, 4 );
|
|
|
|
- ret = ret & klient->sendeEncrypted( (char*)&gruppeId, 4 );
|
|
|
|
- ret = ret & klient->getNachrichtEncrypted( &res, 1 );
|
|
|
|
- }
|
|
|
|
- ret = (char)ret & res;
|
|
|
|
- ms->addEmpfangen( klient->getDownloadBytes( 1 ) );
|
|
|
|
- ms->addGesendet( klient->getUploadBytes( 1 ) );
|
|
|
|
- klient->trenne();
|
|
|
|
- klient = klient->release();
|
|
|
|
- }
|
|
|
|
- ip->release();
|
|
|
|
- }
|
|
|
|
- accId->release();
|
|
|
|
- return ret;
|
|
|
|
|
|
+ if( !adminId || !gruppeId )
|
|
|
|
+ return 0;
|
|
|
|
+ bool ret = 1;
|
|
|
|
+ Array< int > * accId = new Array< int >();
|
|
|
|
+ int anzahl = ms->zDB()->getSpielerAusGruppe( gruppeId, accId );
|
|
|
|
+ for( int i = 0; i < anzahl; i++ )
|
|
|
|
+ {
|
|
|
|
+ int account = accId->get( i );
|
|
|
|
+ Text *ip = new Text( "" );
|
|
|
|
+ unsigned short port = 0;
|
|
|
|
+ ret = ret & ms->zDB()->getChatServerPortIp( account, &port, ip );
|
|
|
|
+ if( ip->getLength() )
|
|
|
|
+ {
|
|
|
|
+ Klient *klient = new Klient();
|
|
|
|
+ unsigned char key[ 20 ] = { 78, 20, 190, 133, 10, 175, 51, 96, 62, 1, 180, 194, 126, 50, 211, 154, 105, 227, 22, 101 };
|
|
|
|
+ klient->setSendeKey( (char *)key, 20 );
|
|
|
|
+ klient->setEmpfangKey( (char *)key, 20 );
|
|
|
|
+ ret = ret & klient->verbinde( port, ip->getText() );
|
|
|
|
+ ret = ret & klient->sendeEncrypted( "\5\x1B", 2 );
|
|
|
|
+ char res = 0;
|
|
|
|
+ ret = ret & klient->getNachrichtEncrypted( &res, 1 );
|
|
|
|
+ if( res )
|
|
|
|
+ {
|
|
|
|
+ ret = ret & klient->sendeEncrypted( (char *)& account, 4 );
|
|
|
|
+ ret = ret & klient->sendeEncrypted( (char *)& adminId, 4 );
|
|
|
|
+ ret = ret & klient->sendeEncrypted( (char *)& gruppeId, 4 );
|
|
|
|
+ ret = ret & klient->getNachrichtEncrypted( &res, 1 );
|
|
|
|
+ }
|
|
|
|
+ ret = (char)ret & res;
|
|
|
|
+ ms->addEmpfangen( klient->getDownloadBytes( 1 ) );
|
|
|
|
+ ms->addGesendet( klient->getUploadBytes( 1 ) );
|
|
|
|
+ klient->trenne();
|
|
|
|
+ klient = klient->release();
|
|
|
|
+ }
|
|
|
|
+ ip->release();
|
|
|
|
+ }
|
|
|
|
+ accId->release();
|
|
|
|
+ return ret;
|
|
}
|
|
}
|
|
|
|
|
|
bool MSGWeiterleitung::spielerLeavesChatroom( int chatroomId, int accountId )
|
|
bool MSGWeiterleitung::spielerLeavesChatroom( int chatroomId, int accountId )
|
|
{
|
|
{
|
|
- bool ret = 1;
|
|
|
|
- Array< int > *accId = new Array< int >();
|
|
|
|
- int anzahl = ms->zDB()->getSpielerAusChatroom( chatroomId, accId );
|
|
|
|
- for( int i = 0; i < anzahl; i++ )
|
|
|
|
- {
|
|
|
|
- int account = accId->get( i );
|
|
|
|
- if( account == accountId )
|
|
|
|
- continue;
|
|
|
|
- Text *ip = new Text( "" );
|
|
|
|
- unsigned short port = 0;
|
|
|
|
- ret = ret & ms->zDB()->getChatServerPortIp( account, &port, ip );
|
|
|
|
- if( ip->getLength() )
|
|
|
|
- {
|
|
|
|
- Klient *klient = new Klient();
|
|
|
|
- unsigned char key[ 20 ] = { 78, 20, 190, 133, 10, 175, 51, 96, 62, 1, 180, 194, 126, 50, 211, 154, 105, 227, 22, 101 };
|
|
|
|
- klient->setSendeKey( (char*)key, 20 );
|
|
|
|
- klient->setEmpfangKey( (char*)key, 20 );
|
|
|
|
- ret = ret & klient->verbinde( port, ip->getText() );
|
|
|
|
- ret = ret & klient->sendeEncrypted( "\5\xE", 2 );
|
|
|
|
- char res = 0;
|
|
|
|
- ret = ret & klient->getNachrichtEncrypted( &res, 1 );
|
|
|
|
- if( res )
|
|
|
|
- {
|
|
|
|
- ret = ret & klient->sendeEncrypted( (char*)&accountId, 4 );
|
|
|
|
- ret = ret & klient->sendeEncrypted( (char*)&account, 4 );
|
|
|
|
- ret = ret & klient->sendeEncrypted( (char*)&chatroomId, 4 );
|
|
|
|
- ret = ret & klient->getNachrichtEncrypted( &res, 1 );
|
|
|
|
- }
|
|
|
|
- ret = (char)ret & res;
|
|
|
|
- ms->addEmpfangen( klient->getDownloadBytes( 1 ) );
|
|
|
|
- ms->addGesendet( klient->getUploadBytes( 1 ) );
|
|
|
|
- klient->trenne();
|
|
|
|
- klient = klient->release();
|
|
|
|
- }
|
|
|
|
- ip->release();
|
|
|
|
- }
|
|
|
|
- accId->release();
|
|
|
|
- return ret;
|
|
|
|
|
|
+ bool ret = 1;
|
|
|
|
+ Array< int > *accId = new Array< int >();
|
|
|
|
+ int anzahl = ms->zDB()->getSpielerAusChatroom( chatroomId, accId );
|
|
|
|
+ for( int i = 0; i < anzahl; i++ )
|
|
|
|
+ {
|
|
|
|
+ int account = accId->get( i );
|
|
|
|
+ if( account == accountId )
|
|
|
|
+ continue;
|
|
|
|
+ Text * ip = new Text( "" );
|
|
|
|
+ unsigned short port = 0;
|
|
|
|
+ ret = ret & ms->zDB()->getChatServerPortIp( account, &port, ip );
|
|
|
|
+ if( ip->getLength() )
|
|
|
|
+ {
|
|
|
|
+ Klient *klient = new Klient();
|
|
|
|
+ unsigned char key[ 20 ] = { 78, 20, 190, 133, 10, 175, 51, 96, 62, 1, 180, 194, 126, 50, 211, 154, 105, 227, 22, 101 };
|
|
|
|
+ klient->setSendeKey( (char *)key, 20 );
|
|
|
|
+ klient->setEmpfangKey( (char *)key, 20 );
|
|
|
|
+ ret = ret & klient->verbinde( port, ip->getText() );
|
|
|
|
+ ret = ret & klient->sendeEncrypted( "\5\xE", 2 );
|
|
|
|
+ char res = 0;
|
|
|
|
+ ret = ret & klient->getNachrichtEncrypted( &res, 1 );
|
|
|
|
+ if( res )
|
|
|
|
+ {
|
|
|
|
+ ret = ret & klient->sendeEncrypted( (char *)& accountId, 4 );
|
|
|
|
+ ret = ret & klient->sendeEncrypted( (char *)& account, 4 );
|
|
|
|
+ ret = ret & klient->sendeEncrypted( (char *)& chatroomId, 4 );
|
|
|
|
+ ret = ret & klient->getNachrichtEncrypted( &res, 1 );
|
|
|
|
+ }
|
|
|
|
+ ret = (char)ret & res;
|
|
|
|
+ ms->addEmpfangen( klient->getDownloadBytes( 1 ) );
|
|
|
|
+ ms->addGesendet( klient->getUploadBytes( 1 ) );
|
|
|
|
+ klient->trenne();
|
|
|
|
+ klient = klient->release();
|
|
|
|
+ }
|
|
|
|
+ ip->release();
|
|
|
|
+ }
|
|
|
|
+ accId->release();
|
|
|
|
+ return ret;
|
|
}
|
|
}
|
|
|
|
|
|
bool MSGWeiterleitung::setChatroomAdmin( int chatroomId, int adminId )
|
|
bool MSGWeiterleitung::setChatroomAdmin( int chatroomId, int adminId )
|
|
{
|
|
{
|
|
- if( !adminId || !chatroomId )
|
|
|
|
- return 0;
|
|
|
|
- bool ret = 1;
|
|
|
|
- Text *ip = new Text( "" );
|
|
|
|
- unsigned short port = 0;
|
|
|
|
- ret = ret & ms->zDB()->getChatServerPortIp( adminId, &port, ip );
|
|
|
|
- if( ip->getLength() )
|
|
|
|
- {
|
|
|
|
- Klient *klient = new Klient();
|
|
|
|
- unsigned char key[ 20 ] = { 78, 20, 190, 133, 10, 175, 51, 96, 62, 1, 180, 194, 126, 50, 211, 154, 105, 227, 22, 101 };
|
|
|
|
- klient->setSendeKey( (char*)key, 20 );
|
|
|
|
- klient->setEmpfangKey( (char*)key, 20 );
|
|
|
|
- ret = ret & klient->verbinde( port, ip->getText() );
|
|
|
|
- ret = ret & klient->sendeEncrypted( "\5\x12", 2 );
|
|
|
|
- char res = 0;
|
|
|
|
- ret = ret & klient->getNachrichtEncrypted( &res, 1 );
|
|
|
|
- if( res )
|
|
|
|
- {
|
|
|
|
- ret = ret & klient->sendeEncrypted( (char*)&adminId, 4 );
|
|
|
|
- ret = ret & klient->sendeEncrypted( (char*)&chatroomId, 4 );
|
|
|
|
- ret = ret & klient->getNachrichtEncrypted( &res, 1 );
|
|
|
|
- }
|
|
|
|
- ret = (char)ret & res;
|
|
|
|
- ms->addEmpfangen( klient->getDownloadBytes( 1 ) );
|
|
|
|
- ms->addGesendet( klient->getUploadBytes( 1 ) );
|
|
|
|
- klient->trenne();
|
|
|
|
- klient = klient->release();
|
|
|
|
- }
|
|
|
|
- ip->release();
|
|
|
|
- return ret;
|
|
|
|
|
|
+ if( !adminId || !chatroomId )
|
|
|
|
+ return 0;
|
|
|
|
+ bool ret = 1;
|
|
|
|
+ Text * ip = new Text( "" );
|
|
|
|
+ unsigned short port = 0;
|
|
|
|
+ ret = ret & ms->zDB()->getChatServerPortIp( adminId, &port, ip );
|
|
|
|
+ if( ip->getLength() )
|
|
|
|
+ {
|
|
|
|
+ Klient *klient = new Klient();
|
|
|
|
+ unsigned char key[ 20 ] = { 78, 20, 190, 133, 10, 175, 51, 96, 62, 1, 180, 194, 126, 50, 211, 154, 105, 227, 22, 101 };
|
|
|
|
+ klient->setSendeKey( (char *)key, 20 );
|
|
|
|
+ klient->setEmpfangKey( (char *)key, 20 );
|
|
|
|
+ ret = ret & klient->verbinde( port, ip->getText() );
|
|
|
|
+ ret = ret & klient->sendeEncrypted( "\5\x12", 2 );
|
|
|
|
+ char res = 0;
|
|
|
|
+ ret = ret & klient->getNachrichtEncrypted( &res, 1 );
|
|
|
|
+ if( res )
|
|
|
|
+ {
|
|
|
|
+ ret = ret & klient->sendeEncrypted( (char *)& adminId, 4 );
|
|
|
|
+ ret = ret & klient->sendeEncrypted( (char *)& chatroomId, 4 );
|
|
|
|
+ ret = ret & klient->getNachrichtEncrypted( &res, 1 );
|
|
|
|
+ }
|
|
|
|
+ ret = (char)ret & res;
|
|
|
|
+ ms->addEmpfangen( klient->getDownloadBytes( 1 ) );
|
|
|
|
+ ms->addGesendet( klient->getUploadBytes( 1 ) );
|
|
|
|
+ klient->trenne();
|
|
|
|
+ klient = klient->release();
|
|
|
|
+ }
|
|
|
|
+ ip->release();
|
|
|
|
+ return ret;
|
|
}
|
|
}
|
|
|
|
|
|
bool MSGWeiterleitung::kickSpielerAusGruppe( int gruppeId )
|
|
bool MSGWeiterleitung::kickSpielerAusGruppe( int gruppeId )
|
|
{
|
|
{
|
|
- if( !gruppeId )
|
|
|
|
- return 0;
|
|
|
|
- bool ret = 1;
|
|
|
|
- Array< int > *accId = new Array< int >();
|
|
|
|
- int anzahl = ms->zDB()->getSpielerAusGruppe( gruppeId, accId );
|
|
|
|
- for( int i = 0; i < anzahl; i++ )
|
|
|
|
- {
|
|
|
|
- int account = accId->get( i );
|
|
|
|
- Text *ip = new Text( "" );
|
|
|
|
- unsigned short port = 0;
|
|
|
|
- ret = ret & ms->zDB()->getChatServerPortIp( account, &port, ip );
|
|
|
|
- if( ip->getLength() )
|
|
|
|
- {
|
|
|
|
- Klient *klient = new Klient();
|
|
|
|
- unsigned char key[ 20 ] = { 78, 20, 190, 133, 10, 175, 51, 96, 62, 1, 180, 194, 126, 50, 211, 154, 105, 227, 22, 101 };
|
|
|
|
- klient->setSendeKey( (char*)key, 20 );
|
|
|
|
- klient->setEmpfangKey( (char*)key, 20 );
|
|
|
|
- ret = ret & klient->verbinde( port, ip->getText() );
|
|
|
|
- ret = ret & klient->sendeEncrypted( "\5\x16", 2 );
|
|
|
|
- char res = 0;
|
|
|
|
- ret = ret & klient->getNachrichtEncrypted( &res, 1 );
|
|
|
|
- if( res )
|
|
|
|
- {
|
|
|
|
- ret = ret & klient->sendeEncrypted( (char*)&account, 4 );
|
|
|
|
- ret = ret & klient->sendeEncrypted( (char*)&gruppeId, 4 );
|
|
|
|
- ret = ret & klient->getNachrichtEncrypted( &res, 1 );
|
|
|
|
- }
|
|
|
|
- ret = (char)ret & res;
|
|
|
|
- ms->addEmpfangen( klient->getDownloadBytes( 1 ) );
|
|
|
|
- ms->addGesendet( klient->getUploadBytes( 1 ) );
|
|
|
|
- klient->trenne();
|
|
|
|
- klient = klient->release();
|
|
|
|
- }
|
|
|
|
- ms->zDB()->kickSpielerAusGruppe( gruppeId, account );
|
|
|
|
- ip->release();
|
|
|
|
- }
|
|
|
|
- accId->release();
|
|
|
|
- return ret;
|
|
|
|
|
|
+ if( !gruppeId )
|
|
|
|
+ return 0;
|
|
|
|
+ bool ret = 1;
|
|
|
|
+ Array< int > * accId = new Array< int >();
|
|
|
|
+ int anzahl = ms->zDB()->getSpielerAusGruppe( gruppeId, accId );
|
|
|
|
+ for( int i = 0; i < anzahl; i++ )
|
|
|
|
+ {
|
|
|
|
+ int account = accId->get( i );
|
|
|
|
+ Text *ip = new Text( "" );
|
|
|
|
+ unsigned short port = 0;
|
|
|
|
+ ret = ret & ms->zDB()->getChatServerPortIp( account, &port, ip );
|
|
|
|
+ if( ip->getLength() )
|
|
|
|
+ {
|
|
|
|
+ Klient *klient = new Klient();
|
|
|
|
+ unsigned char key[ 20 ] = { 78, 20, 190, 133, 10, 175, 51, 96, 62, 1, 180, 194, 126, 50, 211, 154, 105, 227, 22, 101 };
|
|
|
|
+ klient->setSendeKey( (char *)key, 20 );
|
|
|
|
+ klient->setEmpfangKey( (char *)key, 20 );
|
|
|
|
+ ret = ret & klient->verbinde( port, ip->getText() );
|
|
|
|
+ ret = ret & klient->sendeEncrypted( "\5\x16", 2 );
|
|
|
|
+ char res = 0;
|
|
|
|
+ ret = ret & klient->getNachrichtEncrypted( &res, 1 );
|
|
|
|
+ if( res )
|
|
|
|
+ {
|
|
|
|
+ ret = ret & klient->sendeEncrypted( (char *)& account, 4 );
|
|
|
|
+ ret = ret & klient->sendeEncrypted( (char *)& gruppeId, 4 );
|
|
|
|
+ ret = ret & klient->getNachrichtEncrypted( &res, 1 );
|
|
|
|
+ }
|
|
|
|
+ ret = (char)ret & res;
|
|
|
|
+ ms->addEmpfangen( klient->getDownloadBytes( 1 ) );
|
|
|
|
+ ms->addGesendet( klient->getUploadBytes( 1 ) );
|
|
|
|
+ klient->trenne();
|
|
|
|
+ klient = klient->release();
|
|
|
|
+ }
|
|
|
|
+ ms->zDB()->kickSpielerAusGruppe( gruppeId, account );
|
|
|
|
+ ip->release();
|
|
|
|
+ }
|
|
|
|
+ accId->release();
|
|
|
|
+ return ret;
|
|
}
|
|
}
|
|
|
|
|
|
// constant
|
|
// constant
|
|
@@ -1743,14 +1723,14 @@ bool MSGWeiterleitung::kickSpielerAusGruppe( int gruppeId )
|
|
// Reference Counting
|
|
// Reference Counting
|
|
MSGWeiterleitung *MSGWeiterleitung::getThis()
|
|
MSGWeiterleitung *MSGWeiterleitung::getThis()
|
|
{
|
|
{
|
|
- ref++;
|
|
|
|
- return this;
|
|
|
|
|
|
+ ref++;
|
|
|
|
+ return this;
|
|
}
|
|
}
|
|
|
|
|
|
MSGWeiterleitung *MSGWeiterleitung::release()
|
|
MSGWeiterleitung *MSGWeiterleitung::release()
|
|
{
|
|
{
|
|
- ref--;
|
|
|
|
- if( !ref )
|
|
|
|
- delete this;
|
|
|
|
- return 0;
|
|
|
|
|
|
+ ref--;
|
|
|
|
+ if( !ref )
|
|
|
|
+ delete this;
|
|
|
|
+ return 0;
|
|
}
|
|
}
|