count DATA cells with stream ID 0 as delivered for SENDME purposes

Found while investigating 8093, but probably not the cause of it,
since this bug would result in us sending too few SENDMEs, not in us
receiving SENDMEs unexpectedly.

Bugfix on the fix for 7889, which has appeared in 0.2.4.10-alpha, but
not yet in any released 0.2.3.x version.
Check spawn_func() return value

If we don't, we can wind up with a wedged cpuworker, and write to it
for ages and ages.

Found by skruffy.  This was a bug in 2dda97e8fd898757, a.k.a. svn
revision 402. It's been there since we have been using cpuworkers.
Removing is_internal_IP() function. Resolves ticket 4645.
Using proper functions to create tor_addr_t.
Fixes for bug4645 fix.
More hacking around spawn_func issues

This time, we use a pthread_attr to make sure that if pthread_create
succeeds, the thread is successfully detached.

This probably isn't the big thing going on with 4345, since it'd be
a bit weird for pthread_detach to be failing.  But it's worth
getting it right.
Remove TunnelDirConns and PreferTunnelledDirConns

These options were added back in 0.1.2.5-alpha, but no longer make any
sense now that all directories support tunneled connections and
BEGIN_DIR cells.  These options were on by default; now they are
always-on.

This is a fix for 10849, where TunnelDirConns 0 would break hidden
services -- and that bug arrived, I think, in 0.2.0.10-alpha.
Log only one message for dangerous log settings.

We log only one message, containing a complete list of what's
wrong.  We log the complete list whenever any of the possible things
that could have gotten wrong gets worse.

Fix for #9870. Bugfix on 10480dff01bece13fab, which we merged in
0.2.5.1-alpha.
Faster circuit_get_by_rend_token_and_purpose()

On busy servers, this function takes up something like 3-7% in
different profiles, and gets invoked every time we need to participate
as the midpoint in a hidden service.

So maybe walking through a linked list of all the circuits here wasn't
a good idea.
Merge remote-tracking branch 'public/bug9841_024_v2' into bug9841_025

Conflicts:
	src/or/circuitlist.c
Tweak sign of rend_token params for consistency
Tests for rend_token maps

This gets coverage of everything except for the cases which should be
impossible.
Stop accepting 0.2.2 relay uploads for the consensus.

Resolves ticket 11149.
Update ns downloads when we receive a bridge descriptor

This prevents long stalls when we're starting with a state file but
with no bridge descriptors.  Fixes bug 9229.  I believe this bug has
been present since 0.2.0.3-alpha.
Fix our check for the "first" bridge descriptor.

This is meant to be a better bug 9229 fix -- or at least, one more
in tune with the intent of the original code, which calls
router_retry_directory_downloads() only on the first bridge descriptor.
should_disable_dir_fetches() now returns 1 if DisableNetwork==1

This change prevents LD_BUG warnings and bootstrap failure messages
when we try to do directory fetches when starting with
DisableNetwork == 1, a consensus present, but no descriptors (or
insufficient descriptors) yet.

Fixes bug 11200 and bug 10405.  It's a bugfix on 0.2.3.9-alpha.
Thanks to mcs for walking me through the repro instructions!
Test code for implementation of faster circuit_unlink_all_from_channel

This contains the obvious implementation using the circuitmux data
structure.  It also runs the old (slow) algorithm and compares
the results of the two to make sure that they're the same.

Needs review and testing.
Defensive programming: null [pn]_chan,circ_id in circuit_mark_for_close_

Doing this as part of the patch for #9683 to prevent possible bugs
down the line
Take out remaining V1 directory code.
Fix a use-after-free in test_circuitlist.c

Found by clang-3.4 analyzers.