diff options
author | Alexander Færøy <ahf@torproject.org> | 2018-11-29 16:42:56 +0100 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2018-12-17 16:39:28 -0500 |
commit | ec2ae3ed8b542950dc774223607f14f524375a50 (patch) | |
tree | 614ac207b44a06dfd7940ba4fcf8359e5aefde9b /src/feature/client | |
parent | 5585cbd08f54f732c32feea276c1a47ec8446c5e (diff) | |
download | tor-ec2ae3ed8b542950dc774223607f14f524375a50.tar.gz tor-ec2ae3ed8b542950dc774223607f14f524375a50.zip |
Change EVENT_TRANSPORT_LOG to EVENT_PT_LOG.
This patch changes our EVENT_TRANSPORT_LOG event to be EVENT_PT_LOG. The
new message includes the path to the PT executable instead of the
transport name, since one PT binary can include multiple transport they
sometimes might need to log messages that are not specific to a given
transport.
See: https://bugs.torproject.org/28179
Diffstat (limited to 'src/feature/client')
-rw-r--r-- | src/feature/client/transports.c | 33 | ||||
-rw-r--r-- | src/feature/client/transports.h | 2 |
2 files changed, 11 insertions, 24 deletions
diff --git a/src/feature/client/transports.c b/src/feature/client/transports.c index e3cc679411..df7991846c 100644 --- a/src/feature/client/transports.c +++ b/src/feature/client/transports.c @@ -910,7 +910,7 @@ handle_proxy_line(const char *line, managed_proxy_t *mp) parse_proxy_error(line); goto err; } else if (!strcmpstart(line, PROTO_LOG)) { - parse_log_line(line); + parse_log_line(line, mp); return; } @@ -1135,40 +1135,27 @@ parse_proxy_error(const char *line) /** Parses a LOG <b>line</b> and emit log events accordingly. */ STATIC void -parse_log_line(const char *line) +parse_log_line(const char *line, managed_proxy_t *mp) { - smartlist_t *items = smartlist_new(); + tor_assert(line); + tor_assert(mp); if (strlen(line) < (strlen(PROTO_LOG) + 1)) { log_warn(LD_PT, "Managed proxy sent us a %s line " - "with missing arguments.", PROTO_LOG); - goto done; - } - - const char *arguments = line + strlen(PROTO_LOG) + 1; - - /* The format is 'LOG <transport> <message>'. We accept empty messages. */ - smartlist_split_string(items, arguments, NULL, - SPLIT_SKIP_SPACE|SPLIT_IGNORE_BLANK, 2); - - if (smartlist_len(items) < 2) { - log_warn(LD_PT, "Managed proxy sent us a %s line " - "with too few arguments.", PROTO_LOG); + "with missing argument.", PROTO_LOG); goto done; } - const char *transport_name = smartlist_get(items, 0); - const char *message = smartlist_get(items, 1); + const char *message = line + strlen(PROTO_LOG) + 1; - log_info(LD_PT, "Managed proxy transport \"%s\" says: %s", - transport_name, message); + log_info(LD_PT, "Managed proxy \"%s\" says: %s", + mp->argv[0], message); /* Emit control port event. */ - control_event_transport_log(transport_name, message); + control_event_pt_log(mp->argv[0], message); done: - SMARTLIST_FOREACH(items, char *, s, tor_free(s)); - smartlist_free(items); + return; } /** Return a newly allocated string that tor should place in diff --git a/src/feature/client/transports.h b/src/feature/client/transports.h index ba8cbf7105..88735a7211 100644 --- a/src/feature/client/transports.h +++ b/src/feature/client/transports.h @@ -128,7 +128,7 @@ STATIC int parse_version(const char *line, managed_proxy_t *mp); STATIC void parse_env_error(const char *line); STATIC void parse_proxy_error(const char *line); STATIC void handle_proxy_line(const char *line, managed_proxy_t *mp); -STATIC void parse_log_line(const char *line); +STATIC void parse_log_line(const char *line, managed_proxy_t *mp); STATIC char *get_transport_options_for_server_proxy(const managed_proxy_t *mp); STATIC void managed_proxy_destroy(managed_proxy_t *mp, |