Commit Graph

11295 Commits

Author SHA1 Message Date
Nick Mathewson
d9847165e0 Merge remote-tracking branch 'origin/maint-0.2.3' 2012-10-04 10:05:55 -04:00
Roger Dingledine
10b43f4c46 pass the reason from the truncated cell to the controller
(rather than just always declaring that the reason is
END_CIRC_REASON_OR_CONN_CLOSED)

resolves bug 7039.
2012-10-03 23:56:34 -04:00
Roger Dingledine
e50fa0d6cb Refuse extra create cells with reason "resource limit"
In the past we had used reason "internal", which is more vague than
it needs to be. Resolves bug 7037.
2012-10-03 20:17:37 -04:00
Roger Dingledine
b1971d89c8 properly free the return values of rate_limit_log()
resolves bug 7022.
2012-10-03 13:15:27 -04:00
Roger Dingledine
05f6f8f26d actually use the rate-limiting string
previously we just allocated the string and then freed it.
2012-10-03 13:03:09 -04:00
Roger Dingledine
3d31771da9 Free some more still-in-use memory at exit 2012-10-03 12:46:09 -04:00
Roger Dingledine
65e85dba1b reformat; no actual changes 2012-10-02 21:03:01 -04:00
Roger Dingledine
0ca47825a7 and make the last commit compile 2012-10-02 20:50:57 -04:00
Nick Mathewson
78e8eb5f2d Fix compilation error left over from 1cbf45bed1. (Bug 7021) 2012-10-02 20:48:30 -04:00
Roger Dingledine
57b13ad5cc more consistently use [gs]et_uint8 2012-10-02 20:39:58 -04:00
Nick Mathewson
a80d8e09d3 The --version option should imply --quiet.
Patch from 'maker'.
2012-10-01 11:01:18 -04:00
Nick Mathewson
f128baf36c Add missing declaration so 6876 compiles 2012-09-28 12:03:37 -04:00
Nick Mathewson
5f494a363a Merge remote-tracking branch 'linus/enh6876_2' 2012-09-28 11:57:36 -04:00
Nick Mathewson
95d9f7e9cc Merge remote-tracking branch 'rransom/warn-about-hses-without-guards' 2012-09-25 12:39:00 -04:00
Roger Dingledine
dc014c9747 Merge branch 'maint-0.2.3' 2012-09-22 09:31:09 -04:00
Roger Dingledine
c88a4c51b4 add faravahar as our ninth v3 dir auth 2012-09-22 09:10:37 -04:00
Roger Dingledine
a2f57b9799 bump to 0.2.4.3-alpha-dev 2012-09-22 08:09:17 -04:00
Roger Dingledine
3355976bb4 bump to 0.2.4.3-alpha 2012-09-22 06:11:28 -04:00
Roger Dingledine
622f90904c 4aff97cfc didn't update the 'last modified' timestamp 2012-09-22 06:11:05 -04:00
Nick Mathewson
9d4c53534d Remove the testing_since* fields
They weren't actually used since 7a35dad00

Bug 5809
2012-09-21 22:05:09 -04:00
Nick Mathewson
cf182efe0d Fix comment in crypto.h; bug 6830 2012-09-21 21:55:06 -04:00
Nick Mathewson
b7fdb3a927 add changes file and whitespace fixes for bug 4020 2012-09-21 19:48:38 -04:00
Tom Fitzhenry
655782f302 Reinstate address in warning message when binding non-locally
bug4020

Signed-off-by: Tom Fitzhenry <tom@tom-fitzhenry.me.uk>
2012-09-21 19:44:49 -04:00
Linus Nordberg
613079fbc4 Don't leak msg when parse_virtual_addr_network() fails. 2012-09-20 17:15:15 +02:00
Linus Nordberg
1cbf45bed1 Make option OutboundBindAddress accept IPv6 addresses too.
Implements ticket 6786.
2012-09-20 17:09:25 +02:00
Linus Nordberg
ce553d4982 Have node_get_pref_orport() return an IPv6 OR port when UseBridges is set.
We used to never return an IPv6 address unless ClientUseIPv6 was
set. We should allow clients running with bridges use IPv6 OR ports
even without setting ClientUseIPv6. Configuring an IPv6 address in a
Bridge line should imply that.

Fixes th second part of #6757.
2012-09-19 17:18:06 +02:00
Linus Nordberg
9c5ba489d3 Set (and reset) node_t.ipv6_preferred for bridges based on Bridge lines.
We used to set it only when ClientPreferIPv6ORPort was set which seems
wrong.

Fixes one part of #6757.
2012-09-19 17:12:22 +02:00
Robert Ransom
38609f1354 Fix comment typo 2012-09-18 16:50:54 -04:00
Robert Ransom
130e899fbb Warn if HSes are configured on a client with UseEntryGuards disabled 2012-09-18 16:50:00 -04:00
Robert Ransom
d1c4cf2f5a Correct comment explaining why tor2web mode should disable entry guards 2012-09-18 16:38:01 -04:00
Mike Perry
acda1735fd Disable Guard usage for Tor2webMode.
Tor2webMode is fingerprintable by hidden services through repeated
usage of the same three guard nodes for its rend and intro points.
2012-09-18 16:21:35 -04:00
Nick Mathewson
704fd8bb02 Bump bug 6866 log messages back up to notice for 0.2.4 2012-09-18 16:21:24 -04:00
Nick Mathewson
920c76a2fc Merge remote-tracking branch 'origin/maint-0.2.3' 2012-09-18 16:20:01 -04:00
Nick Mathewson
aca325eb0c Whitespace fixes 2012-09-18 16:16:17 -04:00
Linus Nordberg
a989dbc3dc Print the correct address family in log printout.
Look at the address family of the preferred OR port rather than the
node.ipv6_preferred flag since the logic has changed with new
ClientUseIPv6 config option.

Fixes ticket 6884.
2012-09-18 14:41:14 +02:00
Mike Perry
4bfed4378d Bug 6866: Convert pathbias asserts into log messages.
Asserts were hit by Tor2Web mode.
2012-09-17 18:25:28 -07:00
Nick Mathewson
5dfec9f833 Merge remote-tracking branch 'linus/bug6880' 2012-09-17 16:05:09 -04:00
Linus Nordberg
bee1e46bd1 Don't do reachability testing over IPv6 unless AuthDirPublishIPv6 is set.
This affects both directory authorities and bridge authoritites.
2012-09-17 22:01:58 +02:00
Robert Ransom
1e5cd1c7d6 Fix comment typo in tor_memeq 2012-09-17 11:13:09 -04:00
Nick Mathewson
757b3b259e Add unit test for crypto_pk_cmp_keys and NULL 2012-09-17 11:04:56 -04:00
Robert Ransom
cd884c764b Fix documentation for crypto_pk_cmp_keys
Now that crypto_pk_cmp_keys might return the result of tor_memcmp, there
is no guarantee that it will only return -1, 0, or 1.  (It currently does
only return -1, 0, or 1, but that's a lucky accident due to details of the
current implementation of tor_memcmp and the particular input given to it.)

Fortunately, none of crypto_pk_cmp_keys's callers rely on this behaviour,
so changing its documentation is sufficient.
2012-09-17 11:02:53 -04:00
Robert Ransom
62babcaf0a Implement and use crypto_pk_eq_keys 2012-09-17 11:02:53 -04:00
Robert Ransom
f3916a6855 Make crypto_pk_cmp_keys do something sane for NULL keys
Fixes bug 4283; bugfix on r76
(Git commit 01aadefbfc).
2012-09-17 11:02:52 -04:00
Nick Mathewson
32d9cea289 Merge remote-tracking branch 'public/bug6853' 2012-09-17 10:50:48 -04:00
Nick Mathewson
5511d21d2b Merge branch 'bug6861_typofix' 2012-09-17 10:28:35 -04:00
Nick Mathewson
96d2a21683 Avoid sign-extending when computing rend auth type.
Right-shifting negative values has implementation-defined behavior.
On all the platforms we work on right now, the behavior is to
sign-extend the input.  That isn't what we wanted in

    auth_type_val = (descriptor_cookie_tmp[16] >> 4) + 1;

Fix for 6861; bugfix on 0.2.1.5-alpha; reported pseudonymously.

The broken behavior didn't actually hurt anything, I think, since the
only way to get sign-extension to happen would be to have the top bit
of descriptor_cookie_tmp[16] set, which would make the value of
descriptor_cookie_tmp[16] >> 4 somewhere between 0b11111111 and
0b11111000 (that is, between -1 and -8).  So auth_type_val would be
between -7 and 0.  And the immediate next line does:

    if (auth_type_val < 1 || auth_type_val > 2) {

So the incorrectly computed auth_type_val would be rejected as
invalid, just as a correctly computed auth_type_val would be.

Still, this stuff shouldn't sit around the codebase.
2012-09-17 10:28:14 -04:00
Nick Mathewson
414adb237b Parse votes with >31 flags correctly
We were doing (1<<p) to generate a flag at position p, but we should
have been doing (U64_LITERAL(1)<<p).

Fixes bug 6861; bugfix on 0.2.0.3-alpha; reported pseudonymously.
2012-09-17 10:24:52 -04:00
Nick Mathewson
c3f526ed64 Merge branch '6044_nm_squashed' 2012-09-17 10:03:11 -04:00
Nick Mathewson
4b362d002c Turn the read_file_until_eof tests into a single implementation 2012-09-17 10:02:57 -04:00
meejah
d64bf286a1 Handle FIFOs in read_file_to_str
add read_file_to_str_until_eof which is used by read_file_to_str
if the file happens to be a FIFO.

change file_status() to return FN_FILE if st_mode matches S_IFIFO
(on not-windows) so that init_key_from_file() will read from a FIFO.
2012-09-17 10:02:24 -04:00
Nick Mathewson
523b0ec288 Merge remote-tracking branch 'origin/maint-0.2.3' 2012-09-14 12:40:23 -04:00
Nick Mathewson
b1447a4312 Use file-size-fixup code on cygwin too.
We already had code on windows to fix our file sizes when we're
reading a file in text mode and its size doesn't match the size from
fstat.  But that code was only enabled when _WIN32 was defined, and
Cygwin defines __CYGWIN__ instead.

Fixes bug 6844; bugfix on 0.1.2.7-alpha.
2012-09-14 12:39:18 -04:00
Nick Mathewson
c2c6d12a81 Move functions for seeing if we know enough nodes into nodelist 2012-09-14 10:20:01 -04:00
Nick Mathewson
725d3a32bd Remove router_get_by_{nickname,hexdigest} entirely 2012-09-14 10:20:00 -04:00
Nick Mathewson
5161a52c66 Remove the old disabled router_get_by_nickname implementation 2012-09-14 10:20:00 -04:00
Nick Mathewson
ba21ebc6d8 Move many of the node_ functions from routerlist to nodelist 2012-09-14 10:20:00 -04:00
Nick Mathewson
d995dc8bac Split the routerset code out of routerlist.c 2012-09-14 10:20:00 -04:00
Nick Mathewson
286e95f0a5 Merge branch 'bug6833' 2012-09-14 10:10:23 -04:00
Nick Mathewson
68caa834f4 document why we only allow 64 flags in votes 2012-09-14 10:10:16 -04:00
Nick Mathewson
e4ce8cd969 Fix compilation with older gccs
They don't like to have #preprocessor directives inside macro arguments.

Fixes #6842; fix on 0.2.4.2-alpha.

Found by grarpamp.
2012-09-14 10:06:00 -04:00
Nick Mathewson
56bd3dd87f Remove a duplicate test in test_util_pow2 2012-09-14 10:00:47 -04:00
Nick Mathewson
6492a75b9f Merge branch 'bug6831_v2' 2012-09-14 09:54:08 -04:00
Nick Mathewson
37953497d8 Don't compute ((uint64_t)1)<<64 in round_to_power_of_2
This would be undefined behavior if it happened. (It can't actually
happen as we're using round_to_power_of_2, since we would have to
be trying to allocate exabytes of data.)

While we're at it, fix the behavior of round_to_power_of_2(0),
and document the function better.

Fix for bug 6831.
2012-09-14 09:51:24 -04:00
Nick Mathewson
7d11952bf4 Split the or_state_t portions of config.c into their own file 2012-09-13 12:20:26 -04:00
Nick Mathewson
2eb2536c0a Remove all remaining spurious or_options_t invocations in confparse.c 2012-09-13 12:20:25 -04:00
Nick Mathewson
7627b2c187 Split the generic config_fmt_t code into a new confparse.c file
This helps us split up one of our larger files, and sets the stage
for refactoring the configuration backend a little
2012-09-13 12:20:25 -04:00
Nick Mathewson
c8b98ba41c Reject votes (not consensuses) with >64 known-flags
Our flag voting code needs to handle unrecognized flags, so it stores
them in a 64-bit bitfield.  But we never actually checked for too many
flags, so we were potentially doing stuff like U64_LITERAL(1)<<flagnum
with flagnum >= 64.  That's undefined behavior.

Fix for bug 6833; bugfix on 0.2.0.1-alpha.
2012-09-13 11:45:05 -04:00
George Kadianakis
7072dd5dbe Add a unit test for the old crash input of tor_timegm(). 2012-09-13 18:00:06 +03:00
Nick Mathewson
582f2187a7 Merge remote-tracking branch 'origin/maint-0.2.3' 2012-09-13 10:08:51 -04:00
Robert Ransom
0a6480cdd0 Avoid undefined behaviour when parsing HS protocol versions
Fixes bug 6827; bugfix on c58675ca72
(when the v2 HS desc parser was implemented).

Found by asn.
2012-09-13 07:48:21 -04:00
Nick Mathewson
be68c1fb43 Log a notice if we're running with OpenSSL before 1.0.0.
These versions have some dubious, slow crypto implementations; 1.0.0
is a great improvement, and at this point is pretty mature.
2012-09-12 19:32:24 -04:00
Nick Mathewson
feabf4148f Drop support for openssl 0.9.7
097 hasn't seen a new version since 2007; we can drop support too.

This lets us remove our built-in sha256 implementation, and some
checks for old bugs.
2012-09-12 19:25:58 -04:00
Nick Mathewson
a73dec16c5 Merge branch 'bug6815' 2012-09-12 16:28:59 -04:00
Nick Mathewson
19136f6f11 Fix a wide line 2012-09-12 16:28:46 -04:00
Nick Mathewson
45439bfced Revert "6819: typo in torrc.sample.in"
This reverts commit 4aff97cfc7.

We don't actually want to be changing the torrc.sample on stable or
near-stable stuff, since doing so makes pointless busywork for debian
users.
2012-09-12 15:37:47 -04:00
Nick Mathewson
35e19b9498 Merge remote-tracking branch 'origin/maint-0.2.3' 2012-09-12 11:11:16 -04:00
Nick Mathewson
1f5a7917f5 Merge remote-tracking branch 'public/bug6341_a_v2' into maint-0.2.3 2012-09-12 11:10:59 -04:00
Nick Mathewson
6a8861574b Merge remote-tracking branch 'origin/maint-0.2.3' 2012-09-12 11:09:10 -04:00
Nick Mathewson
4aff97cfc7 6819: typo in torrc.sample.in 2012-09-12 11:08:30 -04:00
Nick Mathewson
5cbeb60805 Fix directory self-testing logic
When I removed version_supports_begindir, I accidentally removed the
mechanism we had been using to make a directory cache self-test its
directory port.  This caused bug 6815, which caused 6814 (both in
0.2.4.2-alpha).

To fix this bug, I'm replacing the "anonymized_connection" argument to
directory_initiate_command_* with an enumeration to say how indirectly
to connect to a directory server.  (I don't want to reinstate the
"version_supports_begindir" argument as "begindir_ok" or anything --
these functions already take too many arguments.)

For safety, I made sure that passing 0 and 1 for 'indirection' gives
the same result as you would have gotten before -- just in case I
missed any 0s or 1s.
2012-09-12 10:26:59 -04:00
Roger Dingledine
5977da6c60 hot: we fixed incancations to be intancations. 2012-09-12 02:51:33 -04:00
Nick Mathewson
75c9ccd4f8 Merge remote-tracking branch 'public/bug6538'
Conflicts:
	configure.ac
2012-09-11 17:51:36 -04:00
Nick Mathewson
f8a665c87d Merge remote-tracking branch 'origin/maint-0.2.3' 2012-09-11 13:21:20 -04:00
Nick Mathewson
5833861f62 Merge remote-tracking branch 'origin/maint-0.2.2' into maint-0.2.3
Conflicts:
	src/test/test_util.c
2012-09-11 13:20:15 -04:00
Nick Mathewson
973c18bf0e Fix assertion failure in tor_timegm.
Fixes bug 6811.
2012-09-11 13:13:07 -04:00
Nick Mathewson
99cb9696ac Bump version to 0.2.4.2-alpha-dev 2012-09-10 19:49:20 -04:00
Roger Dingledine
d85b563dbb Merge branch 'maint-0.2.3' 2012-09-10 18:25:57 -04:00
Roger Dingledine
73c13baa97 bump to 0.2.4.2-alpha 2012-09-10 17:38:50 -04:00
Nick Mathewson
bf71866da0 Merge branch 'remove_old_ver_checks' 2012-09-10 15:37:13 -04:00
Nick Mathewson
4319f99828 Merge remote-tracking branch 'public/ticket6789' 2012-09-10 15:31:04 -04:00
Nick Mathewson
7ff5c3f232 Downgrade "EVP ctr128 is ok" message to info
Part of 6736 effort to try to make startup quieter.
2012-09-10 10:38:22 -04:00
Nick Mathewson
8731a4e148 Avoid segfault when reading state file from ancient tor
If s_values is null in rep_hist_load_bwhist_state_section, we would
call smartlist_len() on it, and die.

Fixes bug 6801.
2012-09-10 10:35:18 -04:00
Nick Mathewson
cb8f64cdc8 Fix tab introduced in f43946829c 2012-09-10 10:22:40 -04:00
Nick Mathewson
0ab7716b9e Merge remote-tracking branch 'linus/bug6797' 2012-09-10 10:19:57 -04:00
Nick Mathewson
20e0e7d9d1 Rename _UseFilteringSSLBufferevents to lose its _. Bug 3155 2012-09-10 10:09:19 -04:00
meejah
f43946829c Hide options beginning with "___" from GETINFO config/names 2012-09-10 09:51:31 -04:00
meejah
65838f4883 rename _UsingTestNetworkDefaults to start with triple-underscore 2012-09-10 09:50:24 -04:00
Roger Dingledine
e1e34ee4e4 raise bandwidthrate/bandwidthburst to a new "infinite"
addresses bug 6605.
2012-09-10 03:03:06 -04:00
Linus Nordberg
93ee62297f Don't follow the NULL pointer.
If dirvote_create_microdescriptor() returns NULL, don't use md.

Found by "f. tp.".

Fixes bug 6797.
2012-09-10 00:43:48 +02:00
Roger Dingledine
f6639d5676 finish backing out 5492de76 2012-09-09 16:51:34 -04:00
Roger Dingledine
67abdcd8d9 minor logging improvement 2012-09-09 15:54:59 -04:00
Nick Mathewson
e8b09c0d51 Remove one more check for an insanely old version 2012-09-07 23:23:49 -04:00
Nick Mathewson
7988596f66 Remove version_supports checks for versions before 0.2.2. 2012-09-07 23:21:18 -04:00
Nick Mathewson
26cee96911 Dirservers no longer accept tors released before December 2011.
Implements ticket 6789.
2012-09-07 11:15:23 -04:00
Nick Mathewson
3fe2161d28 Merge remote-tracking branch 'asn/bug6788' 2012-09-07 10:51:38 -04:00
George Kadianakis
14f4a5da45 Remove redundant declaration of find_transport_name_by_bridge_addrport(). 2012-09-07 17:44:53 +03:00
Roger Dingledine
9446efc0df a debugging log line that just helped me 2012-09-07 03:04:15 -04:00
Nick Mathewson
f4cf279eb5 Rename extend_info_alloc() --> _new()
Based on a patch from Linus, regenerated so as to not conflict with
Linus's 5535/6363 patches.
2012-09-06 11:38:32 -04:00
Linus Nordberg
09c84b50e7 Rename packed_cell_alloc() --> _new(). 2012-09-06 11:37:00 -04:00
Linus Nordberg
3327a0a61c Rename config_alloc() --> _new(). 2012-09-06 11:37:00 -04:00
Nick Mathewson
1ca9e2685f Merge branch 'quiet_lib_versions_squashed' 2012-09-06 11:32:09 -04:00
Nick Mathewson
7607ad2bec Detect openssl header version doesn't match runtime version
We already do this for libevent; let's do it for openssl too.

For now, I'm making it always a warn, since this has caused some
problems in the past.  Later, we can see about making it less severe.
2012-09-06 11:31:30 -04:00
Nick Mathewson
e3a130a7eb Don't log about Libevent/OpenSSL initialization when all's well
OTOH, log the Libevent and OpenSSL versions on the first line when
we're starting Tor.
2012-09-06 11:31:22 -04:00
Nick Mathewson
ad1e8b45df Merge branch 'bug6778' 2012-09-06 11:05:16 -04:00
Nick Mathewson
30fe9080e7 Fix a dependency: micro-revision.i influences tor_main.o, not tor_main.c 2012-09-06 11:00:32 -04:00
Nick Mathewson
e9684405ac Merge remote-tracking branch 'asn/bug4567_rebased' 2012-09-06 10:12:28 -04:00
Nick Mathewson
d2d7cab5b8 Merge remote-tracking branch 'asn/bug6779' 2012-09-06 10:12:15 -04:00
Nick Mathewson
deee0b67c3 Merge remote-tracking branch 'asn/bug6765' 2012-09-06 10:12:11 -04:00
George Kadianakis
93c38b679f Log more information when we fail to terminate a process. 2012-09-06 17:03:11 +03:00
Nick Mathewson
5d162d5a7b Fix a dependency: sha256.c influences crypto.o, not crypto.c 2012-09-06 10:03:06 -04:00
Nick Mathewson
91fed2c703 Fix a build-warning when building out-of-tree
We were trying to incorporate all headers in common_sha1.i, not just
the src/common ones.

This is part of bug 6778; fix on 0.2.4.1-alpha
2012-09-06 09:56:48 -04:00
Roger Dingledine
00120544a4 fix punctuation in logs 2012-09-06 01:35:05 -04:00
Nick Mathewson
5d679caa32 Fix warning when implicitly casting strlen(microdesc) to int
Harmless unless we somehow generate a microdesc of more than INT_MAX
bytes.
2012-09-05 20:49:25 -04:00
Roger Dingledine
a504a81d22 bump to 0.2.4.1-alpha-dev 2012-09-05 20:05:50 -04:00
Roger Dingledine
237129847b bump to 0.2.4.1-alpha 2012-09-05 19:12:22 -04:00
George Kadianakis
8284c2bcba Use tor_malloc_zero() in var_cell_new().
This is just a precaution; we seem to be using var_cell_t.payload and
var_cell_t.payload_len correctly at the moment.
2012-09-06 01:22:32 +03:00
Roger Dingledine
b00b8272da make AuthDirHasIPv6Connectivity match the man page
we can turn it into an autobool later if we have some way for it
to make a decision.

(patch possibly got lost when nickm merged #6770; or maybe nickm meant
for it to be this way. i'm not sure.)
2012-09-05 18:17:41 -04:00
Nick Mathewson
f8c1ab7bbf Merge remote-tracking branch 'origin/maint-0.2.3' 2012-09-05 16:25:13 -04:00
Linus Nordberg
0770e4ccdb Whitespace fixes. 2012-09-05 19:40:15 +02:00
Nick Mathewson
9d9ca264ec Avoid segfault if EntryGuardPathBias precedes EntryGuard
Fix for bug 6774; bugfix on 0.2.3.17-beta.
2012-09-05 13:27:54 -04:00
George Kadianakis
4edc57caa5 Figure out ORPort and DirPort even when 'auto' is used.
Use router_get_advertised_{dir,or}_port() functions instead of
get_primary_{dir,or}_port().
2012-09-05 20:17:25 +03:00
Nick Mathewson
116c8409ba Merge remote-tracking branch 'linus/bug6770_3'
Conflicts:
	doc/tor.1.txt
	src/or/config.c
2012-09-05 11:35:26 -04:00
George Kadianakis
b9551fd074 Fix some bugs that did not allow compilation on Windows. 2012-09-05 18:23:29 +03:00
George Kadianakis
44fe717524 General tweaks and fixes for Nick's comments.
* Add changes/ files.
* Edit the tor-fw-helper manpage.
* Fix check-spaces.
* Add prototype for get_list_of_ports_to_forward().
* Fix tor_parse_long() TCP port range.
* Improve doc. of tor_check_port_forwarding().
* Check for overflows in tor_check_port_forwarding().
* Demote successful port forwarding to LOG_INFO.

Conflicts:
	src/common/address.c
	src/or/circuitbuild.c
2012-09-05 18:23:28 +03:00
George Kadianakis
443260ffd8 Tweak code and pump the tor-fw-helper version.
Conflicts:
	src/or/circuitbuild.h
2012-09-05 18:09:45 +03:00
George Kadianakis
da16c425ef Start passing ports to tor_check_port_forwarding().
Conflicts:
	src/or/transports.c
2012-09-05 18:08:18 +03:00
George Kadianakis
cd05f35d2c Refactor tor to support the new tor-fw-helper protocol.
Add handle_fw_helper_output(), a function responsible for parsing the
output of tor-fw-helper. Refactor tor_check_port_forwarding() and
run_scheduled_events() accordingly too.

We now issue warnings when we get control output from tor-fw-helper,
and we log the verbose output of tor-fw-helper in LOG_INFO.

Conflicts:
	src/common/util.c
2012-09-05 18:04:34 +03:00
George Kadianakis
64b2a64310 Use get_lines_from_handle() in configure_proxy(). 2012-09-05 18:02:27 +03:00
George Kadianakis
03e89f0b72 Introduce get_lines_from_handle().
get_lines_from_handle() is a multiplatform function which drains lines
from a stream and stuffs it into a smartlist. It's useful for
line-based protocols, like the one managed proxy and the tor-fw-helper
protocols.
2012-09-05 18:02:27 +03:00
George Kadianakis
e8be040016 All loging messages are now sent to stderr.
stdout should be clean for control messages.
2012-09-05 18:02:27 +03:00
George Kadianakis
b9e160446a Refactor our backends' interface. 2012-09-05 18:02:27 +03:00
George Kadianakis
c5778553dc Further implement tor-fw-helper's TCP port forwarding system. 2012-09-05 18:02:27 +03:00
George Kadianakis
d7261fb7f1 Implement the new TCP port parsing logic in tor-fw-helper. 2012-09-05 18:02:27 +03:00
George Kadianakis
d19a78744e Refactor tor-fw-helper port forwarding logic.
Make it port-purpose-agnostic; that is it should treat each port as
equal, and not expect to get a DirPort and an ORPort.
2012-09-05 18:02:26 +03:00
Linus Nordberg
f7c97cd40b Remove AuthDirPublishIPv6 and let AuthDirHasIPv6Connectivity fill its function.
See #4771 for rationale.

Note that this patch does not take suggested changes in #4470 into
account and keeps treating AuthDirHasIPv6Connectivity as an
AUTOBOOL. Thus, bug fixes for that are included here as well.

This is a fix on master, unreleased as of now.
2012-09-05 13:35:39 +02:00
Linus Nordberg
0e53742a85 Make AuthDirHasIPv6Connectivity a BOOL.
This is a fix of unreleased tor. It solves ticket #6770.
2012-09-05 12:47:01 +02:00
Roger Dingledine
67065c3c06 minor typos i found while constructing the changelog 2012-09-05 04:46:27 -04:00
Nick Mathewson
4d87919ba6 Merge remote-tracking branch 'origin/maint-0.2.3' 2012-09-04 18:34:39 -04:00
Nick Mathewson
acfd487e7d Merge remote-tracking branch 'arma/bug6743' into maint-0.2.3 2012-09-04 18:33:56 -04:00
Nick Mathewson
d7a646edcf Merge branch 'bug5535_only_rebased' 2012-09-04 18:24:20 -04:00
Nick Mathewson
ec94d0307e Merge remote-tracking branch 'linus/bug6363_only-ln' 2012-09-04 18:23:18 -04:00
Linus Nordberg
d34c690e54 Allocate vote_microdesc_hash_t using tor_malloc_zero().
In case the struct grows in the future. Shouldn't be too expensive.
2012-09-04 20:19:41 +02:00
Linus Nordberg
8ef395d6a9 Whitespace. 2012-09-04 20:19:40 +02:00
Linus Nordberg
b337aa4c0e Remove spurious debug log printout. 2012-09-04 19:27:05 +02:00
Linus Nordberg
730dd9a6d0 Remove trailing semicolon from #define TOR_ADDR_NULL.
Can it ever help? I can only see harm. What am I missing?
2012-09-04 13:05:23 -04:00
Linus Nordberg
d827a5495a Take microdesc into account when deciding about preferred OR port. 2012-09-04 12:57:22 -04:00
Linus Nordberg
8b081231b5 Make node_ipv6_preferred() take microdescs into account.
Also, make node_get_prim_orport() indicate in its return value whether
a valid OR port was copied or not.

Maybe we should make it legal to pass ap_out==NULL?
2012-09-04 12:57:22 -04:00
Linus Nordberg
3746215350 Take microdesc IPv6 address into account when setting node->ipv6_preferred.
Also, do this only for clients, explicitly.

Also, give the flag a value every time we set consensus. We used to
touch it only when ClientPreferIPv6ORPort was set, which was wrong.
2012-09-04 12:57:21 -04:00
Linus Nordberg
0f45dbefed Use preferred OR for nodes with routerstatus and microdesc too.
extend_info_from_node() used to use the primary OR port (i.e. IPv4)
unless the node had routerinfo. Now that we have IPv6 addresses in
microdescs we may want to use them.

Note that this patch changes using r->cache_info.identity_digest into
using node->identity. I count on these being well synchronised, or
things would break in other ways. Right?
2012-09-04 12:57:21 -04:00
Linus Nordberg
7a8366a3eb Add IPv6 OR port to microdesc_t and populate it. 2012-09-04 12:57:21 -04:00
Linus Nordberg
e04e1a2e7d Clients connect to public relays over IPv6.
Add ClientUseIPv6 and ClientPreferIPv6ORPort configuration options.

Use "preferred OR port" for all entry nodes, not only for bridges.

Mark bridges with "prefer IPv6 OR port" if an IPv6 address is
configured in Bridge line and ClientPreferIPv6ORPort is set.

Mark relays with "prefer IPv6 OR port" if an IPv6 address is found in
descriptor and ClientPreferIPv6ORPort is set.

Filter "preferred OR port" through the ClientUseIPv6 config option. We
might want to move this test to where actual connection is being set
up once we have a fall back mechanism in place.

Have only non-servers pick an IPv6 address for the first hop: We
don't want relays to connect over IPv6 yet. (IPv6 has never been used
for second or third hops.)

Implements ticket 5535.
2012-09-04 12:57:21 -04:00
Linus Nordberg
d6ad00a01f Clear the ipv6_preferred flag like the others.
I'm not entirely sure that this is meningful but I'm pretty sure it's
not harmful. Seems like the logical thing to do.
2012-09-04 12:55:38 -04:00
Linus Nordberg
c76a332887 Fix a comment. 2012-09-04 12:51:08 -04:00
Linus Nordberg
585ef06978 Add tor_addr_port_new(). 2012-09-04 12:03:42 -04:00
Linus Nordberg
68901da5a1 Generate microdescriptors with "a" lines.
Generate and store all supported microdescriptor formats. Generate
votes with one "m" line for each format. Only "m" lines with version
info matching chosen consensus method will be voted upon.

An optimisation would be to combine "m" lines with identical hashes,
i.e. instead of "m 1,2,3 H1" and "m 4,5 H1", say "m 1,2,3,4,5 H1".
2012-09-04 11:56:34 -04:00
Linus Nordberg
156ffef249 Have directory authorities vote on IPv6 OR ports according to the spec
Define new new consensus method 14 adding "a" lines to vote and
consensus documents.

From proposal 186:

  As with other data in the vote derived from the descriptor, the
  consensus will include whichever set of "a" lines are given by the
  most authorities who voted for the descriptor digest that will be
  used for the router.

This patch implements this.
2012-09-04 11:52:22 -04:00
Nick Mathewson
485b4b7eee Rename configure.in to configure.ac
This is the preferred filename to use with Autoconf 2.50 and later.
2012-09-04 11:12:00 -04:00
Nick Mathewson
05ded76cb6 Merge remote-tracking branch 'arma/bug6759' 2012-09-04 10:18:51 -04:00
Nick Mathewson
3da9a14f1c Merge remote-tracking branch 'arma/feature6758' 2012-09-04 10:16:15 -04:00
Nick Mathewson
978a2251f3 Merge remote-tracking branch 'arma/feature6760' 2012-09-04 10:14:55 -04:00
Roger Dingledine
0a2fcc55c5 resolve an XXX by agreeing with nickm 2012-09-03 22:15:04 -04:00
Roger Dingledine
81c6db3288 make "Launching %d requests for %d routers" message more useful
specifically, specify what sort of routers we're fetching.
2012-09-03 22:10:49 -04:00
Roger Dingledine
3ea37e5faa quiet "I learned some more directory information" on startup
Reserve it for when new directory information arrives in response to
a fetch.

Resolves ticket 6760.
2012-09-03 19:49:44 -04:00
Roger Dingledine
2131cc125b Don't log about reloading the microdescriptor cache at startup
Addresses bug 6759.
2012-09-03 18:50:27 -04:00
Roger Dingledine
e964f81143 omit the first heartbeat message (resolves ticket 6758) 2012-09-03 18:13:35 -04:00
Roger Dingledine
4bd90e20b9 fix whitespace and trivial typo 2012-09-03 02:09:39 -04:00
Roger Dingledine
eb3d079667 Make begindir_cutoff the same as general_cutoff
Allow one-hop directory fetching circuits the full "circuit build timeout"
period, rather than just half of it, before failing them and marking
the relay down. This fix should help reduce cases where clients declare
relays (or worse, bridges) unreachable because the TLS handshake takes
a few seconds to complete.

Fixes bug 6743 (one piece of bug 3443); bugfix on 0.2.2.2-alpha, where
we changed the timeout from a static 30 seconds.
2012-09-01 01:25:17 -04:00
Nick Mathewson
9982122f34 Use a time-invariant comparison in choose_array_element_by_weight 2012-08-28 12:42:25 -04:00
Nick Mathewson
5c3199cda7 In choose-by-bw, scale to better use the range of uint64
The smart part of this is based on an approach and a suggestion by
rransom. The unsmart part is my own fault.
2012-08-27 19:36:12 -04:00
Nick Mathewson
ef628649c8 Spelling fix in util.c comments 2012-08-27 16:44:54 -04:00
Nick Mathewson
3363a0d26e Merge remote-tracking branch 'origin/maint-0.2.3' 2012-08-27 16:39:30 -04:00
Nick Mathewson
a7a4bbff47 Quiet "Set buildtimeout to low val" warnings: make them info
Fix for #6251
2012-08-27 16:37:09 -04:00
Nick Mathewson
f40378118c Merge remote-tracking branch 'mikeperry/bug6647' 2012-08-27 16:23:19 -04:00
Nick Mathewson
b252ffa7cb Downgrade path-bias warning messages to INFO for now.
We've had over two months to fix them, and didn't.  Now we need
0.2.3.x stable.  Yes, it would be cool to get this working in
0.2.3.x, but not at the expense of delaying every other feature that
_does_ work in 0.2.3.x.  We can do a real fix in 0.2.4.
2012-08-27 16:18:35 -04:00
Nick Mathewson
0c5a44ed0a Merge remote-tracking branch 'origin/maint-0.2.3' 2012-08-27 16:16:27 -04:00
Nick Mathewson
bffe0d3ccc Merge branch 'bug6710_023' into maint-0.2.3 2012-08-27 16:15:01 -04:00
Nick Mathewson
e232938ec8 Merge remote-tracking branch 'origin/maint-0.2.3' 2012-08-27 16:09:29 -04:00
Nick Mathewson
443e4ae1ee Merge remote-tracking branch 'origin/maint-0.2.2' into maint-0.2.3
Conflicts:
	src/or/policies.c
2012-08-27 16:07:04 -04:00
Nick Mathewson
62d96284f7 Do not assert when comparing a null address/port against a policy
This can create a remote crash opportunity for/against directory
authorities.
2012-08-27 12:04:55 -04:00
Nick Mathewson
b7c172c9ec Disable extending to private/internal addresses by default
This is important, since otherwise an attacker can use timing info
to probe the internal network.

Also, add an option (ExtendAllowPrivateAddresses) so that
TestingTorNetwork won't break.

Fix for bug 6710; bugfix on all released versions of Tor.
2012-08-27 11:19:29 -04:00
Nick Mathewson
5898c09c3a Fix whitespace 2012-08-27 10:53:40 -04:00
Nick Mathewson
7795f42e4b Merge branch 'bug6524_nm' 2012-08-27 10:33:24 -04:00
Jim Meyering
90d1c85757 build: minimal adjustments to make out-of-tree build work 2012-08-27 10:00:22 -04:00
Nick Mathewson
b3b4f31936 Merge remote-tracking branch 'linus/bug6364' 2012-08-27 09:53:37 -04:00
Nick Mathewson
6f7dbd3d34 Merge remote-tracking branch 'linus/bug6362' 2012-08-27 09:50:22 -04:00
Nick Mathewson
6864a44a4a Merge remote-tracking branch 'origin/maint-0.2.3' 2012-08-24 12:51:50 -04:00
Nick Mathewson
ce4add498f Merge remote-tracking branch 'public/bug6472' into maint-0.2.3 2012-08-24 12:51:02 -04:00
Nick Mathewson
ca09ea0a8b Make node_assert_ok less duplicatey
This comes at the cost of making its failure message a little less
friendly, but since when do assertion failures count as
user-friendly?
2012-08-24 12:48:23 -04:00
Nick Mathewson
03ca9c63c8 Clarify docs on get_configured_bridge_by_*_digest 2012-08-24 12:31:09 -04:00
Mike Perry
e13abda470 Bug 6647: Use correct scale constant and prevent rounding error
We were effectively resetting our counts, and the rounding error
leads to incorrect log messages.
2012-08-23 20:28:29 -07:00
Mike Perry
4950618b13 Bug 6475: Demote pathbias log messages for 0.2.3.x
Also make a couple of them less scary.

We'll do a separate, additional commit on 0.2.4.x to bump them back
up again.
2012-08-23 20:28:25 -07:00
Mike Perry
880c71304b Disable path bias accounting if we have no guards.
This should eliminate a lot of notices for Directory Authorities and other
situations where circuits built without using guard nodes.
2012-08-23 19:47:08 -07:00
Linus Nordberg
3410a46ebc Move ipv6_preferred from routerinfo_t to node_t.
Move extend_info_from_router() from circuitbuild.c to router.c and
make it static.

Add get_configured_bridge_by_orports_digest() and have
get_configured_bridge_by_routerinfo() and
node_is_a_configured_bridge() use it. We now consider all OR ports of
a bridge when looking for it.

Move node_get_*_orport to nodelist.c.

Fix a cut'n'paste error in header of nodelist.h.

Add node_assert_ok().

Add router_get_all_orports(). It's duplicating code from
node_get_all_orports(). Worth fixing at the cost of complicating the
API slightly?
2012-08-23 22:13:12 +02:00
Nick Mathewson
6d703f8db5 Make the _sha1.i file generation quieter 2012-08-23 13:14:41 -04:00
Linus Nordberg
734b09080f Fetch IPv6 address from NETINFO "other OR's address" field.
The my_apparent_addr is still unused, apart from now being logged in
the "Got good NETINFO cell" info message.
2012-08-21 18:43:36 +02:00
Nick Mathewson
64676d0571 Merge branch 'bug6638' 2012-08-21 11:20:58 -04:00
Nick Mathewson
939d01f0ba Merge remote-tracking branch 'origin/maint-0.2.3' 2012-08-21 10:36:51 -04:00
Nick Mathewson
991a8acba2 Merge remote-tracking branch 'public/bug6404' into maint-0.2.3 2012-08-21 10:35:40 -04:00
Nick Mathewson
d517233e71 Merge remote-tracking branch 'linus/bug6621' 2012-08-21 10:21:53 -04:00
Nick Mathewson
778d90122c Avoid spurious warnings in rend_service_introduce
There was some code in the "err:" block that would always log a
warning, reporting an "unknown error" if we hadn't set err_msg.  But
there were also plenty of "goto err" blocks that did their own
logging, and never set err_msg at all.  Now we should only log when
we have an error message to log.

This fixes bug 6638, from no released Tor version.
2012-08-21 10:15:52 -04:00
Linus Nordberg
9216e2819b Send IPv6 address in NETINFO cells.
Closes #6364.
2012-08-20 17:01:18 +02:00
Linus Nordberg
5671586dc7 Make all relays, not only bridges, capable of advertising an IPv6 OR port.
Closes #6362.
2012-08-19 14:48:22 +02:00
Nick Mathewson
661bd3fe71 Merge remote-tracking branch 'origin/maint-0.2.3' 2012-08-17 17:10:16 -04:00
Nick Mathewson
88859b2ff1 whitespace fix 2012-08-17 17:10:03 -04:00
Nick Mathewson
223e7cfabe When iterating over connections pending DNS, skip marked ones
Failure to do this would lead to double-free cases and similar,
especially when the exit's DNS was broken. See bug 6472 for full
details; this is a fix for 6472.

Anonymous patch from "cypherpunks" on trac.
2012-08-17 16:46:11 -04:00
Nick Mathewson
1c64f99a1a Merge remote-tracking branch 'public/bug5124' 2012-08-17 16:05:09 -04:00
Nick Mathewson
d9746bd468 Remove needless flush-on-write code.
Long ago, before we had cell queues, it was necessary to maybe call
connection_handle_write() from connectino_write_to_buf_impl() on OR
connections, so that we wouldn't get into a loop of reading infinite
amounts of data and queueing it all on an outbuf before bothering to
write any data.

If that doesn't sounds like what our code does now, you're right:
right now, we won't stick more than OR_CONN_HIGHWATER bytes of cells
on an outbuf, and we won't suck more than CELL_QUEUE_HIGHWATER_SIZE
cells off any edge connection. So, there's no more call for that
code.

Removing this code will simplify our data flow, and that should be
something we can all get behind.
2012-08-17 16:01:30 -04:00
Nick Mathewson
a9d56289ee Merge remote-tracking branch 'origin/maint-0.2.3' 2012-08-17 15:59:40 -04:00
Linus Nordberg
9ed87b37d0 Consider IPv6 OR ports when deciding whether a routerinfo change is cosmetic.
Closes #6423.
2012-08-17 15:59:13 -04:00
Nick Mathewson
851197f11d Merge remote-tracking branch 'origin/maint-0.2.3' 2012-08-17 14:04:28 -04:00
Nick Mathewson
97602c9de4 Merge branch 'bug6379' into maint-0.2.3 2012-08-17 13:57:07 -04:00
Nick Mathewson
4c8fcba86c Fix more warnings from openbsd_malloc
Apparently, (void)writev is not enough to suppress the "you are
ignoring the return value!" warnings on Linux.  Instead, remove the
whole warning/error logic when compiling openbsd_malloc for Tor: we
can't use it.
2012-08-17 13:49:52 -04:00
Nick Mathewson
eec86939d1 Merge remote-tracking branch 'origin/maint-0.2.3' 2012-08-17 12:39:31 -04:00
Nick Mathewson
e9172e51fb Merge remote-tracking branch 'public/bug6244_part_c' into maint-0.2.3 2012-08-17 12:37:49 -04:00
Nick Mathewson
1728801bbc Merge remote-tracking branch 'origin/maint-0.2.3' 2012-08-17 12:34:52 -04:00
Nick Mathewson
676f71054f Merge remote-tracking branch 'public/bug6507' into maint-0.2.3 2012-08-17 12:33:17 -04:00
Nick Mathewson
a4669d8704 Merge remote-tracking branch 'origin/maint-0.2.3' 2012-08-17 12:10:44 -04:00
Nick Mathewson
a74d4182f1 Whitespace and build fixes on 6475 patch 2012-08-17 12:10:31 -04:00
Nick Mathewson
3621f30ad4 Merge remote-tracking branch 'mikeperry/bug6475' into maint-0.2.3 2012-08-17 12:08:42 -04:00
Nick Mathewson
274e281741 Merge remote-tracking branch 'origin/maint-0.2.3' 2012-08-17 11:54:05 -04:00
Nick Mathewson
f25e8d034b Merge remote-tracking branch 'public/bug6514' into maint-0.2.3 2012-08-17 11:53:06 -04:00
Linus Nordberg
b1c4b3ad0e Make authorities not set Running unless all advertised OR ports are reachable.
Resolves #6621.
2012-08-17 12:53:25 +02:00
Mike Perry
4e42a8a2f2 Address Nick's comments from code review.
Also promote log messages to notice and rate-limit them.
2012-08-16 16:29:19 -07:00
Mike Perry
ec6a7effb8 Bug 6475: Explicitly track our path bias state.
This is done to avoid spurious warns. Additional log lines are also
added to try to track down the codepaths where we are somehow overcounting
success counts.
2012-08-15 19:59:55 -07:00
Nick Mathewson
6a33c33a12 Fix warnings and 64-bit problems in openbsd-malloc code
The warning fixes are:
  - Only define issetugid if it's missing.
  - Explicitly ignore the return value of writev.
  - Explicitly cast the retval of readlink() to int.

The 64-bit problems are related to just storing a size_t in an int. Not cool!  Use a size_t instead.

Fix for bug 6379. Bugfix on 0.2.0.20-rc, which introduced openbsd-malloc.
2012-08-15 19:26:53 -04:00
Nick Mathewson
2ba52f4095 Fix wildcarded address mappings from the control port
Apparently, we weren't actually detecting wildcardedness when parsing
them: whoops!

bug 6244.  Bugfix on 0.2.3.9-alpha
2012-08-15 17:59:30 -04:00
Nick Mathewson
959f850056 Raise the part of torrc mapaddress handling that knows wildcards
This patch extracts the inner part of config_register_addressmaps --
the part that knows about detecting wildcard addresses addresses --
and makes it into a new function.  The new function is deliberately
not moved or reindented, so that the diff is smaller.

I need this to fix bug 6244.
2012-08-15 17:52:40 -04:00
Nick Mathewson
cdd882ee71 Check for stream_id, not conn, on extend cells.
Extend cells aren't allowed to have a stream_id, but we were only
blocking them when they had a stream_id that corresponded to a
connection.  As far as I can tell, this change is harmless: it will
make some kinds of broken clients not work any more, but afaik nobody
actually make a client that was broken in that way.

Found while hunting for other places where we made the same mistake
as in 6271.

Bugfix on d7f50337c1 back from May 2003, which introduced
telescoping circuit construction into 0.0.2pre8.
2012-08-15 13:16:41 -04:00
Nick Mathewson
a9eed33111 Fix memory leak in dirvote_create_microdescriptor
Found by George, who gets a cookie.
2012-08-14 03:07:17 -04:00
Nick Mathewson
f45cde05f9 Remove tor_malloc_roundup().
This function never actually did us any good, and it added a little
complexity.  See the changes file for more info.
2012-08-13 13:27:32 -04:00
Nick Mathewson
d993b04485 Reject attempts to say FooPort and FooPort 0 in the same cfg domain 2012-08-09 16:13:03 -04:00
Nick Mathewson
e1fb3b8d65 Fix spaces from last patch 2012-08-09 16:02:57 -04:00
Nick Mathewson
dfe03d36c8 Don't infer we have a FooPort from the presence of a FooPort line
Thanks to the changes we started making with SocksPort and friends
in 0.2.3.3-alpha, any of our code that did "if (options->Sockport)"
became wrong, since "SocksPort 0" would make that test true whereas
using the default SocksPort value would make it false.  (We didn't
actually do "if (options->SockPort)" but we did have tests for
TransPort.  When we moved DirPort, ORPort, and ControlPort over to
the same system in 0.2.3.9-alpha, the problem got worse, since our
code is littered with checks for DirPort and ORPort as booleans.

This code renames the current linelist-based FooPort options to
FooPort_lines, and adds new FooPort_set options which get set at
parse-and-validate time on the or_options_t.  FooPort_set is true
iff we will actually try to open a listener of the given type. (I
renamed the FooPort options rather than leave them alone so that
every previous user of a FooPort would need to get inspected, and so
that any new code that forgetfully uses FooPort will need fail to
compile.)

Fix for bug 6507.
2012-08-09 15:48:43 -04:00
Nick Mathewson
07df4dd52d Refactor the core of choosing by weights into a function
This eliminates duplicated code, and lets us test a hairy piece of
functionality.
2012-08-09 14:15:58 -04:00
Nick Mathewson
9bfb274abb Refactor smartlist_choose_node_by_bandwidth to be less horrible.
With this patch, I dump the old kludge of using magic negative
numbers to indicate unknown bandwidths.  I also compute each node's
weighted bandwidth exactly once, rather than computing it once in
a loop to compute the total weighted bandwidth and a second time in
a loop to find which one we picked.
2012-08-09 12:59:04 -04:00
Nick Mathewson
50aecc68ca Use a smarter fix for bug 1203.
Previously, we had incremented rand_bw so that when we later tested
"tmp >= rand_bw", we wouldn't have an off-by-one error.  But instead,
it makes more sense to leave rand_bw alone and test "tmp > rand_bw".

Note that this is still safe.  To take the example from the bug1203
writeup: Suppose that we have 3 nodes with bandwidth 1.  So the
bandwidth array is { 1, 1, 1 }, and the total bandwidth is 3.  We
choose rand_bw == 0, 1, or 2.  With the first iteration of the loop,
tmp is now 1; with the second, tmp is 2; with the third, tmp is 3.
Now that our check is tmp > rand_bw, we will set i in the first
iteration of the loop iff rand_bw == 0; in the second iteration of
the loop iff rand_bw == 1, and in the third iff rand_bw == 2.
That's what we want.

Incidentally, this change makes the bug 6538 fix more ironclad: once
rand_bw is set to UINT64_MAX, tmp > rand_bw is obviously false
regardless of the value of tmp.
2012-08-09 12:41:28 -04:00
Nick Mathewson
640a51684c Remove remaining timing-dependency in choosing nodes by bandwidth
The old approach, because of its "tmp >= rand_bw &&
!i_has_been_chosen" check, would run through the second part of the
loop slightly slower than the first part.  Now, we remove
i_has_been_chosen, and instead set rand_bw = UINT64_MAX, so that
every instance of the loop will do exactly the same amount of work
regardless of the initial value of rand_bw.

Fix for bug 6538.
2012-08-09 12:40:03 -04:00
Nick Mathewson
e106812a77 Change smartlist_choose_node_by_bandwidth to avoid double
This should make our preferred solution to #6538 easier to
implement, avoid a bunch of potential nastiness with excessive
int-vs-double math, and generally make the code there a little less
scary.

"But wait!" you say.  "Is it really safe to do this? Won't the
results come out differently?"

Yes, but not much.  We now round every weighted bandwidth to the
nearest byte before computing on it.  This will make every node that
had a fractional part of its weighted bandwidth before either
slighty more likely or slightly less likely.  Further, the rand_bw
value was only ever set with integer precision, so it can't
accurately sample routers with tiny fractional bandwidth values
anyway.  Finally, doing repeated double-vs-uint64 comparisons is
just plain sad; it will involve an implicit cast to double, which is
never a fun thing.
2012-08-09 12:21:37 -04:00
Stewart Smith
2606c8b289 Fix up make distcheck and greatly simplify docs dependencies (although it's still a bit odd) 2012-08-09 11:03:48 -04:00
Stewart Smith
2e80ae895d fix circular dependency for generating code digests 2012-08-09 11:03:48 -04:00