summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--Tools/ProtoProxy/Connection.cpp1
-rw-r--r--Tools/ProtoProxy/Globals.h4
-rw-r--r--Tools/ProtoProxy/ProtoProxy.cpp10
-rw-r--r--Tools/ProtoProxy/Server.cpp22
-rw-r--r--src/LoggerListeners.h1
5 files changed, 23 insertions, 15 deletions
diff --git a/Tools/ProtoProxy/Connection.cpp b/Tools/ProtoProxy/Connection.cpp
index 4e890c26a..507d7cb90 100644
--- a/Tools/ProtoProxy/Connection.cpp
+++ b/Tools/ProtoProxy/Connection.cpp
@@ -8,6 +8,7 @@
#include "Server.h"
#include <iostream>
#include "PolarSSL++/CryptoKey.h"
+#include "../../src/Logger.h"
#ifdef _WIN32
#include <direct.h> // For _mkdir()
diff --git a/Tools/ProtoProxy/Globals.h b/Tools/ProtoProxy/Globals.h
index 23591b675..efc0a9988 100644
--- a/Tools/ProtoProxy/Globals.h
+++ b/Tools/ProtoProxy/Globals.h
@@ -247,7 +247,3 @@ public:
-
-#define LOGERROR printf
-#define LOGINFO printf
-#define LOGWARNING printf
diff --git a/Tools/ProtoProxy/ProtoProxy.cpp b/Tools/ProtoProxy/ProtoProxy.cpp
index 2724ef704..3f427f83f 100644
--- a/Tools/ProtoProxy/ProtoProxy.cpp
+++ b/Tools/ProtoProxy/ProtoProxy.cpp
@@ -5,6 +5,8 @@
#include "Globals.h"
#include "Server.h"
+#include "../../src/Logger.h"
+#include "../../src/LoggerListeners.h"
@@ -12,8 +14,16 @@
int main(int argc, char ** argv)
{
+ // Initialize logging subsystem:
+ cLogger::InitiateMultithreading();
+ auto consoleLogListener = MakeConsoleListener();
+ auto fileLogListener = new cFileListener();
+ cLogger::GetInstance().AttachListener(consoleLogListener);
+ cLogger::GetInstance().AttachListener(fileLogListener);
+
int ListenPort = (argc > 1) ? atoi(argv[1]) : 25564;
int ConnectPort = (argc > 2) ? atoi(argv[2]) : 25565;
+ printf("Initializing ProtoProxy. Listen port %d, connect port %d.\n", ListenPort, ConnectPort);
cServer Server;
int res = Server.Init(ListenPort, ConnectPort);
if (res != 0)
diff --git a/Tools/ProtoProxy/Server.cpp b/Tools/ProtoProxy/Server.cpp
index 5bba98057..98baec8da 100644
--- a/Tools/ProtoProxy/Server.cpp
+++ b/Tools/ProtoProxy/Server.cpp
@@ -6,6 +6,7 @@
#include "Globals.h"
#include "Server.h"
#include "Connection.h"
+#include "../../src/Logger.h"
@@ -28,15 +29,11 @@ int cServer::Init(short a_ListenPort, short a_ConnectPort)
int res = WSAStartup(0x0202, &wsa);
if (res != 0)
{
- printf("Cannot initialize WinSock: %d\n", res);
+ LOGERROR("Cannot initialize WinSock: %d", res);
return res;
}
#endif // _WIN32
- LOGINFO("Generating protocol encryption keypair...");
- m_PrivateKey.Generate();
- m_PublicKeyDER = m_PrivateKey.GetPubKeyDER();
-
m_ListenSocket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
if (m_ListenSocket < 0)
{
@@ -45,22 +42,22 @@ int cServer::Init(short a_ListenPort, short a_ConnectPort)
#else
int err = errno;
#endif
- printf("Failed to create listener socket: %d\n", err);
+ LOGERROR("Failed to create listener socket: %d", err);
return err;
}
sockaddr_in local;
memset(&local, 0, sizeof(local));
local.sin_family = AF_INET;
- local.sin_addr.s_addr = 130; // INADDR_ANY; // All interfaces
+ local.sin_addr.s_addr = INADDR_ANY; // All interfaces
local.sin_port = htons(a_ListenPort);
- if (!bind(m_ListenSocket, (sockaddr *)&local, sizeof(local)))
+ if (bind(m_ListenSocket, (sockaddr *)&local, sizeof(local)) != 0)
{
#ifdef _WIN32
int err = WSAGetLastError();
#else
int err = errno;
#endif
- printf("Failed to bind listener socket: %d\n", err);
+ LOGERROR("Failed to bind listener socket: %d", err);
return err;
}
if (listen(m_ListenSocket, 1) != 0)
@@ -73,9 +70,12 @@ int cServer::Init(short a_ListenPort, short a_ConnectPort)
printf("Failed to listen on socket: %d\n", err);
return err;
}
+ LOGINFO("Listening on port %d, connecting to localhost:%d", a_ListenPort, a_ConnectPort);
- printf("Listening on port %d, connecting to localhost:%d\n", a_ListenPort, a_ConnectPort);
-
+ LOGINFO("Generating protocol encryption keypair...");
+ m_PrivateKey.Generate();
+ m_PublicKeyDER = m_PrivateKey.GetPubKeyDER();
+
return 0;
}
diff --git a/src/LoggerListeners.h b/src/LoggerListeners.h
index d300184b1..c419aa75a 100644
--- a/src/LoggerListeners.h
+++ b/src/LoggerListeners.h
@@ -1,5 +1,6 @@
#include "Logger.h"
+#include "OSSupport/File.h"