mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-28 06:13:31 +01:00
Put some sense into our logging.
Transform our logging severities to something more sensible. Remove sneaky printf()s.
This commit is contained in:
parent
d0416ce3ec
commit
2e73f9b3ee
@ -3230,7 +3230,7 @@ get_string_from_pipe(FILE *stream, char *buf_out, size_t count)
|
|||||||
} else {
|
} else {
|
||||||
/* No newline; check whether we overflowed the buffer */
|
/* No newline; check whether we overflowed the buffer */
|
||||||
if (!feof(stream))
|
if (!feof(stream))
|
||||||
log_warn(LD_GENERAL,
|
log_info(LD_GENERAL,
|
||||||
"Line from stream was truncated: %s", buf_out);
|
"Line from stream was truncated: %s", buf_out);
|
||||||
/* TODO: What to do with this error? */
|
/* TODO: What to do with this error? */
|
||||||
}
|
}
|
||||||
|
@ -4694,15 +4694,15 @@ transport_resolve_conflicts(transport_t *t)
|
|||||||
return 1;
|
return 1;
|
||||||
} else { /* same name but different addrport */
|
} else { /* same name but different addrport */
|
||||||
if (t_tmp->marked_for_removal) { /* marked for removal */
|
if (t_tmp->marked_for_removal) { /* marked for removal */
|
||||||
log_warn(LD_GENERAL, "You tried to add transport '%s' at '%s:%u' but "
|
log_notice(LD_GENERAL, "You tried to add transport '%s' at '%s:%u' "
|
||||||
"there was already a transport marked for deletion at "
|
"but there was already a transport marked for deletion at "
|
||||||
"'%s:%u'. We deleted the old transport and registered the "
|
"'%s:%u'. We deleted the old transport and registered the "
|
||||||
"new one.", t->name, fmt_addr(&t->addr), t->port,
|
"new one.", t->name, fmt_addr(&t->addr), t->port,
|
||||||
fmt_addr(&t_tmp->addr), t_tmp->port);
|
fmt_addr(&t_tmp->addr), t_tmp->port);
|
||||||
smartlist_remove(transport_list, t_tmp);
|
smartlist_remove(transport_list, t_tmp);
|
||||||
transport_free(t_tmp);
|
transport_free(t_tmp);
|
||||||
} else { /* *not* marked for removal */
|
} else { /* *not* marked for removal */
|
||||||
log_warn(LD_GENERAL, "You tried to add transport '%s' at '%s:%u' "
|
log_notice(LD_GENERAL, "You tried to add transport '%s' at '%s:%u' "
|
||||||
"which already exists at '%s:%u'. Skipping.", t->name,
|
"which already exists at '%s:%u'. Skipping.", t->name,
|
||||||
fmt_addr(&t->addr), t->port,
|
fmt_addr(&t->addr), t->port,
|
||||||
fmt_addr(&t_tmp->addr), t_tmp->port);
|
fmt_addr(&t_tmp->addr), t_tmp->port);
|
||||||
@ -4753,17 +4753,17 @@ transport_add_from_config(const tor_addr_t *addr, uint16_t port,
|
|||||||
switch (r) {
|
switch (r) {
|
||||||
case -1:
|
case -1:
|
||||||
default:
|
default:
|
||||||
log_warn(LD_GENERAL, "Could not add transport %s at %s:%u. Skipping.",
|
log_notice(LD_GENERAL, "Could not add transport %s at %s:%u. Skipping.",
|
||||||
t->name, fmt_addr(&t->addr), t->port);
|
t->name, fmt_addr(&t->addr), t->port);
|
||||||
transport_free(t);
|
transport_free(t);
|
||||||
return -1;
|
return -1;
|
||||||
case 1:
|
case 1:
|
||||||
log_warn(LD_GENERAL, "Succesfully registered transport %s at %s:%u.",
|
log_info(LD_GENERAL, "Succesfully registered transport %s at %s:%u.",
|
||||||
t->name, fmt_addr(&t->addr), t->port);
|
t->name, fmt_addr(&t->addr), t->port);
|
||||||
transport_free(t); /* falling */
|
transport_free(t); /* falling */
|
||||||
return 0;
|
return 0;
|
||||||
case 0:
|
case 0:
|
||||||
log_warn(LD_GENERAL, "Succesfully registered transport %s at %s:%u.",
|
log_info(LD_GENERAL, "Succesfully registered transport %s at %s:%u.",
|
||||||
t->name, fmt_addr(&t->addr), t->port);
|
t->name, fmt_addr(&t->addr), t->port);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -4772,7 +4772,7 @@ parse_client_transport_line(const char *line, int validate_only)
|
|||||||
if (!validate_only) {
|
if (!validate_only) {
|
||||||
transport_add_from_config(&addr, port, name, socks_ver);
|
transport_add_from_config(&addr, port, name, socks_ver);
|
||||||
|
|
||||||
log_debug(LD_DIR, "Transport '%s' found at %s:%d", name,
|
log_info(LD_DIR, "Transport '%s' found at %s:%d", name,
|
||||||
fmt_addr(&addr), (int)port);
|
fmt_addr(&addr), (int)port);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -4871,7 +4871,7 @@ parse_server_transport_line(const char *line, int validate_only)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!validate_only) {
|
if (!validate_only) {
|
||||||
log_warn(LD_DIR, "Transport '%s' at %s:%d.", name,
|
log_info(LD_DIR, "Server transport '%s' at %s:%d.", name,
|
||||||
fmt_addr(&addr), (int)port);
|
fmt_addr(&addr), (int)port);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -5886,11 +5886,11 @@ save_transport_to_state(const char *transport,
|
|||||||
|
|
||||||
/* if transport in state has the same address as this one, life is good */
|
/* if transport in state has the same address as this one, life is good */
|
||||||
if (!strcmp(prev_bindaddr, transport_addrport)) {
|
if (!strcmp(prev_bindaddr, transport_addrport)) {
|
||||||
log_warn(LD_CONFIG, "Transport seems to have spawned on its usual "
|
log_info(LD_CONFIG, "Transport seems to have spawned on its usual "
|
||||||
"address:port.");
|
"address:port.");
|
||||||
goto done;
|
goto done;
|
||||||
} else { /* addrport in state is different than the one we got */
|
} else { /* addrport in state is different than the one we got */
|
||||||
log_warn(LD_CONFIG, "Transport seems to have spawned on different "
|
log_info(LD_CONFIG, "Transport seems to have spawned on different "
|
||||||
"address:port. Let's update the state file with the new "
|
"address:port. Let's update the state file with the new "
|
||||||
"address:port");
|
"address:port");
|
||||||
tor_free(transport_line->value); /* free the old line */
|
tor_free(transport_line->value); /* free the old line */
|
||||||
@ -5899,7 +5899,7 @@ save_transport_to_state(const char *transport,
|
|||||||
(int) port); /* replace old addrport line with new line */
|
(int) port); /* replace old addrport line with new line */
|
||||||
}
|
}
|
||||||
} else { /* never seen this one before; save it in state for next time */
|
} else { /* never seen this one before; save it in state for next time */
|
||||||
log_warn(LD_CONFIG, "It's the first time we see this transport. "
|
log_info(LD_CONFIG, "It's the first time we see this transport. "
|
||||||
"Let's save its address:port");
|
"Let's save its address:port");
|
||||||
next = &state->TransportProxies;
|
next = &state->TransportProxies;
|
||||||
/* find the last TransportProxy line in the state and point 'next'
|
/* find the last TransportProxy line in the state and point 'next'
|
||||||
|
@ -268,7 +268,8 @@ launch_managed_proxy(managed_proxy_t *mp)
|
|||||||
&stderr_pipe, (const char **)mp->argv,
|
&stderr_pipe, (const char **)mp->argv,
|
||||||
(const char **)envp);
|
(const char **)envp);
|
||||||
if (pid < 0) {
|
if (pid < 0) {
|
||||||
log_warn(LD_GENERAL, "Spawn failed");
|
log_warn(LD_GENERAL, "Managed proxy at '%s' failed at launch.",
|
||||||
|
mp->argv[0]);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -280,7 +281,7 @@ launch_managed_proxy(managed_proxy_t *mp)
|
|||||||
/* Open the buffered IO streams */
|
/* Open the buffered IO streams */
|
||||||
stdout_read = fdopen(stdout_pipe, "r");
|
stdout_read = fdopen(stdout_pipe, "r");
|
||||||
|
|
||||||
log_warn(LD_CONFIG, "The spawn is alive (%d)!", pid);
|
log_info(LD_CONFIG, "Managed proxy has spawned at PID %d.", pid);
|
||||||
|
|
||||||
mp->conf_state = PT_PROTO_LAUNCHED;
|
mp->conf_state = PT_PROTO_LAUNCHED;
|
||||||
mp->stdout = stdout_read;
|
mp->stdout = stdout_read;
|
||||||
@ -295,7 +296,7 @@ launch_managed_proxy(managed_proxy_t *mp)
|
|||||||
void
|
void
|
||||||
pt_configure_remaining_proxies(void)
|
pt_configure_remaining_proxies(void)
|
||||||
{
|
{
|
||||||
log_warn(LD_CONFIG, "We start configuring remaining managed proxies (%d)!",
|
log_debug(LD_CONFIG, "Configuring remaining managed proxies (%d)!",
|
||||||
unconfigured_proxies_n);
|
unconfigured_proxies_n);
|
||||||
SMARTLIST_FOREACH_BEGIN(managed_proxy_list, managed_proxy_t *, mp) {
|
SMARTLIST_FOREACH_BEGIN(managed_proxy_list, managed_proxy_t *, mp) {
|
||||||
tor_assert(mp->conf_state != PT_PROTO_BROKEN);
|
tor_assert(mp->conf_state != PT_PROTO_BROKEN);
|
||||||
@ -306,10 +307,12 @@ pt_configure_remaining_proxies(void)
|
|||||||
/* This proxy is marked by a SIGHUP. Check whether we need to
|
/* This proxy is marked by a SIGHUP. Check whether we need to
|
||||||
restart it. */
|
restart it. */
|
||||||
if (proxy_needs_restart(mp)) {
|
if (proxy_needs_restart(mp)) {
|
||||||
|
log_info(LD_GENERAL, "Preparing managed proxy for restart.");
|
||||||
proxy_prepare_for_restart(mp);
|
proxy_prepare_for_restart(mp);
|
||||||
continue;
|
continue;
|
||||||
} else { /* it doesn't need to be restarted. */
|
} else { /* it doesn't need to be restarted. */
|
||||||
printf("No need for restart; status quo\n");
|
log_info(LD_GENERAL, "Nothing changed for managed proxy after HUP: "
|
||||||
|
"not restarting.");
|
||||||
unconfigured_proxies_n--;
|
unconfigured_proxies_n--;
|
||||||
tor_assert(unconfigured_proxies_n >= 0);
|
tor_assert(unconfigured_proxies_n >= 0);
|
||||||
}
|
}
|
||||||
@ -349,11 +352,11 @@ configure_proxy(managed_proxy_t *mp)
|
|||||||
} else if (r == IO_STREAM_EAGAIN) { /* check back later */
|
} else if (r == IO_STREAM_EAGAIN) { /* check back later */
|
||||||
return;
|
return;
|
||||||
} else if (r == IO_STREAM_CLOSED || r == IO_STREAM_TERM) { /* snap! */
|
} else if (r == IO_STREAM_CLOSED || r == IO_STREAM_TERM) { /* snap! */
|
||||||
log_warn(LD_GENERAL, "Managed proxy stream closed. "
|
log_notice(LD_GENERAL, "Managed proxy stream closed. "
|
||||||
"Most probably application stopped running");
|
"Most probably application stopped running");
|
||||||
mp->conf_state = PT_PROTO_BROKEN;
|
mp->conf_state = PT_PROTO_BROKEN;
|
||||||
} else { /* unknown stream status */
|
} else { /* unknown stream status */
|
||||||
log_warn(LD_GENERAL, "Unknown stream status while configuring proxy.");
|
log_notice(LD_GENERAL, "Unknown stream status while configuring proxy.");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* if the proxy finished configuring, exit the loop. */
|
/* if the proxy finished configuring, exit the loop. */
|
||||||
@ -398,15 +401,15 @@ register_client_proxy(managed_proxy_t *mp)
|
|||||||
r = transport_add(t);
|
r = transport_add(t);
|
||||||
switch (r) {
|
switch (r) {
|
||||||
case -1:
|
case -1:
|
||||||
log_warn(LD_GENERAL, "Could not add transport %s. Skipping.", t->name);
|
log_notice(LD_GENERAL, "Could not add transport %s. Skipping.", t->name);
|
||||||
transport_free(t);
|
transport_free(t);
|
||||||
break;
|
break;
|
||||||
case 0:
|
case 0:
|
||||||
log_warn(LD_GENERAL, "Succesfully registered transport %s", t->name);
|
log_info(LD_GENERAL, "Succesfully registered transport %s", t->name);
|
||||||
smartlist_add(sm_tmp, tor_strdup(t->name));
|
smartlist_add(sm_tmp, tor_strdup(t->name));
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
log_warn(LD_GENERAL, "Succesfully registered transport %s", t->name);
|
log_info(LD_GENERAL, "Succesfully registered transport %s", t->name);
|
||||||
smartlist_add(sm_tmp, tor_strdup(t->name));
|
smartlist_add(sm_tmp, tor_strdup(t->name));
|
||||||
transport_free(t);
|
transport_free(t);
|
||||||
break;
|
break;
|
||||||
@ -431,7 +434,6 @@ register_proxy(managed_proxy_t *mp)
|
|||||||
static void
|
static void
|
||||||
managed_proxy_destroy(managed_proxy_t *mp)
|
managed_proxy_destroy(managed_proxy_t *mp)
|
||||||
{
|
{
|
||||||
printf("Destroying mp %p\n", mp);
|
|
||||||
if (mp->conf_state != PT_PROTO_COMPLETED)
|
if (mp->conf_state != PT_PROTO_COMPLETED)
|
||||||
SMARTLIST_FOREACH(mp->transports, transport_t *, t, transport_free(t));
|
SMARTLIST_FOREACH(mp->transports, transport_t *, t, transport_free(t));
|
||||||
else
|
else
|
||||||
@ -503,10 +505,10 @@ handle_methods_done(const managed_proxy_t *mp)
|
|||||||
tor_assert(mp->transports);
|
tor_assert(mp->transports);
|
||||||
|
|
||||||
if (smartlist_len(mp->transports) == 0)
|
if (smartlist_len(mp->transports) == 0)
|
||||||
log_warn(LD_GENERAL, "Proxy was spawned successfully, "
|
log_notice(LD_GENERAL, "Proxy was spawned successfully, "
|
||||||
"but it didn't laucn any pluggable transport listeners!");
|
"but it didn't laucn any pluggable transport listeners!");
|
||||||
|
|
||||||
log_warn(LD_CONFIG, "%s managed proxy configuration completed!",
|
log_info(LD_CONFIG, "%s managed proxy configuration completed!",
|
||||||
mp->is_server ? "Server" : "Client");
|
mp->is_server ? "Server" : "Client");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -515,7 +517,7 @@ handle_methods_done(const managed_proxy_t *mp)
|
|||||||
void
|
void
|
||||||
handle_proxy_line(const char *line, managed_proxy_t *mp)
|
handle_proxy_line(const char *line, managed_proxy_t *mp)
|
||||||
{
|
{
|
||||||
printf("Judging line: %s\n", line);
|
log_debug(LD_GENERAL, "Got a line from managed proxy: %s\n", line);
|
||||||
|
|
||||||
if (strlen(line) < SMALLEST_MANAGED_LINE_SIZE) {
|
if (strlen(line) < SMALLEST_MANAGED_LINE_SIZE) {
|
||||||
log_warn(LD_GENERAL, "Managed proxy configuration line is too small. "
|
log_warn(LD_GENERAL, "Managed proxy configuration line is too small. "
|
||||||
@ -609,7 +611,7 @@ parse_env_error(const char *line)
|
|||||||
/* (Length of the protocol string) plus (a space) and (the first char of
|
/* (Length of the protocol string) plus (a space) and (the first char of
|
||||||
the error message) */
|
the error message) */
|
||||||
if (strlen(line) < (strlen(PROTO_ENV_ERROR) + 2))
|
if (strlen(line) < (strlen(PROTO_ENV_ERROR) + 2))
|
||||||
log_warn(LD_CONFIG, "Managed proxy sent us an %s without an error "
|
log_notice(LD_CONFIG, "Managed proxy sent us an %s without an error "
|
||||||
"message.", PROTO_ENV_ERROR);
|
"message.", PROTO_ENV_ERROR);
|
||||||
|
|
||||||
log_warn(LD_CONFIG, "Managed proxy couldn't understand the "
|
log_warn(LD_CONFIG, "Managed proxy couldn't understand the "
|
||||||
@ -628,8 +630,8 @@ parse_version(const char *line, managed_proxy_t *mp)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strcmp("1", line+strlen(PROTO_NEG_SUCCESS)+1)) {
|
if (strcmp("1", line+strlen(PROTO_NEG_SUCCESS)+1)) { /* hardcoded temp */
|
||||||
log_warn(LD_CONFIG, "We don't support version '%s'. "
|
log_warn(LD_CONFIG, "Managed proxy tried to negotiate on version '%s'. "
|
||||||
"We only support version '1'", line+strlen(PROTO_NEG_SUCCESS)+1);
|
"We only support version '1'", line+strlen(PROTO_NEG_SUCCESS)+1);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -713,7 +715,7 @@ parse_smethod_line(const char *line, managed_proxy_t *mp)
|
|||||||
|
|
||||||
/* For now, notify the user so that he knows where the server
|
/* For now, notify the user so that he knows where the server
|
||||||
transport is listening. */
|
transport is listening. */
|
||||||
log_warn(LD_CONFIG, "Server transport %s at %s:%d.",
|
log_info(LD_CONFIG, "Server transport %s at %s:%d.",
|
||||||
method_name, fmt_addr(&addr), (int)port);
|
method_name, fmt_addr(&addr), (int)port);
|
||||||
|
|
||||||
r=0;
|
r=0;
|
||||||
@ -796,7 +798,7 @@ parse_cmethod_line(const char *line, managed_proxy_t *mp)
|
|||||||
|
|
||||||
smartlist_add(mp->transports, transport);
|
smartlist_add(mp->transports, transport);
|
||||||
|
|
||||||
log_warn(LD_CONFIG, "Transport %s at %s:%d with SOCKS %d. "
|
log_info(LD_CONFIG, "Transport %s at %s:%d with SOCKS %d. "
|
||||||
"Attached to managed proxy.",
|
"Attached to managed proxy.",
|
||||||
method_name, fmt_addr(&addr), (int)port, socks_ver);
|
method_name, fmt_addr(&addr), (int)port, socks_ver);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user