mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-28 06:13:31 +01:00
Merge branch 'rename_log_7599'
This commit is contained in:
commit
ec90ed4f6d
4
changes/rename_log_7599
Normal file
4
changes/rename_log_7599
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
o Code simplification and refactoring:
|
||||||
|
- Rename Tor's logging function log() to tor_log(), to avoid conflicts
|
||||||
|
with the natural logarithm function from the system libm. Resolves
|
||||||
|
ticket 7599.
|
@ -1270,14 +1270,14 @@ get_interface_addresses_raw(int severity)
|
|||||||
/* This interface, AFAICT, only supports AF_INET addresses */
|
/* This interface, AFAICT, only supports AF_INET addresses */
|
||||||
fd = socket(AF_INET, SOCK_DGRAM, 0);
|
fd = socket(AF_INET, SOCK_DGRAM, 0);
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
log(severity, LD_NET, "socket failed: %s", strerror(errno));
|
tor_log(severity, LD_NET, "socket failed: %s", strerror(errno));
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
/* Guess how much space we need. */
|
/* Guess how much space we need. */
|
||||||
ifc.ifc_len = sz = 15*1024;
|
ifc.ifc_len = sz = 15*1024;
|
||||||
ifc.ifc_ifcu.ifcu_req = tor_malloc(sz);
|
ifc.ifc_ifcu.ifcu_req = tor_malloc(sz);
|
||||||
if (ioctl(fd, SIOCGIFCONF, &ifc) < 0) {
|
if (ioctl(fd, SIOCGIFCONF, &ifc) < 0) {
|
||||||
log(severity, LD_NET, "ioctl failed: %s", strerror(errno));
|
tor_log(severity, LD_NET, "ioctl failed: %s", strerror(errno));
|
||||||
close(fd);
|
close(fd);
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
@ -76,19 +76,19 @@ libevent_logging_callback(int severity, const char *msg)
|
|||||||
}
|
}
|
||||||
switch (severity) {
|
switch (severity) {
|
||||||
case _EVENT_LOG_DEBUG:
|
case _EVENT_LOG_DEBUG:
|
||||||
log(LOG_DEBUG, LD_NOCB|LD_NET, "Message from libevent: %s", buf);
|
log_debug(LD_NOCB|LD_NET, "Message from libevent: %s", buf);
|
||||||
break;
|
break;
|
||||||
case _EVENT_LOG_MSG:
|
case _EVENT_LOG_MSG:
|
||||||
log(LOG_INFO, LD_NOCB|LD_NET, "Message from libevent: %s", buf);
|
log_info(LD_NOCB|LD_NET, "Message from libevent: %s", buf);
|
||||||
break;
|
break;
|
||||||
case _EVENT_LOG_WARN:
|
case _EVENT_LOG_WARN:
|
||||||
log(LOG_WARN, LD_NOCB|LD_GENERAL, "Warning from libevent: %s", buf);
|
log_warn(LD_NOCB|LD_GENERAL, "Warning from libevent: %s", buf);
|
||||||
break;
|
break;
|
||||||
case _EVENT_LOG_ERR:
|
case _EVENT_LOG_ERR:
|
||||||
log(LOG_ERR, LD_NOCB|LD_GENERAL, "Error from libevent: %s", buf);
|
log_err(LD_NOCB|LD_GENERAL, "Error from libevent: %s", buf);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
log(LOG_WARN, LD_NOCB|LD_GENERAL, "Message [%d] from libevent: %s",
|
log_warn(LD_NOCB|LD_GENERAL, "Message [%d] from libevent: %s",
|
||||||
severity, buf);
|
severity, buf);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -261,13 +261,13 @@ tor_libevent_initialize(tor_libevent_cfg *torcfg)
|
|||||||
#if defined(HAVE_EVENT_GET_VERSION) && defined(HAVE_EVENT_GET_METHOD)
|
#if defined(HAVE_EVENT_GET_VERSION) && defined(HAVE_EVENT_GET_METHOD)
|
||||||
/* Making this a NOTICE for now so we can link bugs to a libevent versions
|
/* Making this a NOTICE for now so we can link bugs to a libevent versions
|
||||||
* or methods better. */
|
* or methods better. */
|
||||||
log(LOG_INFO, LD_GENERAL,
|
log_info(LD_GENERAL,
|
||||||
"Initialized libevent version %s using method %s. Good.",
|
"Initialized libevent version %s using method %s. Good.",
|
||||||
event_get_version(), tor_libevent_get_method());
|
event_get_version(), tor_libevent_get_method());
|
||||||
#else
|
#else
|
||||||
log(LOG_NOTICE, LD_GENERAL,
|
log_notice(LD_GENERAL,
|
||||||
"Initialized old libevent (version 1.0b or earlier).");
|
"Initialized old libevent (version 1.0b or earlier).");
|
||||||
log(LOG_WARN, LD_GENERAL,
|
log_warn(LD_GENERAL,
|
||||||
"You have a *VERY* old version of libevent. It is likely to be buggy; "
|
"You have a *VERY* old version of libevent. It is likely to be buggy; "
|
||||||
"please build Tor with a more recent version.");
|
"please build Tor with a more recent version.");
|
||||||
#endif
|
#endif
|
||||||
@ -440,7 +440,7 @@ tor_check_libevent_header_compatibility(void)
|
|||||||
|
|
||||||
verybad = compat1 != compat2;
|
verybad = compat1 != compat2;
|
||||||
|
|
||||||
log(verybad ? LOG_WARN : LOG_NOTICE,
|
tor_log(verybad ? LOG_WARN : LOG_NOTICE,
|
||||||
LD_GENERAL, "We were compiled with headers from version %s "
|
LD_GENERAL, "We were compiled with headers from version %s "
|
||||||
"of Libevent, but we're using a Libevent library that says it's "
|
"of Libevent, but we're using a Libevent library that says it's "
|
||||||
"version %s.", HEADER_VERSION, event_get_version());
|
"version %s.", HEADER_VERSION, event_get_version());
|
||||||
|
@ -151,10 +151,11 @@ crypto_log_errors(int severity, const char *doing)
|
|||||||
if (!lib) lib = "(null)";
|
if (!lib) lib = "(null)";
|
||||||
if (!func) func = "(null)";
|
if (!func) func = "(null)";
|
||||||
if (doing) {
|
if (doing) {
|
||||||
log(severity, LD_CRYPTO, "crypto error while %s: %s (in %s:%s)",
|
tor_log(severity, LD_CRYPTO, "crypto error while %s: %s (in %s:%s)",
|
||||||
doing, msg, lib, func);
|
doing, msg, lib, func);
|
||||||
} else {
|
} else {
|
||||||
log(severity, LD_CRYPTO, "crypto error: %s (in %s:%s)", msg, lib, func);
|
tor_log(severity, LD_CRYPTO, "crypto error: %s (in %s:%s)",
|
||||||
|
msg, lib, func);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -168,10 +169,10 @@ log_engine(const char *fn, ENGINE *e)
|
|||||||
const char *name, *id;
|
const char *name, *id;
|
||||||
name = ENGINE_get_name(e);
|
name = ENGINE_get_name(e);
|
||||||
id = ENGINE_get_id(e);
|
id = ENGINE_get_id(e);
|
||||||
log(LOG_NOTICE, LD_CRYPTO, "Using OpenSSL engine %s [%s] for %s",
|
log_notice(LD_CRYPTO, "Using OpenSSL engine %s [%s] for %s",
|
||||||
name?name:"?", id?id:"?", fn);
|
name?name:"?", id?id:"?", fn);
|
||||||
} else {
|
} else {
|
||||||
log(LOG_INFO, LD_CRYPTO, "Using default implementation for %s", fn);
|
log_info(LD_CRYPTO, "Using default implementation for %s", fn);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -321,7 +321,7 @@ tor_process_monitor_poll_cb(evutil_socket_t unused1, short unused2,
|
|||||||
its_dead_jim = its_dead_jim && (errno == ESRCH);
|
its_dead_jim = its_dead_jim && (errno == ESRCH);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
log(its_dead_jim ? LOG_NOTICE : LOG_INFO,
|
tor_log(its_dead_jim ? LOG_NOTICE : LOG_INFO,
|
||||||
procmon->log_domain, "Monitored process "PID_T_FORMAT" is %s.",
|
procmon->log_domain, "Monitored process "PID_T_FORMAT" is %s.",
|
||||||
procmon->pid,
|
procmon->pid,
|
||||||
its_dead_jim ? "dead" : "still alive");
|
its_dead_jim ? "dead" : "still alive");
|
||||||
|
@ -153,7 +153,6 @@ void set_log_time_granularity(int granularity_msec);
|
|||||||
|
|
||||||
void tor_log(int severity, log_domain_mask_t domain, const char *format, ...)
|
void tor_log(int severity, log_domain_mask_t domain, const char *format, ...)
|
||||||
CHECK_PRINTF(3,4);
|
CHECK_PRINTF(3,4);
|
||||||
#define log tor_log /* hack it so we don't conflict with log() as much */
|
|
||||||
|
|
||||||
#if defined(__GNUC__) || defined(RUNNING_DOXYGEN)
|
#if defined(__GNUC__) || defined(RUNNING_DOXYGEN)
|
||||||
extern int log_global_min_severity_;
|
extern int log_global_min_severity_;
|
||||||
|
@ -334,11 +334,11 @@ tor_tls_log_one_error(tor_tls_t *tls, unsigned long err,
|
|||||||
if (!lib) lib = "(null)";
|
if (!lib) lib = "(null)";
|
||||||
if (!func) func = "(null)";
|
if (!func) func = "(null)";
|
||||||
if (doing) {
|
if (doing) {
|
||||||
log(severity, domain, "TLS error while %s%s%s: %s (in %s:%s:%s)",
|
tor_log(severity, domain, "TLS error while %s%s%s: %s (in %s:%s:%s)",
|
||||||
doing, addr?" with ":"", addr?addr:"",
|
doing, addr?" with ":"", addr?addr:"",
|
||||||
msg, lib, func, state);
|
msg, lib, func, state);
|
||||||
} else {
|
} else {
|
||||||
log(severity, domain, "TLS error%s%s: %s (in %s:%s:%s)",
|
tor_log(severity, domain, "TLS error%s%s: %s (in %s:%s:%s)",
|
||||||
addr?" with ":"", addr?addr:"",
|
addr?" with ":"", addr?addr:"",
|
||||||
msg, lib, func, state);
|
msg, lib, func, state);
|
||||||
}
|
}
|
||||||
@ -427,12 +427,12 @@ tor_tls_get_error(tor_tls_t *tls, int r, int extra,
|
|||||||
if (extra&CATCH_SYSCALL)
|
if (extra&CATCH_SYSCALL)
|
||||||
return TOR_TLS_SYSCALL_;
|
return TOR_TLS_SYSCALL_;
|
||||||
if (r == 0) {
|
if (r == 0) {
|
||||||
log(severity, LD_NET, "TLS error: unexpected close while %s (%s)",
|
tor_log(severity, LD_NET, "TLS error: unexpected close while %s (%s)",
|
||||||
doing, SSL_state_string_long(tls->ssl));
|
doing, SSL_state_string_long(tls->ssl));
|
||||||
tor_error = TOR_TLS_ERROR_IO;
|
tor_error = TOR_TLS_ERROR_IO;
|
||||||
} else {
|
} else {
|
||||||
int e = tor_socket_errno(tls->socket);
|
int e = tor_socket_errno(tls->socket);
|
||||||
log(severity, LD_NET,
|
tor_log(severity, LD_NET,
|
||||||
"TLS error: <syscall error while %s> (errno=%d: %s; state=%s)",
|
"TLS error: <syscall error while %s> (errno=%d: %s; state=%s)",
|
||||||
doing, e, tor_socket_strerror(e),
|
doing, e, tor_socket_strerror(e),
|
||||||
SSL_state_string_long(tls->ssl));
|
SSL_state_string_long(tls->ssl));
|
||||||
@ -443,7 +443,7 @@ tor_tls_get_error(tor_tls_t *tls, int r, int extra,
|
|||||||
case SSL_ERROR_ZERO_RETURN:
|
case SSL_ERROR_ZERO_RETURN:
|
||||||
if (extra&CATCH_ZERO)
|
if (extra&CATCH_ZERO)
|
||||||
return TOR_TLS_ZERORETURN_;
|
return TOR_TLS_ZERORETURN_;
|
||||||
log(severity, LD_NET, "TLS connection closed while %s in state %s",
|
tor_log(severity, LD_NET, "TLS connection closed while %s in state %s",
|
||||||
doing, SSL_state_string_long(tls->ssl));
|
doing, SSL_state_string_long(tls->ssl));
|
||||||
tls_log_errors(tls, severity, domain, doing);
|
tls_log_errors(tls, severity, domain, doing);
|
||||||
return TOR_TLS_CLOSE;
|
return TOR_TLS_CLOSE;
|
||||||
@ -1224,7 +1224,7 @@ tor_tls_context_new(crypto_pk_t *identity, unsigned int key_lifetime,
|
|||||||
authcert = tor_tls_create_certificate(rsa_auth, identity, nickname, nn2,
|
authcert = tor_tls_create_certificate(rsa_auth, identity, nickname, nn2,
|
||||||
key_lifetime);
|
key_lifetime);
|
||||||
if (!cert || !idcert || !authcert) {
|
if (!cert || !idcert || !authcert) {
|
||||||
log(LOG_WARN, LD_CRYPTO, "Error creating certificate");
|
log_warn(LD_CRYPTO, "Error creating certificate");
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2272,7 +2272,7 @@ tor_tls_shutdown(tor_tls_t *tls)
|
|||||||
*/
|
*/
|
||||||
if (tls->state == TOR_TLS_ST_GOTCLOSE ||
|
if (tls->state == TOR_TLS_ST_GOTCLOSE ||
|
||||||
tls->state == TOR_TLS_ST_SENTCLOSE) {
|
tls->state == TOR_TLS_ST_SENTCLOSE) {
|
||||||
log(LOG_WARN, LD_NET,
|
log_warn(LD_NET,
|
||||||
"TLS returned \"half-closed\" value while already half-closed");
|
"TLS returned \"half-closed\" value while already half-closed");
|
||||||
return TOR_TLS_ERROR_MISC;
|
return TOR_TLS_ERROR_MISC;
|
||||||
}
|
}
|
||||||
@ -2322,7 +2322,7 @@ log_cert_lifetime(int severity, const X509 *cert, const char *problem)
|
|||||||
struct tm tm;
|
struct tm tm;
|
||||||
|
|
||||||
if (problem)
|
if (problem)
|
||||||
log(severity, LD_GENERAL,
|
tor_log(severity, LD_GENERAL,
|
||||||
"Certificate %s. Either their clock is set wrong, or your clock "
|
"Certificate %s. Either their clock is set wrong, or your clock "
|
||||||
"is wrong.",
|
"is wrong.",
|
||||||
problem);
|
problem);
|
||||||
@ -2347,7 +2347,7 @@ log_cert_lifetime(int severity, const X509 *cert, const char *problem)
|
|||||||
|
|
||||||
strftime(mytime, 32, "%b %d %H:%M:%S %Y UTC", tor_gmtime_r(&now, &tm));
|
strftime(mytime, 32, "%b %d %H:%M:%S %Y UTC", tor_gmtime_r(&now, &tm));
|
||||||
|
|
||||||
log(severity, LD_GENERAL,
|
tor_log(severity, LD_GENERAL,
|
||||||
"(certificate lifetime runs from %s through %s. Your time is %s.)",
|
"(certificate lifetime runs from %s through %s. Your time is %s.)",
|
||||||
s1,s2,mytime);
|
s1,s2,mytime);
|
||||||
|
|
||||||
@ -2568,7 +2568,7 @@ check_no_tls_errors_(const char *fname, int line)
|
|||||||
{
|
{
|
||||||
if (ERR_peek_error() == 0)
|
if (ERR_peek_error() == 0)
|
||||||
return;
|
return;
|
||||||
log(LOG_WARN, LD_CRYPTO, "Unhandled OpenSSL errors found at %s:%d: ",
|
log_warn(LD_CRYPTO, "Unhandled OpenSSL errors found at %s:%d: ",
|
||||||
tor_fix_source_file(fname), line);
|
tor_fix_source_file(fname), line);
|
||||||
tls_log_errors(NULL, LOG_WARN, LD_NET, NULL);
|
tls_log_errors(NULL, LOG_WARN, LD_NET, NULL);
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,6 @@
|
|||||||
#define UTIL_PRIVATE
|
#define UTIL_PRIVATE
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "torlog.h"
|
#include "torlog.h"
|
||||||
#undef log
|
|
||||||
#include "crypto.h"
|
#include "crypto.h"
|
||||||
#include "torint.h"
|
#include "torint.h"
|
||||||
#include "container.h"
|
#include "container.h"
|
||||||
@ -323,8 +322,8 @@ tor_log_mallinfo(int severity)
|
|||||||
* ===== */
|
* ===== */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the natural logarithm of d base 2. We define this wrapper here so
|
* Returns the natural logarithm of d base e. We defined this wrapper here so
|
||||||
* as to make it easier not to conflict with Tor's log() macro.
|
* to avoid conflicts with old versions of tor_log(), which were named log().
|
||||||
*/
|
*/
|
||||||
double
|
double
|
||||||
tor_mathlog(double d)
|
tor_mathlog(double d)
|
||||||
|
@ -534,7 +534,7 @@ nameserver_probe_failed(struct nameserver *const ns) {
|
|||||||
ns->failed_times++;
|
ns->failed_times++;
|
||||||
|
|
||||||
if (add_timeout_event(ns, (struct timeval *) timeout) < 0) {
|
if (add_timeout_event(ns, (struct timeval *) timeout) < 0) {
|
||||||
log(EVDNS_LOG_WARN,
|
tor_log(EVDNS_LOG_WARN,
|
||||||
"Error from libevent when adding timer event for %s",
|
"Error from libevent when adding timer event for %s",
|
||||||
debug_ntop((struct sockaddr *)&ns->address));
|
debug_ntop((struct sockaddr *)&ns->address));
|
||||||
/* ???? Do more? */
|
/* ???? Do more? */
|
||||||
@ -550,19 +550,19 @@ nameserver_failed(struct nameserver *const ns, const char *msg) {
|
|||||||
/* then don't do anything */
|
/* then don't do anything */
|
||||||
if (!ns->state) return;
|
if (!ns->state) return;
|
||||||
|
|
||||||
log(EVDNS_LOG_WARN, "Nameserver %s has failed: %s",
|
tor_log(EVDNS_LOG_WARN, "Nameserver %s has failed: %s",
|
||||||
debug_ntop((struct sockaddr *)&ns->address), msg);
|
debug_ntop((struct sockaddr *)&ns->address), msg);
|
||||||
global_good_nameservers--;
|
global_good_nameservers--;
|
||||||
assert(global_good_nameservers >= 0);
|
assert(global_good_nameservers >= 0);
|
||||||
if (global_good_nameservers == 0) {
|
if (global_good_nameservers == 0) {
|
||||||
log(EVDNS_LOG_WARN, "All nameservers have failed");
|
tor_log(EVDNS_LOG_WARN, "All nameservers have failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
ns->state = 0;
|
ns->state = 0;
|
||||||
ns->failed_times = 1;
|
ns->failed_times = 1;
|
||||||
|
|
||||||
if (add_timeout_event(ns, (struct timeval *) &global_nameserver_timeouts[0]) < 0) {
|
if (add_timeout_event(ns, (struct timeval *) &global_nameserver_timeouts[0]) < 0) {
|
||||||
log(EVDNS_LOG_WARN,
|
tor_log(EVDNS_LOG_WARN,
|
||||||
"Error from libevent when adding timer event for %s",
|
"Error from libevent when adding timer event for %s",
|
||||||
debug_ntop((struct sockaddr *)&ns->address));
|
debug_ntop((struct sockaddr *)&ns->address));
|
||||||
/* ???? Do more? */
|
/* ???? Do more? */
|
||||||
@ -593,7 +593,7 @@ nameserver_failed(struct nameserver *const ns, const char *msg) {
|
|||||||
static void
|
static void
|
||||||
nameserver_up(struct nameserver *const ns) {
|
nameserver_up(struct nameserver *const ns) {
|
||||||
if (ns->state) return;
|
if (ns->state) return;
|
||||||
log(EVDNS_LOG_WARN, "Nameserver %s is back up",
|
tor_log(EVDNS_LOG_WARN, "Nameserver %s is back up",
|
||||||
debug_ntop((struct sockaddr *)&ns->address));
|
debug_ntop((struct sockaddr *)&ns->address));
|
||||||
del_timeout_event(ns);
|
del_timeout_event(ns);
|
||||||
ns->state = 1;
|
ns->state = 1;
|
||||||
@ -624,7 +624,7 @@ request_finished(struct evdns_request *const req, struct evdns_request **head) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
log(EVDNS_LOG_DEBUG, "Removing timeout for request %lx",
|
tor_log(EVDNS_LOG_DEBUG, "Removing timeout for request %lx",
|
||||||
(unsigned long) req);
|
(unsigned long) req);
|
||||||
del_timeout_event(req);
|
del_timeout_event(req);
|
||||||
|
|
||||||
@ -776,7 +776,7 @@ reply_handle(struct evdns_request *const req, u16 flags, u32 ttl, struct reply *
|
|||||||
* confusing." Treat this as a timeout, not a failure.
|
* confusing." Treat this as a timeout, not a failure.
|
||||||
*/
|
*/
|
||||||
/*XXXX refactor the parts of */
|
/*XXXX refactor the parts of */
|
||||||
log(EVDNS_LOG_DEBUG, "Got a SERVERFAILED from nameserver %s; "
|
tor_log(EVDNS_LOG_DEBUG, "Got a SERVERFAILED from nameserver %s; "
|
||||||
"will allow the request to time out.",
|
"will allow the request to time out.",
|
||||||
debug_ntop((struct sockaddr *)&req->ns->address));
|
debug_ntop((struct sockaddr *)&req->ns->address));
|
||||||
break;
|
break;
|
||||||
@ -1268,7 +1268,7 @@ nameserver_read(struct nameserver *ns) {
|
|||||||
}
|
}
|
||||||
/* XXX Match port too? */
|
/* XXX Match port too? */
|
||||||
if (!sockaddr_eq(sa, (struct sockaddr*)&ns->address, 0)) {
|
if (!sockaddr_eq(sa, (struct sockaddr*)&ns->address, 0)) {
|
||||||
log(EVDNS_LOG_WARN,
|
tor_log(EVDNS_LOG_WARN,
|
||||||
"Address mismatch on received DNS packet. Address was %s",
|
"Address mismatch on received DNS packet. Address was %s",
|
||||||
debug_ntop(sa));
|
debug_ntop(sa));
|
||||||
return;
|
return;
|
||||||
@ -1294,7 +1294,7 @@ server_port_read(struct evdns_server_port *s) {
|
|||||||
if (r < 0) {
|
if (r < 0) {
|
||||||
int err = last_error(s->socket);
|
int err = last_error(s->socket);
|
||||||
if (error_is_eagain(err)) return;
|
if (error_is_eagain(err)) return;
|
||||||
log(EVDNS_LOG_WARN, "Error %s (%d) while reading request.",
|
tor_log(EVDNS_LOG_WARN, "Error %s (%d) while reading request.",
|
||||||
tor_socket_strerror(err), err);
|
tor_socket_strerror(err), err);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1314,7 +1314,7 @@ server_port_flush(struct evdns_server_port *port)
|
|||||||
int err = last_error(port->socket);
|
int err = last_error(port->socket);
|
||||||
if (error_is_eagain(err))
|
if (error_is_eagain(err))
|
||||||
return;
|
return;
|
||||||
log(EVDNS_LOG_WARN, "Error %s (%d) while writing response to port; dropping", tor_socket_strerror(err), err);
|
tor_log(EVDNS_LOG_WARN, "Error %s (%d) while writing response to port; dropping", tor_socket_strerror(err), err);
|
||||||
}
|
}
|
||||||
if (server_request_free(req)) {
|
if (server_request_free(req)) {
|
||||||
/* we released the last reference to req->port. */
|
/* we released the last reference to req->port. */
|
||||||
@ -1331,7 +1331,7 @@ server_port_flush(struct evdns_server_port *port)
|
|||||||
event_set(&port->event, port->socket, EV_READ | EV_PERSIST,
|
event_set(&port->event, port->socket, EV_READ | EV_PERSIST,
|
||||||
server_port_ready_callback, port);
|
server_port_ready_callback, port);
|
||||||
if (event_add(&port->event, NULL) < 0) {
|
if (event_add(&port->event, NULL) < 0) {
|
||||||
log(EVDNS_LOG_WARN, "Error from libevent when adding event for DNS server.");
|
tor_log(EVDNS_LOG_WARN, "Error from libevent when adding event for DNS server.");
|
||||||
/* ???? Do more? */
|
/* ???? Do more? */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1349,7 +1349,7 @@ nameserver_write_waiting(struct nameserver *ns, char waiting) {
|
|||||||
event_set(&ns->event, ns->socket, EV_READ | (waiting ? EV_WRITE : 0) | EV_PERSIST,
|
event_set(&ns->event, ns->socket, EV_READ | (waiting ? EV_WRITE : 0) | EV_PERSIST,
|
||||||
nameserver_ready_callback, ns);
|
nameserver_ready_callback, ns);
|
||||||
if (event_add(&ns->event, NULL) < 0) {
|
if (event_add(&ns->event, NULL) < 0) {
|
||||||
log(EVDNS_LOG_WARN, "Error from libevent when adding event for %s",
|
tor_log(EVDNS_LOG_WARN, "Error from libevent when adding event for %s",
|
||||||
debug_ntop((struct sockaddr *)&ns->address));
|
debug_ntop((struct sockaddr *)&ns->address));
|
||||||
/* ???? Do more? */
|
/* ???? Do more? */
|
||||||
}
|
}
|
||||||
@ -1859,7 +1859,7 @@ evdns_server_request_respond(struct evdns_server_request *_req, int err)
|
|||||||
event_set(&port->event, port->socket, (port->closing?0:EV_READ) | EV_WRITE | EV_PERSIST, server_port_ready_callback, port);
|
event_set(&port->event, port->socket, (port->closing?0:EV_READ) | EV_WRITE | EV_PERSIST, server_port_ready_callback, port);
|
||||||
|
|
||||||
if (event_add(&port->event, NULL) < 0) {
|
if (event_add(&port->event, NULL) < 0) {
|
||||||
log(EVDNS_LOG_WARN, "Error from libevent when adding event for DNS server");
|
tor_log(EVDNS_LOG_WARN, "Error from libevent when adding event for DNS server");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -1995,7 +1995,7 @@ evdns_request_timeout_callback(int fd, short events, void *arg) {
|
|||||||
(void) fd;
|
(void) fd;
|
||||||
(void) events;
|
(void) events;
|
||||||
|
|
||||||
log(EVDNS_LOG_DEBUG, "Request %lx timed out", (unsigned long) arg);
|
tor_log(EVDNS_LOG_DEBUG, "Request %lx timed out", (unsigned long) arg);
|
||||||
|
|
||||||
req->ns->timedout++;
|
req->ns->timedout++;
|
||||||
if (req->ns->timedout > global_max_nameserver_timeout) {
|
if (req->ns->timedout > global_max_nameserver_timeout) {
|
||||||
@ -2074,11 +2074,11 @@ evdns_request_transmit(struct evdns_request *req) {
|
|||||||
* and make us retransmit the request anyway. */
|
* and make us retransmit the request anyway. */
|
||||||
default:
|
default:
|
||||||
/* transmitted; we need to check for timeout. */
|
/* transmitted; we need to check for timeout. */
|
||||||
log(EVDNS_LOG_DEBUG,
|
tor_log(EVDNS_LOG_DEBUG,
|
||||||
"Setting timeout for request %lx", (unsigned long) req);
|
"Setting timeout for request %lx", (unsigned long) req);
|
||||||
|
|
||||||
if (add_timeout_event(req, &global_timeout) < 0) {
|
if (add_timeout_event(req, &global_timeout) < 0) {
|
||||||
log(EVDNS_LOG_WARN,
|
tor_log(EVDNS_LOG_WARN,
|
||||||
"Error from libevent when adding timer for request %lx",
|
"Error from libevent when adding timer for request %lx",
|
||||||
(unsigned long) req);
|
(unsigned long) req);
|
||||||
/* ???? Do more? */
|
/* ???? Do more? */
|
||||||
@ -2126,7 +2126,7 @@ nameserver_send_probe(struct nameserver *const ns) {
|
|||||||
addr = mm_malloc(sizeof(struct sockaddr_storage));
|
addr = mm_malloc(sizeof(struct sockaddr_storage));
|
||||||
memcpy(addr, &ns->address, sizeof(struct sockaddr_storage));
|
memcpy(addr, &ns->address, sizeof(struct sockaddr_storage));
|
||||||
|
|
||||||
log(EVDNS_LOG_DEBUG, "Sending probe to %s", debug_ntop((struct sockaddr *)&ns->address));
|
tor_log(EVDNS_LOG_DEBUG, "Sending probe to %s", debug_ntop((struct sockaddr *)&ns->address));
|
||||||
|
|
||||||
req = request_new(TYPE_A, "www.google.com", DNS_QUERY_NO_SEARCH, nameserver_probe_callback, addr);
|
req = request_new(TYPE_A, "www.google.com", DNS_QUERY_NO_SEARCH, nameserver_probe_callback, addr);
|
||||||
if (!req) {
|
if (!req) {
|
||||||
@ -2282,14 +2282,14 @@ _evdns_nameserver_add_impl(const struct sockaddr *address,
|
|||||||
if (server) {
|
if (server) {
|
||||||
do {
|
do {
|
||||||
if (sockaddr_eq(address, (struct sockaddr *)&server->address, 1)) {
|
if (sockaddr_eq(address, (struct sockaddr *)&server->address, 1)) {
|
||||||
log(EVDNS_LOG_DEBUG, "Duplicate nameserver.");
|
tor_log(EVDNS_LOG_DEBUG, "Duplicate nameserver.");
|
||||||
return 3;
|
return 3;
|
||||||
}
|
}
|
||||||
server = server->next;
|
server = server->next;
|
||||||
} while (server != started_at);
|
} while (server != started_at);
|
||||||
}
|
}
|
||||||
if (addrlen > (int)sizeof(ns->address)) {
|
if (addrlen > (int)sizeof(ns->address)) {
|
||||||
log(EVDNS_LOG_DEBUG, "Addrlen %d too long.", (int)addrlen);
|
tor_log(EVDNS_LOG_DEBUG, "Addrlen %d too long.", (int)addrlen);
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2315,14 +2315,14 @@ _evdns_nameserver_add_impl(const struct sockaddr *address,
|
|||||||
!sockaddr_is_loopback((struct sockaddr*)&global_bind_address)) {
|
!sockaddr_is_loopback((struct sockaddr*)&global_bind_address)) {
|
||||||
if (bind(ns->socket, (struct sockaddr *)&global_bind_address,
|
if (bind(ns->socket, (struct sockaddr *)&global_bind_address,
|
||||||
global_bind_addrlen) < 0) {
|
global_bind_addrlen) < 0) {
|
||||||
log(EVDNS_LOG_DEBUG, "Couldn't bind to outgoing address.");
|
tor_log(EVDNS_LOG_DEBUG, "Couldn't bind to outgoing address.");
|
||||||
err = 2;
|
err = 2;
|
||||||
goto out2;
|
goto out2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (connect(ns->socket, address, addrlen) != 0) {
|
if (connect(ns->socket, address, addrlen) != 0) {
|
||||||
log(EVDNS_LOG_DEBUG, "Couldn't open socket to nameserver.");
|
tor_log(EVDNS_LOG_DEBUG, "Couldn't open socket to nameserver.");
|
||||||
err = 2;
|
err = 2;
|
||||||
goto out2;
|
goto out2;
|
||||||
}
|
}
|
||||||
@ -2331,12 +2331,12 @@ _evdns_nameserver_add_impl(const struct sockaddr *address,
|
|||||||
ns->state = 1;
|
ns->state = 1;
|
||||||
event_set(&ns->event, ns->socket, EV_READ | EV_PERSIST, nameserver_ready_callback, ns);
|
event_set(&ns->event, ns->socket, EV_READ | EV_PERSIST, nameserver_ready_callback, ns);
|
||||||
if (event_add(&ns->event, NULL) < 0) {
|
if (event_add(&ns->event, NULL) < 0) {
|
||||||
log(EVDNS_LOG_DEBUG, "Couldn't add event for nameserver.");
|
tor_log(EVDNS_LOG_DEBUG, "Couldn't add event for nameserver.");
|
||||||
err = 2;
|
err = 2;
|
||||||
goto out2;
|
goto out2;
|
||||||
}
|
}
|
||||||
|
|
||||||
log(EVDNS_LOG_DEBUG, "Added nameserver %s", debug_ntop(address));
|
tor_log(EVDNS_LOG_DEBUG, "Added nameserver %s", debug_ntop(address));
|
||||||
|
|
||||||
/* insert this nameserver into the list of them */
|
/* insert this nameserver into the list of them */
|
||||||
if (!server_head) {
|
if (!server_head) {
|
||||||
@ -2360,7 +2360,7 @@ out2:
|
|||||||
out1:
|
out1:
|
||||||
CLEAR(ns);
|
CLEAR(ns);
|
||||||
mm_free(ns);
|
mm_free(ns);
|
||||||
log(EVDNS_LOG_WARN, "Unable to add nameserver %s: error %d", debug_ntop(address), err);
|
tor_log(EVDNS_LOG_WARN, "Unable to add nameserver %s: error %d", debug_ntop(address), err);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2393,18 +2393,18 @@ evdns_nameserver_ip_add(const char *ip_as_string) {
|
|||||||
* ipv4
|
* ipv4
|
||||||
*/
|
*/
|
||||||
|
|
||||||
log(EVDNS_LOG_DEBUG, "Trying to add nameserver <%s>", ip_as_string);
|
tor_log(EVDNS_LOG_DEBUG, "Trying to add nameserver <%s>", ip_as_string);
|
||||||
|
|
||||||
cp = strchr(ip_as_string, ':');
|
cp = strchr(ip_as_string, ':');
|
||||||
if (*ip_as_string == '[') {
|
if (*ip_as_string == '[') {
|
||||||
size_t len;
|
size_t len;
|
||||||
if (!(cp = strchr(ip_as_string, ']'))) {
|
if (!(cp = strchr(ip_as_string, ']'))) {
|
||||||
log(EVDNS_LOG_DEBUG, "Nameserver missing closing ]");
|
tor_log(EVDNS_LOG_DEBUG, "Nameserver missing closing ]");
|
||||||
return 4;
|
return 4;
|
||||||
}
|
}
|
||||||
len = cp-(ip_as_string + 1);
|
len = cp-(ip_as_string + 1);
|
||||||
if (len > sizeof(buf)-1) {
|
if (len > sizeof(buf)-1) {
|
||||||
log(EVDNS_LOG_DEBUG, "[Nameserver] does not fit in buffer.");
|
tor_log(EVDNS_LOG_DEBUG, "[Nameserver] does not fit in buffer.");
|
||||||
return 4;
|
return 4;
|
||||||
}
|
}
|
||||||
memcpy(buf, ip_as_string+1, len);
|
memcpy(buf, ip_as_string+1, len);
|
||||||
@ -2422,7 +2422,7 @@ evdns_nameserver_ip_add(const char *ip_as_string) {
|
|||||||
} else if (cp) {
|
} else if (cp) {
|
||||||
is_ipv6 = 0;
|
is_ipv6 = 0;
|
||||||
if (cp - ip_as_string > (int)sizeof(buf)-1) {
|
if (cp - ip_as_string > (int)sizeof(buf)-1) {
|
||||||
log(EVDNS_LOG_DEBUG, "Nameserver does not fit in buffer.");
|
tor_log(EVDNS_LOG_DEBUG, "Nameserver does not fit in buffer.");
|
||||||
return 4;
|
return 4;
|
||||||
}
|
}
|
||||||
memcpy(buf, ip_as_string, cp-ip_as_string);
|
memcpy(buf, ip_as_string, cp-ip_as_string);
|
||||||
@ -2440,7 +2440,7 @@ evdns_nameserver_ip_add(const char *ip_as_string) {
|
|||||||
} else {
|
} else {
|
||||||
port = strtoint(port_part);
|
port = strtoint(port_part);
|
||||||
if (port <= 0 || port > 65535) {
|
if (port <= 0 || port > 65535) {
|
||||||
log(EVDNS_LOG_DEBUG, "Nameserver port <%s> out of range",
|
tor_log(EVDNS_LOG_DEBUG, "Nameserver port <%s> out of range",
|
||||||
port_part);
|
port_part);
|
||||||
return 4;
|
return 4;
|
||||||
}
|
}
|
||||||
@ -2457,7 +2457,7 @@ evdns_nameserver_ip_add(const char *ip_as_string) {
|
|||||||
sin6.sin6_family = AF_INET6;
|
sin6.sin6_family = AF_INET6;
|
||||||
sin6.sin6_port = htons(port);
|
sin6.sin6_port = htons(port);
|
||||||
if (1 != tor_inet_pton(AF_INET6, addr_part, &sin6.sin6_addr)) {
|
if (1 != tor_inet_pton(AF_INET6, addr_part, &sin6.sin6_addr)) {
|
||||||
log(EVDNS_LOG_DEBUG, "inet_pton(%s) failed", addr_part);
|
tor_log(EVDNS_LOG_DEBUG, "inet_pton(%s) failed", addr_part);
|
||||||
return 4;
|
return 4;
|
||||||
}
|
}
|
||||||
return _evdns_nameserver_add_impl((struct sockaddr*)&sin6,
|
return _evdns_nameserver_add_impl((struct sockaddr*)&sin6,
|
||||||
@ -2471,7 +2471,7 @@ evdns_nameserver_ip_add(const char *ip_as_string) {
|
|||||||
sin.sin_family = AF_INET;
|
sin.sin_family = AF_INET;
|
||||||
sin.sin_port = htons(port);
|
sin.sin_port = htons(port);
|
||||||
if (!inet_aton(addr_part, &sin.sin_addr)) {
|
if (!inet_aton(addr_part, &sin.sin_addr)) {
|
||||||
log(EVDNS_LOG_DEBUG, "inet_pton(%s) failed", addr_part);
|
tor_log(EVDNS_LOG_DEBUG, "inet_pton(%s) failed", addr_part);
|
||||||
return 4;
|
return 4;
|
||||||
}
|
}
|
||||||
return _evdns_nameserver_add_impl((struct sockaddr*)&sin,
|
return _evdns_nameserver_add_impl((struct sockaddr*)&sin,
|
||||||
@ -2594,7 +2594,7 @@ request_submit(struct evdns_request *const req) {
|
|||||||
/* exported function */
|
/* exported function */
|
||||||
int evdns_resolve_ipv4(const char *name, int flags,
|
int evdns_resolve_ipv4(const char *name, int flags,
|
||||||
evdns_callback_type callback, void *ptr) {
|
evdns_callback_type callback, void *ptr) {
|
||||||
log(EVDNS_LOG_DEBUG, "Resolve requested for %s", name);
|
tor_log(EVDNS_LOG_DEBUG, "Resolve requested for %s", name);
|
||||||
if (flags & DNS_QUERY_NO_SEARCH) {
|
if (flags & DNS_QUERY_NO_SEARCH) {
|
||||||
struct evdns_request *const req =
|
struct evdns_request *const req =
|
||||||
request_new(TYPE_A, name, flags, callback, ptr);
|
request_new(TYPE_A, name, flags, callback, ptr);
|
||||||
@ -2610,7 +2610,7 @@ int evdns_resolve_ipv4(const char *name, int flags,
|
|||||||
/* exported function */
|
/* exported function */
|
||||||
int evdns_resolve_ipv6(const char *name, int flags,
|
int evdns_resolve_ipv6(const char *name, int flags,
|
||||||
evdns_callback_type callback, void *ptr) {
|
evdns_callback_type callback, void *ptr) {
|
||||||
log(EVDNS_LOG_DEBUG, "Resolve requested for %s", name);
|
tor_log(EVDNS_LOG_DEBUG, "Resolve requested for %s", name);
|
||||||
if (flags & DNS_QUERY_NO_SEARCH) {
|
if (flags & DNS_QUERY_NO_SEARCH) {
|
||||||
struct evdns_request *const req =
|
struct evdns_request *const req =
|
||||||
request_new(TYPE_AAAA, name, flags, callback, ptr);
|
request_new(TYPE_AAAA, name, flags, callback, ptr);
|
||||||
@ -2634,7 +2634,7 @@ int evdns_resolve_reverse(const struct in_addr *in, int flags, evdns_callback_ty
|
|||||||
(int)(u8)((a>>8 )&0xff),
|
(int)(u8)((a>>8 )&0xff),
|
||||||
(int)(u8)((a>>16)&0xff),
|
(int)(u8)((a>>16)&0xff),
|
||||||
(int)(u8)((a>>24)&0xff));
|
(int)(u8)((a>>24)&0xff));
|
||||||
log(EVDNS_LOG_DEBUG, "Resolve requested for %s (reverse)", buf);
|
tor_log(EVDNS_LOG_DEBUG, "Resolve requested for %s (reverse)", buf);
|
||||||
req = request_new(TYPE_PTR, buf, flags, callback, ptr);
|
req = request_new(TYPE_PTR, buf, flags, callback, ptr);
|
||||||
if (!req) return 1;
|
if (!req) return 1;
|
||||||
request_submit(req);
|
request_submit(req);
|
||||||
@ -2658,7 +2658,7 @@ int evdns_resolve_reverse_ipv6(const struct in6_addr *in, int flags, evdns_callb
|
|||||||
}
|
}
|
||||||
assert(cp + strlen("ip6.arpa") < buf+sizeof(buf));
|
assert(cp + strlen("ip6.arpa") < buf+sizeof(buf));
|
||||||
memcpy(cp, "ip6.arpa", strlen("ip6.arpa")+1);
|
memcpy(cp, "ip6.arpa", strlen("ip6.arpa")+1);
|
||||||
log(EVDNS_LOG_DEBUG, "Resolve requested for %s (reverse)", buf);
|
tor_log(EVDNS_LOG_DEBUG, "Resolve requested for %s (reverse)", buf);
|
||||||
req = request_new(TYPE_PTR, buf, flags, callback, ptr);
|
req = request_new(TYPE_PTR, buf, flags, callback, ptr);
|
||||||
if (!req) return 1;
|
if (!req) return 1;
|
||||||
request_submit(req);
|
request_submit(req);
|
||||||
@ -2874,7 +2874,7 @@ search_try_next(struct evdns_request *const req) {
|
|||||||
if (string_num_dots(req->search_origname) < req->search_state->ndots) {
|
if (string_num_dots(req->search_origname) < req->search_state->ndots) {
|
||||||
/* yep, we need to try it raw */
|
/* yep, we need to try it raw */
|
||||||
struct evdns_request *const newreq = request_new(req->request_type, req->search_origname, req->search_flags, req->user_callback, req->user_pointer);
|
struct evdns_request *const newreq = request_new(req->request_type, req->search_origname, req->search_flags, req->user_callback, req->user_pointer);
|
||||||
log(EVDNS_LOG_DEBUG, "Search: trying raw query %s", req->search_origname);
|
tor_log(EVDNS_LOG_DEBUG, "Search: trying raw query %s", req->search_origname);
|
||||||
if (newreq) {
|
if (newreq) {
|
||||||
request_submit(newreq);
|
request_submit(newreq);
|
||||||
return 0;
|
return 0;
|
||||||
@ -2885,7 +2885,7 @@ search_try_next(struct evdns_request *const req) {
|
|||||||
|
|
||||||
new_name = search_make_new(req->search_state, req->search_index, req->search_origname);
|
new_name = search_make_new(req->search_state, req->search_index, req->search_origname);
|
||||||
if (!new_name) return 1;
|
if (!new_name) return 1;
|
||||||
log(EVDNS_LOG_DEBUG, "Search: now trying %s (%d)", new_name, req->search_index);
|
tor_log(EVDNS_LOG_DEBUG, "Search: now trying %s (%d)", new_name, req->search_index);
|
||||||
newreq = request_new(req->request_type, new_name, req->search_flags, req->user_callback, req->user_pointer);
|
newreq = request_new(req->request_type, new_name, req->search_flags, req->user_callback, req->user_pointer);
|
||||||
mm_free(new_name);
|
mm_free(new_name);
|
||||||
if (!newreq) return 1;
|
if (!newreq) return 1;
|
||||||
@ -2955,7 +2955,7 @@ evdns_set_option(const char *option, const char *val, int flags)
|
|||||||
const int ndots = strtoint(val);
|
const int ndots = strtoint(val);
|
||||||
if (ndots == -1) return -1;
|
if (ndots == -1) return -1;
|
||||||
if (!(flags & DNS_OPTION_SEARCH)) return 0;
|
if (!(flags & DNS_OPTION_SEARCH)) return 0;
|
||||||
log(EVDNS_LOG_DEBUG, "Setting ndots to %d", ndots);
|
tor_log(EVDNS_LOG_DEBUG, "Setting ndots to %d", ndots);
|
||||||
if (!global_search_state) global_search_state = search_state_new();
|
if (!global_search_state) global_search_state = search_state_new();
|
||||||
if (!global_search_state) return -1;
|
if (!global_search_state) return -1;
|
||||||
global_search_state->ndots = ndots;
|
global_search_state->ndots = ndots;
|
||||||
@ -2963,20 +2963,20 @@ evdns_set_option(const char *option, const char *val, int flags)
|
|||||||
const int timeout = strtoint(val);
|
const int timeout = strtoint(val);
|
||||||
if (timeout == -1) return -1;
|
if (timeout == -1) return -1;
|
||||||
if (!(flags & DNS_OPTION_MISC)) return 0;
|
if (!(flags & DNS_OPTION_MISC)) return 0;
|
||||||
log(EVDNS_LOG_DEBUG, "Setting timeout to %d", timeout);
|
tor_log(EVDNS_LOG_DEBUG, "Setting timeout to %d", timeout);
|
||||||
global_timeout.tv_sec = timeout;
|
global_timeout.tv_sec = timeout;
|
||||||
} else if (!strncmp(option, "max-timeouts:", 12)) {
|
} else if (!strncmp(option, "max-timeouts:", 12)) {
|
||||||
const int maxtimeout = strtoint_clipped(val, 1, 255);
|
const int maxtimeout = strtoint_clipped(val, 1, 255);
|
||||||
if (maxtimeout == -1) return -1;
|
if (maxtimeout == -1) return -1;
|
||||||
if (!(flags & DNS_OPTION_MISC)) return 0;
|
if (!(flags & DNS_OPTION_MISC)) return 0;
|
||||||
log(EVDNS_LOG_DEBUG, "Setting maximum allowed timeouts to %d",
|
tor_log(EVDNS_LOG_DEBUG, "Setting maximum allowed timeouts to %d",
|
||||||
maxtimeout);
|
maxtimeout);
|
||||||
global_max_nameserver_timeout = maxtimeout;
|
global_max_nameserver_timeout = maxtimeout;
|
||||||
} else if (!strncmp(option, "max-inflight:", 13)) {
|
} else if (!strncmp(option, "max-inflight:", 13)) {
|
||||||
const int maxinflight = strtoint_clipped(val, 1, 65000);
|
const int maxinflight = strtoint_clipped(val, 1, 65000);
|
||||||
if (maxinflight == -1) return -1;
|
if (maxinflight == -1) return -1;
|
||||||
if (!(flags & DNS_OPTION_MISC)) return 0;
|
if (!(flags & DNS_OPTION_MISC)) return 0;
|
||||||
log(EVDNS_LOG_DEBUG, "Setting maximum inflight requests to %d",
|
tor_log(EVDNS_LOG_DEBUG, "Setting maximum inflight requests to %d",
|
||||||
maxinflight);
|
maxinflight);
|
||||||
global_max_requests_inflight = maxinflight;
|
global_max_requests_inflight = maxinflight;
|
||||||
} else if (!strncmp(option, "attempts:", 9)) {
|
} else if (!strncmp(option, "attempts:", 9)) {
|
||||||
@ -2984,12 +2984,12 @@ evdns_set_option(const char *option, const char *val, int flags)
|
|||||||
if (retries == -1) return -1;
|
if (retries == -1) return -1;
|
||||||
if (retries > 255) retries = 255;
|
if (retries > 255) retries = 255;
|
||||||
if (!(flags & DNS_OPTION_MISC)) return 0;
|
if (!(flags & DNS_OPTION_MISC)) return 0;
|
||||||
log(EVDNS_LOG_DEBUG, "Setting retries to %d", retries);
|
tor_log(EVDNS_LOG_DEBUG, "Setting retries to %d", retries);
|
||||||
global_max_retransmits = retries;
|
global_max_retransmits = retries;
|
||||||
} else if (!strncmp(option, "randomize-case:", 15)) {
|
} else if (!strncmp(option, "randomize-case:", 15)) {
|
||||||
int randcase = strtoint(val);
|
int randcase = strtoint(val);
|
||||||
if (!(flags & DNS_OPTION_MISC)) return 0;
|
if (!(flags & DNS_OPTION_MISC)) return 0;
|
||||||
log(EVDNS_LOG_DEBUG, "Setting randomize_case to %d", randcase);
|
tor_log(EVDNS_LOG_DEBUG, "Setting randomize_case to %d", randcase);
|
||||||
global_randomize_case = randcase;
|
global_randomize_case = randcase;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
@ -3047,7 +3047,7 @@ evdns_resolv_conf_parse(int flags, const char *const filename) {
|
|||||||
char *start;
|
char *start;
|
||||||
int err = 0;
|
int err = 0;
|
||||||
|
|
||||||
log(EVDNS_LOG_DEBUG, "Parsing resolv.conf file %s", filename);
|
tor_log(EVDNS_LOG_DEBUG, "Parsing resolv.conf file %s", filename);
|
||||||
|
|
||||||
fd = tor_open_cloexec(filename, O_RDONLY, 0);
|
fd = tor_open_cloexec(filename, O_RDONLY, 0);
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
@ -3146,13 +3146,13 @@ load_nameservers_with_getnetworkparams(void)
|
|||||||
GetNetworkParams_fn_t fn;
|
GetNetworkParams_fn_t fn;
|
||||||
|
|
||||||
if (!(handle = load_windows_system_library(TEXT("iphlpapi.dll")))) {
|
if (!(handle = load_windows_system_library(TEXT("iphlpapi.dll")))) {
|
||||||
log(EVDNS_LOG_WARN, "Could not open iphlpapi.dll");
|
tor_log(EVDNS_LOG_WARN, "Could not open iphlpapi.dll");
|
||||||
/* right now status = 0, doesn't that mean "good" - mikec */
|
/* right now status = 0, doesn't that mean "good" - mikec */
|
||||||
status = -1;
|
status = -1;
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
if (!(fn = (GetNetworkParams_fn_t) GetProcAddress(handle, TEXT("GetNetworkParams")))) {
|
if (!(fn = (GetNetworkParams_fn_t) GetProcAddress(handle, TEXT("GetNetworkParams")))) {
|
||||||
log(EVDNS_LOG_WARN, "Could not get address of function.");
|
tor_log(EVDNS_LOG_WARN, "Could not get address of function.");
|
||||||
/* same as above */
|
/* same as above */
|
||||||
status = -1;
|
status = -1;
|
||||||
goto done;
|
goto done;
|
||||||
@ -3173,7 +3173,7 @@ load_nameservers_with_getnetworkparams(void)
|
|||||||
fixed = buf;
|
fixed = buf;
|
||||||
r = fn(fixed, &size);
|
r = fn(fixed, &size);
|
||||||
if (r != ERROR_SUCCESS) {
|
if (r != ERROR_SUCCESS) {
|
||||||
log(EVDNS_LOG_DEBUG, "fn() failed.");
|
tor_log(EVDNS_LOG_DEBUG, "fn() failed.");
|
||||||
status = -1;
|
status = -1;
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
@ -3185,12 +3185,12 @@ load_nameservers_with_getnetworkparams(void)
|
|||||||
while (ns) {
|
while (ns) {
|
||||||
r = evdns_nameserver_ip_add_line(ns->IpAddress.String);
|
r = evdns_nameserver_ip_add_line(ns->IpAddress.String);
|
||||||
if (r) {
|
if (r) {
|
||||||
log(EVDNS_LOG_DEBUG,"Could not add nameserver %s to list, "
|
tor_log(EVDNS_LOG_DEBUG,"Could not add nameserver %s to list, "
|
||||||
"error: %d; status: %d",
|
"error: %d; status: %d",
|
||||||
(ns->IpAddress.String),(int)GetLastError(), r);
|
(ns->IpAddress.String),(int)GetLastError(), r);
|
||||||
status = r;
|
status = r;
|
||||||
} else {
|
} else {
|
||||||
log(EVDNS_LOG_DEBUG,"Successfully added %s as nameserver",ns->IpAddress.String);
|
tor_log(EVDNS_LOG_DEBUG,"Successfully added %s as nameserver",ns->IpAddress.String);
|
||||||
added_any++;
|
added_any++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3198,7 +3198,7 @@ load_nameservers_with_getnetworkparams(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!added_any) {
|
if (!added_any) {
|
||||||
log(EVDNS_LOG_DEBUG, "No nameservers added.");
|
tor_log(EVDNS_LOG_DEBUG, "No nameservers added.");
|
||||||
if (status == 0)
|
if (status == 0)
|
||||||
status = -1;
|
status = -1;
|
||||||
} else {
|
} else {
|
||||||
@ -3254,10 +3254,10 @@ load_nameservers_from_registry(void)
|
|||||||
|
|
||||||
#define TRY(k, name) \
|
#define TRY(k, name) \
|
||||||
if (!found && config_nameserver_from_reg_key(k,TEXT(name)) == 0) { \
|
if (!found && config_nameserver_from_reg_key(k,TEXT(name)) == 0) { \
|
||||||
log(EVDNS_LOG_DEBUG,"Found nameservers in %s/%s",#k,name); \
|
tor_log(EVDNS_LOG_DEBUG,"Found nameservers in %s/%s",#k,name); \
|
||||||
found = 1; \
|
found = 1; \
|
||||||
} else if (!found) { \
|
} else if (!found) { \
|
||||||
log(EVDNS_LOG_DEBUG,"Didn't find nameservers in %s/%s", \
|
tor_log(EVDNS_LOG_DEBUG,"Didn't find nameservers in %s/%s", \
|
||||||
#k,#name); \
|
#k,#name); \
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3266,14 +3266,14 @@ load_nameservers_from_registry(void)
|
|||||||
|
|
||||||
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, WIN_NS_NT_KEY, 0,
|
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, WIN_NS_NT_KEY, 0,
|
||||||
KEY_READ, &nt_key) != ERROR_SUCCESS) {
|
KEY_READ, &nt_key) != ERROR_SUCCESS) {
|
||||||
log(EVDNS_LOG_DEBUG,"Couldn't open nt key, %d",(int)GetLastError());
|
tor_log(EVDNS_LOG_DEBUG,"Couldn't open nt key, %d",(int)GetLastError());
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
r = RegOpenKeyEx(nt_key, TEXT("Interfaces"), 0,
|
r = RegOpenKeyEx(nt_key, TEXT("Interfaces"), 0,
|
||||||
KEY_QUERY_VALUE|KEY_ENUMERATE_SUB_KEYS,
|
KEY_QUERY_VALUE|KEY_ENUMERATE_SUB_KEYS,
|
||||||
&interfaces_key);
|
&interfaces_key);
|
||||||
if (r != ERROR_SUCCESS) {
|
if (r != ERROR_SUCCESS) {
|
||||||
log(EVDNS_LOG_DEBUG,"Couldn't open interfaces key, %d",(int)GetLastError());
|
tor_log(EVDNS_LOG_DEBUG,"Couldn't open interfaces key, %d",(int)GetLastError());
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
TRY(nt_key, "NameServer");
|
TRY(nt_key, "NameServer");
|
||||||
@ -3286,7 +3286,7 @@ load_nameservers_from_registry(void)
|
|||||||
HKEY win_key = 0;
|
HKEY win_key = 0;
|
||||||
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, WIN_NS_9X_KEY, 0,
|
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, WIN_NS_9X_KEY, 0,
|
||||||
KEY_READ, &win_key) != ERROR_SUCCESS) {
|
KEY_READ, &win_key) != ERROR_SUCCESS) {
|
||||||
log(EVDNS_LOG_DEBUG, "Couldn't open registry key, %d", (int)GetLastError());
|
tor_log(EVDNS_LOG_DEBUG, "Couldn't open registry key, %d", (int)GetLastError());
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
TRY(win_key, "NameServer");
|
TRY(win_key, "NameServer");
|
||||||
@ -3294,7 +3294,7 @@ load_nameservers_from_registry(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (found == 0) {
|
if (found == 0) {
|
||||||
log(EVDNS_LOG_WARN,"Didn't find any nameservers.");
|
tor_log(EVDNS_LOG_WARN,"Didn't find any nameservers.");
|
||||||
}
|
}
|
||||||
|
|
||||||
return found ? 0 : -1;
|
return found ? 0 : -1;
|
||||||
|
@ -335,11 +335,11 @@ buf_dump_freelist_sizes(int severity)
|
|||||||
{
|
{
|
||||||
#ifdef ENABLE_BUF_FREELISTS
|
#ifdef ENABLE_BUF_FREELISTS
|
||||||
int i;
|
int i;
|
||||||
log(severity, LD_MM, "====== Buffer freelists:");
|
tor_log(severity, LD_MM, "====== Buffer freelists:");
|
||||||
for (i = 0; freelists[i].alloc_size; ++i) {
|
for (i = 0; freelists[i].alloc_size; ++i) {
|
||||||
uint64_t total = ((uint64_t)freelists[i].cur_length) *
|
uint64_t total = ((uint64_t)freelists[i].cur_length) *
|
||||||
freelists[i].alloc_size;
|
freelists[i].alloc_size;
|
||||||
log(severity, LD_MM,
|
tor_log(severity, LD_MM,
|
||||||
U64_FORMAT" bytes in %d %d-byte chunks ["U64_FORMAT
|
U64_FORMAT" bytes in %d %d-byte chunks ["U64_FORMAT
|
||||||
" misses; "U64_FORMAT" frees; "U64_FORMAT" hits]",
|
" misses; "U64_FORMAT" frees; "U64_FORMAT" hits]",
|
||||||
U64_PRINTF_ARG(total),
|
U64_PRINTF_ARG(total),
|
||||||
@ -348,7 +348,7 @@ buf_dump_freelist_sizes(int severity)
|
|||||||
U64_PRINTF_ARG(freelists[i].n_free),
|
U64_PRINTF_ARG(freelists[i].n_free),
|
||||||
U64_PRINTF_ARG(freelists[i].n_hit));
|
U64_PRINTF_ARG(freelists[i].n_hit));
|
||||||
}
|
}
|
||||||
log(severity, LD_MM, U64_FORMAT" allocations in non-freelist sizes",
|
tor_log(severity, LD_MM, U64_FORMAT" allocations in non-freelist sizes",
|
||||||
U64_PRINTF_ARG(n_freelist_miss));
|
U64_PRINTF_ARG(n_freelist_miss));
|
||||||
#else
|
#else
|
||||||
(void)severity;
|
(void)severity;
|
||||||
|
@ -2636,10 +2636,10 @@ void
|
|||||||
channel_dumpstats(int severity)
|
channel_dumpstats(int severity)
|
||||||
{
|
{
|
||||||
if (all_channels && smartlist_len(all_channels) > 0) {
|
if (all_channels && smartlist_len(all_channels) > 0) {
|
||||||
log(severity, LD_GENERAL,
|
tor_log(severity, LD_GENERAL,
|
||||||
"Dumping statistics about %d channels:",
|
"Dumping statistics about %d channels:",
|
||||||
smartlist_len(all_channels));
|
smartlist_len(all_channels));
|
||||||
log(severity, LD_GENERAL,
|
tor_log(severity, LD_GENERAL,
|
||||||
"%d are active, and %d are done and waiting for cleanup",
|
"%d are active, and %d are done and waiting for cleanup",
|
||||||
(active_channels != NULL) ?
|
(active_channels != NULL) ?
|
||||||
smartlist_len(active_channels) : 0,
|
smartlist_len(active_channels) : 0,
|
||||||
@ -2649,10 +2649,10 @@ channel_dumpstats(int severity)
|
|||||||
SMARTLIST_FOREACH(all_channels, channel_t *, chan,
|
SMARTLIST_FOREACH(all_channels, channel_t *, chan,
|
||||||
channel_dump_statistics(chan, severity));
|
channel_dump_statistics(chan, severity));
|
||||||
|
|
||||||
log(severity, LD_GENERAL,
|
tor_log(severity, LD_GENERAL,
|
||||||
"Done spamming about channels now");
|
"Done spamming about channels now");
|
||||||
} else {
|
} else {
|
||||||
log(severity, LD_GENERAL,
|
tor_log(severity, LD_GENERAL,
|
||||||
"No channels to dump");
|
"No channels to dump");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2668,10 +2668,10 @@ void
|
|||||||
channel_listener_dumpstats(int severity)
|
channel_listener_dumpstats(int severity)
|
||||||
{
|
{
|
||||||
if (all_listeners && smartlist_len(all_listeners) > 0) {
|
if (all_listeners && smartlist_len(all_listeners) > 0) {
|
||||||
log(severity, LD_GENERAL,
|
tor_log(severity, LD_GENERAL,
|
||||||
"Dumping statistics about %d channel listeners:",
|
"Dumping statistics about %d channel listeners:",
|
||||||
smartlist_len(all_listeners));
|
smartlist_len(all_listeners));
|
||||||
log(severity, LD_GENERAL,
|
tor_log(severity, LD_GENERAL,
|
||||||
"%d are active and %d are done and waiting for cleanup",
|
"%d are active and %d are done and waiting for cleanup",
|
||||||
(active_listeners != NULL) ?
|
(active_listeners != NULL) ?
|
||||||
smartlist_len(active_listeners) : 0,
|
smartlist_len(active_listeners) : 0,
|
||||||
@ -2681,10 +2681,10 @@ channel_listener_dumpstats(int severity)
|
|||||||
SMARTLIST_FOREACH(all_listeners, channel_listener_t *, chan_l,
|
SMARTLIST_FOREACH(all_listeners, channel_listener_t *, chan_l,
|
||||||
channel_listener_dump_statistics(chan_l, severity));
|
channel_listener_dump_statistics(chan_l, severity));
|
||||||
|
|
||||||
log(severity, LD_GENERAL,
|
tor_log(severity, LD_GENERAL,
|
||||||
"Done spamming about channel listeners now");
|
"Done spamming about channel listeners now");
|
||||||
} else {
|
} else {
|
||||||
log(severity, LD_GENERAL,
|
tor_log(severity, LD_GENERAL,
|
||||||
"No channel listeners to dump");
|
"No channel listeners to dump");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3139,13 +3139,13 @@ channel_dump_statistics(channel_t *chan, int severity)
|
|||||||
|
|
||||||
age = (double)(now - chan->timestamp_created);
|
age = (double)(now - chan->timestamp_created);
|
||||||
|
|
||||||
log(severity, LD_GENERAL,
|
tor_log(severity, LD_GENERAL,
|
||||||
"Channel " U64_FORMAT " (at %p) with transport %s is in state "
|
"Channel " U64_FORMAT " (at %p) with transport %s is in state "
|
||||||
"%s (%d)",
|
"%s (%d)",
|
||||||
U64_PRINTF_ARG(chan->global_identifier), chan,
|
U64_PRINTF_ARG(chan->global_identifier), chan,
|
||||||
channel_describe_transport(chan),
|
channel_describe_transport(chan),
|
||||||
channel_state_to_string(chan->state), chan->state);
|
channel_state_to_string(chan->state), chan->state);
|
||||||
log(severity, LD_GENERAL,
|
tor_log(severity, LD_GENERAL,
|
||||||
" * Channel " U64_FORMAT " was created at " U64_FORMAT
|
" * Channel " U64_FORMAT " was created at " U64_FORMAT
|
||||||
" (" U64_FORMAT " seconds ago) "
|
" (" U64_FORMAT " seconds ago) "
|
||||||
"and last active at " U64_FORMAT " (" U64_FORMAT " seconds ago)",
|
"and last active at " U64_FORMAT " (" U64_FORMAT " seconds ago)",
|
||||||
@ -3158,14 +3158,14 @@ channel_dump_statistics(channel_t *chan, int severity)
|
|||||||
/* Handle digest and nickname */
|
/* Handle digest and nickname */
|
||||||
if (!tor_digest_is_zero(chan->identity_digest)) {
|
if (!tor_digest_is_zero(chan->identity_digest)) {
|
||||||
if (chan->nickname) {
|
if (chan->nickname) {
|
||||||
log(severity, LD_GENERAL,
|
tor_log(severity, LD_GENERAL,
|
||||||
" * Channel " U64_FORMAT " says it is connected "
|
" * Channel " U64_FORMAT " says it is connected "
|
||||||
"to an OR with digest %s and nickname %s",
|
"to an OR with digest %s and nickname %s",
|
||||||
U64_PRINTF_ARG(chan->global_identifier),
|
U64_PRINTF_ARG(chan->global_identifier),
|
||||||
hex_str(chan->identity_digest, DIGEST_LEN),
|
hex_str(chan->identity_digest, DIGEST_LEN),
|
||||||
chan->nickname);
|
chan->nickname);
|
||||||
} else {
|
} else {
|
||||||
log(severity, LD_GENERAL,
|
tor_log(severity, LD_GENERAL,
|
||||||
" * Channel " U64_FORMAT " says it is connected "
|
" * Channel " U64_FORMAT " says it is connected "
|
||||||
"to an OR with digest %s and no known nickname",
|
"to an OR with digest %s and no known nickname",
|
||||||
U64_PRINTF_ARG(chan->global_identifier),
|
U64_PRINTF_ARG(chan->global_identifier),
|
||||||
@ -3173,13 +3173,13 @@ channel_dump_statistics(channel_t *chan, int severity)
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (chan->nickname) {
|
if (chan->nickname) {
|
||||||
log(severity, LD_GENERAL,
|
tor_log(severity, LD_GENERAL,
|
||||||
" * Channel " U64_FORMAT " does not know the digest"
|
" * Channel " U64_FORMAT " does not know the digest"
|
||||||
" of the OR it is connected to, but reports its nickname is %s",
|
" of the OR it is connected to, but reports its nickname is %s",
|
||||||
U64_PRINTF_ARG(chan->global_identifier),
|
U64_PRINTF_ARG(chan->global_identifier),
|
||||||
chan->nickname);
|
chan->nickname);
|
||||||
} else {
|
} else {
|
||||||
log(severity, LD_GENERAL,
|
tor_log(severity, LD_GENERAL,
|
||||||
" * Channel " U64_FORMAT " does not know the digest"
|
" * Channel " U64_FORMAT " does not know the digest"
|
||||||
" or the nickname of the OR it is connected to",
|
" or the nickname of the OR it is connected to",
|
||||||
U64_PRINTF_ARG(chan->global_identifier));
|
U64_PRINTF_ARG(chan->global_identifier));
|
||||||
@ -3191,7 +3191,7 @@ channel_dump_statistics(channel_t *chan, int severity)
|
|||||||
if (have_remote_addr) {
|
if (have_remote_addr) {
|
||||||
char *actual = tor_strdup(channel_get_actual_remote_descr(chan));
|
char *actual = tor_strdup(channel_get_actual_remote_descr(chan));
|
||||||
remote_addr_str = tor_dup_addr(&remote_addr);
|
remote_addr_str = tor_dup_addr(&remote_addr);
|
||||||
log(severity, LD_GENERAL,
|
tor_log(severity, LD_GENERAL,
|
||||||
" * Channel " U64_FORMAT " says its remote address"
|
" * Channel " U64_FORMAT " says its remote address"
|
||||||
" is %s, and gives a canonical description of \"%s\" and an "
|
" is %s, and gives a canonical description of \"%s\" and an "
|
||||||
"actual description of \"%s\"",
|
"actual description of \"%s\"",
|
||||||
@ -3203,7 +3203,7 @@ channel_dump_statistics(channel_t *chan, int severity)
|
|||||||
tor_free(actual);
|
tor_free(actual);
|
||||||
} else {
|
} else {
|
||||||
char *actual = tor_strdup(channel_get_actual_remote_descr(chan));
|
char *actual = tor_strdup(channel_get_actual_remote_descr(chan));
|
||||||
log(severity, LD_GENERAL,
|
tor_log(severity, LD_GENERAL,
|
||||||
" * Channel " U64_FORMAT " does not know its remote "
|
" * Channel " U64_FORMAT " does not know its remote "
|
||||||
"address, but gives a canonical description of \"%s\" and an "
|
"address, but gives a canonical description of \"%s\" and an "
|
||||||
"actual description of \"%s\"",
|
"actual description of \"%s\"",
|
||||||
@ -3214,7 +3214,7 @@ channel_dump_statistics(channel_t *chan, int severity)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Handle marks */
|
/* Handle marks */
|
||||||
log(severity, LD_GENERAL,
|
tor_log(severity, LD_GENERAL,
|
||||||
" * Channel " U64_FORMAT " has these marks: %s %s %s "
|
" * Channel " U64_FORMAT " has these marks: %s %s %s "
|
||||||
"%s %s %s",
|
"%s %s %s",
|
||||||
U64_PRINTF_ARG(chan->global_identifier),
|
U64_PRINTF_ARG(chan->global_identifier),
|
||||||
@ -3233,7 +3233,7 @@ channel_dump_statistics(channel_t *chan, int severity)
|
|||||||
"incoming" : "outgoing");
|
"incoming" : "outgoing");
|
||||||
|
|
||||||
/* Describe queues */
|
/* Describe queues */
|
||||||
log(severity, LD_GENERAL,
|
tor_log(severity, LD_GENERAL,
|
||||||
" * Channel " U64_FORMAT " has %d queued incoming cells"
|
" * Channel " U64_FORMAT " has %d queued incoming cells"
|
||||||
" and %d queued outgoing cells",
|
" and %d queued outgoing cells",
|
||||||
U64_PRINTF_ARG(chan->global_identifier),
|
U64_PRINTF_ARG(chan->global_identifier),
|
||||||
@ -3241,7 +3241,7 @@ channel_dump_statistics(channel_t *chan, int severity)
|
|||||||
chan_cell_queue_len(&chan->outgoing_queue));
|
chan_cell_queue_len(&chan->outgoing_queue));
|
||||||
|
|
||||||
/* Describe circuits */
|
/* Describe circuits */
|
||||||
log(severity, LD_GENERAL,
|
tor_log(severity, LD_GENERAL,
|
||||||
" * Channel " U64_FORMAT " has %d active circuits out of"
|
" * Channel " U64_FORMAT " has %d active circuits out of"
|
||||||
" %d in total",
|
" %d in total",
|
||||||
U64_PRINTF_ARG(chan->global_identifier),
|
U64_PRINTF_ARG(chan->global_identifier),
|
||||||
@ -3251,25 +3251,25 @@ channel_dump_statistics(channel_t *chan, int severity)
|
|||||||
circuitmux_num_circuits(chan->cmux) : 0);
|
circuitmux_num_circuits(chan->cmux) : 0);
|
||||||
|
|
||||||
/* Describe timestamps */
|
/* Describe timestamps */
|
||||||
log(severity, LD_GENERAL,
|
tor_log(severity, LD_GENERAL,
|
||||||
" * Channel " U64_FORMAT " was last used by a "
|
" * Channel " U64_FORMAT " was last used by a "
|
||||||
"client at " U64_FORMAT " (" U64_FORMAT " seconds ago)",
|
"client at " U64_FORMAT " (" U64_FORMAT " seconds ago)",
|
||||||
U64_PRINTF_ARG(chan->global_identifier),
|
U64_PRINTF_ARG(chan->global_identifier),
|
||||||
U64_PRINTF_ARG(chan->timestamp_client),
|
U64_PRINTF_ARG(chan->timestamp_client),
|
||||||
U64_PRINTF_ARG(now - chan->timestamp_client));
|
U64_PRINTF_ARG(now - chan->timestamp_client));
|
||||||
log(severity, LD_GENERAL,
|
tor_log(severity, LD_GENERAL,
|
||||||
" * Channel " U64_FORMAT " was last drained at "
|
" * Channel " U64_FORMAT " was last drained at "
|
||||||
U64_FORMAT " (" U64_FORMAT " seconds ago)",
|
U64_FORMAT " (" U64_FORMAT " seconds ago)",
|
||||||
U64_PRINTF_ARG(chan->global_identifier),
|
U64_PRINTF_ARG(chan->global_identifier),
|
||||||
U64_PRINTF_ARG(chan->timestamp_drained),
|
U64_PRINTF_ARG(chan->timestamp_drained),
|
||||||
U64_PRINTF_ARG(now - chan->timestamp_drained));
|
U64_PRINTF_ARG(now - chan->timestamp_drained));
|
||||||
log(severity, LD_GENERAL,
|
tor_log(severity, LD_GENERAL,
|
||||||
" * Channel " U64_FORMAT " last received a cell "
|
" * Channel " U64_FORMAT " last received a cell "
|
||||||
"at " U64_FORMAT " (" U64_FORMAT " seconds ago)",
|
"at " U64_FORMAT " (" U64_FORMAT " seconds ago)",
|
||||||
U64_PRINTF_ARG(chan->global_identifier),
|
U64_PRINTF_ARG(chan->global_identifier),
|
||||||
U64_PRINTF_ARG(chan->timestamp_recv),
|
U64_PRINTF_ARG(chan->timestamp_recv),
|
||||||
U64_PRINTF_ARG(now - chan->timestamp_recv));
|
U64_PRINTF_ARG(now - chan->timestamp_recv));
|
||||||
log(severity, LD_GENERAL,
|
tor_log(severity, LD_GENERAL,
|
||||||
" * Channel " U64_FORMAT " last trasmitted a cell "
|
" * Channel " U64_FORMAT " last trasmitted a cell "
|
||||||
"at " U64_FORMAT " (" U64_FORMAT " seconds ago)",
|
"at " U64_FORMAT " (" U64_FORMAT " seconds ago)",
|
||||||
U64_PRINTF_ARG(chan->global_identifier),
|
U64_PRINTF_ARG(chan->global_identifier),
|
||||||
@ -3277,7 +3277,7 @@ channel_dump_statistics(channel_t *chan, int severity)
|
|||||||
U64_PRINTF_ARG(now - chan->timestamp_xmit));
|
U64_PRINTF_ARG(now - chan->timestamp_xmit));
|
||||||
|
|
||||||
/* Describe counters and rates */
|
/* Describe counters and rates */
|
||||||
log(severity, LD_GENERAL,
|
tor_log(severity, LD_GENERAL,
|
||||||
" * Channel " U64_FORMAT " has received "
|
" * Channel " U64_FORMAT " has received "
|
||||||
U64_FORMAT " cells and transmitted " U64_FORMAT,
|
U64_FORMAT " cells and transmitted " U64_FORMAT,
|
||||||
U64_PRINTF_ARG(chan->global_identifier),
|
U64_PRINTF_ARG(chan->global_identifier),
|
||||||
@ -3288,13 +3288,13 @@ channel_dump_statistics(channel_t *chan, int severity)
|
|||||||
if (chan->n_cells_recved > 0) {
|
if (chan->n_cells_recved > 0) {
|
||||||
avg = (double)(chan->n_cells_recved) / age;
|
avg = (double)(chan->n_cells_recved) / age;
|
||||||
if (avg >= 1.0) {
|
if (avg >= 1.0) {
|
||||||
log(severity, LD_GENERAL,
|
tor_log(severity, LD_GENERAL,
|
||||||
" * Channel " U64_FORMAT " has averaged %f "
|
" * Channel " U64_FORMAT " has averaged %f "
|
||||||
"cells received per second",
|
"cells received per second",
|
||||||
U64_PRINTF_ARG(chan->global_identifier), avg);
|
U64_PRINTF_ARG(chan->global_identifier), avg);
|
||||||
} else if (avg >= 0.0) {
|
} else if (avg >= 0.0) {
|
||||||
interval = 1.0 / avg;
|
interval = 1.0 / avg;
|
||||||
log(severity, LD_GENERAL,
|
tor_log(severity, LD_GENERAL,
|
||||||
" * Channel " U64_FORMAT " has averaged %f "
|
" * Channel " U64_FORMAT " has averaged %f "
|
||||||
"seconds between received cells",
|
"seconds between received cells",
|
||||||
U64_PRINTF_ARG(chan->global_identifier), interval);
|
U64_PRINTF_ARG(chan->global_identifier), interval);
|
||||||
@ -3303,13 +3303,13 @@ channel_dump_statistics(channel_t *chan, int severity)
|
|||||||
if (chan->n_cells_xmitted > 0) {
|
if (chan->n_cells_xmitted > 0) {
|
||||||
avg = (double)(chan->n_cells_xmitted) / age;
|
avg = (double)(chan->n_cells_xmitted) / age;
|
||||||
if (avg >= 1.0) {
|
if (avg >= 1.0) {
|
||||||
log(severity, LD_GENERAL,
|
tor_log(severity, LD_GENERAL,
|
||||||
" * Channel " U64_FORMAT " has averaged %f "
|
" * Channel " U64_FORMAT " has averaged %f "
|
||||||
"cells transmitted per second",
|
"cells transmitted per second",
|
||||||
U64_PRINTF_ARG(chan->global_identifier), avg);
|
U64_PRINTF_ARG(chan->global_identifier), avg);
|
||||||
} else if (avg >= 0.0) {
|
} else if (avg >= 0.0) {
|
||||||
interval = 1.0 / avg;
|
interval = 1.0 / avg;
|
||||||
log(severity, LD_GENERAL,
|
tor_log(severity, LD_GENERAL,
|
||||||
" * Channel " U64_FORMAT " has averaged %f "
|
" * Channel " U64_FORMAT " has averaged %f "
|
||||||
"seconds between transmitted cells",
|
"seconds between transmitted cells",
|
||||||
U64_PRINTF_ARG(chan->global_identifier), interval);
|
U64_PRINTF_ARG(chan->global_identifier), interval);
|
||||||
@ -3337,13 +3337,13 @@ channel_listener_dump_statistics(channel_listener_t *chan_l, int severity)
|
|||||||
|
|
||||||
age = (double)(now - chan_l->timestamp_created);
|
age = (double)(now - chan_l->timestamp_created);
|
||||||
|
|
||||||
log(severity, LD_GENERAL,
|
tor_log(severity, LD_GENERAL,
|
||||||
"Channel listener " U64_FORMAT " (at %p) with transport %s is in "
|
"Channel listener " U64_FORMAT " (at %p) with transport %s is in "
|
||||||
"state %s (%d)",
|
"state %s (%d)",
|
||||||
U64_PRINTF_ARG(chan_l->global_identifier), chan_l,
|
U64_PRINTF_ARG(chan_l->global_identifier), chan_l,
|
||||||
channel_listener_describe_transport(chan_l),
|
channel_listener_describe_transport(chan_l),
|
||||||
channel_listener_state_to_string(chan_l->state), chan_l->state);
|
channel_listener_state_to_string(chan_l->state), chan_l->state);
|
||||||
log(severity, LD_GENERAL,
|
tor_log(severity, LD_GENERAL,
|
||||||
" * Channel listener " U64_FORMAT " was created at " U64_FORMAT
|
" * Channel listener " U64_FORMAT " was created at " U64_FORMAT
|
||||||
" (" U64_FORMAT " seconds ago) "
|
" (" U64_FORMAT " seconds ago) "
|
||||||
"and last active at " U64_FORMAT " (" U64_FORMAT " seconds ago)",
|
"and last active at " U64_FORMAT " (" U64_FORMAT " seconds ago)",
|
||||||
@ -3353,7 +3353,7 @@ channel_listener_dump_statistics(channel_listener_t *chan_l, int severity)
|
|||||||
U64_PRINTF_ARG(chan_l->timestamp_active),
|
U64_PRINTF_ARG(chan_l->timestamp_active),
|
||||||
U64_PRINTF_ARG(now - chan_l->timestamp_active));
|
U64_PRINTF_ARG(now - chan_l->timestamp_active));
|
||||||
|
|
||||||
log(severity, LD_GENERAL,
|
tor_log(severity, LD_GENERAL,
|
||||||
" * Channel listener " U64_FORMAT " last accepted an incoming "
|
" * Channel listener " U64_FORMAT " last accepted an incoming "
|
||||||
"channel at " U64_FORMAT " (" U64_FORMAT " seconds ago) "
|
"channel at " U64_FORMAT " (" U64_FORMAT " seconds ago) "
|
||||||
"and has accepted " U64_FORMAT " channels in total",
|
"and has accepted " U64_FORMAT " channels in total",
|
||||||
@ -3371,13 +3371,13 @@ channel_listener_dump_statistics(channel_listener_t *chan_l, int severity)
|
|||||||
chan_l->n_accepted > 0) {
|
chan_l->n_accepted > 0) {
|
||||||
avg = (double)(chan_l->n_accepted) / age;
|
avg = (double)(chan_l->n_accepted) / age;
|
||||||
if (avg >= 1.0) {
|
if (avg >= 1.0) {
|
||||||
log(severity, LD_GENERAL,
|
tor_log(severity, LD_GENERAL,
|
||||||
" * Channel listener " U64_FORMAT " has averaged %f incoming "
|
" * Channel listener " U64_FORMAT " has averaged %f incoming "
|
||||||
"channels per second",
|
"channels per second",
|
||||||
U64_PRINTF_ARG(chan_l->global_identifier), avg);
|
U64_PRINTF_ARG(chan_l->global_identifier), avg);
|
||||||
} else if (avg >= 0.0) {
|
} else if (avg >= 0.0) {
|
||||||
interval = 1.0 / avg;
|
interval = 1.0 / avg;
|
||||||
log(severity, LD_GENERAL,
|
tor_log(severity, LD_GENERAL,
|
||||||
" * Channel listener " U64_FORMAT " has averaged %f seconds "
|
" * Channel listener " U64_FORMAT " has averaged %f seconds "
|
||||||
"between incoming channels",
|
"between incoming channels",
|
||||||
U64_PRINTF_ARG(chan_l->global_identifier), interval);
|
U64_PRINTF_ARG(chan_l->global_identifier), interval);
|
||||||
|
@ -783,8 +783,8 @@ circuit_dump_conn_details(int severity,
|
|||||||
int this_circid,
|
int this_circid,
|
||||||
int other_circid)
|
int other_circid)
|
||||||
{
|
{
|
||||||
log(severity, LD_CIRC, "Conn %d has %s circuit: circID %d (other side %d), "
|
tor_log(severity, LD_CIRC, "Conn %d has %s circuit: circID %d "
|
||||||
"state %d (%s), born %ld:",
|
"(other side %d), state %d (%s), born %ld:",
|
||||||
conn_array_index, type, this_circid, other_circid, circ->state,
|
conn_array_index, type, this_circid, other_circid, circ->state,
|
||||||
circuit_state_to_string(circ->state),
|
circuit_state_to_string(circ->state),
|
||||||
(long)circ->timestamp_began.tv_sec);
|
(long)circ->timestamp_began.tv_sec);
|
||||||
@ -846,8 +846,8 @@ circuit_dump_chan_details(int severity,
|
|||||||
int this_circid,
|
int this_circid,
|
||||||
int other_circid)
|
int other_circid)
|
||||||
{
|
{
|
||||||
log(severity, LD_CIRC, "Conn %p has %s circuit: circID %d (other side %d), "
|
tor_log(severity, LD_CIRC, "Conn %p has %s circuit: circID %d "
|
||||||
"state %d (%s), born %ld:",
|
"(other side %d), state %d (%s), born %ld:",
|
||||||
chan, type, this_circid, other_circid, circ->state,
|
chan, type, this_circid, other_circid, circ->state,
|
||||||
circuit_state_to_string(circ->state),
|
circuit_state_to_string(circ->state),
|
||||||
(long)circ->timestamp_began.tv_sec);
|
(long)circ->timestamp_began.tv_sec);
|
||||||
@ -1343,7 +1343,7 @@ circuit_mark_for_close_(circuit_t *circ, int reason, int line,
|
|||||||
tor_assert(file);
|
tor_assert(file);
|
||||||
|
|
||||||
if (circ->marked_for_close) {
|
if (circ->marked_for_close) {
|
||||||
log(LOG_WARN,LD_BUG,
|
log_warn(LD_BUG,
|
||||||
"Duplicate call to circuit_mark_for_close at %s:%d"
|
"Duplicate call to circuit_mark_for_close at %s:%d"
|
||||||
" (first at %s:%d)", file, line,
|
" (first at %s:%d)", file, line,
|
||||||
circ->marked_for_close_file, circ->marked_for_close);
|
circ->marked_for_close_file, circ->marked_for_close);
|
||||||
|
@ -1092,7 +1092,7 @@ options_act_reversible(const or_options_t *old_options, char **msg)
|
|||||||
|
|
||||||
mark_logs_temp(); /* Close current logs once new logs are open. */
|
mark_logs_temp(); /* Close current logs once new logs are open. */
|
||||||
logs_marked = 1;
|
logs_marked = 1;
|
||||||
if (options_init_logs(options, 0)<0) { /* Configure the log(s) */
|
if (options_init_logs(options, 0)<0) { /* Configure the tor_log(s) */
|
||||||
*msg = tor_strdup("Failed to init Log options. See logs for details.");
|
*msg = tor_strdup("Failed to init Log options. See logs for details.");
|
||||||
goto rollback;
|
goto rollback;
|
||||||
}
|
}
|
||||||
@ -1268,7 +1268,7 @@ options_act(const or_options_t *old_options)
|
|||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
#ifdef NON_ANONYMOUS_MODE_ENABLED
|
#ifdef NON_ANONYMOUS_MODE_ENABLED
|
||||||
log(LOG_WARN, LD_GENERAL, "This copy of Tor was compiled to run in a "
|
log_warn(LD_GENERAL, "This copy of Tor was compiled to run in a "
|
||||||
"non-anonymous mode. It will provide NO ANONYMITY.");
|
"non-anonymous mode. It will provide NO ANONYMITY.");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -1770,7 +1770,7 @@ config_get_commandlines(int argc, char **argv, config_line_t **result)
|
|||||||
(*new)->value = want_arg ? tor_strdup(argv[i+1]) : tor_strdup("");
|
(*new)->value = want_arg ? tor_strdup(argv[i+1]) : tor_strdup("");
|
||||||
(*new)->command = command;
|
(*new)->command = command;
|
||||||
(*new)->next = NULL;
|
(*new)->next = NULL;
|
||||||
log(LOG_DEBUG, LD_CONFIG, "command line: parsed keyword '%s', value '%s'",
|
log_debug(LD_CONFIG, "command line: parsed keyword '%s', value '%s'",
|
||||||
(*new)->key, (*new)->value);
|
(*new)->key, (*new)->value);
|
||||||
|
|
||||||
new = &((*new)->next);
|
new = &((*new)->next);
|
||||||
@ -2218,7 +2218,7 @@ options_validate(or_options_t *old_options, or_options_t *options,
|
|||||||
int n_ports=0;
|
int n_ports=0;
|
||||||
#define REJECT(arg) \
|
#define REJECT(arg) \
|
||||||
STMT_BEGIN *msg = tor_strdup(arg); return -1; STMT_END
|
STMT_BEGIN *msg = tor_strdup(arg); return -1; STMT_END
|
||||||
#define COMPLAIN(arg) STMT_BEGIN log(LOG_WARN, LD_CONFIG, arg); STMT_END
|
#define COMPLAIN(arg) STMT_BEGIN log_warn(LD_CONFIG, arg); STMT_END
|
||||||
|
|
||||||
tor_assert(msg);
|
tor_assert(msg);
|
||||||
*msg = NULL;
|
*msg = NULL;
|
||||||
@ -2227,7 +2227,7 @@ options_validate(or_options_t *old_options, or_options_t *options,
|
|||||||
(!strcmpstart(uname, "Windows 95") ||
|
(!strcmpstart(uname, "Windows 95") ||
|
||||||
!strcmpstart(uname, "Windows 98") ||
|
!strcmpstart(uname, "Windows 98") ||
|
||||||
!strcmpstart(uname, "Windows Me"))) {
|
!strcmpstart(uname, "Windows Me"))) {
|
||||||
log(LOG_WARN, LD_CONFIG, "Tor is running as a server, but you are "
|
log_warn(LD_CONFIG, "Tor is running as a server, but you are "
|
||||||
"running %s; this probably won't work. See "
|
"running %s; this probably won't work. See "
|
||||||
"https://wiki.torproject.org/TheOnionRouter/TorFAQ#ServerOS "
|
"https://wiki.torproject.org/TheOnionRouter/TorFAQ#ServerOS "
|
||||||
"for details.", uname);
|
"for details.", uname);
|
||||||
@ -2256,7 +2256,7 @@ options_validate(or_options_t *old_options, or_options_t *options,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (server_mode(options) && !options->ContactInfo)
|
if (server_mode(options) && !options->ContactInfo)
|
||||||
log(LOG_NOTICE, LD_CONFIG, "Your ContactInfo config option is not set. "
|
log_notice(LD_CONFIG, "Your ContactInfo config option is not set. "
|
||||||
"Please consider setting it, so we can contact you if your server is "
|
"Please consider setting it, so we can contact you if your server is "
|
||||||
"misconfigured or something else goes wrong.");
|
"misconfigured or something else goes wrong.");
|
||||||
|
|
||||||
@ -2268,7 +2268,7 @@ options_validate(or_options_t *old_options, or_options_t *options,
|
|||||||
config_line_append(&options->Logs, "Log", "warn stdout");
|
config_line_append(&options->Logs, "Log", "warn stdout");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options_init_logs(options, 1)<0) /* Validate the log(s) */
|
if (options_init_logs(options, 1)<0) /* Validate the tor_log(s) */
|
||||||
REJECT("Failed to validate Log options. See logs for details.");
|
REJECT("Failed to validate Log options. See logs for details.");
|
||||||
|
|
||||||
if (authdir_mode(options)) {
|
if (authdir_mode(options)) {
|
||||||
@ -2286,7 +2286,7 @@ options_validate(or_options_t *old_options, or_options_t *options,
|
|||||||
/* XXXX require that the only port not be DirPort? */
|
/* XXXX require that the only port not be DirPort? */
|
||||||
/* XXXX require that at least one port be listened-upon. */
|
/* XXXX require that at least one port be listened-upon. */
|
||||||
if (n_ports == 0 && !options->RendConfigLines)
|
if (n_ports == 0 && !options->RendConfigLines)
|
||||||
log(LOG_WARN, LD_CONFIG,
|
log_warn(LD_CONFIG,
|
||||||
"SocksPort, TransPort, NATDPort, DNSPort, and ORPort are all "
|
"SocksPort, TransPort, NATDPort, DNSPort, and ORPort are all "
|
||||||
"undefined, and there aren't any hidden services configured. "
|
"undefined, and there aren't any hidden services configured. "
|
||||||
"Tor will still run, but probably won't do anything.");
|
"Tor will still run, but probably won't do anything.");
|
||||||
@ -2446,7 +2446,7 @@ options_validate(or_options_t *old_options, or_options_t *options,
|
|||||||
});
|
});
|
||||||
new_line->value = smartlist_join_strings(instead,",",0,NULL);
|
new_line->value = smartlist_join_strings(instead,",",0,NULL);
|
||||||
/* These have been deprecated since 0.1.1.5-alpha-cvs */
|
/* These have been deprecated since 0.1.1.5-alpha-cvs */
|
||||||
log(LOG_NOTICE, LD_CONFIG,
|
log_notice(LD_CONFIG,
|
||||||
"Converting FascistFirewall and FirewallPorts "
|
"Converting FascistFirewall and FirewallPorts "
|
||||||
"config options to new format: \"ReachableAddresses %s\"",
|
"config options to new format: \"ReachableAddresses %s\"",
|
||||||
new_line->value);
|
new_line->value);
|
||||||
@ -2461,7 +2461,7 @@ options_validate(or_options_t *old_options, or_options_t *options,
|
|||||||
new_line->key = tor_strdup("ReachableDirAddresses");
|
new_line->key = tor_strdup("ReachableDirAddresses");
|
||||||
new_line->value = tor_strdup("*:80");
|
new_line->value = tor_strdup("*:80");
|
||||||
options->ReachableDirAddresses = new_line;
|
options->ReachableDirAddresses = new_line;
|
||||||
log(LOG_NOTICE, LD_CONFIG, "Converting FascistFirewall config option "
|
log_notice(LD_CONFIG, "Converting FascistFirewall config option "
|
||||||
"to new format: \"ReachableDirAddresses *:80\"");
|
"to new format: \"ReachableDirAddresses *:80\"");
|
||||||
}
|
}
|
||||||
if (!options->ReachableORAddresses) {
|
if (!options->ReachableORAddresses) {
|
||||||
@ -2469,7 +2469,7 @@ options_validate(or_options_t *old_options, or_options_t *options,
|
|||||||
new_line->key = tor_strdup("ReachableORAddresses");
|
new_line->key = tor_strdup("ReachableORAddresses");
|
||||||
new_line->value = tor_strdup("*:443");
|
new_line->value = tor_strdup("*:443");
|
||||||
options->ReachableORAddresses = new_line;
|
options->ReachableORAddresses = new_line;
|
||||||
log(LOG_NOTICE, LD_CONFIG, "Converting FascistFirewall config option "
|
log_notice(LD_CONFIG, "Converting FascistFirewall config option "
|
||||||
"to new format: \"ReachableORAddresses *:443\"");
|
"to new format: \"ReachableORAddresses *:443\"");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3423,7 +3423,7 @@ find_torrc_filename(int argc, char **argv,
|
|||||||
for (i = 1; i < argc; ++i) {
|
for (i = 1; i < argc; ++i) {
|
||||||
if (i < argc-1 && !strcmp(argv[i],fname_opt)) {
|
if (i < argc-1 && !strcmp(argv[i],fname_opt)) {
|
||||||
if (fname) {
|
if (fname) {
|
||||||
log(LOG_WARN, LD_CONFIG, "Duplicate %s options on command line.",
|
log_warn(LD_CONFIG, "Duplicate %s options on command line.",
|
||||||
fname_opt);
|
fname_opt);
|
||||||
tor_free(fname);
|
tor_free(fname);
|
||||||
}
|
}
|
||||||
@ -3486,7 +3486,7 @@ load_torrc_from_disk(int argc, char **argv, int defaults_file)
|
|||||||
fname = find_torrc_filename(argc, argv, defaults_file,
|
fname = find_torrc_filename(argc, argv, defaults_file,
|
||||||
&using_default_torrc, &ignore_missing_torrc);
|
&using_default_torrc, &ignore_missing_torrc);
|
||||||
tor_assert(fname);
|
tor_assert(fname);
|
||||||
log(LOG_DEBUG, LD_CONFIG, "Opening config file \"%s\"", fname);
|
log_debug(LD_CONFIG, "Opening config file \"%s\"", fname);
|
||||||
|
|
||||||
tor_free(*fname_var);
|
tor_free(*fname_var);
|
||||||
*fname_var = fname;
|
*fname_var = fname;
|
||||||
@ -3496,18 +3496,18 @@ load_torrc_from_disk(int argc, char **argv, int defaults_file)
|
|||||||
!(cf = read_file_to_str(fname,0,NULL))) {
|
!(cf = read_file_to_str(fname,0,NULL))) {
|
||||||
if (using_default_torrc == 1 || ignore_missing_torrc) {
|
if (using_default_torrc == 1 || ignore_missing_torrc) {
|
||||||
if (!defaults_file)
|
if (!defaults_file)
|
||||||
log(LOG_NOTICE, LD_CONFIG, "Configuration file \"%s\" not present, "
|
log_notice(LD_CONFIG, "Configuration file \"%s\" not present, "
|
||||||
"using reasonable defaults.", fname);
|
"using reasonable defaults.", fname);
|
||||||
tor_free(fname); /* sets fname to NULL */
|
tor_free(fname); /* sets fname to NULL */
|
||||||
*fname_var = NULL;
|
*fname_var = NULL;
|
||||||
cf = tor_strdup("");
|
cf = tor_strdup("");
|
||||||
} else {
|
} else {
|
||||||
log(LOG_WARN, LD_CONFIG,
|
log_warn(LD_CONFIG,
|
||||||
"Unable to open configuration file \"%s\".", fname);
|
"Unable to open configuration file \"%s\".", fname);
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
log(LOG_NOTICE, LD_CONFIG, "Read configuration file \"%s\".", fname);
|
log_notice(LD_CONFIG, "Read configuration file \"%s\".", fname);
|
||||||
}
|
}
|
||||||
|
|
||||||
return cf;
|
return cf;
|
||||||
@ -3599,7 +3599,7 @@ options_init_from_torrc(int argc, char **argv)
|
|||||||
tor_free(cf);
|
tor_free(cf);
|
||||||
tor_free(cf_defaults);
|
tor_free(cf_defaults);
|
||||||
if (errmsg) {
|
if (errmsg) {
|
||||||
log(LOG_WARN,LD_CONFIG,"%s", errmsg);
|
log_warn(LD_CONFIG,"%s", errmsg);
|
||||||
tor_free(errmsg);
|
tor_free(errmsg);
|
||||||
}
|
}
|
||||||
return retval < 0 ? -1 : 0;
|
return retval < 0 ? -1 : 0;
|
||||||
@ -5383,7 +5383,7 @@ check_server_ports(const smartlist_t *ports,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (n_low_port && options->AccountingMax) {
|
if (n_low_port && options->AccountingMax) {
|
||||||
log(LOG_WARN, LD_CONFIG,
|
log_warn(LD_CONFIG,
|
||||||
"You have set AccountingMax to use hibernation. You have also "
|
"You have set AccountingMax to use hibernation. You have also "
|
||||||
"chosen a low DirPort or OrPort. This combination can make Tor stop "
|
"chosen a low DirPort or OrPort. This combination can make Tor stop "
|
||||||
"working when it tries to re-attach the port after a period of "
|
"working when it tries to re-attach the port after a period of "
|
||||||
|
@ -731,7 +731,7 @@ connection_mark_for_close_internal_(connection_t *conn,
|
|||||||
tor_assert(file);
|
tor_assert(file);
|
||||||
|
|
||||||
if (conn->marked_for_close) {
|
if (conn->marked_for_close) {
|
||||||
log(LOG_WARN,LD_BUG,"Duplicate call to connection_mark_for_close at %s:%d"
|
log_warn(LD_BUG,"Duplicate call to connection_mark_for_close at %s:%d"
|
||||||
" (first at %s:%d)", file, line, conn->marked_for_close_file,
|
" (first at %s:%d)", file, line, conn->marked_for_close_file,
|
||||||
conn->marked_for_close);
|
conn->marked_for_close);
|
||||||
tor_fragile_assert();
|
tor_fragile_assert();
|
||||||
@ -2530,7 +2530,7 @@ connection_bucket_refill_helper(int *bucket, int rate, int burst,
|
|||||||
*bucket = burst;
|
*bucket = burst;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
log(LOG_DEBUG, LD_NET,"%s now %d.", name, *bucket);
|
log_debug(LD_NET,"%s now %d.", name, *bucket);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3897,7 +3897,7 @@ client_check_address_changed(tor_socket_t sock)
|
|||||||
} else {
|
} else {
|
||||||
/* The interface changed. We're a client, so we need to regenerate our
|
/* The interface changed. We're a client, so we need to regenerate our
|
||||||
* keys. First, reset the state. */
|
* keys. First, reset the state. */
|
||||||
log(LOG_NOTICE, LD_NET, "Our IP address has changed. Rotating keys...");
|
log_notice(LD_NET, "Our IP address has changed. Rotating keys...");
|
||||||
tor_addr_copy(*last_interface_ip_ptr, &iface_addr);
|
tor_addr_copy(*last_interface_ip_ptr, &iface_addr);
|
||||||
SMARTLIST_FOREACH(outgoing_addrs, tor_addr_t*, a_ptr, tor_free(a_ptr));
|
SMARTLIST_FOREACH(outgoing_addrs, tor_addr_t*, a_ptr, tor_free(a_ptr));
|
||||||
smartlist_clear(outgoing_addrs);
|
smartlist_clear(outgoing_addrs);
|
||||||
@ -4109,14 +4109,14 @@ connection_dump_buffer_mem_stats(int severity)
|
|||||||
total_alloc += alloc_by_type[i];
|
total_alloc += alloc_by_type[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
log(severity, LD_GENERAL,
|
tor_log(severity, LD_GENERAL,
|
||||||
"In buffers for %d connections: "U64_FORMAT" used/"U64_FORMAT" allocated",
|
"In buffers for %d connections: "U64_FORMAT" used/"U64_FORMAT" allocated",
|
||||||
smartlist_len(conns),
|
smartlist_len(conns),
|
||||||
U64_PRINTF_ARG(total_used), U64_PRINTF_ARG(total_alloc));
|
U64_PRINTF_ARG(total_used), U64_PRINTF_ARG(total_alloc));
|
||||||
for (i=CONN_TYPE_MIN_; i <= CONN_TYPE_MAX_; ++i) {
|
for (i=CONN_TYPE_MIN_; i <= CONN_TYPE_MAX_; ++i) {
|
||||||
if (!n_conns_by_type[i])
|
if (!n_conns_by_type[i])
|
||||||
continue;
|
continue;
|
||||||
log(severity, LD_GENERAL,
|
tor_log(severity, LD_GENERAL,
|
||||||
" For %d %s connections: "U64_FORMAT" used/"U64_FORMAT" allocated",
|
" For %d %s connections: "U64_FORMAT" used/"U64_FORMAT" allocated",
|
||||||
n_conns_by_type[i], conn_type_to_string(i),
|
n_conns_by_type[i], conn_type_to_string(i),
|
||||||
U64_PRINTF_ARG(used_by_type[i]), U64_PRINTF_ARG(alloc_by_type[i]));
|
U64_PRINTF_ARG(used_by_type[i]), U64_PRINTF_ARG(alloc_by_type[i]));
|
||||||
|
@ -295,13 +295,13 @@ connection_or_report_broken_states(int severity, int domain)
|
|||||||
|
|
||||||
smartlist_sort(items, broken_state_count_compare);
|
smartlist_sort(items, broken_state_count_compare);
|
||||||
|
|
||||||
log(severity, domain, "%d connections have failed%s", total,
|
tor_log(severity, domain, "%d connections have failed%s", total,
|
||||||
smartlist_len(items) > MAX_REASONS_TO_REPORT ? ". Top reasons:" : ":");
|
smartlist_len(items) > MAX_REASONS_TO_REPORT ? ". Top reasons:" : ":");
|
||||||
|
|
||||||
SMARTLIST_FOREACH_BEGIN(items, const broken_state_count_t *, c) {
|
SMARTLIST_FOREACH_BEGIN(items, const broken_state_count_t *, c) {
|
||||||
if (c_sl_idx > MAX_REASONS_TO_REPORT)
|
if (c_sl_idx > MAX_REASONS_TO_REPORT)
|
||||||
break;
|
break;
|
||||||
log(severity, domain,
|
tor_log(severity, domain,
|
||||||
" %d connections died in state %s", (int)c->count, c->state);
|
" %d connections died in state %s", (int)c->count, c->state);
|
||||||
} SMARTLIST_FOREACH_END(c);
|
} SMARTLIST_FOREACH_END(c);
|
||||||
|
|
||||||
|
@ -4663,7 +4663,7 @@ control_event_bootstrap(bootstrap_status_t status, int progress)
|
|||||||
if (status > bootstrap_percent ||
|
if (status > bootstrap_percent ||
|
||||||
(progress && progress > bootstrap_percent)) {
|
(progress && progress > bootstrap_percent)) {
|
||||||
bootstrap_status_to_string(status, &tag, &summary);
|
bootstrap_status_to_string(status, &tag, &summary);
|
||||||
log(status ? LOG_NOTICE : LOG_INFO, LD_CONTROL,
|
tor_log(status ? LOG_NOTICE : LOG_INFO, LD_CONTROL,
|
||||||
"Bootstrapped %d%%: %s.", progress ? progress : status, summary);
|
"Bootstrapped %d%%: %s.", progress ? progress : status, summary);
|
||||||
tor_snprintf(buf, sizeof(buf),
|
tor_snprintf(buf, sizeof(buf),
|
||||||
"BOOTSTRAP PROGRESS=%d TAG=%s SUMMARY=\"%s\"",
|
"BOOTSTRAP PROGRESS=%d TAG=%s SUMMARY=\"%s\"",
|
||||||
|
@ -1860,7 +1860,7 @@ connection_dir_client_reached_eof(dir_connection_t *conn)
|
|||||||
const char *flavname = conn->requested_resource;
|
const char *flavname = conn->requested_resource;
|
||||||
if (status_code != 200) {
|
if (status_code != 200) {
|
||||||
int severity = (status_code == 304) ? LOG_INFO : LOG_WARN;
|
int severity = (status_code == 304) ? LOG_INFO : LOG_WARN;
|
||||||
log(severity, LD_DIR,
|
tor_log(severity, LD_DIR,
|
||||||
"Received http status code %d (%s) from server "
|
"Received http status code %d (%s) from server "
|
||||||
"'%s:%d' while fetching consensus directory.",
|
"'%s:%d' while fetching consensus directory.",
|
||||||
status_code, escaped(reason), conn->base_.address,
|
status_code, escaped(reason), conn->base_.address,
|
||||||
|
@ -2017,7 +2017,7 @@ dirserv_compute_performance_thresholds(routerlist_t *rl)
|
|||||||
median_uint32(bandwidths_excluding_exits, n_active_nonexit);
|
median_uint32(bandwidths_excluding_exits, n_active_nonexit);
|
||||||
}
|
}
|
||||||
|
|
||||||
log(LOG_INFO, LD_DIRSERV,
|
log_info(LD_DIRSERV,
|
||||||
"Cutoffs: For Stable, %lu sec uptime, %lu sec MTBF. "
|
"Cutoffs: For Stable, %lu sec uptime, %lu sec MTBF. "
|
||||||
"For Fast: %lu bytes/sec. "
|
"For Fast: %lu bytes/sec. "
|
||||||
"For Guard: WFU %.03f%%, time-known %lu sec, "
|
"For Guard: WFU %.03f%%, time-known %lu sec, "
|
||||||
|
@ -2288,7 +2288,7 @@ networkstatus_add_detached_signatures(networkstatus_t *target,
|
|||||||
if (sig->good_signature || !old_sig || old_sig->bad_signature) {
|
if (sig->good_signature || !old_sig || old_sig->bad_signature) {
|
||||||
log_info(LD_DIR, "Adding signature from %s with %s", voter_identity,
|
log_info(LD_DIR, "Adding signature from %s with %s", voter_identity,
|
||||||
algorithm);
|
algorithm);
|
||||||
log(severity, LD_DIR, "Added a signature for %s from %s.",
|
tor_log(severity, LD_DIR, "Added a signature for %s from %s.",
|
||||||
target_voter->nickname, source);
|
target_voter->nickname, source);
|
||||||
++r;
|
++r;
|
||||||
if (old_sig) {
|
if (old_sig) {
|
||||||
|
16
src/or/dns.c
16
src/or/dns.c
@ -262,7 +262,7 @@ evdns_log_cb(int warn, const char *msg)
|
|||||||
int severity = warn ? LOG_WARN : LOG_INFO;
|
int severity = warn ? LOG_WARN : LOG_INFO;
|
||||||
if (!strcmpstart(msg, "Resolve requested for") &&
|
if (!strcmpstart(msg, "Resolve requested for") &&
|
||||||
get_options()->SafeLogging) {
|
get_options()->SafeLogging) {
|
||||||
log(LOG_INFO, LD_EXIT, "eventdns: Resolve requested.");
|
log_info(LD_EXIT, "eventdns: Resolve requested.");
|
||||||
return;
|
return;
|
||||||
} else if (!strcmpstart(msg, "Search: ")) {
|
} else if (!strcmpstart(msg, "Search: ")) {
|
||||||
return;
|
return;
|
||||||
@ -291,7 +291,7 @@ evdns_log_cb(int warn, const char *msg)
|
|||||||
control_event_server_status(LOG_WARN, "NAMESERVER_ALL_DOWN");
|
control_event_server_status(LOG_WARN, "NAMESERVER_ALL_DOWN");
|
||||||
all_down = 1;
|
all_down = 1;
|
||||||
}
|
}
|
||||||
log(severity, LD_EXIT, "eventdns: %s", msg);
|
tor_log(severity, LD_EXIT, "eventdns: %s", msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Helper: passed to eventdns.c as a callback so it can generate random
|
/** Helper: passed to eventdns.c as a callback so it can generate random
|
||||||
@ -835,7 +835,7 @@ dns_resolve_impl(edge_connection_t *exitconn, int is_resolve,
|
|||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (address_is_invalid_destination(exitconn->base_.address, 0)) {
|
if (address_is_invalid_destination(exitconn->base_.address, 0)) {
|
||||||
log(LOG_PROTOCOL_WARN, LD_EXIT,
|
tor_log(LOG_PROTOCOL_WARN, LD_EXIT,
|
||||||
"Rejecting invalid destination address %s",
|
"Rejecting invalid destination address %s",
|
||||||
escaped_safe_str(exitconn->base_.address));
|
escaped_safe_str(exitconn->base_.address));
|
||||||
return -1;
|
return -1;
|
||||||
@ -1844,7 +1844,7 @@ wildcard_increment_answer(const char *id)
|
|||||||
if (*ip > 5 && n_wildcard_requests > 10) {
|
if (*ip > 5 && n_wildcard_requests > 10) {
|
||||||
if (!dns_wildcard_list) dns_wildcard_list = smartlist_new();
|
if (!dns_wildcard_list) dns_wildcard_list = smartlist_new();
|
||||||
if (!smartlist_contains_string(dns_wildcard_list, id)) {
|
if (!smartlist_contains_string(dns_wildcard_list, id)) {
|
||||||
log(dns_wildcard_notice_given ? LOG_INFO : LOG_NOTICE, LD_EXIT,
|
tor_log(dns_wildcard_notice_given ? LOG_INFO : LOG_NOTICE, LD_EXIT,
|
||||||
"Your DNS provider has given \"%s\" as an answer for %d different "
|
"Your DNS provider has given \"%s\" as an answer for %d different "
|
||||||
"invalid addresses. Apparently they are hijacking DNS failures. "
|
"invalid addresses. Apparently they are hijacking DNS failures. "
|
||||||
"I'll try to correct for this by treating future occurrences of "
|
"I'll try to correct for this by treating future occurrences of "
|
||||||
@ -1876,7 +1876,7 @@ add_wildcarded_test_address(const char *address)
|
|||||||
smartlist_add(dns_wildcarded_test_address_list, tor_strdup(address));
|
smartlist_add(dns_wildcarded_test_address_list, tor_strdup(address));
|
||||||
n = smartlist_len(dns_wildcarded_test_address_list);
|
n = smartlist_len(dns_wildcarded_test_address_list);
|
||||||
if (n > n_test_addrs/2) {
|
if (n > n_test_addrs/2) {
|
||||||
log(dns_wildcarded_test_address_notice_given ? LOG_INFO : LOG_NOTICE,
|
tor_log(dns_wildcarded_test_address_notice_given ? LOG_INFO : LOG_NOTICE,
|
||||||
LD_EXIT, "Your DNS provider tried to redirect \"%s\" to a junk "
|
LD_EXIT, "Your DNS provider tried to redirect \"%s\" to a junk "
|
||||||
"address. It has done this with %d test addresses so far. I'm "
|
"address. It has done this with %d test addresses so far. I'm "
|
||||||
"going to stop being an exit node for now, since our DNS seems so "
|
"going to stop being an exit node for now, since our DNS seems so "
|
||||||
@ -1920,7 +1920,7 @@ evdns_wildcard_check_callback(int result, char type, int count, int ttl,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
log(dns_wildcard_one_notice_given ? LOG_INFO : LOG_NOTICE, LD_EXIT,
|
tor_log(dns_wildcard_one_notice_given ? LOG_INFO : LOG_NOTICE, LD_EXIT,
|
||||||
"Your DNS provider gave an answer for \"%s\", which "
|
"Your DNS provider gave an answer for \"%s\", which "
|
||||||
"is not supposed to exist. Apparently they are hijacking "
|
"is not supposed to exist. Apparently they are hijacking "
|
||||||
"DNS failures. Trying to correct for this. We've noticed %d "
|
"DNS failures. Trying to correct for this. We've noticed %d "
|
||||||
@ -2151,8 +2151,8 @@ dump_dns_mem_usage(int severity)
|
|||||||
/* Print out the count and estimated size of our &cache_root. It undercounts
|
/* Print out the count and estimated size of our &cache_root. It undercounts
|
||||||
hostnames in cached reverse resolves.
|
hostnames in cached reverse resolves.
|
||||||
*/
|
*/
|
||||||
log(severity, LD_MM, "Our DNS cache has %d entries.", hash_count);
|
tor_log(severity, LD_MM, "Our DNS cache has %d entries.", hash_count);
|
||||||
log(severity, LD_MM, "Our DNS cache size is approximately %u bytes.",
|
tor_log(severity, LD_MM, "Our DNS cache size is approximately %u bytes.",
|
||||||
(unsigned)hash_mem);
|
(unsigned)hash_mem);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -973,7 +973,7 @@ directory_info_has_arrived(time_t now, int from_cache)
|
|||||||
if (!router_have_minimum_dir_info()) {
|
if (!router_have_minimum_dir_info()) {
|
||||||
int quiet = from_cache ||
|
int quiet = from_cache ||
|
||||||
directory_too_idle_to_fetch_descriptors(options, now);
|
directory_too_idle_to_fetch_descriptors(options, now);
|
||||||
log(quiet ? LOG_INFO : LOG_NOTICE, LD_DIR,
|
tor_log(quiet ? LOG_INFO : LOG_NOTICE, LD_DIR,
|
||||||
"I learned some more directory information, but not enough to "
|
"I learned some more directory information, but not enough to "
|
||||||
"build a circuit: %s", get_dir_info_status_string());
|
"build a circuit: %s", get_dir_info_status_string());
|
||||||
update_all_descriptor_downloads(now);
|
update_all_descriptor_downloads(now);
|
||||||
@ -1201,7 +1201,7 @@ run_scheduled_events(time_t now)
|
|||||||
* eventually. */
|
* eventually. */
|
||||||
if (signewnym_is_pending &&
|
if (signewnym_is_pending &&
|
||||||
time_of_last_signewnym + MAX_SIGNEWNYM_RATE <= now) {
|
time_of_last_signewnym + MAX_SIGNEWNYM_RATE <= now) {
|
||||||
log(LOG_INFO, LD_CONTROL, "Honoring delayed NEWNYM request");
|
log_info(LD_CONTROL, "Honoring delayed NEWNYM request");
|
||||||
signewnym_impl(now);
|
signewnym_impl(now);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2083,7 +2083,7 @@ process_signal(uintptr_t sig)
|
|||||||
time_t now = time(NULL);
|
time_t now = time(NULL);
|
||||||
if (time_of_last_signewnym + MAX_SIGNEWNYM_RATE > now) {
|
if (time_of_last_signewnym + MAX_SIGNEWNYM_RATE > now) {
|
||||||
signewnym_is_pending = 1;
|
signewnym_is_pending = 1;
|
||||||
log(LOG_NOTICE, LD_CONTROL,
|
log_notice(LD_CONTROL,
|
||||||
"Rate limiting NEWNYM request: delaying by %d second(s)",
|
"Rate limiting NEWNYM request: delaying by %d second(s)",
|
||||||
(int)(MAX_SIGNEWNYM_RATE+time_of_last_signewnym-now));
|
(int)(MAX_SIGNEWNYM_RATE+time_of_last_signewnym-now));
|
||||||
} else {
|
} else {
|
||||||
@ -2115,7 +2115,7 @@ static void
|
|||||||
dumpmemusage(int severity)
|
dumpmemusage(int severity)
|
||||||
{
|
{
|
||||||
connection_dump_buffer_mem_stats(severity);
|
connection_dump_buffer_mem_stats(severity);
|
||||||
log(severity, LD_GENERAL, "In rephist: "U64_FORMAT" used by %d Tors.",
|
tor_log(severity, LD_GENERAL, "In rephist: "U64_FORMAT" used by %d Tors.",
|
||||||
U64_PRINTF_ARG(rephist_total_alloc), rephist_total_num);
|
U64_PRINTF_ARG(rephist_total_alloc), rephist_total_num);
|
||||||
dump_routerlist_mem_usage(severity);
|
dump_routerlist_mem_usage(severity);
|
||||||
dump_cell_pool_usage(severity);
|
dump_cell_pool_usage(severity);
|
||||||
@ -2133,27 +2133,27 @@ dumpstats(int severity)
|
|||||||
time_t elapsed;
|
time_t elapsed;
|
||||||
size_t rbuf_cap, wbuf_cap, rbuf_len, wbuf_len;
|
size_t rbuf_cap, wbuf_cap, rbuf_len, wbuf_len;
|
||||||
|
|
||||||
log(severity, LD_GENERAL, "Dumping stats:");
|
tor_log(severity, LD_GENERAL, "Dumping stats:");
|
||||||
|
|
||||||
SMARTLIST_FOREACH_BEGIN(connection_array, connection_t *, conn) {
|
SMARTLIST_FOREACH_BEGIN(connection_array, connection_t *, conn) {
|
||||||
int i = conn_sl_idx;
|
int i = conn_sl_idx;
|
||||||
log(severity, LD_GENERAL,
|
tor_log(severity, LD_GENERAL,
|
||||||
"Conn %d (socket %d) type %d (%s), state %d (%s), created %d secs ago",
|
"Conn %d (socket %d) type %d (%s), state %d (%s), created %d secs ago",
|
||||||
i, (int)conn->s, conn->type, conn_type_to_string(conn->type),
|
i, (int)conn->s, conn->type, conn_type_to_string(conn->type),
|
||||||
conn->state, conn_state_to_string(conn->type, conn->state),
|
conn->state, conn_state_to_string(conn->type, conn->state),
|
||||||
(int)(now - conn->timestamp_created));
|
(int)(now - conn->timestamp_created));
|
||||||
if (!connection_is_listener(conn)) {
|
if (!connection_is_listener(conn)) {
|
||||||
log(severity,LD_GENERAL,
|
tor_log(severity,LD_GENERAL,
|
||||||
"Conn %d is to %s:%d.", i,
|
"Conn %d is to %s:%d.", i,
|
||||||
safe_str_client(conn->address),
|
safe_str_client(conn->address),
|
||||||
conn->port);
|
conn->port);
|
||||||
log(severity,LD_GENERAL,
|
tor_log(severity,LD_GENERAL,
|
||||||
"Conn %d: %d bytes waiting on inbuf (len %d, last read %d secs ago)",
|
"Conn %d: %d bytes waiting on inbuf (len %d, last read %d secs ago)",
|
||||||
i,
|
i,
|
||||||
(int)connection_get_inbuf_len(conn),
|
(int)connection_get_inbuf_len(conn),
|
||||||
(int)buf_allocation(conn->inbuf),
|
(int)buf_allocation(conn->inbuf),
|
||||||
(int)(now - conn->timestamp_lastread));
|
(int)(now - conn->timestamp_lastread));
|
||||||
log(severity,LD_GENERAL,
|
tor_log(severity,LD_GENERAL,
|
||||||
"Conn %d: %d bytes waiting on outbuf "
|
"Conn %d: %d bytes waiting on outbuf "
|
||||||
"(len %d, last written %d secs ago)",i,
|
"(len %d, last written %d secs ago)",i,
|
||||||
(int)connection_get_outbuf_len(conn),
|
(int)connection_get_outbuf_len(conn),
|
||||||
@ -2164,7 +2164,7 @@ dumpstats(int severity)
|
|||||||
if (or_conn->tls) {
|
if (or_conn->tls) {
|
||||||
tor_tls_get_buffer_sizes(or_conn->tls, &rbuf_cap, &rbuf_len,
|
tor_tls_get_buffer_sizes(or_conn->tls, &rbuf_cap, &rbuf_len,
|
||||||
&wbuf_cap, &wbuf_len);
|
&wbuf_cap, &wbuf_len);
|
||||||
log(severity, LD_GENERAL,
|
tor_log(severity, LD_GENERAL,
|
||||||
"Conn %d: %d/%d bytes used on OpenSSL read buffer; "
|
"Conn %d: %d/%d bytes used on OpenSSL read buffer; "
|
||||||
"%d/%d bytes used on write buffer.",
|
"%d/%d bytes used on write buffer.",
|
||||||
i, (int)rbuf_len, (int)rbuf_cap, (int)wbuf_len, (int)wbuf_cap);
|
i, (int)rbuf_len, (int)rbuf_cap, (int)wbuf_len, (int)wbuf_cap);
|
||||||
@ -2178,7 +2178,7 @@ dumpstats(int severity)
|
|||||||
channel_dumpstats(severity);
|
channel_dumpstats(severity);
|
||||||
channel_listener_dumpstats(severity);
|
channel_listener_dumpstats(severity);
|
||||||
|
|
||||||
log(severity, LD_NET,
|
tor_log(severity, LD_NET,
|
||||||
"Cells processed: "U64_FORMAT" padding\n"
|
"Cells processed: "U64_FORMAT" padding\n"
|
||||||
" "U64_FORMAT" create\n"
|
" "U64_FORMAT" create\n"
|
||||||
" "U64_FORMAT" created\n"
|
" "U64_FORMAT" created\n"
|
||||||
@ -2194,11 +2194,11 @@ dumpstats(int severity)
|
|||||||
U64_PRINTF_ARG(stats_n_relay_cells_delivered),
|
U64_PRINTF_ARG(stats_n_relay_cells_delivered),
|
||||||
U64_PRINTF_ARG(stats_n_destroy_cells_processed));
|
U64_PRINTF_ARG(stats_n_destroy_cells_processed));
|
||||||
if (stats_n_data_cells_packaged)
|
if (stats_n_data_cells_packaged)
|
||||||
log(severity,LD_NET,"Average packaged cell fullness: %2.3f%%",
|
tor_log(severity,LD_NET,"Average packaged cell fullness: %2.3f%%",
|
||||||
100*(U64_TO_DBL(stats_n_data_bytes_packaged) /
|
100*(U64_TO_DBL(stats_n_data_bytes_packaged) /
|
||||||
U64_TO_DBL(stats_n_data_cells_packaged*RELAY_PAYLOAD_SIZE)) );
|
U64_TO_DBL(stats_n_data_cells_packaged*RELAY_PAYLOAD_SIZE)) );
|
||||||
if (stats_n_data_cells_received)
|
if (stats_n_data_cells_received)
|
||||||
log(severity,LD_NET,"Average delivered cell fullness: %2.3f%%",
|
tor_log(severity,LD_NET,"Average delivered cell fullness: %2.3f%%",
|
||||||
100*(U64_TO_DBL(stats_n_data_bytes_received) /
|
100*(U64_TO_DBL(stats_n_data_bytes_received) /
|
||||||
U64_TO_DBL(stats_n_data_cells_received*RELAY_PAYLOAD_SIZE)) );
|
U64_TO_DBL(stats_n_data_cells_received*RELAY_PAYLOAD_SIZE)) );
|
||||||
|
|
||||||
@ -2211,19 +2211,19 @@ dumpstats(int severity)
|
|||||||
elapsed = 0;
|
elapsed = 0;
|
||||||
|
|
||||||
if (elapsed) {
|
if (elapsed) {
|
||||||
log(severity, LD_NET,
|
tor_log(severity, LD_NET,
|
||||||
"Average bandwidth: "U64_FORMAT"/%d = %d bytes/sec reading",
|
"Average bandwidth: "U64_FORMAT"/%d = %d bytes/sec reading",
|
||||||
U64_PRINTF_ARG(stats_n_bytes_read),
|
U64_PRINTF_ARG(stats_n_bytes_read),
|
||||||
(int)elapsed,
|
(int)elapsed,
|
||||||
(int) (stats_n_bytes_read/elapsed));
|
(int) (stats_n_bytes_read/elapsed));
|
||||||
log(severity, LD_NET,
|
tor_log(severity, LD_NET,
|
||||||
"Average bandwidth: "U64_FORMAT"/%d = %d bytes/sec writing",
|
"Average bandwidth: "U64_FORMAT"/%d = %d bytes/sec writing",
|
||||||
U64_PRINTF_ARG(stats_n_bytes_written),
|
U64_PRINTF_ARG(stats_n_bytes_written),
|
||||||
(int)elapsed,
|
(int)elapsed,
|
||||||
(int) (stats_n_bytes_written/elapsed));
|
(int) (stats_n_bytes_written/elapsed));
|
||||||
}
|
}
|
||||||
|
|
||||||
log(severity, LD_NET, "--------------- Dumping memory information:");
|
tor_log(severity, LD_NET, "--------------- Dumping memory information:");
|
||||||
dumpmemusage(severity);
|
dumpmemusage(severity);
|
||||||
|
|
||||||
rep_hist_dump_stats(now,severity);
|
rep_hist_dump_stats(now,severity);
|
||||||
@ -2364,7 +2364,7 @@ tor_init(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef NON_ANONYMOUS_MODE_ENABLED
|
#ifdef NON_ANONYMOUS_MODE_ENABLED
|
||||||
log(LOG_WARN, LD_GENERAL, "This copy of Tor was compiled to run in a "
|
log_warn(LD_GENERAL, "This copy of Tor was compiled to run in a "
|
||||||
"non-anonymous mode. It will provide NO ANONYMITY.");
|
"non-anonymous mode. It will provide NO ANONYMITY.");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -561,7 +561,7 @@ networkstatus_check_consensus_signature(networkstatus_t *consensus,
|
|||||||
if (warn >= 0) {
|
if (warn >= 0) {
|
||||||
SMARTLIST_FOREACH(unrecognized, networkstatus_voter_info_t *, voter,
|
SMARTLIST_FOREACH(unrecognized, networkstatus_voter_info_t *, voter,
|
||||||
{
|
{
|
||||||
log(severity, LD_DIR, "Consensus includes unrecognized authority "
|
tor_log(severity, LD_DIR, "Consensus includes unrecognized authority "
|
||||||
"'%s' at %s:%d (contact %s; identity %s)",
|
"'%s' at %s:%d (contact %s; identity %s)",
|
||||||
voter->nickname, voter->address, (int)voter->dir_port,
|
voter->nickname, voter->address, (int)voter->dir_port,
|
||||||
voter->contact?voter->contact:"n/a",
|
voter->contact?voter->contact:"n/a",
|
||||||
@ -569,7 +569,7 @@ networkstatus_check_consensus_signature(networkstatus_t *consensus,
|
|||||||
});
|
});
|
||||||
SMARTLIST_FOREACH(need_certs_from, networkstatus_voter_info_t *, voter,
|
SMARTLIST_FOREACH(need_certs_from, networkstatus_voter_info_t *, voter,
|
||||||
{
|
{
|
||||||
log(severity, LD_DIR, "Looks like we need to download a new "
|
tor_log(severity, LD_DIR, "Looks like we need to download a new "
|
||||||
"certificate from authority '%s' at %s:%d (contact %s; "
|
"certificate from authority '%s' at %s:%d (contact %s; "
|
||||||
"identity %s)",
|
"identity %s)",
|
||||||
voter->nickname, voter->address, (int)voter->dir_port,
|
voter->nickname, voter->address, (int)voter->dir_port,
|
||||||
@ -578,7 +578,7 @@ networkstatus_check_consensus_signature(networkstatus_t *consensus,
|
|||||||
});
|
});
|
||||||
SMARTLIST_FOREACH(missing_authorities, dir_server_t *, ds,
|
SMARTLIST_FOREACH(missing_authorities, dir_server_t *, ds,
|
||||||
{
|
{
|
||||||
log(severity, LD_DIR, "Consensus does not include configured "
|
tor_log(severity, LD_DIR, "Consensus does not include configured "
|
||||||
"authority '%s' at %s:%d (identity %s)",
|
"authority '%s' at %s:%d (identity %s)",
|
||||||
ds->nickname, ds->address, (int)ds->dir_port,
|
ds->nickname, ds->address, (int)ds->dir_port,
|
||||||
hex_str(ds->v3_identity_digest, DIGEST_LEN));
|
hex_str(ds->v3_identity_digest, DIGEST_LEN));
|
||||||
@ -614,7 +614,7 @@ networkstatus_check_consensus_signature(networkstatus_t *consensus,
|
|||||||
"because we were missing the keys.", n_missing_key);
|
"because we were missing the keys.", n_missing_key);
|
||||||
}
|
}
|
||||||
joined = smartlist_join_strings(sl, " ", 0, NULL);
|
joined = smartlist_join_strings(sl, " ", 0, NULL);
|
||||||
log(severity, LD_DIR, "%s", joined);
|
tor_log(severity, LD_DIR, "%s", joined);
|
||||||
tor_free(joined);
|
tor_free(joined);
|
||||||
SMARTLIST_FOREACH(sl, char *, c, tor_free(c));
|
SMARTLIST_FOREACH(sl, char *, c, tor_free(c));
|
||||||
smartlist_free(sl);
|
smartlist_free(sl);
|
||||||
|
@ -1463,14 +1463,14 @@ update_router_have_minimum_dir_info(void)
|
|||||||
|
|
||||||
done:
|
done:
|
||||||
if (res && !have_min_dir_info) {
|
if (res && !have_min_dir_info) {
|
||||||
log(LOG_NOTICE, LD_DIR,
|
log_notice(LD_DIR,
|
||||||
"We now have enough directory information to build circuits.");
|
"We now have enough directory information to build circuits.");
|
||||||
control_event_client_status(LOG_NOTICE, "ENOUGH_DIR_INFO");
|
control_event_client_status(LOG_NOTICE, "ENOUGH_DIR_INFO");
|
||||||
control_event_bootstrap(BOOTSTRAP_STATUS_CONN_OR, 0);
|
control_event_bootstrap(BOOTSTRAP_STATUS_CONN_OR, 0);
|
||||||
}
|
}
|
||||||
if (!res && have_min_dir_info) {
|
if (!res && have_min_dir_info) {
|
||||||
int quiet = directory_too_idle_to_fetch_descriptors(options, now);
|
int quiet = directory_too_idle_to_fetch_descriptors(options, now);
|
||||||
log(quiet ? LOG_INFO : LOG_NOTICE, LD_DIR,
|
tor_log(quiet ? LOG_INFO : LOG_NOTICE, LD_DIR,
|
||||||
"Our directory information is no longer up-to-date "
|
"Our directory information is no longer up-to-date "
|
||||||
"enough to build circuits: %s", dir_info_status);
|
"enough to build circuits: %s", dir_info_status);
|
||||||
|
|
||||||
|
@ -881,7 +881,7 @@ exit_policy_remove_redundancies(smartlist_t *dest)
|
|||||||
char p1[POLICY_BUF_LEN], p2[POLICY_BUF_LEN];
|
char p1[POLICY_BUF_LEN], p2[POLICY_BUF_LEN];
|
||||||
policy_write_item(p1, sizeof(p1), tmp, 0);
|
policy_write_item(p1, sizeof(p1), tmp, 0);
|
||||||
policy_write_item(p2, sizeof(p2), ap, 0);
|
policy_write_item(p2, sizeof(p2), ap, 0);
|
||||||
log(LOG_DEBUG, LD_CONFIG, "Removing exit policy %s (%d). It is made "
|
log_debug(LD_CONFIG, "Removing exit policy %s (%d). It is made "
|
||||||
"redundant by %s (%d).", p1, j, p2, i);
|
"redundant by %s (%d).", p1, j, p2, i);
|
||||||
smartlist_del_keeporder(dest, j--);
|
smartlist_del_keeporder(dest, j--);
|
||||||
addr_policy_free(tmp);
|
addr_policy_free(tmp);
|
||||||
@ -910,7 +910,7 @@ exit_policy_remove_redundancies(smartlist_t *dest)
|
|||||||
char p1[POLICY_BUF_LEN], p2[POLICY_BUF_LEN];
|
char p1[POLICY_BUF_LEN], p2[POLICY_BUF_LEN];
|
||||||
policy_write_item(p1, sizeof(p1), ap, 0);
|
policy_write_item(p1, sizeof(p1), ap, 0);
|
||||||
policy_write_item(p2, sizeof(p2), tmp, 0);
|
policy_write_item(p2, sizeof(p2), tmp, 0);
|
||||||
log(LOG_DEBUG, LD_CONFIG, "Removing exit policy %s. It is already "
|
log_debug(LD_CONFIG, "Removing exit policy %s. It is already "
|
||||||
"covered by %s.", p1, p2);
|
"covered by %s.", p1, p2);
|
||||||
smartlist_del_keeporder(dest, i--);
|
smartlist_del_keeporder(dest, i--);
|
||||||
addr_policy_free(ap);
|
addr_policy_free(ap);
|
||||||
|
@ -2024,8 +2024,9 @@ dump_cell_pool_usage(int severity)
|
|||||||
n_cells += TO_OR_CIRCUIT(c)->p_chan_cells.n;
|
n_cells += TO_OR_CIRCUIT(c)->p_chan_cells.n;
|
||||||
++n_circs;
|
++n_circs;
|
||||||
}
|
}
|
||||||
log(severity, LD_MM, "%d cells allocated on %d circuits. %d cells leaked.",
|
tor_log(severity, LD_MM,
|
||||||
n_cells, n_circs, total_cells_allocated - n_cells);
|
"%d cells allocated on %d circuits. %d cells leaked.",
|
||||||
|
n_cells, n_circs, total_cells_allocated - n_cells);
|
||||||
mp_pool_log_status(cell_pool, severity);
|
mp_pool_log_status(cell_pool, severity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3304,7 +3304,7 @@ rend_service_dump_stats(int severity)
|
|||||||
|
|
||||||
for (i=0; i < smartlist_len(rend_service_list); ++i) {
|
for (i=0; i < smartlist_len(rend_service_list); ++i) {
|
||||||
service = smartlist_get(rend_service_list, i);
|
service = smartlist_get(rend_service_list, i);
|
||||||
log(severity, LD_GENERAL, "Service configured in \"%s\":",
|
tor_log(severity, LD_GENERAL, "Service configured in \"%s\":",
|
||||||
service->directory);
|
service->directory);
|
||||||
for (j=0; j < smartlist_len(service->intro_nodes); ++j) {
|
for (j=0; j < smartlist_len(service->intro_nodes); ++j) {
|
||||||
intro = smartlist_get(service->intro_nodes, j);
|
intro = smartlist_get(service->intro_nodes, j);
|
||||||
@ -3312,11 +3312,11 @@ rend_service_dump_stats(int severity)
|
|||||||
|
|
||||||
circ = find_intro_circuit(intro, service->pk_digest);
|
circ = find_intro_circuit(intro, service->pk_digest);
|
||||||
if (!circ) {
|
if (!circ) {
|
||||||
log(severity, LD_GENERAL, " Intro point %d at %s: no circuit",
|
tor_log(severity, LD_GENERAL, " Intro point %d at %s: no circuit",
|
||||||
j, safe_name);
|
j, safe_name);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
log(severity, LD_GENERAL, " Intro point %d at %s: circuit is %s",
|
tor_log(severity, LD_GENERAL, " Intro point %d at %s: circuit is %s",
|
||||||
j, safe_name, circuit_state_to_string(circ->base_.state));
|
j, safe_name, circuit_state_to_string(circ->base_.state));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -648,7 +648,7 @@ rep_hist_dump_stats(time_t now, int severity)
|
|||||||
|
|
||||||
rep_history_clean(now - get_options()->RephistTrackTime);
|
rep_history_clean(now - get_options()->RephistTrackTime);
|
||||||
|
|
||||||
log(severity, LD_HIST, "--------------- Dumping history information:");
|
tor_log(severity, LD_HIST, "--------------- Dumping history information:");
|
||||||
|
|
||||||
for (orhist_it = digestmap_iter_init(history_map);
|
for (orhist_it = digestmap_iter_init(history_map);
|
||||||
!digestmap_iter_done(orhist_it);
|
!digestmap_iter_done(orhist_it);
|
||||||
@ -673,7 +673,7 @@ rep_hist_dump_stats(time_t now, int severity)
|
|||||||
} else {
|
} else {
|
||||||
uptime=1.0;
|
uptime=1.0;
|
||||||
}
|
}
|
||||||
log(severity, LD_HIST,
|
tor_log(severity, LD_HIST,
|
||||||
"OR %s [%s]: %ld/%ld good connections; uptime %ld/%ld sec (%.2f%%); "
|
"OR %s [%s]: %ld/%ld good connections; uptime %ld/%ld sec (%.2f%%); "
|
||||||
"wmtbf %lu:%02lu:%02lu",
|
"wmtbf %lu:%02lu:%02lu",
|
||||||
name1, hexdigest1,
|
name1, hexdigest1,
|
||||||
@ -707,7 +707,7 @@ rep_hist_dump_stats(time_t now, int severity)
|
|||||||
else
|
else
|
||||||
len += ret;
|
len += ret;
|
||||||
}
|
}
|
||||||
log(severity, LD_HIST, "%s", buffer);
|
tor_log(severity, LD_HIST, "%s", buffer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2042,7 +2042,7 @@ note_crypto_pk_op(pk_op_t operation)
|
|||||||
void
|
void
|
||||||
dump_pk_ops(int severity)
|
dump_pk_ops(int severity)
|
||||||
{
|
{
|
||||||
log(severity, LD_HIST,
|
tor_log(severity, LD_HIST,
|
||||||
"PK operations: %lu directory objects signed, "
|
"PK operations: %lu directory objects signed, "
|
||||||
"%lu directory objects verified, "
|
"%lu directory objects verified, "
|
||||||
"%lu routerdescs signed, "
|
"%lu routerdescs signed, "
|
||||||
|
@ -391,14 +391,14 @@ init_key_from_file(const char *fname, int generate, int severity)
|
|||||||
crypto_pk_t *prkey = NULL;
|
crypto_pk_t *prkey = NULL;
|
||||||
|
|
||||||
if (!(prkey = crypto_pk_new())) {
|
if (!(prkey = crypto_pk_new())) {
|
||||||
log(severity, LD_GENERAL,"Error constructing key");
|
tor_log(severity, LD_GENERAL,"Error constructing key");
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (file_status(fname)) {
|
switch (file_status(fname)) {
|
||||||
case FN_DIR:
|
case FN_DIR:
|
||||||
case FN_ERROR:
|
case FN_ERROR:
|
||||||
log(severity, LD_FS,"Can't read key from \"%s\"", fname);
|
tor_log(severity, LD_FS,"Can't read key from \"%s\"", fname);
|
||||||
goto error;
|
goto error;
|
||||||
case FN_NOENT:
|
case FN_NOENT:
|
||||||
if (generate) {
|
if (generate) {
|
||||||
@ -406,8 +406,8 @@ init_key_from_file(const char *fname, int generate, int severity)
|
|||||||
if (try_locking(get_options(), 0)<0) {
|
if (try_locking(get_options(), 0)<0) {
|
||||||
/* Make sure that --list-fingerprint only creates new keys
|
/* Make sure that --list-fingerprint only creates new keys
|
||||||
* if there is no possibility for a deadlock. */
|
* if there is no possibility for a deadlock. */
|
||||||
log(severity, LD_FS, "Another Tor process has locked \"%s\". Not "
|
tor_log(severity, LD_FS, "Another Tor process has locked \"%s\". "
|
||||||
"writing any new keys.", fname);
|
"Not writing any new keys.", fname);
|
||||||
/*XXXX The 'other process' might make a key in a second or two;
|
/*XXXX The 'other process' might make a key in a second or two;
|
||||||
* maybe we should wait for it. */
|
* maybe we should wait for it. */
|
||||||
goto error;
|
goto error;
|
||||||
@ -416,16 +416,16 @@ init_key_from_file(const char *fname, int generate, int severity)
|
|||||||
log_info(LD_GENERAL, "No key found in \"%s\"; generating fresh key.",
|
log_info(LD_GENERAL, "No key found in \"%s\"; generating fresh key.",
|
||||||
fname);
|
fname);
|
||||||
if (crypto_pk_generate_key(prkey)) {
|
if (crypto_pk_generate_key(prkey)) {
|
||||||
log(severity, LD_GENERAL,"Error generating onion key");
|
tor_log(severity, LD_GENERAL,"Error generating onion key");
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
if (crypto_pk_check_key(prkey) <= 0) {
|
if (crypto_pk_check_key(prkey) <= 0) {
|
||||||
log(severity, LD_GENERAL,"Generated key seems invalid");
|
tor_log(severity, LD_GENERAL,"Generated key seems invalid");
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
log_info(LD_GENERAL, "Generated key seems valid");
|
log_info(LD_GENERAL, "Generated key seems valid");
|
||||||
if (crypto_pk_write_private_key_to_filename(prkey, fname)) {
|
if (crypto_pk_write_private_key_to_filename(prkey, fname)) {
|
||||||
log(severity, LD_FS,
|
tor_log(severity, LD_FS,
|
||||||
"Couldn't write generated key to \"%s\".", fname);
|
"Couldn't write generated key to \"%s\".", fname);
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
@ -435,7 +435,7 @@ init_key_from_file(const char *fname, int generate, int severity)
|
|||||||
return prkey;
|
return prkey;
|
||||||
case FN_FILE:
|
case FN_FILE:
|
||||||
if (crypto_pk_read_private_key_from_filename(prkey, fname)) {
|
if (crypto_pk_read_private_key_from_filename(prkey, fname)) {
|
||||||
log(severity, LD_GENERAL,"Error loading private key.");
|
tor_log(severity, LD_GENERAL,"Error loading private key.");
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
return prkey;
|
return prkey;
|
||||||
@ -465,7 +465,7 @@ init_curve25519_keypair_from_file(curve25519_keypair_t *keys_out,
|
|||||||
switch (file_status(fname)) {
|
switch (file_status(fname)) {
|
||||||
case FN_DIR:
|
case FN_DIR:
|
||||||
case FN_ERROR:
|
case FN_ERROR:
|
||||||
log(severity, LD_FS,"Can't read key from \"%s\"", fname);
|
tor_log(severity, LD_FS,"Can't read key from \"%s\"", fname);
|
||||||
goto error;
|
goto error;
|
||||||
case FN_NOENT:
|
case FN_NOENT:
|
||||||
if (generate) {
|
if (generate) {
|
||||||
@ -473,8 +473,8 @@ init_curve25519_keypair_from_file(curve25519_keypair_t *keys_out,
|
|||||||
if (try_locking(get_options(), 0)<0) {
|
if (try_locking(get_options(), 0)<0) {
|
||||||
/* Make sure that --list-fingerprint only creates new keys
|
/* Make sure that --list-fingerprint only creates new keys
|
||||||
* if there is no possibility for a deadlock. */
|
* if there is no possibility for a deadlock. */
|
||||||
log(severity, LD_FS, "Another Tor process has locked \"%s\". Not "
|
tor_log(severity, LD_FS, "Another Tor process has locked \"%s\". "
|
||||||
"writing any new keys.", fname);
|
"Not writing any new keys.", fname);
|
||||||
/*XXXX The 'other process' might make a key in a second or two;
|
/*XXXX The 'other process' might make a key in a second or two;
|
||||||
* maybe we should wait for it. */
|
* maybe we should wait for it. */
|
||||||
goto error;
|
goto error;
|
||||||
@ -485,7 +485,7 @@ init_curve25519_keypair_from_file(curve25519_keypair_t *keys_out,
|
|||||||
if (curve25519_keypair_generate(keys_out, 1) < 0)
|
if (curve25519_keypair_generate(keys_out, 1) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
if (curve25519_keypair_write_to_file(keys_out, fname, tag)<0) {
|
if (curve25519_keypair_write_to_file(keys_out, fname, tag)<0) {
|
||||||
log(severity, LD_FS,
|
tor_log(severity, LD_FS,
|
||||||
"Couldn't write generated key to \"%s\".", fname);
|
"Couldn't write generated key to \"%s\".", fname);
|
||||||
memset(keys_out, 0, sizeof(*keys_out));
|
memset(keys_out, 0, sizeof(*keys_out));
|
||||||
goto error;
|
goto error;
|
||||||
@ -498,12 +498,12 @@ init_curve25519_keypair_from_file(curve25519_keypair_t *keys_out,
|
|||||||
{
|
{
|
||||||
char *tag_in=NULL;
|
char *tag_in=NULL;
|
||||||
if (curve25519_keypair_read_from_file(keys_out, &tag_in, fname) < 0) {
|
if (curve25519_keypair_read_from_file(keys_out, &tag_in, fname) < 0) {
|
||||||
log(severity, LD_GENERAL,"Error loading private key.");
|
tor_log(severity, LD_GENERAL,"Error loading private key.");
|
||||||
tor_free(tag_in);
|
tor_free(tag_in);
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
if (!tag_in || strcmp(tag_in, tag)) {
|
if (!tag_in || strcmp(tag_in, tag)) {
|
||||||
log(severity, LD_GENERAL,"Unexpected tag %s on private key.",
|
tor_log(severity, LD_GENERAL,"Unexpected tag %s on private key.",
|
||||||
escaped(tag_in));
|
escaped(tag_in));
|
||||||
tor_free(tag_in);
|
tor_free(tag_in);
|
||||||
goto error;
|
goto error;
|
||||||
@ -631,14 +631,14 @@ v3_authority_check_key_expiry(void)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if (time_left <= 0) {
|
if (time_left <= 0) {
|
||||||
log(badness, LD_DIR, "Your v3 authority certificate has expired."
|
tor_log(badness, LD_DIR, "Your v3 authority certificate has expired."
|
||||||
" Generate a new one NOW.");
|
" Generate a new one NOW.");
|
||||||
} else if (time_left <= 24*60*60) {
|
} else if (time_left <= 24*60*60) {
|
||||||
log(badness, LD_DIR, "Your v3 authority certificate expires in %d hours;"
|
tor_log(badness, LD_DIR, "Your v3 authority certificate expires in %d "
|
||||||
" Generate a new one NOW.", time_left/(60*60));
|
"hours; Generate a new one NOW.", time_left/(60*60));
|
||||||
} else {
|
} else {
|
||||||
log(badness, LD_DIR, "Your v3 authority certificate expires in %d days;"
|
tor_log(badness, LD_DIR, "Your v3 authority certificate expires in %d "
|
||||||
" Generate a new one soon.", time_left/(24*60*60));
|
"days; Generate a new one soon.", time_left/(24*60*60));
|
||||||
}
|
}
|
||||||
last_warned = now;
|
last_warned = now;
|
||||||
}
|
}
|
||||||
@ -902,7 +902,7 @@ init_keys(void)
|
|||||||
tor_free(cp);
|
tor_free(cp);
|
||||||
tor_free(keydir);
|
tor_free(keydir);
|
||||||
|
|
||||||
log(LOG_NOTICE, LD_GENERAL,
|
log_notice(LD_GENERAL,
|
||||||
"Your Tor server's identity key fingerprint is '%s %s'",
|
"Your Tor server's identity key fingerprint is '%s %s'",
|
||||||
options->Nickname, fingerprint);
|
options->Nickname, fingerprint);
|
||||||
if (!authdir_mode(options))
|
if (!authdir_mode(options))
|
||||||
@ -1062,10 +1062,10 @@ decide_to_advertise_dirport(const or_options_t *options, uint16_t dir_port)
|
|||||||
|
|
||||||
if (advertising != new_choice) {
|
if (advertising != new_choice) {
|
||||||
if (new_choice == 1) {
|
if (new_choice == 1) {
|
||||||
log(LOG_NOTICE, LD_DIR, "Advertising DirPort as %d", dir_port);
|
log_notice(LD_DIR, "Advertising DirPort as %d", dir_port);
|
||||||
} else {
|
} else {
|
||||||
tor_assert(reason);
|
tor_assert(reason);
|
||||||
log(LOG_NOTICE, LD_DIR, "Not advertising DirPort (Reason: %s)", reason);
|
log_notice(LD_DIR, "Not advertising DirPort (Reason: %s)", reason);
|
||||||
}
|
}
|
||||||
advertising = new_choice;
|
advertising = new_choice;
|
||||||
}
|
}
|
||||||
|
@ -2647,7 +2647,7 @@ dump_routerlist_mem_usage(int severity)
|
|||||||
SMARTLIST_FOREACH(routerlist->old_routers, signed_descriptor_t *, sd,
|
SMARTLIST_FOREACH(routerlist->old_routers, signed_descriptor_t *, sd,
|
||||||
olddescs += sd->signed_descriptor_len);
|
olddescs += sd->signed_descriptor_len);
|
||||||
|
|
||||||
log(severity, LD_DIR,
|
tor_log(severity, LD_DIR,
|
||||||
"In %d live descriptors: "U64_FORMAT" bytes. "
|
"In %d live descriptors: "U64_FORMAT" bytes. "
|
||||||
"In %d old descriptors: "U64_FORMAT" bytes.",
|
"In %d old descriptors: "U64_FORMAT" bytes.",
|
||||||
smartlist_len(routerlist->routers), U64_PRINTF_ARG(livedescs),
|
smartlist_len(routerlist->routers), U64_PRINTF_ARG(livedescs),
|
||||||
|
@ -1029,7 +1029,7 @@ dump_distinct_digest_count(int severity)
|
|||||||
#ifdef COUNT_DISTINCT_DIGESTS
|
#ifdef COUNT_DISTINCT_DIGESTS
|
||||||
if (!verified_digests)
|
if (!verified_digests)
|
||||||
verified_digests = digestmap_new();
|
verified_digests = digestmap_new();
|
||||||
log(severity, LD_GENERAL, "%d *distinct* router digests verified",
|
tor_log(severity, LD_GENERAL, "%d *distinct* router digests verified",
|
||||||
digestmap_size(verified_digests));
|
digestmap_size(verified_digests));
|
||||||
#else
|
#else
|
||||||
(void)severity; /* suppress "unused parameter" warning */
|
(void)severity; /* suppress "unused parameter" warning */
|
||||||
|
@ -95,7 +95,7 @@ routerset_refresh_countries(routerset_t *target)
|
|||||||
tor_assert(cc < target->n_countries);
|
tor_assert(cc < target->n_countries);
|
||||||
bitarray_set(target->countries, cc);
|
bitarray_set(target->countries, cc);
|
||||||
} else {
|
} else {
|
||||||
log(LOG_WARN, LD_CONFIG, "Country code '%s' is not recognized.",
|
log_warn(LD_CONFIG, "Country code '%s' is not recognized.",
|
||||||
country);
|
country);
|
||||||
}
|
}
|
||||||
} SMARTLIST_FOREACH_END(country);
|
} SMARTLIST_FOREACH_END(country);
|
||||||
|
@ -108,7 +108,7 @@ log_heartbeat(time_t now)
|
|||||||
uptime, count_circuits(),bw_sent,bw_rcvd);
|
uptime, count_circuits(),bw_sent,bw_rcvd);
|
||||||
|
|
||||||
if (stats_n_data_cells_packaged)
|
if (stats_n_data_cells_packaged)
|
||||||
log(LOG_NOTICE, LD_HEARTBEAT, "Average packaged cell fullness: %2.3f%%",
|
log_notice(LD_HEARTBEAT, "Average packaged cell fullness: %2.3f%%",
|
||||||
100*(U64_TO_DBL(stats_n_data_bytes_packaged) /
|
100*(U64_TO_DBL(stats_n_data_bytes_packaged) /
|
||||||
U64_TO_DBL(stats_n_data_cells_packaged*RELAY_PAYLOAD_SIZE)) );
|
U64_TO_DBL(stats_n_data_cells_packaged*RELAY_PAYLOAD_SIZE)) );
|
||||||
|
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#include <tchar.h>
|
#include <tchar.h>
|
||||||
#endif
|
#endif
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
/* XXXX this is a minimal wrapper to make the unit tests compile with the
|
/* XXXX this is a minimal wrapper to make the unit tests compile with the
|
||||||
* changed tor_timegm interface. */
|
* changed tor_timegm interface. */
|
||||||
@ -3240,6 +3241,20 @@ test_util_set_env_var_in_sl(void *ptr)
|
|||||||
smartlist_free(expected_resulting_env_vars);
|
smartlist_free(expected_resulting_env_vars);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
test_util_mathlog(void *arg)
|
||||||
|
{
|
||||||
|
double d;
|
||||||
|
(void) arg;
|
||||||
|
|
||||||
|
d = tor_mathlog(2.718281828);
|
||||||
|
tt_double_op(fabs(d - 1.0), <, .000001);
|
||||||
|
d = tor_mathlog(10);
|
||||||
|
tt_double_op(fabs(d - 2.30258509), <, .000001);
|
||||||
|
done:
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
#define UTIL_LEGACY(name) \
|
#define UTIL_LEGACY(name) \
|
||||||
{ #name, legacy_test_helper, 0, &legacy_setup, test_util_ ## name }
|
{ #name, legacy_test_helper, 0, &legacy_setup, test_util_ ## name }
|
||||||
|
|
||||||
@ -3296,6 +3311,7 @@ struct testcase_t util_tests[] = {
|
|||||||
UTIL_TEST(read_file_eof_tiny_limit, 0),
|
UTIL_TEST(read_file_eof_tiny_limit, 0),
|
||||||
UTIL_TEST(read_file_eof_two_loops, 0),
|
UTIL_TEST(read_file_eof_two_loops, 0),
|
||||||
UTIL_TEST(read_file_eof_zero_bytes, 0),
|
UTIL_TEST(read_file_eof_zero_bytes, 0),
|
||||||
|
UTIL_TEST(mathlog, 0),
|
||||||
END_OF_TESTCASES
|
END_OF_TESTCASES
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -82,10 +82,11 @@ crypto_log_errors(int severity, const char *doing)
|
|||||||
if (!lib) lib = "(null)";
|
if (!lib) lib = "(null)";
|
||||||
if (!func) func = "(null)";
|
if (!func) func = "(null)";
|
||||||
if (doing) {
|
if (doing) {
|
||||||
log(severity, LD_CRYPTO, "crypto error while %s: %s (in %s:%s)",
|
tor_log(severity, LD_CRYPTO, "crypto error while %s: %s (in %s:%s)",
|
||||||
doing, msg, lib, func);
|
doing, msg, lib, func);
|
||||||
} else {
|
} else {
|
||||||
log(severity, LD_CRYPTO, "crypto error: %s (in %s:%s)", msg, lib, func);
|
tor_log(severity, LD_CRYPTO, "crypto error: %s (in %s:%s)",
|
||||||
|
msg, lib, func);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user