From a61adb53582d333d6399263bc37d4d22018009ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrien=20B=C3=A9raud?= <adrien.beraud@savoirfairelinux.com> Date: Wed, 23 Aug 2023 09:31:02 -0400 Subject: [PATCH] pupnp: init on default ipv4 interface Change-Id: I149e0e007c570c36dca2b3fa98d099fe6aeaedf7 --- src/upnp/protocol/pupnp/pupnp.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) 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 @@ PUPnP::initUpnpLib() { 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 @@ PUPnP::ctrlPtCallback(Upnp_EventType event_type, const void* event, void* user_d 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_) -- GitLab