Pārlūkot izejas kodu

Admin Verbindung SSL verschlüsselt

Kolja Strohm 6 gadi atpakaļ
vecāks
revīzija
4bc3cee840

+ 34 - 34
HistorieServer/HistorieServer.cpp

@@ -19,7 +19,10 @@ HistorieServer::HistorieServer( InitDatei *zIni )
 	ini = zIni->getThis();
 	id = *zIni->zWert( "ServerId" );
 	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 << "HS: Starten des Admin Servers...\n";
 	if( !aServer->verbinde( (unsigned short)TextZuInt( ini->zWert( "AdminServerPort" )->getText(), 10 ), 10 ) )
 	{
@@ -58,7 +61,7 @@ void HistorieServer::runn()
 {
 	while( !end )
 	{
-		SKlient *klient;
+		SSLSKlient *klient;
 		klient = aServer->getKlient();
 		if( end && klient )
 		{
@@ -300,13 +303,10 @@ HistorieServer *HistorieServer::release()
 
 // Inhalt der HSAKlient Klasse aus HistorieServer.h
 // Konstruktor 
-HSAKlient::HSAKlient( SKlient *klient, HistorieServer *hs )
+HSAKlient::HSAKlient( SSLSKlient *klient, HistorieServer *hs )
 	: Thread()
 {
 	this->klient = klient;
-	unsigned char key[ 20 ] = { 230, 14, 195, 114, 204, 79, 136, 125, 73, 119, 191, 155, 162, 80, 9, 63, 210, 55, 39, 203 };
-	klient->setSendeKey( (char*)key, 20 );
-	klient->setEmpfangKey( (char*)key, 20 );
 	name = new Text( "" );
 	passwort = new Text( "" );
 	adminId = 0;
@@ -330,7 +330,7 @@ void HSAKlient::thread()
 	while( 1 )
 	{
 		char c = 0;
-		if( !klient->getNachrichtEncrypted( &c, 1 ) )
+		if( !klient->getNachricht( &c, 1 ) )
 			break;
 		else
 		{
@@ -340,23 +340,23 @@ void HSAKlient::thread()
 			case 1: // Login
 				if( 1 )
 				{
-					klient->sendeEncrypted( "\1", 1 );
+					klient->sende( "\1", 1 );
 					unsigned char nLen = 0;
-					klient->getNachrichtEncrypted( (char*)&nLen, 1 );
+					klient->getNachricht( (char*)&nLen, 1 );
 					char *n = new char[ nLen + 1 ];
 					n[ (int)nLen ] = 0;
 					if( nLen )
-						klient->getNachrichtEncrypted( n, nLen );
+						klient->getNachricht( n, nLen );
 					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 = hs->zDB()->istAdministrator( n, p );
 					if( adminId )
 					{
-						klient->sendeEncrypted( "\1", 1 );
+						klient->sende( "\1", 1 );
 						name->setText( n );
 						passwort->setText( p );
 						this->adminId = adminId;
@@ -371,11 +371,11 @@ void HSAKlient::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 )
@@ -392,7 +392,7 @@ void HSAKlient::thread()
 							err->release();
 						}
 						else
-							klient->sendeEncrypted( "\1", 1 );
+							klient->sende( "\1", 1 );
 					}
 					else
 						errorZuKlient( "Du bist nicht berechtigt den Server zu starten." );
@@ -406,7 +406,7 @@ void HSAKlient::thread()
 					if( hs->zDB()->adminHatRecht( adminId, Admin_Recht::HSBeenden ) )
 					{
 						if( hs->serverBeenden() )
-							klient->sendeEncrypted( "\1", 1 );
+							klient->sende( "\1", 1 );
 						else
 						{
 							Text *err = new Text();
@@ -451,7 +451,7 @@ void HSAKlient::thread()
 					}
 					if( ok )
 					{
-						klient->sendeEncrypted( "\1", 1 );
+						klient->sende( "\1", 1 );
 						std::cout << "HS: Der Server wird von Benutzer " << adminId << " heruntergefahren.\n";
 						hs->close();
 						br = 1;
@@ -478,7 +478,7 @@ void HSAKlient::thread()
 						ok = 1;
 					if( ok )
 					{
-						klient->sendeEncrypted( "\1", 1 );
+						klient->sende( "\1", 1 );
 						std::cout << "HS: Der Server wurde von Benutzer " << adminId << " terminiert.\n";
 						hs->close();
 						br = 1;
@@ -495,8 +495,8 @@ void HSAKlient::thread()
 						if( hs->istAn() )
 							status = 2;
 					}
-					klient->sendeEncrypted( "\1", 1 );
-					klient->sendeEncrypted( &status, 1 );
+					klient->sende( "\1", 1 );
+					klient->sende( &status, 1 );
 				}
 				break;
 			case 9: // Server pausieren
@@ -504,9 +504,9 @@ void HSAKlient::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( hs->zDB()->adminHatRecht( adminId, Admin_Recht::HSPausieren ) )
 					{
 						bool ok = 0;
@@ -515,7 +515,7 @@ void HSAKlient::thread()
 						else
 							ok = hs->serverFortsetzen();
 						if( ok )
-							klient->sendeEncrypted( "\1", 1 );
+							klient->sende( "\1", 1 );
 						else
 						{
 							Text *err = new Text();
@@ -538,13 +538,13 @@ void HSAKlient::thread()
 					errorZuKlient( "Du musst dich einloggen." );
 				else
 				{
-					klient->sendeEncrypted( "\1", 1 );
+					klient->sende( "\1", 1 );
 					int maxS = 0;
-					klient->getNachrichtEncrypted( (char*)&maxS, 4 );
+					klient->getNachricht( (char*)&maxS, 4 );
 					if( hs->zDB()->adminHatRecht( adminId, Admin_Recht::HSMSChange ) )
 					{
 						if( hs->setMaxSpiele( maxS ) )
-							klient->sendeEncrypted( "\1", 1 );
+							klient->sende( "\1", 1 );
 						else
 						{
 							Text *err = new Text();
@@ -560,13 +560,13 @@ void HSAKlient::thread()
 			case 0xC: // 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 && hs->absturzKlient( klientId ) )
-						klient->sendeEncrypted( "\1", 1 );
+						klient->sende( "\1", 1 );
 					else
-						klient->sendeEncrypted( "\0", 1 );
+						klient->sende( "\0", 1 );
 				}
 				break;
 			default:
@@ -586,10 +586,10 @@ void HSAKlient::thread()
 
 void HSAKlient::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 );
 }
 
 

+ 3 - 3
HistorieServer/HistorieServer.h

@@ -17,7 +17,7 @@ class HistorieServer : public Thread
 {
 private:
 	Server *server;
-	Server *aServer;
+	SSLServer *aServer;
 	InitDatei *ini;
 	HSDatenbank *db;
 	CRITICAL_SECTION cs;
@@ -65,7 +65,7 @@ public:
 class HSAKlient : public Thread
 {
 private:
-	SKlient *klient;
+	SSLSKlient *klient;
 	Text *name;
 	Text *passwort;
 	int adminId;
@@ -74,7 +74,7 @@ private:
 
 public:
 	// Konstruktor 
-	HSAKlient( SKlient *klient, HistorieServer *hs );
+	HSAKlient( SSLSKlient *klient, HistorieServer *hs );
 	// Destruktor 
 	virtual ~HSAKlient();
 	// nicht constant

+ 1 - 1
HistorieServer/main.cpp

@@ -32,7 +32,7 @@ int main()
 		dat->release();
 		exit( 1 );
 	}
-    const char *wichtig[] = { "ServerId", "DBBenutzer", "DBPasswort", "DBName", "DBIP", "DBPort", "Aktiv", "SpielHistoriePfad" };
+    const char *wichtig[] = { "ServerId", "DBBenutzer", "DBPasswort", "DBName", "DBIP", "DBPort", "Aktiv", "SpielHistoriePfad", "SSLPasswort", "SSLCert", "SSLKey" };
     for( const char *w : wichtig )
     {
         if( !dat->wertExistiert( w ) )

+ 0 - 0
historie/67/statistik/gs0.ini