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