Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8f011440b4 | ||
|
|
771e34f199 | ||
|
|
c8e8af7d4b | ||
|
|
18b914d9f6 | ||
|
|
e9ddf91157 | ||
|
|
28a5935ee7 | ||
|
|
ce3b9c3d31 | ||
|
|
0f3506a92c | ||
|
|
1e6337b9b0 | ||
|
|
363b62f69f | ||
|
|
3175b1c4fa |
+1
-1
Submodule GS-IPv6-Forwarder updated: acd693efa3...48c0136b9d
@@ -1,9 +1,9 @@
|
|||||||
/* $Id: miniupnpc.h,v 1.55 2020/11/09 19:49:32 nanard Exp $ */
|
/* $Id: miniupnpc.h,v 1.59 2021/09/28 21:39:17 nanard Exp $ */
|
||||||
/* vim: tabstop=4 shiftwidth=4 noexpandtab
|
/* vim: tabstop=4 shiftwidth=4 noexpandtab
|
||||||
* Project: miniupnp
|
* Project: miniupnp
|
||||||
* http://miniupnp.free.fr/
|
* http://miniupnp.free.fr/
|
||||||
* Author: Thomas Bernard
|
* Author: Thomas Bernard
|
||||||
* Copyright (c) 2005-2018 Thomas Bernard
|
* Copyright (c) 2005-2021 Thomas Bernard
|
||||||
* This software is subjects to the conditions detailed
|
* This software is subjects to the conditions detailed
|
||||||
* in the LICENCE file provided within this distribution */
|
* in the LICENCE file provided within this distribution */
|
||||||
#ifndef MINIUPNPC_H_INCLUDED
|
#ifndef MINIUPNPC_H_INCLUDED
|
||||||
@@ -20,7 +20,7 @@
|
|||||||
#define UPNPDISCOVER_MEMORY_ERROR (-102)
|
#define UPNPDISCOVER_MEMORY_ERROR (-102)
|
||||||
|
|
||||||
/* versions : */
|
/* versions : */
|
||||||
#define MINIUPNPC_VERSION "2.2.0"
|
#define MINIUPNPC_VERSION "2.2.3"
|
||||||
#define MINIUPNPC_API_VERSION 17
|
#define MINIUPNPC_API_VERSION 17
|
||||||
|
|
||||||
/* Source port:
|
/* Source port:
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
#ifndef MINIUPNPC_SOCKETDEF_H_INCLUDED
|
#ifndef MINIUPNPC_SOCKETDEF_H_INCLUDED
|
||||||
#define MINIUPNPC_SOCKETDEF_H_INCLUDED
|
#define MINIUPNPC_SOCKETDEF_H_INCLUDED
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _WIN32
|
||||||
|
|
||||||
#define ISINVALID(s) (INVALID_SOCKET==(s))
|
#define ISINVALID(s) (INVALID_SOCKET==(s))
|
||||||
|
|
||||||
|
|||||||
@@ -1,13 +1,15 @@
|
|||||||
/* $Id: miniupnpctypes.h,v 1.1 2011/02/15 11:10:40 nanard Exp $ */
|
/* $Id: miniupnpctypes.h,v 1.1 2011/02/15 11:10:40 nanard Exp $ */
|
||||||
/* Miniupnp project : http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org
|
/* Miniupnp project : http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org
|
||||||
* Author : Thomas Bernard
|
* Author : Thomas Bernard
|
||||||
* Copyright (c) 2011 Thomas Bernard
|
* Copyright (c) 2021 Thomas Bernard
|
||||||
* This software is subject to the conditions detailed in the
|
* This software is subject to the conditions detailed in the
|
||||||
* LICENCE file provided within this distribution */
|
* LICENCE file provided within this distribution */
|
||||||
#ifndef MINIUPNPCTYPES_H_INCLUDED
|
#ifndef MINIUPNPCTYPES_H_INCLUDED
|
||||||
#define MINIUPNPCTYPES_H_INCLUDED
|
#define MINIUPNPCTYPES_H_INCLUDED
|
||||||
|
|
||||||
#if (defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L)
|
/* Use unsigned long long when available :
|
||||||
|
* strtoull is C99 */
|
||||||
|
#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
|
||||||
#define UNSIGNED_INTEGER unsigned long long
|
#define UNSIGNED_INTEGER unsigned long long
|
||||||
#define STRTOUI strtoull
|
#define STRTOUI strtoull
|
||||||
#else
|
#else
|
||||||
|
|||||||
@@ -0,0 +1,65 @@
|
|||||||
|
/* $Id: portlistingparse.h,v 1.10 2014/11/01 10:37:32 nanard Exp $ */
|
||||||
|
/* MiniUPnP project
|
||||||
|
* http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/
|
||||||
|
* (c) 2011-2015 Thomas Bernard
|
||||||
|
* This software is subject to the conditions detailed
|
||||||
|
* in the LICENCE file provided within the distribution */
|
||||||
|
#ifndef PORTLISTINGPARSE_H_INCLUDED
|
||||||
|
#define PORTLISTINGPARSE_H_INCLUDED
|
||||||
|
|
||||||
|
#include "miniupnpc_declspec.h"
|
||||||
|
/* for the definition of UNSIGNED_INTEGER */
|
||||||
|
#include "miniupnpctypes.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* sample of PortMappingEntry :
|
||||||
|
<p:PortMappingEntry>
|
||||||
|
<p:NewRemoteHost>202.233.2.1</p:NewRemoteHost>
|
||||||
|
<p:NewExternalPort>2345</p:NewExternalPort>
|
||||||
|
<p:NewProtocol>TCP</p:NewProtocol>
|
||||||
|
<p:NewInternalPort>2345</p:NewInternalPort>
|
||||||
|
<p:NewInternalClient>192.168.1.137</p:NewInternalClient>
|
||||||
|
<p:NewEnabled>1</p:NewEnabled>
|
||||||
|
<p:NewDescription>dooom</p:NewDescription>
|
||||||
|
<p:NewLeaseTime>345</p:NewLeaseTime>
|
||||||
|
</p:PortMappingEntry>
|
||||||
|
*/
|
||||||
|
typedef enum { PortMappingEltNone,
|
||||||
|
PortMappingEntry, NewRemoteHost,
|
||||||
|
NewExternalPort, NewProtocol,
|
||||||
|
NewInternalPort, NewInternalClient,
|
||||||
|
NewEnabled, NewDescription,
|
||||||
|
NewLeaseTime } portMappingElt;
|
||||||
|
|
||||||
|
struct PortMapping {
|
||||||
|
struct PortMapping * l_next; /* list next element */
|
||||||
|
UNSIGNED_INTEGER leaseTime;
|
||||||
|
unsigned short externalPort;
|
||||||
|
unsigned short internalPort;
|
||||||
|
char remoteHost[64];
|
||||||
|
char internalClient[64];
|
||||||
|
char description[64];
|
||||||
|
char protocol[4];
|
||||||
|
unsigned char enabled;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct PortMappingParserData {
|
||||||
|
struct PortMapping * l_head; /* list head */
|
||||||
|
portMappingElt curelt;
|
||||||
|
};
|
||||||
|
|
||||||
|
MINIUPNP_LIBSPEC void
|
||||||
|
ParsePortListing(const char * buffer, int bufsize,
|
||||||
|
struct PortMappingParserData * pdata);
|
||||||
|
|
||||||
|
MINIUPNP_LIBSPEC void
|
||||||
|
FreePortListing(struct PortMappingParserData * pdata);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
/* $Id: upnpdev.h,v 1.3 2020/05/29 15:57:42 nanard Exp $ */
|
/* $Id: upnpdev.h,v 1.4 2021/08/21 09:45:01 nanard Exp $ */
|
||||||
/* Project : miniupnp
|
/* Project : miniupnp
|
||||||
* Web : http://miniupnp.free.fr/ or https://miniupnp.tuxfamily.org/
|
* Web : http://miniupnp.free.fr/ or https://miniupnp.tuxfamily.org/
|
||||||
* Author : Thomas BERNARD
|
* Author : Thomas BERNARD
|
||||||
* copyright (c) 2005-2020 Thomas Bernard
|
* copyright (c) 2005-2021 Thomas Bernard
|
||||||
* This software is subjet to the conditions detailed in the
|
* This software is subjet to the conditions detailed in the
|
||||||
* provided LICENSE file. */
|
* provided LICENSE file. */
|
||||||
#ifndef UPNPDEV_H_INCLUDED
|
#ifndef UPNPDEV_H_INCLUDED
|
||||||
@@ -20,7 +20,7 @@ struct UPNPDev {
|
|||||||
char * st;
|
char * st;
|
||||||
char * usn;
|
char * usn;
|
||||||
unsigned int scope_id;
|
unsigned int scope_id;
|
||||||
#if defined(__STDC_VERSION) && __STDC_VERSION__ >= 199901L
|
#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
|
||||||
/* C99 flexible array member */
|
/* C99 flexible array member */
|
||||||
char buffer[];
|
char buffer[];
|
||||||
#elif defined(__GNUC__)
|
#elif defined(__GNUC__)
|
||||||
|
|||||||
@@ -0,0 +1,63 @@
|
|||||||
|
/* $Id: upnpreplyparse.h,v 1.19 2014/10/27 16:33:19 nanard Exp $ */
|
||||||
|
/* MiniUPnP project
|
||||||
|
* http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/
|
||||||
|
* (c) 2006-2013 Thomas Bernard
|
||||||
|
* This software is subject to the conditions detailed
|
||||||
|
* in the LICENCE file provided within the distribution */
|
||||||
|
|
||||||
|
#ifndef UPNPREPLYPARSE_H_INCLUDED
|
||||||
|
#define UPNPREPLYPARSE_H_INCLUDED
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
struct NameValue {
|
||||||
|
struct NameValue * l_next;
|
||||||
|
char name[64];
|
||||||
|
char value[128];
|
||||||
|
};
|
||||||
|
|
||||||
|
struct NameValueParserData {
|
||||||
|
struct NameValue * l_head;
|
||||||
|
char curelt[64];
|
||||||
|
char * portListing;
|
||||||
|
int portListingLength;
|
||||||
|
int topelt;
|
||||||
|
const char * cdata;
|
||||||
|
int cdatalen;
|
||||||
|
};
|
||||||
|
|
||||||
|
/* ParseNameValue() */
|
||||||
|
void
|
||||||
|
ParseNameValue(const char * buffer, int bufsize,
|
||||||
|
struct NameValueParserData * data);
|
||||||
|
|
||||||
|
/* ClearNameValueList() */
|
||||||
|
void
|
||||||
|
ClearNameValueList(struct NameValueParserData * pdata);
|
||||||
|
|
||||||
|
/* GetValueFromNameValueList() */
|
||||||
|
char *
|
||||||
|
GetValueFromNameValueList(struct NameValueParserData * pdata,
|
||||||
|
const char * Name);
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
/* GetValueFromNameValueListIgnoreNS() */
|
||||||
|
char *
|
||||||
|
GetValueFromNameValueListIgnoreNS(struct NameValueParserData * pdata,
|
||||||
|
const char * Name);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* DisplayNameValueList() */
|
||||||
|
#ifdef DEBUG
|
||||||
|
void
|
||||||
|
DisplayNameValueList(char * buffer, int bufsize);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
#ifndef DECLSPEC_H_INCLUDED
|
#ifndef NATPMP_DECLSPEC_H_INCLUDED
|
||||||
#define DECLSPEC_H_INCLUDED
|
#define NATPMP_DECLSPEC_H_INCLUDED
|
||||||
|
|
||||||
#if defined(_WIN32) && !defined(NATPMP_STATICLIB)
|
#if defined(_WIN32) && !defined(NATPMP_STATICLIB)
|
||||||
/* for windows dll */
|
/* for windows dll */
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+11
-10
@@ -1,8 +1,9 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
<?define VCREDIST_VER = "14.28.29334" ?>
|
<?define VCREDIST_VER = "14.31.31103" ?>
|
||||||
<?define VCREDIST_X86_SIZE = "14328440" ?>
|
<?define VCREDIST_X86_SIZE = "13725768" ?>
|
||||||
<?define VCREDIST_X86_SHA1 = "17674FCC6CF3A2FFDC391BDCDE082AA936E37A89" ?>
|
<?define VCREDIST_X86_SHA1 = "15fe8e70c3c5582b70df173cd9b580331677735a" ?>
|
||||||
|
<?define VCREDIST_X86_URL = "https://download.visualstudio.microsoft.com/download/pr/144a5711-f076-44fa-bf55-f7e0121eb30c/B7AE307237F869E09F7413691A2CD1944357B5CEE28049C0A0D3430B47BB3EDC/VC_redist.x86.exe" ?>
|
||||||
<?define VCREDIST_X86_UPGRADE_CODE = "65E5BD06-6392-3027-8C26-853107D3CF1A" ?>
|
<?define VCREDIST_X86_UPGRADE_CODE = "65E5BD06-6392-3027-8C26-853107D3CF1A" ?>
|
||||||
|
|
||||||
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
|
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
|
||||||
@@ -19,24 +20,24 @@
|
|||||||
|
|
||||||
<WixVariable Id="WixUILicenseRtf" Value="" />
|
<WixVariable Id="WixUILicenseRtf" Value="" />
|
||||||
|
|
||||||
<util:ProductSearch Id="VCREDIST_142_x86"
|
<util:ProductSearch Id="VCREDIST_14_x86"
|
||||||
UpgradeCode="$(var.VCREDIST_X86_UPGRADE_CODE)"
|
UpgradeCode="$(var.VCREDIST_X86_UPGRADE_CODE)"
|
||||||
Result="version"
|
Result="version"
|
||||||
Variable="VCREDIST_142_x86" />
|
Variable="VCREDIST_14_x86" />
|
||||||
|
|
||||||
<Chain>
|
<Chain>
|
||||||
<ExePackage Name="Microsoft Visual C++ 2015-2019 Redistributable - x86"
|
<ExePackage Name="Microsoft Visual C++ 2015-2022 Redistributable - x86"
|
||||||
Cache="no"
|
Cache="no"
|
||||||
Compressed="no"
|
Compressed="no"
|
||||||
PerMachine="yes"
|
PerMachine="yes"
|
||||||
Permanent="yes"
|
Permanent="yes"
|
||||||
Vital="yes"
|
Vital="yes"
|
||||||
InstallCommand="/install /quiet /norestart"
|
InstallCommand="/install /quiet /norestart"
|
||||||
DownloadUrl="https://moonlight-stream.org/downloads/vcredist/$(var.VCREDIST_VER)/vcredist_x86.exe"
|
DownloadUrl="$(var.VCREDIST_X86_URL)"
|
||||||
DetectCondition="VCREDIST_142_x86 >= v$(var.VCREDIST_VER)">
|
DetectCondition="VCREDIST_14_x86 >= v$(var.VCREDIST_VER)">
|
||||||
|
|
||||||
<RemotePayload Description="Microsoft Visual C++ 2015-2019 Redistributable - x86"
|
<RemotePayload Description="Microsoft Visual C++ 2015-2022 Redistributable - x86"
|
||||||
ProductName="Microsoft Visual C++ 2015-2019 Redistributable - x86"
|
ProductName="Microsoft Visual C++ 2015-2022 Redistributable - x86"
|
||||||
Size="$(var.VCREDIST_X86_SIZE)"
|
Size="$(var.VCREDIST_X86_SIZE)"
|
||||||
Version="$(var.VCREDIST_VER).0"
|
Version="$(var.VCREDIST_VER).0"
|
||||||
Hash="$(var.VCREDIST_X86_SHA1)"/>
|
Hash="$(var.VCREDIST_X86_SHA1)"/>
|
||||||
|
|||||||
+70
-68
@@ -32,8 +32,6 @@ bool getHopsIP4(IN_ADDR* hopAddress, int* hopAddressCount);
|
|||||||
struct UPNPDev* getUPnPDevicesByAddress(IN_ADDR address);
|
struct UPNPDev* getUPnPDevicesByAddress(IN_ADDR address);
|
||||||
bool PCPMapPort(PSOCKADDR_STORAGE localAddr, int localAddrLen, PSOCKADDR_STORAGE pcpAddr, int pcpAddrLen, int proto, int port, bool enable, bool indefinite);
|
bool PCPMapPort(PSOCKADDR_STORAGE localAddr, int localAddrLen, PSOCKADDR_STORAGE pcpAddr, int pcpAddrLen, int proto, int port, bool enable, bool indefinite);
|
||||||
|
|
||||||
#define NL "\n"
|
|
||||||
|
|
||||||
#define SERVICE_NAME "MISS"
|
#define SERVICE_NAME "MISS"
|
||||||
#define UPNP_SERVICE_NAME "Moonlight"
|
#define UPNP_SERVICE_NAME "Moonlight"
|
||||||
#define POLLING_DELAY_SEC 120
|
#define POLLING_DELAY_SEC 120
|
||||||
@@ -99,7 +97,7 @@ bool UPnPMapPort(struct UPNPUrls* urls, struct IGDdatas* data, int proto, const
|
|||||||
intClient, intPort, desc, enabled, leaseDuration);
|
intClient, intPort, desc, enabled, leaseDuration);
|
||||||
if (err == 714) {
|
if (err == 714) {
|
||||||
// NoSuchEntryInArray
|
// NoSuchEntryInArray
|
||||||
printf("NOT FOUND" NL);
|
printf("NOT FOUND\n");
|
||||||
|
|
||||||
if (validationPass) {
|
if (validationPass) {
|
||||||
// On validation, we found a missing entry. Convert this entry to indefinite
|
// On validation, we found a missing entry. Convert this entry to indefinite
|
||||||
@@ -108,7 +106,7 @@ bool UPnPMapPort(struct UPNPUrls* urls, struct IGDdatas* data, int proto, const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (err == 606) {
|
else if (err == 606) {
|
||||||
printf("UNAUTHORIZED" NL);
|
printf("UNAUTHORIZED\n");
|
||||||
|
|
||||||
// If we're just validating, we're done. We can't know if the entry was
|
// If we're just validating, we're done. We can't know if the entry was
|
||||||
// actually applied but we'll return true to avoid false errors if it was.
|
// actually applied but we'll return true to avoid false errors if it was.
|
||||||
@@ -120,7 +118,7 @@ bool UPnPMapPort(struct UPNPUrls* urls, struct IGDdatas* data, int proto, const
|
|||||||
// Some routers change the description, so we can't check that here
|
// Some routers change the description, so we can't check that here
|
||||||
if (!strcmp(intClient, myAddr)) {
|
if (!strcmp(intClient, myAddr)) {
|
||||||
if (atoi(leaseDuration) == 0) {
|
if (atoi(leaseDuration) == 0) {
|
||||||
printf("OK (Static, Internal port: %s)" NL, intPort);
|
printf("OK (Static, Internal port: %s)\n", intPort);
|
||||||
|
|
||||||
// If we have an existing permanent mapping, we can just leave it alone.
|
// If we have an existing permanent mapping, we can just leave it alone.
|
||||||
if (enable) {
|
if (enable) {
|
||||||
@@ -128,7 +126,7 @@ bool UPnPMapPort(struct UPNPUrls* urls, struct IGDdatas* data, int proto, const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
printf("OK (%s seconds remaining, Internal port: %s)" NL, leaseDuration, intPort);
|
printf("OK (%s seconds remaining, Internal port: %s)\n", leaseDuration, intPort);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we're just validating, we found an entry, so we're done.
|
// If we're just validating, we found an entry, so we're done.
|
||||||
@@ -141,17 +139,17 @@ bool UPnPMapPort(struct UPNPUrls* urls, struct IGDdatas* data, int proto, const
|
|||||||
printf("Deleting UPnP mapping for %s %s -> %s...", protoStr, portStr, myAddr);
|
printf("Deleting UPnP mapping for %s %s -> %s...", protoStr, portStr, myAddr);
|
||||||
err = UPNP_DeletePortMapping(urls->controlURL, data->first.servicetype, portStr, protoStr, nullptr);
|
err = UPNP_DeletePortMapping(urls->controlURL, data->first.servicetype, portStr, protoStr, nullptr);
|
||||||
if (err == UPNPCOMMAND_SUCCESS) {
|
if (err == UPNPCOMMAND_SUCCESS) {
|
||||||
printf("OK" NL);
|
printf("OK\n");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
printf("ERROR %d" NL, err);
|
printf("ERROR %d\n", err);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
printf("CONFLICT: %s %s" NL, intClient, desc);
|
printf("CONFLICT: %s %s\n", intClient, desc);
|
||||||
|
|
||||||
// If we're just validating, we found an entry, so we're done.
|
// If we're just validating, we found an entry, so we're done.
|
||||||
if (validationPass) {
|
if (validationPass) {
|
||||||
@@ -166,21 +164,21 @@ bool UPnPMapPort(struct UPNPUrls* urls, struct IGDdatas* data, int proto, const
|
|||||||
printf("Trying to delete conflicting UPnP mapping for %s %s -> %s...", protoStr, portStr, intClient);
|
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);
|
err = UPNP_DeletePortMapping(urls->controlURL, data->first.servicetype, portStr, protoStr, nullptr);
|
||||||
if (err == UPNPCOMMAND_SUCCESS) {
|
if (err == UPNPCOMMAND_SUCCESS) {
|
||||||
printf("OK" NL);
|
printf("OK\n");
|
||||||
}
|
}
|
||||||
else if (err == 606) {
|
else if (err == 606) {
|
||||||
printf("UNAUTHORIZED" NL);
|
printf("UNAUTHORIZED\n");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
printf("ERROR %d" NL, err);
|
printf("ERROR %d\n", err);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
printf("ERROR %d (%s)" NL, err, strupnperror(err));
|
printf("ERROR %d (%s)\n", err, strupnperror(err));
|
||||||
|
|
||||||
// If we get a strange error from the router, we'll assume it's some old broken IGDv1
|
// If we get a strange error from the router, we'll assume it's some old broken IGDv1
|
||||||
// device and only use indefinite lease durations to hopefully avoid confusing it.
|
// device and only use indefinite lease durations to hopefully avoid confusing it.
|
||||||
@@ -226,11 +224,11 @@ bool UPnPMapPort(struct UPNPUrls* urls, struct IGDdatas* data, int proto, const
|
|||||||
printf("ALTERNATE ");
|
printf("ALTERNATE ");
|
||||||
}
|
}
|
||||||
if (err == UPNPCOMMAND_SUCCESS) {
|
if (err == UPNPCOMMAND_SUCCESS) {
|
||||||
printf("OK" NL);
|
printf("OK\n");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
printf("ERROR %d (%s)" NL, err, strupnperror(err));
|
printf("ERROR %d (%s)\n", err, strupnperror(err));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -252,7 +250,7 @@ bool GetIP4OnLinkPrefixLength(char* lanAddressString, int* prefixLength)
|
|||||||
free(addresses);
|
free(addresses);
|
||||||
addresses = (PIP_ADAPTER_ADDRESSES)malloc(length);
|
addresses = (PIP_ADAPTER_ADDRESSES)malloc(length);
|
||||||
if (addresses == NULL) {
|
if (addresses == NULL) {
|
||||||
printf("malloc(%u) failed" NL, length);
|
printf("malloc(%u) failed\n", length);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -268,7 +266,7 @@ bool GetIP4OnLinkPrefixLength(char* lanAddressString, int* prefixLength)
|
|||||||
} while (error == ERROR_BUFFER_OVERFLOW);
|
} while (error == ERROR_BUFFER_OVERFLOW);
|
||||||
|
|
||||||
if (error != ERROR_SUCCESS) {
|
if (error != ERROR_SUCCESS) {
|
||||||
printf("GetAdaptersAddresses() failed: %d" NL, error);
|
printf("GetAdaptersAddresses() failed: %d\n", error);
|
||||||
free(addresses);
|
free(addresses);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -294,7 +292,7 @@ bool GetIP4OnLinkPrefixLength(char* lanAddressString, int* prefixLength)
|
|||||||
currentAdapter = currentAdapter->Next;
|
currentAdapter = currentAdapter->Next;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("No adapter found with IPv4 address: %s" NL, lanAddressString);
|
printf("No adapter found with IPv4 address: %s\n", lanAddressString);
|
||||||
free(addresses);
|
free(addresses);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -310,31 +308,31 @@ bool UPnPHandleDeviceList(struct UPNPDev* list, bool enable, char* lanAddrOverri
|
|||||||
|
|
||||||
int ret = UPNP_GetValidIGD(list, &urls, &data, localAddress, sizeof(localAddress));
|
int ret = UPNP_GetValidIGD(list, &urls, &data, localAddress, sizeof(localAddress));
|
||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
printf("No UPnP device found!" NL);
|
printf("No UPnP device found!\n");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else if (ret == 3) {
|
else if (ret == 3) {
|
||||||
printf("No UPnP IGD found!" NL);
|
printf("No UPnP IGD found!\n");
|
||||||
FreeUPNPUrls(&urls);
|
FreeUPNPUrls(&urls);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else if (ret == 1) {
|
else if (ret == 1) {
|
||||||
printf("Found a connected UPnP IGD (%s)" NL, urls.rootdescURL);
|
printf("Found a connected UPnP IGD (%s)\n", urls.rootdescURL);
|
||||||
}
|
}
|
||||||
else if (ret == 2) {
|
else if (ret == 2) {
|
||||||
printf("Found a disconnected (!) UPnP IGD (%s)" NL, urls.rootdescURL);
|
printf("Found a disconnected (!) UPnP IGD (%s)\n", urls.rootdescURL);
|
||||||
|
|
||||||
// Even if we are able to add forwarding entries, go ahead and try NAT-PMP
|
// Even if we are able to add forwarding entries, go ahead and try NAT-PMP
|
||||||
success = false;
|
success = false;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
printf("UPNP_GetValidIGD() failed: %d" NL, ret);
|
printf("UPNP_GetValidIGD() failed: %d\n", ret);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = UPNP_GetExternalIPAddress(urls.controlURL, data.first.servicetype, wanAddr);
|
ret = UPNP_GetExternalIPAddress(urls.controlURL, data.first.servicetype, wanAddr);
|
||||||
if (ret == UPNPCOMMAND_SUCCESS) {
|
if (ret == UPNPCOMMAND_SUCCESS) {
|
||||||
printf("UPnP IGD WAN address is: %s" NL, wanAddr);
|
printf("UPnP IGD WAN address is: %s\n", wanAddr);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Empty string
|
// Empty string
|
||||||
@@ -390,7 +388,7 @@ bool UPnPHandleDeviceList(struct UPNPDev* list, bool enable, char* lanAddrOverri
|
|||||||
// Wait 10 seconds for the router state to quiesce or the stop event to be set
|
// Wait 10 seconds for the router state to quiesce or the stop event to be set
|
||||||
printf("Waiting before UPnP port validation...");
|
printf("Waiting before UPnP port validation...");
|
||||||
if (WaitForSingleObject(s_StopEvent, 10000) == WAIT_TIMEOUT) {
|
if (WaitForSingleObject(s_StopEvent, 10000) == WAIT_TIMEOUT) {
|
||||||
printf("done" NL);
|
printf("done\n");
|
||||||
|
|
||||||
// Perform the validation pass (converting any now missing entries to permanent ones)
|
// Perform the validation pass (converting any now missing entries to permanent ones)
|
||||||
for (int i = 0; i < ARRAYSIZE(k_Ports); i++) {
|
for (int i = 0; i < ARRAYSIZE(k_Ports); i++) {
|
||||||
@@ -400,7 +398,7 @@ bool UPnPHandleDeviceList(struct UPNPDev* list, bool enable, char* lanAddrOverri
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
printf("aborted" NL);
|
printf("aborted\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -440,7 +438,7 @@ bool NATPMPMapPort(natpmp_t* natpmp, int proto, int port, bool enable, bool inde
|
|||||||
printf("Updating NAT-PMP port mapping for %s %d...", proto == IPPROTO_TCP ? "TCP" : "UDP", port);
|
printf("Updating NAT-PMP port mapping for %s %d...", proto == IPPROTO_TCP ? "TCP" : "UDP", port);
|
||||||
int err = sendnewportmappingrequest(natpmp, natPmpProto, port, enable ? port : 0, lifetime);
|
int err = sendnewportmappingrequest(natpmp, natPmpProto, port, enable ? port : 0, lifetime);
|
||||||
if (err < 0) {
|
if (err < 0) {
|
||||||
printf("ERROR %d" NL, err);
|
printf("ERROR %d\n", err);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -456,7 +454,7 @@ bool NATPMPMapPort(natpmp_t* natpmp, int proto, int port, bool enable, bool inde
|
|||||||
err = getnatpmprequesttimeout(natpmp, &timeout);
|
err = getnatpmprequesttimeout(natpmp, &timeout);
|
||||||
if (err != 0) {
|
if (err != 0) {
|
||||||
assert(err == 0);
|
assert(err == 0);
|
||||||
printf("WAIT FAILED: %d" NL, err);
|
printf("WAIT FAILED: %d\n", err);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -466,22 +464,22 @@ bool NATPMPMapPort(natpmp_t* natpmp, int proto, int port, bool enable, bool inde
|
|||||||
} while (err == NATPMP_TRYAGAIN);
|
} while (err == NATPMP_TRYAGAIN);
|
||||||
|
|
||||||
if (err != 0) {
|
if (err != 0) {
|
||||||
printf("FAILED %d" NL, err);
|
printf("FAILED %d\n", err);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else if (response.pnu.newportmapping.lifetime == 0 && !enable) {
|
else if (response.pnu.newportmapping.lifetime == 0 && !enable) {
|
||||||
printf("DELETED" NL);
|
printf("DELETED\n");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if (response.pnu.newportmapping.mappedpublicport != port) {
|
else if (response.pnu.newportmapping.mappedpublicport != port) {
|
||||||
printf("CONFLICT" NL);
|
printf("CONFLICT\n");
|
||||||
|
|
||||||
// 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.
|
||||||
printf("Deleting unwanted NAT-PMP mapping for %s %d...", proto == IPPROTO_TCP ? "TCP" : "UDP", response.pnu.newportmapping.mappedpublicport);
|
printf("Deleting unwanted NAT-PMP mapping for %s %d...", proto == IPPROTO_TCP ? "TCP" : "UDP", response.pnu.newportmapping.mappedpublicport);
|
||||||
err = sendnewportmappingrequest(natpmp, natPmpProto, response.pnu.newportmapping.privateport, 0, 0);
|
err = sendnewportmappingrequest(natpmp, natPmpProto, response.pnu.newportmapping.privateport, 0, 0);
|
||||||
if (err < 0) {
|
if (err < 0) {
|
||||||
printf("ERROR %d" NL, err);
|
printf("ERROR %d\n", err);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -495,7 +493,7 @@ bool NATPMPMapPort(natpmp_t* natpmp, int proto, int port, bool enable, bool inde
|
|||||||
err = getnatpmprequesttimeout(natpmp, &timeout);
|
err = getnatpmprequesttimeout(natpmp, &timeout);
|
||||||
if (err != 0) {
|
if (err != 0) {
|
||||||
assert(err == 0);
|
assert(err == 0);
|
||||||
printf("WAIT FAILED: %d" NL, err);
|
printf("WAIT FAILED: %d\n", err);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -505,17 +503,17 @@ bool NATPMPMapPort(natpmp_t* natpmp, int proto, int port, bool enable, bool inde
|
|||||||
} while (err == NATPMP_TRYAGAIN);
|
} while (err == NATPMP_TRYAGAIN);
|
||||||
|
|
||||||
if (err == 0) {
|
if (err == 0) {
|
||||||
printf("OK" NL);
|
printf("OK\n");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
printf("FAILED %d" NL, err);
|
printf("FAILED %d\n", err);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
printf("OK (%d seconds remaining)" NL, response.pnu.newportmapping.lifetime);
|
printf("OK (%d seconds remaining)\n", response.pnu.newportmapping.lifetime);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -537,7 +535,7 @@ bool IsGameStreamEnabled()
|
|||||||
error = RegQueryValueExA(key, "EnableStreaming", nullptr, nullptr, (LPBYTE)&enabled, &len);
|
error = RegQueryValueExA(key, "EnableStreaming", nullptr, nullptr, (LPBYTE)&enabled, &len);
|
||||||
RegCloseKey(key);
|
RegCloseKey(key);
|
||||||
if (error != ERROR_SUCCESS) {
|
if (error != ERROR_SUCCESS) {
|
||||||
printf("RegQueryValueExA() failed: %d" NL, error);
|
printf("RegQueryValueExA() failed: %d\n", error);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -552,18 +550,18 @@ void UpdatePortMappingsForTarget(bool enable, char* targetAddressIP4, char* inte
|
|||||||
char upstreamAddrNatPmp[128] = {};
|
char upstreamAddrNatPmp[128] = {};
|
||||||
char upstreamAddrUPnP[128] = {};
|
char upstreamAddrUPnP[128] = {};
|
||||||
|
|
||||||
printf("Starting port mapping update on %s to %s..." NL,
|
printf("Starting port mapping update on %s to %s...\n",
|
||||||
targetAddressIP4 ? targetAddressIP4 : "default gateway",
|
targetAddressIP4 ? targetAddressIP4 : "default gateway",
|
||||||
internalAddressIP4 ? internalAddressIP4 : "local machine");
|
internalAddressIP4 ? internalAddressIP4 : "local machine");
|
||||||
|
|
||||||
int natPmpErr = initnatpmp(&natpmp, targetAddressIP4 ? 1 : 0, targetAddressIP4 ? inet_addr(targetAddressIP4) : 0);
|
int natPmpErr = initnatpmp(&natpmp, targetAddressIP4 ? 1 : 0, targetAddressIP4 ? inet_addr(targetAddressIP4) : 0);
|
||||||
if (natPmpErr != 0) {
|
if (natPmpErr != 0) {
|
||||||
printf("initnatpmp() failed: %d" NL, natPmpErr);
|
printf("initnatpmp() failed: %d\n", natPmpErr);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
natPmpErr = sendpublicaddressrequest(&natpmp);
|
natPmpErr = sendpublicaddressrequest(&natpmp);
|
||||||
if (natPmpErr < 0) {
|
if (natPmpErr < 0) {
|
||||||
printf("sendpublicaddressrequest() failed: %d" NL, natPmpErr);
|
printf("sendpublicaddressrequest() failed: %d\n", natPmpErr);
|
||||||
closenatpmp(&natpmp);
|
closenatpmp(&natpmp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -577,7 +575,7 @@ void UpdatePortMappingsForTarget(bool enable, char* targetAddressIP4, char* inte
|
|||||||
if (targetAddressIP4 == nullptr) {
|
if (targetAddressIP4 == nullptr) {
|
||||||
// If we have no target, use discovery to find the first hop
|
// If we have no target, use discovery to find the first hop
|
||||||
ipv4Devs = upnpDiscoverAll(UPNP_DISCOVERY_DELAY_MS, nullptr, nullptr, UPNP_LOCAL_PORT_ANY, 0, 2, &upnpErr);
|
ipv4Devs = upnpDiscoverAll(UPNP_DISCOVERY_DELAY_MS, nullptr, nullptr, UPNP_LOCAL_PORT_ANY, 0, 2, &upnpErr);
|
||||||
printf("UPnP IPv4 IGD discovery completed with error code: %d" NL, upnpErr);
|
printf("UPnP IPv4 IGD discovery completed with error code: %d\n", upnpErr);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// We have a specified target, so do discovery against that directly (may be outside our subnet in case of double-NAT)
|
// We have a specified target, so do discovery against that directly (may be outside our subnet in case of double-NAT)
|
||||||
@@ -588,7 +586,7 @@ void UpdatePortMappingsForTarget(bool enable, char* targetAddressIP4, char* inte
|
|||||||
|
|
||||||
// Abort if this is an add/update request and we're stopping
|
// Abort if this is an add/update request and we're stopping
|
||||||
if (enable && WaitForSingleObject(s_StopEvent, 0) == WAIT_OBJECT_0) {
|
if (enable && WaitForSingleObject(s_StopEvent, 0) == WAIT_OBJECT_0) {
|
||||||
printf("Aborting port mapping update due to stop request" NL);
|
printf("Aborting port mapping update due to stop request\n");
|
||||||
goto Exit;
|
goto Exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -598,17 +596,17 @@ void UpdatePortMappingsForTarget(bool enable, char* targetAddressIP4, char* inte
|
|||||||
natPmpErr = readnatpmpresponseorretry(&natpmp, &response);
|
natPmpErr = readnatpmpresponseorretry(&natpmp, &response);
|
||||||
if (natPmpErr == 0) {
|
if (natPmpErr == 0) {
|
||||||
inet_ntop(AF_INET, &response.pnu.publicaddress.addr, upstreamAddrNatPmp, sizeof(upstreamAddrNatPmp));
|
inet_ntop(AF_INET, &response.pnu.publicaddress.addr, upstreamAddrNatPmp, sizeof(upstreamAddrNatPmp));
|
||||||
printf("NAT-PMP upstream address is: %s" NL, upstreamAddrNatPmp);
|
printf("NAT-PMP upstream address is: %s\n", upstreamAddrNatPmp);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
printf("NAT-PMP public address request failed: %d" NL, natPmpErr);
|
printf("NAT-PMP public address request failed: %d\n", natPmpErr);
|
||||||
closenatpmp(&natpmp);
|
closenatpmp(&natpmp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Don't try NAT-PMP if UPnP succeeds
|
// Don't try NAT-PMP if UPnP succeeds
|
||||||
if (UPnPHandleDeviceList(ipv4Devs, enable, internalAddressIP4, upstreamAddrUPnP)) {
|
if (UPnPHandleDeviceList(ipv4Devs, enable, internalAddressIP4, upstreamAddrUPnP)) {
|
||||||
printf("UPnP IPv4 port mapping successful" NL);
|
printf("UPnP IPv4 port mapping successful\n");
|
||||||
if (enable) {
|
if (enable) {
|
||||||
// We still want to try NAT-PMP if we're removing
|
// We still want to try NAT-PMP if we're removing
|
||||||
// rules to ensure any NAT-PMP rules get cleaned up
|
// rules to ensure any NAT-PMP rules get cleaned up
|
||||||
@@ -627,7 +625,7 @@ void UpdatePortMappingsForTarget(bool enable, char* targetAddressIP4, char* inte
|
|||||||
// if we created the rules we'd be deleting. Since we don't have that, we can't
|
// if we created the rules we'd be deleting. Since we don't have that, we can't
|
||||||
// safely remove mappings that could be shared by another machine behind a double NAT.
|
// safely remove mappings that could be shared by another machine behind a double NAT.
|
||||||
if (!enable && targetAddressIP4 != nullptr) {
|
if (!enable && targetAddressIP4 != nullptr) {
|
||||||
printf("Not removing upstream NAT-PMP mappings on non-default gateway device" NL);
|
printf("Not removing upstream NAT-PMP mappings on non-default gateway device\n");
|
||||||
tryNatPmp = false;
|
tryNatPmp = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -663,7 +661,7 @@ void UpdatePortMappingsForTarget(bool enable, char* targetAddressIP4, char* inte
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (success) {
|
if (success) {
|
||||||
printf("NAT-PMP IPv4 port mapping successful" NL);
|
printf("NAT-PMP IPv4 port mapping successful\n");
|
||||||
|
|
||||||
// Always try all possibilities when disabling to ensure
|
// Always try all possibilities when disabling to ensure
|
||||||
// we completely clean up
|
// we completely clean up
|
||||||
@@ -695,7 +693,7 @@ void UpdatePortMappingsForTarget(bool enable, char* targetAddressIP4, char* inte
|
|||||||
targetAddr.sin_addr.S_un.S_addr = route.dwForwardNextHop;
|
targetAddr.sin_addr.S_un.S_addr = route.dwForwardNextHop;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
printf("GetBestRoute() failed: %d" NL, error);
|
printf("GetBestRoute() failed: %d\n", error);
|
||||||
goto Exit;
|
goto Exit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -723,22 +721,22 @@ void UpdatePortMappingsForTarget(bool enable, char* targetAddressIP4, char* inte
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (success) {
|
if (success) {
|
||||||
printf("PCP IPv4 port mapping successful" NL);
|
printf("PCP IPv4 port mapping successful\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Exit:
|
Exit:
|
||||||
// Write this at the end to avoid clobbering an input parameter
|
// Write this at the end to avoid clobbering an input parameter
|
||||||
if (upstreamAddrNatPmp[0] != 0 && inet_addr(upstreamAddrNatPmp) != 0) {
|
if (upstreamAddrNatPmp[0] != 0 && inet_addr(upstreamAddrNatPmp) != 0) {
|
||||||
printf("Using NAT-PMP upstream IPv4 address: %s" NL, upstreamAddrNatPmp);
|
printf("Using NAT-PMP upstream IPv4 address: %s\n", upstreamAddrNatPmp);
|
||||||
strcpy(upstreamAddressIP4, upstreamAddrNatPmp);
|
strcpy(upstreamAddressIP4, upstreamAddrNatPmp);
|
||||||
}
|
}
|
||||||
else if (upstreamAddrUPnP[0] != 0 && inet_addr(upstreamAddrUPnP) != 0) {
|
else if (upstreamAddrUPnP[0] != 0 && inet_addr(upstreamAddrUPnP) != 0) {
|
||||||
printf("Using UPnP upstream IPv4 address: %s" NL, upstreamAddrUPnP);
|
printf("Using UPnP upstream IPv4 address: %s\n", upstreamAddrUPnP);
|
||||||
strcpy(upstreamAddressIP4, upstreamAddrUPnP);
|
strcpy(upstreamAddressIP4, upstreamAddrUPnP);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
printf("No valid upstream IPv4 address found!" NL);
|
printf("No valid upstream IPv4 address found!\n");
|
||||||
upstreamAddressIP4[0] = 0;
|
upstreamAddressIP4[0] = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -774,12 +772,12 @@ void UpdatePortMappings(bool enable)
|
|||||||
char upstreamAddrStr[128];
|
char upstreamAddrStr[128];
|
||||||
unsigned long upstreamAddr;
|
unsigned long upstreamAddr;
|
||||||
|
|
||||||
printf("Finding upstream IPv4 hops via traceroute..." NL);
|
printf("Finding upstream IPv4 hops via traceroute...\n");
|
||||||
if (!getHopsIP4(hops, &hopCount)) {
|
if (!getHopsIP4(hops, &hopCount)) {
|
||||||
hopCount = 0;
|
hopCount = 0;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
printf("Found %d hops" NL, hopCount);
|
printf("Found %d hops\n", hopCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
// getHopsIP4() already skips the default gateway, so 0
|
// getHopsIP4() already skips the default gateway, so 0
|
||||||
@@ -791,10 +789,10 @@ void UpdatePortMappings(bool enable)
|
|||||||
while (upstreamAddrStr[0] != 0 && (upstreamAddr = inet_addr(upstreamAddrStr)) != 0) {
|
while (upstreamAddrStr[0] != 0 && (upstreamAddr = inet_addr(upstreamAddrStr)) != 0) {
|
||||||
// We got an upstream address. Let's check if this is a NAT
|
// We got an upstream address. Let's check if this is a NAT
|
||||||
if (IsLikelyNAT(upstreamAddr)) {
|
if (IsLikelyNAT(upstreamAddr)) {
|
||||||
printf("Upstream address %s is likely a NAT" NL, upstreamAddrStr);
|
printf("Upstream address %s is likely a NAT\n", upstreamAddrStr);
|
||||||
|
|
||||||
if (nextHopIndex >= hopCount) {
|
if (nextHopIndex >= hopCount) {
|
||||||
printf("Traceroute didn't reach this hop! Aborting!" NL);
|
printf("Traceroute didn't reach this hop! Aborting!\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -808,7 +806,7 @@ void UpdatePortMappings(bool enable)
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// If we reach a proper public IP address, we're done
|
// If we reach a proper public IP address, we're done
|
||||||
printf("Reached the Internet at hop %d" NL, nextHopIndex);
|
printf("Reached the Internet at hop %d\n", nextHopIndex);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -844,16 +842,20 @@ void ResetLogFile(bool standaloneExe)
|
|||||||
MoveFileExA(currentLogFilePath, oldLogFilePath, MOVEFILE_REPLACE_EXISTING);
|
MoveFileExA(currentLogFilePath, oldLogFilePath, MOVEFILE_REPLACE_EXISTING);
|
||||||
|
|
||||||
// Redirect stdout to this new file
|
// Redirect stdout to this new file
|
||||||
freopen(currentLogFilePath, "w", stdout);
|
if (freopen(currentLogFilePath, "w", stdout) == NULL) {
|
||||||
|
// If we couldn't create a log file, just redirect stdout to NUL.
|
||||||
|
// We have to open _something_ or printf() will crash.
|
||||||
|
freopen("NUL", "w", stdout);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Print a log header
|
// Print a log header
|
||||||
printf("Moonlight Internet Streaming Service v" VER_VERSION_STR NL);
|
printf("Moonlight Internet Streaming Service v" VER_VERSION_STR "\n");
|
||||||
|
|
||||||
// Print the current time
|
// Print the current time
|
||||||
GetSystemTime(&time);
|
GetSystemTime(&time);
|
||||||
GetTimeFormatA(LOCALE_SYSTEM_DEFAULT, 0, &time, "hh':'mm':'ss tt", timeString, ARRAYSIZE(timeString));
|
GetTimeFormatA(LOCALE_SYSTEM_DEFAULT, 0, &time, "hh':'mm':'ss tt", timeString, ARRAYSIZE(timeString));
|
||||||
printf("The current UTC time is: %s" NL, timeString);
|
printf("The current UTC time is: %s\n", timeString);
|
||||||
}
|
}
|
||||||
|
|
||||||
DWORD WINAPI GameStreamStateChangeThread(PVOID Context)
|
DWORD WINAPI GameStreamStateChangeThread(PVOID Context)
|
||||||
@@ -934,10 +936,10 @@ int Run(bool standaloneExe)
|
|||||||
bool gameStreamEnabled = IsGameStreamEnabled();
|
bool gameStreamEnabled = IsGameStreamEnabled();
|
||||||
|
|
||||||
if (gameStreamEnabled) {
|
if (gameStreamEnabled) {
|
||||||
printf("GameStream is ON!" NL);
|
printf("GameStream is ON!\n");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
printf("GameStream is OFF!" NL);
|
printf("GameStream is OFF!\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Acquire the mapping lock and update port mappings
|
// Acquire the mapping lock and update port mappings
|
||||||
@@ -954,7 +956,7 @@ int Run(bool standaloneExe)
|
|||||||
|
|
||||||
// Refresh when half the duration is expired or if an IP interface
|
// Refresh when half the duration is expired or if an IP interface
|
||||||
// change event occurs.
|
// change event occurs.
|
||||||
printf("Going to sleep..." NL);
|
printf("Going to sleep...\n");
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
|
|
||||||
ULONGLONG beforeSleepTime = GetTickCount64();
|
ULONGLONG beforeSleepTime = GetTickCount64();
|
||||||
@@ -962,7 +964,7 @@ int Run(bool standaloneExe)
|
|||||||
if (ret == WAIT_OBJECT_0) {
|
if (ret == WAIT_OBJECT_0) {
|
||||||
ResetLogFile(standaloneExe);
|
ResetLogFile(standaloneExe);
|
||||||
|
|
||||||
printf("Woke up for interface change notification after %lld seconds" NL,
|
printf("Woke up for interface change notification after %lld seconds\n",
|
||||||
(GetTickCount64() - beforeSleepTime) / 1000);
|
(GetTickCount64() - beforeSleepTime) / 1000);
|
||||||
|
|
||||||
// Wait a little bit for the interface to settle down (DHCP, RA, etc)
|
// Wait a little bit for the interface to settle down (DHCP, RA, etc)
|
||||||
@@ -971,17 +973,17 @@ int Run(bool standaloneExe)
|
|||||||
else if (ret == WAIT_OBJECT_0 + 1) {
|
else if (ret == WAIT_OBJECT_0 + 1) {
|
||||||
ResetLogFile(standaloneExe);
|
ResetLogFile(standaloneExe);
|
||||||
|
|
||||||
printf("Woke up for GameStream state change notification after %lld seconds" NL,
|
printf("Woke up for GameStream state change notification after %lld seconds\n",
|
||||||
(GetTickCount64() - beforeSleepTime) / 1000);
|
(GetTickCount64() - beforeSleepTime) / 1000);
|
||||||
}
|
}
|
||||||
else if (ret == WAIT_OBJECT_0 + 2) {
|
else if (ret == WAIT_OBJECT_0 + 2) {
|
||||||
printf("Woke up for stop notification" NL);
|
printf("Woke up for stop notification\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
ResetLogFile(standaloneExe);
|
ResetLogFile(standaloneExe);
|
||||||
|
|
||||||
printf("Woke up for periodic refresh" NL);
|
printf("Woke up for periodic refresh\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1031,7 +1033,7 @@ ServiceMain(DWORD dwArgc, LPTSTR *lpszArgv)
|
|||||||
|
|
||||||
ServiceStatusHandle = RegisterServiceCtrlHandlerEx(SERVICE_NAME, HandlerEx, NULL);
|
ServiceStatusHandle = RegisterServiceCtrlHandlerEx(SERVICE_NAME, HandlerEx, NULL);
|
||||||
if (ServiceStatusHandle == NULL) {
|
if (ServiceStatusHandle == NULL) {
|
||||||
fprintf(stderr, "RegisterServiceCtrlHandlerEx() failed: %d" NL, GetLastError());
|
fprintf(stderr, "RegisterServiceCtrlHandlerEx() failed: %d\n", GetLastError());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+4
-4
@@ -29,26 +29,26 @@
|
|||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||||
<ConfigurationType>Application</ConfigurationType>
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
<UseDebugLibraries>true</UseDebugLibraries>
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
<PlatformToolset>v142</PlatformToolset>
|
<PlatformToolset>v143</PlatformToolset>
|
||||||
<CharacterSet>NotSet</CharacterSet>
|
<CharacterSet>NotSet</CharacterSet>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||||
<ConfigurationType>Application</ConfigurationType>
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
<UseDebugLibraries>false</UseDebugLibraries>
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
<PlatformToolset>v142</PlatformToolset>
|
<PlatformToolset>v143</PlatformToolset>
|
||||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
<CharacterSet>NotSet</CharacterSet>
|
<CharacterSet>NotSet</CharacterSet>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||||
<ConfigurationType>Application</ConfigurationType>
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
<UseDebugLibraries>true</UseDebugLibraries>
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
<PlatformToolset>v142</PlatformToolset>
|
<PlatformToolset>v143</PlatformToolset>
|
||||||
<CharacterSet>NotSet</CharacterSet>
|
<CharacterSet>NotSet</CharacterSet>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||||
<ConfigurationType>Application</ConfigurationType>
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
<UseDebugLibraries>false</UseDebugLibraries>
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
<PlatformToolset>v142</PlatformToolset>
|
<PlatformToolset>v143</PlatformToolset>
|
||||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
<CharacterSet>NotSet</CharacterSet>
|
<CharacterSet>NotSet</CharacterSet>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|||||||
+4
-4
@@ -29,26 +29,26 @@
|
|||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||||
<ConfigurationType>Application</ConfigurationType>
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
<UseDebugLibraries>true</UseDebugLibraries>
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
<PlatformToolset>v142</PlatformToolset>
|
<PlatformToolset>v143</PlatformToolset>
|
||||||
<CharacterSet>NotSet</CharacterSet>
|
<CharacterSet>NotSet</CharacterSet>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||||
<ConfigurationType>Application</ConfigurationType>
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
<UseDebugLibraries>false</UseDebugLibraries>
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
<PlatformToolset>v142</PlatformToolset>
|
<PlatformToolset>v143</PlatformToolset>
|
||||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
<CharacterSet>NotSet</CharacterSet>
|
<CharacterSet>NotSet</CharacterSet>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||||
<ConfigurationType>Application</ConfigurationType>
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
<UseDebugLibraries>true</UseDebugLibraries>
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
<PlatformToolset>v142</PlatformToolset>
|
<PlatformToolset>v143</PlatformToolset>
|
||||||
<CharacterSet>Unicode</CharacterSet>
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||||
<ConfigurationType>Application</ConfigurationType>
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
<UseDebugLibraries>false</UseDebugLibraries>
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
<PlatformToolset>v142</PlatformToolset>
|
<PlatformToolset>v143</PlatformToolset>
|
||||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
<CharacterSet>Unicode</CharacterSet>
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#define VER_VERSION 5,5,2,0
|
#define VER_VERSION 5,5,4,0
|
||||||
#define VER_VERSION_STR "5.5.2.0"
|
#define VER_VERSION_STR "5.5.4.0"
|
||||||
|
|
||||||
#define VER_COMPANYNAME_STR "Moonlight Game Streaming Project"
|
#define VER_COMPANYNAME_STR "Moonlight Game Streaming Project"
|
||||||
#define VER_PRODUCTNAME_STR "Moonlight Internet Hosting Tool"
|
#define VER_PRODUCTNAME_STR "Moonlight Internet Hosting Tool"
|
||||||
|
|||||||
Reference in New Issue
Block a user