commit 8754b6626d758adf138cd8fc06328ae24d3e7bd5
Author: George Kadianakis <desnacked(a)riseup.net>
Date: Wed Jan 18 04:44:09 2012 +0200
Add logging to src/managed.c.
---
src/managed.c | 28 ++++++++++++++++++++++++++++
src/util.c | 6 ++++++
src/util.h | 2 ++
3 files changed, 36 insertions(+), 0 deletions(-)
diff --git a/src/managed.c b/src/managed.c
index d70c1cf..dfd8a3f 100644
--- a/src/managed.c
+++ b/src/managed.c
@@ -112,6 +112,27 @@ assert_proxy_env(managed_proxy_t *proxy)
}
}
+/** Log the environment variables that tor prepared for <b>proxy</b>. */
+static inline void
+log_proxy_env(managed_proxy_t *proxy)
+{
+ obfs_assert(proxy);
+
+ log_debug("Proxy environment:\n"
+ "state_loc: '%s'\nconf_proto_version: '%s'\ntransports: '%s'",
+ proxy->vars.state_loc,
+ proxy->vars.conf_proto_version,
+ proxy->vars.transports);
+
+ if (proxy->is_server) {
+ log_debug("Proxy environment (cont):\n"
+ "extended_port: '%s'\nor_port: '%s'\nbindaddrs: '%s'",
+ proxy->vars.extended_port,
+ proxy->vars.or_port,
+ proxy->vars.bindaddrs);
+ }
+}
+
/**
This function is used for obfsproxy to communicate with tor.
Practically a wrapper of printf, it prints 'format' and the
@@ -125,6 +146,11 @@ print_protocol_line(const char *format, ...)
va_start(ap,format);
vprintf(format, ap);
fflush(stdout);
+
+ /* log the protocol message */
+ log_debug("We sent:");
+ log_debug_raw(format, ap);
+
va_end(ap);
}
@@ -246,6 +272,8 @@ validate_environment(managed_proxy_t *proxy)
assert_proxy_env(proxy);
+ if (log_do_debug()) log_proxy_env(proxy);
+
if (proxy->is_server) {
if (validate_bindaddrs(proxy->vars.bindaddrs, proxy->vars.transports) < 0) {
status = ST_ENV_FAIL_BINDADDR;
diff --git a/src/util.c b/src/util.c
index c63a651..2e84cc6 100644
--- a/src/util.c
+++ b/src/util.c
@@ -595,3 +595,9 @@ log_debug(const char *format, ...)
va_end(ap);
}
+
+void
+log_debug_raw(const char *format, va_list ap)
+{
+ logv(LOG_SEV_DEBUG, format, ap);
+}
diff --git a/src/util.h b/src/util.h
index 8a7585b..a8588c2 100644
--- a/src/util.h
+++ b/src/util.h
@@ -171,6 +171,8 @@ void log_info(const char *format, ...)
void log_debug(const char *format, ...)
ATTR_PRINTF_1;
+void log_debug_raw(const char *format, va_list ap);
+
/** Assertion checking. We don't ever compile assertions out, and we
want precise control over the error messages, so we use our own
assertion macros. */