KTorrent uPnP plugin just don't see the d-link router model DIR-300 (and very likely many others). KTorrent/ktupnptest log looks like that: Detected IGD Debian/squeeze/sid UPnP/1.0 MiniUPnPd/1.6 Downloading XML file Failed to download : Malformed URL Note the absence of URL in log while it is supposed to be printed. I found a solution for that issue. Dlink uPnP service spells "location" header as "lOCATION" (with lower-case L, I almost spilled my coffee when found that) which confuses libktorrent expecting "Location", "location" or "LOCATION". I might be wrong but HTTP standard states headers are case-insensitive and thus d-link's MiniUPnPd behavior is silly but valid and ktorrent should accept such responses. I paste a trivial patch in Additional Information section. I applied it and and uPnP now works for me. Reproducible: Always Steps to Reproduce: 1. Have d-link DIR-300 2. Activate uPnP in ktorrent Actual Results: Nothing happens. Expected Results: Ports being forwarded. A typical D-Link MiniUPnPd response (it sends bunch of them with variations after "SERVER:" part): ===================== NOTIFY * HTTP/1.1 HOST: 239.255.255.250:1900 CACHE-CONTROL: max-age=120 lOCATION: http://192.168.0.1:4649/rootDesc.xml SERVER: Debian/squeeze/sid UPnP/1.0 MiniUPnPd/1.6 NT: urn:schemas-upnp-org:device:WANConnectionDevice:1 USN: uuid:00000000-466f-0000-0000-466f00000000::urn:schemas-upnp-org:device:WANConnectionDevice:1 NTS: ssdp:alive OPT: "http://schemas.upnp.org/upnp/1/0/"; 01-NLS: 1 BOOTID.UPNP.ORG: 1 CONFIGID.UPNP.ORG: 1337 ===================== Proposed patch: ===================== From b9948b112132d1654aa6b52cc8b6ade908973130 Mon Sep 17 00:00:00 2001 From: Oleg Osipov <legolegs@yandex.ru> Date: Tue, 9 Dec 2014 22:37:39 +0300 Subject: [PATCH] Made HTTP header match case-insensitive. Fixes issue with d-link DIR-300. --- src/upnp/upnpmcastsocket.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/upnp/upnpmcastsocket.cpp b/src/upnp/upnpmcastsocket.cpp index 286952c..0c07a2e 100644 --- a/src/upnp/upnpmcastsocket.cpp +++ b/src/upnp/upnpmcastsocket.cpp @@ -343,13 +343,13 @@ namespace bt for (int i = 1;i < lines.count();i++) { line = lines[i]; - if (line.startsWith("Location") || line.startsWith("LOCATION") || line.startsWith("location")) + if (line.startsWith("location", Qt::CaseInsensitive)) { location = line.mid(line.indexOf(':') + 1).trimmed(); if (!location.isValid()) return 0; } - else if (line.startsWith("Server") || line.startsWith("server") || line.startsWith("SERVER")) + else if (line.startsWith("server", Qt::CaseInsensitive)) { server = line.mid(line.indexOf(':') + 1).trimmed(); if (server.length() == 0) -- 1.8.3.1 =====================
Created attachment 89890 [details] Made HTTP header match case-insensitive. Fixes issue with d-link DIR-300
Please post the patch here: https://git.reviewboard.kde.org/r/new/
Done: https://git.reviewboard.kde.org/r/121463/
Git commit ac4455532a73c1e98426b71a30c3f3e98c702463 by Martin T. H. Sandsmark. Committed on 06/10/2016 at 21:38. Pushed by sandsmark into branch 'master'. Fix parsing of headers from certain D-Link routers Dlink uPnP service spells "location" header as "lOCATION" (with lower-case L) which confuses libktorrent expecting "Location", "location" or "LOCATION". This patch makes uPnP plugin accept those headers since they are valid. Modified version of patch from Oleg Osipov. REVIEW: 121463 M +2 -2 src/upnp/upnpmcastsocket.cpp http://commits.kde.org/libktorrent/ac4455532a73c1e98426b71a30c3f3e98c702463