Compare commits

..
9 Commits
9 changed files with 129 additions and 16 deletions
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+1 -3
View File
@@ -47,9 +47,7 @@
Account="NT AUTHORITY\LocalService"
ErrorControl="ignore"
Interactive="no">
<ServiceConfig DelayedAutoStart="no" OnInstall="yes" OnReinstall="yes" ServiceSid="restricted">
<RequiredPrivilege>SeChangeNotifyPrivilege</RequiredPrivilege>
</ServiceConfig>
<ServiceConfig DelayedAutoStart="no" OnInstall="yes" OnReinstall="yes" ServiceSid="unrestricted"/>
</ServiceInstall>
<ServiceControl Id="StartService" Start="install" Stop="both" Remove="uninstall" Name="MISS" Wait="yes" />
</Component>
-9
View File
@@ -386,15 +386,6 @@ bool NATPMPMapPort(natpmp_t* natpmp, int proto, int port, bool enable, bool inde
else if (response.pnu.newportmapping.mappedpublicport != port) {
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.
// We can't use this alternate mapping, so immediately release it.
printf("Deleting unwanted NAT-PMP mapping for %s %d...", proto == IPPROTO_TCP ? "TCP" : "UDP", response.pnu.newportmapping.mappedpublicport);
+125 -1
View File
@@ -178,6 +178,56 @@ void DisplayMessage(const char* message, const char* helpUrl = nullptr, MessageP
}
}
bool ExecuteCommand(PCSTR command, PCHAR outputBuffer, DWORD outputBufferLength)
{
SECURITY_ATTRIBUTES attribs;
STARTUPINFO si;
PROCESS_INFORMATION pi;
HANDLE outReadHandle;
DWORD bytesRead = 0;
ZeroMemory(&si, sizeof(si));
si.cb = sizeof(si);
si.dwFlags = STARTF_USESHOWWINDOW | STARTF_USESTDHANDLES;
si.wShowWindow = SW_HIDE;
ZeroMemory(&attribs, sizeof(attribs));
attribs.nLength = sizeof(attribs);
attribs.bInheritHandle = TRUE;
if (!CreatePipe(&outReadHandle, &si.hStdOutput, &attribs, 0))
{
fprintf(LOG_OUT, "CreatePipe() failed: %d\n", GetLastError());
return false;
}
si.hStdError = si.hStdOutput;
if (!CreateProcess(NULL, (LPSTR)command, NULL, NULL, TRUE, 0, NULL, NULL, &si, &pi))
{
fprintf(LOG_OUT, "CreateProcess() failed: %d\n", GetLastError());
CloseHandle(si.hStdOutput);
return false;
}
WaitForSingleObject(pi.hProcess, INFINITE);
CloseHandle(si.hStdOutput);
CloseHandle(pi.hProcess);
CloseHandle(pi.hThread);
if (!ReadFile(outReadHandle, outputBuffer, outputBufferLength, &bytesRead, NULL))
{
fprintf(LOG_OUT, "ReadFile() failed: %d\n", GetLastError());
CloseHandle(outReadHandle);
return false;
}
outputBuffer[bytesRead] = 0;
CloseHandle(outReadHandle);
return true;
}
bool IsGameStreamEnabled()
{
DWORD error;
@@ -590,7 +640,7 @@ bool FindZeroTierInterfaceAddress(PSOCKADDR_STORAGE addr)
&addresses,
&length);
if (error != ERROR_SUCCESS) {
fprintf(LOG_OUT, "GetAdaptersAddresses() failed: %d\n", WSAGetLastError());
fprintf(LOG_OUT, "GetAdaptersAddresses() failed: %d\n", error);
return false;
}
@@ -616,6 +666,57 @@ bool FindZeroTierInterfaceAddress(PSOCKADDR_STORAGE addr)
return false;
}
bool FindDuplicateDefaultInterfaces(void)
{
union {
IP_ADAPTER_ADDRESSES addresses;
char buffer[8192];
};
ULONG error;
ULONG length;
MIB_IPFORWARDROW defaultRoute;
PIP_ADAPTER_ADDRESSES currentAdapter;
DWORD matchingInterfaces = 0;
error = GetBestRoute(0, 0, &defaultRoute);
if (error != NO_ERROR) {
fprintf(LOG_OUT, "GetBestRoute() failed: %d\n", error);
return false;
}
// Get all IPv4 interfaces
length = sizeof(buffer);
error = GetAdaptersAddresses(AF_INET,
GAA_FLAG_SKIP_UNICAST |
GAA_FLAG_SKIP_ANYCAST |
GAA_FLAG_SKIP_MULTICAST |
GAA_FLAG_SKIP_DNS_SERVER |
GAA_FLAG_INCLUDE_GATEWAYS |
GAA_FLAG_SKIP_FRIENDLY_NAME,
NULL,
&addresses,
&length);
if (error != ERROR_SUCCESS) {
fprintf(LOG_OUT, "GetAdaptersAddresses() failed: %d\n", error);
return false;
}
currentAdapter = &addresses;
while (currentAdapter != NULL) {
if (currentAdapter->OperStatus == IfOperStatusUp &&
currentAdapter->FirstGatewayAddress != NULL &&
currentAdapter->FirstGatewayAddress->Address.iSockaddrLength == sizeof(SOCKADDR_IN)) {
if (((PSOCKADDR_IN)currentAdapter->FirstGatewayAddress->Address.lpSockaddr)->sin_addr.S_un.S_addr == defaultRoute.dwForwardNextHop) {
matchingInterfaces++;
}
}
currentAdapter = currentAdapter->Next;
}
return matchingInterfaces > 1;
}
enum UPnPPortStatus {
NOT_FOUND,
OK,
@@ -885,6 +986,29 @@ int main(int argc, char* argv[])
return -1;
}
fprintf(CONSOLE_OUT, "Checking for anti-virus and firewall software...\n");
char wmicBuf[8192];
if (ExecuteCommand("WMIC /Node:localhost /Namespace:\\\\root\\SecurityCenter2 Path AntiVirusProduct Get displayName", wmicBuf, sizeof(wmicBuf))) {
fprintf(LOG_OUT, "AV products:\n%s", wmicBuf);
}
if (ExecuteCommand("WMIC /Node:localhost /Namespace:\\\\root\\SecurityCenter2 Path FirewallProduct Get displayName", wmicBuf, sizeof(wmicBuf))) {
fprintf(LOG_OUT, "Firewall products:\n%s", wmicBuf);
if (!strstr(wmicBuf, "No Instance(s) Available.") && !strstr(wmicBuf, "Invalid namespace")) {
DisplayMessage("Detected anti-virus and/or firewall software installed on this system. This software may interfere with NVIDIA GameStream.\n\n"
"Please try temporarily disabling your anti-virus or firewall software if you experience connection issues with Moonlight.",
"https://github.com/moonlight-stream/moonlight-docs/wiki/Troubleshooting", MpInfo, false);
}
}
fprintf(CONSOLE_OUT, "Checking network connections...\n");
if (FindDuplicateDefaultInterfaces()) {
DisplayMessage("This computer appears to have more than one connection to the same network (like both WiFi and Ethernet, for example).\n\n"
"Please disconnect the extra connection(s) to ensure hosting works reliably over the Internet. If you are connected via WiFi and Ethernet, try disabling your WiFi connection.",
"https://github.com/moonlight-stream/moonlight-docs/wiki/Internet-Streaming-Errors#multiple-connections-error", MpWarn, false);
}
union {
SOCKADDR_STORAGE ss;
SOCKADDR_IN sin;
+2 -2
View File
@@ -1,7 +1,7 @@
#pragma once
#define VER_VERSION 4,2,0,0
#define VER_VERSION_STR "4.2.0.0"
#define VER_VERSION 4,3,0,0
#define VER_VERSION_STR "4.3.0.0"
#define VER_COMPANYNAME_STR "Moonlight Game Streaming Project"
#define VER_PRODUCTNAME_STR "Moonlight Internet Hosting Tool"