|
@@ -26,7 +26,10 @@ PatchServer::PatchServer( InitDatei *zIni )
|
|
|
db->setDateiGruppe( id, TextZuInt( dgInit->zName( i )->getText(), 10 ), (int)TextZuInt( dgInit->zWert( i )->getText(), 10 ) );
|
|
|
dgInit->release();
|
|
|
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 << "PS: Starten des Admin Servers...\n";
|
|
|
if( !aServer->verbinde( (unsigned short)TextZuInt( ini->zWert( "AdminServerPort" )->getText(), 10 ), 10 ) )
|
|
|
{
|
|
@@ -68,7 +71,7 @@ void PatchServer::runn()
|
|
|
{
|
|
|
while( !end )
|
|
|
{
|
|
|
- SKlient *klient;
|
|
|
+ SSLSKlient *klient;
|
|
|
klient = aServer->getKlient();
|
|
|
if( end && klient )
|
|
|
{
|
|
@@ -553,13 +556,10 @@ PatchServer *PatchServer::release()
|
|
|
|
|
|
// Inhalt der PSAKlient Klasse aus PatchServer.h
|
|
|
// Konstruktor
|
|
|
-PSAKlient::PSAKlient( SKlient *klient, PatchServer *ps, InitDatei *ini )
|
|
|
+PSAKlient::PSAKlient( SSLSKlient *klient, PatchServer *ps, InitDatei *ini )
|
|
|
: Thread()
|
|
|
{
|
|
|
this->klient = klient;
|
|
|
- unsigned char key[ 20 ] = { 178, 218, 37, 140, 30, 8, 70, 197, 79, 42, 201, 81, 87, 199, 177, 183, 173, 129, 66, 110 };
|
|
|
- klient->setSendeKey( (char*)key, 20 );
|
|
|
- klient->setEmpfangKey( (char*)key, 20 );
|
|
|
name = new Text( "" );
|
|
|
passwort = new Text( "" );
|
|
|
adminId = 0;
|
|
@@ -588,7 +588,7 @@ void PSAKlient::thread()
|
|
|
while( 1 )
|
|
|
{
|
|
|
char c = 0;
|
|
|
- if( !klient->getNachrichtEncrypted( &c, 1 ) )
|
|
|
+ if( !klient->getNachricht( &c, 1 ) )
|
|
|
break;
|
|
|
else
|
|
|
{
|
|
@@ -598,23 +598,23 @@ void PSAKlient::thread()
|
|
|
case 1: // Login
|
|
|
if( 1 )
|
|
|
{
|
|
|
- klient->sendeEncrypted( "\1", 1 );
|
|
|
+ klient->sende( "\1", 1 );
|
|
|
unsigned char len = 0;
|
|
|
- klient->getNachrichtEncrypted( (char*)&len, 1 );
|
|
|
+ klient->getNachricht( (char*)&len, 1 );
|
|
|
char *n = new char[ len + 1 ];
|
|
|
n[ (int)len ] = 0;
|
|
|
if( len )
|
|
|
- klient->getNachrichtEncrypted( n, len );
|
|
|
+ klient->getNachricht( n, len );
|
|
|
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 = ps->zDB()->istAdministrator( n, p );
|
|
|
if( adminId )
|
|
|
{
|
|
|
- klient->sendeEncrypted( "\1", 1 );
|
|
|
+ klient->sende( "\1", 1 );
|
|
|
name->setText( n );
|
|
|
passwort->setText( p );
|
|
|
this->adminId = adminId;
|
|
@@ -629,11 +629,11 @@ void PSAKlient::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 )
|
|
@@ -650,7 +650,7 @@ void PSAKlient::thread()
|
|
|
err->release();
|
|
|
}
|
|
|
else
|
|
|
- klient->sendeEncrypted( "\1", 1 );
|
|
|
+ klient->sende( "\1", 1 );
|
|
|
}
|
|
|
else
|
|
|
errorZuKlient( "Du bist nicht berechtigt den Server zu starten." );
|
|
@@ -664,7 +664,7 @@ void PSAKlient::thread()
|
|
|
if( ps->zDB()->adminHatRecht( adminId, Admin_Recht::PSBeenden ) )
|
|
|
{
|
|
|
if( ps->serverBeenden() )
|
|
|
- klient->sendeEncrypted( "\1", 1 );
|
|
|
+ klient->sende( "\1", 1 );
|
|
|
else
|
|
|
{
|
|
|
Text *err = new Text();
|
|
@@ -709,7 +709,7 @@ void PSAKlient::thread()
|
|
|
}
|
|
|
if( ok )
|
|
|
{
|
|
|
- klient->sendeEncrypted( "\1", 1 );
|
|
|
+ klient->sende( "\1", 1 );
|
|
|
std::cout << "PS: Der Server wird von Benutzer " << adminId << " heruntergefahren.\n";
|
|
|
ps->close();
|
|
|
br = 1;
|
|
@@ -736,7 +736,7 @@ void PSAKlient::thread()
|
|
|
ok = 1;
|
|
|
if( ok )
|
|
|
{
|
|
|
- klient->sendeEncrypted( "\1", 1 );
|
|
|
+ klient->sende( "\1", 1 );
|
|
|
std::cout << "PS: Der Server wurde von Benutzer " << adminId << " terminiert.\n";
|
|
|
ps->close();
|
|
|
br = 1;
|
|
@@ -755,8 +755,8 @@ void PSAKlient::thread()
|
|
|
}
|
|
|
if( !ps->proveVersion() )
|
|
|
status = 3;
|
|
|
- klient->sendeEncrypted( "\1", 1 );
|
|
|
- klient->sendeEncrypted( &status, 1 );
|
|
|
+ klient->sende( "\1", 1 );
|
|
|
+ klient->sende( &status, 1 );
|
|
|
}
|
|
|
break;
|
|
|
case 9: // Server pausieren
|
|
@@ -764,9 +764,9 @@ void PSAKlient::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( ps->zDB()->adminHatRecht( adminId, Admin_Recht::PSPausieren ) )
|
|
|
{
|
|
|
bool ok = 0;
|
|
@@ -775,7 +775,7 @@ void PSAKlient::thread()
|
|
|
else
|
|
|
ok = ps->serverFortsetzen();
|
|
|
if( ok )
|
|
|
- klient->sendeEncrypted( "\1", 1 );
|
|
|
+ klient->sende( "\1", 1 );
|
|
|
else
|
|
|
{
|
|
|
Text *err = new Text();
|
|
@@ -798,13 +798,13 @@ void PSAKlient::thread()
|
|
|
errorZuKlient( "Du musst dich einloggen." );
|
|
|
else
|
|
|
{
|
|
|
- klient->sendeEncrypted( "\1", 1 );
|
|
|
+ klient->sende( "\1", 1 );
|
|
|
int maxC = 0;
|
|
|
- klient->getNachrichtEncrypted( (char*)&maxC, 4 );
|
|
|
+ klient->getNachricht( (char*)&maxC, 4 );
|
|
|
if( ps->zDB()->adminHatRecht( adminId, Admin_Recht::PSMCChange ) )
|
|
|
{
|
|
|
if( ps->setMaxKlients( maxC ) )
|
|
|
- klient->sendeEncrypted( "\1", 1 );
|
|
|
+ klient->sende( "\1", 1 );
|
|
|
else
|
|
|
{
|
|
|
Text *err = new Text();
|
|
@@ -825,13 +825,13 @@ void PSAKlient::thread()
|
|
|
}
|
|
|
if( updateGruppe )
|
|
|
{
|
|
|
- klient->sendeEncrypted( "\1", 1 );
|
|
|
+ klient->sende( "\1", 1 );
|
|
|
Result systemT = ps->zDB()->getSystemListe();
|
|
|
for( int i = 0; i < systemT.zeilenAnzahl; i++ )
|
|
|
{
|
|
|
int len = systemT.values[ i * 2 + 1 ].getLength();
|
|
|
- klient->sendeEncrypted( (char*)&len, 4 );
|
|
|
- klient->sendeEncrypted( systemT.values[ i * 2 + 1 ].getText(), len );
|
|
|
+ klient->sende( (char*)&len, 4 );
|
|
|
+ klient->sende( systemT.values[ i * 2 + 1 ].getText(), len );
|
|
|
Result dateiT = ps->zDB()->getDateiListeOhneOrdner( TextZuInt( systemT.values[ i * 2 ].getText(), 10 ), updateGruppe );
|
|
|
Text *pfad = new Text( ini->zWert( "SystemPfad" )->getText() );
|
|
|
pfad->append( "/" );
|
|
@@ -851,15 +851,15 @@ void PSAKlient::thread()
|
|
|
if( veraltet )
|
|
|
{
|
|
|
int len = dateiT.values[ j * 2 ].getLength();
|
|
|
- klient->sendeEncrypted( (char*)&len, 4 );
|
|
|
- klient->sendeEncrypted( dateiT.values[ j * 2 ].getText(), len );
|
|
|
+ klient->sende( (char*)&len, 4 );
|
|
|
+ klient->sende( dateiT.values[ j * 2 ].getText(), len );
|
|
|
}
|
|
|
}
|
|
|
- klient->sendeEncrypted( "\0\0\0\0", 4 );
|
|
|
+ klient->sende( "\0\0\0\0", 4 );
|
|
|
dateiT.destroy();
|
|
|
vIni->release();
|
|
|
}
|
|
|
- klient->sendeEncrypted( "\0\0\0\0", 4 );
|
|
|
+ klient->sende( "\0\0\0\0", 4 );
|
|
|
systemT.destroy();
|
|
|
}
|
|
|
else
|
|
@@ -880,7 +880,7 @@ void PSAKlient::thread()
|
|
|
if( gruppeN )
|
|
|
gruppeN = gruppeN->release();
|
|
|
std::cout << "PS: Update erfolgreich abgeschlossen.\n";
|
|
|
- klient->sendeEncrypted( "\1", 1 );
|
|
|
+ klient->sende( "\1", 1 );
|
|
|
}
|
|
|
break;
|
|
|
case 0xD: // Update Vorgang starten
|
|
@@ -893,8 +893,8 @@ void PSAKlient::thread()
|
|
|
errorZuKlient( "Du musst die Aktualisierung erst beenden." );
|
|
|
break;
|
|
|
}
|
|
|
- klient->sendeEncrypted( "\1", 1 );
|
|
|
- klient->getNachrichtEncrypted( (char*)&updateGruppe, 4 );
|
|
|
+ klient->sende( "\1", 1 );
|
|
|
+ klient->getNachricht( (char*)&updateGruppe, 4 );
|
|
|
gruppeN = ps->zDB()->getDateiGruppeName( updateGruppe );
|
|
|
if( !gruppeN )
|
|
|
{
|
|
@@ -908,7 +908,7 @@ void PSAKlient::thread()
|
|
|
{
|
|
|
if( ps->beginnUpdate( updateGruppe ) )
|
|
|
{
|
|
|
- klient->sendeEncrypted( "\1", 1 );
|
|
|
+ klient->sende( "\1", 1 );
|
|
|
std::cout << "PS: Die Dateigruppe " << updateGruppe << " wird von Benutzer " << adminId << " geupdatet.\n";
|
|
|
}
|
|
|
else
|
|
@@ -931,18 +931,18 @@ void PSAKlient::thread()
|
|
|
errorZuKlient( "Du musst zunächst den Aktualisierungsvorgang starten." );
|
|
|
break;
|
|
|
}
|
|
|
- klient->sendeEncrypted( "\1", 1 );
|
|
|
+ klient->sende( "\1", 1 );
|
|
|
int system = 0;
|
|
|
- klient->getNachrichtEncrypted( (char*)&system, 4 );
|
|
|
+ klient->getNachricht( (char*)&system, 4 );
|
|
|
int version = 0;
|
|
|
- klient->getNachrichtEncrypted( (char*)&version, 4 );
|
|
|
+ klient->getNachricht( (char*)&version, 4 );
|
|
|
Text *sName = ps->zDB()->getSystemName( system );
|
|
|
unsigned short len = 0;
|
|
|
- klient->getNachrichtEncrypted( (char*)&len, 2 );
|
|
|
+ klient->getNachricht( (char*)&len, 2 );
|
|
|
char *pfad = new char[ len + 1 ];
|
|
|
pfad[ len ] = 0;
|
|
|
if( len )
|
|
|
- klient->getNachrichtEncrypted( pfad, len );
|
|
|
+ klient->getNachricht( pfad, len );
|
|
|
if( !len || !sName )
|
|
|
{
|
|
|
errorZuKlient( "Die Datei konnte nicht angelegt werden." );
|
|
@@ -967,7 +967,7 @@ void PSAKlient::thread()
|
|
|
d->erstellen();
|
|
|
if( d->open( Datei::Style::schreiben ) )
|
|
|
{
|
|
|
- klient->sendeEncrypted( "\1", 1 );
|
|
|
+ klient->sende( "\1", 1 );
|
|
|
klient->getNachricht( (char*)&len, 2 );
|
|
|
while( len )
|
|
|
{
|
|
@@ -979,7 +979,7 @@ void PSAKlient::thread()
|
|
|
ps->addEmpfangen( klient->getDownloadBytes( 1 ) );
|
|
|
ps->addGesendet( klient->getUploadBytes( 1 ) );
|
|
|
}
|
|
|
- klient->sendeEncrypted( "\1", 1 );
|
|
|
+ klient->sende( "\1", 1 );
|
|
|
Text *vT = new Text();
|
|
|
vT->append( version );
|
|
|
if( !vIni->wertExistiert( pfad ) )
|
|
@@ -1000,13 +1000,13 @@ void PSAKlient::thread()
|
|
|
case 0xF: // 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 && ps->absturzKlient( klientId ) )
|
|
|
- klient->sendeEncrypted( "\1", 1 );
|
|
|
+ klient->sende( "\1", 1 );
|
|
|
else
|
|
|
- klient->sendeEncrypted( "\0", 1 );
|
|
|
+ klient->sende( "\0", 1 );
|
|
|
}
|
|
|
break;
|
|
|
default:
|
|
@@ -1028,10 +1028,10 @@ void PSAKlient::thread()
|
|
|
|
|
|
void PSAKlient::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 );
|
|
|
}
|
|
|
|
|
|
|