|
@@ -19,10 +19,14 @@ MainServer::MainServer( InitDatei *zDat )
|
|
gesendet = 0;
|
|
gesendet = 0;
|
|
dat = zDat->getThis();
|
|
dat = zDat->getThis();
|
|
serverSSL = new SSLServer();
|
|
serverSSL = new SSLServer();
|
|
- serverSSL->setCertificateFile( zDat->zWert( "SSLCert" )->getText() );
|
|
|
|
- serverSSL->setCertificateFile( zDat->zWert( "SSLKey" )->getText() );
|
|
|
|
|
|
+ aServer->setPrivateKeyPassword( zDat->zWert( "SSLPasswort" )->getText() );
|
|
|
|
+ aServer->setCertificateFile( zDat->zWert( "SSLCert" )->getText() );
|
|
|
|
+ aServer->setPrivateKeyFile( zDat->zWert( "SSLKey" )->getText() );
|
|
server = new Server();
|
|
server = new Server();
|
|
- aServer = new Server();
|
|
|
|
|
|
+ aServer = new SSLServer();
|
|
|
|
+ aServer->setPrivateKeyPassword( zDat->zWert( "SSLPasswort" )->getText() );
|
|
|
|
+ aServer->setCertificateFile( zDat->zWert( "SSLCert" )->getText() );
|
|
|
|
+ aServer->setPrivateKeyFile( zDat->zWert( "SSLKey" )->getText() );
|
|
std::cout << "MS: Starten des Admin Servers...\n";
|
|
std::cout << "MS: Starten des Admin Servers...\n";
|
|
if( !aServer->verbinde( (unsigned short)TextZuInt( zDat->zWert( "AdminServerPort" )->getText(), 10 ), 10 ) )
|
|
if( !aServer->verbinde( (unsigned short)TextZuInt( zDat->zWert( "AdminServerPort" )->getText(), 10 ), 10 ) )
|
|
{
|
|
{
|
|
@@ -57,7 +61,7 @@ void MainServer::runn()
|
|
{
|
|
{
|
|
while( !end )
|
|
while( !end )
|
|
{
|
|
{
|
|
- SKlient *klient;
|
|
|
|
|
|
+ SSLSKlient *klient;
|
|
klient = aServer->getKlient();
|
|
klient = aServer->getKlient();
|
|
if( end && klient )
|
|
if( end && klient )
|
|
{
|
|
{
|
|
@@ -205,13 +209,10 @@ MainServer *MainServer::release()
|
|
|
|
|
|
// Inhalt der MSKlient Klasse aus MainServer.h
|
|
// Inhalt der MSKlient Klasse aus MainServer.h
|
|
// Konstruktor
|
|
// Konstruktor
|
|
-MSAKlient::MSAKlient( SKlient *klient, MainServer *ms )
|
|
|
|
|
|
+MSAKlient::MSAKlient( SSLSKlient *klient, MainServer *ms )
|
|
: Thread()
|
|
: Thread()
|
|
{
|
|
{
|
|
this->klient = klient;
|
|
this->klient = klient;
|
|
- unsigned char key[ 20 ] = { 103, 112, 161, 152, 241, 81, 192, 29, 85, 160, 151, 68, 120, 164, 145, 208, 65, 241, 234, 219 };
|
|
|
|
- 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;
|
|
@@ -234,7 +235,7 @@ void MSAKlient::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
|
|
{
|
|
{
|
|
@@ -244,23 +245,23 @@ void MSAKlient::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 = ms->zDB()->istAdministrator( n, p );
|
|
int adminId = ms->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;
|
|
@@ -275,11 +276,11 @@ void MSAKlient::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 )
|
|
@@ -291,7 +292,7 @@ void MSAKlient::thread()
|
|
if( !ms->serverStarten() )
|
|
if( !ms->serverStarten() )
|
|
errorZuKlient( "Beim starten des Servers ist ein Fehler aufgetreten." );
|
|
errorZuKlient( "Beim starten des Servers ist ein Fehler aufgetreten." );
|
|
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." );
|
|
@@ -305,7 +306,7 @@ void MSAKlient::thread()
|
|
if( ms->zDB()->adminHatRecht( adminId, Admin_Recht::MSBeenden ) )
|
|
if( ms->zDB()->adminHatRecht( adminId, Admin_Recht::MSBeenden ) )
|
|
{
|
|
{
|
|
ms->serverBeenden();
|
|
ms->serverBeenden();
|
|
- klient->sendeEncrypted( "\1", 1 );
|
|
|
|
|
|
+ klient->sende( "\1", 1 );
|
|
}
|
|
}
|
|
else
|
|
else
|
|
errorZuKlient( "Du bist nicht berechtigt den Server zu beenden." );
|
|
errorZuKlient( "Du bist nicht berechtigt den Server zu beenden." );
|
|
@@ -336,7 +337,7 @@ void MSAKlient::thread()
|
|
}
|
|
}
|
|
if( ok )
|
|
if( ok )
|
|
{
|
|
{
|
|
- klient->sendeEncrypted( "\1", 1 );
|
|
|
|
|
|
+ klient->sende( "\1", 1 );
|
|
std::cout << "MS: Der Server wird von Benutzer " << adminId << " heruntergefahren.\n";
|
|
std::cout << "MS: Der Server wird von Benutzer " << adminId << " heruntergefahren.\n";
|
|
ms->close();
|
|
ms->close();
|
|
br = 1;
|
|
br = 1;
|
|
@@ -363,7 +364,7 @@ void MSAKlient::thread()
|
|
ok = 1;
|
|
ok = 1;
|
|
if( ok )
|
|
if( ok )
|
|
{
|
|
{
|
|
- klient->sendeEncrypted( "\1", 1 );
|
|
|
|
|
|
+ klient->sende( "\1", 1 );
|
|
std::cout << "MS: Der Server wurde von Benutzer " << adminId << " terminiert.\n";
|
|
std::cout << "MS: Der Server wurde von Benutzer " << adminId << " terminiert.\n";
|
|
ms->close();
|
|
ms->close();
|
|
br = 1;
|
|
br = 1;
|
|
@@ -373,9 +374,9 @@ void MSAKlient::thread()
|
|
case 8: // Status Frage
|
|
case 8: // Status Frage
|
|
if( 1 )
|
|
if( 1 )
|
|
{
|
|
{
|
|
- klient->sendeEncrypted( "\1", 1 );
|
|
|
|
|
|
+ klient->sende( "\1", 1 );
|
|
char status = (int)ms->isRunning();
|
|
char status = (int)ms->isRunning();
|
|
- klient->sendeEncrypted( &status, 1 );
|
|
|
|
|
|
+ klient->sende( &status, 1 );
|
|
}
|
|
}
|
|
break;
|
|
break;
|
|
default:
|
|
default:
|
|
@@ -395,10 +396,10 @@ void MSAKlient::thread()
|
|
|
|
|
|
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->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 );
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|