mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-30 15:43:32 +01:00
touchups all over
put uptime in descriptor svn:r2011
This commit is contained in:
parent
5284826a05
commit
cbf73b2bc5
@ -259,8 +259,6 @@ static int config_assign(or_options_t *options, struct config_line_t *list) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* XXX are there any other specifiers we want to give so making
|
|
||||||
* a several-thousand-byte string is less painful? */
|
|
||||||
const char default_dirservers_string[] =
|
const char default_dirservers_string[] =
|
||||||
"router moria1 18.244.0.188 9001 9021 9031\n"
|
"router moria1 18.244.0.188 9001 9021 9031\n"
|
||||||
"platform Tor 0.0.6rc1 on Linux moria.mit.edu i686\n"
|
"platform Tor 0.0.6rc1 on Linux moria.mit.edu i686\n"
|
||||||
@ -380,15 +378,16 @@ int config_assign_default_dirservers(void) {
|
|||||||
|
|
||||||
/** Set <b>options</b> to a reasonable default.
|
/** Set <b>options</b> to a reasonable default.
|
||||||
*
|
*
|
||||||
* Call this function when they're using the default torrc but
|
* Call this function when we can't find any torrc config file.
|
||||||
* we can't find it. For now, we just hard-code what comes in the
|
|
||||||
* default torrc.
|
|
||||||
*/
|
*/
|
||||||
static int config_assign_default(or_options_t *options) {
|
static int config_assign_defaults(or_options_t *options) {
|
||||||
|
|
||||||
/* set them up as a client only */
|
/* set them up as a client only */
|
||||||
options->SocksPort = 9050;
|
options->SocksPort = 9050;
|
||||||
|
|
||||||
|
config_free_lines(options->ExitPolicy);
|
||||||
|
options->ExitPolicy = config_line_prepend(NULL, "ExitPolicy", "reject *:*");
|
||||||
|
|
||||||
/* plus give them a dirservers file */
|
/* plus give them a dirservers file */
|
||||||
if(config_assign_default_dirservers() < 0)
|
if(config_assign_default_dirservers() < 0)
|
||||||
return -1;
|
return -1;
|
||||||
@ -585,7 +584,7 @@ int getconfig(int argc, char **argv, or_options_t *options) {
|
|||||||
if(!cf) {
|
if(!cf) {
|
||||||
if(using_default_torrc == 1) {
|
if(using_default_torrc == 1) {
|
||||||
log(LOG_NOTICE, "Configuration file '%s' not present, using reasonable defaults.",fname);
|
log(LOG_NOTICE, "Configuration file '%s' not present, using reasonable defaults.",fname);
|
||||||
if(config_assign_default(options) < 0)
|
if(config_assign_defaults(options) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
} else {
|
} else {
|
||||||
log(LOG_WARN, "Unable to open configuration file '%s'.",fname);
|
log(LOG_WARN, "Unable to open configuration file '%s'.",fname);
|
||||||
@ -631,13 +630,6 @@ int getconfig(int argc, char **argv, or_options_t *options) {
|
|||||||
result = -1;
|
result = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
|
||||||
if(options->ORPort && options->DataDirectory == NULL) {
|
|
||||||
log(LOG_WARN,"DataDirectory option required if ORPort is set, but not found.");
|
|
||||||
result = -1;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (options->ORPort) {
|
if (options->ORPort) {
|
||||||
if (options->Nickname == NULL) {
|
if (options->Nickname == NULL) {
|
||||||
log_fn(LOG_WARN,"Nickname required if ORPort is set, but not found.");
|
log_fn(LOG_WARN,"Nickname required if ORPort is set, but not found.");
|
||||||
@ -676,7 +668,7 @@ int getconfig(int argc, char **argv, or_options_t *options) {
|
|||||||
result = -1;
|
result = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(options->DirPort && options->RecommendedVersions == NULL) {
|
if(options->AuthoritativeDir && options->RecommendedVersions == NULL) {
|
||||||
log(LOG_WARN,"Directory servers must configure RecommendedVersions.");
|
log(LOG_WARN,"Directory servers must configure RecommendedVersions.");
|
||||||
result = -1;
|
result = -1;
|
||||||
}
|
}
|
||||||
|
@ -235,8 +235,9 @@ void connection_close_immediate(connection_t *conn)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (conn->outbuf_flushlen) {
|
if (conn->outbuf_flushlen) {
|
||||||
log_fn(LOG_INFO,"Closing connection (fd %d, type %s, state %d) with data on outbuf.",
|
log_fn(LOG_INFO,"fd %d, type %s, state %d, %d bytes on outbuf.",
|
||||||
conn->s, CONN_TYPE_TO_STRING(conn->type), conn->state);
|
conn->s, CONN_TYPE_TO_STRING(conn->type),
|
||||||
|
conn->state, conn->outbuf_flushlen);
|
||||||
}
|
}
|
||||||
tor_close_socket(conn->s);
|
tor_close_socket(conn->s);
|
||||||
conn->s = -1;
|
conn->s = -1;
|
||||||
|
@ -28,7 +28,7 @@ static int stats_prev_global_read_bucket;
|
|||||||
/** How many bytes have we read since we started the process? */
|
/** How many bytes have we read since we started the process? */
|
||||||
static uint64_t stats_n_bytes_read = 0;
|
static uint64_t stats_n_bytes_read = 0;
|
||||||
/** How many seconds have we been running? */
|
/** How many seconds have we been running? */
|
||||||
static long stats_n_seconds_reading = 0;
|
long stats_n_seconds_uptime = 0;
|
||||||
|
|
||||||
/** Array of all open connections; each element corresponds to the element of
|
/** Array of all open connections; each element corresponds to the element of
|
||||||
* poll_array in the same position. The first nfds elements are valid. */
|
* poll_array in the same position. The first nfds elements are valid. */
|
||||||
@ -536,7 +536,7 @@ static int prepare_for_poll(void) {
|
|||||||
|
|
||||||
if(now.tv_sec > current_second) { /* the second has rolled over. check more stuff. */
|
if(now.tv_sec > current_second) { /* the second has rolled over. check more stuff. */
|
||||||
|
|
||||||
++stats_n_seconds_reading;
|
++stats_n_seconds_uptime;
|
||||||
assert_all_pending_dns_resolves_ok();
|
assert_all_pending_dns_resolves_ok();
|
||||||
run_scheduled_events(now.tv_sec);
|
run_scheduled_events(now.tv_sec);
|
||||||
assert_all_pending_dns_resolves_ok();
|
assert_all_pending_dns_resolves_ok();
|
||||||
@ -844,9 +844,9 @@ static void dumpstats(int severity) {
|
|||||||
100*(((double)stats_n_data_bytes_received) /
|
100*(((double)stats_n_data_bytes_received) /
|
||||||
(stats_n_data_cells_received*RELAY_PAYLOAD_SIZE)) );
|
(stats_n_data_cells_received*RELAY_PAYLOAD_SIZE)) );
|
||||||
|
|
||||||
if (stats_n_seconds_reading)
|
if (stats_n_seconds_uptime)
|
||||||
log(severity,"Average bandwidth used: %d bytes/sec",
|
log(severity,"Average bandwidth used: %d bytes/sec",
|
||||||
(int) (stats_n_bytes_read/stats_n_seconds_reading));
|
(int) (stats_n_bytes_read/stats_n_seconds_uptime));
|
||||||
|
|
||||||
rep_hist_dump_stats(now,severity);
|
rep_hist_dump_stats(now,severity);
|
||||||
rend_service_dump_stats(severity);
|
rend_service_dump_stats(severity);
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
**/
|
**/
|
||||||
|
|
||||||
extern or_options_t options; /* command-line and config-file options */
|
extern or_options_t options; /* command-line and config-file options */
|
||||||
|
extern long stats_n_seconds_uptime;
|
||||||
|
|
||||||
/** Exposed for test.c. */ void get_platform_str(char *platform, int len);
|
/** Exposed for test.c. */ void get_platform_str(char *platform, int len);
|
||||||
|
|
||||||
@ -474,7 +475,8 @@ int router_rebuild_descriptor(void) {
|
|||||||
*/
|
*/
|
||||||
void get_platform_str(char *platform, int len)
|
void get_platform_str(char *platform, int len)
|
||||||
{
|
{
|
||||||
snprintf(platform, len-1, "Tor %s on %s", VERSION, get_uname());
|
snprintf(platform, len-1, "Tor %s (up %ld sec) on %s",
|
||||||
|
VERSION, stats_n_seconds_uptime, get_uname());
|
||||||
platform[len-1] = '\0';
|
platform[len-1] = '\0';
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -124,7 +124,7 @@ void add_nickname_list_to_smartlist(smartlist_t *sl, const char *list) {
|
|||||||
if (router->is_running)
|
if (router->is_running)
|
||||||
smartlist_add(sl,router);
|
smartlist_add(sl,router);
|
||||||
else
|
else
|
||||||
log_fn(LOG_INFO,"Nickname list includes '%s' which is known but down.",nick);
|
log_fn(LOG_WARN,"Nickname list includes '%s' which is known but down.",nick);
|
||||||
} else
|
} else
|
||||||
log_fn(has_fetched_directory ? LOG_WARN : LOG_INFO,
|
log_fn(has_fetched_directory ? LOG_WARN : LOG_INFO,
|
||||||
"Nickname list includes '%s' which isn't a known router.",nick);
|
"Nickname list includes '%s' which isn't a known router.",nick);
|
||||||
|
Loading…
Reference in New Issue
Block a user