pupnp: init on default ipv4 interface
Change-Id: I149e0e007c570c36dca2b3fa98d099fe6aeaedf7
diff --git a/src/upnp/protocol/pupnp/pupnp.cpp b/src/upnp/protocol/pupnp/pupnp.cpp
index b902e00..403a704 100644
--- a/src/upnp/protocol/pupnp/pupnp.cpp
+++ b/src/upnp/protocol/pupnp/pupnp.cpp
@@ -112,7 +112,11 @@
{
assert(not initialized_);
- int upnp_err = UpnpInit2(nullptr, 0);
+ auto hostinfo = ip_utils::getHostName();
+
+ if (logger_) logger_->debug("PUPnP: Initializing libupnp {} {}", hostinfo.address, hostinfo.interface);
+
+ int upnp_err = UpnpInit2(hostinfo.interface.empty() ? nullptr : hostinfo.interface.c_str(), 0);
if (upnp_err != UPNP_E_SUCCESS) {
if (logger_) logger_->error("PUPnP: Can't initialize libupnp: {}", UpnpGetErrorMessage(upnp_err));
@@ -693,14 +697,15 @@
auto pupnp = static_cast<PUPnP*>(user_data);
if (pupnp == nullptr) {
- // JAMI_WARN("PUPnP: Control point callback without PUPnP");
+ fmt::print(stderr, "PUPnP: Control point callback without PUPnP");
return UPNP_E_SUCCESS;
}
auto upnpThis = pupnp->weak().lock();
-
- if (not upnpThis)
+ if (not upnpThis) {
+ fmt::print(stderr, "PUPnP: Control point callback without PUPnP");
return UPNP_E_SUCCESS;
+ }
// Ignore if already unregistered.
if (not upnpThis->clientRegistered_)