diff --git a/p2p/host/basic/basic_host.go b/p2p/host/basic/basic_host.go index aac8e46b1b..d0c23af9aa 100644 --- a/p2p/host/basic/basic_host.go +++ b/p2p/host/basic/basic_host.go @@ -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() {