mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-27 13:53:31 +01:00
Inform the server operator when we decide not to advertise a
DirPort due to AccountingMax enabled or a low BandwidthRate. It was confusing Zax, so now we're hopefully more helpful. svn:r9404
This commit is contained in:
parent
75db2a61cb
commit
9d5449c52e
@ -52,6 +52,9 @@ Changes in version 0.1.2.7-alpha - 2007-??-??
|
|||||||
this by setting ServerDNSAllowNonRFC953Addresses to 1.
|
this by setting ServerDNSAllowNonRFC953Addresses to 1.
|
||||||
- Adapt a patch from goodell to let the contrib/exitlist script
|
- Adapt a patch from goodell to let the contrib/exitlist script
|
||||||
take arguments rather than require direct editing.
|
take arguments rather than require direct editing.
|
||||||
|
- Inform the server operator when we decide not to advertise a
|
||||||
|
DirPort due to AccountingMax enabled or a low BandwidthRate. It
|
||||||
|
was confusing Zax, so now we're hopefully more helpful.
|
||||||
|
|
||||||
o Minor features (controller):
|
o Minor features (controller):
|
||||||
- Track reasons for OR connection failure; make these reasons available
|
- Track reasons for OR connection failure; make these reasons available
|
||||||
|
@ -410,10 +410,22 @@ check_whether_dirport_reachable(void)
|
|||||||
|
|
||||||
/** Look at a variety of factors, and return 0 if we don't want to
|
/** Look at a variety of factors, and return 0 if we don't want to
|
||||||
* advertise the fact that we have a DirPort open. Else return the
|
* advertise the fact that we have a DirPort open. Else return the
|
||||||
* DirPort we want to advertise. */
|
* DirPort we want to advertise.
|
||||||
|
*
|
||||||
|
* Log a helpful message if we change our mind about whether to publish
|
||||||
|
* a DirPort.
|
||||||
|
*/
|
||||||
static int
|
static int
|
||||||
decide_to_advertise_dirport(or_options_t *options, routerinfo_t *router)
|
decide_to_advertise_dirport(or_options_t *options, routerinfo_t *router)
|
||||||
{
|
{
|
||||||
|
static int advertising=1; /* start out assuming we will advertise */
|
||||||
|
int new_choice=1;
|
||||||
|
const char *reason = NULL;
|
||||||
|
|
||||||
|
/* Section one: reasons to publish or not publish that aren't
|
||||||
|
* worth mentioning to the user, either because they're obvious
|
||||||
|
* or because they're normal behavior. */
|
||||||
|
|
||||||
if (!router->dir_port) /* short circuit the rest of the function */
|
if (!router->dir_port) /* short circuit the rest of the function */
|
||||||
return 0;
|
return 0;
|
||||||
if (authdir_mode(options)) /* always publish */
|
if (authdir_mode(options)) /* always publish */
|
||||||
@ -422,15 +434,32 @@ decide_to_advertise_dirport(or_options_t *options, routerinfo_t *router)
|
|||||||
return 0;
|
return 0;
|
||||||
if (!check_whether_dirport_reachable())
|
if (!check_whether_dirport_reachable())
|
||||||
return 0;
|
return 0;
|
||||||
/* check if we might potentially hibernate. */
|
|
||||||
if (accounting_is_enabled(options))
|
|
||||||
return 0;
|
|
||||||
/* also check if we're advertising a small amount */
|
|
||||||
if (router->bandwidthrate <= 51200)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
/* Sounds like a great idea. Let's publish it. */
|
/* Section two: reasons to publish or not publish that the user
|
||||||
return router->dir_port;
|
* might find surprising. These are generally config options that
|
||||||
|
* make us choose not to publish. */
|
||||||
|
|
||||||
|
if (accounting_is_enabled(options)) {
|
||||||
|
/* if we might potentially hibernate */
|
||||||
|
new_choice = 0;
|
||||||
|
reason = "AccountingMax enabled";
|
||||||
|
} else if (router->bandwidthrate <= 51200) {
|
||||||
|
/* if we're advertising a small amount */
|
||||||
|
new_choice = 0;
|
||||||
|
reason = "BandwidthRate under 50KB";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (advertising != new_choice) {
|
||||||
|
if (new_choice == 1) {
|
||||||
|
log(LOG_NOTICE, LD_DIR, "Advertising DirPort as %d", router->dir_port);
|
||||||
|
} else {
|
||||||
|
tor_assert(reason);
|
||||||
|
log(LOG_NOTICE, LD_DIR, "Not advertising DirPort (Reason: %s)", reason);
|
||||||
|
}
|
||||||
|
advertising = new_choice;
|
||||||
|
}
|
||||||
|
|
||||||
|
return advertising ? router->dir_port : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Some time has passed, or we just got new directory information.
|
/** Some time has passed, or we just got new directory information.
|
||||||
|
Loading…
Reference in New Issue
Block a user