addConn is called both when we add a dialed and an accepted connection to the
swarm. InterceptAddrDial is only supposed to intercept outgoing connections
though. When dialing, we already call InterceptAddrDial when we compose the
list of dialable addresses.
It's impossible to run two nodes on the same IP:port, so we know for
sure that any dial to an address that we're listening on will fail (as
the peer IDs won't match).
In practice, this will be most useful for preventing dials to localhost
for nodes that are listening on the default port.
When we close a connection, we set the "stream" set to nil to avoid opening new
stream. Unfortunately, this meant we wouldn't decrement the reference count on
the swarm.
Removes:
* go-libp2p-conn logic (moved to transports)
* go-libp2p-peerstream (moved here)
Changes:
* New transport interface.
* Explicit over implicit (the implicit automagic now all lives in go-libp2p):
* No more default transports, muxers, etc.
* No more fallback dialer. Transports are now *required*.
* Stream opening:
* Connection picking logic (instead of just picking the first).
* Tries harder to open a stream of some connections happen to be closed.
* Stream closing:
* No longer treats half-closed streams as fully closed. Users *must* read the
an EOF or reset the stream for it to be garbage collected.
* No more polling for dead connections.
* Multiplexers are now *non-optional*. Really, they haven't been optional for a
while but we still pretended that they were.
* No more Network type alias. It added a bunch of code and didn't really provide
anything but an alternative set of methods that do the same thing.
* Notifications:
* New guarantee: connection open notifications will complete before connection
close notifications begin.
* Given that, notifications are now delivered in parallel. No more
notification backlogs blocking connection closing/opening.
Previously we were unable to dial on a given transport if there were no
listener addresses defined for that. This meant that most people couldnt
use utp (as they had no utp listener transport to dial from).