|
@@ -19,7 +19,10 @@ NewsServer::NewsServer( InitDatei *zIni )
|
|
ini = zIni->getThis();
|
|
ini = zIni->getThis();
|
|
id = *zIni->zWert( "ServerId" );
|
|
id = *zIni->zWert( "ServerId" );
|
|
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 << "IS: Starten des Admin Servers...\n";
|
|
std::cout << "IS: 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 ) )
|
|
{
|
|
{
|
|
@@ -58,7 +61,7 @@ void NewsServer::runn()
|
|
{
|
|
{
|
|
while( !end )
|
|
while( !end )
|
|
{
|
|
{
|
|
- SKlient *klient;
|
|
|
|
|
|
+ SSLSKlient *klient;
|
|
klient = aServer->getKlient();
|
|
klient = aServer->getKlient();
|
|
if( end && klient )
|
|
if( end && klient )
|
|
{
|
|
{
|
|
@@ -298,13 +301,10 @@ NewsServer *NewsServer::release()
|
|
|
|
|
|
// Inhalt der NSAKlient Klasse aus NewsServer.h
|
|
// Inhalt der NSAKlient Klasse aus NewsServer.h
|
|
// Konstruktor
|
|
// Konstruktor
|
|
-NSAKlient::NSAKlient( SKlient *klient, NewsServer *ns )
|
|
|
|
|
|
+NSAKlient::NSAKlient( SSLSKlient *klient, NewsServer *ns )
|
|
: Thread()
|
|
: Thread()
|
|
{
|
|
{
|
|
this->klient = klient;
|
|
this->klient = klient;
|
|
- unsigned char key[ 20 ] = { 118, 24, 81, 121, 254, 35, 132, 34, 118, 165, 132, 212, 137, 41, 253, 153, 239, 26, 1, 72 };
|
|
|
|
- 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;
|
|
@@ -327,7 +327,7 @@ void NSAKlient::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
|
|
{
|
|
{
|
|
@@ -337,23 +337,23 @@ void NSAKlient::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 = ns->zDB()->istAdministrator( n, p );
|
|
int adminId = ns->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;
|
|
@@ -368,11 +368,11 @@ void NSAKlient::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 )
|
|
@@ -389,7 +389,7 @@ void NSAKlient::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." );
|
|
@@ -403,7 +403,7 @@ void NSAKlient::thread()
|
|
if( ns->zDB()->adminHatRecht( adminId, Admin_Recht::NSBeenden ) )
|
|
if( ns->zDB()->adminHatRecht( adminId, Admin_Recht::NSBeenden ) )
|
|
{
|
|
{
|
|
if( ns->serverBeenden() )
|
|
if( ns->serverBeenden() )
|
|
- klient->sendeEncrypted( "\1", 1 );
|
|
|
|
|
|
+ klient->sende( "\1", 1 );
|
|
else
|
|
else
|
|
{
|
|
{
|
|
Text *err = new Text();
|
|
Text *err = new Text();
|
|
@@ -448,7 +448,7 @@ void NSAKlient::thread()
|
|
}
|
|
}
|
|
if( ok )
|
|
if( ok )
|
|
{
|
|
{
|
|
- klient->sendeEncrypted( "\1", 1 );
|
|
|
|
|
|
+ klient->sende( "\1", 1 );
|
|
std::cout << "NS: Der Server wird von Benutzer " << adminId << " heruntergefahren.\n";
|
|
std::cout << "NS: Der Server wird von Benutzer " << adminId << " heruntergefahren.\n";
|
|
ns->close();
|
|
ns->close();
|
|
br = 1;
|
|
br = 1;
|
|
@@ -475,7 +475,7 @@ void NSAKlient::thread()
|
|
ok = 1;
|
|
ok = 1;
|
|
if( ok )
|
|
if( ok )
|
|
{
|
|
{
|
|
- klient->sendeEncrypted( "\1", 1 );
|
|
|
|
|
|
+ klient->sende( "\1", 1 );
|
|
std::cout << "NS: Der Server wurde von Benutzer " << adminId << " terminiert.\n";
|
|
std::cout << "NS: Der Server wurde von Benutzer " << adminId << " terminiert.\n";
|
|
ns->close();
|
|
ns->close();
|
|
br = 1;
|
|
br = 1;
|
|
@@ -492,8 +492,8 @@ void NSAKlient::thread()
|
|
if( ns->istAn() )
|
|
if( ns->istAn() )
|
|
status = 2;
|
|
status = 2;
|
|
}
|
|
}
|
|
- 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
|
|
@@ -501,9 +501,9 @@ void NSAKlient::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( ns->zDB()->adminHatRecht( adminId, Admin_Recht::NSPausieren ) )
|
|
if( ns->zDB()->adminHatRecht( adminId, Admin_Recht::NSPausieren ) )
|
|
{
|
|
{
|
|
bool ok = 0;
|
|
bool ok = 0;
|
|
@@ -512,7 +512,7 @@ void NSAKlient::thread()
|
|
else
|
|
else
|
|
ok = ns->serverFortsetzen();
|
|
ok = ns->serverFortsetzen();
|
|
if( ok )
|
|
if( ok )
|
|
- klient->sendeEncrypted( "\1", 1 );
|
|
|
|
|
|
+ klient->sende( "\1", 1 );
|
|
else
|
|
else
|
|
{
|
|
{
|
|
Text *err = new Text();
|
|
Text *err = new Text();
|
|
@@ -535,13 +535,13 @@ void NSAKlient::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( ns->zDB()->adminHatRecht( adminId, Admin_Recht::NSMCChange ) )
|
|
if( ns->zDB()->adminHatRecht( adminId, Admin_Recht::NSMCChange ) )
|
|
{
|
|
{
|
|
if( ns->setMaxKlients( maxC ) )
|
|
if( ns->setMaxKlients( maxC ) )
|
|
- klient->sendeEncrypted( "\1", 1 );
|
|
|
|
|
|
+ klient->sende( "\1", 1 );
|
|
else
|
|
else
|
|
{
|
|
{
|
|
Text *err = new Text();
|
|
Text *err = new Text();
|
|
@@ -557,13 +557,13 @@ void NSAKlient::thread()
|
|
case 0xC: // klient absturtz
|
|
case 0xC: // 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 && ns->absturzKlient( klientId ) )
|
|
if( klientId && ns->absturzKlient( klientId ) )
|
|
- klient->sendeEncrypted( "\1", 1 );
|
|
|
|
|
|
+ klient->sende( "\1", 1 );
|
|
else
|
|
else
|
|
- klient->sendeEncrypted( "\0", 1 );
|
|
|
|
|
|
+ klient->sende( "\0", 1 );
|
|
}
|
|
}
|
|
break;
|
|
break;
|
|
default:
|
|
default:
|
|
@@ -583,10 +583,10 @@ void NSAKlient::thread()
|
|
|
|
|
|
void NSAKlient::errorZuKlient( const char *nachricht ) const // sendet eine Fehlernachricht zum Klient
|
|
void NSAKlient::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 );
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|