mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2024-11-22 04:21:23 +00:00
Update i_tcp.c
made UPnP port mapping enabled by default lowered UPnP Discover delay from 2000 ms to 500 ms only look for first InternetGatewayDevice found remove UPnP port mapping on shutdown
This commit is contained in:
parent
9c3ac6c86f
commit
acc78d0ee5
1 changed files with 16 additions and 9 deletions
25
src/i_tcp.c
25
src/i_tcp.c
|
@ -268,23 +268,24 @@ static const char* inet_ntopA(short af, const void *cp, char *buf, socklen_t len
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_MINIUPNPC // based on old XChat patch
|
#ifdef HAVE_MINIUPNPC // based on old XChat patch
|
||||||
|
static void I_ShutdownUPnP(void);
|
||||||
static struct UPNPUrls urls;
|
static struct UPNPUrls urls;
|
||||||
static struct IGDdatas data;
|
static struct IGDdatas data;
|
||||||
static char lanaddr[64];
|
static char lanaddr[64];
|
||||||
|
|
||||||
static void I_ShutdownUPnP(void)
|
|
||||||
{
|
|
||||||
FreeUPNPUrls(&urls);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void I_InitUPnP(void)
|
static inline void I_InitUPnP(void)
|
||||||
{
|
{
|
||||||
|
const char * const deviceTypes[] = {
|
||||||
|
"urn:schemas-upnp-org:device:InternetGatewayDevice:2",
|
||||||
|
"urn:schemas-upnp-org:device:InternetGatewayDevice:1",
|
||||||
|
0
|
||||||
|
};
|
||||||
struct UPNPDev * devlist = NULL;
|
struct UPNPDev * devlist = NULL;
|
||||||
int upnp_error = -2;
|
int upnp_error = -2;
|
||||||
int scope_id = 0;
|
int scope_id = 0;
|
||||||
int status_code = 0;
|
int status_code = 0;
|
||||||
CONS_Printf(M_GetText("Looking for UPnP Internet Gateway Device\n"));
|
CONS_Printf(M_GetText("Looking for UPnP Internet Gateway Device\n"));
|
||||||
devlist = upnpDiscover(2000, NULL, NULL, 0, false, 2, &upnp_error);
|
devlist = upnpDiscoverDevices(deviceTypes, 500, NULL, NULL, 0, false, 2, &upnp_error, 0);
|
||||||
if (devlist)
|
if (devlist)
|
||||||
{
|
{
|
||||||
struct UPNPDev *dev = devlist;
|
struct UPNPDev *dev = devlist;
|
||||||
|
@ -340,6 +341,12 @@ static inline void I_UPnP_rem(const char *port, const char * servicetype)
|
||||||
UPNP_DeletePortMapping(urls.controlURL, data.first.servicetype,
|
UPNP_DeletePortMapping(urls.controlURL, data.first.servicetype,
|
||||||
port, servicetype, NULL);
|
port, servicetype, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void I_ShutdownUPnP(void)
|
||||||
|
{
|
||||||
|
I_UPnP_rem(serverport_name, "UDP");
|
||||||
|
FreeUPNPUrls(&urls);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static const char *SOCK_AddrToStr(mysockaddr_t *sk)
|
static const char *SOCK_AddrToStr(mysockaddr_t *sk)
|
||||||
|
@ -1130,10 +1137,10 @@ boolean I_InitTcpDriver(void)
|
||||||
{
|
{
|
||||||
I_AddExitFunc(I_ShutdownTcpDriver);
|
I_AddExitFunc(I_ShutdownTcpDriver);
|
||||||
#ifdef HAVE_MINIUPNPC
|
#ifdef HAVE_MINIUPNPC
|
||||||
if (M_CheckParm("-useUPnP"))
|
if (M_CheckParm("-noUPnP"))
|
||||||
I_InitUPnP();
|
|
||||||
else
|
|
||||||
UPNP_support = false;
|
UPNP_support = false;
|
||||||
|
else
|
||||||
|
I_InitUPnP();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
return init_tcp_driver;
|
return init_tcp_driver;
|
||||||
|
|
Loading…
Reference in a new issue