summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--changes/bug11075
-rw-r--r--changes/bug12225
-rw-r--r--changes/bug9194
-rw-r--r--changes/bug9284
-rw-r--r--changes/nowhereland6
-rw-r--r--changes/relays_as_bridges5
-rw-r--r--src/or/circuituse.c8
-rw-r--r--src/or/config.c25
-rw-r--r--src/or/geoip.c51
-rw-r--r--src/or/routerlist.c27
-rw-r--r--src/test/test.c6
11 files changed, 105 insertions, 41 deletions
diff --git a/changes/bug1107 b/changes/bug1107
new file mode 100644
index 0000000000..c396b5d68a
--- /dev/null
+++ b/changes/bug1107
@@ -0,0 +1,5 @@
+ o Minor bugfixes:
+ - Complain if PublishServerDescriptor is given multiple arguments that
+ include 0 or 1. This configuration will be rejected in future.
+ Bugfix in 0.2.0.1-alpha, closes bug 1107.
+
diff --git a/changes/bug1222 b/changes/bug1222
new file mode 100644
index 0000000000..66d24def9c
--- /dev/null
+++ b/changes/bug1222
@@ -0,0 +1,5 @@
+ o Minor bugfixes:
+ - #1222: Change "Application request when we're believed to be
+ offline." notice to "Application request when we haven't used
+ client functionality lately.", to clarify that it's not an error.
+
diff --git a/changes/bug919 b/changes/bug919
new file mode 100644
index 0000000000..728b821a95
--- /dev/null
+++ b/changes/bug919
@@ -0,0 +1,4 @@
+ o Minor bugfixes:
+ - Fix a regression that caused Tor to rebind its ports if it receives
+ SIGHUP while hibernating. Bugfix in 0.1.1.6-alpha, closes bug 919.
+
diff --git a/changes/bug928 b/changes/bug928
new file mode 100644
index 0000000000..4f9fc5fe35
--- /dev/null
+++ b/changes/bug928
@@ -0,0 +1,4 @@
+ o Minor bugfixes:
+ - Disallow BridgeRelay 1 and ORPort 0 configuration.
+ Bugfix in 0.2.0.13-alpha, closes bug 928.
+
diff --git a/changes/nowhereland b/changes/nowhereland
new file mode 100644
index 0000000000..5435e965e9
--- /dev/null
+++ b/changes/nowhereland
@@ -0,0 +1,6 @@
+ o Minor features:
+ - Add support for the country code "{??}" in torrc options like
+ ExcludeNodes, to indicate all routers of unknown country. Fixes bug
+ 1094.
+
+
diff --git a/changes/relays_as_bridges b/changes/relays_as_bridges
new file mode 100644
index 0000000000..6e8afb005b
--- /dev/null
+++ b/changes/relays_as_bridges
@@ -0,0 +1,5 @@
+ o Minor bugfixes:
+ - Allow the use of regular relays as bridges. To achieve this, replace
+ routers with a purpose other than bridge with bridge descriptors when
+ fetching them. Bugfix on 0.1.1.9-alpha; fixes bug 1776.
+
diff --git a/src/or/circuituse.c b/src/or/circuituse.c
index a3f10a8841..63742da307 100644
--- a/src/or/circuituse.c
+++ b/src/or/circuituse.c
@@ -1184,13 +1184,13 @@ circuit_get_open_circ_or_launch(edge_connection_t *conn,
* as loudly. the user doesn't even know it's happening. */
if (options->UseBridges && bridges_known_but_down()) {
log_fn(severity, LD_APP|LD_DIR,
- "Application request when we're believed to be "
- "offline. Optimistically trying known bridges again.");
+ "Application request when we haven't used client functionality "
+ "lately. Optimistically trying known bridges again.");
bridges_retry_all();
} else if (!options->UseBridges || any_bridge_descriptors_known()) {
log_fn(severity, LD_APP|LD_DIR,
- "Application request when we're believed to be "
- "offline. Optimistically trying directory fetches again.");
+ "Application request when we haven't used client functionality "
+ "lately. Optimistically trying directory fetches again.");
routerlist_retry_directory_downloads(time(NULL));
}
}
diff --git a/src/or/config.c b/src/or/config.c
index 0a26c84be7..77cd518b1d 100644
--- a/src/or/config.c
+++ b/src/or/config.c
@@ -950,10 +950,12 @@ options_act_reversible(or_options_t *old_options, char **msg)
}
/* Launch the listeners. (We do this before we setuid, so we can bind to
- * ports under 1024.) */
- if (retry_all_listeners(replaced_listeners, new_listeners) < 0) {
- *msg = tor_strdup("Failed to bind one of the listener ports.");
- goto rollback;
+ * ports under 1024.) We don't want to rebind if we're hibernating. */
+ if (!we_are_hibernating()) {
+ if (retry_all_listeners(replaced_listeners, new_listeners) < 0) {
+ *msg = tor_strdup("Failed to bind one of the listener ports.");
+ goto rollback;
+ }
}
}
@@ -3607,6 +3609,21 @@ options_validate(or_options_t *old_options, or_options_t *options,
if (options->AccelDir && !options->AccelName)
REJECT("Can't use hardware crypto accelerator dir without engine name.");
+ if (options->PublishServerDescriptor)
+ SMARTLIST_FOREACH(options->PublishServerDescriptor, const char *, pubdes, {
+ if (!strcmp(pubdes, "1") || !strcmp(pubdes, "0"))
+ if (smartlist_len(options->PublishServerDescriptor) > 1) {
+ COMPLAIN("You have passed a list of multiple arguments to the "
+ "PublishServerDescriptor option that includes 0 or 1. "
+ "0 or 1 should only be used as the sole argument. "
+ "This configuration will be rejected in a future release.");
+ break;
+ }
+ });
+
+ if (options->BridgeRelay == 1 && options->ORPort == 0)
+ REJECT("BridgeRelay is 1, ORPort is 0. This is an invalid combination.");
+
return 0;
#undef REJECT
#undef COMPLAIN
diff --git a/src/or/geoip.c b/src/or/geoip.c
index eae927522a..8c218ef27f 100644
--- a/src/or/geoip.c
+++ b/src/or/geoip.c
@@ -17,6 +17,7 @@
#include "routerlist.h"
static void clear_geoip_db(void);
+static void init_geoip_countries(void);
/** An entry from the GeoIP file: maps an IP range to a country. */
typedef struct geoip_entry_t {
@@ -106,11 +107,11 @@ geoip_parse_entry(const char *line)
{
unsigned int low, high;
char b[3];
- if (!geoip_countries) {
- geoip_countries = smartlist_create();
+ if (!geoip_countries)
+ init_geoip_countries();
+ if (!geoip_entries)
geoip_entries = smartlist_create();
- country_idxplus1_by_lc_code = strmap_new();
- }
+
while (TOR_ISSPACE(*line))
++line;
if (*line == '#')
@@ -165,6 +166,24 @@ should_record_bridge_info(or_options_t *options)
return options->BridgeRelay && options->BridgeRecordUsageByCountry;
}
+/** Set up a new list of geoip countries with no countries (yet) set in it,
+ * except for the unknown country.
+ */
+static void
+init_geoip_countries(void)
+{
+ geoip_country_t *geoip_unresolved;
+ geoip_countries = smartlist_create();
+ /* Add a geoip_country_t for requests that could not be resolved to a
+ * country as first element (index 0) to geoip_countries. */
+ geoip_unresolved = tor_malloc_zero(sizeof(geoip_country_t));
+ strlcpy(geoip_unresolved->countrycode, "??",
+ sizeof(geoip_unresolved->countrycode));
+ smartlist_add(geoip_countries, geoip_unresolved);
+ country_idxplus1_by_lc_code = strmap_new();
+ strmap_set_lc(country_idxplus1_by_lc_code, "??", (void*)(1));
+}
+
/** Clear the GeoIP database and reload it from the file
* <b>filename</b>. Return 0 on success, -1 on failure.
*
@@ -190,17 +209,8 @@ geoip_load_file(const char *filename, or_options_t *options)
filename, msg);
return -1;
}
- if (!geoip_countries) {
- geoip_country_t *geoip_unresolved;
- geoip_countries = smartlist_create();
- /* Add a geoip_country_t for requests that could not be resolved to a
- * country as first element (index 0) to geoip_countries. */
- geoip_unresolved = tor_malloc_zero(sizeof(geoip_country_t));
- strlcpy(geoip_unresolved->countrycode, "??",
- sizeof(geoip_unresolved->countrycode));
- smartlist_add(geoip_countries, geoip_unresolved);
- country_idxplus1_by_lc_code = strmap_new();
- }
+ if (!geoip_countries)
+ init_geoip_countries();
if (geoip_entries) {
SMARTLIST_FOREACH(geoip_entries, geoip_entry_t *, e, tor_free(e));
smartlist_free(geoip_entries);
@@ -227,9 +237,10 @@ geoip_load_file(const char *filename, or_options_t *options)
}
/** Given an IP address in host order, return a number representing the
- * country to which that address belongs, or -1 for unknown. The return value
- * will always be less than geoip_get_n_countries(). To decode it,
- * call geoip_get_country_name().
+ * country to which that address belongs, -1 for "No geoip information
+ * available", or 0 for the 'unknown country'. The return value will always
+ * be less than geoip_get_n_countries(). To decode it, call
+ * geoip_get_country_name().
*/
int
geoip_get_country_by_ip(uint32_t ipaddr)
@@ -238,7 +249,7 @@ geoip_get_country_by_ip(uint32_t ipaddr)
if (!geoip_entries)
return -1;
ent = smartlist_bsearch(geoip_entries, &ipaddr, _geoip_compare_key_to_entry);
- return ent ? (int)ent->country : -1;
+ return ent ? (int)ent->country : 0;
}
/** Return the number of countries recognized by the GeoIP database. */
@@ -417,7 +428,7 @@ geoip_note_client_seen(geoip_client_action_t action,
if (options->BridgeRelay) {
while (current_request_period_starts + REQUEST_HIST_PERIOD < now) {
if (!geoip_countries)
- geoip_countries = smartlist_create();
+ init_geoip_countries();
if (!current_request_period_starts) {
current_request_period_starts = now;
break;
diff --git a/src/or/routerlist.c b/src/or/routerlist.c
index 5f98abe01b..8808f56db9 100644
--- a/src/or/routerlist.c
+++ b/src/or/routerlist.c
@@ -3151,15 +3151,23 @@ router_add_to_routerlist(routerinfo_t *router, const char **msg,
id_digest = router->cache_info.identity_digest;
+ old_router = router_get_by_digest(id_digest);
+
/* Make sure that we haven't already got this exact descriptor. */
if (sdmap_get(routerlist->desc_digest_map,
router->cache_info.signed_descriptor_digest)) {
- log_info(LD_DIR,
- "Dropping descriptor that we already have for router '%s'",
- router->nickname);
- *msg = "Router descriptor was not new.";
- routerinfo_free(router);
- return ROUTER_WAS_NOT_NEW;
+ /* If we have this descriptor already and the new descriptor is a bridge
+ * descriptor, replace it. If we had a bridge descriptor before and the
+ * new one is not a bridge descriptor, don't replace it. */
+ if (old_router && (!routerinfo_is_a_configured_bridge(router) ||
+ routerinfo_is_a_configured_bridge(old_router))) {
+ log_info(LD_DIR,
+ "Dropping descriptor that we already have for router '%s'",
+ router->nickname);
+ *msg = "Router descriptor was not new.";
+ routerinfo_free(router);
+ return ROUTER_WAS_NOT_NEW;
+ }
}
if (authdir) {
@@ -3196,15 +3204,14 @@ router_add_to_routerlist(routerinfo_t *router, const char **msg,
SMARTLIST_FOREACH(networkstatus_v2_list, networkstatus_v2_t *, ns,
{
routerstatus_t *rs =
- networkstatus_v2_find_entry(ns, router->cache_info.identity_digest);
+ networkstatus_v2_find_entry(ns, id_digest);
if (rs && !memcmp(rs->descriptor_digest,
router->cache_info.signed_descriptor_digest,
DIGEST_LEN))
rs->need_to_mirror = 0;
});
if (consensus) {
- routerstatus_t *rs = networkstatus_vote_find_entry(consensus,
- router->cache_info.identity_digest);
+ routerstatus_t *rs = networkstatus_vote_find_entry(consensus, id_digest);
if (rs && !memcmp(rs->descriptor_digest,
router->cache_info.signed_descriptor_digest,
DIGEST_LEN)) {
@@ -3226,8 +3233,6 @@ router_add_to_routerlist(routerinfo_t *router, const char **msg,
}
/* If we have a router with the same identity key, choose the newer one. */
- old_router = rimap_get(routerlist->identity_map,
- router->cache_info.identity_digest);
if (old_router) {
if (!in_consensus && (router->cache_info.published_on <=
old_router->cache_info.published_on)) {
diff --git a/src/test/test.c b/src/test/test.c
index 755d1233f6..0830f57946 100644
--- a/src/test/test.c
+++ b/src/test/test.c
@@ -1108,10 +1108,12 @@ test_geoip(void)
test_eq(0, geoip_parse_entry("\"150\",\"190\",\"XY\""));
test_eq(0, geoip_parse_entry("\"200\",\"250\",\"AB\""));
- /* We should have 3 countries: ab, xy, zz. */
- test_eq(3, geoip_get_n_countries());
+ /* We should have 4 countries: ??, ab, xy, zz. */
+ test_eq(4, geoip_get_n_countries());
/* Make sure that country ID actually works. */
#define NAMEFOR(x) geoip_get_country_name(geoip_get_country_by_ip(x))
+ test_streq("??", NAMEFOR(3));
+ test_eq(0, geoip_get_country_by_ip(3));
test_streq("ab", NAMEFOR(32));
test_streq("??", NAMEFOR(5));
test_streq("??", NAMEFOR(51));