nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
fork

Configure Feed

Select the types of activity you want to include in your feed.

sunshine: add upstream patch for miniupnpc 2.2.8

Emily 2bf72c41 22574208

+126
+120
pkgs/servers/sunshine/0001-fix-upnp-support-newer-miniupnpc-library-2782.patch
··· 1 + From f4f1800f5e67ab59312ccf710695acf06fb4ae26 Mon Sep 17 00:00:00 2001 2 + From: ReenigneArcher <42013603+ReenigneArcher@users.noreply.github.com> 3 + Date: Mon, 1 Jul 2024 10:07:06 -0400 4 + Subject: [PATCH] fix(upnp): support newer miniupnpc library (#2782) 5 + 6 + Co-authored-by: Vithorio Polten <reach@vithor.io> 7 + --- 8 + src/upnp.cpp | 30 +++++++++++++++--------------- 9 + src/upnp.h | 31 ++++++++++++++++++++++++++++++- 10 + 2 files changed, 45 insertions(+), 16 deletions(-) 11 + 12 + diff --git a/src/upnp.cpp b/src/upnp.cpp 13 + index f65bcb87..fcbaaeb5 100644 14 + --- a/src/upnp.cpp 15 + +++ b/src/upnp.cpp 16 + @@ -19,19 +19,6 @@ 17 + using namespace std::literals; 18 + 19 + namespace upnp { 20 + - constexpr auto INET6_ADDRESS_STRLEN = 46; 21 + - 22 + - constexpr auto PORT_MAPPING_LIFETIME = 3600s; 23 + - constexpr auto REFRESH_INTERVAL = 120s; 24 + - 25 + - constexpr auto IPv4 = 0; 26 + - constexpr auto IPv6 = 1; 27 + - 28 + - using device_t = util::safe_ptr<UPNPDev, freeUPNPDevlist>; 29 + - 30 + - KITTY_USING_MOVE_T(urls_t, UPNPUrls, , { 31 + - FreeUPNPUrls(&el); 32 + - }); 33 + 34 + struct mapping_t { 35 + struct { 36 + @@ -59,6 +46,19 @@ namespace upnp { 37 + return "Unknown status"sv; 38 + } 39 + 40 + + /** 41 + + * This function is a wrapper around UPNP_GetValidIGD() that returns the status code. There is a pre-processor 42 + + * check to determine which version of the function to call based on the version of the MiniUPnPc library. 43 + + */ 44 + + int 45 + + UPNP_GetValidIGDStatus(device_t &device, urls_t *urls, IGDdatas *data, std::array<char, INET6_ADDRESS_STRLEN> &lan_addr) { 46 + +#if (MINIUPNPC_API_VERSION >= 18) 47 + + return UPNP_GetValidIGD(device.get(), &urls->el, data, lan_addr.data(), lan_addr.size(), nullptr, 0); 48 + +#else 49 + + return UPNP_GetValidIGD(device.get(), &urls->el, data, lan_addr.data(), lan_addr.size()); 50 + +#endif 51 + + } 52 + + 53 + class deinit_t: public platf::deinit_t { 54 + public: 55 + deinit_t() { 56 + @@ -109,7 +109,7 @@ namespace upnp { 57 + IGDdatas data; 58 + urls_t urls; 59 + std::array<char, INET6_ADDRESS_STRLEN> lan_addr; 60 + - auto status = UPNP_GetValidIGD(device.get(), &urls.el, &data, lan_addr.data(), lan_addr.size()); 61 + + auto status = upnp::UPNP_GetValidIGDStatus(device, &urls, &data, lan_addr); 62 + if (status != 1 && status != 2) { 63 + BOOST_LOG(debug) << "No valid IPv6 IGD: "sv << status_string(status); 64 + return false; 65 + @@ -331,7 +331,7 @@ namespace upnp { 66 + std::array<char, INET6_ADDRESS_STRLEN> lan_addr; 67 + 68 + urls_t urls; 69 + - auto status = UPNP_GetValidIGD(device.get(), &urls.el, &data, lan_addr.data(), lan_addr.size()); 70 + + auto status = upnp::UPNP_GetValidIGDStatus(device, &urls, &data, lan_addr); 71 + if (status != 1 && status != 2) { 72 + BOOST_LOG(error) << status_string(status); 73 + mapped = false; 74 + diff --git a/src/upnp.h b/src/upnp.h 75 + index 73fc4f79..4b2e3296 100644 76 + --- a/src/upnp.h 77 + +++ b/src/upnp.h 78 + @@ -4,9 +4,38 @@ 79 + */ 80 + #pragma once 81 + 82 + +#include <miniupnpc/miniupnpc.h> 83 + + 84 + #include "platform/common.h" 85 + 86 + namespace upnp { 87 + + constexpr auto INET6_ADDRESS_STRLEN = 46; 88 + + constexpr auto IPv4 = 0; 89 + + constexpr auto IPv6 = 1; 90 + + constexpr auto PORT_MAPPING_LIFETIME = 3600s; 91 + + constexpr auto REFRESH_INTERVAL = 120s; 92 + + 93 + + using device_t = util::safe_ptr<UPNPDev, freeUPNPDevlist>; 94 + + 95 + + KITTY_USING_MOVE_T(urls_t, UPNPUrls, , { 96 + + FreeUPNPUrls(&el); 97 + + }); 98 + + 99 + + /** 100 + + * @brief Get the valid IGD status. 101 + + * @param device The device. 102 + + * @param urls The URLs. 103 + + * @param data The IGD data. 104 + + * @param lan_addr The LAN address. 105 + + * @return The UPnP Status. 106 + + * @retval 0 No IGD found. 107 + + * @retval 1 A valid connected IGD has been found. 108 + + * @retval 2 A valid IGD has been found but it reported as not connected. 109 + + * @retval 3 An UPnP device has been found but was not recognized as an IGD. 110 + + */ 111 + + int 112 + + UPNP_GetValidIGDStatus(device_t &device, urls_t *urls, IGDdatas *data, std::array<char, INET6_ADDRESS_STRLEN> &lan_addr); 113 + + 114 + [[nodiscard]] std::unique_ptr<platf::deinit_t> 115 + start(); 116 + -} 117 + +} // namespace upnp 118 + -- 119 + 2.45.2 120 +
+6
pkgs/servers/sunshine/default.nix
··· 62 62 fetchSubmodules = true; 63 63 }; 64 64 65 + patches = [ 66 + # fix(upnp): support newer miniupnpc library (#2782) 67 + # Manually cherry-picked on to 0.23.1. 68 + ./0001-fix-upnp-support-newer-miniupnpc-library-2782.patch 69 + ]; 70 + 65 71 # build webui 66 72 ui = buildNpmPackage { 67 73 inherit src version;