From e62ed6ccc52e8f645d5b34192de608b33b7f6635 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Mon, 5 Nov 2018 17:49:27 -0800 Subject: [PATCH] Try deleting conflicting UPnP mappings --- miss/miss.cpp | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/miss/miss.cpp b/miss/miss.cpp index c42d0bf..aeda39b 100644 --- a/miss/miss.cpp +++ b/miss/miss.cpp @@ -134,10 +134,23 @@ bool UPnPMapPort(struct UPNPUrls* urls, struct IGDdatas* data, int proto, const } } else { - // UPnP IGDs won't let unauthenticated clients delete other conflicting port mappings - // for security reasons, so we have to give up in this case. printf("CONFLICT: %s %s" NL, intClient, desc); - return false; + + // Some UPnP IGDs won't let unauthenticated clients delete other conflicting port mappings + // for security reasons, but we will give it a try anyway. + printf("Trying to delete conflicting UPnP mapping for %s %s -> %s...", protoStr, portStr, intClient); + err = UPNP_DeletePortMapping(urls->controlURL, data->first.servicetype, portStr, protoStr, nullptr); + if (err == UPNPCOMMAND_SUCCESS) { + printf("OK" NL); + } + else if (err == 606) { + printf("UNAUTHORIZED" NL); + return false; + } + else { + printf("ERROR %d" NL, err); + return false; + } } } else {