diff options
Diffstat (limited to 'csgo-loader/csgo-server')
| -rw-r--r-- | csgo-loader/csgo-server/Networking/TCPServer.cpp | 18 | ||||
| -rw-r--r-- | csgo-loader/csgo-server/Networking/TCPServer.hpp | 2 | ||||
| -rw-r--r-- | csgo-loader/csgo-server/Security/Encryption.cpp | 8 | ||||
| -rw-r--r-- | csgo-loader/csgo-server/Server.cpp | 14 |
4 files changed, 24 insertions, 18 deletions
diff --git a/csgo-loader/csgo-server/Networking/TCPServer.cpp b/csgo-loader/csgo-server/Networking/TCPServer.cpp index 739cbdd..c381c85 100644 --- a/csgo-loader/csgo-server/Networking/TCPServer.cpp +++ b/csgo-loader/csgo-server/Networking/TCPServer.cpp @@ -4,7 +4,7 @@ namespace Networking {
void TCPConnection::Close()
{
- printf("[ <= ] %s disconnected!\n", m_IpAddress);
+ printf("[ <= ] disconnected\n");
if(m_Socket)
closesocket(m_Socket);
@@ -20,10 +20,10 @@ namespace Networking if(m_IpAddress)
- printf("[ => ] Sending %zd bytes to %s.\n", Bytes.size(), m_IpAddress);
+ printf("[ => ] %zd bytes\n", Bytes.size());
if(Result == -1)
- printf("[ => ] Failed to send %zd bytes to %s. (Socket %04Ix)\n", Bytes.size(), m_IpAddress, m_Socket);
+ printf("[ => ] %zd bytes failed (%d)\n", Bytes.size(), WSAGetLastError());
}
ByteArray TCPConnection::ReceiveRawBytes()
@@ -43,7 +43,7 @@ namespace Networking // Emplace all received bytes.
for(int n = 0; n < Received; ++n)
{
- ReceivedBytes.push_back(RecvBuffer[n]);
+ ReceivedBytes.emplace_back(RecvBuffer[n]);
}
// No more bytes left to receive.
@@ -51,7 +51,7 @@ namespace Networking break;
}
- printf("[ <= ] Received %zd bytes from %s.\n", ReceivedBytes.size(), m_IpAddress);
+ printf("[ <= ] %zd bytes\n", ReceivedBytes.size());
return ReceivedBytes;
}
@@ -126,6 +126,14 @@ namespace Networking ByteArray EncryptionKey = Connection.GetEncryptionKey();
Connection.SendRawBytes(EncryptionKey);
+ // Print out handshake header
+ printf("[ => ] Handshake: ");
+
+ for(auto &It : EncryptionKey)
+ printf("%02x ", It);
+
+ printf("\n");
+
// Detach a thread to handle the connection.
std::thread thread([&]
{
diff --git a/csgo-loader/csgo-server/Networking/TCPServer.hpp b/csgo-loader/csgo-server/Networking/TCPServer.hpp index 092254d..31beec8 100644 --- a/csgo-loader/csgo-server/Networking/TCPServer.hpp +++ b/csgo-loader/csgo-server/Networking/TCPServer.hpp @@ -29,7 +29,7 @@ namespace Networking TCPConnection(SOCKET Connection, const char *IpAddress, Wrapper::Encryption &RSA) :
m_Encryption(RSA), m_Socket(Connection), m_IpAddress(IpAddress)
{
- printf("[ => ] %s connected!\n", IpAddress);
+ printf("[ => ] connected\n");
}
// Release the connection once it goes out of scope.
diff --git a/csgo-loader/csgo-server/Security/Encryption.cpp b/csgo-loader/csgo-server/Security/Encryption.cpp index dc6ef84..b79a1c3 100644 --- a/csgo-loader/csgo-server/Security/Encryption.cpp +++ b/csgo-loader/csgo-server/Security/Encryption.cpp @@ -614,11 +614,7 @@ namespace Wrapper // Encrypt outgoing data.
ByteArray Encrypted;
- #ifdef DEBUG
- Encrypted = Data;
- #else
Aes256::encrypt(m_EncryptionKey, Data, Encrypted);
- #endif
return Encrypted;
}
@@ -628,11 +624,7 @@ namespace Wrapper // Decrypt incoming data.
ByteArray Decrypted;
- #ifdef DEBUG
- Decrypted = Data;
- #else
Aes256::decrypt(m_EncryptionKey, Data, Decrypted);
- #endif
return Decrypted;
}
diff --git a/csgo-loader/csgo-server/Server.cpp b/csgo-loader/csgo-server/Server.cpp index 3b6bdea..c475542 100644 --- a/csgo-loader/csgo-server/Server.cpp +++ b/csgo-loader/csgo-server/Server.cpp @@ -1,8 +1,14 @@ #include <Server.hpp>
-void ConnectionHandler(Networking::TCPConnection &)
+void ConnectionHandler(Networking::TCPConnection &Connection)
{
+ ByteArray Bytes = Connection.ReceiveBytes();
+ for(auto &It : Bytes)
+ printf("%02x ", It);
+ printf("\n");
+
+ Connection.SendBytes(Bytes);
}
int __stdcall WinMain(HINSTANCE, HINSTANCE, char*, int)
@@ -14,13 +20,13 @@ int __stdcall WinMain(HINSTANCE, HINSTANCE, char*, int) // Create an instance of the TCP server.
Networking::TCPServer Server;
+ // Attach our connection handler.
+ Server += ConnectionHandler;
+
bool Result = Server.Start(SERVER_PORT);
if(Result)
{
- // Attach our connection handler.
- Server += ConnectionHandler;
-
// Accept any incoming connections.
for(;;)
Server.AcceptConnection();
|
