Try deleting conflicting UPnP mappings

This commit is contained in:
Cameron Gutman 2018-11-05 17:49:27 -08:00
parent 774878ed17
commit e62ed6ccc5

View File

@ -134,11 +134,24 @@ bool UPnPMapPort(struct UPNPUrls* urls, struct IGDdatas* data, int proto, const
} }
} }
else { 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); printf("CONFLICT: %s %s" NL, intClient, desc);
// 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; return false;
} }
else {
printf("ERROR %d" NL, err);
return false;
}
}
} }
else { else {
printf("ERROR %d (%s)" NL, err, strupnperror(err)); printf("ERROR %d (%s)" NL, err, strupnperror(err));