|
@@ -23,7 +23,10 @@ SpielServer::SpielServer( InitDatei *zIni )
|
|
ini = zIni->getThis();
|
|
ini = zIni->getThis();
|
|
id = *zIni->zWert( "ServerId" );
|
|
id = *zIni->zWert( "ServerId" );
|
|
server = new Server();
|
|
server = new Server();
|
|
- aServer = new Server();
|
|
|
|
|
|
+ aServer = new SSLServer();
|
|
|
|
+ aServer->setPrivateKeyPassword( zIni->zWert( "SSLPasswort" )->getText() );
|
|
|
|
+ aServer->setCertificateFile( zIni->zWert( "SSLCert" )->getText() );
|
|
|
|
+ aServer->setPrivateKeyFile( zIni->zWert( "SSLKey" )->getText() );
|
|
std::cout << "SS: Starten des Admin Servers...\n";
|
|
std::cout << "SS: Starten des Admin Servers...\n";
|
|
if( !aServer->verbinde( (unsigned short)TextZuInt( ini->zWert( "AdminServerPort" )->getText(), 10 ), 10 ) )
|
|
if( !aServer->verbinde( (unsigned short)TextZuInt( ini->zWert( "AdminServerPort" )->getText(), 10 ), 10 ) )
|
|
{
|
|
{
|
|
@@ -91,7 +94,7 @@ void SpielServer::runn()
|
|
{
|
|
{
|
|
while( !end )
|
|
while( !end )
|
|
{
|
|
{
|
|
- SKlient *klient;
|
|
|
|
|
|
+ SSLSKlient *klient;
|
|
klient = aServer->getKlient();
|
|
klient = aServer->getKlient();
|
|
if( end && klient )
|
|
if( end && klient )
|
|
{
|
|
{
|
|
@@ -665,13 +668,10 @@ SpielServer *SpielServer::release()
|
|
|
|
|
|
// Inhalt der SSAKlient Klasse aus SpielServer.h
|
|
// Inhalt der SSAKlient Klasse aus SpielServer.h
|
|
// Konstruktor
|
|
// Konstruktor
|
|
-SSAKlient::SSAKlient( SKlient *klient, SpielServer *ss )
|
|
|
|
|
|
+SSAKlient::SSAKlient( SSLSKlient *klient, SpielServer *ss )
|
|
: Thread()
|
|
: Thread()
|
|
{
|
|
{
|
|
this->klient = klient;
|
|
this->klient = klient;
|
|
- unsigned char key[ 20 ] = { 148, 52, 231, 50, 20, 138, 243, 178, 149, 24, 69, 60, 68, 116, 10, 161, 178, 148, 32, 212 };
|
|
|
|
- klient->setSendeKey( (char*)key, 20 );
|
|
|
|
- klient->setEmpfangKey( (char*)key, 20 );
|
|
|
|
name = new Text( "" );
|
|
name = new Text( "" );
|
|
passwort = new Text( "" );
|
|
passwort = new Text( "" );
|
|
adminId = 0;
|
|
adminId = 0;
|
|
@@ -695,7 +695,7 @@ void SSAKlient::thread()
|
|
while( 1 )
|
|
while( 1 )
|
|
{
|
|
{
|
|
char c = 0;
|
|
char c = 0;
|
|
- if( !klient->getNachrichtEncrypted( &c, 1 ) )
|
|
|
|
|
|
+ if( !klient->getNachricht( &c, 1 ) )
|
|
break;
|
|
break;
|
|
else
|
|
else
|
|
{
|
|
{
|
|
@@ -705,23 +705,23 @@ void SSAKlient::thread()
|
|
case 1: // Login
|
|
case 1: // Login
|
|
if( 1 )
|
|
if( 1 )
|
|
{
|
|
{
|
|
- klient->sendeEncrypted( "\1", 1 );
|
|
|
|
|
|
+ klient->sende( "\1", 1 );
|
|
unsigned char nLen = 0;
|
|
unsigned char nLen = 0;
|
|
- klient->getNachrichtEncrypted( (char*)&nLen, 1 );
|
|
|
|
|
|
+ klient->getNachricht( (char*)&nLen, 1 );
|
|
char *n = new char[ nLen + 1 ];
|
|
char *n = new char[ nLen + 1 ];
|
|
n[ (int)nLen ] = 0;
|
|
n[ (int)nLen ] = 0;
|
|
if( nLen )
|
|
if( nLen )
|
|
- klient->getNachrichtEncrypted( n, nLen );
|
|
|
|
|
|
+ klient->getNachricht( n, nLen );
|
|
unsigned char pLen = 0;
|
|
unsigned char pLen = 0;
|
|
- klient->getNachrichtEncrypted( (char*)&pLen, 1 );
|
|
|
|
|
|
+ klient->getNachricht( (char*)&pLen, 1 );
|
|
char *p = new char[ pLen + 1 ];
|
|
char *p = new char[ pLen + 1 ];
|
|
p[ (int)pLen ] = 0;
|
|
p[ (int)pLen ] = 0;
|
|
if( pLen )
|
|
if( pLen )
|
|
- klient->getNachrichtEncrypted( p, pLen );
|
|
|
|
|
|
+ klient->getNachricht( p, pLen );
|
|
int adminId = ss->zDB()->istAdministrator( n, p );
|
|
int adminId = ss->zDB()->istAdministrator( n, p );
|
|
if( adminId )
|
|
if( adminId )
|
|
{
|
|
{
|
|
- klient->sendeEncrypted( "\1", 1 );
|
|
|
|
|
|
+ klient->sende( "\1", 1 );
|
|
name->setText( n );
|
|
name->setText( n );
|
|
passwort->setText( p );
|
|
passwort->setText( p );
|
|
this->adminId = adminId;
|
|
this->adminId = adminId;
|
|
@@ -736,11 +736,11 @@ void SSAKlient::thread()
|
|
adminId = 0;
|
|
adminId = 0;
|
|
name->setText( "" );
|
|
name->setText( "" );
|
|
passwort->setText( "" );
|
|
passwort->setText( "" );
|
|
- klient->sendeEncrypted( "\1", 1 );
|
|
|
|
|
|
+ klient->sende( "\1", 1 );
|
|
break;
|
|
break;
|
|
case 3: // Trennen
|
|
case 3: // Trennen
|
|
br = 1;
|
|
br = 1;
|
|
- klient->sendeEncrypted( "\1", 1 );
|
|
|
|
|
|
+ klient->sende( "\1", 1 );
|
|
break;
|
|
break;
|
|
case 4: // Server starten
|
|
case 4: // Server starten
|
|
if( !adminId )
|
|
if( !adminId )
|
|
@@ -757,7 +757,7 @@ void SSAKlient::thread()
|
|
err->release();
|
|
err->release();
|
|
}
|
|
}
|
|
else
|
|
else
|
|
- klient->sendeEncrypted( "\1", 1 );
|
|
|
|
|
|
+ klient->sende( "\1", 1 );
|
|
}
|
|
}
|
|
else
|
|
else
|
|
errorZuKlient( "Du bist nicht berechtigt den Server zu starten." );
|
|
errorZuKlient( "Du bist nicht berechtigt den Server zu starten." );
|
|
@@ -771,7 +771,7 @@ void SSAKlient::thread()
|
|
if( ss->zDB()->adminHatRecht( adminId, Admin_Recht::SSBeenden ) )
|
|
if( ss->zDB()->adminHatRecht( adminId, Admin_Recht::SSBeenden ) )
|
|
{
|
|
{
|
|
if( ss->serverBeenden() )
|
|
if( ss->serverBeenden() )
|
|
- klient->sendeEncrypted( "\1", 1 );
|
|
|
|
|
|
+ klient->sende( "\1", 1 );
|
|
else
|
|
else
|
|
{
|
|
{
|
|
Text *err = new Text();
|
|
Text *err = new Text();
|
|
@@ -816,7 +816,7 @@ void SSAKlient::thread()
|
|
}
|
|
}
|
|
if( ok )
|
|
if( ok )
|
|
{
|
|
{
|
|
- klient->sendeEncrypted( "\1", 1 );
|
|
|
|
|
|
+ klient->sende( "\1", 1 );
|
|
std::cout << "SS: Der Server wird von Benutzer " << adminId << " heruntergefahren.\n";
|
|
std::cout << "SS: Der Server wird von Benutzer " << adminId << " heruntergefahren.\n";
|
|
ss->close();
|
|
ss->close();
|
|
br = 1;
|
|
br = 1;
|
|
@@ -843,7 +843,7 @@ void SSAKlient::thread()
|
|
ok = 1;
|
|
ok = 1;
|
|
if( ok )
|
|
if( ok )
|
|
{
|
|
{
|
|
- klient->sendeEncrypted( "\1", 1 );
|
|
|
|
|
|
+ klient->sende( "\1", 1 );
|
|
std::cout << "sS: Der Server wurde von Benutzer " << adminId << " terminiert.\n";
|
|
std::cout << "sS: Der Server wurde von Benutzer " << adminId << " terminiert.\n";
|
|
ss->close();
|
|
ss->close();
|
|
br = 1;
|
|
br = 1;
|
|
@@ -860,8 +860,8 @@ void SSAKlient::thread()
|
|
if( ss->istAn() )
|
|
if( ss->istAn() )
|
|
status = 2;
|
|
status = 2;
|
|
}
|
|
}
|
|
- klient->sendeEncrypted( "\1", 1 );
|
|
|
|
- klient->sendeEncrypted( &status, 1 );
|
|
|
|
|
|
+ klient->sende( "\1", 1 );
|
|
|
|
+ klient->sende( &status, 1 );
|
|
}
|
|
}
|
|
break;
|
|
break;
|
|
case 9: // Server pausieren
|
|
case 9: // Server pausieren
|
|
@@ -869,9 +869,9 @@ void SSAKlient::thread()
|
|
errorZuKlient( "Du musst dich einloggen." );
|
|
errorZuKlient( "Du musst dich einloggen." );
|
|
else
|
|
else
|
|
{
|
|
{
|
|
- klient->sendeEncrypted( "\1", 1 );
|
|
|
|
|
|
+ klient->sende( "\1", 1 );
|
|
char pause = 0;
|
|
char pause = 0;
|
|
- klient->getNachrichtEncrypted( &pause, 1 );
|
|
|
|
|
|
+ klient->getNachricht( &pause, 1 );
|
|
if( ss->zDB()->adminHatRecht( adminId, Admin_Recht::SSPausieren ) )
|
|
if( ss->zDB()->adminHatRecht( adminId, Admin_Recht::SSPausieren ) )
|
|
{
|
|
{
|
|
bool ok = 0;
|
|
bool ok = 0;
|
|
@@ -880,7 +880,7 @@ void SSAKlient::thread()
|
|
else
|
|
else
|
|
ok = ss->serverFortsetzen();
|
|
ok = ss->serverFortsetzen();
|
|
if( ok )
|
|
if( ok )
|
|
- klient->sendeEncrypted( "\1", 1 );
|
|
|
|
|
|
+ klient->sende( "\1", 1 );
|
|
else
|
|
else
|
|
{
|
|
{
|
|
Text *err = new Text();
|
|
Text *err = new Text();
|
|
@@ -903,13 +903,13 @@ void SSAKlient::thread()
|
|
errorZuKlient( "Du musst dich einloggen." );
|
|
errorZuKlient( "Du musst dich einloggen." );
|
|
else
|
|
else
|
|
{
|
|
{
|
|
- klient->sendeEncrypted( "\1", 1 );
|
|
|
|
|
|
+ klient->sende( "\1", 1 );
|
|
int maxS = 0;
|
|
int maxS = 0;
|
|
- klient->getNachrichtEncrypted( (char*)&maxS, 4 );
|
|
|
|
|
|
+ klient->getNachricht( (char*)&maxS, 4 );
|
|
if( ss->zDB()->adminHatRecht( adminId, Admin_Recht::SSMSChange ) )
|
|
if( ss->zDB()->adminHatRecht( adminId, Admin_Recht::SSMSChange ) )
|
|
{
|
|
{
|
|
if( ss->setMaxSpiele( maxS ) )
|
|
if( ss->setMaxSpiele( maxS ) )
|
|
- klient->sendeEncrypted( "\1", 1 );
|
|
|
|
|
|
+ klient->sende( "\1", 1 );
|
|
else
|
|
else
|
|
{
|
|
{
|
|
Text *err = new Text();
|
|
Text *err = new Text();
|
|
@@ -927,9 +927,9 @@ void SSAKlient::thread()
|
|
errorZuKlient( "Zugriff verweigert." );
|
|
errorZuKlient( "Zugriff verweigert." );
|
|
else
|
|
else
|
|
{
|
|
{
|
|
- klient->sendeEncrypted( "\1", 1 );
|
|
|
|
|
|
+ klient->sende( "\1", 1 );
|
|
int spielId = 0;
|
|
int spielId = 0;
|
|
- klient->getNachrichtEncrypted( (char*)&spielId, 4 );
|
|
|
|
|
|
+ klient->getNachricht( (char*)&spielId, 4 );
|
|
if( !ss->hatSpielHistorieId( spielId ) )
|
|
if( !ss->hatSpielHistorieId( spielId ) )
|
|
{
|
|
{
|
|
errorZuKlient( "Zugriff auf Spiel-Historie verweigert." );
|
|
errorZuKlient( "Zugriff auf Spiel-Historie verweigert." );
|
|
@@ -944,23 +944,23 @@ void SSAKlient::thread()
|
|
errorZuKlient( "Die Spiel-Historie wurde nicht gefunden." );
|
|
errorZuKlient( "Die Spiel-Historie wurde nicht gefunden." );
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
- klient->sendeEncrypted( "\1", 1 );
|
|
|
|
|
|
+ klient->sende( "\1", 1 );
|
|
pfad->remove( "/fertig" );
|
|
pfad->remove( "/fertig" );
|
|
sendeVerzeichnisAnKlient( *pfad, pfad->getLength() + 1 );
|
|
sendeVerzeichnisAnKlient( *pfad, pfad->getLength() + 1 );
|
|
pfad->release();
|
|
pfad->release();
|
|
- klient->sendeEncrypted( "\0", 1 );
|
|
|
|
|
|
+ klient->sende( "\0", 1 );
|
|
}
|
|
}
|
|
break;
|
|
break;
|
|
case 0xC: // klient absturtz
|
|
case 0xC: // klient absturtz
|
|
if( 1 )
|
|
if( 1 )
|
|
{
|
|
{
|
|
- klient->sendeEncrypted( "\1", 1 );
|
|
|
|
|
|
+ klient->sende( "\1", 1 );
|
|
int klientId = 0;
|
|
int klientId = 0;
|
|
- klient->getNachrichtEncrypted( (char*)&klientId, 4 );
|
|
|
|
|
|
+ klient->getNachricht( (char*)&klientId, 4 );
|
|
if( klientId && ss->absturzKlient( klientId ) )
|
|
if( klientId && ss->absturzKlient( klientId ) )
|
|
- klient->sendeEncrypted( "\1", 1 );
|
|
|
|
|
|
+ klient->sende( "\1", 1 );
|
|
else
|
|
else
|
|
- klient->sendeEncrypted( "\0", 1 );
|
|
|
|
|
|
+ klient->sende( "\0", 1 );
|
|
}
|
|
}
|
|
break;
|
|
break;
|
|
default:
|
|
default:
|
|
@@ -1005,9 +1005,9 @@ void SSAKlient::sendeVerzeichnisAnKlient( char *pfad, int gpl )
|
|
if( gr && d->zPfad()->getLength() - gpl > 0 && d->open( Datei::Style::lesen ) )
|
|
if( gr && d->zPfad()->getLength() - gpl > 0 && d->open( Datei::Style::lesen ) )
|
|
{
|
|
{
|
|
char pfLen = (char)( d->zPfad()->getLength() - gpl );
|
|
char pfLen = (char)( d->zPfad()->getLength() - gpl );
|
|
- klient->sendeEncrypted( &pfLen, 1 );
|
|
|
|
- klient->sendeEncrypted( d->zPfad()->getText() + gpl, pfLen );
|
|
|
|
- klient->sendeEncrypted( (char*)&gr, 8 );
|
|
|
|
|
|
+ klient->sende( &pfLen, 1 );
|
|
|
|
+ klient->sende( d->zPfad()->getText() + gpl, pfLen );
|
|
|
|
+ klient->sende( (char*)&gr, 8 );
|
|
char *bytes = new char[ 2048 ];
|
|
char *bytes = new char[ 2048 ];
|
|
while( gr )
|
|
while( gr )
|
|
{
|
|
{
|
|
@@ -1025,10 +1025,10 @@ void SSAKlient::sendeVerzeichnisAnKlient( char *pfad, int gpl )
|
|
|
|
|
|
void SSAKlient::errorZuKlient( const char *nachricht ) const // sendet eine Fehlernachricht zum Klient
|
|
void SSAKlient::errorZuKlient( const char *nachricht ) const // sendet eine Fehlernachricht zum Klient
|
|
{
|
|
{
|
|
- klient->sendeEncrypted( "\3", 1 );
|
|
|
|
|
|
+ klient->sende( "\3", 1 );
|
|
char len = (char)textLength( nachricht );
|
|
char len = (char)textLength( nachricht );
|
|
- klient->sendeEncrypted( &len, 1 );
|
|
|
|
- klient->sendeEncrypted( nachricht, len );
|
|
|
|
|
|
+ klient->sende( &len, 1 );
|
|
|
|
+ klient->sende( nachricht, len );
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|