-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathredis.js
854 lines (666 loc) · 21.5 KB
/
redis.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
const bluebird = require("bluebird");
const redis = bluebird.promisifyAll(require("redis"));
const shortid = require("shortid");
const sha1 = require("sha1");
const models = require("./db/models");
const constants = require("./constants");
const Random = require("./Random");
const client = redis.createClient();
client.on("error", e => { throw e });
client.select(process.env.REDIS_DB || 0);
async function getUserDbId(userId) {
const key = `user:${userId}:dbId`;
const exists = await client.existsAsync(key);
if (!exists) {
const user = await models.User.findOne({ id: userId })
.select("_id");
if (user) {
client.set(key, user._id);
client.expire(key, 3600);
}
return user._id;
}
else
return await client.get(key);
}
async function cacheSetups(userId) {
const key = `user:${userId}:favSetups`;
const exists = await client.existsAsync(key);
if (!exists) {
var user = await models.User.findOne({ id: userId, deleted: false })
.select("favSetups")
.populate({
path: "favSetups",
select: "id"
});
if (!user)
return;
var setups = user.favSetups.map(setup => setup.id);
for (let setup of setups)
client.sadd(key, setup);
client.expire(key, 3600);
}
}
async function getFavSetups(userId) {
await cacheSetups(userId);
const key = `user:${userId}:favSetups`;
return await client.smembersAsync(key);
}
async function getFavSetupsHashtable(userId) {
var setups = {};
const setupList = await getFavSetups(userId);
for (let setup of setupList)
setups[setup] = true;
return setups;
}
async function updateFavSetup(userId, setupId) {
await cacheSetups(userId);
const key = `user:${userId}:favSetups`;
const isMember = await client.sismemberAsync(key, setupId);
var setup = await models.Setup.findOne({ id: setupId });
if (setup && isMember) {
var user = await models.User.findOne({ id: userId, deleted: false })
.select("_id");
if (!user)
return "0";
client.srem(key, setupId);
models.User.updateOne({ id: userId }, { $pull: { favSetups: setup._id } }).exec();
models.Setup.updateOne({ id: setupId }, { $inc: { favorites: -1 } }).exec();
return "-1";
}
else if (setup) {
var favSetupCount = await client.scardAsync(key);
if (favSetupCount > constants.maxFavSetups)
return "-2";
var user = await models.User.findOne({ id: userId, deleted: false })
.select("_id");
if (!user)
return "0";
client.sadd(key, setupId);
client.expire(key, 3600);
models.User.updateOne({ id: userId }, { $push: { favSetups: setup._id } }).exec();
models.Setup.updateOne({ id: setupId }, { $inc: { favorites: 1 } }).exec();
return "1";
}
else
return "0";
}
async function userCached(userId) {
return client.existsAsync(`user:${userId}:info:id`);
}
async function cacheUserInfo(userId, reset) {
var exists = await userCached(userId);
if (!exists || reset) {
var user = await models.User.findOne({ id: userId, deleted: false })
.select("id name avatar blockedUsers settings itemsOwned nameChanged -_id");
if (!user)
return false;
user = user.toJSON();
await client.setAsync(`user:${userId}:info:id`, userId);
await client.setAsync(`user:${userId}:info:name`, user.name);
await client.setAsync(`user:${userId}:info:avatar`, user.avatar);
await client.setAsync(`user:${userId}:info:nameChanged`, user.nameChanged);
await client.setAsync(`user:${userId}:info:blockedUsers`, JSON.stringify(user.blockedUsers || []));
await client.setAsync(`user:${userId}:info:settings`, JSON.stringify(user.settings));
await client.setAsync(`user:${userId}:info:itemsOwned`, JSON.stringify(user.itemsOwned));
}
client.expire(`user:${userId}:info:id`, 3600);
client.expire(`user:${userId}:info:name`, 3600);
client.expire(`user:${userId}:info:avatar`, 3600);
client.expire(`user:${userId}:info:nameChanged`, 3600);
client.expire(`user:${userId}:info:blockedUsers`, 3600);
client.expire(`user:${userId}:info:settings`, 3600);
client.expire(`user:${userId}:info:itemsOwned`, 3600);
return true;
}
async function deleteUserInfo(userId) {
await client.delAsync(`user:${userId}:info:id`);
await client.delAsync(`user:${userId}:info:name`);
await client.delAsync(`user:${userId}:info:avatar`);
await client.delAsync(`user:${userId}:info:nameChanged`);
await client.delAsync(`user:${userId}:info:status`);
await client.delAsync(`user:${userId}:info:blockedUsers`);
await client.delAsync(`user:${userId}:info:settings`);
await client.delAsync(`user:${userId}:info:itemsOwned`);
}
async function getUserInfo(userId) {
var exists = await cacheUserInfo(userId);
if (!exists)
return;
var info = {};
info.id = await client.getAsync(`user:${userId}:info:id`);
info.name = await client.getAsync(`user:${userId}:info:name`);
info.avatar = await client.getAsync(`user:${userId}:info:avatar`) == "true";
info.nameChanged = await client.getAsync(`user:${userId}:info:nameChanged`) == "true";
info.status = await client.getAsync(`user:${userId}:info:status`);
info.blockedUsers = JSON.parse(await client.getAsync(`user:${userId}:info:blockedUsers`));
info.settings = JSON.parse(await client.getAsync(`user:${userId}:info:settings`));
info.itemsOwned = JSON.parse(await client.getAsync(`user:${userId}:info:itemsOwned`));
return info;
}
async function getBasicUserInfo(userId) {
var exists = await cacheUserInfo(userId);
if (!exists)
return;
var info = {};
info.id = await client.getAsync(`user:${userId}:info:id`);
info.name = await client.getAsync(`user:${userId}:info:name`);
info.avatar = await client.getAsync(`user:${userId}:info:avatar`) == "true";
info.status = await client.getAsync(`user:${userId}:info:status`);
return info;
}
async function getUserName(userId) {
var exists = await cacheUserInfo(userId);
if (!exists)
return;
return await client.getAsync(`user:${userId}:info:name`);
}
async function getUserStatus(userId) {
var exists = await cacheUserInfo(userId);
if (!exists)
return;
var status = await client.getAsync(`user:${userId}:info:status`);
return status || "offline";
}
async function getBlockedUsers(userId) {
var exists = await cacheUserInfo(userId);
if (!exists)
return;
var blockedUsers = await client.getAsync(`user:${userId}:info:blockedUsers`);
return JSON.parse(blockedUsers || "[]");
}
async function getUserSettings(userId) {
var exists = await cacheUserInfo(userId);
if (!exists)
return;
var settings = await client.getAsync(`user:${userId}:info:settings`);
return JSON.parse(settings || "{}");
}
async function getUserItemsOwned(userId) {
var exists = await cacheUserInfo(userId);
if (!exists)
return;
var settings = await client.getAsync(`user:${userId}:info:itemsOwned`);
return JSON.parse(settings || "{}");
}
async function createAuthToken(userId) {
const token = sha1(Random.randFloat());
const key = `token:${token}`;
await client.setAsync(key, userId);
client.expire(key, 5);
return token;
}
async function authenticateToken(token) {
const key = `token:${token}`;
const userId = await client.getAsync(key);
return userId;
}
async function gameExists(gameId) {
return (await client.sismemberAsync("games", gameId)) != 0;
}
async function inGame(userId) {
const gameId = await client.getAsync(`user:${userId}:game`);
return gameId || false;
}
async function hostingScheduled(userId) {
const gameId = await client.getAsync(`user:${userId}:scheduled`);
return gameId || false;
}
async function getCreatingGame(userId) {
const val = await client.getAsync(`creatingGame:${userId}`);
return val != null && val != 0;
}
async function getSetCreatingGame(userId) {
const key = `creatingGame:${userId}`;
const newVal = await client.incrAsync(key);
client.expire(key, Number(process.env.GAME_CREATION_TIMEOUT) / 1000 + 1);
return newVal - 1 != 0;
}
async function unsetCreatingGame(userId) {
const key = `creatingGame:${userId}`;
const newVal = await client.decrAsync(key);
if (newVal <= 0)
await client.delAsync(key);
}
async function setHostingScheduled(userId, gameId) {
if (hostingScheduled(userId))
return;
await client.setAsync(`user:${userId}:scheduled`, gameId);
}
async function clearHostingScheduled(userId) {
await client.delAsync(`user:${userId}:scheduled`);
}
async function getGameInfo(gameId, idsOnly) {
if (!(await gameExists(gameId)))
return;
var info = {};
info.id = gameId;
info.type = await client.getAsync(`game:${gameId}:type`);
info.port = await client.getAsync(`game:${gameId}:port`);
info.status = await client.getAsync(`game:${gameId}:status`);
info.hostId = await client.getAsync(`game:${gameId}:hostId`);
info.lobby = await client.getAsync(`game:${gameId}:lobby`);
info.settings = JSON.parse(await client.getAsync(`game:${gameId}:settings`) || "{}");
info.createTime = Number(await client.getAsync(`game:${gameId}:createTime`));
info.startTime = Number(await client.getAsync(`game:${gameId}:startTime`));
info.webhookPublished = await client.existsAsync(`game:${gameId}:webhookPublished`);
info.setup = info.settings.setup;
if (!info.settings.scheduled || info.settings.scheduled < Date.now())
info.players = (await client.smembersAsync(`game:${gameId}:players`)) || [];
else
info.players = await getGameReservations(gameId);
if (!idsOnly) {
var newPlayers = [];
for (let playerId of info.players) {
let userInfo = await getBasicUserInfo(playerId);
if (userInfo)
newPlayers.push(userInfo);
else {
newPlayers.push({
name: "[Guest]",
id: "",
avatar: false
});
}
}
info.players = newPlayers;
}
return info;
}
async function getPlayerGameInfo(playerId) {
const gameId = await inGame(playerId);
return await getGameInfo(gameId);
}
async function getGamePort(gameId) {
return await client.getAsync(`game:${gameId}:port`);
}
async function getGameType(gameId) {
return await client.getAsync(`game:${gameId}:type`);
}
async function getGameReservations(gameId, start, stop) {
start = start != null ? start : 0;
stop = stop != null ? stop : -1;
return await client.zrangeAsync(`game:${gameId}:reservations`, start, stop);
}
async function setGameStatus(gameId, status) {
await client.setAsync(`game:${gameId}:status`, status);
if (status == "In Progress")
await client.setAsync(`game:${gameId}:startTime`, Date.now());
}
async function getOpenGames(gameType) {
var allGames = await client.smembersAsync("games");
var games = [];
for (let gameId of allGames) {
let game = await getGameInfo(gameId);
if (
(!gameType || game.type == gameType) &&
game.status == "Open"
) {
games.push(game);
}
}
return games;
}
async function getOpenPublicGames(gameType) {
var allGames = await client.smembersAsync("games");
var games = [];
for (let gameId of allGames) {
let game = await getGameInfo(gameId);
if (
(!gameType || game.type == gameType) &&
game.status == "Open" &&
!game.settings.private
) {
games.push(game);
}
}
return games;
}
async function getInProgressGames(gameType) {
var allGames = await client.smembersAsync("games");
var games = [];
for (let gameId of allGames) {
let game = await getGameInfo(gameId);
if (
(!gameType || game.type == gameType) &&
game.status == "In Progress"
) {
games.push(game);
}
}
return games;
}
async function getInProgressPublicGames(gameType) {
var allGames = await client.smembersAsync("games");
var games = [];
for (let gameId of allGames) {
let game = await getGameInfo(gameId);
if (
(!gameType || game.type == gameType) &&
game.status == "In Progress" &&
!game.settings.private
) {
games.push(game);
}
}
return games;
}
async function getAllGames(gameType) {
var allGames = await client.smembersAsync("games");
var games = [];
for (let gameId of allGames) {
let game = await getGameInfo(gameId);
if ((!gameType || game.type == gameType))
games.push(game);
}
return games;
}
async function createGame(gameId, info) {
for (let key in info) {
let val = info[key];
if (val == null)
continue;
if (typeof val == "object")
val = JSON.stringify(val);
await client.setAsync(`game:${gameId}:${key}`, val);
}
await client.saddAsync("games", gameId);
if (info.settings.scheduled) {
await client.saddAsync("scheduledGames", gameId);
await client.zaddAsync(`game:${gameId}:reservations`, Date.now(), info.hostId);
}
}
async function joinGame(userId, gameId) {
const currentGame = await client.getAsync(`user:${userId}:game`);
if (currentGame == gameId)
return;
else if (currentGame != null)
await leaveGame(userId);
await client.saddAsync(`game:${gameId}:players`, userId);
await client.setAsync(`user:${userId}:game`, gameId);
// var ban = new models.Ban({
// id: shortid.generate(),
// userId,
// modId: null,
// expires: 0,
// permissions: ["createThread", "postReply", "editPost", "publicChat", "privateChat"],
// type: "gameAuto",
// auto: true
// });
// await ban.save();
// await cacheUserPermissions(userId);
}
async function leaveGame(userId) {
const gameId = await client.getAsync(`user:${userId}:game`);
if (!gameId)
return;
await client.sremAsync(`game:${gameId}:players`, userId);
await client.delAsync(`user:${userId}:game`);
await models.Ban.deleteOne({ userId, type: "gameAuto" }).exec();
await cacheUserPermissions(userId);
}
async function reserveGame(userId, gameId) {
var game = await getGameInfo(gameId);
if (!game || !game.settings.scheduled)
return;
var key = `game:${gameId}:reservations`;
var numReservations = await client.zcardAsync(key);
await client.zaddAsync(key, Date.now(), userId);
return numReservations < game.settings.total;
}
async function unreserveGame(userId, gameId) {
if (!(await gameExists(gameId)))
return;
await client.zremAsync(`game:${gameId}:reservations`, userId);
}
async function deleteGame(gameId, game) {
if (!(await gameExists(gameId)))
return;
game = game || await getGameInfo(gameId, true);
for (let playerId of game.players)
await leaveGame(playerId);
if (game.settings.scheduled) {
await client.sremAsync("scheduledGames", gameId);
if ((await client.getAsync(`user:${game.hostId}:scheduled`)) == game.id)
await client.delAsync(`user:${game.hostId}:scheduled`);
}
await client.sremAsync("games", gameId);
await client.delAsync(`game:${gameId}:id`);
await client.delAsync(`game:${gameId}:type`);
await client.delAsync(`game:${gameId}:port`);
await client.delAsync(`game:${gameId}:status`);
await client.delAsync(`game:${gameId}:hostId`);
await client.delAsync(`game:${gameId}:lobby`);
await client.delAsync(`game:${gameId}:players`);
await client.delAsync(`game:${gameId}:settings`);
await client.delAsync(`game:${gameId}:createTime`);
await client.delAsync(`game:${gameId}:startTime`);
await client.delAsync(`game:${gameId}:webhookPublished`);
}
async function breakGame(gameId) {
if (!(await gameExists(gameId)))
return;
var game = await getGameInfo(gameId, true);
await deleteGame(gameId);
var setup = await models.Setup.findOne({ id: game.settings.setup });
if (!setup)
return;
var setupId = setup._id;
var users = [];
for (let userId of game.players) {
let user = await models.User.findOne({ id: userId })
.select("_id");
if (user)
users.push(user._id);
}
game = new models.Game({
id: game.id,
type: game.type,
setup: setupId,
users: users,
startTime: game.startTime,
endTime: Date.now(),
ranked: game.settings.ranked,
spectating: game.settings.spectating,
stateLengths: game.settings.stateLengths,
gameTypeOptions: JSON.stringify(game.settings.gameTypeOptions),
broken: true
});
await game.save();
}
async function gameWebhookPublished(gameId) {
await client.setAsync(`game:${gameId}:webhookPublished`, "1");
}
async function registerGameServer(port) {
await client.saddAsync("gameServers", port);
}
async function removeGameServer(port) {
await client.sremAsync("gameServers", port)
}
async function getNextGameServerPort() {
var ports = await client.smembersAsync("gameServers");
var index = await client.incrAsync("gameServerIndex");
index = Math.abs(index % ports.length);
return Number(ports[index]);
}
async function getAllGameServerPorts() {
var ports = await client.smembersAsync("gameServers");
return ports.map(port => Number(port));
}
async function getOnlineUsers(limit) {
var limit = limit || Infinity;
var users = await client.zrangebyscoreAsync("onlineUsers", Date.now() - constants.userOnlineTTL, Infinity);
return users.slice(0, limit);
}
async function getOnlineUsersInfo(limit) {
var userIds = await getOnlineUsers(limit);
var users = [];
for (let userId of userIds)
users.push(await getBasicUserInfo(userId));
return users;
}
async function updateUserOnline(userId) {
await client.zaddAsync("onlineUsers", Date.now(), userId);
await client.setAsync(`user:${userId}:info:status`, "online");
client.expire(`user:${userId}:info:status`, constants.userOnlineTTL / 1000);
}
async function setUserOffline(userId) {
await client.zremAsync("onlineUsers", userId);
}
async function removeStaleUsers() {
await client.zremrangebyscoreAsync("onlineUsers", 0, Date.now() - constants.userOnlineTTL);
}
async function getAllLastActive() {
var dates = {};
var users = await client.zrangeAsync("onlineUsers", 0, -1);
for (let user of users)
dates[user] = await client.zscoreAsync("onlineUsers", user);
return dates;
}
async function cacheUserPermissions(userId) {
const permKey = `user:${userId}:perms`;
const rankKey = `user:${userId}:rank`;
var user = await models.User.findOne({ id: userId, deleted: false })
.select("rank permissions");
if (!user)
return { perms: {}, rank: 0, noUser: true };
user = user.toJSON();
var inGroups = await models.InGroup.find({ user: user._id })
.populate("group", "rank permissions");
var groups = inGroups.map(group => group.toJSON().group);
var bans = await models.Ban.find({ userId: userId })
.select("permissions");
var perms = {};
var maxRank = user.rank || 0;
for (let perm of constants.defaultPerms)
perms[perm] = true;
for (let perm of user.permissions)
perms[perm] = true;
for (let group of groups) {
for (let perm of group.permissions)
perms[perm] = true;
if (group.rank > maxRank)
maxRank = group.rank;
}
for (let ban of bans)
for (let perm of ban.permissions)
delete perms[perm];
client.set(permKey, JSON.stringify(perms));
client.expire(permKey, 3600);
client.set(rankKey, maxRank);
client.expire(rankKey, 3600);
return { perms, rank: maxRank };
}
async function getUserPermissions(userId) {
const permKey = `user:${userId}:perms`;
const rankKey = `user:${userId}:rank`;
const exists = await client.existsAsync(permKey) && await client.existsAsync(rankKey);
if (!exists)
return await cacheUserPermissions(userId);
else {
const perms = await client.getAsync(permKey);
const rank = await client.getAsync(rankKey);
client.expire(permKey, 3600);
client.expire(rankKey, 3600);
return {
perms: JSON.parse(perms),
rank: Number(rank)
};
}
}
async function getUserRank(userId) {
var perms = await getUserPermissions(userId);
return !perms.noUser ? perms.rank : null;
}
async function hasPermissions(userId, perms, rank) {
if (!userId)
return false;
const permInfo = await getUserPermissions(userId);
if (permInfo.rank < rank)
return false;
for (let perm of perms)
if (!permInfo.perms[perm])
return false;
return true;
}
async function hasPermission(userId, perm, rank) {
return await hasPermissions(userId, [perm], rank);
}
async function clearPermissionCache() {
var keys = await client.keysAsync("user:*:perms");
for (let key of keys)
await client.delAsync(key);
}
async function rateLimit(userId, type) {
var key = `user:${userId}:rateLimit:${type}`;
var exists = await client.existsAsync(key);
if (!exists) {
await client.setAsync(key, 1);
await client.pexpireAsync(key, constants.rateLimits[type] || 0);
}
return !exists;
}
module.exports = {
client,
getUserDbId,
cacheSetups,
getFavSetups,
getFavSetupsHashtable,
updateFavSetup,
userCached,
cacheUserInfo,
deleteUserInfo,
getUserInfo,
getBasicUserInfo,
getUserName,
getUserStatus,
getBlockedUsers,
getUserSettings,
getUserItemsOwned,
createAuthToken,
authenticateToken,
gameExists,
inGame,
hostingScheduled,
getCreatingGame,
getSetCreatingGame,
unsetCreatingGame,
setHostingScheduled,
clearHostingScheduled,
getGameInfo,
getPlayerGameInfo,
getGamePort,
getGameType,
getGameReservations,
setGameStatus,
getOpenGames,
getOpenPublicGames,
getInProgressGames,
getInProgressPublicGames,
getAllGames,
createGame,
joinGame,
leaveGame,
reserveGame,
unreserveGame,
deleteGame,
breakGame,
gameWebhookPublished,
registerGameServer,
removeGameServer,
getNextGameServerPort,
getAllGameServerPorts,
getOnlineUsers,
getOnlineUsersInfo,
updateUserOnline,
setUserOffline,
removeStaleUsers,
getAllLastActive,
cacheUserPermissions,
getUserPermissions,
getUserRank,
hasPermissions,
hasPermission,
clearPermissionCache,
rateLimit,
};