add server-side player vita database

The server keeps track of every player ID that ever connected successfully.
This database stores the last names and IPs used by the player and the
last countries the connections came from. Some stats are counted, like
"time connected" and "total tks". Most importantly, the database stores
rights (like admin) and restrictions (like ban). All rights and
restrictions are kept as dates (or timecodes), so, for example, if your
ban date is in the future, you are banned - and if it's in the past, you
can play. The collected stats are meant to help server owners at managing
players - especially, if they want to give someone admin rights.

The database is periodically saved to a file and read from that file on
startup. The default file is config/servervita.cfg and one backup is kept
in config/servervita_bak.cfg. During server start, if the regular file
can't be loaded, the backup is tried instead.

While the server is running, it checks periodically for a file named
config/servervita_update.cfg, and if the file exists, it is renamed to
a backup filename including a timecode and read and merged into the
database. The automatic rename makes sure, that a file is only read once.
Using such updates, a server owner can easily give several people admin
rights or for example, add clan tags for a whole list of IDs. (Yes, the
database also stores a clan tag for every ID...)

The database also stores two short comments for every ID. One can only be
read by server admins, but the other one is public. The public reason, for
example, can state a reason for a ban.

One database record takes up 264 bytes of RAM. During autosave, accounts,
that have not been used for a specified time (default 12 months), will
not be written. After a server restart, those old records will be gone.

Currently, there is no process in place, to also clean up old records
from RAM. Maybe, that'll be added later...
This commit is contained in:
ac-stef
2017-06-27 15:15:23 +02:00
parent 035d7caf2f
commit 0b656d2380
13 changed files with 344 additions and 45 deletions
+24 -1
View File
@@ -223,6 +223,27 @@ struct medals
}
};
#define VITANAMEHISTLEN 4
#define VITAIPHISTLEN 4
#define VITACCHISTLEN 4
#define VITACOMMENTLEN 31
#define VITACLANLEN 7
struct vita_s
{
char namehist[VITANAMEHISTLEN][MAXNAMELEN + 1];
enet_uint32 iphist[VITAIPHISTLEN];
char privatecomment[VITACOMMENTLEN + 1], publiccomment[VITACOMMENTLEN + 1]; // private comments can be seen by admins and owners only, public comments can be seen by everyone
char clan[VITACLANLEN + 1];
char cchist[VITACCHISTLEN * 2];
int vs[VS_NUM];
void addname(const char *name);
void addip(enet_uint32 ip);
void addcc(const char *cc);
};
struct vitakey_s { const vita_s *v; const uchar32 *k; };
struct client // server side version of "dynent" type
{
int type;
@@ -232,8 +253,9 @@ struct client // server side version of "dynent" type
enet_uint32 ip, ip_censored;
int connectclock;
char country[4];
uchar pubkey[32];
uchar32 pubkey;
char pubkeyhex[68];
vita_s *vita;
string servinforesponse;
string name;
int team;
@@ -334,6 +356,7 @@ struct client // server side version of "dynent" type
name[0] = pwd[0] = demoflags = 0;
ip = ip_censored = 0;
pubkeyhex[0] = '\0';
vita = NULL;
bottomRTT = ping = 9999;
team = TEAM_SPECT;
state.state = CS_SPECTATE;