fix: re-expose AutoNAT service on BasicHost

Unfortunately, lotus relies on this and we don't have a good alternative
at the moment.

1. The "correct" way to get the status is to subscribe to the
"discoverability" events and read the first event (you're guaranteed to
see a "current status" event). However, this is a bit annoying.
2. Ideally, you'd call host.Addrs() to get the list of "good" addresses.
Unfortunately, we don't feed enough information back into the Host from
AutoNAT for this to be truly useful (yet).
This commit is contained in:
Steven Allen 2021-05-04 20:21:22 -07:00
parent a8e8215edc
commit e482b45c66
1 changed files with 7 additions and 0 deletions

View File

@ -1007,6 +1007,13 @@ func (h *BasicHost) SetAutoNat(a autonat.AutoNAT) {
}
}
// Return the host's AutoNAT service, if AutoNAT is enabled.
func (h *BasicHost) GetAutoNat() autonat.AutoNAT {
h.addrMu.Lock()
defer h.addrMu.Unlock()
return h.autoNat
}
// Close shuts down the Host's services (network, etc).
func (h *BasicHost) Close() error {
h.closeSync.Do(func() {