Commit Graph

260 Commits

Author SHA1 Message Date
Guangcong Luo
c42a2f2aa7 Use fewer trys
I read something that says that V8 doesn't optimize any code inside
try-blocks. I hope this means that this change will lead to better-
performing code, but I suspect the difference will be relatively
small.
2014-04-10 19:04:24 -04:00
Guangcong Luo
99e885713e Better messages for login server errors 2014-03-31 00:32:53 -04:00
Guangcong Luo
f5d10cd85e Fix crash in unlock 2014-03-27 19:17:35 -04:00
Guangcong Luo
d4467c4636 Don't accept messages with too many lines 2014-03-23 05:08:26 -04:00
Guangcong Luo
c107cc68bd Make throttle limit a const instead of hardcoded
Also make the limit 6 messages instead of 8
2014-03-22 14:29:16 -04:00
Guangcong Luo
bb5865446b Bans and locks work by username too
Now, when a user logs into a registered username that was previously
locked/banned, that user is also locked/banned.

The main reason this matters is because users who log in under an
autoconfirmed username are permanently autoconfirmed, even if they
log out and in to a new username. So when they're banned, they can
switch IP and regain autoconfirmed status. This change bans the
username that was autoconfirmed as well, so attempting to use it
to regain autoconfirmed status will result in an automatic re-ban.
2014-03-18 08:13:17 -04:00
asgdf
5bb35f5bd7 increase throttle delay to 600 2014-03-18 08:13:09 -04:00
Guangcong Luo
e2b57563a6 Optimized team sending
Teams are now sent using our new packTeam/unpackTeam code, rather
than JSON. This compresses teams from an average of 2000 bytes to
an average of 500 bytes.
2014-03-05 23:30:16 -05:00
Guangcong Luo
d5b528dbcc Optimize bandwidth usage of updateChallenges 2014-03-05 23:27:10 -05:00
Guangcong Luo
a797c60173 Don't inherit locks from unregistered users 2014-02-15 17:20:47 -05:00
Tyler Stark
afb3dc0c09 First pass at code quality: adding semicolons. 2014-02-09 20:35:42 -06:00
Guangcong Luo
974eff0d44 Don't ladder search if we can't retrieve MMR 2014-02-02 20:21:54 -05:00
Guangcong Luo
1b0b3ec63b Optimize team validator
The main process no longer does any JSON parsing/stringifying of
teams. The communication protocol with validator processes has
been changed from JSON to a string protocol delimited by pipes.

A variety of more minor optimizations have also been done.
2014-01-23 21:35:26 -08:00
Guangcong Luo
f1f88aeefa user.autoconfirmed tracks autoconfirmed userid 2014-01-23 09:30:38 -08:00
Guangcong Luo
b6a117bfc6 Optimize /whois
Warning: Some hardcoding used
2014-01-18 10:54:26 -08:00
Guangcong Luo
b19119cf9c MMR is now Elo 2014-01-14 22:59:22 -08:00
小太
839fdb005b Multiprocess Team Validator 2014-01-13 15:35:10 +11:00
Guangcong Luo
2cf7f32970 Revert "Make team checking asynchronous"
This reverts commit a8d63fd791.

Conflicts:

	config/commands.js
2014-01-12 13:49:03 -08:00
小太
a8d63fd791 Make team checking asynchronous 2014-01-12 16:55:19 +11:00
Guangcong Luo
a39fdd6006 Split off team validation to team-validator.js
This is the first step in a refactor to split team validation into
its own process.
2014-01-09 17:35:19 -08:00
Guangcong Luo
1afd06e1fa Narrow down verify mismatch errors 2013-12-26 23:04:45 -08:00
Joimer
cc31a6c31b Remove crash from emergency logging
The code hasn't been used for a while and changes on the file had made
it crash.
2013-12-17 12:38:27 +01:00
Guangcong Luo
80bf389570 API for spawning/killing socket worker processes 2013-11-19 01:31:03 -08:00
Guangcong Luo
61cf7d1e8e Fix miscellaneous bugs in load balancer 2013-11-13 21:13:03 -08:00
Guangcong Luo
dc70892f14 Use channels for broadcasting
Now that we're using proxy processes, this heavily optimizes the
communication between the main process and the proxy processes
by sending broadcasted messages once, instead of once per user.
2013-11-13 19:55:26 -08:00
Guangcong Luo
466359023f Load balance connections to proxy processes
Instead of handling all connections in the master process, we now
use Node's cluster module to push them to worker processes. These
worker processes are pretty lightweight and do nothing but proxy
connections so far.
2013-11-13 18:44:44 -08:00
Guangcong Luo
4ad19bb333 Refactor: Rename some permissions functions
In particular, Development Staff has been renamed to System Operator.
2013-09-22 16:42:52 -07:00
Guangcong Luo
3fdd6c3e97 Fix crash with autoconfirmed setting 2013-09-22 00:11:19 -07:00
Guangcong Luo
47723b2e11 Support new autoconfirmed user status
Autoconfirmed users are users whose accounts existed for more than one
week and who have played at least one rated battle.
2013-09-21 21:17:45 -07:00
Guangcong Luo
6a2add8898 ipbans.txt now supports CIDR format
This introduces a new file cidr.js, which handles matching CIDR IP
blocks. It replaces our dependency on node-ip.

The old proxy IP system is also moved to cidr.js.
2013-09-21 14:15:11 -07:00
Guangcong Luo
de7d5310e2 IPs listed on Spamhaus's SBL are now locked rather than banned. 2013-09-14 09:12:33 -07:00
Joimer
ff4d3ccb5d Implement PM blocking for regular users and admins
The PM blocking tool is available for all regular users and admins.
Regular users can use it as a global ignore rule, allowing them to
avoid harassers that are able to ban, mute, or ignore evade and PM
spam them.
Administrators are often bombarded with PMs and often they don't have
the time nor the means to entertain them, so this tool allows them
to work or just use the simulator in peace. Generally, administrators
are not required to be available to all PMs as the rest of the members
of staff, whom are not allowed to use this tool, are.
2013-09-05 15:17:55 +02:00
Guangcong Luo
ae62e9e737 Update ResourceMonitor to control bandwidth 2013-09-01 02:37:35 -07:00
Cathy J. Fitzpatrick
95c9a504ad Security: Fix privilege escalation with crafted /trn
This fixes a bug that allows any user with `forcerenameto` permission
(which by default includes the entire ~ group) to escalate to console
permissions, which is much more powerful.

Suppose user "Jasmine" has the ~ group, but not console permissions and
suppose user "Zarel" is on the console list on config.js. Jasmine could
escalate to console permissions with these commands:

    /frt Jasmine, Zarel
    /trn Zarel

The use of the /trn command sets her User object's `forceRenamed`
property to false, allowing the console userid check to pass.

This bug meant that the attack surface area to completely take over the
sim server was as large as the ~ group, not just the list of console
users. This commit fixes the bug by correctly propagating the
`forceRenamed` property when using /trn.
2013-08-28 01:16:14 -06:00
Joimer
b72edfe967 Improve room bans
Implemented some changes from #306.
The bans are checked now on User.prototype.joinRoom.
Redirect command now does not override room bans.
Commands now control if the room is designed for room bans.
Several small style improvements.
2013-08-20 09:36:16 +02:00
Guangcong Luo
6ffb81dece Yet another change to the MMR formula
It's now (2*rpr+r)/3
2013-08-18 14:17:51 -07:00
Guangcong Luo
a5cc67bb90 Some tweaks to matchmaking:
- Harsher initial matchmaking range
- MMR is now projected rating (rather than the average of projected
  and actual rating)
2013-08-13 22:47:54 -07:00
Guangcong Luo
a153f2f51e Overhaul room auth system
Now, most rooms inherit auth from global auth. In other words, if
you're a global driver but a room leader, you'll be a leader
in that room, but if you're a global driver but have no room
auth, you'll be a room driver.

The exception is private rooms with private auth: These don't
inherit, and in general are not bound by chat rules, so /warn
doesn't work in these rooms at all.
2013-08-02 23:52:02 -07:00
Joimer
051ac52d27 Refactor rank check: room only ranks do not interact with demote/promote
The function getNextGroupSymbol now takes an extra parameter to exclude room only ranks, which are defined in config.
The function will try to find the closest non room only rank with a safeguard against maliciously or badly crafted config.js to crash the server.
If no rank is found regardless of room only or not status, the first or last rank are returned accordingly.
This refactor allows getNextGroupSymbol's name to keep true to its functionality, while also providing a way to exclude crafted ranks for rooms or otherwise from the global demote/promote scheme.
2013-07-31 12:46:15 +02:00
Guangcong Luo
55e2e3ecd6 Deallocate users more aggressively
Specifically, if a user disconnects without ever choosing a name,
deallocate their object immediately
2013-07-28 01:48:47 -05:00
Guangcong Luo
950eafa544 Fix hole in throttler
Previously, /cmd was exempt from the throttler. This allowed an
amplification attack by sending a lot of /cmd's in one message,
which was responsible for the recent DoS attacks.

/cmd is now throttled normally, except for userdetails, which
happens instantly but is limited to once/message, so it can't
be used for anywhere near as much amplification.
2013-07-26 13:45:50 -07:00
Guangcong Luo
73a5ab895c Consolidate battle initialization
Preparing for a battle is now done in User.prototype.prepBattle
2013-07-26 13:45:50 -07:00
Guangcong Luo
cc3aa7d566 Resource Monitor 2013-07-24 21:55:33 -07:00
Guangcong Luo
a6608e5817 Refactor: Remove typeof ... === 'undefined' 2013-07-14 11:37:01 -07:00
Guangcong Luo
2a0981fc83 Refactor: sendData no longer a global
user.send and connection.send are already abstraction layers over
socket.write, so another abstraction layer is unnecessary.
2013-07-14 11:37:01 -07:00
Guangcong Luo
f91dd38d6f Less logging 2013-07-09 23:40:16 -07:00
Guangcong Luo
759e2aaaef More generalized per-room auth
Per-room auth is now less hardcoded. Promotion/demotion is still
done manually in commands.js, but at least users.js doesn't have
as much hardcoded.

A result of this is that /roomvoice is now possible.
2013-07-07 12:22:48 -07:00
Guangcong Luo
b61dace45d Minor users refactor
Raw sockets should be used less often; connections are now used
in most places instead.
2013-07-03 20:31:10 -07:00
Guangcong Luo
4ff26ea064 Support for per-room authority
- if room.auth exists, the room will have its own authority instead
  of global authority
- # is room owner, % is room moderator, admins are still there, and
  every other auth becomes voice
- % can mute/unmute/announce
- # can additionally roommod/deroommod/declare/modchat
- modchat is now per-room
2013-07-02 20:38:58 -07:00
Guangcong Luo
f1f3b6db98 Improved rooms support
- Rooms now stay in existence through restarts
- Room data is stored in config/chatrooms.json
- By default, there's a staff room autojoined by staff and joinable
  only by staff
2013-07-01 22:26:22 -07:00