From b0eaec47cd776f633b6607f2be85531cdf1aadd6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C8=98tefan=20Talpalaru?= Date: Wed, 14 Dec 2022 08:31:48 +0100 Subject: [PATCH] fix: re-enable port forwarding (#4343) --- libtransmission/port-forwarding-upnp.cc | 4 ++-- libtransmission/session.cc | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/libtransmission/port-forwarding-upnp.cc b/libtransmission/port-forwarding-upnp.cc index f58621868..f41a0b882 100644 --- a/libtransmission/port-forwarding-upnp.cc +++ b/libtransmission/port-forwarding-upnp.cc @@ -284,11 +284,11 @@ tr_port_forwarding_state tr_upnpPulse(tr_upnp* handle, tr_port port, bool is_ena FreeUPNPUrls(&handle->urls); auto lanaddr = std::array{}; - if (UPNP_GetValidIGD(devlist, &handle->urls, &handle->data, std::data(lanaddr), std::size(lanaddr)) == + if (UPNP_GetValidIGD(devlist, &handle->urls, &handle->data, std::data(lanaddr), std::size(lanaddr) - 1) == UPNP_IGD_VALID_CONNECTED) { tr_logAddInfo(fmt::format(_("Found Internet Gateway Device '{url}'"), fmt::arg("url", handle->urls.controlURL))); - tr_logAddInfo(fmt::format(_("Local Address is '{address}'"), fmt::arg("address", handle->lanaddr.data()))); + tr_logAddInfo(fmt::format(_("Local Address is '{address}'"), fmt::arg("address", lanaddr.data()))); handle->state = UpnpState::Idle; handle->hasDiscovered = true; handle->lanaddr = std::data(lanaddr); diff --git a/libtransmission/session.cc b/libtransmission/session.cc index 8c2976b4e..fbe8aad6e 100644 --- a/libtransmission/session.cc +++ b/libtransmission/session.cc @@ -666,6 +666,11 @@ void tr_session::setSettings(tr_session_settings&& settings_in, bool force) addr_changed = true; } + if (auto const& val = new_settings.port_forwarding_enabled; force || val != old_settings.port_forwarding_enabled) + { + tr_sessionSetPortForwardingEnabled(this, val); + } + if (port_changed) { port_forwarding_->localPortChanged();