Commit Graph

23 Commits

Author SHA1 Message Date
Guangcong Luo
86707e6ef5 Add new FS module
The new FS module is an abstraction layer over the built-in fs module.

The main reason it exists is because I need an abstraction layer I can
disable writing from. But that'll be in another commit.

Currently, mine is better because:
 - paths are always relative to PS's base directory
 - Promises (seriously wtf Node Core what are you thinking)
 - PS-style API: FS("foo.txt").write("bar") for easier argument order
 - mkdirp

This also increases the minimum supported Node version from v6.0 to
v7.7, because we now use async/await. Sorry for the inconvenience!
2017-06-23 14:29:13 -07:00
Guangcong Luo
a8393c40ed Support Config.loglevel
Another undocumented config setting; this one lets you specify what
you want to appear in standard out.
2017-02-25 02:48:16 -05:00
Guangcong Luo
9990a25385 Give higher battle limit to shared IPs 2017-02-25 02:35:32 -05:00
Guangcong Luo
e45b52a57b Fix DeprecationWarnings for lack of callback
Various standard library functions now warn for lack of callback, so
this commit adds those callbacks.
2017-02-10 17:10:15 -05:00
Guangcong Luo
d6f5404e7e Rename CommandParser to Chat
We had a lot of discussion in Dev and a somewhat-close poll, but in
the end "Chat" was a better name than "Messages", and also has the
advantage of being shorter (which is nice for Chat.html and
Chat.plural which should be short).
2016-09-30 18:31:15 -07:00
Guangcong Luo
da1b318707 Move text processing from Tools to CommandParser
The following functions have been renamed:

- Tools.html to CommandParser.html
- Tools.plural to CommandParser.plural
- Tools.escapeHTML to CommandParser.escapeHTML
- Tools.toDurationString to CommandParser.toDurationString
- Tools.toTimeStamp to CommandParser.toTimestamp
  (notice the lowercase 's')

This is in preparation for a rename of Tools to Dex (by removing the
non-dex-related functions) and a rename of CommandParser to either
Messages or Chat.
2016-09-30 18:04:13 -07:00
Guangcong Luo
8e4f762c23 ResourceMonitor: Warn less for too many battles 2016-09-25 23:47:00 -04:00
Guangcong Luo
c030c84245 Move "too many battles" messages to monitor.js 2016-09-10 15:52:16 -04:00
Guangcong Luo
604c0f181c Remove eslint-disable-line from monitor.js
(It's no longer needed)
2016-08-20 04:37:40 -05:00
Guangcong Luo
e3f1a3b9ff Shorten ResourceMonitor cflood messages 2016-08-20 04:32:38 -05:00
Guangcong Luo
85e739f353 Refactor ResourceMonitor
This is a major refactor.

countConnection, countBattle, countPrepBattle, and countGroupChat have
been rewritten to use a new TimedCounter class that extends Map. Newer
versions of V8 seem to deal poorly with hash-mode Objects, so I hope
this approach is better.

countBattle now reports to Monitor.adminlog (console log and Upper
Staff room if it exists) instead of Monitor.log. This makes it match
countConnection, since non-programmers can't really do anything about
it anyway.

The teamValidatorChanged/Unchanged counters have been removed. They
were added to measure the proportion of times a validator has resulted
in no changes (the answer is approximately 50%).

countNetworkUse is now only active in emergency mode. It does nothing
but take up RAM normally.

countCmd has been removed entirely. The original code was buggy (only
blocking 1 out of every 15 client queries even when spammed) and
was only active in emergency mode. It should probably be rewritten
from scratch the next time we have a need for it.
2016-08-20 04:24:55 -05:00
Guangcong Luo
99ee4f8ac3 Clear Monitor tables more often
For less RAM usage
2016-08-07 22:12:41 -04:00
Guangcong Luo
4a995350bb Shim Array#includes
This also refactors everything to use Array#includes except data
and mods, which are large enough that I'll refactor them later
probably.
2016-05-04 02:55:18 -07:00
Ivo Julca
66c00d29af Remove usage of String|Number methods implemented by Sugar.js
Implements Tools#toDurationString to replace Number#duration.
2016-03-09 16:55:40 -05:00
Guangcong Luo
f57c6273e5 Update Monitor.cleanInterval to new style 2016-02-16 03:49:04 -05:00
Guangcong Luo
ed160c475c Decrease ResourceMonitor blocked connection reports 2016-01-25 18:05:32 -05:00
Konrad Borowski
81f602b8d8 Always use trailing comma for multiline objects 2016-01-01 00:20:07 +01:00
Guangcong Luo
49c4dda506 Use Rooms() instead of Rooms.get() 2015-12-11 19:12:00 -05:00
Guangcong Luo
8937b15a22 Periodically clear caches to save RAM use
This actually saves a huge amount of RAM on the main server, like 1/3
or so of all our RAM use is from the monitors.
2015-12-10 10:58:56 -05:00
panpawn
9aef0065dd hotpatch: implement /hotpatch disable
Allows developers to turn off the usage of hotpatch.  (enabled by default)
2015-12-04 20:44:48 +00:00
Ivo Julca
7dddb66253 Migrate build system to ESLint
JSHint's ES6 support is shaky, and its development has stalled as of late.
Since ESLint can do by itself both JSHint and JSCS' jobs, this commit replaces them.
Gulp and its related dependencies are also hereby removed.
2015-11-07 21:36:49 -05:00
Juanma Serrano
c4ac8d6e2f Use strict mode and let and const instead of var
This commit also fixes some duplicated variable declarations.
2015-11-06 21:56:52 -05:00
Guangcong Luo
ab71ae20fe Refactor ResourceMonitor into monitor.js
ResourceMonitor has been moved from app.js into monitor.js and
renamed to simply Monitor. It also gains the ability to fine-
grained control the log level, although in a pretty crude way.

Monitor.debug - bugs in PS's engine that we need to fix
someday - by default, these aren't reported

Monitor.warn - issues that suggest an attacker or poorly
coded custom client - these should probably be looked at

Monitor.notice - issues that staff probably want to know.
These are usually also written to the Staff room.
2015-10-04 17:02:17 -04:00