Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

+CLSTAT_PORT, +SRVMAIN_PORT #4

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions netconn.c
Copy link
Author

@oeai oeai Aug 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually you can't use the range of 0-1024 - it is binded for ftp/http/clock etc
but for client - sometimes it is more open and if it takes there, maybe it is wrong

now you can set the CLSTAT to 0 and for clients it will be random from this clPortRange
and for example set the range to hoger ports 63000-64000, but it's better to put that in GUI
with random switch and write some exact port, while leaving random port range more predefined.
it really produces error when server gets to random higher port, socket overload can be the problem of that
for example when they ask for heartbeat or server reply +socket runs and it may bump out the real server socket

Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define DPMASTER_PORT 27950
#define SRVMAIN_PORT 26000
#define CLSTAT_PORT 26062

// can be set to 0 - 65536 aka random uPnP , they can use same range really, it's alice and bob, check sockets
const int clPortRange[] = {26192,26262} ;
const int svPortRange[] = {26000,26184} ;

// then redefine with var from config files, hardcoded stuff is not the best idea / if CLSTAT_PORT = 0 - is random ? uPnP alike the func is down there, port can be defined now

// note this defaults on for dedicated servers, off for listen servers
Expand Down Expand Up @@ -1098,7 +1103,7 @@ void NetConn_OpenClientPorts(void)
Crypto_LoadKeys(); // client sockets
SV_UnlockThreadMutex();

port = bound(0, cl_netport.integer, 65535);
port = bound(clPortRange[0], cl_netport.integer, clPortRange[1]);
if (cl_netport.integer != port)
Cvar_SetValueQuick(&cl_netport, port);
if(port == 0)
Expand Down Expand Up @@ -1169,7 +1174,7 @@ void NetConn_OpenServerPorts(int opennetports)
SV_UnlockThreadMutex();

NetConn_UpdateSockets();
port = bound(0, sv_netport.integer, 65535);
port = bound(svPortRange[0], sv_netport.integer, svPortRange[1]);
if (port == 0)
port = SRVMAIN_PORT;
if (sv_netport.integer != port)
Expand Down Expand Up @@ -4159,7 +4164,7 @@ void NetConn_Init(void)
if (((i = Sys_CheckParm("-port")) || (i = Sys_CheckParm("-ipport")) || (i = Sys_CheckParm("-udpport"))) && i + 1 < sys.argc)
{
i = atoi(sys.argv[i + 1]);
if (i >= 0 && i < 65536)
if (i >= svPortRange[0] && i < svPortRange[1])
{
Con_Printf("-port option used, setting port cvar to %i\n", i);
Cvar_SetValueQuick(&sv_netport, i);
Expand Down