|
@@ -23,7 +23,10 @@ SpielServer::SpielServer( InitDatei *zIni )
|
|
|
ini = zIni->getThis();
|
|
|
id = *zIni->zWert( "ServerId" );
|
|
|
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";
|
|
|
if( !aServer->verbinde( (unsigned short)TextZuInt( ini->zWert( "AdminServerPort" )->getText(), 10 ), 10 ) )
|
|
|
{
|
|
@@ -91,7 +94,7 @@ void SpielServer::runn()
|
|
|
{
|
|
|
while( !end )
|
|
|
{
|
|
|
- SKlient *klient;
|
|
|
+ SSLSKlient *klient;
|
|
|
klient = aServer->getKlient();
|
|
|
if( end && klient )
|
|
|
{
|
|
@@ -665,13 +668,10 @@ SpielServer *SpielServer::release()
|
|
|
|
|
|
// Inhalt der SSAKlient Klasse aus SpielServer.h
|
|
|
// Konstruktor
|
|
|
-SSAKlient::SSAKlient( SKlient *klient, SpielServer *ss )
|
|
|
+SSAKlient::SSAKlient( SSLSKlient *klient, SpielServer *ss )
|
|
|
: Thread()
|
|
|
{
|
|
|
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( "" );
|
|
|
passwort = new Text( "" );
|
|
|
adminId = 0;
|
|
@@ -695,7 +695,7 @@ void SSAKlient::thread()
|
|
|
while( 1 )
|
|
|
{
|
|
|
char c = 0;
|
|
|
- if( !klient->getNachrichtEncrypted( &c, 1 ) )
|
|
|
+ if( !klient->getNachricht( &c, 1 ) )
|
|
|
break;
|
|
|
else
|
|
|
{
|
|
@@ -705,23 +705,23 @@ void SSAKlient::thread()
|
|
|
case 1: // Login
|
|
|
if( 1 )
|
|
|
{
|
|
|
- klient->sendeEncrypted( "\1", 1 );
|
|
|
+ klient->sende( "\1", 1 );
|
|
|
unsigned char nLen = 0;
|
|
|
- klient->getNachrichtEncrypted( (char*)&nLen, 1 );
|
|
|
+ klient->getNachricht( (char*)&nLen, 1 );
|
|
|
char *n = new char[ nLen + 1 ];
|
|
|
n[ (int)nLen ] = 0;
|
|
|
if( nLen )
|
|
|
- klient->getNachrichtEncrypted( n, nLen );
|
|
|
+ klient->getNachricht( n, nLen );
|
|
|
unsigned char pLen = 0;
|
|
|
- klient->getNachrichtEncrypted( (char*)&pLen, 1 );
|
|
|
+ klient->getNachricht( (char*)&pLen, 1 );
|
|
|
char *p = new char[ pLen + 1 ];
|
|
|
p[ (int)pLen ] = 0;
|
|
|
if( pLen )
|
|
|
- klient->getNachrichtEncrypted( p, pLen );
|
|
|
+ klient->getNachricht( p, pLen );
|
|
|
int adminId = ss->zDB()->istAdministrator( n, p );
|
|
|
if( adminId )
|
|
|
{
|
|
|
- klient->sendeEncrypted( "\1", 1 );
|
|
|
+ klient->sende( "\1", 1 );
|
|
|
name->setText( n );
|
|
|
passwort->setText( p );
|
|
|
this->adminId = adminId;
|
|
@@ -736,11 +736,11 @@ void SSAKlient::thread()
|
|
|
adminId = 0;
|
|
|
name->setText( "" );
|
|
|
passwort->setText( "" );
|
|
|
- klient->sendeEncrypted( "\1", 1 );
|
|
|
+ klient->sende( "\1", 1 );
|
|
|
break;
|
|
|
case 3: // Trennen
|
|
|
br = 1;
|
|
|
- klient->sendeEncrypted( "\1", 1 );
|
|
|
+ klient->sende( "\1", 1 );
|
|
|
break;
|
|
|
case 4: // Server starten
|
|
|
if( !adminId )
|
|
@@ -757,7 +757,7 @@ void SSAKlient::thread()
|
|
|
err->release();
|
|
|
}
|
|
|
else
|
|
|
- klient->sendeEncrypted( "\1", 1 );
|
|
|
+ klient->sende( "\1", 1 );
|
|
|
}
|
|
|
else
|
|
|
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->serverBeenden() )
|
|
|
- klient->sendeEncrypted( "\1", 1 );
|
|
|
+ klient->sende( "\1", 1 );
|
|
|
else
|
|
|
{
|
|
|
Text *err = new Text();
|
|
@@ -816,7 +816,7 @@ void SSAKlient::thread()
|
|
|
}
|
|
|
if( ok )
|
|
|
{
|
|
|
- klient->sendeEncrypted( "\1", 1 );
|
|
|
+ klient->sende( "\1", 1 );
|
|
|
std::cout << "SS: Der Server wird von Benutzer " << adminId << " heruntergefahren.\n";
|
|
|
ss->close();
|
|
|
br = 1;
|
|
@@ -843,7 +843,7 @@ void SSAKlient::thread()
|
|
|
ok = 1;
|
|
|
if( ok )
|
|
|
{
|
|
|
- klient->sendeEncrypted( "\1", 1 );
|
|
|
+ klient->sende( "\1", 1 );
|
|
|
std::cout << "sS: Der Server wurde von Benutzer " << adminId << " terminiert.\n";
|
|
|
ss->close();
|
|
|
br = 1;
|
|
@@ -860,8 +860,8 @@ void SSAKlient::thread()
|
|
|
if( ss->istAn() )
|
|
|
status = 2;
|
|
|
}
|
|
|
- klient->sendeEncrypted( "\1", 1 );
|
|
|
- klient->sendeEncrypted( &status, 1 );
|
|
|
+ klient->sende( "\1", 1 );
|
|
|
+ klient->sende( &status, 1 );
|
|
|
}
|
|
|
break;
|
|
|
case 9: // Server pausieren
|
|
@@ -869,9 +869,9 @@ void SSAKlient::thread()
|
|
|
errorZuKlient( "Du musst dich einloggen." );
|
|
|
else
|
|
|
{
|
|
|
- klient->sendeEncrypted( "\1", 1 );
|
|
|
+ klient->sende( "\1", 1 );
|
|
|
char pause = 0;
|
|
|
- klient->getNachrichtEncrypted( &pause, 1 );
|
|
|
+ klient->getNachricht( &pause, 1 );
|
|
|
if( ss->zDB()->adminHatRecht( adminId, Admin_Recht::SSPausieren ) )
|
|
|
{
|
|
|
bool ok = 0;
|
|
@@ -880,7 +880,7 @@ void SSAKlient::thread()
|
|
|
else
|
|
|
ok = ss->serverFortsetzen();
|
|
|
if( ok )
|
|
|
- klient->sendeEncrypted( "\1", 1 );
|
|
|
+ klient->sende( "\1", 1 );
|
|
|
else
|
|
|
{
|
|
|
Text *err = new Text();
|
|
@@ -903,13 +903,13 @@ void SSAKlient::thread()
|
|
|
errorZuKlient( "Du musst dich einloggen." );
|
|
|
else
|
|
|
{
|
|
|
- klient->sendeEncrypted( "\1", 1 );
|
|
|
+ klient->sende( "\1", 1 );
|
|
|
int maxS = 0;
|
|
|
- klient->getNachrichtEncrypted( (char*)&maxS, 4 );
|
|
|
+ klient->getNachricht( (char*)&maxS, 4 );
|
|
|
if( ss->zDB()->adminHatRecht( adminId, Admin_Recht::SSMSChange ) )
|
|
|
{
|
|
|
if( ss->setMaxSpiele( maxS ) )
|
|
|
- klient->sendeEncrypted( "\1", 1 );
|
|
|
+ klient->sende( "\1", 1 );
|
|
|
else
|
|
|
{
|
|
|
Text *err = new Text();
|
|
@@ -927,9 +927,9 @@ void SSAKlient::thread()
|
|
|
errorZuKlient( "Zugriff verweigert." );
|
|
|
else
|
|
|
{
|
|
|
- klient->sendeEncrypted( "\1", 1 );
|
|
|
+ klient->sende( "\1", 1 );
|
|
|
int spielId = 0;
|
|
|
- klient->getNachrichtEncrypted( (char*)&spielId, 4 );
|
|
|
+ klient->getNachricht( (char*)&spielId, 4 );
|
|
|
if( !ss->hatSpielHistorieId( spielId ) )
|
|
|
{
|
|
|
errorZuKlient( "Zugriff auf Spiel-Historie verweigert." );
|
|
@@ -944,23 +944,23 @@ void SSAKlient::thread()
|
|
|
errorZuKlient( "Die Spiel-Historie wurde nicht gefunden." );
|
|
|
break;
|
|
|
}
|
|
|
- klient->sendeEncrypted( "\1", 1 );
|
|
|
+ klient->sende( "\1", 1 );
|
|
|
pfad->remove( "/fertig" );
|
|
|
sendeVerzeichnisAnKlient( *pfad, pfad->getLength() + 1 );
|
|
|
pfad->release();
|
|
|
- klient->sendeEncrypted( "\0", 1 );
|
|
|
+ klient->sende( "\0", 1 );
|
|
|
}
|
|
|
break;
|
|
|
case 0xC: // klient absturtz
|
|
|
if( 1 )
|
|
|
{
|
|
|
- klient->sendeEncrypted( "\1", 1 );
|
|
|
+ klient->sende( "\1", 1 );
|
|
|
int klientId = 0;
|
|
|
- klient->getNachrichtEncrypted( (char*)&klientId, 4 );
|
|
|
+ klient->getNachricht( (char*)&klientId, 4 );
|
|
|
if( klientId && ss->absturzKlient( klientId ) )
|
|
|
- klient->sendeEncrypted( "\1", 1 );
|
|
|
+ klient->sende( "\1", 1 );
|
|
|
else
|
|
|
- klient->sendeEncrypted( "\0", 1 );
|
|
|
+ klient->sende( "\0", 1 );
|
|
|
}
|
|
|
break;
|
|
|
default:
|
|
@@ -1005,9 +1005,9 @@ void SSAKlient::sendeVerzeichnisAnKlient( char *pfad, int gpl )
|
|
|
if( gr && d->zPfad()->getLength() - gpl > 0 && d->open( Datei::Style::lesen ) )
|
|
|
{
|
|
|
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 ];
|
|
|
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
|
|
|
{
|
|
|
- klient->sendeEncrypted( "\3", 1 );
|
|
|
+ klient->sende( "\3", 1 );
|
|
|
char len = (char)textLength( nachricht );
|
|
|
- klient->sendeEncrypted( &len, 1 );
|
|
|
- klient->sendeEncrypted( nachricht, len );
|
|
|
+ klient->sende( &len, 1 );
|
|
|
+ klient->sende( nachricht, len );
|
|
|
}
|
|
|
|
|
|
|