Consolidate the logic to determine connection type into one conditional to
clarify how they are chosen.
This is a backport of core#19724 [7/9]
https://github.com/bitcoin/bitcoin/pull/19724/commits/4829b6fcc6489b445f80689af6c2a1a919f176b1
Depends on D9775