Merge pull request #126 from libp2p/feat/single-routability-event

Switch to a single routability event
This commit is contained in:
Steven Allen 2020-03-04 21:15:24 -08:00 committed by GitHub
commit d143201d83
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 32 additions and 21 deletions

13
event/reachability.go Normal file
View File

@ -0,0 +1,13 @@
package event
import (
"github.com/libp2p/go-libp2p-core/network"
)
// EvtLocalReachabilityChanged is an event struct to be emitted when the local's
// node reachability changes state.
//
// This event is usually emitted by the AutoNAT subsystem.
type EvtLocalReachabilityChanged struct {
Reachability network.Reachability
}

View File

@ -1,21 +0,0 @@
package event
// EvtLocalRoutabilityPrivate is an event struct to be emitted with the local's
// node routability changes to PRIVATE (i.e. not routable from the Internet).
//
// This event is usually emitted by the AutoNAT subsystem.
type EvtLocalRoutabilityPrivate struct{}
// EvtLocalRoutabilityPublic is an event struct to be emitted with the local's
// node routability changes to PUBLIC (i.e. appear to routable from the
// Internet).
//
// This event is usually emitted by the AutoNAT subsystem.
type EvtLocalRoutabilityPublic struct{}
// EvtLocalRoutabilityUnknown is an event struct to be emitted with the local's
// node routability changes to UNKNOWN (i.e. we were unable to make a
// determination about our NAT status with enough confidence).
//
// This event is usually emitted by the AutoNAT subsystem.
type EvtLocalRoutabilityUnknown struct{}

View File

@ -53,6 +53,25 @@ const (
CannotConnect
)
// Reachability indicates how reachable a node is.
type Reachability int
const (
// ReachabilityUnknown indicates that the reachability status of the
// node is unknown.
ReachabilityUnknown = iota
// ReachabilityPublic indicates that the node is reachable from the
// public internet.
ReachabilityPublic
// ReachabilityPrivate indicates that the node is not reachable from the
// public internet.
//
// NOTE: This node may _still_ be reachable via relays.
ReachabilityPrivate
)
// Stat stores metadata pertaining to a given Stream/Conn.
type Stat struct {
Direction Direction