Commit Graph

292 Commits

Author SHA1 Message Date
Cathy J. Fitzpatrick
e660fa2022 Fix the config.proxyip feature 2013-05-06 17:36:20 -06:00
Cathy J. Fitzpatrick
212ac72dc8 Less obfuscated creation of default config.js file 2013-05-05 14:50:22 -06:00
Cathy J. Fitzpatrick
fb80b1d956 Less obfuscated fallback for fs.existsSync 2013-05-05 14:50:22 -06:00
Guangcong Luo
46473676c7 Sanitize whitespace characters in names 2013-05-05 02:36:00 -07:00
Guangcong Luo
f60e20f5cd Another toName fix 2013-05-04 18:03:46 -07:00
Guangcong Luo
9ee457cad9 Fix toName sanitization 2013-05-04 17:58:17 -07:00
Cathy J. Fitzpatrick
f64226138e Implement SSL option
This isn't documented in config.js because it's currently only
really usable by the main server.
2013-05-01 05:46:08 -07:00
Cathy J. Fitzpatrick
318db7bd30 Rate limit crash broadcasting to once per five minutes 2013-04-30 00:21:47 -06:00
Guangcong Luo
69ff7ccb6f Split the lobby into ChatRoom and GlobalRoom 2013-04-28 01:26:00 -07:00
Cathy J. Fitzpatrick
072bb5e042 Remove legacy code for old protocols 2013-04-26 04:22:17 -06:00
Cathy J. Fitzpatrick
9d60ccb58a Add support for custom HTTP responses 2013-04-25 21:17:58 -06:00
Cathy J. Fitzpatrick
838a33b691 Fewer module-level variables in app.js 2013-04-25 21:05:20 -06:00
Cathy J. Fitzpatrick
2d2b183802 Move the LoginServer object to loginserver.js 2013-04-25 17:17:38 -06:00
Guangcong Luo
3b24ef347d Update README with new nicer URIs
The message on server start has been updated, too
2013-04-25 16:00:03 -07:00
Cathy J. Fitzpatrick
5854da2c62 Move crash logging to new file: crashlogger.js 2013-04-25 00:14:36 -06:00
Cathy J. Fitzpatrick
387b7974f3 Revisions to crash logging
- crash logging is now handled by `Tools.logCrash`
- simulator processes now send crash emails as well
- emails are now rate limited to 1 email per 5 minutes per process
2013-04-24 23:53:47 -06:00
Cathy J. Fitzpatrick
d8d3d897be Implement email crash logging 2013-04-24 23:20:29 -06:00
Cathy J. Fitzpatrick
f454177364 Changes to static file serving
- /static/custom.css is now located at /config/custom.css
- /static/avatars/ is now located at /config/avatars/
- The redirect script now redirects all room URIs, not just the root
  path. For example, if you are running a server on localhost port 8000,
  visiting http://localhost:8000/teambuilder will now take you to the
  teambuilder. This works for any room.
2013-04-24 20:41:49 -06:00
Cathy J. Fitzpatrick
3d65a9b180 Fix some indentation in app.js 2013-04-24 16:19:35 -06:00
Cathy J. Fitzpatrick
2d8b489bc1 Add support for serving static files over HTTP 2013-04-24 01:37:58 -06:00
Cathy J. Fitzpatrick
876d2191c1 sockjs now runs under /showdown prefix 2013-04-24 01:03:46 -06:00
Cathy J. Fitzpatrick
77f0c127a0 Implement sockjs hack for Heroku
See https://github.com/sockjs/sockjs-node/issues/57#issuecomment-5242187
2013-04-23 21:24:29 -06:00
Cathy J. Fitzpatrick
4f42bd525c Introduce global variable Server
This allows us to access the sockjs server using the console.
2013-04-23 19:54:21 -06:00
Cathy J. Fitzpatrick
62c5e5af89 Drop warnings about broken versions of node
These warnings were more important when the latest stable version of
node was broken. Now that the latest stable version has been fixed for
a while, these specific warnings are not necessary.
2013-04-18 21:26:44 -06:00
Cathy J. Fitzpatrick
5935c33aef Require tools.js after beginning to listen for connections 2013-04-14 17:06:37 -06:00
Cathy J. Fitzpatrick
4486d09372 Remove message about old login server public key 2013-04-14 16:53:31 -06:00
Cathy J. Fitzpatrick
0c846d0fe1 More optimised watchconfig feature 2013-04-14 16:52:45 -06:00
Cathy J. Fitzpatrick
bb6de78b92 Refactor login server code
This allows a server to use different login server URIs for handling
different actions. This is mainly intended to be potentially used by
the main server.
2013-04-01 19:31:35 -06:00
Cathy J. Fitzpatrick
4572ea8f92 Fix MMR retrieval
This fixes MMR retrieval, which has unfortunately been broken since
Zarel/Pokemon-Showdown-Client@83fe1d5b72
2013-04-01 18:41:40 -06:00
Cathy J. Fitzpatrick
f448e35173 node v0.10.2 has been released and is not broken 2013-03-30 05:58:15 -06:00
Cathy J. Fitzpatrick
36b3f173dd Note that node v0.10.0 and v0.10.1 are broken 2013-03-25 22:53:42 -06:00
Cathy J. Fitzpatrick
3db30bb344 Remove the requireGracefully function 2013-03-24 23:23:42 -06:00
Cathy J. Fitzpatrick
5265a78b07 Automatically run npm install or npm update if necessary 2013-03-24 23:18:06 -06:00
Cathy J. Fitzpatrick
133afb2619 Add check for outdated version of sugar to app.js 2013-03-24 22:40:59 -06:00
Cathy J. Fitzpatrick
11694d5b3d Update URIs to *.psim.us where appropriate 2013-03-22 03:24:38 -06:00
Cathy J. Fitzpatrick
321236215f Fix presumably accidental global youUser in app.js 2013-03-10 12:25:55 -06:00
Cathy J. Fitzpatrick
05b769d9af Changes re: client no longer running arbitrary server CSS/JavaScript
As of Zarel/Pokemon-Showdown-Client@5950a2dbbd, the client will no
longer run arbitrary JavaScript or `style` tags received from the
server. This commit makes various changes in response to this:

- Various chat commands now send `class` attributes rather than
  `style` attributes.

- The /redirect command is removed.

- The /banredirect command is removed.
2013-02-12 02:56:59 -07:00
Cathy J. Fitzpatrick
22770b0117 Fix setuid feature
The call to setuid() was previously after the simulator and verifier
processes were spawned, so both those processes always ran as the user
who started the process (which would have been `root` if the setuid
feature was being used), rather than the setuid user. In particular,
this meant that the >>> battle dev console could be used to execute
arbitrary code as root (if the server was started as root).

This commit makes the setuid() feature work as advertised, but it
still should not be used for the reasons given in config-example.js.
Instead of using setuid, start the server as an unprivileged user and
use port forwarding (e.g. iptables ) to use the port(s) you prefer.
2013-02-09 19:45:29 -07:00
Cathy J. Fitzpatrick
cd5954d32c Delete call to nodetime.profile 2013-02-09 04:29:20 -07:00
Cathy J. Fitzpatrick
21f7b105d3 Remove some unnecessary code from app.js 2013-02-09 04:28:01 -07:00
Cathy J. Fitzpatrick
4192289269 Refactor: Don't require client to send username in join message 2013-02-08 22:33:41 -07:00
Cathy J. Fitzpatrick
627ca0d38d New login server public key 2013-02-08 01:13:12 -07:00
Cathy J. Fitzpatrick
7dbd8cfec5 Implement challenge-response authentication 2013-02-08 00:52:42 -07:00
Cathy J. Fitzpatrick
b5f144a9aa Remove unnecessary code from app.js 2013-02-01 22:07:37 -07:00
Cathy J. Fitzpatrick
9a1c2679e1 Add feature to watch config file for changes 2013-02-01 22:01:20 -07:00
Cathy J. Fitzpatrick
0d67aa1f35 Display helpful message for missing module
This should help users understand that they need to run npm install.
2013-01-21 21:15:20 -07:00
Guangcong Luo
d361c0cbf1 Increase login server timeout, might decrease ladder strain 2013-01-02 17:10:08 -08:00
Guangcong Luo
45b5dc0043 Configurable batch time for ladder queries 2013-01-02 16:39:41 -08:00
Guangcong Luo
82fc0142dd Emergency ladder enabling/disabling functions 2013-01-02 07:59:38 -08:00
Guangcong Luo
578550908f Better error messages for ladder server issues 2012-12-16 16:57:25 -08:00
Guangcong Luo
fd512f4fc4 More efficient toId implementation 2012-12-14 19:05:30 -08:00
Guangcong Luo
cae58c2fde More consistent name validation 2012-12-14 18:58:18 -08:00
Guangcong Luo
c9045cb538 Update link for hosting a server 2012-12-07 02:44:51 -08:00
Guangcong Luo
95a195b83b Handle the X-Forwarded-For header securely
Namely, don't trust it unless it's on a list of secure IPs
and trust nothing by default.
2012-11-25 16:47:05 -08:00
小太
a80a77cac1 Fix whitespace issues 2012-10-21 19:30:50 +11:00
Guangcong Luo
52d57a52c1 Remove a lot of code from the old protocol 2012-10-02 22:45:09 -07:00
Bill Meltsner
4d2907d2ce Check the user token's type to ensure it's a string, and thus won't break anything that assumes it is. 2012-09-13 00:22:59 -07:00
Guangcong Luo
955fe3948e Reduce the login server timeout to 10 seconds
(this is on the off chance that a login server stall is causing our lag spikes)
2012-08-17 21:43:08 -07:00
Guangcong Luo
c2d09f55b2 New protocol - significantly reduced network usage 2012-08-14 20:02:56 -07:00
Guangcong Luo
ea746cf2ca Don't crash on malformed JSON 2012-08-14 16:59:34 -07:00
Guangcong Luo
59959ce24e Chat commands for most user actions
- we're moving to a new protocol! wheee!
2012-08-12 13:44:59 -07:00
Guangcong Luo
641f4c153c Support engine.io 2012-08-10 18:55:12 -07:00
Guangcong Luo
91f3f20364 Comment out some unnecessary logging 2012-08-10 09:54:05 -07:00
Guangcong Luo
1d31929db8 Time out requests and responses after 2 seconds each 2012-08-08 23:50:40 -07:00
Guangcong Luo
efc9d77f58 Time out requests after 3 minutes 2012-08-08 22:37:33 -07:00
Guangcong Luo
1b5d406fa3 Some improvements to login/ladder server connection 2012-08-08 13:20:11 -07:00
Guangcong Luo
47c7e02464 Batched ladder requests 2012-08-07 19:21:53 -07:00
Guangcong Luo
2ab4f287db New request API
(preparation for batched requests)
2012-08-05 00:10:04 -07:00
Guangcong Luo
445b840411 Disconnect is now handled separately 2012-08-04 00:56:44 -07:00
Guangcong Luo
878a3f9b11 Implement the disconnect event correctly 2012-08-04 00:51:45 -07:00
Guangcong Luo
4831e68a8c Multi-process battles!
Battles now occur in a separate process.
Hopefully, this results in a substantial increase in network stability.
WARNING: Battle crashes are now practically unrecoverable.
2012-08-01 13:48:58 -07:00
Guangcong Luo
31e642c5a2 Rename simulator.js to battles.js 2012-07-31 19:48:09 -07:00
Guangcong Luo
a230425dcd Fixes to verifier 2012-07-29 14:23:05 -07:00
Patrick Roberts
2325ed9c9a connection grabs IP from behind proxy and fs stream doesn't throw exception now 2012-07-28 23:22:36 -05:00
Guangcong Luo
b801be60c0 Normalize set variables 2012-07-28 17:28:42 -07:00
Guangcong Luo
8b0ee28f21 Hopefully this will make request limiting work properly 2012-07-23 23:30:15 -07:00
Guangcong Luo
8c7449d441 Try to limit the number of open requests 2012-07-23 23:25:49 -07:00
Guangcong Luo
1dc63e446f Even fewer console messages 2012-07-23 23:25:49 -07:00
Guangcong Luo
ba78f59052 Continue cutting down on what we print to console 2012-07-23 13:36:11 -07:00
Guangcong Luo
5df400c39e Support Node 0.6 and 0.8 2012-07-20 23:53:57 -07:00
Guangcong Luo
b654c5f5b6 path.existsSync is now fs.existsSync in Node 0.8 2012-07-20 14:33:53 -07:00
Guangcong Luo
12dac23bb1 setuid support 2012-07-20 13:43:24 -07:00
Guangcong Luo
0db9ffc394 Severely cut down on the number of debug messages 2012-07-17 12:45:25 -07:00
Guangcong Luo
6a4f08f26b New request code - maybe it'll be better on the server? 2012-07-16 17:09:32 -07:00
Bill Meltsner
22cd7cab27 Guard against the mysterious and seemingly impossible situation where someone successfully connects with a null socket. 2012-07-08 20:38:06 -05:00
Bill Meltsner
c31ee2a428 Add SockJS as the default networking library.
You can still use Socket.IO by setting config.protocol in config.js.
2012-07-06 22:56:28 -05:00
Guangcong Luo
b3054fefdf Load all data using tools.js
- the original names BattleItems etc have been deprecated; please use:
  - Tools.getItem() accessor method if possible
  - Tools.data.Items for lower-level access (e.g. iteration)
- app.js was also rearranged a bit
2012-06-13 22:51:37 -07:00
Guangcong Luo
12e9b5458b Make tools.js support mods (past gens)
- replace Tools.foo with Tools.mod('gen4').foo for gen 4 tools
- mods are stored in mods/modname/ in the same directory structure as data/
- mods modify base data
- further documentation coming soon in mods/modding.md
2012-06-13 08:27:32 -07:00
Bill Meltsner
651881e2f1 Temporarily disable JSONP in Socket.io until https://github.com/LearnBoost/socket.io/issues/609 is fixed. 2012-06-09 01:18:33 -05:00
Guangcong Luo
7009b3a4bb Revert bmelts's hasty porting of Id etc to Sugar.js extensions
- The reverted utility functions, toId/toUserid/sanitize/clampIntRange, were designed to handle unsanitized data gracefully
2012-06-08 15:44:49 -07:00
Guangcong Luo
37c8fca226 Even fewer globals:- getRoom -> Rooms.get, newRoom -> Rooms.create
- getUser -> Users.get
- getTime has been entirely removed; new Date().getTime() isn't that long
2012-06-08 14:51:40 -07:00
Guangcong Luo
e4f5686dc2 Fewer globals:
- serverid and servertoken are now only available as config.serverid and config.servertoken
- lobby is now only available as rooms.lobby
2012-06-08 14:38:13 -07:00
Guangcong Luo
ce506d3b3e Rooms cleanup:
- Renamed: Room -> BattleRoom, Lobby -> LobbyRoom
- rooms.js is now its own file; app.js is now no longer huge
2012-06-08 14:32:48 -07:00
Guangcong Luo
e73c587e7d Move a bunch of files into data/
also take this opportunity to rename movedex.js -> moves.js
2012-06-08 14:25:45 -07:00
Bill Meltsner
caaef761cf Restore individual case-checking for user IDs in the 'challenge' message. 2012-06-03 15:27:46 -05:00
Bill Meltsner
c63593fdd7 Stylistic cleanup. 2012-06-03 13:47:35 -05:00
Bill Meltsner
a38f78d53b Take more caution with what we accept from the client. 2012-06-03 13:46:31 -05:00
Bill Meltsner
7499f3f81c Limit the size of the server-side chatlog.
We're now only keeping the last 100ish messages (100 plus any that arrived between updates). There's really no good reason to keep the entire thing in memory. This should also hopefully mitigate some of the lag issues.
2012-06-02 15:49:33 -05:00
Guangcong Luo
048d06239e Chat throttling implemented
Happens mostly in users.js. Now, chatting is proxied through users.js, which handles throttling.
I tried to write my code to avoid race conditions, but I'm not entirely sure if I succeeded.
2012-05-31 02:42:52 -07:00
Bill Meltsner
4f729aae7f Refactor most utility functions (toId, clampIntRange, etc.) into Sugar extensions of the relevant objects. 2012-05-24 01:41:01 -05:00
Guangcong Luo
41b670ad37 Add a new dependency: sugar
also clean up our includes a bit
2012-05-16 21:56:29 -07:00
Guangcong Luo
e9474d9745 Add some basic help information when starting the server 2012-05-16 21:56:28 -07:00
Guangcong Luo
588a6d5b48 Create a default config.js if it doesn't exist 2012-05-16 20:26:49 -04:00
Bill Meltsner
91541f50d4 Remove tiers.js completely.
Rest in peace.
2012-05-15 17:32:54 -04:00
Guangcong Luo
fedc12d35f Consolidate formats data in formats-data.js 2012-05-15 16:07:35 -04:00
Guangcong Luo
015fb9a6fa Prevent crash from invalid rooms 2012-05-12 18:12:07 -04:00
Patrick Roberts
6d6c00e1c5 Added NameLock Command Implementation 2012-04-27 14:52:20 -05:00
小太
9f11d4a7c2 New permissions system.
/help is only partially done though.
2012-04-20 17:29:01 +10:00
小太
c592a5ae65 Fixed the fix 2012-04-16 14:29:07 +10:00
小太
f03d2f516f Proper four spaces -> single tab 2012-04-16 14:22:08 +10:00
小太
33162d2501 Revert "Four spaces -> Single tab"
This reverts commit 8f8d387f56.
2012-04-16 14:09:07 +10:00
小太
8f8d387f56 Four spaces -> Single tab 2012-04-16 12:55:40 +10:00
小太
dfca43114d Move braces to the same line as their control statements 2012-04-16 12:54:03 +10:00
小太
64d876f1ca Begone, trailing whitespace!
Also converted all line endings to UNIX format
2012-04-16 12:03:15 +10:00
Guangcong Luo
2a12da42af Even more validation 2012-04-14 12:59:32 -04:00
Guangcong Luo
82035632d7 More client packet validation 2012-04-13 21:52:10 -04:00
Guangcong Luo
12e559c330 Whoops - suppress commands from battles, too 2012-04-13 19:32:25 -04:00
Guangcong Luo
0018800c0c My apologies to server runners, but chat-commands has been changed.
Namely, the meaning of return true and return false have been changed, to better match other event handlers
You can now return a string from parseCommand to have the user say that message. Used mainly to automatically escape messages, but could also be used for a profanity filter or something.
I also commented it a bit more.
2012-04-13 03:57:51 -04:00
Guangcong Luo
607b384099 Don't really need a debug message for ladder update 2012-04-12 00:09:37 -04:00
Guangcong Luo
4d7a209fc3 Better error messages 2012-04-09 22:23:03 -04:00
Guangcong Luo
459bfed0ec Remove message length limits from sysops 2012-04-09 20:03:34 -04:00
Guangcong Luo
1acea3caa5 More renames: allySide -> p1, foeSide -> p2 2012-04-09 18:46:13 -04:00
Guangcong Luo
28b12f2f70 More of the forme name changes 2012-04-08 18:03:39 -04:00
Guangcong Luo
fde681f1e2 Capitalize names correctly in battles 2012-04-05 23:57:05 -04:00
Guangcong Luo
45b75d729d Update toId everywhere to the new IDs 2012-04-05 22:00:49 -04:00
Guangcong Luo
ad9420197e Update (hopefully) all remaining battle messages to new format 2012-04-05 22:00:01 -04:00
Guangcong Luo
5ae4dbf188 Fully working /data and !data commands! 2012-04-05 11:16:35 -04:00
Guangcong Luo
73fa46a3cf Attempts to make !data work 2012-04-05 02:02:07 -04:00
Bill Meltsner
391ed6efbd Modify selfB.add to generate the proper log message format from the passed arguments. 2012-03-29 04:04:48 -05:00
Bill Meltsner
fbbfa47a50 Upgrade chat messages. 2012-03-29 03:01:44 -05:00
Bill Meltsner
16204be2f6 Upgrade the restart callback message. 2012-03-29 03:01:17 -05:00
Bill Meltsner
85349e1444 Upgrade join/leave messages. 2012-03-29 01:22:37 -05:00
Bill Meltsner
b38b8ff431 Forgot a pipe. 2012-03-29 00:50:17 -05:00
Bill Meltsner
0c136e040e Upgrade the join command. 2012-03-29 00:47:42 -05:00
Bill Meltsner
626a975029 Nomenclature change: "ranked" -> "rated" 2012-03-28 03:43:02 -05:00
Guangcong Luo
c3bae8b437 Show your rejected message if it was too long in lobby, too 2012-03-21 00:57:45 -04:00
Guangcong Luo
76e8fd458c Show the rejected message if it was too long. 2012-03-19 23:48:30 -04:00
Guangcong Luo
823dcd765c More changes to the inactivity timer:
- time before clicking 'kick inactive' now counts 2:1 instead of 4:1
- if you've stalled too much, you'll go down to 30sec/turn, below the usual 60sec minimum
- you'll get a notice when trying to start the timer when it's already started
2012-03-08 19:31:28 -05:00
Guangcong Luo
a98575733d Clamp down a bit on the timer:
- users start with 8 ticks instead of 9
2012-03-08 16:05:06 -05:00
Guangcong Luo
53cb0b985a Encourage users to register if they win a ladder match 2012-03-08 16:03:42 -05:00
Guangcong Luo
576bbd9b54 Inactive users tick down their timers properly now 2012-03-08 16:02:20 -05:00
Guangcong Luo
f9deac88be More effective ban code - previous method accidentally relied on cookies. 2012-03-07 13:18:04 -05:00
Guangcong Luo
8b7e9ff367 Allow muted users to use 'kick inactive', etc
(Moved a lot of battle-room commands to chat-commands.js)
2012-03-04 11:42:48 -05:00
Guangcong Luo
2ed88eb21f Server support for clicking on a user to get their avatar/rooms 2012-03-04 09:38:53 -05:00
Guangcong Luo
971cfa89ef Fix crash in getRoomList 2012-03-03 13:43:18 -05:00
Guangcong Luo
b0bb7597e8 getRoomList updated:
- now shows most recent 8 battles, not 6
- inactive rooms are now skipped correctly
- new syntax: getRoomList(true) to get all battles, not just most recent 8
2012-03-02 11:56:13 -05:00
Guangcong Luo
5cec184cae Report joins/leaves as deltas only:
- The entire user-list can now be shown, lag-less, no matter how many users are online
- config.lagmode is no longer needed
2012-03-02 08:14:51 -05:00
Guangcong Luo
30cbb1dd92 Report the 6 newest battles, not the 24 oldest 2012-03-02 08:12:13 -05:00
Guangcong Luo
12e6df3fed Improve getUser
- /ban, /mute, etc are no longer foiled by name changes
- The entire user list can be accessed from anywhere in PS as Users.users
2012-02-28 09:01:58 -05:00
Guangcong Luo
9eef7e79fb And now, the real implementation of /me 2012-02-27 09:59:38 -05:00