mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-24 04:13:28 +01:00
Make new logging stuff work on windows; fix a couple of windows typos.
svn:r5375
This commit is contained in:
parent
4cd7bddfc3
commit
9b432311c4
@ -757,7 +757,7 @@ get_uname(void)
|
||||
tor_snprintf(uname_result, sizeof(uname_result),
|
||||
"Unrecognized version of Windows [major=%d,minor=%d] %s",
|
||||
(int)info.dwMajorVersion,(int)info.dwMinorVersion,
|
||||
infor.szCSDVersion);
|
||||
info.szCSDVersion);
|
||||
}
|
||||
if (info.wProductType == VER_NT_DOMAIN_CONTROLLER) {
|
||||
strlcat(uname_result, " [domain controller]", sizeof(uname_result));
|
||||
@ -768,7 +768,7 @@ get_uname(void)
|
||||
}
|
||||
leftover_mask = info.wSuiteMask;
|
||||
for (i = 0; win_mask_table[i].mask; ++i) {
|
||||
if (info.wSuiteMask & win_mask_table[i]) {
|
||||
if (info.wSuiteMask & win_mask_table[i].mask) {
|
||||
strlcat(uname_result, win_mask_table[i].str, sizeof(uname_result));
|
||||
leftover_mask &= ~win_mask_table[i].mask;
|
||||
}
|
||||
|
@ -264,47 +264,47 @@ _log_fn(int severity, uint32_t domain, const char *format, ...)
|
||||
_log_fn_function_name = NULL;
|
||||
}
|
||||
void
|
||||
_debug(uint32_t domain, const char *format, ...)
|
||||
debug(uint32_t domain, const char *format, ...)
|
||||
{
|
||||
va_list ap;
|
||||
va_start(ap,format);
|
||||
logv(LOG_DEBUG, domain, _log_fn_function_name, format, ap);
|
||||
logv(LOG_DEBUG, domain, NULL, format, ap);
|
||||
va_end(ap);
|
||||
_log_fn_function_name = NULL;
|
||||
}
|
||||
void
|
||||
_info(uint32_t domain, const char *format, ...)
|
||||
info(uint32_t domain, const char *format, ...)
|
||||
{
|
||||
va_list ap;
|
||||
va_start(ap,format);
|
||||
logv(LOG_INFO, domain, _log_fn_function_name, format, ap);
|
||||
logv(LOG_INFO, domain, NULL, format, ap);
|
||||
va_end(ap);
|
||||
_log_fn_function_name = NULL;
|
||||
}
|
||||
void
|
||||
_notice(uint32_t domain, const char *format, ...)
|
||||
notice(uint32_t domain, const char *format, ...)
|
||||
{
|
||||
va_list ap;
|
||||
va_start(ap,format);
|
||||
logv(LOG_NOTICE, domain, _log_fn_function_name, format, ap);
|
||||
logv(LOG_NOTICE, domain, NULL, format, ap);
|
||||
va_end(ap);
|
||||
_log_fn_function_name = NULL;
|
||||
}
|
||||
void
|
||||
_warn(uint32_t domain, const char *format, ...)
|
||||
warn(uint32_t domain, const char *format, ...)
|
||||
{
|
||||
va_list ap;
|
||||
va_start(ap,format);
|
||||
logv(LOG_WARN, domain, _log_fn_function_name, format, ap);
|
||||
logv(LOG_WARN, domain, NULL, format, ap);
|
||||
va_end(ap);
|
||||
_log_fn_function_name = NULL;
|
||||
}
|
||||
void
|
||||
_err(uint32_t domain, const char *format, ...)
|
||||
err(uint32_t domain, const char *format, ...)
|
||||
{
|
||||
va_list ap;
|
||||
va_start(ap,format);
|
||||
logv(LOG_ERR, domain, _log_fn_function_name, format, ap);
|
||||
logv(LOG_ERR, domain, NULL, format, ap);
|
||||
va_end(ap);
|
||||
_log_fn_function_name = NULL;
|
||||
}
|
||||
|
@ -138,20 +138,22 @@ void _log_fn(int severity, uint32_t domain,
|
||||
#else /* ! defined(__GNUC__) */
|
||||
|
||||
void _log_fn(int severity, uint32_t domain, const char *format, ...);
|
||||
void _debug(uint32_t domain, const char *format, ...);
|
||||
void _info(uint32_t domain, const char *format, ...);
|
||||
void _notice(uint32_t domain, const char *format, ...);
|
||||
void _warn(uint32_t domain, const char *format, ...);
|
||||
void _err(uint32_t domain, const char *format, ...);
|
||||
void debug(uint32_t domain, const char *format, ...);
|
||||
void info(uint32_t domain, const char *format, ...);
|
||||
void notice(uint32_t domain, const char *format, ...);
|
||||
void warn(uint32_t domain, const char *format, ...);
|
||||
void err(uint32_t domain, const char *format, ...);
|
||||
|
||||
#if defined(_MSC_VER) && _MSC_VER < 1300
|
||||
/* MSVC 6 and earlier don't have __FUNCTION__, or even __LINE__. */
|
||||
#define log_fn _log_fn
|
||||
/*
|
||||
#define debug _debug
|
||||
#define info _info
|
||||
#define notice _notice
|
||||
#define warn _warn
|
||||
#define err _err
|
||||
*/
|
||||
#else
|
||||
/* We don't have GCC's varargs macros, so use a global variable to pass the
|
||||
* function name to log_fn */
|
||||
@ -160,11 +162,13 @@ extern const char *_log_fn_function_name;
|
||||
* do {...} while (0) trick to wrap this macro, since the macro can't take
|
||||
* arguments. */
|
||||
#define log_fn (_log_fn_function_name=__FUNCTION__),_log_fn
|
||||
/*
|
||||
#define debug (_log_fn_function_name=__FUNCTION__),_debug
|
||||
#define info (_log_fn_function_name=__FUNCTION__),_info
|
||||
#define notice (_log_fn_function_name=__FUNCTION__),_notice
|
||||
#define warn (_log_fn_function_name=__FUNCTION__),_warn
|
||||
#define err (_log_fn_function_name=__FUNCTION__),_err
|
||||
*/
|
||||
#endif
|
||||
|
||||
#endif /* !GNUC */
|
||||
|
@ -433,7 +433,7 @@ find_whitespace(const char *s)
|
||||
err: \
|
||||
if (ok) *ok = 0; \
|
||||
if (next) *next = endptr; \
|
||||
return 0;
|
||||
return 0
|
||||
|
||||
/** Extract a long from the start of s, in the given numeric base. If
|
||||
* there is unconverted data and next is provided, set *next to the
|
||||
@ -1249,7 +1249,7 @@ tor_listdir(const char *dirname)
|
||||
smartlist_add(result, tor_strdup(findData.cFileName));
|
||||
if (!FindNextFile(handle, &findData)) {
|
||||
if (GetLastError() != ERROR_NO_MORE_FILES) {
|
||||
log_fn(LOG_WARN, "Error reading directory.");
|
||||
warn(LD_FS, "Error reading directory.");
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -743,7 +743,7 @@ circuit_launch_by_router(uint8_t purpose, routerinfo_t *exit,
|
||||
* last hop need not be an exit node. Return the newly allocated circuit on
|
||||
* success, or NULL on failure. */
|
||||
circuit_t *
|
||||
circuit_launch_by_extend_info(uint8_t purpose, extend_info_t *info,
|
||||
circuit_launch_by_extend_info(uint8_t purpose, extend_info_t *extend_info,
|
||||
int need_uptime, int need_capacity, int internal)
|
||||
{
|
||||
circuit_t *circ;
|
||||
@ -753,10 +753,10 @@ circuit_launch_by_extend_info(uint8_t purpose, extend_info_t *info,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if ((info || purpose != CIRCUIT_PURPOSE_C_GENERAL) &&
|
||||
if ((extend_info || purpose != CIRCUIT_PURPOSE_C_GENERAL) &&
|
||||
purpose != CIRCUIT_PURPOSE_TESTING) {
|
||||
/* see if there are appropriate circs available to cannibalize. */
|
||||
circ = circuit_find_to_cannibalize(CIRCUIT_PURPOSE_C_GENERAL, info,
|
||||
circ = circuit_find_to_cannibalize(CIRCUIT_PURPOSE_C_GENERAL, extend_info,
|
||||
need_uptime, need_capacity, internal);
|
||||
if (circ) {
|
||||
info(LD_CIRC,"Cannibalizing circ '%s' for purpose %d",
|
||||
@ -775,8 +775,8 @@ circuit_launch_by_extend_info(uint8_t purpose, extend_info_t *info,
|
||||
case CIRCUIT_PURPOSE_S_CONNECT_REND:
|
||||
case CIRCUIT_PURPOSE_C_GENERAL:
|
||||
/* need to add a new hop */
|
||||
tor_assert(info);
|
||||
if (circuit_extend_to_new_exit(circ, info) < 0)
|
||||
tor_assert(extend_info);
|
||||
if (circuit_extend_to_new_exit(circ, extend_info) < 0)
|
||||
return NULL;
|
||||
break;
|
||||
default:
|
||||
@ -796,7 +796,7 @@ circuit_launch_by_extend_info(uint8_t purpose, extend_info_t *info,
|
||||
}
|
||||
|
||||
/* try a circ. if it fails, circuit_mark_for_close will increment n_circuit_failures */
|
||||
return circuit_establish_circuit(purpose, info,
|
||||
return circuit_establish_circuit(purpose, extend_info,
|
||||
need_uptime, need_capacity, internal);
|
||||
}
|
||||
|
||||
|
@ -1567,7 +1567,7 @@ nt_service_control(DWORD request)
|
||||
void
|
||||
nt_service_body(int argc, char **argv)
|
||||
{
|
||||
int err;
|
||||
int r;
|
||||
service_status.dwServiceType = SERVICE_WIN32_OWN_PROCESS;
|
||||
service_status.dwCurrentState = SERVICE_START_PENDING;
|
||||
service_status.dwControlsAccepted =
|
||||
@ -1585,21 +1585,21 @@ nt_service_body(int argc, char **argv)
|
||||
|
||||
// check for torrc
|
||||
if (nt_torrc_is_present()) {
|
||||
err = tor_init(backup_argc, backup_argv); // refactor this part out of tor_main and do_main_loop
|
||||
if (err) {
|
||||
err = NT_SERVICE_ERROR_TORINIT_FAILED;
|
||||
r = tor_init(backup_argc, backup_argv); // refactor this part out of tor_main and do_main_loop
|
||||
if (r) {
|
||||
r = NT_SERVICE_ERROR_TORINIT_FAILED;
|
||||
}
|
||||
}
|
||||
else {
|
||||
err(LD_CONFIG, "torrc is not in the current working directory. The Tor service will not start.");
|
||||
err = NT_SERVICE_ERROR_NO_TORRC;
|
||||
r = NT_SERVICE_ERROR_NO_TORRC;
|
||||
}
|
||||
|
||||
if (err) {
|
||||
if (r) {
|
||||
// failed.
|
||||
service_status.dwCurrentState = SERVICE_STOPPED;
|
||||
service_status.dwWin32ExitCode = err;
|
||||
service_status.dwServiceSpecificExitCode = err;
|
||||
service_status.dwWin32ExitCode = r;
|
||||
service_status.dwServiceSpecificExitCode = r;
|
||||
SetServiceStatus(hStatus, &service_status);
|
||||
return;
|
||||
}
|
||||
|
@ -216,10 +216,10 @@ rend_client_introduction_acked(circuit_t *circ,
|
||||
circ->rend_query) > 0) {
|
||||
/* There are introduction points left. Re-extend the circuit to
|
||||
* another intro point and try again. */
|
||||
extend_info_t *info;
|
||||
extend_info_t *extend_info;
|
||||
int result;
|
||||
info = rend_client_get_random_intro(circ->rend_query);
|
||||
if (!info) {
|
||||
extend_info = rend_client_get_random_intro(circ->rend_query);
|
||||
if (!extend_info) {
|
||||
warn(LD_REND, "No introduction points left for %s. Closing.",
|
||||
safe_str(circ->rend_query));
|
||||
circuit_mark_for_close(circ);
|
||||
@ -229,9 +229,9 @@ rend_client_introduction_acked(circuit_t *circ,
|
||||
"Got nack for %s from %s. Re-extending circ %d, this time to %s.",
|
||||
safe_str(circ->rend_query),
|
||||
circ->build_state->chosen_exit->nickname, circ->n_circ_id,
|
||||
info->nickname);
|
||||
result = circuit_extend_to_new_exit(circ, info);
|
||||
extend_info_free(info);
|
||||
extend_info->nickname);
|
||||
result = circuit_extend_to_new_exit(circ, extend_info);
|
||||
extend_info_free(extend_info);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
@ -2348,12 +2348,12 @@ policy_includes_addr_mask_implicitly(addr_policy_t *policy,
|
||||
}
|
||||
|
||||
/** If <b>policy</b> implicitly allows connections to any port on
|
||||
* 127.*, 192.168.*, etc, then warn (if <b>warn</b> is set) and return
|
||||
* 127.*, 192.168.*, etc, then warn (if <b>should_warn</b> is set) and return
|
||||
* true. Else return false.
|
||||
**/
|
||||
int
|
||||
exit_policy_implicitly_allows_local_networks(addr_policy_t *policy,
|
||||
int warn)
|
||||
int should_warn)
|
||||
{
|
||||
addr_policy_t *p;
|
||||
int r=0,i;
|
||||
@ -2372,7 +2372,7 @@ exit_policy_implicitly_allows_local_networks(addr_policy_t *policy,
|
||||
/* log_fn(LOG_INFO,"Checking network %s", private_networks[i].network); */
|
||||
if (policy_includes_addr_mask_implicitly(
|
||||
policy, private_networks[i].addr, private_networks[i].mask, &p)) {
|
||||
if (warn)
|
||||
if (should_warn)
|
||||
warn(LD_CONFIG, "Exit policy %s implicitly accepts %s",
|
||||
p?p->string:"(default)",
|
||||
private_networks[i].network);
|
||||
|
Loading…
Reference in New Issue
Block a user