Fix log messages in channeltls.c

Add hop number in debug "Contemplating intermediate hop..."
Fix capitalisation on warn "Failed to choose an exit server"
Fix a function name in a comment in config.c
Fix grammar in comment on running_long_enough_to_decide_unreachable
Avoid excluding guards from path building in minimal test networks

choose_good_entry_server() now excludes current entry
guards and their families, unless we're in a test network,
and excluding guards would exclude all nodes.

This typically occurs in incredibly small tor networks,
and those using TestingAuthVoteGuard *

This is an incomplete fix, but is no worse than the previous
behaviour, and only applies to minimal, testing tor networks
(so it's no less secure).

Discovered as part of #13718.
Refactor count_usable_descriptors to use named enums for exit_only

count_usable_descriptors now uses named exit_only values:
  USABLE_DESCRIPTOR_ALL
  USABLE_DESCRIPTOR_EXIT_ONLY

Add debug logging code for descriptor counts.

This (hopefully) resolves nickm's request in bug 13718 to improve
argument readability in nodelist.c.
Check if there are exits in the consensus

Add router_have_consensus_path() which reports whether
the consensus has exit paths, internal paths, or whether it
just doesn't know.

Used by #13718 and #13814.
Allow tor to build circuits using a consensus with no exits

If the consensus has no exits (typical of a bootstrapping
test network), allow tor to build circuits once enough
descriptors have been downloaded.

When there are no exits, we always have "enough"
exit descriptors. (We treat the proportion of available
exit descriptors as 100%.)

This assists in bootstrapping a testing Tor network.

Fixes bug 13718.
Makes bug 13161's TestingDirAuthVoteExit non-essential.
(But still useful for speeding up a bootstrap.)
Avoid building exit circuits from a consensus with no exits

Tor can now build circuits from a consensus with no exits.
But if it tries to build exit circuits, they fail and flood the logs.

The circuit types in the Exit Circuits list below will only be
built if the current consensus has exits. If it doesn't,
only the Internal Circuits will be built. (This can change
with each new consensus.)
Fixes bug #13814, causes fewer path failures due to #13817.

Exit Circuits:
    Predicted Exit Circuits
    User Traffic Circuits
    Most AP Streams
    Circuits Marked Exit
    Build Timeout Circuits (with exits)

Internal Circuits:
    Hidden Service Server Circuits
    Hidden Service Client Circuits
    Hidden Service AP Streams
    Hidden Service Intro Point Streams
    Circuits Marked Internal
    Build Timeout Circuits (with no exits)
    Other Circuits?
Add "internal" to some bootstrap statuses when no exits are available.

If the consensus does not contain Exits, Tor will only build internal
circuits. In this case, relevant statuses will contain the word "internal"
as indicated in the Tor control-spec.txt. When bootstrap completes,
Tor will be ready to handle an application requesting an internal
circuit to hidden services at ".onion" addresses.

If a future consensus contains Exits, exit circuits may become available.

Tor already notifies the user at "notice" level if they have no exits in
the consensus, and can therefor only build internal paths.

Consequential change from #13718.
Fix Reachability self-tests in test networks

Stop assuming that private addresses are local when checking
reachability in a TestingTorNetwork. Instead, when testing, assume
all OR connections are remote. (This is necessary due to many test
scenarios running all nodes on localhost.)

This assists in bootstrapping a testing Tor network.

Fixes bugs 13718 & 13924.
Increase reachability testing rate in faster Tor networks

Increase reachability testing rate proportionally when
TestingAuthDirTimeToLearnReachability has a low value.

Refactor the dirserv_test_reachability() function.

This assists in bootstrapping a testing Tor network.

Fixes bugs 13718 & 13929.
Randomise Authority Reachability Testing Sequence

Tor authorities' reachability testing of relays is predictable,
as it is sequential, always starts at the lowest fingerprints, and
checks fingerprints in numeric order. This means that authorities
that start in the same 10-second period, check the reachability
of the same relays at the same time.
(This is more of an issue in testing networks.)

To fix this, each authority picks a random start point and
sequence order when it starts reachability testing.

This may improve the accuracy, reliability, and/or security
of reachability testing.

Fixes bug 13928. Relies on fixes in bug 13929.