Skip to content
This repository has been archived by the owner on Sep 6, 2022. It is now read-only.

Disovered Addresses Event #171

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
24 changes: 24 additions & 0 deletions event/addrs.go
Expand Up @@ -80,3 +80,27 @@ type EvtLocalAddressesUpdated struct {
// wrapped in a record.Envelope and signed by the Host's private key.
SignedPeerRecord *record.Envelope
}

// DiscoveredAddressesSource represents the source of a new set
// of discovered dialable addresses.
type DiscoveredAddressesSource int

const (
// InterfaceNewListen means that the dialable addresses are interface listen addresses.
InterfaceNewListen DiscoveredAddressesSource = iota
// ExternallyObserved means the dialable addresses are addresses observed by remote peers on connections.
ExternallyObserved
// UPnP means the dialable addresses are new addresses assigned by UPnP port mappings.
UPnP
// NetRoute means the dialable addresses are new interface addresses as determined by NetRoute.
NetRoute
)

// EvtDiscoveredAddresses should be emitted when a new dialable address is discovered by a system.
// This dialable address would then be verified by a system such as AutoNAT.
type EvtDiscoveredAddresses struct {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we have each event provide a single discovered address?
anyone watching for new addresses will already be wanting to aggregate since addresses may arrive at the same time (e.g. startup) form multiple sources. We can probably reduce the second aggregation here for simplicity

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@willscott But imagine a scenario wherein the "default route" changes and we want to send the new interface addresses. Are you saying we'd send two events here for each new interface address ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer getting two events, since the default route changing also likely will occur at the same time as different externally discovered and different netroute events.

// Source contains the source system that discovers these dialable addresses.
Source DiscoveredAddressesSource
// Addresses contains the dialable addresses discovered.
Addresses []ma.Multiaddr
}