|
|
|
@@ -5,15 +5,16 @@
|
|
|
|
|
#include <assert.h>
|
|
|
|
|
#include <shellapi.h>
|
|
|
|
|
#include <objbase.h>
|
|
|
|
|
#include <WinInet.h>
|
|
|
|
|
#include <WinHttp.h>
|
|
|
|
|
#include <wtsapi32.h>
|
|
|
|
|
#include <powerbase.h>
|
|
|
|
|
#include <VersionHelpers.h>
|
|
|
|
|
|
|
|
|
|
#pragma comment(lib, "miniupnpc.lib")
|
|
|
|
|
#pragma comment(lib, "libnatpmp.lib")
|
|
|
|
|
#pragma comment(lib, "ws2_32.lib")
|
|
|
|
|
#pragma comment(lib, "iphlpapi.lib")
|
|
|
|
|
#pragma comment(lib, "wininet.lib")
|
|
|
|
|
#pragma comment(lib, "winhttp.lib")
|
|
|
|
|
#pragma comment(lib, "wtsapi32.lib")
|
|
|
|
|
#pragma comment(lib, "powrprof.lib")
|
|
|
|
|
|
|
|
|
@@ -25,6 +26,8 @@
|
|
|
|
|
#define NATPMP_STATICLIB
|
|
|
|
|
#include <natpmp.h>
|
|
|
|
|
|
|
|
|
|
#define LOOPBACK_SERVER_PORT_OFFSET -10000
|
|
|
|
|
|
|
|
|
|
static struct port_entry {
|
|
|
|
|
int proto;
|
|
|
|
|
int port;
|
|
|
|
@@ -456,7 +459,7 @@ PortTestStatus TestPort(PSOCKADDR_STORAGE addr, int proto, int port, bool withSe
|
|
|
|
|
sizeof(SOCKADDR_IN) : sizeof(SOCKADDR_IN6);
|
|
|
|
|
|
|
|
|
|
RtlCopyMemory(&sin6, addr, addrLen);
|
|
|
|
|
sin6.sin6_port = htons(port);
|
|
|
|
|
sin6.sin6_port = htons(port + (isLoopbackRelay ? LOOPBACK_SERVER_PORT_OFFSET : 0));
|
|
|
|
|
|
|
|
|
|
if (proto == IPPROTO_TCP) {
|
|
|
|
|
err = connect(clientSock, (struct sockaddr*)&sin6, addrLen);
|
|
|
|
@@ -546,64 +549,96 @@ PortTestStatus TestPort(PSOCKADDR_STORAGE addr, int proto, int port, bool withSe
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
PortTestStatus TestHttpPort(PSOCKADDR_STORAGE addr, int port)
|
|
|
|
|
PortTestStatus TestHttpPort(PSOCKADDR_STORAGE addr, int port, bool isLoopbackRelay)
|
|
|
|
|
{
|
|
|
|
|
HINTERNET hInternet;
|
|
|
|
|
HINTERNET hRequest;
|
|
|
|
|
char url[1024];
|
|
|
|
|
HINTERNET hSession = nullptr;
|
|
|
|
|
HINTERNET hConnection = nullptr;
|
|
|
|
|
HINTERNET hRequest = nullptr;
|
|
|
|
|
PortTestStatus result;
|
|
|
|
|
|
|
|
|
|
hInternet = InternetOpenA("MIST", 0, nullptr, nullptr, 0);
|
|
|
|
|
if (hInternet == nullptr) {
|
|
|
|
|
fprintf(LOG_OUT, "InternetOpen() failed: %d\n", GetLastError());
|
|
|
|
|
return PortTestError;
|
|
|
|
|
hSession = WinHttpOpen(L"MIST", WINHTTP_ACCESS_TYPE_NO_PROXY, WINHTTP_NO_PROXY_NAME, WINHTTP_NO_PROXY_BYPASS, 0);
|
|
|
|
|
if (hSession == nullptr) {
|
|
|
|
|
fprintf(LOG_OUT, "WinHttpOpen() failed: %d\n", GetLastError());
|
|
|
|
|
result = PortTestError;
|
|
|
|
|
goto Exit;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
char addrStr[INET6_ADDRSTRLEN + 2];
|
|
|
|
|
// Windows 8.1 enabled TLSv1.2 for WinHTTP by default (8.0 enables it for Schannel but not WinHTTP)
|
|
|
|
|
// https://docs.microsoft.com/en-us/security/engineering/solving-tls1-problem
|
|
|
|
|
if (!IsWindows8Point1OrGreater()) {
|
|
|
|
|
DWORD protocols = WINHTTP_FLAG_SECURE_PROTOCOL_TLS1 |
|
|
|
|
|
WINHTTP_FLAG_SECURE_PROTOCOL_TLS1_1 |
|
|
|
|
|
WINHTTP_FLAG_SECURE_PROTOCOL_TLS1_2;
|
|
|
|
|
|
|
|
|
|
if (!WinHttpSetOption(hSession, WINHTTP_OPTION_SECURE_PROTOCOLS, &protocols, sizeof(protocols))) {
|
|
|
|
|
fprintf(LOG_OUT, "WinHttpSetOption(WINHTTP_OPTION_SECURE_PROTOCOLS) failed: %d\n", GetLastError());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
WCHAR urlEscapedAddr[INET6_ADDRSTRLEN + 2];
|
|
|
|
|
if (addr->ss_family == AF_INET) {
|
|
|
|
|
inet_ntop(AF_INET, &((struct sockaddr_in*)addr)->sin_addr, addrStr, sizeof(addrStr));
|
|
|
|
|
InetNtopW(AF_INET, &((struct sockaddr_in*)addr)->sin_addr, urlEscapedAddr, ARRAYSIZE(urlEscapedAddr));
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
// The address string must be escaped for usage in URLs
|
|
|
|
|
addrStr[0] = '[';
|
|
|
|
|
inet_ntop(AF_INET6, &((struct sockaddr_in6*)addr)->sin6_addr, &addrStr[1], INET6_ADDRSTRLEN);
|
|
|
|
|
strcat_s(addrStr, "]");
|
|
|
|
|
urlEscapedAddr[0] = L'[';
|
|
|
|
|
InetNtopW(AF_INET6, &((struct sockaddr_in6*)addr)->sin6_addr, &urlEscapedAddr[1], INET6_ADDRSTRLEN);
|
|
|
|
|
wcscat_s(urlEscapedAddr, L"]");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
sprintf(url, "%s://%s:%d/",
|
|
|
|
|
port == 47989 ? "http" : "https",
|
|
|
|
|
addrStr,
|
|
|
|
|
port);
|
|
|
|
|
hConnection = WinHttpConnect(hSession, urlEscapedAddr, port + (isLoopbackRelay ? LOOPBACK_SERVER_PORT_OFFSET : 0), NULL);
|
|
|
|
|
if (hConnection == nullptr) {
|
|
|
|
|
fprintf(LOG_OUT, "WinHttpConnect() failed: %d\n", GetLastError());
|
|
|
|
|
result = PortTestError;
|
|
|
|
|
goto Exit;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
hRequest = InternetOpenUrlA(hInternet, url, nullptr, 0,
|
|
|
|
|
INTERNET_FLAG_IGNORE_CERT_DATE_INVALID | INTERNET_FLAG_NO_UI | INTERNET_FLAG_NO_AUTH | INTERNET_FLAG_NO_COOKIES | INTERNET_FLAG_RELOAD,
|
|
|
|
|
NULL);
|
|
|
|
|
if (hRequest == nullptr) {
|
|
|
|
|
if (GetLastError() == ERROR_INTERNET_CLIENT_AUTH_CERT_NEEDED) {
|
|
|
|
|
hRequest = WinHttpOpenRequest(hConnection, L"GET", L"/", NULL, WINHTTP_NO_REFERER, WINHTTP_DEFAULT_ACCEPT_TYPES,
|
|
|
|
|
port == 47984 ? WINHTTP_FLAG_SECURE : 0);
|
|
|
|
|
if (hConnection == nullptr) {
|
|
|
|
|
fprintf(LOG_OUT, "WinHttpOpenRequest() failed: %d\n", GetLastError());
|
|
|
|
|
WinHttpCloseHandle(hConnection);
|
|
|
|
|
result = PortTestError;
|
|
|
|
|
goto Exit;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!WinHttpSendRequest(hRequest, WINHTTP_NO_ADDITIONAL_HEADERS, 0, WINHTTP_NO_REQUEST_DATA, 0, 0, 0) || !WinHttpReceiveResponse(hRequest, NULL)) {
|
|
|
|
|
if (GetLastError() == ERROR_WINHTTP_CLIENT_AUTH_CERT_NEEDED) {
|
|
|
|
|
// This is expected for our HTTPS connection
|
|
|
|
|
fprintf(LOG_OUT, "Success\n");
|
|
|
|
|
result = PortTestOk;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
// CANNOT_CONNECT is the "expected" error
|
|
|
|
|
if (GetLastError() == ERROR_INTERNET_CANNOT_CONNECT) {
|
|
|
|
|
if (GetLastError() == ERROR_WINHTTP_CANNOT_CONNECT) {
|
|
|
|
|
fprintf(LOG_OUT, "Failed\n");
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
fprintf(LOG_OUT, "Failed: %d\n", GetLastError());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
InternetCloseHandle(hInternet);
|
|
|
|
|
return PortTestError;
|
|
|
|
|
result = PortTestError;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
goto Exit;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
fprintf(LOG_OUT, "Success\n");
|
|
|
|
|
InternetCloseHandle(hRequest);
|
|
|
|
|
result = PortTestOk;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Exit:
|
|
|
|
|
if (hRequest != nullptr) {
|
|
|
|
|
WinHttpCloseHandle(hRequest);
|
|
|
|
|
}
|
|
|
|
|
if (hConnection != nullptr) {
|
|
|
|
|
WinHttpCloseHandle(hConnection);
|
|
|
|
|
}
|
|
|
|
|
if (hSession != nullptr) {
|
|
|
|
|
WinHttpCloseHandle(hSession);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
InternetCloseHandle(hInternet);
|
|
|
|
|
|
|
|
|
|
return PortTestOk;
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool TestAllPorts(PSOCKADDR_STORAGE addr, char* portMsg, int portMsgLen, bool isLoopbackRelay, bool consolePrint, bool* allPortsFailed = nullptr)
|
|
|
|
@@ -633,7 +668,7 @@ bool TestAllPorts(PSOCKADDR_STORAGE addr, char* portMsg, int portMsgLen, bool is
|
|
|
|
|
// TestHttpPort() can take significantly longer to timeout than TestPort(),
|
|
|
|
|
// so we only do this test if we believe we're likely to get a response.
|
|
|
|
|
fprintf(LOG_OUT, "Testing TCP %d with HTTP traffic...", k_Ports[i].port);
|
|
|
|
|
status = TestHttpPort(addr, k_Ports[i].port);
|
|
|
|
|
status = TestHttpPort(addr, k_Ports[i].port, isLoopbackRelay);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (status != PortTestOk) {
|
|
|
|
@@ -673,7 +708,7 @@ bool FindLocalInterfaceIPAddress(int family, PSOCKADDR_STORAGE addr)
|
|
|
|
|
hint.ai_socktype = SOCK_STREAM;
|
|
|
|
|
hint.ai_protocol = IPPROTO_TCP;
|
|
|
|
|
hint.ai_flags = AI_ADDRCONFIG;
|
|
|
|
|
err = getaddrinfo("moonlight-stream.org", "https", &hint, &result);
|
|
|
|
|
err = getaddrinfo("moonlight-stream.org", "443", &hint, &result);
|
|
|
|
|
if (err != 0 || result == NULL) {
|
|
|
|
|
fprintf(LOG_OUT, "getaddrinfo() failed: %d\n", err);
|
|
|
|
|
return false;
|
|
|
|
@@ -1231,8 +1266,6 @@ int main(int argc, char* argv[])
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fprintf(CONSOLE_OUT, "Testing GameStream connectivity over the Internet...\n");
|
|
|
|
|
|
|
|
|
|
// Detect a double NAT by detecting STUN and and UPnP mismatches
|
|
|
|
|
if (sin.sin_addr.S_un.S_addr != locallyReportedWanAddr.sin_addr.S_un.S_addr) {
|
|
|
|
|
fprintf(LOG_OUT, "Testing GameStream ports via UPnP/NAT-PMP reported WAN address\n");
|
|
|
|
@@ -1250,101 +1283,88 @@ int main(int argc, char* argv[])
|
|
|
|
|
// Go directly to the relay check if we have only IPv6 connectivity
|
|
|
|
|
igdDisconnected = false;
|
|
|
|
|
locallyReportedWanAddr = {};
|
|
|
|
|
goto RelayCheck;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Try to connect via WAN IPv4 address
|
|
|
|
|
fprintf(LOG_OUT, "Testing GameStream ports via STUN-reported WAN address\n");
|
|
|
|
|
if (!TestAllPorts(&ss, portMsgBuf, sizeof(portMsgBuf), false, true)) {
|
|
|
|
|
RelayCheck:
|
|
|
|
|
struct addrinfo hint = {};
|
|
|
|
|
struct addrinfo* result;
|
|
|
|
|
struct addrinfo hint = {};
|
|
|
|
|
struct addrinfo* result;
|
|
|
|
|
|
|
|
|
|
// We can get here if the router doesn't support NAT reflection.
|
|
|
|
|
// We'll need to call out to our loopback server to get a second opinion.
|
|
|
|
|
hint.ai_family = AF_UNSPEC;
|
|
|
|
|
hint.ai_flags = AI_ADDRCONFIG;
|
|
|
|
|
err = getaddrinfo("loopback-v2.moonlight-stream.org", NULL, &hint, &result);
|
|
|
|
|
if (err != 0 || result == NULL) {
|
|
|
|
|
fprintf(LOG_OUT, "getaddrinfo() failed: %d\n", err);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
bool allPortsFailedOnV4 = true;
|
|
|
|
|
|
|
|
|
|
hint.ai_family = AF_UNSPEC;
|
|
|
|
|
hint.ai_flags = AI_ADDRCONFIG;
|
|
|
|
|
err = getaddrinfo("loopback.moonlight-stream.org", NULL, &hint, &result);
|
|
|
|
|
if (err != 0 || result == NULL) {
|
|
|
|
|
fprintf(LOG_OUT, "getaddrinfo() failed: %d\n", err);
|
|
|
|
|
// First try the relay server over IPv4. If this passes, it's considered a full success
|
|
|
|
|
fprintf(LOG_OUT, "Testing GameStream ports via IPv4 loopback server\n");
|
|
|
|
|
for (struct addrinfo* current = result; current != NULL; current = current->ai_next) {
|
|
|
|
|
if (current->ai_family == AF_INET) {
|
|
|
|
|
fprintf(CONSOLE_OUT, "Testing GameStream connectivity over the Internet using a relay server...\n");
|
|
|
|
|
if (TestAllPorts((PSOCKADDR_STORAGE)current->ai_addr, portMsgBuf, sizeof(portMsgBuf), true, true, &allPortsFailedOnV4)) {
|
|
|
|
|
freeaddrinfo(result);
|
|
|
|
|
snprintf(msgBuf, sizeof(msgBuf), "This PC is ready to host over the Internet!\n\n"
|
|
|
|
|
"For the easiest setup, you should pair Moonlight to your gaming PC from your home network before trying to stream over the Internet.\n\n"
|
|
|
|
|
"If you can't, you can type the following address into Moonlight's Add PC dialog: %s", wanAddrStr);
|
|
|
|
|
DisplayMessage(msgBuf, nullptr, MpInfo);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
bool allPortsFailedOnV4 = true;
|
|
|
|
|
|
|
|
|
|
// First try the relay server over IPv4. If this passes, it's considered a full success
|
|
|
|
|
fprintf(LOG_OUT, "Testing GameStream ports via IPv4 loopback server\n");
|
|
|
|
|
for (struct addrinfo* current = result; current != NULL; current = current->ai_next) {
|
|
|
|
|
if (current->ai_family == AF_INET) {
|
|
|
|
|
fprintf(CONSOLE_OUT, "Testing GameStream connectivity over the Internet using a relay server...\n");
|
|
|
|
|
if (TestAllPorts((PSOCKADDR_STORAGE)current->ai_addr, portMsgBuf, sizeof(portMsgBuf), true, true, &allPortsFailedOnV4)) {
|
|
|
|
|
// If that fails, try the relay server over IPv6. If this passes, it will be a partial success
|
|
|
|
|
fprintf(LOG_OUT, "Testing GameStream ports via IPv6 loopback server\n");
|
|
|
|
|
for (struct addrinfo* current = result; current != NULL; current = current->ai_next) {
|
|
|
|
|
if (current->ai_family == AF_INET6) {
|
|
|
|
|
fprintf(CONSOLE_OUT, "Testing GameStream connectivity over the Internet using an IPv6 relay server...\n");
|
|
|
|
|
// Pass the portMsgBuf only if we've detected an IPv6-only setup. Otherwise, we want to preserve
|
|
|
|
|
// the failing ports from the IPv4 to display in the error dialog.
|
|
|
|
|
if (TestAllPorts((PSOCKADDR_STORAGE)current->ai_addr,
|
|
|
|
|
ss.ss_family == AF_INET6 ? portMsgBuf : NULL,
|
|
|
|
|
ss.ss_family == AF_INET6 ? sizeof(portMsgBuf) : 0, true, true)) {
|
|
|
|
|
// We will terminate the test at the IPv6 limited connectivity warning in the following cases:
|
|
|
|
|
// 1) Double-NAT/CGN - indicates the connection is fundamentally limited to IPv6 for end-to-end connectivity
|
|
|
|
|
// 2) IPv6-only - indicates the connection is fundamentally limited to IPv6 for all connectivity
|
|
|
|
|
// 3) All ports failed the test with our IPv4 relay - This is one final heuristic to weed out IPv4 misconfigurations. If we have some ports open,
|
|
|
|
|
// it clearly indicates IPv4 support is possible, just currently misconfigured.
|
|
|
|
|
//
|
|
|
|
|
// Our last (implicit) heuristic is that we actually managed to establish an IPv6 connection. This means that there was either
|
|
|
|
|
// no IPv6 firewall (hopefully not) or that we were able to talk to a PCP/IGDv6 gateway to allow us through. Hopefully if we have
|
|
|
|
|
// a gateway that is unresponsive to UPnP/NAT-PMP, we wouldn't even be able to establish this connection so we would inherently fall
|
|
|
|
|
// to the checks below for IPv4 issues.
|
|
|
|
|
if (IsDoubleNAT(&locallyReportedWanAddr) || igdDisconnected || IsPossibleCGN(&locallyReportedWanAddr) || ss.ss_family == AF_INET6 || allPortsFailedOnV4) {
|
|
|
|
|
snprintf(msgBuf, sizeof(msgBuf), "This PC has limited connectivity for Internet hosting. It will work only for clients on certain networks.\n\n"
|
|
|
|
|
"If you want to try streaming with this configuration, you must pair Moonlight to your gaming PC from your home network before trying to stream over the Internet.\n\n"
|
|
|
|
|
"To get full connectivity, please contact your ISP and ask for a \"public IP address\" which they may offer for free upon request. For more information and workarounds, click the Help button.");
|
|
|
|
|
DisplayMessage(msgBuf, "https://github.com/moonlight-stream/moonlight-docs/wiki/Internet-Streaming-Errors#limited-connectivity-for-hosting-error", MpWarn);
|
|
|
|
|
freeaddrinfo(result);
|
|
|
|
|
goto AllTestsPassed;
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// If that fails, try the relay server over IPv6. If this passes, it will be a partial success
|
|
|
|
|
fprintf(LOG_OUT, "Testing GameStream ports via IPv6 loopback server\n");
|
|
|
|
|
for (struct addrinfo* current = result; current != NULL; current = current->ai_next) {
|
|
|
|
|
if (current->ai_family == AF_INET6) {
|
|
|
|
|
fprintf(CONSOLE_OUT, "Testing GameStream connectivity over the Internet using an IPv6 relay server...\n");
|
|
|
|
|
// Pass the portMsgBuf only if we've detected an IPv6-only setup. Otherwise, we want to preserve
|
|
|
|
|
// the failing ports from the IPv4 to display in the error dialog.
|
|
|
|
|
if (TestAllPorts((PSOCKADDR_STORAGE)current->ai_addr,
|
|
|
|
|
ss.ss_family == AF_INET6 ? portMsgBuf : NULL,
|
|
|
|
|
ss.ss_family == AF_INET6 ? sizeof(portMsgBuf) : 0, true, true)) {
|
|
|
|
|
// We will terminate the test at the IPv6 limited connectivity warning in the following cases:
|
|
|
|
|
// 1) Double-NAT/CGN - indicates the connection is fundamentally limited to IPv6 for end-to-end connectivity
|
|
|
|
|
// 2) IPv6-only - indicates the connection is fundamentally limited to IPv6 for all connectivity
|
|
|
|
|
// 3) All ports failed the test with our IPv4 relay - This is one final heuristic to weed out IPv4 misconfigurations. If we have some ports open,
|
|
|
|
|
// it clearly indicates IPv4 support is possible, just currently misconfigured.
|
|
|
|
|
//
|
|
|
|
|
// Our last (implicit) heuristic is that we actually managed to establish an IPv6 connection. This means that there was either
|
|
|
|
|
// no IPv6 firewall (hopefully not) or that we were able to talk to a PCP/IGDv6 gateway to allow us through. Hopefully if we have
|
|
|
|
|
// a gateway that is unresponsive to UPnP/NAT-PMP, we wouldn't even be able to establish this connection so we would inherently fall
|
|
|
|
|
// to the checks below for IPv4 issues.
|
|
|
|
|
if (IsDoubleNAT(&locallyReportedWanAddr) || igdDisconnected || IsPossibleCGN(&locallyReportedWanAddr) || ss.ss_family == AF_INET6 || allPortsFailedOnV4) {
|
|
|
|
|
snprintf(msgBuf, sizeof(msgBuf), "This PC has limited connectivity for Internet hosting. It will work only for clients on certain networks.\n\n"
|
|
|
|
|
"If you want to try streaming with this configuration, you must pair Moonlight to your gaming PC from your home network before trying to stream over the Internet.\n\n"
|
|
|
|
|
"To get full connectivity, please contact your ISP and ask for a \"public IP address\" which they may offer for free upon request. For more information and workarounds, click the Help button.");
|
|
|
|
|
DisplayMessage(msgBuf, "https://github.com/moonlight-stream/moonlight-docs/wiki/Internet-Streaming-Errors#limited-connectivity-for-hosting-error", MpWarn);
|
|
|
|
|
freeaddrinfo(result);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
freeaddrinfo(result);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Many UPnP devices report IGD disconnected when double-NATed. If it was really offline,
|
|
|
|
|
// we probably would not have even gotten past STUN.
|
|
|
|
|
if (IsDoubleNAT(&locallyReportedWanAddr) || igdDisconnected) {
|
|
|
|
|
snprintf(msgBuf, sizeof(msgBuf), "Your router appears be connected to the Internet through another router. Click the Help button for guidance on fixing this issue.");
|
|
|
|
|
DisplayMessage(msgBuf, "https://github.com/moonlight-stream/moonlight-docs/wiki/Internet-Streaming-Errors#connected-through-another-router-error");
|
|
|
|
|
}
|
|
|
|
|
else if (IsPossibleCGN(&locallyReportedWanAddr)) {
|
|
|
|
|
snprintf(msgBuf, sizeof(msgBuf), "Your ISP is running a Carrier-Grade NAT that is preventing you from hosting services like Moonlight on the Internet.\n\n"
|
|
|
|
|
"Ask your ISP for a \"public IP address\" which they may offer for free upon request. For more information and workarounds, click the Help button.");
|
|
|
|
|
DisplayMessage(msgBuf, "https://github.com/moonlight-stream/moonlight-docs/wiki/Internet-Streaming-Errors#carrier-grade-nat-error");
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
snprintf(msgBuf, sizeof(msgBuf), "Internet GameStream connectivity check failed.\n\n"
|
|
|
|
|
"First, try restarting your router. If that fails, check that UPnP is enabled in your router settings. For more information and workarounds, click the Help button.\n\n"
|
|
|
|
|
"The following ports were not forwarded properly:\n%s", portMsgBuf);
|
|
|
|
|
DisplayMessage(msgBuf, "https://github.com/moonlight-stream/moonlight-docs/wiki/Internet-Streaming-Errors#internet-gamestream-connectivity-check-error");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
|
freeaddrinfo(result);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
AllTestsPassed:
|
|
|
|
|
snprintf(msgBuf, sizeof(msgBuf), "This PC is ready to host over the Internet!\n\n"
|
|
|
|
|
"For the easiest setup, you should pair Moonlight to your gaming PC from your home network before trying to stream over the Internet.\n\n"
|
|
|
|
|
"If you can't, you can type the following address into Moonlight's Add PC dialog: %s", wanAddrStr);
|
|
|
|
|
DisplayMessage(msgBuf, nullptr, MpInfo);
|
|
|
|
|
// Many UPnP devices report IGD disconnected when double-NATed. If it was really offline,
|
|
|
|
|
// we probably would not have even gotten past STUN.
|
|
|
|
|
if (IsDoubleNAT(&locallyReportedWanAddr) || igdDisconnected) {
|
|
|
|
|
snprintf(msgBuf, sizeof(msgBuf), "Your router appears be connected to the Internet through another router. Click the Help button for guidance on fixing this issue.");
|
|
|
|
|
DisplayMessage(msgBuf, "https://github.com/moonlight-stream/moonlight-docs/wiki/Internet-Streaming-Errors#connected-through-another-router-error");
|
|
|
|
|
}
|
|
|
|
|
else if (IsPossibleCGN(&locallyReportedWanAddr)) {
|
|
|
|
|
snprintf(msgBuf, sizeof(msgBuf), "Your ISP is running a Carrier-Grade NAT that is preventing you from hosting services like Moonlight on the Internet.\n\n"
|
|
|
|
|
"Ask your ISP for a \"public IP address\" which they may offer for free upon request. For more information and workarounds, click the Help button.");
|
|
|
|
|
DisplayMessage(msgBuf, "https://github.com/moonlight-stream/moonlight-docs/wiki/Internet-Streaming-Errors#carrier-grade-nat-error");
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
snprintf(msgBuf, sizeof(msgBuf), "Internet GameStream connectivity check failed.\n\n"
|
|
|
|
|
"First, try restarting your router. If that fails, check that UPnP is enabled in your router settings. For more information and workarounds, click the Help button.\n\n"
|
|
|
|
|
"The following ports were not forwarded properly:\n%s", portMsgBuf);
|
|
|
|
|
DisplayMessage(msgBuf, "https://github.com/moonlight-stream/moonlight-docs/wiki/Internet-Streaming-Errors#internet-gamestream-connectivity-check-error");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
return -1;
|
|
|
|
|
}
|