feat: add logger on TINYMITM_LOGS builds
This commit is contained in:
@@ -21,6 +21,12 @@
|
|||||||
|
|
||||||
#include "raai-helper.h"
|
#include "raai-helper.h"
|
||||||
|
|
||||||
|
#ifdef TINYMITM_LOGS
|
||||||
|
#define TINYMITM_WRITELOG(type, ...) _log->type(...)
|
||||||
|
#else
|
||||||
|
#define TINYMITM_WRITELOG()
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
RAAI helpers
|
RAAI helpers
|
||||||
*/
|
*/
|
||||||
@@ -113,6 +119,7 @@ void setNonBlocking(SOCKET s)
|
|||||||
TinyMITMProxy::~TinyMITMProxy()
|
TinyMITMProxy::~TinyMITMProxy()
|
||||||
{
|
{
|
||||||
shutdown();
|
shutdown();
|
||||||
|
delete _log;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TinyMITMProxy::init()
|
bool TinyMITMProxy::init()
|
||||||
|
|||||||
@@ -2,6 +2,10 @@
|
|||||||
|
|
||||||
#include <seallib/events.h>
|
#include <seallib/events.h>
|
||||||
|
|
||||||
|
#if TINYMITM_LOGS
|
||||||
|
#include <seallib/log.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <thread>
|
#include <thread>
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
#include <queue>
|
#include <queue>
|
||||||
@@ -51,7 +55,12 @@ struct TinyMITMConfig
|
|||||||
class TinyMITMProxy
|
class TinyMITMProxy
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
TinyMITMProxy(TinyMITMConfig config) : _config(std::move(config)) {}
|
TinyMITMProxy(TinyMITMConfig config) : _config(std::move(config))
|
||||||
|
{
|
||||||
|
#ifdef TINYMITM_LOGS
|
||||||
|
_log = new seallib::Logger("TinyMITMProxy");
|
||||||
|
#endif
|
||||||
|
}
|
||||||
~TinyMITMProxy();
|
~TinyMITMProxy();
|
||||||
|
|
||||||
bool init();
|
bool init();
|
||||||
@@ -85,6 +94,10 @@ class TinyMITMProxy
|
|||||||
*/
|
*/
|
||||||
seallib::Event<const std::string&, std::string&, std::string&, bool> onServerResponse;
|
seallib::Event<const std::string&, std::string&, std::string&, bool> onServerResponse;
|
||||||
|
|
||||||
|
#ifdef TINYMITM_LOGS
|
||||||
|
void addLogSink(std::shared_ptr<seallib::ILogSink> sink) { _log->addSink(std::move(sink)); }
|
||||||
|
#endif
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// helper functions
|
// helper functions
|
||||||
static long long stollSafe(const std::string& s, int def = 0, int base = 10);
|
static long long stollSafe(const std::string& s, int def = 0, int base = 10);
|
||||||
@@ -117,4 +130,8 @@ class TinyMITMProxy
|
|||||||
CertificateManager _certManager;
|
CertificateManager _certManager;
|
||||||
|
|
||||||
TinyMITMConfig _config;
|
TinyMITMConfig _config;
|
||||||
|
|
||||||
|
#ifdef TINYMITM_LOGS
|
||||||
|
seallib::Logger* _log;
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user