#define DPMASTER_PORT 27950
// note this defaults on for dedicated servers, off for listen servers
-cvar_t sv_public = {0, "sv_public", "0", "advertises this server on the master server (so that players can find it in the server browser)"};
+cvar_t sv_public = {0, "sv_public", "0", "1: advertises this server on the master server (so that players can find it in the server browser); 0: allow direct queries only; -1: do not respond to direct queries; -2: do not allow anyone to connect"};
static cvar_t sv_heartbeatperiod = {CVAR_SAVE, "sv_heartbeatperiod", "120", "how often to send heartbeat in seconds (only used if sv_public is 1)"};
static cvar_t sv_masters [] =
{CVAR_SAVE, "sv_master4", "", "user-chosen master server 4"},
{0, "sv_masterextra1", "ghdigital.com", "default master server 1 (admin: LordHavoc)"}, // admin: LordHavoc
{0, "sv_masterextra2", "dpmaster.deathmask.net", "default master server 2 (admin: Willis)"}, // admin: Willis
- {0, "sv_masterextra3", "12.166.196.192", "default master server 3 (admin: Venim)"}, // admin: Venim
- {0, "sv_masterextra4", "excalibur.nvg.ntnu.no", "default master server 4 (admin: tChr)"}, // admin: tChr
+ {0, "sv_masterextra3", "excalibur.nvg.ntnu.no", "default master server 3 (admin: tChr)"}, // admin: tChr
{0, NULL, NULL, NULL}
};
cvar_t net_address = {0, "net_address", "0.0.0.0", "network address to open ports on"};
//cvar_t net_netaddress_ipv6 = {0, "net_address_ipv6", "[0:0:0:0:0:0:0:0]", "network address to open ipv6 ports on"};
+char net_extresponse[NET_EXTRESPONSE_MAX][1400];
+int net_extresponse_count = 0;
+int net_extresponse_last = 0;
+
// ServerList interface
serverlist_mask_t serverlist_andmasks[SERVERLIST_ANDMASKCOUNT];
serverlist_mask_t serverlist_ormasks[SERVERLIST_ORMASKCOUNT];
void ServerList_QueryList(qboolean querydp, qboolean queryqw)
{
- //masterquerytime = realtime;
- masterquerytime = Sys_DoubleTime();
+ masterquerytime = realtime;
masterquerycount = 0;
masterreplycount = 0;
serverquerycount = 0;
{
if (conn->message.cursize > (int)sizeof(conn->sendMessage))
{
- Con_Printf("NetConn_SendUnreliableMessage: reliable message too big (%u > %u)\n", conn->message.cursize, sizeof(conn->sendMessage));
+ Con_Printf("NetConn_SendUnreliableMessage: reliable message too big (%u > %u)\n", conn->message.cursize, (int)sizeof(conn->sendMessage));
conn->message.overflowed = true;
return -1;
}
cls.state = ca_connected;
cls.signon = 0; // need all the signon messages before playing
cls.protocol = initialprotocol;
+ // reset move sequence numbering on this new connection
+ cls.movesequence = 0;
+ cls.servermovesequence = 0;
if (cls.protocol == PROTOCOL_QUAKEWORLD)
Cmd_ForwardStringToServer("new");
if (cls.protocol == PROTOCOL_QUAKE)
// store the data the engine cares about (address and ping)
strlcpy(serverlist_cache[serverlist_cachecount].info.cname, addressstring, sizeof(serverlist_cache[serverlist_cachecount].info.cname));
serverlist_cache[serverlist_cachecount].info.ping = 100000;
- //serverlist_cache[serverlist_cachecount].querytime = realtime;
- serverlist_cache[serverlist_cachecount].querytime = Sys_DoubleTime();
+ serverlist_cache[serverlist_cachecount].querytime = realtime;
// if not in the slist menu we should print the server to console
if (serverlist_consoleoutput)
Con_Printf("querying %s\n", addressstring);
// if this is the first reply from this server, count it as having replied
if (serverlist_cache[n].info.ping == 100000)
serverreplycount++;
- pingtime = (int)((Sys_DoubleTime() - serverlist_cache[n].querytime) * 1000.0 + 0.5);
+ pingtime = (int)((realtime - serverlist_cache[n].querytime) * 1000.0 + 0.5);
pingtime = bound(0, pingtime, 9999);
// update the ping
serverlist_cache[n].info.ping = min(serverlist_cache[n].info.ping, pingtime);
serverlist_querywaittime = realtime + 3;
return true;
}
+ if (!strncmp(string, "extResponse ", 12))
+ {
+ ++net_extresponse_count;
+ if(net_extresponse_count > NET_EXTRESPONSE_MAX)
+ net_extresponse_count = NET_EXTRESPONSE_MAX;
+ net_extresponse_last = (net_extresponse_last + 1) % NET_EXTRESPONSE_MAX;
+ dpsnprintf(net_extresponse[net_extresponse_last], sizeof(net_extresponse[net_extresponse_last]), "'%s' %s", addressstring2, string + 12);
+ return true;
+ }
if (!strncmp(string, "ping", 4))
{
if (developer.integer >= 10)
int n;
serverlist_info_t *info;
- c = data[4];
- data += 5;
- length -= 5;
+ data += 4;
+ length -= 4;
+ SZ_Clear(&net_message);
+ SZ_Write(&net_message, data, length);
+ MSG_BeginReading();
+ c = MSG_ReadByte();
switch (c)
{
case CCREP_ACCEPT:
{
lhnetaddress_t clientportaddress;
clientportaddress = *peeraddress;
- if (length >= 4)
- {
- unsigned int port = (data[0] << 0) | (data[1] << 8) | (data[2] << 16) | (data[3] << 24);
- data += 4;
- length -= 4;
- LHNETADDRESS_SetPort(&clientportaddress, port);
- }
+ LHNETADDRESS_SetPort(&clientportaddress, MSG_ReadLong());
// update the server IP in the userinfo (QW servers expect this, and it is used by the reconnect command)
InfoString_SetValue(cls.userinfo, sizeof(cls.userinfo), "*ip", addressstring2);
M_Update_Return_Reason("Accepted");
if (developer.integer >= 10)
Con_Printf("Datagram_ParseConnectionless: received CCREP_REJECT from %s.\n", addressstring2);
cls.connect_trying = false;
- M_Update_Return_Reason((char *)data);
+ M_Update_Return_Reason((char *)MSG_ReadString());
break;
case CCREP_SERVER_INFO:
if (developer.integer >= 10)
default:
break;
}
+ SZ_Clear(&net_message);
// we may not have liked the packet, but it was a valid control
// packet, so we're done processing this packet now
return true;
NetConn_WriteString(cl_sockets[socket], "\377\377\377\377getinfo", &address);
}
- //entry->querytime = realtime;
- entry->querytime = Sys_DoubleTime();
+ entry->querytime = realtime;
entry->querycounter++;
// if not in the slist menu we should print the server to console
client_t *cl = &svs.clients[i];
if (cl->active)
{
- int nameind, cleanind;
+ int nameind, cleanind, pingvalue;
char curchar;
char cleanname [sizeof(cl->name)];
}
} while (curchar != '\0');
+ pingvalue = (int)(cl->ping * 1000.0f);
+ if(cl->netconnection)
+ pingvalue = bound(1, pingvalue, 9999);
+ else
+ pingvalue = 0;
length = dpsnprintf(ptr, left, "%d %d \"%s\"\n",
cl->frags,
- (int)(cl->ping * 1000.0f),
+ pingvalue,
cleanname);
if(length < 0)
return false;
Com_HexDumpToConsole(data, length);
}
- if (length >= 12 && !memcmp(string, "getchallenge", 12))
+ if (length >= 12 && !memcmp(string, "getchallenge", 12) && sv_public.integer > -2)
{
for (i = 0, best = 0, besttime = realtime;i < MAX_CHALLENGES;i++)
{
NetConn_WriteString(mysocket, va("\377\377\377\377challenge %s", challenge[i].string), peeraddress);
return true;
}
- if (length > 8 && !memcmp(string, "connect\\", 8))
+ if (length > 8 && !memcmp(string, "connect\\", 8) && sv_public.integer > -2)
{
string += 7;
length -= 7;
return true;
}
- if (length >= 7 && !memcmp(string, "getinfo", 7))
+ if (length >= 7 && !memcmp(string, "getinfo", 7) && sv_public.integer > -1)
{
const char *challenge = NULL;
}
return true;
}
- if (length >= 9 && !memcmp(string, "getstatus", 9))
+ if (length >= 9 && !memcmp(string, "getstatus", 9) && sv_public.integer > -1)
{
const char *challenge = NULL;
// Quake packet flood Denial Of Service attacks)
if (length >= 5 && (i = BigLong(*((int *)data))) && (i & (~NETFLAG_LENGTH_MASK)) == (int)NETFLAG_CTL && (i & NETFLAG_LENGTH_MASK) == length && (sv.protocol == PROTOCOL_QUAKE || sv.protocol == PROTOCOL_QUAKEDP || sv.protocol == PROTOCOL_NEHAHRAMOVIE || sv.protocol == PROTOCOL_DARKPLACES1 || sv.protocol == PROTOCOL_DARKPLACES2 || sv.protocol == PROTOCOL_DARKPLACES3))
{
- int c = data[4];
- data += 5;
- length -= 5;
+ int c;
+ int protocolnumber;
+ const char *protocolname;
+ data += 4;
+ length -= 4;
+ SZ_Clear(&net_message);
+ SZ_Write(&net_message, data, length);
+ MSG_BeginReading();
+ c = MSG_ReadByte();
switch (c)
{
case CCREQ_CONNECT:
if (developer.integer >= 10)
Con_Printf("Datagram_ParseConnectionless: received CCREQ_CONNECT from %s.\n", addressstring2);
- if (length < (int)strlen("QUAKE") + 1 + 1)
+ if(sv_public.integer <= -2)
break;
- if (memcmp(data, "QUAKE", strlen("QUAKE") + 1) != 0 || (int)data[strlen("QUAKE") + 1] != NET_PROTOCOL_VERSION)
+ protocolname = MSG_ReadString();
+ protocolnumber = MSG_ReadByte();
+ if (strcmp(protocolname, "QUAKE") || protocolnumber != NET_PROTOCOL_VERSION)
{
if (developer.integer >= 10)
Con_Printf("Datagram_ParseConnectionless: sending CCREP_REJECT \"Incompatible version.\" to %s.\n", addressstring2);
case CCREQ_SERVER_INFO:
if (developer.integer >= 10)
Con_Printf("Datagram_ParseConnectionless: received CCREQ_SERVER_INFO from %s.\n", addressstring2);
+ if(sv_public.integer <= -1)
+ break;
if (sv.active && !strcmp(MSG_ReadString(), "QUAKE"))
{
int numclients;
case CCREQ_PLAYER_INFO:
if (developer.integer >= 10)
Con_Printf("Datagram_ParseConnectionless: received CCREQ_PLAYER_INFO from %s.\n", addressstring2);
+ if(sv_public.integer <= -1)
+ break;
if (sv.active)
{
int playerNumber, activeNumber, clientNumber;
MSG_WriteByte(&net_message, playerNumber);
MSG_WriteString(&net_message, client->name);
MSG_WriteLong(&net_message, client->colors);
- MSG_WriteLong(&net_message, (int)client->edict->fields.server->frags);
+ MSG_WriteLong(&net_message, client->frags);
MSG_WriteLong(&net_message, (int)(realtime - client->connecttime));
MSG_WriteString(&net_message, client->netconnection ? client->netconnection->address : "botclient");
*((int *)net_message.data) = BigLong(NETFLAG_CTL | (net_message.cursize & NETFLAG_LENGTH_MASK));
case CCREQ_RULE_INFO:
if (developer.integer >= 10)
Con_Printf("Datagram_ParseConnectionless: received CCREQ_RULE_INFO from %s.\n", addressstring2);
+ if(sv_public.integer <= -1)
+ break;
if (sv.active)
{
char *prevCvarName;
default:
break;
}
+ SZ_Clear(&net_message);
// we may not have liked the packet, but it was a valid control
// packet, so we're done processing this packet now
return true;
}
}
+void NetConn_SleepMicroseconds(int microseconds)
+{
+ LHNET_SleepUntilPacket_Microseconds(microseconds);
+}
+
void NetConn_QueryMasters(qboolean querydp, qboolean queryqw)
{
int i;
// make advertising optional and don't advertise singleplayer games, and
// only send a heartbeat as often as the admin wants
- if (sv.active && sv_public.integer && svs.maxclients >= 2 && (priority > 1 || realtime > nextheartbeattime))
+ if (sv.active && sv_public.integer > 0 && svs.maxclients >= 2 && (priority > 1 || realtime > nextheartbeattime))
{
nextheartbeattime = realtime + sv_heartbeatperiod.value;
for (masternum = 0;sv_masters[masternum].name;masternum++)
{
if (LHNETADDRESS_FromString(&tempaddress, com_argv[i + 1], 0) == 1)
{
- Con_Printf("-ip option used, setting net_address to \"%s\"\n");
+ Con_Printf("-ip option used, setting net_address to \"%s\"\n", com_argv[i + 1]);
Cvar_SetQuick(&net_address, com_argv[i + 1]);
}
else