Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Debug log #630

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/goodbyedpi.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#include "ttltrack.h"
#include "blackwhitelist.h"
#include "fakepackets.h"

int (*debugPrint)(char const *const _Format, ...) = NULL;
// My mingw installation does not load inet_pton definition for some reason
WINSOCK_API_LINKAGE INT WSAAPI inet_pton(INT Family, LPCSTR pStringBuf, PVOID pAddr);

Expand Down Expand Up @@ -192,6 +192,7 @@ static struct option long_options[] = {
{"fake-gen", required_argument, 0, 'j' },
{"fake-resend", required_argument, 0, 't' },
{"debug-exit", optional_argument, 0, 'x' },
{"debug-log", optional_argument, 0, 'l' },
{0, 0, 0, 0 }
};

Expand Down Expand Up @@ -965,6 +966,10 @@ int main(int argc, char *argv[]) {
case 'x': // --debug-exit
debug_exit = true;
break;
case 'l':
debugPrint = &printf;
debug("Testing debug output\n");
break;
default:
puts("Usage: goodbyedpi.exe [OPTION...]\n"
" -p block passive DPI\n"
Expand Down
7 changes: 5 additions & 2 deletions src/goodbyedpi.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
#define HOST_MAXLEN 253
#define MAX_PACKET_SIZE 9016

extern int (*debugPrint)(char const *const _Format, ...);
#ifndef DEBUG
#define debug(...) do {} while (0)
#define debug(...) \
if (debugPrint) { \
debugPrint(__VA_ARGS__); \
}
#else
#define debug(...) printf(__VA_ARGS__)
#endif
Expand Down