Compare commits

...
6 Commits
5 changed files with 40 additions and 11 deletions
+19 -3
View File
@@ -11,6 +11,8 @@
#include <assert.h> #include <assert.h>
#include <stdlib.h> #include <stdlib.h>
#include "..\version.h"
#pragma comment(lib, "miniupnpc.lib") #pragma comment(lib, "miniupnpc.lib")
#pragma comment(lib, "libnatpmp.lib") #pragma comment(lib, "libnatpmp.lib")
#pragma comment(lib, "ws2_32.lib") #pragma comment(lib, "ws2_32.lib")
@@ -25,7 +27,6 @@
#include <natpmp.h> #include <natpmp.h>
#define NL "\n" #define NL "\n"
#define STR(x) #x
#define SERVICE_NAME "MISS" #define SERVICE_NAME "MISS"
#define UPNP_SERVICE_NAME "Moonlight" #define UPNP_SERVICE_NAME "Moonlight"
@@ -149,10 +150,11 @@ bool UPnPMapPort(struct UPNPUrls* urls, struct IGDdatas* data, int proto, const
} }
// Create or update the expiration time of an existing mapping // Create or update the expiration time of an existing mapping
snprintf(leaseDuration, sizeof(leaseDuration), "%d", PORT_MAPPING_DURATION_SEC);
printf("Updating UPnP port mapping for %s %s -> %s...", protoStr, portStr, myAddr); printf("Updating UPnP port mapping for %s %s -> %s...", protoStr, portStr, myAddr);
err = UPNP_AddPortMapping( err = UPNP_AddPortMapping(
urls->controlURL, data->first.servicetype, portStr, urls->controlURL, data->first.servicetype, portStr,
portStr, myAddr, myDesc, protoStr, nullptr, STR(PORT_MAPPING_DURATION_SEC)); portStr, myAddr, myDesc, protoStr, nullptr, leaseDuration);
if (err == 725) { // OnlyPermanentLeasesSupported if (err == 725) { // OnlyPermanentLeasesSupported
err = UPNP_AddPortMapping( err = UPNP_AddPortMapping(
urls->controlURL, data->first.servicetype, portStr, urls->controlURL, data->first.servicetype, portStr,
@@ -385,9 +387,20 @@ bool NATPMPMapPort(natpmp_t* natpmp, int proto, int port, bool enable)
} }
else if (response.pnu.newportmapping.mappedpublicport != port) { else if (response.pnu.newportmapping.mappedpublicport != port) {
printf("CONFLICT" NL); printf("CONFLICT" NL);
// Some buggy routers (Untangle) will change the *internal* port when
// adjusting a port mapping request that collides. This is why we also
// pass privateport back from the response and not from the port we originally
// asked for. Warn in this case.
if (response.pnu.newportmapping.privateport != port) {
printf("Buggy router changed the internal port when handling NAT-PMP conflict! (%d -> %d)" NL,
port, response.pnu.newportmapping.privateport);
}
// It couldn't assign us the external port we requested and gave us an alternate external port. // It couldn't assign us the external port we requested and gave us an alternate external port.
// We can't use this alternate mapping, so immediately release it. // We can't use this alternate mapping, so immediately release it.
sendnewportmappingrequest(natpmp, natPmpProto, port, response.pnu.newportmapping.mappedpublicport, 0); sendnewportmappingrequest(natpmp, natPmpProto, response.pnu.newportmapping.privateport,
response.pnu.newportmapping.mappedpublicport, 0);
return false; return false;
} }
else { else {
@@ -537,6 +550,9 @@ void ResetLogFile()
// Redirect stdout to this new file // Redirect stdout to this new file
freopen(currentLogFilePath, "w", stdout); freopen(currentLogFilePath, "w", stdout);
// Print a log header
printf("Moonlight Internet Streaming Service v" VER_VERSION_STR NL);
} }
DWORD WINAPI GameStreamStateChangeThread(PVOID Context) DWORD WINAPI GameStreamStateChangeThread(PVOID Context)
+2 -2
View File
@@ -2,7 +2,7 @@
#include "../version.h" #include "../version.h"
VS_VERSION_INFO VERSIONINFO VS_VERSION_INFO VERSIONINFO
FILEVERSION VER_FILEVERSION FILEVERSION VER_VERSION
BEGIN BEGIN
BLOCK "StringFileInfo" BLOCK "StringFileInfo"
BEGIN BEGIN
@@ -10,7 +10,7 @@ BEGIN
BEGIN BEGIN
VALUE "CompanyName", VER_COMPANYNAME_STR VALUE "CompanyName", VER_COMPANYNAME_STR
VALUE "FileDescription", "Moonlight Internet Streaming Service" VALUE "FileDescription", "Moonlight Internet Streaming Service"
VALUE "FileVersion", VER_FILEVERSION_STR VALUE "ProductName", VER_PRODUCTNAME_STR
END END
END END
+13 -2
View File
@@ -12,6 +12,8 @@
#include <shellapi.h> #include <shellapi.h>
#include <objbase.h> #include <objbase.h>
#include "..\version.h"
#pragma comment(lib, "miniupnpc.lib") #pragma comment(lib, "miniupnpc.lib")
#pragma comment(lib, "libnatpmp.lib") #pragma comment(lib, "libnatpmp.lib")
#pragma comment(lib, "ws2_32.lib") #pragma comment(lib, "ws2_32.lib")
@@ -618,6 +620,9 @@ bool CheckWANAccess(PSOCKADDR_IN wanAddr, PSOCKADDR_IN reportedWanAddr, bool* fo
FreeUPNPUrls(&urls); FreeUPNPUrls(&urls);
} }
else {
printf("No UPnP devices detected\n");
}
} }
// Use the delay of upnpDiscoverAll() to also allow the NAT-PMP endpoint time to respond // Use the delay of upnpDiscoverAll() to also allow the NAT-PMP endpoint time to respond
@@ -710,6 +715,12 @@ int main(int argc, char* argv[])
snprintf(logFilePath, sizeof(logFilePath), "%s\\%s", tempPath, "mis-test.log"); snprintf(logFilePath, sizeof(logFilePath), "%s\\%s", tempPath, "mis-test.log");
freopen(logFilePath, "w", stdout); freopen(logFilePath, "w", stdout);
// Print a log header
printf("Moonlight Internet Streaming Tester v" VER_VERSION_STR "\n");
// Print a console header
fprintf(stderr, "Moonlight Internet Streaming Tester v" VER_VERSION_STR "\n\n");
int err = WSAStartup(MAKEWORD(2, 2), &wsaData); int err = WSAStartup(MAKEWORD(2, 2), &wsaData);
if (err != NO_ERROR) { if (err != NO_ERROR) {
DisplayMessage("Unable to initialize WinSock"); DisplayMessage("Unable to initialize WinSock");
@@ -773,7 +784,7 @@ int main(int argc, char* argv[])
if (igdDisconnected) { if (igdDisconnected) {
DisplayMessage("Your router reports to be disconnected from the Internet. Make sure UPnP is enabled in your router settings. " DisplayMessage("Your router reports to be disconnected from the Internet. Make sure UPnP is enabled in your router settings. "
"If this message persists, make sure your router isn't connected to the Internet through another router. If it is, switch one of the routers to bridge mode.\n\n" "If this message persists, make sure your router isn't connected to the Internet through another router. If it is, switch one of the routers to bridge/AP mode.\n\n"
"Just in case this warning is due to a buggy router, the test will continue anyway.", MpWarn, false); "Just in case this warning is due to a buggy router, the test will continue anyway.", MpWarn, false);
} }
@@ -797,7 +808,7 @@ int main(int argc, char* argv[])
printf("Testing GameStream ports via STUN-reported WAN address\n"); printf("Testing GameStream ports via STUN-reported WAN address\n");
if (!TestAllPorts(&ss, portMsgBuf, sizeof(portMsgBuf))) { if (!TestAllPorts(&ss, portMsgBuf, sizeof(portMsgBuf))) {
if (IsDoubleNAT(&locallyReportedWanAddr)) { if (IsDoubleNAT(&locallyReportedWanAddr)) {
DisplayMessage("Your router appears be connected to the Internet through another router. This configuration breaks port forwarding. To resolve this, switch one of the routers into bridge mode."); snprintf(msgBuf, sizeof(msgBuf), "Your router appears be connected to the Internet through another router. This configuration breaks port forwarding. To resolve this, switch one of the routers into bridge/AP mode.");
DisplayMessage(msgBuf); DisplayMessage(msgBuf);
} }
else if (IsPossibleCGN(&locallyReportedWanAddr)) { else if (IsPossibleCGN(&locallyReportedWanAddr)) {
+2 -2
View File
@@ -2,7 +2,7 @@
#include "../version.h" #include "../version.h"
VS_VERSION_INFO VERSIONINFO VS_VERSION_INFO VERSIONINFO
FILEVERSION VER_FILEVERSION FILEVERSION VER_VERSION
BEGIN BEGIN
BLOCK "StringFileInfo" BLOCK "StringFileInfo"
BEGIN BEGIN
@@ -10,7 +10,7 @@ BEGIN
BEGIN BEGIN
VALUE "CompanyName", VER_COMPANYNAME_STR VALUE "CompanyName", VER_COMPANYNAME_STR
VALUE "FileDescription", "Moonlight Internet Streaming Tester" VALUE "FileDescription", "Moonlight Internet Streaming Tester"
VALUE "FileVersion", VER_FILEVERSION_STR VALUE "ProductName", VER_PRODUCTNAME_STR
END END
END END
+4 -2
View File
@@ -1,5 +1,7 @@
#pragma once #pragma once
#define VER_VERSION 1,3,0,0
#define VER_VERSION_STR "1.3.0.0"
#define VER_COMPANYNAME_STR "Moonlight Game Streaming Project" #define VER_COMPANYNAME_STR "Moonlight Game Streaming Project"
#define VER_FILEVERSION 1,2,0,0 #define VER_PRODUCTNAME_STR "Moonlight Internet Streaming Helper"
#define VER_FILEVERSION_STR "1.2.0.0\0"