Use a random port when connecting
This commit is contained in:
parent
53c7df4818
commit
f584b61c93
|
@ -70,7 +70,7 @@
|
||||||
boolean server = true; // true or false but !server == client
|
boolean server = true; // true or false but !server == client
|
||||||
#define client (!server)
|
#define client (!server)
|
||||||
boolean nodownload = false;
|
boolean nodownload = false;
|
||||||
static boolean serverrunning = false;
|
boolean serverrunning = false;
|
||||||
INT32 serverplayer = 0;
|
INT32 serverplayer = 0;
|
||||||
char motd[254], server_context[8]; // Message of the Day, Unique Context (even without Mumble support)
|
char motd[254], server_context[8]; // Message of the Day, Unique Context (even without Mumble support)
|
||||||
|
|
||||||
|
|
|
@ -40,6 +40,8 @@ extern SINT8 nodetoplayer2[MAXNETNODES]; // Say the numplayer for this node if a
|
||||||
extern UINT8 playerpernode[MAXNETNODES]; // Used specially for splitscreen
|
extern UINT8 playerpernode[MAXNETNODES]; // Used specially for splitscreen
|
||||||
extern boolean nodeingame[MAXNETNODES]; // Set false as nodes leave game
|
extern boolean nodeingame[MAXNETNODES]; // Set false as nodes leave game
|
||||||
|
|
||||||
|
extern boolean serverrunning;
|
||||||
|
|
||||||
INT32 Net_GetFreeAcks(boolean urgent);
|
INT32 Net_GetFreeAcks(boolean urgent);
|
||||||
void Net_AckTicker(void);
|
void Net_AckTicker(void);
|
||||||
|
|
||||||
|
|
14
src/i_tcp.c
14
src/i_tcp.c
|
@ -887,6 +887,7 @@ static boolean UDP_Socket(void)
|
||||||
#ifdef HAVE_IPV6
|
#ifdef HAVE_IPV6
|
||||||
const INT32 b_ipv6 = M_CheckParm("-ipv6");
|
const INT32 b_ipv6 = M_CheckParm("-ipv6");
|
||||||
#endif
|
#endif
|
||||||
|
const char *serv;
|
||||||
|
|
||||||
|
|
||||||
for (s = 0; s < mysocketses; s++)
|
for (s = 0; s < mysocketses; s++)
|
||||||
|
@ -902,11 +903,16 @@ static boolean UDP_Socket(void)
|
||||||
hints.ai_socktype = SOCK_DGRAM;
|
hints.ai_socktype = SOCK_DGRAM;
|
||||||
hints.ai_protocol = IPPROTO_UDP;
|
hints.ai_protocol = IPPROTO_UDP;
|
||||||
|
|
||||||
|
if (serverrunning)
|
||||||
|
serv = port_name;
|
||||||
|
else
|
||||||
|
serv = NULL;/* any port */
|
||||||
|
|
||||||
if (M_CheckParm("-bindaddr"))
|
if (M_CheckParm("-bindaddr"))
|
||||||
{
|
{
|
||||||
while (M_IsNextParm())
|
while (M_IsNextParm())
|
||||||
{
|
{
|
||||||
gaie = I_getaddrinfo(M_GetNextParm(), port_name, &hints, &ai);
|
gaie = I_getaddrinfo(M_GetNextParm(), serv, &hints, &ai);
|
||||||
if (gaie == 0)
|
if (gaie == 0)
|
||||||
{
|
{
|
||||||
runp = ai;
|
runp = ai;
|
||||||
|
@ -927,7 +933,7 @@ static boolean UDP_Socket(void)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
gaie = I_getaddrinfo("0.0.0.0", port_name, &hints, &ai);
|
gaie = I_getaddrinfo("0.0.0.0", serv, &hints, &ai);
|
||||||
if (gaie == 0)
|
if (gaie == 0)
|
||||||
{
|
{
|
||||||
runp = ai;
|
runp = ai;
|
||||||
|
@ -960,7 +966,7 @@ static boolean UDP_Socket(void)
|
||||||
{
|
{
|
||||||
while (M_IsNextParm())
|
while (M_IsNextParm())
|
||||||
{
|
{
|
||||||
gaie = I_getaddrinfo(M_GetNextParm(), port_name, &hints, &ai);
|
gaie = I_getaddrinfo(M_GetNextParm(), serv, &hints, &ai);
|
||||||
if (gaie == 0)
|
if (gaie == 0)
|
||||||
{
|
{
|
||||||
runp = ai;
|
runp = ai;
|
||||||
|
@ -981,7 +987,7 @@ static boolean UDP_Socket(void)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
gaie = I_getaddrinfo("::", port_name, &hints, &ai);
|
gaie = I_getaddrinfo("::", serv, &hints, &ai);
|
||||||
if (gaie == 0)
|
if (gaie == 0)
|
||||||
{
|
{
|
||||||
runp = ai;
|
runp = ai;
|
||||||
|
|
Loading…
Reference in New Issue