|
@@ -18,7 +18,10 @@ AppServer::AppServer( InitDatei *zDat )
|
|
gesendet = 0;
|
|
gesendet = 0;
|
|
dat = zDat->getThis();
|
|
dat = zDat->getThis();
|
|
server = new Server();
|
|
server = new Server();
|
|
- aServer = new Server();
|
|
|
|
|
|
+ aServer = new SSLServer();
|
|
|
|
+ aServer->setPrivateKeyPassword( zDat->zWert( "SSLPasswort" )->getText() );
|
|
|
|
+ aServer->setPrivateKeyFile( zDat->zWert( "SSLKey" )->getText() );
|
|
|
|
+ aServer->setCertificateFile( zDat->zWert( "SSLCert" )->getText() );
|
|
std::cout << "AppS: Starten des Admin Servers...\n";
|
|
std::cout << "AppS: Starten des Admin Servers...\n";
|
|
if( !aServer->verbinde( (unsigned short)TextZuInt( zDat->zWert( "AppSAPort" )->getText(), 10 ), 10 ) )
|
|
if( !aServer->verbinde( (unsigned short)TextZuInt( zDat->zWert( "AppSAPort" )->getText(), 10 ), 10 ) )
|
|
{
|
|
{
|
|
@@ -49,9 +52,9 @@ AppServer::~AppServer()
|
|
// nicht constant
|
|
// nicht constant
|
|
void AppServer::runn()
|
|
void AppServer::runn()
|
|
{
|
|
{
|
|
- while( !end )
|
|
|
|
|
|
+ while( !end && aServer->isConnected() )
|
|
{
|
|
{
|
|
- SKlient *klient;
|
|
|
|
|
|
+ SSLSKlient *klient;
|
|
klient = aServer->getKlient();
|
|
klient = aServer->getKlient();
|
|
if( end && klient )
|
|
if( end && klient )
|
|
{
|
|
{
|
|
@@ -61,7 +64,7 @@ void AppServer::runn()
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
if( !klient )
|
|
if( !klient )
|
|
- return;
|
|
|
|
|
|
+ continue;
|
|
AppSAKlient *clHandle = new AppSAKlient( klient, getThis() );
|
|
AppSAKlient *clHandle = new AppSAKlient( klient, getThis() );
|
|
clHandle->start();
|
|
clHandle->start();
|
|
}
|
|
}
|
|
@@ -69,12 +72,12 @@ void AppServer::runn()
|
|
|
|
|
|
void AppServer::thread()
|
|
void AppServer::thread()
|
|
{
|
|
{
|
|
- while( 1 )
|
|
|
|
|
|
+ while( server->isConnected() )
|
|
{
|
|
{
|
|
SKlient *klient;
|
|
SKlient *klient;
|
|
klient = server->getKlient();
|
|
klient = server->getKlient();
|
|
if( !klient )
|
|
if( !klient )
|
|
- break;
|
|
|
|
|
|
+ continue;
|
|
Framework::getThreadRegister()->cleanUpClosedThreads();
|
|
Framework::getThreadRegister()->cleanUpClosedThreads();
|
|
AppSKlient *clHandle = new AppSKlient( klient, getThis() );
|
|
AppSKlient *clHandle = new AppSKlient( klient, getThis() );
|
|
clHandle->start();
|
|
clHandle->start();
|
|
@@ -185,13 +188,10 @@ AppServer *AppServer::release()
|
|
|
|
|
|
// Inhalt der AppSKlient Klasse aus AppServer.h
|
|
// Inhalt der AppSKlient Klasse aus AppServer.h
|
|
// Konstruktor
|
|
// Konstruktor
|
|
-AppSAKlient::AppSAKlient( SKlient *klient, AppServer *appS )
|
|
|
|
|
|
+AppSAKlient::AppSAKlient( SSLSKlient *klient, AppServer *appS )
|
|
: Thread()
|
|
: Thread()
|
|
{
|
|
{
|
|
this->klient = klient;
|
|
this->klient = klient;
|
|
- unsigned char key[ 20 ] = { 14, 143, 241, 74, 52, 68, 158, 32, 83, 67, 205, 80, 206, 243, 151, 156, 46, 72, 120, 161 };
|
|
|
|
- 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;
|
|
@@ -214,7 +214,7 @@ void AppSAKlient::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
|
|
{
|
|
{
|
|
@@ -224,23 +224,23 @@ void AppSAKlient::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 = appS->zDB()->istAdministrator( n, p );
|
|
int adminId = appS->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;
|
|
@@ -255,11 +255,11 @@ void AppSAKlient::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 )
|
|
@@ -271,7 +271,7 @@ void AppSAKlient::thread()
|
|
if( !appS->serverStarten() )
|
|
if( !appS->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." );
|
|
@@ -285,7 +285,7 @@ void AppSAKlient::thread()
|
|
if( appS->zDB()->adminHatRecht( adminId, Admin_Recht::AppSBeenden ) )
|
|
if( appS->zDB()->adminHatRecht( adminId, Admin_Recht::AppSBeenden ) )
|
|
{
|
|
{
|
|
appS->serverBeenden();
|
|
appS->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." );
|
|
@@ -316,7 +316,7 @@ void AppSAKlient::thread()
|
|
}
|
|
}
|
|
if( ok )
|
|
if( ok )
|
|
{
|
|
{
|
|
- klient->sendeEncrypted( "\1", 1 );
|
|
|
|
|
|
+ klient->sende( "\1", 1 );
|
|
std::cout << "AppS: Der Server wird von Benutzer " << adminId << " heruntergefahren.\n";
|
|
std::cout << "AppS: Der Server wird von Benutzer " << adminId << " heruntergefahren.\n";
|
|
appS->close();
|
|
appS->close();
|
|
br = 1;
|
|
br = 1;
|
|
@@ -343,7 +343,7 @@ void AppSAKlient::thread()
|
|
ok = 1;
|
|
ok = 1;
|
|
if( ok )
|
|
if( ok )
|
|
{
|
|
{
|
|
- klient->sendeEncrypted( "\1", 1 );
|
|
|
|
|
|
+ klient->sende( "\1", 1 );
|
|
std::cout << "AppS: Der Server wurde von Benutzer " << adminId << " terminiert.\n";
|
|
std::cout << "AppS: Der Server wurde von Benutzer " << adminId << " terminiert.\n";
|
|
appS->close();
|
|
appS->close();
|
|
br = 1;
|
|
br = 1;
|
|
@@ -353,9 +353,9 @@ void AppSAKlient::thread()
|
|
case 8: // Status Frage
|
|
case 8: // Status Frage
|
|
if( 1 )
|
|
if( 1 )
|
|
{
|
|
{
|
|
- klient->sendeEncrypted( "\1", 1 );
|
|
|
|
|
|
+ klient->sende( "\1", 1 );
|
|
char status = (int)appS->isRunning();
|
|
char status = (int)appS->isRunning();
|
|
- klient->sendeEncrypted( &status, 1 );
|
|
|
|
|
|
+ klient->sende( &status, 1 );
|
|
}
|
|
}
|
|
break;
|
|
break;
|
|
default:
|
|
default:
|
|
@@ -376,10 +376,10 @@ void AppSAKlient::thread()
|
|
|
|
|
|
void AppSAKlient::errorZuKlient( const char *nachricht ) const // sendet eine Fehlernachricht zum Klient
|
|
void AppSAKlient::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 );
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|