listener.go
func getUPNPExternalAddress(externalPort, internalPort int) *NetAddress {
	log.Info("Getting UPNP external address")
	nat, err := upnp.Discover()
	if err != nil {
		log.Info("Could not perform UPNP discover", "error", err)
		return nil
	}

	ext, err := nat.GetExternalAddress()
	if err != nil {
		log.Info("Could not get UPNP external address", "error", err)
		return nil
	}

	// UPnP can't seem to get the external port, so let's just be explicit.
	if externalPort == 0 {
		externalPort = defaultExternalPort
	}

	externalPort, err = nat.AddPortMapping("tcp", externalPort, internalPort, "tendermint", 0)
	if err != nil {
		log.Info("Could not add UPNP port mapping", "error", err)
		return nil
	}

	log.Info("Got UPNP external address", "address", ext)
	return NewNetAddressIPPort(ext, uint16(externalPort))
}
func getUPNPExternalAddress(externalPort, internalPort int) *NetAddress {
	log.Info("Getting UPNP external address")
	nat, err := upnp.Discover()
	if err != nil {
		log.Info("Could not perform UPNP discover", "error", err)
		return nil
	}

	ext, err := nat.GetExternalAddress()
	if err != nil {
		log.Info("Could not get UPNP external address", "error", err)
		return nil
	}

	// UPnP can't seem to get the external port, so let's just be explicit.
	if externalPort == 0 {
		externalPort = defaultExternalPort
	}

	externalPort, err = nat.AddPortMapping("tcp", externalPort, internalPort, "tendermint", 0)
	if err != nil {
		log.Info("Could not add UPNP port mapping", "error", err)
		return nil
	}

	log.Info("Got UPNP external address", "address", ext)
	return NewNetAddressIPPort(ext, uint16(externalPort))
}
/* external address helpers */
// UPNP external address discovery & port mapping