libp2p
    Preparing search index...

    The AddressManager provides an interface for managing peer addresses in libp2p. It supports handling multiple types of addresses, verifying their validity, and storing mappings between internal and external addresses.

    interface AddressManager {
        addDNSMapping(domain: string, ipAddresses: string[]): void;
        addObservedAddr(addr: Multiaddr): void;
        addPublicAddressMapping(
            internalIp: string,
            internalPort: number,
            externalIp: string,
            externalPort?: number,
            protocol?: "tcp" | "udp",
        ): void;
        confirmObservedAddr(addr: Multiaddr, options?: ConfirmAddressOptions): void;
        getAddresses(): Multiaddr[];
        getAddressesWithMetadata(): NodeAddress[];
        getAnnounceAddrs(): Multiaddr[];
        getListenAddrs(): Multiaddr[];
        getObservedAddrs(): Multiaddr[];
        removeDNSMapping(domain: string): void;
        removeObservedAddr(addr: Multiaddr): void;
        removePublicAddressMapping(
            internalIp: string,
            internalPort: number,
            externalIp: string,
            externalPort?: number,
            protocol?: "tcp" | "udp",
        ): void;
    }
    Index

    Methods

    • Adds a mapping between one or more IP addresses and a domain name - when getAddresses is invoked, where the IP addresses are present in a multiaddr, an additional multiaddr will be added with ip4 and ip6 tuples replaced with dns4 and `dns6 ones respectively.

      Parameters

      • domain: string

        The domain name to map.

      • ipAddresses: string[]

        The associated IP addresses.

      Returns void

    • Add a publicly routable address/port/protocol tuple that this node is reachable on. Where this node listens on a link-local (e.g. LAN) address with the same protocol for any transport, an additional listen address will be added with the IP and port replaced with this IP and port.

      It's possible to add a IPv6 address here and have it added to the address list, this is for the case when a router has an external IPv6 address with port forwarding configured, but it does IPv6 -> IPv4 NAT.

      Parameters

      • internalIp: string

        The internal IP address.

      • internalPort: number

        The internal port number.

      • externalIp: string

        The external IP address.

      • OptionalexternalPort: number

        The external port number (optional).

      • Optionalprotocol: "tcp" | "udp"

        The transport protocol (tcp or udp).

      Returns void

    • Remove a publicly routable address that this node is no longer reachable on

      Parameters

      • internalIp: string

        The internal IP address.

      • internalPort: number

        The internal port number.

      • externalIp: string

        The external IP address.

      • OptionalexternalPort: number

        The external port number (optional).

      • Optionalprotocol: "tcp" | "udp"

        The transport protocol (tcp or udp).

      Returns void