mirror of
https://github.com/moonlight-stream/Internet-Hosting-Tool.git
synced 2025-07-03 08:15:40 +00:00
Add support for IPv6-only environments
This commit is contained in:
parent
0bd212e6f1
commit
acb3f5a059
@ -835,14 +835,14 @@ int main(int argc, char* argv[])
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!FindLocalInterfaceIPAddress(AF_INET, &ss)) {
|
if (!FindLocalInterfaceIPAddress(AF_INET, &ss) && !FindLocalInterfaceIPAddress(AF_INET6, &ss)) {
|
||||||
DisplayMessage("Unable to perform GameStream connectivity check. Please check your Internet connection and try again.");
|
DisplayMessage("Unable to perform GameStream connectivity check. Please check your Internet connection and try again.");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(CONSOLE_OUT, "Testing GameStream connectivity on your local network...\n");
|
fprintf(CONSOLE_OUT, "Testing GameStream connectivity on your local network...\n");
|
||||||
|
|
||||||
// Try to connect via LAN IPv4 address
|
// Try to connect via LAN address
|
||||||
fprintf(LOG_OUT, "Testing GameStream ports via local network\n");
|
fprintf(LOG_OUT, "Testing GameStream ports via local network\n");
|
||||||
if (!TestAllPorts(&ss, portMsgBuf, sizeof(portMsgBuf), true)) {
|
if (!TestAllPorts(&ss, portMsgBuf, sizeof(portMsgBuf), true)) {
|
||||||
snprintf(msgBuf, sizeof(msgBuf),
|
snprintf(msgBuf, sizeof(msgBuf),
|
||||||
@ -851,33 +851,47 @@ int main(int argc, char* argv[])
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(CONSOLE_OUT, "Detecting public IP address...\n");
|
|
||||||
|
|
||||||
bool rulesFound, igdDisconnected;
|
bool igdDisconnected;
|
||||||
SOCKADDR_IN locallyReportedWanAddr;
|
SOCKADDR_IN locallyReportedWanAddr;
|
||||||
if (!CheckWANAccess(&sin, &locallyReportedWanAddr, &rulesFound, &igdDisconnected)) {
|
char wanAddrStr[INET_ADDRSTRLEN];
|
||||||
return -1;
|
|
||||||
|
if (ss.ss_family == AF_INET) {
|
||||||
|
bool rulesFound;
|
||||||
|
|
||||||
|
fprintf(CONSOLE_OUT, "Detecting public IP address...\n");
|
||||||
|
|
||||||
|
if (!CheckWANAccess(&sin, &locallyReportedWanAddr, &rulesFound, &igdDisconnected)) {
|
||||||
|
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");
|
||||||
|
|
||||||
|
// We don't actually care about the outcome here but it's nice to have in logs
|
||||||
|
// to determine whether solving the double NAT will actually make Moonlight work.
|
||||||
|
TestAllPorts((PSOCKADDR_STORAGE)&locallyReportedWanAddr, portMsgBuf, sizeof(portMsgBuf), false);
|
||||||
|
|
||||||
|
fprintf(LOG_OUT, "Detected inconsistency between UPnP/NAT-PMP and STUN reported WAN addresses!\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
inet_ntop(AF_INET, &sin.sin_addr, wanAddrStr, sizeof(wanAddrStr));
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
fprintf(CONSOLE_OUT, "Testing GameStream connectivity over the Internet...\n");
|
// Go directly to the relay check if we have only IPv6 connectivity
|
||||||
|
igdDisconnected = false;
|
||||||
// Detect a double NAT by detecting STUN and and UPnP mismatches
|
locallyReportedWanAddr = {};
|
||||||
if (sin.sin_addr.S_un.S_addr != locallyReportedWanAddr.sin_addr.S_un.S_addr) {
|
goto RelayCheck;
|
||||||
fprintf(LOG_OUT, "Testing GameStream ports via UPnP/NAT-PMP reported WAN address\n");
|
|
||||||
|
|
||||||
// We don't actually care about the outcome here but it's nice to have in logs
|
|
||||||
// to determine whether solving the double NAT will actually make Moonlight work.
|
|
||||||
TestAllPorts((PSOCKADDR_STORAGE)&locallyReportedWanAddr, portMsgBuf, sizeof(portMsgBuf), false);
|
|
||||||
|
|
||||||
fprintf(LOG_OUT, "Detected inconsistency between UPnP/NAT-PMP and STUN reported WAN addresses!\n");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
char wanAddrStr[64];
|
|
||||||
inet_ntop(AF_INET, &sin.sin_addr, wanAddrStr, sizeof(wanAddrStr));
|
|
||||||
|
|
||||||
// Try to connect via WAN IPv4 address
|
// Try to connect via WAN IPv4 address
|
||||||
fprintf(LOG_OUT, "Testing GameStream ports via STUN-reported WAN address\n");
|
fprintf(LOG_OUT, "Testing GameStream ports via STUN-reported WAN address\n");
|
||||||
if (!TestAllPorts(&ss, portMsgBuf, sizeof(portMsgBuf), true)) {
|
if (!TestAllPorts(&ss, portMsgBuf, sizeof(portMsgBuf), true)) {
|
||||||
|
|
||||||
|
RelayCheck:
|
||||||
// Many UPnP devices report IGD disconnected when double-NATed. If it was really offline,
|
// Many UPnP devices report IGD disconnected when double-NATed. If it was really offline,
|
||||||
// we probably would not have even gotten past STUN.
|
// we probably would not have even gotten past STUN.
|
||||||
if (IsDoubleNAT(&locallyReportedWanAddr) || igdDisconnected) {
|
if (IsDoubleNAT(&locallyReportedWanAddr) || igdDisconnected) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user