diff --git a/packages/interface-libp2p/src/index.ts b/packages/interface-libp2p/src/index.ts index c62d7466e..f3efe3aa6 100644 --- a/packages/interface-libp2p/src/index.ts +++ b/packages/interface-libp2p/src/index.ts @@ -46,6 +46,34 @@ export interface PeerUpdate { previous?: Peer } +/** + * A address this node knows about + */ +export interface NodeAddress { + /** + * This address as a multiaddr + */ + multiaddr: Multiaddr + + /** + * If `true`, this address is advertised to the network via peer records and the + * Identify protocols + */ + announce?: boolean + + /** + * If `true`, this address was observed by remote peers and communicated back to + * this node via the AutoNAT protocol + */ + observed?: boolean + + /** + * Only set on `observed` addresses - if `true` the node has confidence that this + * address is publicly routable and remote peers can dial it + */ + confidence?: boolean +} + /** * Once you have a libp2p instance, you can listen to several events it emits, * so that you can be notified of relevant network events. @@ -404,6 +432,22 @@ export interface Libp2p extends Startable, EventEmitter { */ getMultiaddrs: () => Multiaddr[] + /** + * Returns a list of address this node is listening on and the status + * of those addresses + * + * @example + * + * ```js + * const listenMa = libp2p.getAddresses() + * // [{ + * // multiaddr: + * // announce: true + * // }] + * ``` + */ + getAddresses: () => NodeAddress[] + /** * Returns a list of supported protocols *